From 5b2abdfbf4211b6592cdd02b9507555a0ecbb04b Mon Sep 17 00:00:00 2001 From: Apple Date: Mon, 15 Jul 2002 23:57:42 +0000 Subject: [PATCH] Libc-262.tar.gz --- APPLE_LICENSE | 372 ++++ CLIB-LIST | 679 +++++++ GNUmakefile | 211 ++ Info.plist | 1 + MISSING-MANPAGE | 9 + MISSING_SYSCALLS | 8 + Makefile | 99 +- Makefile.inc | 66 + Makefile.postamble | 12 - Makefile.preamble | 12 - Makefile.xbs | 125 ++ PB.project | 50 - REQUIRED-MACROS | 3 + SYSCALL-LIST | 142 ++ compat-43/Makefile.inc | 18 + compat-43/creat.2 | 64 + {compat43.subproj => compat-43}/creat.c | 0 compat-43/gethostid.3 | 78 + {compat43.subproj => compat-43}/gethostid.c | 0 {compat43.subproj => compat-43}/getwd.c | 0 compat-43/killpg.2 | 96 + {compat43.subproj => compat-43}/killpg.c | 0 {compat43.subproj => compat-43}/send.c | 0 {compat43.subproj => compat-43}/sethostid.c | 0 {compat43.subproj => compat-43}/setpgrp.c | 0 {compat43.subproj => compat-43}/setregid.c | 0 {compat43.subproj => compat-43}/setreuid.c | 0 {compat43.subproj => compat-43}/setrgid.c | 0 compat-43/setruid.3 | 84 + {compat43.subproj => compat-43}/setruid.c | 0 compat-43/sigblock.2 | 87 + {compat43.subproj => compat-43}/sigcompat.c | 25 + compat-43/sigpause.2 | 77 + compat-43/sigsetmask.2 | 85 + compat-43/sigvec.2 | 327 +++ compat43.subproj/Makefile | 47 - compat43.subproj/Makefile.postamble | 100 - compat43.subproj/Makefile.preamble | 137 -- compat43.subproj/PB.project | 36 - db.subproj/Makefile | 51 - db.subproj/Makefile.postamble | 100 - db.subproj/Makefile.preamble | 137 -- db.subproj/PB.project | 26 - db.subproj/btree.subproj/Makefile | 56 - db.subproj/btree.subproj/Makefile.postamble | 100 - db.subproj/btree.subproj/Makefile.preamble | 3 - db.subproj/db.subproj/Makefile | 45 - db.subproj/db.subproj/Makefile.postamble | 100 - db.subproj/db.subproj/Makefile.preamble | 137 -- db.subproj/db.subproj/PB.project | 23 - db.subproj/hash.subproj/Makefile | 48 - db.subproj/hash.subproj/Makefile.postamble | 100 - db.subproj/hash.subproj/Makefile.preamble | 137 -- db.subproj/hash.subproj/PB.project | 32 - db.subproj/mpool.subproj/Makefile | 45 - db.subproj/mpool.subproj/Makefile.postamble | 100 - db.subproj/mpool.subproj/Makefile.preamble | 137 -- db.subproj/mpool.subproj/PB.project | 23 - db.subproj/recno.subproj/Makefile | 48 - db.subproj/recno.subproj/Makefile.postamble | 100 - db.subproj/recno.subproj/Makefile.preamble | 137 -- db.subproj/recno.subproj/PB.project | 32 - db/Makefile.inc | 11 + db/btree/Makefile.inc | 8 + .../btree.subproj => db/btree}/PB.project | 0 .../btree.subproj => db/btree}/bt_close.c | 0 .../btree.subproj => db/btree}/bt_conv.c | 0 .../btree.subproj => db/btree}/bt_debug.c | 0 .../btree.subproj => db/btree}/bt_delete.c | 0 .../btree.subproj => db/btree}/bt_extern.h | 0 .../btree.subproj => db/btree}/bt_get.c | 0 .../btree.subproj => db/btree}/bt_open.c | 0 .../btree.subproj => db/btree}/bt_overflow.c | 0 .../btree.subproj => db/btree}/bt_page.c | 0 .../btree.subproj => db/btree}/bt_put.c | 0 .../btree.subproj => db/btree}/bt_search.c | 0 .../btree.subproj => db/btree}/bt_seq.c | 0 .../btree.subproj => db/btree}/bt_split.c | 0 .../btree.subproj => db/btree}/bt_stack.c | 0 .../btree.subproj => db/btree}/bt_utils.c | 0 .../btree.subproj => db/btree}/btree.h | 0 db/db/Makefile.inc | 6 + {db.subproj/db.subproj => db/db}/db.c | 0 db/hash/Makefile.inc | 7 + {db.subproj/hash.subproj => db/hash}/extern.h | 0 {db.subproj/hash.subproj => db/hash}/hash.c | 0 {db.subproj/hash.subproj => db/hash}/hash.h | 0 .../hash.subproj => db/hash}/hash_bigkey.c | 0 .../hash.subproj => db/hash}/hash_buf.c | 0 .../hash.subproj => db/hash}/hash_func.c | 0 .../hash.subproj => db/hash}/hash_log2.c | 0 .../hash.subproj => db/hash}/hash_page.c | 0 .../hash.subproj => db/hash}/hsearch.c | 0 {db.subproj/hash.subproj => db/hash}/ndbm.c | 0 {db.subproj/hash.subproj => db/hash}/page.h | 0 {db.subproj/hash.subproj => db/hash}/search.h | 0 db/man/Makefile.inc | 20 + db/man/btree.3 | 272 +++ db/man/dbm.3 | 196 ++ db/man/dbopen.3 | 539 +++++ db/man/hash.3 | 191 ++ db/man/mpool.3 | 238 +++ db/man/recno.3 | 232 +++ db/mpool/Makefile.inc | 6 + .../mpool.subproj => db/mpool}/mpool.c | 0 db/recno/Makefile.inc | 9 + .../recno.subproj => db/recno}/extern.h | 0 .../recno.subproj => db/recno}/rec_close.c | 0 .../recno.subproj => db/recno}/rec_delete.c | 0 .../recno.subproj => db/recno}/rec_get.c | 0 .../recno.subproj => db/recno}/rec_open.c | 0 .../recno.subproj => db/recno}/rec_put.c | 0 .../recno.subproj => db/recno}/rec_search.c | 0 .../recno.subproj => db/recno}/rec_seq.c | 0 .../recno.subproj => db/recno}/rec_utils.c | 0 .../recno.subproj => db/recno}/recno.h | 0 dpkg/control | 4 + gen.subproj/Makefile | 72 - gen.subproj/Makefile.postamble | 4 - gen.subproj/Makefile.preamble | 2 - gen.subproj/PB.project | 108 - gen.subproj/i386.subproj/Makefile | 50 - gen.subproj/i386.subproj/Makefile.postamble | 100 - gen.subproj/i386.subproj/Makefile.preamble | 137 -- gen.subproj/i386.subproj/PB.project | 43 - gen.subproj/ppc.subproj/Makefile | 53 - gen.subproj/ppc.subproj/Makefile.postamble | 100 - gen.subproj/ppc.subproj/Makefile.preamble | 137 -- gen.subproj/ppc.subproj/PB.project | 41 - gen.subproj/ppc.subproj/blockmoof.s | 940 --------- gen.subproj/ppc.subproj/bzero.s | 79 - gen.subproj/ppc.subproj/strlen.s | 100 - gen/Makefile.inc | 139 ++ {gen.subproj => gen}/NSSystemDirectories.c | 6 +- gen/_rand48.c | 46 + gen/alarm.3 | 98 + {gen.subproj => gen}/alarm.c | 0 gen/arc4random.3 | 89 + gen/arc4random.c | 177 ++ {gen.subproj => gen}/assert.c | 0 gen/authentication.c | 101 + gen/basename.3 | 101 + gen/basename.c | 83 + gen/clock.3 | 80 + {gen.subproj => gen}/clock.c | 0 {gen.subproj => gen}/closedir.c | 0 gen/confstr.3 | 136 ++ {gen.subproj => gen}/confstr.c | 0 {gen.subproj => gen}/crypt.c | 0 gen/ctermid.3 | 109 + {gen.subproj => gen}/ctermid.c | 0 {gen.subproj => gen}/ctime.c | 0 gen/daemon.3 | 81 + {gen.subproj => gen}/daemon.c | 0 gen/devname.3 | 72 + {gen.subproj => gen}/devname.c | 46 +- {gen.subproj => gen}/difftime.c | 0 gen/directory.3 | 200 ++ gen/dirname.3 | 108 + gen/dirname.c | 86 + {gen.subproj => gen}/disklabel.c | 0 gen/drand48.c | 22 + gen/erand48.c | 23 + gen/err.3 | 230 +++ {gen.subproj => gen}/err.c | 0 {gen.subproj => gen}/errlst.c | 0 gen/exec.3 | 296 +++ {gen.subproj => gen}/exec.c | 0 gen/fmtcheck.3 | 108 + gen/fnmatch.3 | 151 ++ {gen.subproj => gen}/fnmatch.c | 120 +- gen/frexp.3 | 88 + gen/fstab.c | 225 +++ {gen.subproj => gen}/ftok.3 | 46 +- {gen.subproj => gen}/ftok.c | 0 gen/fts.3 | 761 +++++++ {gen.subproj => gen}/fts.c | 0 gen/getbootfile.3 | 72 + gen/getbsize.3 | 82 + {gen.subproj => gen}/getbsize.c | 0 gen/getcap.3 | 542 +++++ {gen.subproj => gen}/getcap.c | 0 gen/getcwd.3 | 158 ++ {gen.subproj => gen}/getcwd.c | 0 gen/getdomainname.3 | 98 + gen/getfsent.3 | 153 ++ gen/getgrent.3 | 203 ++ gen/getgrouplist.3 | 96 + string.subproj/strtok.c => gen/getgrouplist.c | 88 +- gen/gethostname.3 | 99 + {gen.subproj => gen}/gethostname.c | 0 gen/getloadavg.3 | 69 + {gen.subproj => gen}/getloadavg.c | 0 {gen.subproj => gen}/getlogin.c | 11 +- gen/getmntinfo.3 | 113 ++ {gen.subproj => gen}/getmntinfo.c | 0 gen/getnetgrent.3 | 133 ++ gen/getobjformat.3 | 128 ++ gen/getpagesize.3 | 63 + {gen.subproj => gen}/getpagesize.c | 0 gen/getpass.3 | 96 + {gen.subproj => gen}/getpass.c | 0 gen/getpeereid.3 | 134 ++ gen/getpwent.3 | 218 ++ gen/getttyent.3 | 212 ++ {gen.subproj => gen}/getttyent.c | 11 +- gen/getusershell.3 | 103 + {gen.subproj => gen}/getusershell.c | 0 gen/getvfsbyname.3 | 97 + {gen.subproj => gen}/getvfsbyname.c | 0 gen/getvfsent.3 | 183 ++ gen/glob.3 | 466 +++++ gen/glob.c | 864 ++++++++ .../i386.subproj/bzero.c => gen/hton.c | 30 +- gen/initgroups.3 | 86 + {gen.subproj => gen}/isatty.c | 0 gen/isinf.3 | 80 + {gen.subproj => gen}/isnan.c | 0 gen/jrand48.c | 21 + gen/lcong48.c | 30 + gen/ldexp.3 | 80 + gen/lockf.3 | 254 +++ gen/lockf.c | 92 + gen/lrand48.c | 23 + {gen.subproj => gen}/malloc.c | 157 -- gen/modf.3 | 75 + gen/mrand48.c | 23 + gen/msgctl.3 | 206 ++ gen/msgget.3 | 139 ++ gen/msgrcv.3 | 202 ++ gen/msgsnd.3 | 167 ++ {gen.subproj => gen}/nanosleep.c | 0 gen/nice.3 | 73 + {gen.subproj => gen}/nice.c | 0 gen/nlist.3 | 77 + {gen.subproj => gen}/nlist.c | 5 +- gen/nrand48.c | 21 + {gen.subproj => gen}/opendir.c | 0 gen/pause.3 | 86 + {gen.subproj => gen}/pause.c | 0 gen/popen.3 | 201 ++ {gen.subproj => gen}/popen.c | 0 gen/psignal.3 | 113 ++ {gen.subproj => gen}/psignal.c | 0 gen/pwcache.3 | 96 + net.subproj/iso_addr.c => gen/pwcache.c | 159 +- gen/raise.3 | 77 + {gen.subproj => gen}/raise.c | 0 gen/rand48.3 | 167 ++ gen/rand48.h | 30 + gen/rcmd.c | 429 ++++ {gen.subproj => gen}/readdir.c | 0 gen/readdir_r.c | 51 + {gen.subproj => gen}/rewinddir.c | 0 gen/rfork_thread.3 | 77 + {gen.subproj => gen}/scalable_malloc.c | 422 ++-- {gen.subproj => gen}/scalable_malloc.h | 0 gen/scandir.3 | 109 + {gen.subproj => gen}/scandir.c | 0 gen/seed48.c | 36 + {gen.subproj => gen}/seekdir.c | 0 {gen.subproj => gen}/sethostname.c | 0 gen/setjmp.3 | 176 ++ {gen.subproj => gen}/setlogin.c | 0 gen/setmode.3 | 118 ++ {gen.subproj => gen}/setmode.c | 47 +- gen/siginterrupt.3 | 122 ++ {gen.subproj => gen}/siginterrupt.c | 0 {gen.subproj => gen}/siglist.c | 0 gen/signal.3 | 243 +++ {gen.subproj => gen}/signal.c | 0 gen/sigsetops.3 | 116 ++ {gen.subproj => gen}/sigsetops.c | 13 + gen/sleep.3 | 86 + {gen.subproj => gen}/sleep.c | 0 gen/srand48.c | 30 + {gen.subproj => gen}/stack_logging.c | 2 +- {gen.subproj => gen}/stack_logging.h | 0 gen/strchr.c | 41 + gen/stringlist.3 | 124 ++ gen/strtofflags.3 | 99 + gen/strtofflags.c | 154 ++ gen/sysconf.3 | 208 ++ {gen.subproj => gen}/sysconf.c | 0 gen/sysctl.3 | 827 ++++++++ {gen.subproj => gen}/sysctl.c | 0 {gen.subproj => gen}/sysctlbyname.c | 0 gen/syslog.3 | 296 +++ {gen.subproj => gen}/syslog.c | 0 gen/tcgetpgrp.3 | 82 + gen/tcsendbreak.3 | 157 ++ gen/tcsetattr.3 | 333 ++++ gen/tcsetpgrp.3 | 99 + {gen.subproj => gen}/telldir.c | 0 {gen.subproj => gen}/termios.c | 0 gen/time.3 | 87 + {gen.subproj => gen}/time.c | 0 gen/times.3 | 144 ++ {gen.subproj => gen}/times.c | 0 gen/timezone.3 | 71 + {gen.subproj => gen}/timezone.c | 0 gen/ttyname.3 | 131 ++ {gen.subproj => gen}/ttyname.c | 16 +- {gen.subproj => gen}/ttyslot.c | 0 gen/tzset.3 | 327 +++ gen/ualarm.3 | 101 + {gen.subproj => gen}/ualarm.c | 0 gen/ulimit.c | 32 + gen/uname.3 | 92 + {gen.subproj => gen}/uname.c | 0 gen/unvis.3 | 196 ++ {gen.subproj => gen}/unvis.c | 0 gen/usleep.3 | 84 + gen/usleep.c | 54 + gen/utime.3 | 91 + {gen.subproj => gen}/utime.c | 0 gen/valloc.3 | 74 + gen/vis.3 | 277 +++ {gen.subproj => gen}/vis.c | 0 {gen.subproj => gen}/wait.c | 0 {gen.subproj => gen}/wait3.c | 0 {gen.subproj => gen}/waitpid.c | 0 {gen.subproj => gen}/zone.c | 0 gmon/Makefile.inc | 22 + {gen.subproj => gmon}/gmon.c | 0 headers.subproj/Makefile | 53 - headers.subproj/Makefile.postamble | 5 - headers.subproj/Makefile.preamble | 4 - headers.subproj/PB.project | 41 - i386/gen/Makefile.inc | 5 + {gen.subproj/i386.subproj => i386/gen}/abs.c | 0 {gen.subproj/i386.subproj => i386/gen}/bcmp.c | 0 i386/gen/bcopy.s | 123 ++ i386/gen/bcopy_init.c | 9 + i386/gen/bzero.s | 103 + {gen.subproj/i386.subproj => i386/gen}/ecvt.c | 0 {gen.subproj/i386.subproj => i386/gen}/ffs.c | 0 .../i386.subproj => i386/gen}/insque.c | 0 .../i386.subproj => i386/gen}/isinf.c | 30 +- .../i386.subproj => i386/gen}/mcount.s | 0 .../memcpy.c => i386/gen/memcpy.s | 2 +- .../memmove.c => i386/gen/memmove.s | 2 +- .../i386.subproj => i386/gen}/remque.c | 0 .../i386.subproj => i386/gen}/setjmperr.c | 0 .../i386.subproj => i386/gen}/strcat.c | 0 stdio.subproj/fvwrite.h => i386/gen/strcmp.c | 35 +- .../i386.subproj => i386/gen}/strcpy.c | 0 .../i386.subproj => i386/gen}/strlen.c | 0 .../i386.subproj => i386/gen}/strncat.c | 0 .../i386.subproj => i386/gen}/strncmp.c | 0 .../i386.subproj => i386/gen}/strncpy.c | 0 i386/mach/Makefile.inc | 1 + i386/mach/mach_absolute_time.c | 33 + .../i386.subproj => i386/sys}/ATPgetreq.s | 0 .../i386.subproj => i386/sys}/ATPgetrsp.s | 0 .../i386.subproj => i386/sys}/ATPsndreq.s | 0 .../i386.subproj => i386/sys}/ATPsndrsp.s | 0 .../i386.subproj => i386/sys}/ATgetmsg.s | 0 .../i386.subproj => i386/sys}/ATputmsg.s | 0 .../i386.subproj => i386/sys}/ATsocket.s | 0 i386/sys/Makefile.inc | 189 ++ {sys.subproj/i386.subproj => i386/sys}/SYS.h | 4 +- .../i386.subproj => i386/sys}/_exit.s | 0 .../i386.subproj => i386/sys}/_getlogin.s | 0 i386/sys/_pthread_kill.s | 28 + .../i386.subproj => i386/sys}/_setjmp.s | 0 .../i386.subproj => i386/sys}/_setlogin.s | 0 .../i386.subproj => i386/sys}/_sysctl.s | 0 .../i386.subproj => i386/sys}/accept.s | 0 .../i386.subproj => i386/sys}/access.s | 0 {sys.subproj/i386.subproj => i386/sys}/acct.s | 0 .../i386.subproj => i386/sys}/add_profil.s | 0 .../i386.subproj => i386/sys}/adjtime.s | 0 {sys.subproj/i386.subproj => i386/sys}/bind.s | 0 .../i386.subproj => i386/sys}/cerror.s | 0 .../i386.subproj => i386/sys}/chdir.s | 0 .../sys}/checkuseraccess.s | 0 .../i386.subproj => i386/sys}/chflags.s | 0 .../i386.subproj => i386/sys}/chmod.s | 0 .../i386.subproj => i386/sys}/chown.s | 0 .../i386.subproj => i386/sys}/chroot.s | 0 .../i386.subproj => i386/sys}/close.s | 0 .../i386.subproj => i386/sys}/connect.s | 0 {sys.subproj/i386.subproj => i386/sys}/dup.s | 0 {sys.subproj/i386.subproj => i386/sys}/dup2.s | 0 .../i386.subproj => i386/sys}/exchangedata.s | 0 .../i386.subproj => i386/sys}/execve.s | 0 .../i386.subproj => i386/sys}/fchdir.s | 0 .../i386.subproj => i386/sys}/fchflags.s | 0 .../i386.subproj => i386/sys}/fchmod.s | 0 .../i386.subproj => i386/sys}/fchown.s | 0 .../i386.subproj => i386/sys}/fcntl.s | 0 .../i386.subproj => i386/sys}/flock.s | 0 {sys.subproj/i386.subproj => i386/sys}/fork.s | 2 +- .../i386.subproj => i386/sys}/fpathconf.s | 0 .../i386.subproj => i386/sys}/fstat.s | 0 .../i386.subproj => i386/sys}/fstatfs.s | 0 .../i386.subproj => i386/sys}/fstatv.s | 0 .../i386.subproj => i386/sys}/fsync.s | 0 .../i386.subproj => i386/sys}/ftruncate.s | 0 .../lfs_bmapv.s => i386/sys/futimes.s | 2 +- .../i386.subproj => i386/sys}/getattrlist.s | 0 .../i386.subproj => i386/sys}/getdirentries.s | 0 .../sys}/getdirentriesattr.s | 0 .../i386.subproj => i386/sys}/getegid.s | 0 .../i386.subproj => i386/sys}/geteuid.s | 0 .../i386.subproj => i386/sys}/getfh.s | 0 .../i386.subproj => i386/sys}/getfsstat.s | 0 .../i386.subproj => i386/sys}/getgid.s | 0 .../i386.subproj => i386/sys}/getgroups.s | 0 .../i386.subproj => i386/sys}/getitimer.s | 0 .../i386.subproj => i386/sys}/getpeername.s | 0 .../lfs_markv.s => i386/sys/getpgid.s | 2 +- .../i386.subproj => i386/sys}/getpgrp.s | 0 .../i386.subproj => i386/sys}/getpid.s | 0 .../i386.subproj => i386/sys}/getppid.s | 0 .../i386.subproj => i386/sys}/getpriority.s | 0 .../i386.subproj => i386/sys}/getrlimit.s | 0 .../i386.subproj => i386/sys}/getrusage.s | 0 .../lfs_segwait.s => i386/sys/getsid.s | 2 +- .../i386.subproj => i386/sys}/getsockname.s | 0 .../i386.subproj => i386/sys}/getsockopt.s | 0 .../i386.subproj => i386/sys}/getuid.s | 0 .../i386.subproj => i386/sys}/ioctl.s | 0 i386/sys/issetugid.s | 28 + {sys.subproj/i386.subproj => i386/sys}/kill.s | 0 .../i386.subproj => i386/sys}/ktrace.s | 0 {sys.subproj/i386.subproj => i386/sys}/link.s | 0 .../i386.subproj => i386/sys}/listen.s | 0 .../sys}/load_shared_file.s | 0 .../i386.subproj => i386/sys}/lseek.s | 0 .../i386.subproj => i386/sys}/lstat.s | 0 .../i386.subproj => i386/sys}/lstatv.s | 0 .../i386.subproj => i386/sys}/madvise.s | 0 .../i386.subproj => i386/sys}/mincore.s | 0 .../i386.subproj => i386/sys}/minherit.s | 0 .../i386.subproj => i386/sys}/mkcomplex.s | 0 .../i386.subproj => i386/sys}/mkdir.s | 0 .../i386.subproj => i386/sys}/mkfifo.s | 0 .../i386.subproj => i386/sys}/mknod.s | 0 .../i386.subproj => i386/sys}/mlock.s | 0 .../i386.subproj => i386/sys}/mlockall.s | 0 {sys.subproj/i386.subproj => i386/sys}/mmap.s | 0 .../i386.subproj => i386/sys}/mount.s | 0 .../i386.subproj => i386/sys}/mprotect.s | 0 .../i386.subproj => i386/sys}/msgctl.s | 0 .../i386.subproj => i386/sys}/msgget.s | 0 .../i386.subproj => i386/sys}/msgrcv.s | 0 .../i386.subproj => i386/sys}/msgsnd.s | 0 .../i386.subproj => i386/sys}/msgsys.s | 0 .../i386.subproj => i386/sys}/msync.s | 0 .../i386.subproj => i386/sys}/munlock.s | 0 .../i386.subproj => i386/sys}/munlockall.s | 0 .../i386.subproj => i386/sys}/munmap.s | 0 i386/sys/new_system_shared_regions.s | 28 + .../i386.subproj => i386/sys}/nfssvc.s | 0 {sys.subproj/i386.subproj => i386/sys}/open.s | 0 .../i386.subproj => i386/sys}/pathconf.s | 0 {sys.subproj/i386.subproj => i386/sys}/pipe.s | 0 i386/sys/posix_madvise.s | 27 + .../lfs_segclean.s => i386/sys/pread.s | 2 +- .../i386.subproj => i386/sys}/profil.s | 0 i386/sys/pthread_sigmask.s | 28 + .../i386.subproj => i386/sys}/ptrace.s | 0 i386/sys/pwrite.s | 28 + .../i386.subproj => i386/sys}/quota.s | 0 .../i386.subproj => i386/sys}/quotactl.s | 0 {sys.subproj/i386.subproj => i386/sys}/read.s | 0 .../i386.subproj => i386/sys}/readlink.s | 0 .../i386.subproj => i386/sys}/readv.s | 0 .../i386.subproj => i386/sys}/reboot.s | 0 .../i386.subproj => i386/sys}/recvfrom.s | 0 .../i386.subproj => i386/sys}/recvmsg.s | 0 .../i386.subproj => i386/sys}/rename.s | 0 .../sys}/reset_shared_file.s | 0 .../i386.subproj => i386/sys}/revoke.s | 0 .../i386.subproj => i386/sys}/rmdir.s | 0 i386/sys/s.template | 7 + .../i386.subproj => i386/sys}/searchfs.s | 0 .../i386.subproj => i386/sys}/select.s | 0 .../i386.subproj => i386/sys}/sem_close.s | 0 .../i386.subproj => i386/sys}/sem_destroy.s | 0 .../i386.subproj => i386/sys}/sem_getvalue.s | 0 .../i386.subproj => i386/sys}/sem_init.s | 0 .../i386.subproj => i386/sys}/sem_open.s | 0 .../i386.subproj => i386/sys}/sem_post.s | 0 .../i386.subproj => i386/sys}/sem_trywait.s | 0 .../i386.subproj => i386/sys}/sem_unlink.s | 0 .../i386.subproj => i386/sys}/sem_wait.s | 0 .../i386.subproj => i386/sys}/semconfig.s | 0 .../i386.subproj => i386/sys}/semctl.s | 0 .../i386.subproj => i386/sys}/semget.s | 0 .../i386.subproj => i386/sys}/semop.s | 0 .../i386.subproj => i386/sys}/semsys.s | 0 .../i386.subproj => i386/sys}/sendmsg.s | 0 .../i386.subproj => i386/sys}/sendto.s | 0 .../i386.subproj => i386/sys}/setattrlist.s | 0 .../i386.subproj => i386/sys}/setegid.s | 0 .../i386.subproj => i386/sys}/seteuid.s | 0 .../i386.subproj => i386/sys}/setgid.s | 0 .../i386.subproj => i386/sys}/setgroups.s | 0 .../i386.subproj => i386/sys}/setitimer.s | 0 .../i386.subproj => i386/sys}/setjmp.s | 2 +- .../i386.subproj => i386/sys}/setpgid.s | 0 .../i386.subproj => i386/sys}/setpriority.s | 0 .../i386.subproj => i386/sys}/setprivexec.s | 0 .../i386.subproj => i386/sys}/setquota.s | 0 .../i386.subproj => i386/sys}/setrlimit.s | 0 .../i386.subproj => i386/sys}/setsid.s | 0 .../i386.subproj => i386/sys}/setsockopt.s | 0 .../i386.subproj => i386/sys}/settimeofday.s | 0 .../i386.subproj => i386/sys}/setuid.s | 0 .../i386.subproj => i386/sys}/shm_open.s | 0 .../i386.subproj => i386/sys}/shm_unlink.s | 0 .../i386.subproj => i386/sys}/shmat.s | 0 .../i386.subproj => i386/sys}/shmctl.s | 0 .../i386.subproj => i386/sys}/shmdt.s | 0 .../i386.subproj => i386/sys}/shmget.s | 0 .../i386.subproj => i386/sys}/shmsys.s | 0 .../i386.subproj => i386/sys}/shutdown.s | 0 .../i386.subproj => i386/sys}/sigaltstack.s | 0 .../i386.subproj => i386/sys}/sigpending.s | 0 i386/sys/sigprocmask.s | 28 + .../i386.subproj => i386/sys}/sigreturn.s | 0 i386/sys/sigwait.s | 28 + .../i386.subproj => i386/sys}/socket.s | 0 .../i386.subproj => i386/sys}/socketpair.s | 0 {sys.subproj/i386.subproj => i386/sys}/stat.s | 0 .../i386.subproj => i386/sys}/statfs.s | 0 .../i386.subproj => i386/sys}/statv.s | 0 .../i386.subproj => i386/sys}/swapon.s | 0 .../i386.subproj => i386/sys}/symlink.s | 0 {sys.subproj/i386.subproj => i386/sys}/sync.s | 0 .../i386.subproj => i386/sys}/syscall.s | 0 .../table.s => i386/sys/systable.s | 0 .../i386.subproj => i386/sys}/truncate.s | 0 .../i386.subproj => i386/sys}/umask.s | 0 .../i386.subproj => i386/sys}/undelete.s | 0 .../i386.subproj => i386/sys}/unlink.s | 0 .../i386.subproj => i386/sys}/unmount.s | 0 .../i386.subproj => i386/sys}/utimes.s | 0 .../i386.subproj => i386/sys}/vfork.s | 4 +- .../i386.subproj => i386/sys}/wait4.s | 0 .../i386.subproj => i386/sys}/write.s | 0 .../i386.subproj => i386/sys}/writev.s | 0 i386/threads/Makefile.inc | 2 + .../i386.subproj => i386/threads}/thread.c | 1 + include/Makefile.inc | 70 + .../NSSystemDirectories.h | 2 + include/ar.h | 88 + include/arpa/Makefile.inc | 5 + include/arpa/ftp.h | 130 ++ include/arpa/nameser_compat.h | 194 ++ include/arpa/telnet.h | 341 ++++ include/arpa/tftp.h | 101 + {headers.subproj => include}/asm.h | 0 include/authentication.h | 31 + include/bitstring.h | 164 ++ include/c.h | 82 + {headers.subproj => include}/crt_externs.h | 1 + include/ctype.h | 225 +++ include/db.h | 239 +++ include/dirent.h | 124 ++ include/disktab.h | 82 + include/err.h | 81 + .../bootstrap.defs => include/errno.h | 5 +- include/fcntl.h | 22 + include/fnmatch.h | 81 + include/fsproperties.h | 49 + include/fstab.h | 100 + include/fts.h | 149 ++ include/glob.h | 111 ++ locale.subproj/ctype.c => include/grp.h | 60 +- include/kvm.h | 90 + {headers.subproj => include}/libc.h | 0 include/libgen.h | 49 + include/limits.h | 108 + include/locale.h | 81 + .../localeconv.c => include/memory.h | 20 +- {headers.subproj => include}/monitor.h | 0 include/mpool.h | 156 ++ include/ndbm.h | 98 + include/netdb.h | 259 +++ locale.subproj/isctype.c => include/nlist.h | 185 +- include/objc/Makefile.inc | 2 + {gen.subproj => include/objc}/malloc.h | 0 {gen.subproj => include/objc}/zone.h | 0 include/paths.h | 100 + include/protocols/Makefile.inc | 6 + include/protocols/dumprestore.h | 133 ++ include/protocols/routed.h | 125 ++ include/protocols/rwhod.h | 89 + include/protocols/talkd.h | 135 ++ include/protocols/timed.h | 120 ++ .../i386.subproj/bcopy.c => include/pwd.h | 167 +- include/ranlib.h | 100 + include/regex.h | 127 ++ include/regexp.h | 90 + include/rune.h | 66 + include/runetype.h | 110 + include/semaphore.h | 30 + include/setjmp.h | 27 + gen.subproj/usleep.c => include/sgtty.h | 21 +- stdio.subproj/mktemp.c => include/signal.h | 135 +- include/stab.h | 88 + {headers.subproj => include}/standards.h | 0 include/stddef.h | 91 + include/stdio.h | 404 ++++ include/stdlib.h | 218 ++ include/string.h | 117 ++ stdlib.subproj/rand.c => include/strings.h | 25 +- include/struct.h | 72 + include/sysexits.h | 139 ++ include/syslog.h | 23 + net.subproj/ns_ntoa.c => include/tar.h | 102 +- include/termios.h | 23 + include/time.h | 150 ++ include/ttyent.h | 91 + include/tzfile.h | 172 ++ include/ucontext.h | 28 + include/ulimit.h | 9 + include/unistd.h | 249 +++ include/util.h | 107 + stdio.subproj/remove.c => include/utime.h | 33 +- locale.subproj/lconv.c => include/utmp.h | 60 +- include/vis.h | 105 + internat.subproj/Makefile | 50 - internat.subproj/Makefile.postamble | 5 - internat.subproj/Makefile.preamble | 3 - internat.subproj/PB.project | 42 - internat/Makefile.inc | 6 + {internat.subproj => internat}/NXCType.c | 0 {internat.subproj => internat}/NXCType.h | 0 {internat.subproj => internat}/NXIsAlNum.c | 0 {internat.subproj => internat}/NXIsAlpha.c | 0 {internat.subproj => internat}/NXIsAscii.c | 0 {internat.subproj => internat}/NXIsCntrl.c | 0 {internat.subproj => internat}/NXIsDigit.c | 0 {internat.subproj => internat}/NXIsGraph.c | 0 {internat.subproj => internat}/NXIsLower.c | 0 {internat.subproj => internat}/NXIsPrint.c | 0 {internat.subproj => internat}/NXIsPunct.c | 0 {internat.subproj => internat}/NXIsSpace.c | 0 {internat.subproj => internat}/NXIsUpper.c | 0 {internat.subproj => internat}/NXIsXDigit.c | 0 {internat.subproj => internat}/NXToAscii.c | 0 {internat.subproj => internat}/NXToLower.c | 0 {internat.subproj => internat}/NXToUpper.c | 0 {internat.subproj => internat}/_NXToLower.c | 0 {internat.subproj => internat}/_NXToUpper.c | 0 locale.subproj/Makefile | 46 - locale.subproj/Makefile.postamble | 100 - locale.subproj/Makefile.preamble | 137 -- locale.subproj/PB.project | 37 - locale.subproj/setlocale.c | 252 --- locale/Makefile.inc | 26 + {locale.subproj => locale}/ansi.c | 41 +- locale/big5.c | 119 ++ locale/collate.c | 212 ++ locale/collate.h | 67 + locale/collcmp.c | 84 + locale/ctype.3 | 147 ++ locale/euc.4 | 242 +++ {locale.subproj => locale}/euc.c | 29 +- {locale.subproj => locale}/frune.c | 26 +- locale/isalnum.3 | 101 + locale/isalpha.3 | 99 + locale/isascii.3 | 61 + locale/isblank.3 | 68 + locale/iscntrl.3 | 89 + locale/isctype.c | 233 +++ locale/isdigit.3 | 84 + locale/isgraph.3 | 101 + locale/islower.3 | 89 + locale/isprint.3 | 101 + locale/ispunct.3 | 92 + locale/isspace.3 | 84 + locale/isupper.3 | 89 + locale/isxdigit.3 | 87 + locale/lconv.c | 70 + locale/localeconv.c | 51 + locale/mbrune.3 | 160 ++ {locale.subproj => locale}/mbrune.c | 26 +- locale/mskanji.c | 106 + locale/multibyte.3 | 245 +++ locale/nl_langinfo.3 | 90 + locale/nomacros.c | 9 + {locale.subproj => locale}/none.c | 31 +- locale/rune.3 | 277 +++ {locale.subproj => locale}/rune.c | 199 +- locale/runetype.c | 65 + locale/setinvalidrune.c | 44 + locale/setlocale.3 | 338 ++++ locale/setlocale.c | 307 +++ locale/setlocale.h | 34 + locale/setrunelocale.c | 121 ++ locale.subproj/runetable.c => locale/table.c | 196 +- locale/toascii.3 | 72 + locale/tolower.3 | 92 + locale/tolower.c | 61 + locale/toupper.3 | 92 + locale/toupper.c | 61 + locale/utf2.4 | 88 + {locale.subproj => locale}/utf2.c | 31 +- mach.subproj/Makefile | 65 - mach.subproj/Makefile.postamble | 0 mach.subproj/Makefile.preamble | 37 - mach.subproj/PB.project | 78 - mach.subproj/headers.subproj/Makefile | 53 - .../headers.subproj/Makefile.postamble | 100 - .../headers.subproj/Makefile.preamble | 1 - mach.subproj/headers.subproj/PB.project | 45 - mach.subproj/headers.subproj/mig_errors.h | 124 -- mach.subproj/mach_absolute_time.c | 19 - mach.subproj/mach_msg.c | 148 -- mach.subproj/mach_msg_destroy.c | 169 -- mach.subproj/mach_msg_send.c | 57 - mach.subproj/mach_msg_server.c | 265 --- mach.subproj/mach_subsystem_join.c | 153 -- mach.subproj/servers.subproj/Makefile | 49 - .../servers.subproj/Makefile.postamble | 100 - .../servers.subproj/Makefile.preamble | 3 - mach.subproj/servers.subproj/PB.project | 23 - mach/Makefile.inc | 103 + .../bootstrap_ports.c | 23 +- {mach.subproj => mach}/clock.defs | 0 {mach.subproj => mach}/clock_priv.defs | 0 {mach.subproj => mach}/clock_reply.defs | 0 {mach.subproj => mach}/clock_sleep.c | 0 {mach.subproj => mach}/err_ipc.sub | 0 {mach.subproj => mach}/err_kern.sub | 0 {mach.subproj => mach}/err_mach_ipc.sub | 0 {mach.subproj => mach}/err_server.sub | 0 {mach.subproj => mach}/err_us.sub | 0 {mach.subproj => mach}/error_codes.c | 6 +- mach/errorlib.h | 73 + {mach.subproj => mach}/exc.defs | 0 {mach.subproj => mach}/exc_catcher.c | 0 {mach.subproj => mach}/exc_catcher_state.c | 0 .../exc_catcher_state_identity.c | 0 {mach.subproj => mach}/externs.h | 1 - {mach.subproj => mach}/fprintf_stderr.c | 0 mach/headers/Makefile.inc | 8 + .../headers}/errorlib.h | 0 .../headers.subproj => mach/headers}/mach.h | 6 + .../headers}/mach_error.h | 0 .../headers}/mach_init.h | 0 .../headers}/mach_interface.h | 0 .../headers}/port_obj.h | 0 .../headers.subproj => mach/headers}/sync.h | 0 .../headers}/vm_task.h | 0 {mach.subproj => mach}/host_priv.defs | 0 {mach.subproj => mach}/host_security.defs | 0 {mach.subproj => mach}/ledger.defs | 0 {mach.subproj => mach}/lock_set.defs | 0 {mach.subproj => mach}/mach_error.c | 2 +- {mach.subproj => mach}/mach_error_string.c | 17 +- {mach.subproj => mach}/mach_host.defs | 0 {mach.subproj => mach}/mach_init.c | 20 +- {mach.subproj => mach}/mach_init_ports.c | 9 +- mach/mach_msg.c | 626 ++++++ {mach.subproj => mach}/mach_port.defs | 0 {mach.subproj => mach}/mach_traps.s | 0 {mach.subproj => mach}/mig_allocate.c | 0 {mach.subproj => mach}/mig_deallocate.c | 0 {mach.subproj => mach}/mig_reply_setup.c | 0 {mach.subproj => mach}/mig_strncpy.c | 2 +- {mach.subproj => mach}/ms_thread_switch.c | 0 {mach.subproj => mach}/notify.defs | 0 {mach.subproj => mach}/panic.c | 0 {mach.subproj => mach}/port_obj.c | 0 {mach.subproj => mach}/processor.defs | 0 {mach.subproj => mach}/processor_set.defs | 0 {mach.subproj => mach}/sbrk.c | 0 {mach.subproj => mach}/semaphore.c | 7 - mach/servers/Makefile.inc | 45 + .../servers}/bootstrap_defs.h | 17 +- .../servers}/key_defs.h | 0 .../servers}/ls_defs.h | 0 .../servers}/netname.defs | 0 .../servers}/netname_defs.h | 0 .../servers}/nm_defs.h | 0 .../servers/srvbootstrap.defs | 251 ++- {mach.subproj => mach}/slot_name.c | 0 {mach.subproj => mach}/task.defs | 0 {mach.subproj => mach}/thread_act.defs | 0 {mach.subproj => mach}/vm_map.defs | 0 net.subproj/Makefile | 47 - net.subproj/Makefile.postamble | 100 - net.subproj/Makefile.preamble | 137 -- net.subproj/PB.project | 36 - net.subproj/ns_addr.c | 245 --- net/Makefile.inc | 54 + net/addr2ascii.3 | 222 +++ net/byteorder.3 | 84 + net/ethers.3 | 197 ++ net/getaddrinfo.3 | 619 ++++++ net/gethostbyname.3 | 380 ++++ net/getifaddrs.3 | 164 ++ net/getipnodebyname.3 | 461 +++++ net/getnameinfo.3 | 311 +++ net/getnetent.3 | 172 ++ net/getprotoent.3 | 149 ++ net/getservent.3 | 158 ++ net/hesiod.3 | 159 ++ net/if_indextoname.3 | 142 ++ net/inet.3 | 271 +++ net/inet6_option_space.3 | 445 +++++ net/inet6_rthdr_space.3 | 323 +++ {net.subproj => net}/inet_addr.c | 123 +- {net.subproj => net}/inet_lnaof.c | 0 {net.subproj => net}/inet_makeaddr.c | 0 net/inet_net.3 | 157 ++ {net.subproj => net}/inet_netof.c | 0 {net.subproj => net}/inet_network.c | 0 {net.subproj => net}/inet_ntoa.c | 0 net/linkaddr.3 | 140 ++ {net.subproj => net}/linkaddr.c | 0 net/ns.3 | 133 ++ {net.subproj => net}/nsap_addr.c | 11 +- net/nsdispatch.3 | 231 +++ net/rcmd.3 | 298 +++ net/rcmdsh.3 | 116 ++ {net.subproj => net}/recv.c | 0 net/resolver.3 | 422 ++++ nls/Makefile.inc | 10 + posix1e/Makefile.inc | 92 + ppc/gen/Makefile.inc | 6 + {gen.subproj/ppc.subproj => ppc/gen}/abs.s | 0 ppc/gen/assymdefs.c | 87 + {gen.subproj/ppc.subproj => ppc/gen}/bcmp.c | 0 ppc/gen/bcopy.s | 1159 +++++++++++ ppc/gen/bzero.s | 202 ++ {gen.subproj/ppc.subproj => ppc/gen}/ecvt.c | 0 {gen.subproj/ppc.subproj => ppc/gen}/ffs.s | 0 {gen.subproj/ppc.subproj => ppc/gen}/fp.h | 0 ppc/gen/genassym.c | 205 ++ .../ppc.subproj => ppc/gen}/genassym.h | 0 {gen.subproj/ppc.subproj => ppc/gen}/insque.c | 0 {gen.subproj/ppc.subproj => ppc/gen}/isinf.c | 0 {gen.subproj/ppc.subproj => ppc/gen}/mcount.s | 0 {gen.subproj/ppc.subproj => ppc/gen}/remque.c | 0 .../ppc.subproj => ppc/gen}/setjmperr.c | 0 {gen.subproj/ppc.subproj => ppc/gen}/strcat.c | 0 ppc/gen/strcmp.c | 53 + {gen.subproj/ppc.subproj => ppc/gen}/strcpy.c | 0 ppc/gen/strlen.s | 111 ++ .../ppc.subproj => ppc/gen}/strncat.c | 0 .../ppc.subproj => ppc/gen}/strncmp.c | 0 .../ppc.subproj => ppc/gen}/strncpy.c | 0 ppc/mach/Makefile.inc | 1 + ppc/mach/mach_absolute_time.s | 34 + .../ppc.subproj => ppc/sys}/ATPgetreq.s | 0 .../ppc.subproj => ppc/sys}/ATPgetrsp.s | 0 .../ppc.subproj => ppc/sys}/ATPsndreq.s | 0 .../ppc.subproj => ppc/sys}/ATPsndrsp.s | 0 .../ppc.subproj => ppc/sys}/ATgetmsg.s | 0 .../ppc.subproj => ppc/sys}/ATputmsg.s | 0 .../ppc.subproj => ppc/sys}/ATsocket.s | 0 ppc/sys/Makefile.inc | 195 ++ {sys.subproj/ppc.subproj => ppc/sys}/SYS.h | 0 {sys.subproj/ppc.subproj => ppc/sys}/_exit.s | 0 .../ppc.subproj => ppc/sys}/_getlogin.s | 0 .../ppc.subproj => ppc/sys}/_longjmp.s | 0 ppc/sys/_pthread_kill.s | 26 + .../ppc.subproj => ppc/sys}/_setjmp.h | 0 .../ppc.subproj => ppc/sys}/_setjmp.s | 0 .../ppc.subproj => ppc/sys}/_setlogin.s | 0 .../ppc.subproj => ppc/sys}/_sysctl.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/accept.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/access.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/acct.s | 0 .../ppc.subproj => ppc/sys}/add_profil.s | 0 .../ppc.subproj => ppc/sys}/adjtime.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/assym.h | 0 ppc/sys/assymdefs.c | 128 ++ {sys.subproj/ppc.subproj => ppc/sys}/bind.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/cerror.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/chdir.s | 0 .../ppc.subproj => ppc/sys}/checkuseraccess.s | 0 .../ppc.subproj => ppc/sys}/chflags.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/chmod.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/chown.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/chroot.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/close.s | 0 .../ppc.subproj => ppc/sys}/connect.s | 0 .../ppc.subproj => ppc/sys}/cthread.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/dup.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/dup2.s | 0 .../ppc.subproj => ppc/sys}/exchangedata.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/execve.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/fchdir.s | 0 .../ppc.subproj => ppc/sys}/fchflags.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/fchmod.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/fchown.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/fcntl.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/flock.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/fork.s | 2 + .../ppc.subproj => ppc/sys}/fpathconf.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/fstat.s | 0 .../ppc.subproj => ppc/sys}/fstatfs.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/fstatv.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/fsync.s | 0 .../ppc.subproj => ppc/sys}/ftruncate.s | 0 .../lfs_bmapv.s => ppc/sys/futimes.s | 3 +- ppc/sys/genassym.c | 205 ++ .../ppc.subproj => ppc/sys}/genassym.h | 0 .../ppc.subproj => ppc/sys}/getattrlist.s | 0 .../ppc.subproj => ppc/sys}/getdirentries.s | 0 .../sys}/getdirentriesattr.s | 0 .../ppc.subproj => ppc/sys}/getegid.s | 0 .../ppc.subproj => ppc/sys}/geteuid.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/getfh.s | 0 .../ppc.subproj => ppc/sys}/getfsstat.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/getgid.s | 0 .../ppc.subproj => ppc/sys}/getgroups.s | 0 .../ppc.subproj => ppc/sys}/getitimer.s | 0 .../ppc.subproj => ppc/sys}/getpeername.s | 0 .../lfs_markv.s => ppc/sys/getpgid.s | 3 +- .../ppc.subproj => ppc/sys}/getpgrp.s | 0 ppc/sys/getpid.s | 53 + .../ppc.subproj => ppc/sys}/getppid.s | 0 .../ppc.subproj => ppc/sys}/getpriority.s | 0 .../ppc.subproj => ppc/sys}/getrlimit.s | 0 .../ppc.subproj => ppc/sys}/getrusage.s | 0 .../ppc.subproj/getpid.s => ppc/sys/getsid.s | 2 +- .../ppc.subproj => ppc/sys}/getsockname.s | 0 .../ppc.subproj => ppc/sys}/getsockopt.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/getuid.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/ioctl.s | 0 .../lfs_segwait.s => ppc/sys/issetugid.s | 3 +- {sys.subproj/ppc.subproj => ppc/sys}/kill.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/ktrace.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/link.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/listen.s | 0 .../sys}/load_shared_file.s | 0 .../ppc.subproj => ppc/sys}/longjmp.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/lseek.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/lstat.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/lstatv.s | 0 .../ppc.subproj => ppc/sys}/madvise.s | 1 + .../ppc.subproj => ppc/sys}/mincore.s | 0 .../ppc.subproj => ppc/sys}/minherit.s | 0 .../ppc.subproj => ppc/sys}/mkcomplex.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/mkdir.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/mkfifo.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/mknod.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/mlock.s | 0 .../ppc.subproj => ppc/sys}/mlockall.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/mmap.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/mount.s | 0 .../ppc.subproj => ppc/sys}/mprotect.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/msgctl.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/msgget.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/msgrcv.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/msgsnd.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/msgsys.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/msync.s | 0 .../ppc.subproj => ppc/sys}/munlock.s | 0 .../ppc.subproj => ppc/sys}/munlockall.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/munmap.s | 0 ppc/sys/new_system_shared_regions.s | 26 + {sys.subproj/ppc.subproj => ppc/sys}/nfssvc.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/open.s | 0 .../ppc.subproj => ppc/sys}/pathconf.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/pipe.s | 0 ppc/sys/posix_madvise.s | 27 + ppc/sys/ppc_gettimeofday.s | 42 + ppc/sys/pread.s | 26 + .../sys}/processor_facilities.h | 0 .../sys}/processor_facilities.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/profil.s | 0 ppc/sys/pthread_sigmask.s | 26 + {sys.subproj/ppc.subproj => ppc/sys}/ptrace.s | 0 ppc/sys/pwrite.s | 26 + {sys.subproj/ppc.subproj => ppc/sys}/quota.s | 0 .../ppc.subproj => ppc/sys}/quotactl.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/read.s | 0 .../ppc.subproj => ppc/sys}/readlink.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/readv.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/reboot.s | 0 .../ppc.subproj => ppc/sys}/recvfrom.s | 0 .../ppc.subproj => ppc/sys}/recvmsg.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/rename.s | 0 .../sys}/reset_shared_file.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/revoke.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/rmdir.s | 0 ppc/sys/s.template | 6 + .../ppc.subproj => ppc/sys}/searchfs.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/select.s | 0 .../ppc.subproj => ppc/sys}/sem_close.s | 0 .../ppc.subproj => ppc/sys}/sem_destroy.s | 0 .../ppc.subproj => ppc/sys}/sem_getvalue.s | 0 .../ppc.subproj => ppc/sys}/sem_init.s | 0 .../ppc.subproj => ppc/sys}/sem_open.s | 0 .../ppc.subproj => ppc/sys}/sem_post.s | 0 .../ppc.subproj => ppc/sys}/sem_trywait.s | 0 .../ppc.subproj => ppc/sys}/sem_unlink.s | 0 .../ppc.subproj => ppc/sys}/sem_wait.s | 0 .../ppc.subproj => ppc/sys}/semconfig.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/semctl.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/semget.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/semop.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/semsys.s | 0 .../ppc.subproj => ppc/sys}/sendmsg.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/sendto.s | 0 .../ppc.subproj => ppc/sys}/setattrlist.s | 0 .../ppc.subproj => ppc/sys}/setegid.s | 0 .../ppc.subproj => ppc/sys}/seteuid.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/setgid.s | 0 .../ppc.subproj => ppc/sys}/setgroups.s | 0 .../ppc.subproj => ppc/sys}/setitimer.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/setjmp.s | 0 .../ppc.subproj => ppc/sys}/setpgid.s | 0 .../ppc.subproj => ppc/sys}/setpriority.s | 0 .../ppc.subproj => ppc/sys}/setprivexec.s | 0 .../ppc.subproj => ppc/sys}/setquota.s | 0 .../ppc.subproj => ppc/sys}/setrlimit.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/setsid.s | 0 .../ppc.subproj => ppc/sys}/setsockopt.s | 0 .../ppc.subproj => ppc/sys}/settimeofday.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/setuid.s | 0 .../ppc.subproj => ppc/sys}/shm_open.s | 0 .../ppc.subproj => ppc/sys}/shm_unlink.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/shmat.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/shmctl.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/shmdt.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/shmget.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/shmsys.s | 0 .../ppc.subproj => ppc/sys}/shutdown.s | 0 .../ppc.subproj => ppc/sys}/sigaltstack.s | 0 .../ppc.subproj => ppc/sys}/sigpending.s | 0 .../lfs_segclean.s => ppc/sys/sigprocmask.s | 3 +- .../ppc.subproj => ppc/sys}/sigreturn.s | 0 ppc/sys/sigwait.s | 26 + {sys.subproj/ppc.subproj => ppc/sys}/socket.s | 0 .../ppc.subproj => ppc/sys}/socketpair.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/stat.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/statfs.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/statv.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/swapon.s | 0 .../ppc.subproj => ppc/sys}/symlink.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/sync.s | 0 .../ppc.subproj => ppc/sys}/syscall.s | 0 .../ppc.subproj/table.s => ppc/sys/systable.s | 0 .../ppc.subproj => ppc/sys}/truncate.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/umask.s | 0 .../ppc.subproj => ppc/sys}/undelete.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/unlink.s | 0 .../ppc.subproj => ppc/sys}/unmount.s | 0 .../ppc.subproj => ppc/sys}/ur_cthread.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/utimes.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/vfork.s | 47 +- {sys.subproj/ppc.subproj => ppc/sys}/wait4.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/write.s | 0 {sys.subproj/ppc.subproj => ppc/sys}/writev.s | 0 pthreads.subproj/Makefile | 63 - pthreads.subproj/Makefile.postamble | 100 - pthreads.subproj/Makefile.preamble | 137 -- pthreads.subproj/PB.project | 44 - pthreads/Makefile.inc | 70 + {pthreads.subproj => pthreads}/lock.s | 18 +- .../mk_pthread_impl.c | 0 {pthreads.subproj => pthreads}/posix_sched.h | 0 pthreads/pthread.3 | 435 ++++ {pthreads.subproj => pthreads}/pthread.c | 637 +++--- {pthreads.subproj => pthreads}/pthread.h | 78 +- pthreads/pthread_attr.3 | 211 ++ pthreads/pthread_cancel.3 | 77 + pthreads/pthread_cleanup_pop.3 | 62 + pthreads/pthread_cleanup_push.3 | 64 + {pthreads.subproj => pthreads}/pthread_cond.c | 57 +- pthreads/pthread_cond_broadcast.3 | 68 + pthreads/pthread_cond_destroy.3 | 72 + pthreads/pthread_cond_init.3 | 78 + pthreads/pthread_cond_signal.3 | 68 + pthreads/pthread_cond_timedwait.3 | 87 + pthreads/pthread_cond_wait.3 | 75 + pthreads/pthread_condattr.3 | 83 + pthreads/pthread_create.3 | 119 ++ pthreads/pthread_detach.3 | 87 + pthreads/pthread_equal.3 | 66 + pthreads/pthread_exit.3 | 102 + pthreads/pthread_getschedparam.3 | 88 + pthreads/pthread_getspecific.3 | 81 + {pthreads.subproj => pthreads}/pthread_impl.h | 0 .../pthread_internals.h | 55 +- pthreads/pthread_join.3 | 102 + pthreads/pthread_key_create.3 | 105 + pthreads/pthread_key_delete.3 | 96 + .../pthread_machdep.h | 0 .../pthread_mutex.c | 231 ++- pthreads/pthread_mutex_destroy.3 | 70 + pthreads/pthread_mutex_init.3 | 75 + pthreads/pthread_mutex_lock.3 | 72 + pthreads/pthread_mutex_trylock.3 | 73 + pthreads/pthread_mutex_unlock.3 | 72 + pthreads/pthread_mutexattr.3 | 175 ++ pthreads/pthread_once.3 | 103 + pthreads/pthread_rwlock.c | 319 +++ pthreads/pthread_rwlock_destroy.3 | 80 + pthreads/pthread_rwlock_init.3 | 99 + pthreads/pthread_rwlock_rdlock.3 | 122 ++ pthreads/pthread_rwlock_unlock.3 | 79 + pthreads/pthread_rwlock_wrlock.3 | 102 + pthreads/pthread_rwlockattr_destroy.3 | 68 + pthreads/pthread_rwlockattr_getpshared.3 | 80 + pthreads/pthread_rwlockattr_init.3 | 67 + pthreads/pthread_rwlockattr_setpshared.3 | 88 + pthreads/pthread_self.3 | 59 + pthreads/pthread_setcancelstate.3 | 199 ++ pthreads/pthread_setspecific.3 | 93 + {pthreads.subproj => pthreads}/pthread_tsd.c | 0 {pthreads.subproj => pthreads}/sched.h | 0 {pthreads.subproj => pthreads}/stack.s | 0 {pthreads.subproj => pthreads}/thread_setup.c | 82 +- quad/Makefile.inc | 19 + regex.subproj/Makefile | 47 - regex.subproj/Makefile.postamble | 100 - regex.subproj/Makefile.preamble | 137 -- regex.subproj/PB.project | 23 - regex/Makefile.inc | 17 + {regex.subproj => regex}/cclass.h | 0 {regex.subproj => regex}/cname.h | 0 {regex.subproj => regex}/engine.c | 0 regex/re_format.7 | 476 +++++ {regex.subproj => regex}/regcomp.c | 0 {regex.subproj => regex}/regerror.c | 0 regex/regex.3 | 701 +++++++ {regex.subproj => regex}/regex2.h | 0 {regex.subproj => regex}/regexec.c | 0 {regex.subproj => regex}/regfree.c | 0 {regex.subproj => regex}/utils.h | 0 rpc/Makefile.inc | 159 ++ stdio.subproj/Makefile | 57 - stdio.subproj/Makefile.postamble | 100 - stdio.subproj/Makefile.preamble | 137 -- stdio.subproj/PB.project | 89 - stdio/Makefile.inc | 47 + stdio/asprintf.c | 81 + {stdio.subproj => stdio}/clrerr.c | 0 stdio/fclose.3 | 99 + {stdio.subproj => stdio}/fclose.c | 0 {stdio.subproj => stdio}/fdopen.c | 0 {stdio.subproj => stdio}/feof.c | 0 stdio/ferror.3 | 103 + {stdio.subproj => stdio}/ferror.c | 0 stdio/fflush.3 | 113 ++ {stdio.subproj => stdio}/fflush.c | 0 {stdio.subproj => stdio}/fgetc.c | 0 stdio/fgetln.3 | 127 ++ {stdio.subproj => stdio}/fgetln.c | 0 {stdio.subproj => stdio}/fgetpos.c | 0 stdio/fgets.3 | 158 ++ {stdio.subproj => stdio}/fgets.c | 2 +- {stdio.subproj => stdio}/fileno.c | 0 {stdio.subproj => stdio}/findfp.c | 0 {stdio.subproj => stdio}/flags.c | 0 {stdio.subproj => stdio}/floatio.h | 0 stdio/fopen.3 | 252 +++ {stdio.subproj => stdio}/fopen.c | 0 {stdio.subproj => stdio}/fprintf.c | 0 {stdio.subproj => stdio}/fpurge.c | 0 {stdio.subproj => stdio}/fputc.c | 0 stdio/fputs.3 | 110 + {stdio.subproj => stdio}/fputs.c | 0 stdio/fread.3 | 109 + {stdio.subproj => stdio}/fread.c | 0 {stdio.subproj => stdio}/freopen.c | 0 {stdio.subproj => stdio}/fscanf.c | 0 stdio/fseek.3 | 252 +++ {stdio.subproj => stdio}/fseek.c | 0 {stdio.subproj => stdio}/fsetpos.c | 0 {stdio.subproj => stdio}/ftell.c | 0 stdio/funopen.3 | 172 ++ {stdio.subproj => stdio}/funopen.c | 0 {stdio.subproj => stdio}/fvwrite.c | 55 +- stdio/fvwrite.h | 56 + {stdio.subproj => stdio}/fwalk.c | 0 {stdio.subproj => stdio}/fwrite.c | 0 stdio/getc.3 | 139 ++ {stdio.subproj => stdio}/getc.c | 0 {stdio.subproj => stdio}/getchar.c | 0 {stdio.subproj => stdio}/gets.c | 0 {stdio.subproj => stdio}/getw.c | 0 {stdio.subproj => stdio}/glue.h | 0 {stdio.subproj => stdio}/local.h | 0 {stdio.subproj => stdio}/makebuf.c | 0 stdio/mktemp.3 | 246 +++ stdio/mktemp.c | 186 ++ {stdio.subproj => stdio}/perror.c | 0 stdio/printf.3 | 643 ++++++ {stdio.subproj => stdio}/printf.c | 0 stdio/putc.3 | 136 ++ {stdio.subproj => stdio}/putc.c | 0 {stdio.subproj => stdio}/putchar.c | 0 {stdio.subproj => stdio}/puts.c | 0 {stdio.subproj => stdio}/putw.c | 0 {stdio.subproj => stdio}/refill.c | 0 stdio/remove.3 | 87 + stdio/remove.c | 61 + {stdio.subproj => stdio}/rewind.c | 0 {stdio.subproj => stdio}/rget.c | 0 stdio/scanf.3 | 446 +++++ {stdio.subproj => stdio}/scanf.c | 0 stdio/setbuf.3 | 205 ++ {stdio.subproj => stdio}/setbuf.c | 0 {stdio.subproj => stdio}/setbuffer.c | 0 {stdio.subproj => stdio}/setvbuf.c | 0 {stdio.subproj => stdio}/snprintf.c | 0 {stdio.subproj => stdio}/sprintf.c | 0 {stdio.subproj => stdio}/sscanf.c | 0 stdio/stdio.3 | 297 +++ {stdio.subproj => stdio}/stdio.c | 0 {stdio.subproj => stdio}/tempnam.c | 0 {stdio.subproj => stdio}/tmpfile.c | 0 stdio/tmpnam.3 | 229 +++ {stdio.subproj => stdio}/tmpnam.c | 9 +- stdio/ungetc.3 | 101 + {stdio.subproj => stdio}/ungetc.c | 0 stdio/vasprintf.c | 65 + {stdio.subproj => stdio}/vfprintf.c | 432 +++- {stdio.subproj => stdio}/vfscanf.c | 17 +- {stdio.subproj => stdio}/vprintf.c | 0 {stdio.subproj => stdio}/vscanf.c | 0 {stdio.subproj => stdio}/vsnprintf.c | 0 {stdio.subproj => stdio}/vsprintf.c | 0 {stdio.subproj => stdio}/vsscanf.c | 0 {stdio.subproj => stdio}/wbuf.c | 0 {stdio.subproj => stdio}/wsetup.c | 0 stdlib.subproj/Makefile | 51 - stdlib.subproj/Makefile.postamble | 100 - stdlib.subproj/Makefile.preamble | 137 -- stdlib.subproj/PB.project | 51 - stdlib/Makefile.inc | 45 + stdlib/a64l.3 | 145 ++ stdlib/a64l.c | 47 + stdlib/abort.3 | 83 + {stdlib.subproj => stdlib}/abort.c | 31 +- stdlib/abs.3 | 77 + stdlib/alloca.3 | 81 + stdlib/atexit.3 | 80 + {stdlib.subproj => stdlib}/atexit.c | 0 {stdlib.subproj => stdlib}/atexit.h | 0 stdlib/atof.3 | 97 + {stdlib.subproj => stdlib}/atof.c | 0 stdlib/atoi.3 | 93 + {stdlib.subproj => stdlib}/atoi.c | 0 stdlib/atol.3 | 77 + {stdlib.subproj => stdlib}/atol.c | 0 stdlib/bsearch.3 | 93 + {stdlib.subproj => stdlib}/bsearch.c | 0 stdlib/div.3 | 70 + {stdlib.subproj => stdlib}/div.c | 0 stdlib/exit.3 | 98 + {stdlib.subproj => stdlib}/exit.c | 0 stdlib/getenv.3 | 164 ++ {stdlib.subproj => stdlib}/getenv.c | 0 stdlib/getopt.3 | 266 +++ {stdlib.subproj => stdlib}/getopt.c | 0 stdlib/getsubopt.3 | 149 ++ {stdlib.subproj => stdlib}/getsubopt.c | 0 stdlib/hcreate.3 | 206 ++ {stdlib.subproj => stdlib}/heapsort.c | 0 stdlib/l64a.c | 47 + stdlib/labs.3 | 69 + {stdlib.subproj => stdlib}/labs.c | 0 stdlib/ldiv.3 | 73 + {stdlib.subproj => stdlib}/ldiv.c | 0 stdlib/malloc.3 | 483 +++++ stdlib/memory.3 | 81 + {stdlib.subproj => stdlib}/merge.c | 0 {stdlib.subproj => stdlib}/putenv.c | 0 stdlib/qsort.3 | 231 +++ {stdlib.subproj => stdlib}/qsort.c | 0 stdlib/radixsort.3 | 161 ++ {stdlib.subproj => stdlib}/radixsort.c | 16 +- stdlib/rand.3 | 117 ++ stdlib/rand.c | 107 + stdlib/random.3 | 191 ++ {stdlib.subproj => stdlib}/random.c | 0 stdlib/reallocf.c | 39 + stdlib/realpath.3 | 128 ++ {stdlib.subproj => stdlib}/setenv.c | 0 stdlib/strfmon.3 | 92 + stdlib/strtod.3 | 140 ++ {stdlib.subproj => stdlib}/strtod.c | 7 + stdlib/strtol.3 | 207 ++ {stdlib.subproj => stdlib}/strtol.c | 0 stdlib.subproj/strtoq.c => stdlib/strtoll.c | 52 +- stdlib/strtoq.c | 61 + stdlib/strtoul.3 | 198 ++ {stdlib.subproj => stdlib}/strtoul.c | 0 stdlib.subproj/strtouq.c => stdlib/strtoull.c | 55 +- stdlib/strtouq.c | 61 + stdlib/system.3 | 103 + {stdlib.subproj => stdlib}/system.c | 9 +- stdlib/tsearch.3 | 118 ++ stdtime/Makefile.inc | 17 + stdtime/asctime.c | 78 + stdtime/ctime.3 | 363 ++++ stdtime/difftime.c | 79 + stdtime/localtime.c | 1770 +++++++++++++++++ stdtime/private.h | 220 ++ stdtime/strftime.3 | 265 +++ stdtime/strftime.c | 459 +++++ stdtime/strptime.3 | 139 ++ stdtime/strptime.c | 560 ++++++ stdtime/time2posix.3 | 120 ++ stdtime/timelocal.c | 244 +++ stdtime/timelocal.h | 54 + stdtime/tzfile.5 | 138 ++ stdtime/tzfile.h | 190 ++ string.subproj/Makefile | 51 - string.subproj/Makefile.postamble | 100 - string.subproj/Makefile.preamble | 137 -- string.subproj/PB.project | 47 - string/Makefile.inc | 47 + string/bcmp.3 | 74 + string/bcopy.3 | 74 + string/bstring.3 | 112 ++ string/bzero.3 | 71 + string/ffs.3 | 64 + string/index.3 | 83 + {string.subproj => string}/index.c | 0 string/memccpy.3 | 76 + {string.subproj => string}/memccpy.c | 0 string/memchr.3 | 82 + {string.subproj => string}/memchr.c | 0 string/memcmp.3 | 85 + {string.subproj => string}/memcmp.c | 0 string/memcpy.3 | 86 + string/memmove.3 | 78 + string/memset.3 | 73 + {string.subproj => string}/memset.c | 3 + string/rindex.3 | 85 + {string.subproj => string}/rindex.c | 0 {string.subproj => string}/rindix.c | 0 string/strcasecmp.3 | 97 + {string.subproj => string}/strcasecmp.c | 0 string/strcat.3 | 101 + string/strchr.3 | 88 + {string.subproj => string}/strchr.c | 0 string/strcmp.3 | 104 + {string.subproj => string}/strcmp.s | 0 string/strcoll.3 | 75 + {string.subproj => string}/strcoll.c | 0 string/strcpy.3 | 165 ++ string/strcspn.3 | 85 + {string.subproj => string}/strcspn.c | 0 string/strdup.3 | 70 + {string.subproj => string}/strdup.c | 0 string/strerror.3 | 130 ++ {string.subproj => string}/strerror.c | 0 {string.subproj => string}/strftime.c | 0 string/string.3 | 158 ++ string/strlcat.c | 74 + string/strlcpy.3 | 201 ++ string/strlcpy.c | 74 + string/strlen.3 | 73 + string/strmode.3 | 153 ++ {string.subproj => string}/strmode.c | 0 string/strpbrk.3 | 80 + {string.subproj => string}/strpbrk.c | 0 string/strrchr.3 | 91 + string/strsep.3 | 121 ++ {string.subproj => string}/strsep.c | 0 string/strspn.3 | 80 + {string.subproj => string}/strspn.c | 0 string/strstr.3 | 144 ++ {string.subproj => string}/strstr.c | 0 string/strtok.3 | 175 ++ string/strtok.c | 168 ++ string/strxfrm.3 | 99 + {string.subproj => string}/strxfrm.c | 0 string/swab.3 | 68 + {string.subproj => string}/swab.c | 0 string/wmemchr.3 | 145 ++ sys.subproj/Makefile | 52 - sys.subproj/Makefile.postamble | 106 - sys.subproj/Makefile.preamble | 139 -- sys.subproj/PB.project | 45 - sys.subproj/i386.subproj/Makefile | 127 -- sys.subproj/i386.subproj/Makefile.postamble | 100 - sys.subproj/i386.subproj/Makefile.preamble | 137 -- sys.subproj/i386.subproj/PB.project | 211 -- sys.subproj/ppc.subproj/Makefile | 132 -- sys.subproj/ppc.subproj/Makefile.postamble | 100 - sys.subproj/ppc.subproj/Makefile.preamble | 138 -- sys.subproj/ppc.subproj/PB.project | 216 -- sys.subproj/sigprocmask.c | 51 - sys/CLIB-LIST | 679 +++++++ sys/MISSING-MANPAGE | 9 + sys/MISSING_SYSCALLS | 8 + sys/Makefile.inc | 150 ++ sys/REQUIRED-MACROS | 3 + sys/SYSCALL-LIST | 145 ++ crt_externs.c => sys/crt_externs.c | 6 + {sys.subproj => sys}/errno.c | 2 +- sys/getdtablesize.2 | 63 + {sys.subproj => sys}/getdtablesize.c | 0 {sys.subproj => sys}/gettimeofday.c | 8 + {sys.subproj => sys}/msync.2 | 0 sys/nanosleep.2 | 104 + sys/pthread_kill.2 | 75 + sys/pthread_sigmask.2 | 94 + {sys.subproj => sys}/sem_close.2 | 3 +- {sys.subproj => sys}/sem_open.2 | 3 +- {sys.subproj => sys}/sem_post.2 | 3 +- {sys.subproj => sys}/sem_trywait.2 | 0 {sys.subproj => sys}/sem_unlink.2 | 3 +- {sys.subproj => sys}/sem_wait.2 | 3 +- sys/setregid.2 | 92 + sys/setreuid.2 | 90 + {sys.subproj => sys}/shm_open.2 | 3 +- {sys.subproj => sys}/shm_unlink.2 | 3 +- {sys.subproj => sys}/sigaction.c | 20 +- {sys.subproj => sys}/sigcatch.c | 0 {sys.subproj => sys}/sigcatch.h | 0 {sys.subproj => sys}/sigsuspend.c | 0 {sys.subproj => sys}/sigtramp.c | 21 +- sys/sigwait.2 | 82 + threads.subproj/Makefile | 57 - threads.subproj/Makefile.postamble | 100 - threads.subproj/Makefile.preamble | 137 -- threads.subproj/PB.project | 28 - threads.subproj/i386.subproj/Makefile | 45 - .../i386.subproj/Makefile.postamble | 100 - .../i386.subproj/Makefile.preamble | 137 -- threads.subproj/i386.subproj/PB.project | 23 - threads.subproj/ppc.subproj/Makefile | 43 - .../ppc.subproj/Makefile.postamble | 100 - threads.subproj/ppc.subproj/Makefile.preamble | 137 -- threads.subproj/ppc.subproj/PB.project | 23 - threads/Makefile.inc | 7 + {threads.subproj => threads}/cprocs.c | 0 .../cthread_internals.h | 0 {threads.subproj => threads}/cthreads.c | 8 +- {threads.subproj => threads}/cthreads.h | 0 {threads.subproj => threads}/lu_utils.c | 2 +- {threads.subproj => threads}/mig_support.c | 0 util.subproj/Makefile | 45 - util.subproj/Makefile.postamble | 100 - util.subproj/Makefile.preamble | 137 -- util.subproj/PB.project | 23 - util/Makefile.inc | 3 + {util.subproj => util}/login.c | 0 {util.subproj => util}/login_tty.c | 0 {util.subproj => util}/logout.c | 0 {util.subproj => util}/logwtmp.c | 0 {util.subproj => util}/pty.c | 0 xdr/Makefile.inc | 52 + yp/Makefile.inc | 17 + 1453 files changed, 70028 insertions(+), 13723 deletions(-) create mode 100644 APPLE_LICENSE create mode 100644 CLIB-LIST create mode 100644 GNUmakefile create mode 100644 Info.plist create mode 100644 MISSING-MANPAGE create mode 100644 MISSING_SYSCALLS create mode 100644 Makefile.inc delete mode 100644 Makefile.postamble delete mode 100644 Makefile.preamble create mode 100644 Makefile.xbs delete mode 100644 PB.project create mode 100644 REQUIRED-MACROS create mode 100644 SYSCALL-LIST create mode 100644 compat-43/Makefile.inc create mode 100644 compat-43/creat.2 rename {compat43.subproj => compat-43}/creat.c (100%) create mode 100644 compat-43/gethostid.3 rename {compat43.subproj => compat-43}/gethostid.c (100%) rename {compat43.subproj => compat-43}/getwd.c (100%) create mode 100644 compat-43/killpg.2 rename {compat43.subproj => compat-43}/killpg.c (100%) rename {compat43.subproj => compat-43}/send.c (100%) rename {compat43.subproj => compat-43}/sethostid.c (100%) rename {compat43.subproj => compat-43}/setpgrp.c (100%) rename {compat43.subproj => compat-43}/setregid.c (100%) rename {compat43.subproj => compat-43}/setreuid.c (100%) rename {compat43.subproj => compat-43}/setrgid.c (100%) create mode 100644 compat-43/setruid.3 rename {compat43.subproj => compat-43}/setruid.c (100%) create mode 100644 compat-43/sigblock.2 rename {compat43.subproj => compat-43}/sigcompat.c (90%) create mode 100644 compat-43/sigpause.2 create mode 100644 compat-43/sigsetmask.2 create mode 100644 compat-43/sigvec.2 delete mode 100644 compat43.subproj/Makefile delete mode 100644 compat43.subproj/Makefile.postamble delete mode 100644 compat43.subproj/Makefile.preamble delete mode 100644 compat43.subproj/PB.project delete mode 100644 db.subproj/Makefile delete mode 100644 db.subproj/Makefile.postamble delete mode 100644 db.subproj/Makefile.preamble delete mode 100644 db.subproj/PB.project delete mode 100644 db.subproj/btree.subproj/Makefile delete mode 100644 db.subproj/btree.subproj/Makefile.postamble delete mode 100644 db.subproj/btree.subproj/Makefile.preamble delete mode 100644 db.subproj/db.subproj/Makefile delete mode 100644 db.subproj/db.subproj/Makefile.postamble delete mode 100644 db.subproj/db.subproj/Makefile.preamble delete mode 100644 db.subproj/db.subproj/PB.project delete mode 100644 db.subproj/hash.subproj/Makefile delete mode 100644 db.subproj/hash.subproj/Makefile.postamble delete mode 100644 db.subproj/hash.subproj/Makefile.preamble delete mode 100644 db.subproj/hash.subproj/PB.project delete mode 100644 db.subproj/mpool.subproj/Makefile delete mode 100644 db.subproj/mpool.subproj/Makefile.postamble delete mode 100644 db.subproj/mpool.subproj/Makefile.preamble delete mode 100644 db.subproj/mpool.subproj/PB.project delete mode 100644 db.subproj/recno.subproj/Makefile delete mode 100644 db.subproj/recno.subproj/Makefile.postamble delete mode 100644 db.subproj/recno.subproj/Makefile.preamble delete mode 100644 db.subproj/recno.subproj/PB.project create mode 100644 db/Makefile.inc create mode 100644 db/btree/Makefile.inc rename {db.subproj/btree.subproj => db/btree}/PB.project (100%) rename {db.subproj/btree.subproj => db/btree}/bt_close.c (100%) rename {db.subproj/btree.subproj => db/btree}/bt_conv.c (100%) rename {db.subproj/btree.subproj => db/btree}/bt_debug.c (100%) rename {db.subproj/btree.subproj => db/btree}/bt_delete.c (100%) rename {db.subproj/btree.subproj => db/btree}/bt_extern.h (100%) rename {db.subproj/btree.subproj => db/btree}/bt_get.c (100%) rename {db.subproj/btree.subproj => db/btree}/bt_open.c (100%) rename {db.subproj/btree.subproj => db/btree}/bt_overflow.c (100%) rename {db.subproj/btree.subproj => db/btree}/bt_page.c (100%) rename {db.subproj/btree.subproj => db/btree}/bt_put.c (100%) rename {db.subproj/btree.subproj => db/btree}/bt_search.c (100%) rename {db.subproj/btree.subproj => db/btree}/bt_seq.c (100%) rename {db.subproj/btree.subproj => db/btree}/bt_split.c (100%) rename {db.subproj/btree.subproj => db/btree}/bt_stack.c (100%) rename {db.subproj/btree.subproj => db/btree}/bt_utils.c (100%) rename {db.subproj/btree.subproj => db/btree}/btree.h (100%) create mode 100644 db/db/Makefile.inc rename {db.subproj/db.subproj => db/db}/db.c (100%) create mode 100644 db/hash/Makefile.inc rename {db.subproj/hash.subproj => db/hash}/extern.h (100%) rename {db.subproj/hash.subproj => db/hash}/hash.c (100%) rename {db.subproj/hash.subproj => db/hash}/hash.h (100%) rename {db.subproj/hash.subproj => db/hash}/hash_bigkey.c (100%) rename {db.subproj/hash.subproj => db/hash}/hash_buf.c (100%) rename {db.subproj/hash.subproj => db/hash}/hash_func.c (100%) rename {db.subproj/hash.subproj => db/hash}/hash_log2.c (100%) rename {db.subproj/hash.subproj => db/hash}/hash_page.c (100%) rename {db.subproj/hash.subproj => db/hash}/hsearch.c (100%) rename {db.subproj/hash.subproj => db/hash}/ndbm.c (100%) rename {db.subproj/hash.subproj => db/hash}/page.h (100%) rename {db.subproj/hash.subproj => db/hash}/search.h (100%) create mode 100644 db/man/Makefile.inc create mode 100644 db/man/btree.3 create mode 100644 db/man/dbm.3 create mode 100644 db/man/dbopen.3 create mode 100644 db/man/hash.3 create mode 100644 db/man/mpool.3 create mode 100644 db/man/recno.3 create mode 100644 db/mpool/Makefile.inc rename {db.subproj/mpool.subproj => db/mpool}/mpool.c (100%) create mode 100644 db/recno/Makefile.inc rename {db.subproj/recno.subproj => db/recno}/extern.h (100%) rename {db.subproj/recno.subproj => db/recno}/rec_close.c (100%) rename {db.subproj/recno.subproj => db/recno}/rec_delete.c (100%) rename {db.subproj/recno.subproj => db/recno}/rec_get.c (100%) rename {db.subproj/recno.subproj => db/recno}/rec_open.c (100%) rename {db.subproj/recno.subproj => db/recno}/rec_put.c (100%) rename {db.subproj/recno.subproj => db/recno}/rec_search.c (100%) rename {db.subproj/recno.subproj => db/recno}/rec_seq.c (100%) rename {db.subproj/recno.subproj => db/recno}/rec_utils.c (100%) rename {db.subproj/recno.subproj => db/recno}/recno.h (100%) create mode 100644 dpkg/control delete mode 100644 gen.subproj/Makefile delete mode 100644 gen.subproj/Makefile.postamble delete mode 100644 gen.subproj/Makefile.preamble delete mode 100644 gen.subproj/PB.project delete mode 100644 gen.subproj/i386.subproj/Makefile delete mode 100644 gen.subproj/i386.subproj/Makefile.postamble delete mode 100644 gen.subproj/i386.subproj/Makefile.preamble delete mode 100644 gen.subproj/i386.subproj/PB.project delete mode 100644 gen.subproj/ppc.subproj/Makefile delete mode 100644 gen.subproj/ppc.subproj/Makefile.postamble delete mode 100644 gen.subproj/ppc.subproj/Makefile.preamble delete mode 100644 gen.subproj/ppc.subproj/PB.project delete mode 100755 gen.subproj/ppc.subproj/blockmoof.s delete mode 100644 gen.subproj/ppc.subproj/bzero.s delete mode 100644 gen.subproj/ppc.subproj/strlen.s create mode 100644 gen/Makefile.inc rename {gen.subproj => gen}/NSSystemDirectories.c (96%) create mode 100644 gen/_rand48.c create mode 100644 gen/alarm.3 rename {gen.subproj => gen}/alarm.c (100%) create mode 100644 gen/arc4random.3 create mode 100644 gen/arc4random.c rename {gen.subproj => gen}/assert.c (100%) create mode 100644 gen/authentication.c create mode 100644 gen/basename.3 create mode 100644 gen/basename.c create mode 100644 gen/clock.3 rename {gen.subproj => gen}/clock.c (100%) rename {gen.subproj => gen}/closedir.c (100%) create mode 100644 gen/confstr.3 rename {gen.subproj => gen}/confstr.c (100%) rename {gen.subproj => gen}/crypt.c (100%) create mode 100644 gen/ctermid.3 rename {gen.subproj => gen}/ctermid.c (100%) rename {gen.subproj => gen}/ctime.c (100%) create mode 100644 gen/daemon.3 rename {gen.subproj => gen}/daemon.c (100%) create mode 100644 gen/devname.3 rename {gen.subproj => gen}/devname.c (80%) rename {gen.subproj => gen}/difftime.c (100%) create mode 100644 gen/directory.3 create mode 100644 gen/dirname.3 create mode 100644 gen/dirname.c rename {gen.subproj => gen}/disklabel.c (100%) create mode 100644 gen/drand48.c create mode 100644 gen/erand48.c create mode 100644 gen/err.3 rename {gen.subproj => gen}/err.c (100%) rename {gen.subproj => gen}/errlst.c (100%) create mode 100644 gen/exec.3 rename {gen.subproj => gen}/exec.c (100%) create mode 100644 gen/fmtcheck.3 create mode 100644 gen/fnmatch.3 rename {gen.subproj => gen}/fnmatch.c (68%) create mode 100644 gen/frexp.3 create mode 100644 gen/fstab.c rename {gen.subproj => gen}/ftok.3 (72%) rename {gen.subproj => gen}/ftok.c (100%) create mode 100644 gen/fts.3 rename {gen.subproj => gen}/fts.c (100%) create mode 100644 gen/getbootfile.3 create mode 100644 gen/getbsize.3 rename {gen.subproj => gen}/getbsize.c (100%) create mode 100644 gen/getcap.3 rename {gen.subproj => gen}/getcap.c (100%) create mode 100644 gen/getcwd.3 rename {gen.subproj => gen}/getcwd.c (100%) create mode 100644 gen/getdomainname.3 create mode 100644 gen/getfsent.3 create mode 100644 gen/getgrent.3 create mode 100644 gen/getgrouplist.3 rename string.subproj/strtok.c => gen/getgrouplist.c (71%) create mode 100644 gen/gethostname.3 rename {gen.subproj => gen}/gethostname.c (100%) create mode 100644 gen/getloadavg.3 rename {gen.subproj => gen}/getloadavg.c (100%) rename {gen.subproj => gen}/getlogin.c (93%) create mode 100644 gen/getmntinfo.3 rename {gen.subproj => gen}/getmntinfo.c (100%) create mode 100644 gen/getnetgrent.3 create mode 100644 gen/getobjformat.3 create mode 100644 gen/getpagesize.3 rename {gen.subproj => gen}/getpagesize.c (100%) create mode 100644 gen/getpass.3 rename {gen.subproj => gen}/getpass.c (100%) create mode 100644 gen/getpeereid.3 create mode 100644 gen/getpwent.3 create mode 100644 gen/getttyent.3 rename {gen.subproj => gen}/getttyent.c (96%) create mode 100644 gen/getusershell.3 rename {gen.subproj => gen}/getusershell.c (100%) create mode 100644 gen/getvfsbyname.3 rename {gen.subproj => gen}/getvfsbyname.c (100%) create mode 100644 gen/getvfsent.3 create mode 100644 gen/glob.3 create mode 100644 gen/glob.c rename gen.subproj/i386.subproj/bzero.c => gen/hton.c (64%) create mode 100644 gen/initgroups.3 rename {gen.subproj => gen}/isatty.c (100%) create mode 100644 gen/isinf.3 rename {gen.subproj => gen}/isnan.c (100%) create mode 100644 gen/jrand48.c create mode 100644 gen/lcong48.c create mode 100644 gen/ldexp.3 create mode 100644 gen/lockf.3 create mode 100644 gen/lockf.c create mode 100644 gen/lrand48.c rename {gen.subproj => gen}/malloc.c (80%) create mode 100644 gen/modf.3 create mode 100644 gen/mrand48.c create mode 100644 gen/msgctl.3 create mode 100644 gen/msgget.3 create mode 100644 gen/msgrcv.3 create mode 100644 gen/msgsnd.3 rename {gen.subproj => gen}/nanosleep.c (100%) create mode 100644 gen/nice.3 rename {gen.subproj => gen}/nice.c (100%) create mode 100644 gen/nlist.3 rename {gen.subproj => gen}/nlist.c (98%) create mode 100644 gen/nrand48.c rename {gen.subproj => gen}/opendir.c (100%) create mode 100644 gen/pause.3 rename {gen.subproj => gen}/pause.c (100%) create mode 100644 gen/popen.3 rename {gen.subproj => gen}/popen.c (100%) create mode 100644 gen/psignal.3 rename {gen.subproj => gen}/psignal.c (100%) create mode 100644 gen/pwcache.3 rename net.subproj/iso_addr.c => gen/pwcache.c (58%) create mode 100644 gen/raise.3 rename {gen.subproj => gen}/raise.c (100%) create mode 100644 gen/rand48.3 create mode 100644 gen/rand48.h create mode 100644 gen/rcmd.c rename {gen.subproj => gen}/readdir.c (100%) create mode 100644 gen/readdir_r.c rename {gen.subproj => gen}/rewinddir.c (100%) create mode 100644 gen/rfork_thread.3 rename {gen.subproj => gen}/scalable_malloc.c (87%) rename {gen.subproj => gen}/scalable_malloc.h (100%) create mode 100644 gen/scandir.3 rename {gen.subproj => gen}/scandir.c (100%) create mode 100644 gen/seed48.c rename {gen.subproj => gen}/seekdir.c (100%) rename {gen.subproj => gen}/sethostname.c (100%) create mode 100644 gen/setjmp.3 rename {gen.subproj => gen}/setlogin.c (100%) create mode 100644 gen/setmode.3 rename {gen.subproj => gen}/setmode.c (90%) create mode 100644 gen/siginterrupt.3 rename {gen.subproj => gen}/siginterrupt.c (100%) rename {gen.subproj => gen}/siglist.c (100%) create mode 100644 gen/signal.3 rename {gen.subproj => gen}/signal.c (100%) create mode 100644 gen/sigsetops.3 rename {gen.subproj => gen}/sigsetops.c (93%) create mode 100644 gen/sleep.3 rename {gen.subproj => gen}/sleep.c (100%) create mode 100644 gen/srand48.c rename {gen.subproj => gen}/stack_logging.c (99%) rename {gen.subproj => gen}/stack_logging.h (100%) create mode 100644 gen/strchr.c create mode 100644 gen/stringlist.3 create mode 100644 gen/strtofflags.3 create mode 100644 gen/strtofflags.c create mode 100644 gen/sysconf.3 rename {gen.subproj => gen}/sysconf.c (100%) create mode 100644 gen/sysctl.3 rename {gen.subproj => gen}/sysctl.c (100%) rename {gen.subproj => gen}/sysctlbyname.c (100%) create mode 100644 gen/syslog.3 rename {gen.subproj => gen}/syslog.c (100%) create mode 100644 gen/tcgetpgrp.3 create mode 100644 gen/tcsendbreak.3 create mode 100644 gen/tcsetattr.3 create mode 100644 gen/tcsetpgrp.3 rename {gen.subproj => gen}/telldir.c (100%) rename {gen.subproj => gen}/termios.c (100%) create mode 100644 gen/time.3 rename {gen.subproj => gen}/time.c (100%) create mode 100644 gen/times.3 rename {gen.subproj => gen}/times.c (100%) create mode 100644 gen/timezone.3 rename {gen.subproj => gen}/timezone.c (100%) create mode 100644 gen/ttyname.3 rename {gen.subproj => gen}/ttyname.c (93%) rename {gen.subproj => gen}/ttyslot.c (100%) create mode 100644 gen/tzset.3 create mode 100644 gen/ualarm.3 rename {gen.subproj => gen}/ualarm.c (100%) create mode 100644 gen/ulimit.c create mode 100644 gen/uname.3 rename {gen.subproj => gen}/uname.c (100%) create mode 100644 gen/unvis.3 rename {gen.subproj => gen}/unvis.c (100%) create mode 100644 gen/usleep.3 create mode 100644 gen/usleep.c create mode 100644 gen/utime.3 rename {gen.subproj => gen}/utime.c (100%) create mode 100644 gen/valloc.3 create mode 100644 gen/vis.3 rename {gen.subproj => gen}/vis.c (100%) rename {gen.subproj => gen}/wait.c (100%) rename {gen.subproj => gen}/wait3.c (100%) rename {gen.subproj => gen}/waitpid.c (100%) rename {gen.subproj => gen}/zone.c (100%) create mode 100644 gmon/Makefile.inc rename {gen.subproj => gmon}/gmon.c (100%) delete mode 100644 headers.subproj/Makefile delete mode 100644 headers.subproj/Makefile.postamble delete mode 100644 headers.subproj/Makefile.preamble delete mode 100644 headers.subproj/PB.project create mode 100644 i386/gen/Makefile.inc rename {gen.subproj/i386.subproj => i386/gen}/abs.c (100%) rename {gen.subproj/i386.subproj => i386/gen}/bcmp.c (100%) create mode 100644 i386/gen/bcopy.s create mode 100644 i386/gen/bcopy_init.c create mode 100644 i386/gen/bzero.s rename {gen.subproj/i386.subproj => i386/gen}/ecvt.c (100%) rename {gen.subproj/i386.subproj => i386/gen}/ffs.c (100%) rename {gen.subproj/i386.subproj => i386/gen}/insque.c (100%) rename {gen.subproj/i386.subproj => i386/gen}/isinf.c (72%) rename {gen.subproj/i386.subproj => i386/gen}/mcount.s (100%) rename gen.subproj/i386.subproj/memcpy.c => i386/gen/memcpy.s (98%) rename gen.subproj/i386.subproj/memmove.c => i386/gen/memmove.s (98%) rename {gen.subproj/i386.subproj => i386/gen}/remque.c (100%) rename {gen.subproj/i386.subproj => i386/gen}/setjmperr.c (100%) rename {gen.subproj/i386.subproj => i386/gen}/strcat.c (100%) rename stdio.subproj/fvwrite.h => i386/gen/strcmp.c (84%) rename {gen.subproj/i386.subproj => i386/gen}/strcpy.c (100%) rename {gen.subproj/i386.subproj => i386/gen}/strlen.c (100%) rename {gen.subproj/i386.subproj => i386/gen}/strncat.c (100%) rename {gen.subproj/i386.subproj => i386/gen}/strncmp.c (100%) rename {gen.subproj/i386.subproj => i386/gen}/strncpy.c (100%) create mode 100644 i386/mach/Makefile.inc create mode 100644 i386/mach/mach_absolute_time.c rename {sys.subproj/i386.subproj => i386/sys}/ATPgetreq.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/ATPgetrsp.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/ATPsndreq.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/ATPsndrsp.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/ATgetmsg.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/ATputmsg.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/ATsocket.s (100%) create mode 100644 i386/sys/Makefile.inc rename {sys.subproj/i386.subproj => i386/sys}/SYS.h (97%) rename {sys.subproj/i386.subproj => i386/sys}/_exit.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/_getlogin.s (100%) create mode 100644 i386/sys/_pthread_kill.s rename {sys.subproj/i386.subproj => i386/sys}/_setjmp.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/_setlogin.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/_sysctl.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/accept.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/access.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/acct.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/add_profil.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/adjtime.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/bind.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/cerror.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/chdir.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/checkuseraccess.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/chflags.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/chmod.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/chown.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/chroot.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/close.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/connect.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/dup.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/dup2.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/exchangedata.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/execve.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/fchdir.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/fchflags.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/fchmod.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/fchown.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/fcntl.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/flock.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/fork.s (99%) rename {sys.subproj/i386.subproj => i386/sys}/fpathconf.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/fstat.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/fstatfs.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/fstatv.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/fsync.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/ftruncate.s (100%) rename sys.subproj/i386.subproj/lfs_bmapv.s => i386/sys/futimes.s (97%) rename {sys.subproj/i386.subproj => i386/sys}/getattrlist.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/getdirentries.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/getdirentriesattr.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/getegid.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/geteuid.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/getfh.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/getfsstat.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/getgid.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/getgroups.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/getitimer.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/getpeername.s (100%) rename sys.subproj/i386.subproj/lfs_markv.s => i386/sys/getpgid.s (97%) rename {sys.subproj/i386.subproj => i386/sys}/getpgrp.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/getpid.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/getppid.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/getpriority.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/getrlimit.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/getrusage.s (100%) rename sys.subproj/i386.subproj/lfs_segwait.s => i386/sys/getsid.s (97%) rename {sys.subproj/i386.subproj => i386/sys}/getsockname.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/getsockopt.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/getuid.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/ioctl.s (100%) create mode 100644 i386/sys/issetugid.s rename {sys.subproj/i386.subproj => i386/sys}/kill.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/ktrace.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/link.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/listen.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/load_shared_file.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/lseek.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/lstat.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/lstatv.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/madvise.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/mincore.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/minherit.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/mkcomplex.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/mkdir.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/mkfifo.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/mknod.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/mlock.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/mlockall.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/mmap.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/mount.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/mprotect.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/msgctl.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/msgget.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/msgrcv.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/msgsnd.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/msgsys.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/msync.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/munlock.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/munlockall.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/munmap.s (100%) create mode 100644 i386/sys/new_system_shared_regions.s rename {sys.subproj/i386.subproj => i386/sys}/nfssvc.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/open.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/pathconf.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/pipe.s (100%) create mode 100644 i386/sys/posix_madvise.s rename sys.subproj/i386.subproj/lfs_segclean.s => i386/sys/pread.s (97%) rename {sys.subproj/i386.subproj => i386/sys}/profil.s (100%) create mode 100644 i386/sys/pthread_sigmask.s rename {sys.subproj/i386.subproj => i386/sys}/ptrace.s (100%) create mode 100644 i386/sys/pwrite.s rename {sys.subproj/i386.subproj => i386/sys}/quota.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/quotactl.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/read.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/readlink.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/readv.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/reboot.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/recvfrom.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/recvmsg.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/rename.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/reset_shared_file.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/revoke.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/rmdir.s (100%) create mode 100644 i386/sys/s.template rename {sys.subproj/i386.subproj => i386/sys}/searchfs.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/select.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/sem_close.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/sem_destroy.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/sem_getvalue.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/sem_init.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/sem_open.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/sem_post.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/sem_trywait.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/sem_unlink.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/sem_wait.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/semconfig.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/semctl.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/semget.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/semop.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/semsys.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/sendmsg.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/sendto.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/setattrlist.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/setegid.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/seteuid.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/setgid.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/setgroups.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/setitimer.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/setjmp.s (98%) rename {sys.subproj/i386.subproj => i386/sys}/setpgid.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/setpriority.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/setprivexec.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/setquota.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/setrlimit.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/setsid.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/setsockopt.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/settimeofday.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/setuid.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/shm_open.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/shm_unlink.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/shmat.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/shmctl.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/shmdt.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/shmget.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/shmsys.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/shutdown.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/sigaltstack.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/sigpending.s (100%) create mode 100644 i386/sys/sigprocmask.s rename {sys.subproj/i386.subproj => i386/sys}/sigreturn.s (100%) create mode 100644 i386/sys/sigwait.s rename {sys.subproj/i386.subproj => i386/sys}/socket.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/socketpair.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/stat.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/statfs.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/statv.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/swapon.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/symlink.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/sync.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/syscall.s (100%) rename sys.subproj/i386.subproj/table.s => i386/sys/systable.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/truncate.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/umask.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/undelete.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/unlink.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/unmount.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/utimes.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/vfork.s (98%) rename {sys.subproj/i386.subproj => i386/sys}/wait4.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/write.s (100%) rename {sys.subproj/i386.subproj => i386/sys}/writev.s (100%) create mode 100644 i386/threads/Makefile.inc rename {threads.subproj/i386.subproj => i386/threads}/thread.c (98%) create mode 100644 include/Makefile.inc rename {headers.subproj => include}/NSSystemDirectories.h (96%) create mode 100644 include/ar.h create mode 100644 include/arpa/Makefile.inc create mode 100644 include/arpa/ftp.h create mode 100644 include/arpa/nameser_compat.h create mode 100644 include/arpa/telnet.h create mode 100644 include/arpa/tftp.h rename {headers.subproj => include}/asm.h (100%) create mode 100644 include/authentication.h create mode 100644 include/bitstring.h create mode 100644 include/c.h rename {headers.subproj => include}/crt_externs.h (97%) create mode 100644 include/ctype.h create mode 100644 include/db.h create mode 100644 include/dirent.h create mode 100644 include/disktab.h create mode 100644 include/err.h rename mach.subproj/bootstrap.defs => include/errno.h (90%) create mode 100644 include/fcntl.h create mode 100644 include/fnmatch.h create mode 100644 include/fsproperties.h create mode 100644 include/fstab.h create mode 100644 include/fts.h create mode 100644 include/glob.h rename locale.subproj/ctype.c => include/grp.h (77%) create mode 100644 include/kvm.h rename {headers.subproj => include}/libc.h (100%) create mode 100644 include/libgen.h create mode 100644 include/limits.h create mode 100644 include/locale.h rename locale.subproj/localeconv.c => include/memory.h (91%) rename {headers.subproj => include}/monitor.h (100%) create mode 100644 include/mpool.h create mode 100644 include/ndbm.h create mode 100644 include/netdb.h rename locale.subproj/isctype.c => include/nlist.h (66%) create mode 100644 include/objc/Makefile.inc rename {gen.subproj => include/objc}/malloc.h (100%) rename {gen.subproj => include/objc}/zone.h (100%) create mode 100644 include/paths.h create mode 100644 include/protocols/Makefile.inc create mode 100644 include/protocols/dumprestore.h create mode 100644 include/protocols/routed.h create mode 100644 include/protocols/rwhod.h create mode 100644 include/protocols/talkd.h create mode 100644 include/protocols/timed.h rename gen.subproj/i386.subproj/bcopy.c => include/pwd.h (52%) create mode 100644 include/ranlib.h create mode 100644 include/regex.h create mode 100644 include/regexp.h create mode 100644 include/rune.h create mode 100644 include/runetype.h create mode 100644 include/semaphore.h create mode 100644 include/setjmp.h rename gen.subproj/usleep.c => include/sgtty.h (89%) rename stdio.subproj/mktemp.c => include/signal.h (61%) create mode 100644 include/stab.h rename {headers.subproj => include}/standards.h (100%) create mode 100644 include/stddef.h create mode 100644 include/stdio.h create mode 100644 include/stdlib.h create mode 100644 include/string.h rename stdlib.subproj/rand.c => include/strings.h (90%) create mode 100644 include/struct.h create mode 100644 include/sysexits.h create mode 100644 include/syslog.h rename net.subproj/ns_ntoa.c => include/tar.h (65%) create mode 100644 include/termios.h create mode 100644 include/time.h create mode 100644 include/ttyent.h create mode 100644 include/tzfile.h create mode 100644 include/ucontext.h create mode 100644 include/ulimit.h create mode 100644 include/unistd.h create mode 100644 include/util.h rename stdio.subproj/remove.c => include/utime.h (87%) rename locale.subproj/lconv.c => include/utmp.h (75%) create mode 100644 include/vis.h delete mode 100644 internat.subproj/Makefile delete mode 100644 internat.subproj/Makefile.postamble delete mode 100644 internat.subproj/Makefile.preamble delete mode 100644 internat.subproj/PB.project create mode 100644 internat/Makefile.inc rename {internat.subproj => internat}/NXCType.c (100%) rename {internat.subproj => internat}/NXCType.h (100%) rename {internat.subproj => internat}/NXIsAlNum.c (100%) rename {internat.subproj => internat}/NXIsAlpha.c (100%) rename {internat.subproj => internat}/NXIsAscii.c (100%) rename {internat.subproj => internat}/NXIsCntrl.c (100%) rename {internat.subproj => internat}/NXIsDigit.c (100%) rename {internat.subproj => internat}/NXIsGraph.c (100%) rename {internat.subproj => internat}/NXIsLower.c (100%) rename {internat.subproj => internat}/NXIsPrint.c (100%) rename {internat.subproj => internat}/NXIsPunct.c (100%) rename {internat.subproj => internat}/NXIsSpace.c (100%) rename {internat.subproj => internat}/NXIsUpper.c (100%) rename {internat.subproj => internat}/NXIsXDigit.c (100%) rename {internat.subproj => internat}/NXToAscii.c (100%) rename {internat.subproj => internat}/NXToLower.c (100%) rename {internat.subproj => internat}/NXToUpper.c (100%) rename {internat.subproj => internat}/_NXToLower.c (100%) rename {internat.subproj => internat}/_NXToUpper.c (100%) delete mode 100644 locale.subproj/Makefile delete mode 100644 locale.subproj/Makefile.postamble delete mode 100644 locale.subproj/Makefile.preamble delete mode 100644 locale.subproj/PB.project delete mode 100644 locale.subproj/setlocale.c create mode 100644 locale/Makefile.inc rename {locale.subproj => locale}/ansi.c (74%) create mode 100644 locale/big5.c create mode 100644 locale/collate.c create mode 100644 locale/collate.h create mode 100644 locale/collcmp.c create mode 100644 locale/ctype.3 create mode 100644 locale/euc.4 rename {locale.subproj => locale}/euc.c (84%) rename {locale.subproj => locale}/frune.c (75%) create mode 100644 locale/isalnum.3 create mode 100644 locale/isalpha.3 create mode 100644 locale/isascii.3 create mode 100644 locale/isblank.3 create mode 100644 locale/iscntrl.3 create mode 100644 locale/isctype.c create mode 100644 locale/isdigit.3 create mode 100644 locale/isgraph.3 create mode 100644 locale/islower.3 create mode 100644 locale/isprint.3 create mode 100644 locale/ispunct.3 create mode 100644 locale/isspace.3 create mode 100644 locale/isupper.3 create mode 100644 locale/isxdigit.3 create mode 100644 locale/lconv.c create mode 100644 locale/localeconv.c create mode 100644 locale/mbrune.3 rename {locale.subproj => locale}/mbrune.c (77%) create mode 100644 locale/mskanji.c create mode 100644 locale/multibyte.3 create mode 100644 locale/nl_langinfo.3 create mode 100644 locale/nomacros.c rename {locale.subproj => locale}/none.c (74%) create mode 100644 locale/rune.3 rename {locale.subproj => locale}/rune.c (56%) create mode 100644 locale/runetype.c create mode 100644 locale/setinvalidrune.c create mode 100644 locale/setlocale.3 create mode 100644 locale/setlocale.c create mode 100644 locale/setlocale.h create mode 100644 locale/setrunelocale.c rename locale.subproj/runetable.c => locale/table.c (55%) create mode 100644 locale/toascii.3 create mode 100644 locale/tolower.3 create mode 100644 locale/tolower.c create mode 100644 locale/toupper.3 create mode 100644 locale/toupper.c create mode 100644 locale/utf2.4 rename {locale.subproj => locale}/utf2.c (80%) delete mode 100644 mach.subproj/Makefile delete mode 100644 mach.subproj/Makefile.postamble delete mode 100644 mach.subproj/Makefile.preamble delete mode 100644 mach.subproj/PB.project delete mode 100644 mach.subproj/headers.subproj/Makefile delete mode 100644 mach.subproj/headers.subproj/Makefile.postamble delete mode 100644 mach.subproj/headers.subproj/Makefile.preamble delete mode 100644 mach.subproj/headers.subproj/PB.project delete mode 100644 mach.subproj/headers.subproj/mig_errors.h delete mode 100644 mach.subproj/mach_absolute_time.c delete mode 100644 mach.subproj/mach_msg.c delete mode 100644 mach.subproj/mach_msg_destroy.c delete mode 100644 mach.subproj/mach_msg_send.c delete mode 100644 mach.subproj/mach_msg_server.c delete mode 100644 mach.subproj/mach_subsystem_join.c delete mode 100644 mach.subproj/servers.subproj/Makefile delete mode 100644 mach.subproj/servers.subproj/Makefile.postamble delete mode 100644 mach.subproj/servers.subproj/Makefile.preamble delete mode 100644 mach.subproj/servers.subproj/PB.project create mode 100644 mach/Makefile.inc rename mach.subproj/mach_msg_receive.c => mach/bootstrap_ports.c (80%) rename {mach.subproj => mach}/clock.defs (100%) rename {mach.subproj => mach}/clock_priv.defs (100%) rename {mach.subproj => mach}/clock_reply.defs (100%) rename {mach.subproj => mach}/clock_sleep.c (100%) rename {mach.subproj => mach}/err_ipc.sub (100%) rename {mach.subproj => mach}/err_kern.sub (100%) rename {mach.subproj => mach}/err_mach_ipc.sub (100%) rename {mach.subproj => mach}/err_server.sub (100%) rename {mach.subproj => mach}/err_us.sub (100%) rename {mach.subproj => mach}/error_codes.c (92%) create mode 100644 mach/errorlib.h rename {mach.subproj => mach}/exc.defs (100%) rename {mach.subproj => mach}/exc_catcher.c (100%) rename {mach.subproj => mach}/exc_catcher_state.c (100%) rename {mach.subproj => mach}/exc_catcher_state_identity.c (100%) rename {mach.subproj => mach}/externs.h (82%) rename {mach.subproj => mach}/fprintf_stderr.c (100%) create mode 100644 mach/headers/Makefile.inc rename {mach.subproj/headers.subproj => mach/headers}/errorlib.h (100%) rename {mach.subproj/headers.subproj => mach/headers}/mach.h (96%) rename {mach.subproj/headers.subproj => mach/headers}/mach_error.h (100%) rename {mach.subproj/headers.subproj => mach/headers}/mach_init.h (100%) rename {mach.subproj/headers.subproj => mach/headers}/mach_interface.h (100%) rename {mach.subproj/headers.subproj => mach/headers}/port_obj.h (100%) rename {mach.subproj/headers.subproj => mach/headers}/sync.h (100%) rename {mach.subproj/headers.subproj => mach/headers}/vm_task.h (100%) rename {mach.subproj => mach}/host_priv.defs (100%) rename {mach.subproj => mach}/host_security.defs (100%) rename {mach.subproj => mach}/ledger.defs (100%) rename {mach.subproj => mach}/lock_set.defs (100%) rename {mach.subproj => mach}/mach_error.c (99%) rename {mach.subproj => mach}/mach_error_string.c (86%) rename {mach.subproj => mach}/mach_host.defs (100%) rename {mach.subproj => mach}/mach_init.c (93%) rename {mach.subproj => mach}/mach_init_ports.c (91%) create mode 100644 mach/mach_msg.c rename {mach.subproj => mach}/mach_port.defs (100%) rename {mach.subproj => mach}/mach_traps.s (100%) rename {mach.subproj => mach}/mig_allocate.c (100%) rename {mach.subproj => mach}/mig_deallocate.c (100%) rename {mach.subproj => mach}/mig_reply_setup.c (100%) rename {mach.subproj => mach}/mig_strncpy.c (98%) rename {mach.subproj => mach}/ms_thread_switch.c (100%) rename {mach.subproj => mach}/notify.defs (100%) rename {mach.subproj => mach}/panic.c (100%) rename {mach.subproj => mach}/port_obj.c (100%) rename {mach.subproj => mach}/processor.defs (100%) rename {mach.subproj => mach}/processor_set.defs (100%) rename {mach.subproj => mach}/sbrk.c (100%) rename {mach.subproj => mach}/semaphore.c (91%) create mode 100644 mach/servers/Makefile.inc rename {mach.subproj/servers.subproj => mach/servers}/bootstrap_defs.h (79%) rename {mach.subproj/servers.subproj => mach/servers}/key_defs.h (100%) rename {mach.subproj/servers.subproj => mach/servers}/ls_defs.h (100%) rename {mach.subproj/servers.subproj => mach/servers}/netname.defs (100%) rename {mach.subproj/servers.subproj => mach/servers}/netname_defs.h (100%) rename {mach.subproj/servers.subproj => mach/servers}/nm_defs.h (100%) rename mach.subproj/servers.subproj/bootstrap.defs => mach/servers/srvbootstrap.defs (52%) rename {mach.subproj => mach}/slot_name.c (100%) rename {mach.subproj => mach}/task.defs (100%) rename {mach.subproj => mach}/thread_act.defs (100%) rename {mach.subproj => mach}/vm_map.defs (100%) delete mode 100644 net.subproj/Makefile delete mode 100644 net.subproj/Makefile.postamble delete mode 100644 net.subproj/Makefile.preamble delete mode 100644 net.subproj/PB.project delete mode 100644 net.subproj/ns_addr.c create mode 100644 net/Makefile.inc create mode 100644 net/addr2ascii.3 create mode 100644 net/byteorder.3 create mode 100644 net/ethers.3 create mode 100644 net/getaddrinfo.3 create mode 100644 net/gethostbyname.3 create mode 100644 net/getifaddrs.3 create mode 100644 net/getipnodebyname.3 create mode 100644 net/getnameinfo.3 create mode 100644 net/getnetent.3 create mode 100644 net/getprotoent.3 create mode 100644 net/getservent.3 create mode 100644 net/hesiod.3 create mode 100644 net/if_indextoname.3 create mode 100644 net/inet.3 create mode 100644 net/inet6_option_space.3 create mode 100644 net/inet6_rthdr_space.3 rename {net.subproj => net}/inet_addr.c (73%) rename {net.subproj => net}/inet_lnaof.c (100%) rename {net.subproj => net}/inet_makeaddr.c (100%) create mode 100644 net/inet_net.3 rename {net.subproj => net}/inet_netof.c (100%) rename {net.subproj => net}/inet_network.c (100%) rename {net.subproj => net}/inet_ntoa.c (100%) create mode 100644 net/linkaddr.3 rename {net.subproj => net}/linkaddr.c (100%) create mode 100644 net/ns.3 rename {net.subproj => net}/nsap_addr.c (91%) create mode 100644 net/nsdispatch.3 create mode 100644 net/rcmd.3 create mode 100644 net/rcmdsh.3 rename {net.subproj => net}/recv.c (100%) create mode 100644 net/resolver.3 create mode 100644 nls/Makefile.inc create mode 100644 posix1e/Makefile.inc create mode 100644 ppc/gen/Makefile.inc rename {gen.subproj/ppc.subproj => ppc/gen}/abs.s (100%) create mode 100644 ppc/gen/assymdefs.c rename {gen.subproj/ppc.subproj => ppc/gen}/bcmp.c (100%) create mode 100644 ppc/gen/bcopy.s create mode 100644 ppc/gen/bzero.s rename {gen.subproj/ppc.subproj => ppc/gen}/ecvt.c (100%) mode change 100755 => 100644 rename {gen.subproj/ppc.subproj => ppc/gen}/ffs.s (100%) rename {gen.subproj/ppc.subproj => ppc/gen}/fp.h (100%) mode change 100755 => 100644 create mode 100644 ppc/gen/genassym.c rename {gen.subproj/ppc.subproj => ppc/gen}/genassym.h (100%) rename {gen.subproj/ppc.subproj => ppc/gen}/insque.c (100%) rename {gen.subproj/ppc.subproj => ppc/gen}/isinf.c (100%) rename {gen.subproj/ppc.subproj => ppc/gen}/mcount.s (100%) rename {gen.subproj/ppc.subproj => ppc/gen}/remque.c (100%) rename {gen.subproj/ppc.subproj => ppc/gen}/setjmperr.c (100%) mode change 100755 => 100644 rename {gen.subproj/ppc.subproj => ppc/gen}/strcat.c (100%) create mode 100644 ppc/gen/strcmp.c rename {gen.subproj/ppc.subproj => ppc/gen}/strcpy.c (100%) create mode 100644 ppc/gen/strlen.s rename {gen.subproj/ppc.subproj => ppc/gen}/strncat.c (100%) rename {gen.subproj/ppc.subproj => ppc/gen}/strncmp.c (100%) rename {gen.subproj/ppc.subproj => ppc/gen}/strncpy.c (100%) create mode 100644 ppc/mach/Makefile.inc create mode 100644 ppc/mach/mach_absolute_time.s rename {sys.subproj/ppc.subproj => ppc/sys}/ATPgetreq.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/ATPgetrsp.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/ATPsndreq.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/ATPsndrsp.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/ATgetmsg.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/ATputmsg.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/ATsocket.s (100%) create mode 100644 ppc/sys/Makefile.inc rename {sys.subproj/ppc.subproj => ppc/sys}/SYS.h (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/_exit.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/_getlogin.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/_longjmp.s (100%) create mode 100644 ppc/sys/_pthread_kill.s rename {sys.subproj/ppc.subproj => ppc/sys}/_setjmp.h (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/_setjmp.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/_setlogin.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/_sysctl.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/accept.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/access.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/acct.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/add_profil.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/adjtime.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/assym.h (100%) create mode 100644 ppc/sys/assymdefs.c rename {sys.subproj/ppc.subproj => ppc/sys}/bind.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/cerror.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/chdir.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/checkuseraccess.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/chflags.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/chmod.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/chown.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/chroot.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/close.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/connect.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/cthread.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/dup.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/dup2.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/exchangedata.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/execve.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/fchdir.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/fchflags.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/fchmod.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/fchown.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/fcntl.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/flock.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/fork.s (97%) rename {sys.subproj/ppc.subproj => ppc/sys}/fpathconf.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/fstat.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/fstatfs.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/fstatv.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/fsync.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/ftruncate.s (100%) rename sys.subproj/ppc.subproj/lfs_bmapv.s => ppc/sys/futimes.s (97%) create mode 100644 ppc/sys/genassym.c rename {sys.subproj/ppc.subproj => ppc/sys}/genassym.h (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/getattrlist.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/getdirentries.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/getdirentriesattr.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/getegid.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/geteuid.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/getfh.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/getfsstat.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/getgid.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/getgroups.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/getitimer.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/getpeername.s (100%) rename sys.subproj/ppc.subproj/lfs_markv.s => ppc/sys/getpgid.s (97%) rename {sys.subproj/ppc.subproj => ppc/sys}/getpgrp.s (100%) create mode 100644 ppc/sys/getpid.s rename {sys.subproj/ppc.subproj => ppc/sys}/getppid.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/getpriority.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/getrlimit.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/getrusage.s (100%) rename sys.subproj/ppc.subproj/getpid.s => ppc/sys/getsid.s (98%) rename {sys.subproj/ppc.subproj => ppc/sys}/getsockname.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/getsockopt.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/getuid.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/ioctl.s (100%) rename sys.subproj/ppc.subproj/lfs_segwait.s => ppc/sys/issetugid.s (97%) rename {sys.subproj/ppc.subproj => ppc/sys}/kill.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/ktrace.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/link.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/listen.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/load_shared_file.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/longjmp.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/lseek.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/lstat.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/lstatv.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/madvise.s (99%) rename {sys.subproj/ppc.subproj => ppc/sys}/mincore.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/minherit.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/mkcomplex.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/mkdir.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/mkfifo.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/mknod.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/mlock.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/mlockall.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/mmap.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/mount.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/mprotect.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/msgctl.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/msgget.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/msgrcv.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/msgsnd.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/msgsys.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/msync.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/munlock.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/munlockall.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/munmap.s (100%) create mode 100644 ppc/sys/new_system_shared_regions.s rename {sys.subproj/ppc.subproj => ppc/sys}/nfssvc.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/open.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/pathconf.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/pipe.s (100%) create mode 100644 ppc/sys/posix_madvise.s create mode 100644 ppc/sys/ppc_gettimeofday.s create mode 100644 ppc/sys/pread.s rename {sys.subproj/ppc.subproj => ppc/sys}/processor_facilities.h (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/processor_facilities.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/profil.s (100%) create mode 100644 ppc/sys/pthread_sigmask.s rename {sys.subproj/ppc.subproj => ppc/sys}/ptrace.s (100%) create mode 100644 ppc/sys/pwrite.s rename {sys.subproj/ppc.subproj => ppc/sys}/quota.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/quotactl.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/read.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/readlink.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/readv.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/reboot.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/recvfrom.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/recvmsg.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/rename.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/reset_shared_file.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/revoke.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/rmdir.s (100%) create mode 100644 ppc/sys/s.template rename {sys.subproj/ppc.subproj => ppc/sys}/searchfs.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/select.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/sem_close.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/sem_destroy.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/sem_getvalue.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/sem_init.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/sem_open.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/sem_post.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/sem_trywait.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/sem_unlink.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/sem_wait.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/semconfig.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/semctl.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/semget.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/semop.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/semsys.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/sendmsg.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/sendto.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/setattrlist.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/setegid.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/seteuid.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/setgid.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/setgroups.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/setitimer.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/setjmp.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/setpgid.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/setpriority.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/setprivexec.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/setquota.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/setrlimit.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/setsid.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/setsockopt.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/settimeofday.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/setuid.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/shm_open.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/shm_unlink.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/shmat.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/shmctl.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/shmdt.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/shmget.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/shmsys.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/shutdown.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/sigaltstack.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/sigpending.s (100%) rename sys.subproj/ppc.subproj/lfs_segclean.s => ppc/sys/sigprocmask.s (97%) rename {sys.subproj/ppc.subproj => ppc/sys}/sigreturn.s (100%) create mode 100644 ppc/sys/sigwait.s rename {sys.subproj/ppc.subproj => ppc/sys}/socket.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/socketpair.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/stat.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/statfs.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/statv.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/swapon.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/symlink.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/sync.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/syscall.s (100%) rename sys.subproj/ppc.subproj/table.s => ppc/sys/systable.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/truncate.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/umask.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/undelete.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/unlink.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/unmount.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/ur_cthread.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/utimes.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/vfork.s (82%) rename {sys.subproj/ppc.subproj => ppc/sys}/wait4.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/write.s (100%) rename {sys.subproj/ppc.subproj => ppc/sys}/writev.s (100%) delete mode 100644 pthreads.subproj/Makefile delete mode 100644 pthreads.subproj/Makefile.postamble delete mode 100644 pthreads.subproj/Makefile.preamble delete mode 100644 pthreads.subproj/PB.project create mode 100644 pthreads/Makefile.inc rename {pthreads.subproj => pthreads}/lock.s (93%) rename {pthreads.subproj => pthreads}/mk_pthread_impl.c (100%) rename {pthreads.subproj => pthreads}/posix_sched.h (100%) create mode 100644 pthreads/pthread.3 rename {pthreads.subproj => pthreads}/pthread.c (67%) rename {pthreads.subproj => pthreads}/pthread.h (74%) create mode 100644 pthreads/pthread_attr.3 create mode 100644 pthreads/pthread_cancel.3 create mode 100644 pthreads/pthread_cleanup_pop.3 create mode 100644 pthreads/pthread_cleanup_push.3 rename {pthreads.subproj => pthreads}/pthread_cond.c (86%) create mode 100644 pthreads/pthread_cond_broadcast.3 create mode 100644 pthreads/pthread_cond_destroy.3 create mode 100644 pthreads/pthread_cond_init.3 create mode 100644 pthreads/pthread_cond_signal.3 create mode 100644 pthreads/pthread_cond_timedwait.3 create mode 100644 pthreads/pthread_cond_wait.3 create mode 100644 pthreads/pthread_condattr.3 create mode 100644 pthreads/pthread_create.3 create mode 100644 pthreads/pthread_detach.3 create mode 100644 pthreads/pthread_equal.3 create mode 100644 pthreads/pthread_exit.3 create mode 100644 pthreads/pthread_getschedparam.3 create mode 100644 pthreads/pthread_getspecific.3 rename {pthreads.subproj => pthreads}/pthread_impl.h (100%) rename {pthreads.subproj => pthreads}/pthread_internals.h (86%) create mode 100644 pthreads/pthread_join.3 create mode 100644 pthreads/pthread_key_create.3 create mode 100644 pthreads/pthread_key_delete.3 rename {pthreads.subproj => pthreads}/pthread_machdep.h (100%) rename {pthreads.subproj => pthreads}/pthread_mutex.c (68%) create mode 100644 pthreads/pthread_mutex_destroy.3 create mode 100644 pthreads/pthread_mutex_init.3 create mode 100644 pthreads/pthread_mutex_lock.3 create mode 100644 pthreads/pthread_mutex_trylock.3 create mode 100644 pthreads/pthread_mutex_unlock.3 create mode 100644 pthreads/pthread_mutexattr.3 create mode 100644 pthreads/pthread_once.3 create mode 100644 pthreads/pthread_rwlock.c create mode 100644 pthreads/pthread_rwlock_destroy.3 create mode 100644 pthreads/pthread_rwlock_init.3 create mode 100644 pthreads/pthread_rwlock_rdlock.3 create mode 100644 pthreads/pthread_rwlock_unlock.3 create mode 100644 pthreads/pthread_rwlock_wrlock.3 create mode 100644 pthreads/pthread_rwlockattr_destroy.3 create mode 100644 pthreads/pthread_rwlockattr_getpshared.3 create mode 100644 pthreads/pthread_rwlockattr_init.3 create mode 100644 pthreads/pthread_rwlockattr_setpshared.3 create mode 100644 pthreads/pthread_self.3 create mode 100644 pthreads/pthread_setcancelstate.3 create mode 100644 pthreads/pthread_setspecific.3 rename {pthreads.subproj => pthreads}/pthread_tsd.c (100%) rename {pthreads.subproj => pthreads}/sched.h (100%) rename {pthreads.subproj => pthreads}/stack.s (100%) rename {pthreads.subproj => pthreads}/thread_setup.c (55%) create mode 100644 quad/Makefile.inc delete mode 100644 regex.subproj/Makefile delete mode 100644 regex.subproj/Makefile.postamble delete mode 100644 regex.subproj/Makefile.preamble delete mode 100644 regex.subproj/PB.project create mode 100644 regex/Makefile.inc rename {regex.subproj => regex}/cclass.h (100%) rename {regex.subproj => regex}/cname.h (100%) rename {regex.subproj => regex}/engine.c (100%) create mode 100644 regex/re_format.7 rename {regex.subproj => regex}/regcomp.c (100%) rename {regex.subproj => regex}/regerror.c (100%) create mode 100644 regex/regex.3 rename {regex.subproj => regex}/regex2.h (100%) rename {regex.subproj => regex}/regexec.c (100%) rename {regex.subproj => regex}/regfree.c (100%) rename {regex.subproj => regex}/utils.h (100%) create mode 100644 rpc/Makefile.inc delete mode 100644 stdio.subproj/Makefile delete mode 100644 stdio.subproj/Makefile.postamble delete mode 100644 stdio.subproj/Makefile.preamble delete mode 100644 stdio.subproj/PB.project create mode 100644 stdio/Makefile.inc create mode 100644 stdio/asprintf.c rename {stdio.subproj => stdio}/clrerr.c (100%) create mode 100644 stdio/fclose.3 rename {stdio.subproj => stdio}/fclose.c (100%) rename {stdio.subproj => stdio}/fdopen.c (100%) rename {stdio.subproj => stdio}/feof.c (100%) create mode 100644 stdio/ferror.3 rename {stdio.subproj => stdio}/ferror.c (100%) create mode 100644 stdio/fflush.3 rename {stdio.subproj => stdio}/fflush.c (100%) rename {stdio.subproj => stdio}/fgetc.c (100%) create mode 100644 stdio/fgetln.3 rename {stdio.subproj => stdio}/fgetln.c (100%) rename {stdio.subproj => stdio}/fgetpos.c (100%) create mode 100644 stdio/fgets.3 rename {stdio.subproj => stdio}/fgets.c (99%) rename {stdio.subproj => stdio}/fileno.c (100%) rename {stdio.subproj => stdio}/findfp.c (100%) rename {stdio.subproj => stdio}/flags.c (100%) rename {stdio.subproj => stdio}/floatio.h (100%) create mode 100644 stdio/fopen.3 rename {stdio.subproj => stdio}/fopen.c (100%) rename {stdio.subproj => stdio}/fprintf.c (100%) rename {stdio.subproj => stdio}/fpurge.c (100%) rename {stdio.subproj => stdio}/fputc.c (100%) create mode 100644 stdio/fputs.3 rename {stdio.subproj => stdio}/fputs.c (100%) create mode 100644 stdio/fread.3 rename {stdio.subproj => stdio}/fread.c (100%) rename {stdio.subproj => stdio}/freopen.c (100%) rename {stdio.subproj => stdio}/fscanf.c (100%) create mode 100644 stdio/fseek.3 rename {stdio.subproj => stdio}/fseek.c (100%) rename {stdio.subproj => stdio}/fsetpos.c (100%) rename {stdio.subproj => stdio}/ftell.c (100%) create mode 100644 stdio/funopen.3 rename {stdio.subproj => stdio}/funopen.c (100%) rename {stdio.subproj => stdio}/fvwrite.c (84%) create mode 100644 stdio/fvwrite.h rename {stdio.subproj => stdio}/fwalk.c (100%) rename {stdio.subproj => stdio}/fwrite.c (100%) create mode 100644 stdio/getc.3 rename {stdio.subproj => stdio}/getc.c (100%) rename {stdio.subproj => stdio}/getchar.c (100%) rename {stdio.subproj => stdio}/gets.c (100%) rename {stdio.subproj => stdio}/getw.c (100%) rename {stdio.subproj => stdio}/glue.h (100%) rename {stdio.subproj => stdio}/local.h (100%) rename {stdio.subproj => stdio}/makebuf.c (100%) create mode 100644 stdio/mktemp.3 create mode 100644 stdio/mktemp.c rename {stdio.subproj => stdio}/perror.c (100%) create mode 100644 stdio/printf.3 rename {stdio.subproj => stdio}/printf.c (100%) create mode 100644 stdio/putc.3 rename {stdio.subproj => stdio}/putc.c (100%) rename {stdio.subproj => stdio}/putchar.c (100%) rename {stdio.subproj => stdio}/puts.c (100%) rename {stdio.subproj => stdio}/putw.c (100%) rename {stdio.subproj => stdio}/refill.c (100%) create mode 100644 stdio/remove.3 create mode 100644 stdio/remove.c rename {stdio.subproj => stdio}/rewind.c (100%) rename {stdio.subproj => stdio}/rget.c (100%) create mode 100644 stdio/scanf.3 rename {stdio.subproj => stdio}/scanf.c (100%) create mode 100644 stdio/setbuf.3 rename {stdio.subproj => stdio}/setbuf.c (100%) rename {stdio.subproj => stdio}/setbuffer.c (100%) rename {stdio.subproj => stdio}/setvbuf.c (100%) rename {stdio.subproj => stdio}/snprintf.c (100%) rename {stdio.subproj => stdio}/sprintf.c (100%) rename {stdio.subproj => stdio}/sscanf.c (100%) create mode 100644 stdio/stdio.3 rename {stdio.subproj => stdio}/stdio.c (100%) rename {stdio.subproj => stdio}/tempnam.c (100%) rename {stdio.subproj => stdio}/tmpfile.c (100%) create mode 100644 stdio/tmpnam.3 rename {stdio.subproj => stdio}/tmpnam.c (95%) create mode 100644 stdio/ungetc.3 rename {stdio.subproj => stdio}/ungetc.c (100%) create mode 100644 stdio/vasprintf.c rename {stdio.subproj => stdio}/vfprintf.c (77%) rename {stdio.subproj => stdio}/vfscanf.c (98%) rename {stdio.subproj => stdio}/vprintf.c (100%) rename {stdio.subproj => stdio}/vscanf.c (100%) rename {stdio.subproj => stdio}/vsnprintf.c (100%) rename {stdio.subproj => stdio}/vsprintf.c (100%) rename {stdio.subproj => stdio}/vsscanf.c (100%) rename {stdio.subproj => stdio}/wbuf.c (100%) rename {stdio.subproj => stdio}/wsetup.c (100%) delete mode 100644 stdlib.subproj/Makefile delete mode 100644 stdlib.subproj/Makefile.postamble delete mode 100644 stdlib.subproj/Makefile.preamble delete mode 100644 stdlib.subproj/PB.project create mode 100644 stdlib/Makefile.inc create mode 100644 stdlib/a64l.3 create mode 100644 stdlib/a64l.c create mode 100644 stdlib/abort.3 rename {stdlib.subproj => stdlib}/abort.c (82%) create mode 100644 stdlib/abs.3 create mode 100644 stdlib/alloca.3 create mode 100644 stdlib/atexit.3 rename {stdlib.subproj => stdlib}/atexit.c (100%) rename {stdlib.subproj => stdlib}/atexit.h (100%) create mode 100644 stdlib/atof.3 rename {stdlib.subproj => stdlib}/atof.c (100%) create mode 100644 stdlib/atoi.3 rename {stdlib.subproj => stdlib}/atoi.c (100%) create mode 100644 stdlib/atol.3 rename {stdlib.subproj => stdlib}/atol.c (100%) create mode 100644 stdlib/bsearch.3 rename {stdlib.subproj => stdlib}/bsearch.c (100%) create mode 100644 stdlib/div.3 rename {stdlib.subproj => stdlib}/div.c (100%) create mode 100644 stdlib/exit.3 rename {stdlib.subproj => stdlib}/exit.c (100%) create mode 100644 stdlib/getenv.3 rename {stdlib.subproj => stdlib}/getenv.c (100%) create mode 100644 stdlib/getopt.3 rename {stdlib.subproj => stdlib}/getopt.c (100%) create mode 100644 stdlib/getsubopt.3 rename {stdlib.subproj => stdlib}/getsubopt.c (100%) create mode 100644 stdlib/hcreate.3 rename {stdlib.subproj => stdlib}/heapsort.c (100%) create mode 100644 stdlib/l64a.c create mode 100644 stdlib/labs.3 rename {stdlib.subproj => stdlib}/labs.c (100%) create mode 100644 stdlib/ldiv.3 rename {stdlib.subproj => stdlib}/ldiv.c (100%) create mode 100644 stdlib/malloc.3 create mode 100644 stdlib/memory.3 rename {stdlib.subproj => stdlib}/merge.c (100%) rename {stdlib.subproj => stdlib}/putenv.c (100%) create mode 100644 stdlib/qsort.3 rename {stdlib.subproj => stdlib}/qsort.c (100%) create mode 100644 stdlib/radixsort.3 rename {stdlib.subproj => stdlib}/radixsort.c (97%) create mode 100644 stdlib/rand.3 create mode 100644 stdlib/rand.c create mode 100644 stdlib/random.3 rename {stdlib.subproj => stdlib}/random.c (100%) create mode 100644 stdlib/reallocf.c create mode 100644 stdlib/realpath.3 rename {stdlib.subproj => stdlib}/setenv.c (100%) create mode 100644 stdlib/strfmon.3 create mode 100644 stdlib/strtod.3 rename {stdlib.subproj => stdlib}/strtod.c (99%) create mode 100644 stdlib/strtol.3 rename {stdlib.subproj => stdlib}/strtol.c (100%) rename stdlib.subproj/strtoq.c => stdlib/strtoll.c (76%) create mode 100644 stdlib/strtoq.c create mode 100644 stdlib/strtoul.3 rename {stdlib.subproj => stdlib}/strtoul.c (100%) rename stdlib.subproj/strtouq.c => stdlib/strtoull.c (69%) create mode 100644 stdlib/strtouq.c create mode 100644 stdlib/system.3 rename {stdlib.subproj => stdlib}/system.c (96%) create mode 100644 stdlib/tsearch.3 create mode 100644 stdtime/Makefile.inc create mode 100644 stdtime/asctime.c create mode 100644 stdtime/ctime.3 create mode 100644 stdtime/difftime.c create mode 100644 stdtime/localtime.c create mode 100644 stdtime/private.h create mode 100644 stdtime/strftime.3 create mode 100644 stdtime/strftime.c create mode 100644 stdtime/strptime.3 create mode 100644 stdtime/strptime.c create mode 100644 stdtime/time2posix.3 create mode 100644 stdtime/timelocal.c create mode 100644 stdtime/timelocal.h create mode 100644 stdtime/tzfile.5 create mode 100644 stdtime/tzfile.h delete mode 100644 string.subproj/Makefile delete mode 100644 string.subproj/Makefile.postamble delete mode 100644 string.subproj/Makefile.preamble delete mode 100644 string.subproj/PB.project create mode 100644 string/Makefile.inc create mode 100644 string/bcmp.3 create mode 100644 string/bcopy.3 create mode 100644 string/bstring.3 create mode 100644 string/bzero.3 create mode 100644 string/ffs.3 create mode 100644 string/index.3 rename {string.subproj => string}/index.c (100%) create mode 100644 string/memccpy.3 rename {string.subproj => string}/memccpy.c (100%) create mode 100644 string/memchr.3 rename {string.subproj => string}/memchr.c (100%) create mode 100644 string/memcmp.3 rename {string.subproj => string}/memcmp.c (100%) create mode 100644 string/memcpy.3 create mode 100644 string/memmove.3 create mode 100644 string/memset.3 rename {string.subproj => string}/memset.c (99%) create mode 100644 string/rindex.3 rename {string.subproj => string}/rindex.c (100%) rename {string.subproj => string}/rindix.c (100%) create mode 100644 string/strcasecmp.3 rename {string.subproj => string}/strcasecmp.c (100%) create mode 100644 string/strcat.3 create mode 100644 string/strchr.3 rename {string.subproj => string}/strchr.c (100%) create mode 100644 string/strcmp.3 rename {string.subproj => string}/strcmp.s (100%) create mode 100644 string/strcoll.3 rename {string.subproj => string}/strcoll.c (100%) create mode 100644 string/strcpy.3 create mode 100644 string/strcspn.3 rename {string.subproj => string}/strcspn.c (100%) create mode 100644 string/strdup.3 rename {string.subproj => string}/strdup.c (100%) create mode 100644 string/strerror.3 rename {string.subproj => string}/strerror.c (100%) rename {string.subproj => string}/strftime.c (100%) create mode 100644 string/string.3 create mode 100644 string/strlcat.c create mode 100644 string/strlcpy.3 create mode 100644 string/strlcpy.c create mode 100644 string/strlen.3 create mode 100644 string/strmode.3 rename {string.subproj => string}/strmode.c (100%) create mode 100644 string/strpbrk.3 rename {string.subproj => string}/strpbrk.c (100%) create mode 100644 string/strrchr.3 create mode 100644 string/strsep.3 rename {string.subproj => string}/strsep.c (100%) create mode 100644 string/strspn.3 rename {string.subproj => string}/strspn.c (100%) create mode 100644 string/strstr.3 rename {string.subproj => string}/strstr.c (100%) create mode 100644 string/strtok.3 create mode 100644 string/strtok.c create mode 100644 string/strxfrm.3 rename {string.subproj => string}/strxfrm.c (100%) create mode 100644 string/swab.3 rename {string.subproj => string}/swab.c (100%) create mode 100644 string/wmemchr.3 delete mode 100644 sys.subproj/Makefile delete mode 100644 sys.subproj/Makefile.postamble delete mode 100644 sys.subproj/Makefile.preamble delete mode 100644 sys.subproj/PB.project delete mode 100644 sys.subproj/i386.subproj/Makefile delete mode 100644 sys.subproj/i386.subproj/Makefile.postamble delete mode 100644 sys.subproj/i386.subproj/Makefile.preamble delete mode 100644 sys.subproj/i386.subproj/PB.project delete mode 100644 sys.subproj/ppc.subproj/Makefile delete mode 100644 sys.subproj/ppc.subproj/Makefile.postamble delete mode 100644 sys.subproj/ppc.subproj/Makefile.preamble delete mode 100644 sys.subproj/ppc.subproj/PB.project delete mode 100644 sys.subproj/sigprocmask.c create mode 100644 sys/CLIB-LIST create mode 100644 sys/MISSING-MANPAGE create mode 100644 sys/MISSING_SYSCALLS create mode 100644 sys/Makefile.inc create mode 100644 sys/REQUIRED-MACROS create mode 100644 sys/SYSCALL-LIST rename crt_externs.c => sys/crt_externs.c (96%) rename {sys.subproj => sys}/errno.c (97%) create mode 100644 sys/getdtablesize.2 rename {sys.subproj => sys}/getdtablesize.c (100%) rename {sys.subproj => sys}/gettimeofday.c (92%) rename {sys.subproj => sys}/msync.2 (100%) create mode 100644 sys/nanosleep.2 create mode 100644 sys/pthread_kill.2 create mode 100644 sys/pthread_sigmask.2 rename {sys.subproj => sys}/sem_close.2 (93%) rename {sys.subproj => sys}/sem_open.2 (97%) rename {sys.subproj => sys}/sem_post.2 (94%) rename {sys.subproj => sys}/sem_trywait.2 (100%) rename {sys.subproj => sys}/sem_unlink.2 (95%) rename {sys.subproj => sys}/sem_wait.2 (96%) create mode 100644 sys/setregid.2 create mode 100644 sys/setreuid.2 rename {sys.subproj => sys}/shm_open.2 (97%) rename {sys.subproj => sys}/shm_unlink.2 (95%) rename {sys.subproj => sys}/sigaction.c (84%) rename {sys.subproj => sys}/sigcatch.c (100%) rename {sys.subproj => sys}/sigcatch.h (100%) rename {sys.subproj => sys}/sigsuspend.c (100%) rename {sys.subproj => sys}/sigtramp.c (83%) create mode 100644 sys/sigwait.2 delete mode 100644 threads.subproj/Makefile delete mode 100644 threads.subproj/Makefile.postamble delete mode 100644 threads.subproj/Makefile.preamble delete mode 100644 threads.subproj/PB.project delete mode 100644 threads.subproj/i386.subproj/Makefile delete mode 100644 threads.subproj/i386.subproj/Makefile.postamble delete mode 100644 threads.subproj/i386.subproj/Makefile.preamble delete mode 100644 threads.subproj/i386.subproj/PB.project delete mode 100644 threads.subproj/ppc.subproj/Makefile delete mode 100644 threads.subproj/ppc.subproj/Makefile.postamble delete mode 100644 threads.subproj/ppc.subproj/Makefile.preamble delete mode 100644 threads.subproj/ppc.subproj/PB.project create mode 100644 threads/Makefile.inc rename {threads.subproj => threads}/cprocs.c (100%) rename {threads.subproj => threads}/cthread_internals.h (100%) rename {threads.subproj => threads}/cthreads.c (96%) rename {threads.subproj => threads}/cthreads.h (100%) rename {threads.subproj => threads}/lu_utils.c (97%) rename {threads.subproj => threads}/mig_support.c (100%) delete mode 100644 util.subproj/Makefile delete mode 100644 util.subproj/Makefile.postamble delete mode 100644 util.subproj/Makefile.preamble delete mode 100644 util.subproj/PB.project create mode 100644 util/Makefile.inc rename {util.subproj => util}/login.c (100%) rename {util.subproj => util}/login_tty.c (100%) rename {util.subproj => util}/logout.c (100%) rename {util.subproj => util}/logwtmp.c (100%) rename {util.subproj => util}/pty.c (100%) create mode 100644 xdr/Makefile.inc create mode 100644 yp/Makefile.inc diff --git a/APPLE_LICENSE b/APPLE_LICENSE new file mode 100644 index 0000000..a0a8416 --- /dev/null +++ b/APPLE_LICENSE @@ -0,0 +1,372 @@ +APPLE PUBLIC SOURCE LICENSE +Version 1.1 - April 19,1999 + +Please read this License carefully before downloading this software. +By downloading and using this software, you are agreeing to be bound +by the terms of this License. If you do not or cannot agree to the +terms of this License, please do not download or use the software. + +1. General; Definitions. This License applies to any program or other +work which Apple Computer, Inc. ("Apple") publicly announces as +subject to this Apple Public Source License and which contains a +notice placed by Apple identifying such program or work as "Original +Code" and stating that it is subject to the terms of this Apple Public +Source License version 1.1 (or subsequent version thereof), as it may +be revised from time to time by Apple ("License"). As used in this +License: + +1.1 "Affected Original Code" means only those specific portions of +Original Code that allegedly infringe upon any party's intellectual +property rights or are otherwise the subject of a claim of +infringement. + +1.2 "Applicable Patent Rights" mean: (a) in the case where Apple is +the grantor of rights, (i) claims of patents that are now or hereafter +acquired, owned by or assigned to Apple and (ii) that cover subject +matter contained in the Original Code, but only to the extent +necessary to use, reproduce and/or distribute the Original Code +without infringement; and (b) in the case where You are the grantor of +rights, (i) claims of patents that are now or hereafter acquired, +owned by or assigned to You and (ii) that cover subject matter in Your +Modifications, taken alone or in combination with Original Code. + +1.3 "Covered Code" means the Original Code, Modifications, the +combination of Original Code and any Modifications, and/or any +respective portions thereof. + +1.4 "Deploy" means to use, sublicense or distribute Covered Code other +than for Your internal research and development (R&D), and includes +without limitation, any and all internal use or distribution of +Covered Code within Your business or organization except for R&D use, +as well as direct or indirect sublicensing or distribution of Covered +Code by You to any third party in any form or manner. + +1.5 "Larger Work" means a work which combines Covered Code or portions +thereof with code not governed by the terms of this License. + +1.6 "Modifications" mean any addition to, deletion from, and/or change +to, the substance and/or structure of Covered Code. When code is +released as a series of files, a Modification is: (a) any addition to +or deletion from the contents of a file containing Covered Code; +and/or (b) any new file or other representation of computer program +statements that contains any part of Covered Code. + +1.7 "Original Code" means (a) the Source Code of a program or other +work as originally made available by Apple under this License, +including the Source Code of any updates or upgrades to such programs +or works made available by Apple under this License, and that has been +expressly identified by Apple as such in the header file(s) of such +work; and (b) the object code compiled from such Source Code and +originally made available by Apple under this License. + +1.8 "Source Code" means the human readable form of a program or other +work that is suitable for making modifications to it, including all +modules it contains, plus any associated interface definition files, +scripts used to control compilation and installation of an executable +(object code). + +1.9 "You" or "Your" means an individual or a legal entity exercising +rights under this License. For legal entities, "You" or "Your" +includes any entity which controls, is controlled by, or is under +common control with, You, where "control" means (a) the power, direct +or indirect, to cause the direction or management of such entity, +whether by contract or otherwise, or (b) ownership of fifty percent +(50%) or more of the outstanding shares or beneficial ownership of +such entity. + +2. Permitted Uses; Conditions & Restrictions. Subject to the terms +and conditions of this License, Apple hereby grants You, effective on +the date You accept this License and download the Original Code, a +world-wide, royalty-free, non- exclusive license, to the extent of +Apple's Applicable Patent Rights and copyrights covering the Original +Code, to do the following: + +2.1 You may use, copy, modify and distribute Original Code, with or +without Modifications, solely for Your internal research and +development, provided that You must in each instance: + +(a) retain and reproduce in all copies of Original Code the copyright +and other proprietary notices and disclaimers of Apple as they appear +in the Original Code, and keep intact all notices in the Original Code +that refer to this License; + +(b) include a copy of this License with every copy of Source Code of +Covered Code and documentation You distribute, and You may not offer +or impose any terms on such Source Code that alter or restrict this +License or the recipients' rights hereunder, except as permitted under +Section 6; and + +(c) completely and accurately document all Modifications that you have +made and the date of each such Modification, designate the version of +the Original Code you used, prominently include a file carrying such +information with the Modifications, and duplicate the notice in +Exhibit A in each file of the Source Code of all such Modifications. + +2.2 You may Deploy Covered Code, provided that You must in each + instance: + +(a) satisfy all the conditions of Section 2.1 with respect to the +Source Code of the Covered Code; + +(b) make all Your Deployed Modifications publicly available in Source +Code form via electronic distribution (e.g. download from a web site) +under the terms of this License and subject to the license grants set +forth in Section 3 below, and any additional terms You may choose to +offer under Section 6. You must continue to make the Source Code of +Your Deployed Modifications available for as long as you Deploy the +Covered Code or twelve (12) months from the date of initial +Deployment, whichever is longer; + +(c) if You Deploy Covered Code containing Modifications made by You, +inform others of how to obtain those Modifications by filling out and +submitting the information found at +http://www.apple.com/publicsource/modifications.html, if available; +and + +(d) if You Deploy Covered Code in object code, executable form only, +include a prominent notice, in the code itself as well as in related +documentation, stating that Source Code of the Covered Code is +available under the terms of this License with information on how and +where to obtain such Source Code. + +3. Your Grants. In consideration of, and as a condition to, the +licenses granted to You under this License: + +(a) You hereby grant to Apple and all third parties a non-exclusive, +royalty-free license, under Your Applicable Patent Rights and other +intellectual property rights owned or controlled by You, to use, +reproduce, modify, distribute and Deploy Your Modifications of the +same scope and extent as Apple's licenses under Sections 2.1 and 2.2; +and + +(b) You hereby grant to Apple and its subsidiaries a non-exclusive, +worldwide, royalty-free, perpetual and irrevocable license, under Your +Applicable Patent Rights and other intellectual property rights owned +or controlled by You, to use, reproduce, execute, compile, display, +perform, modify or have modified (for Apple and/or its subsidiaries), +sublicense and distribute Your Modifications, in any form, through +multiple tiers of distribution. + +4. Larger Works. You may create a Larger Work by combining Covered +Code with other code not governed by the terms of this License and +distribute the Larger Work as a single product. In each such +instance, You must make sure the requirements of this License are +fulfilled for the Covered Code or any portion thereof. + +5. Limitations on Patent License. Except as expressly stated in +Section 2, no other patent rights, express or implied, are granted by +Apple herein. Modifications and/or Larger Works may require +additional patent licenses from Apple which Apple may grant in its +sole discretion. + +6. Additional Terms. You may choose to offer, and to charge a fee +for, warranty, support, indemnity or liability obligations and/or +other rights consistent with the scope of the license granted herein +("Additional Terms") to one or more recipients of Covered +Code. However, You may do so only on Your own behalf and as Your sole +responsibility, and not on behalf of Apple. You must obtain the +recipient's agreement that any such Additional Terms are offered by +You alone, and You hereby agree to indemnify, defend and hold Apple +harmless for any liability incurred by or claims asserted against +Apple by reason of any such Additional Terms. + +7. Versions of the License. Apple may publish revised and/or new +versions of this License from time to time. Each version will be +given a distinguishing version number. Once Original Code has been +published under a particular version of this License, You may continue +to use it under the terms of that version. You may also choose to use +such Original Code under the terms of any subsequent version of this +License published by Apple. No one other than Apple has the right to +modify the terms applicable to Covered Code created under this +License. + +8. NO WARRANTY OR SUPPORT. The Original Code may contain in whole or +in part pre-release, untested, or not fully tested works. The +Original Code may contain errors that could cause failures or loss of +data, and may be incomplete or contain inaccuracies. You expressly +acknowledge and agree that use of the Original Code, or any portion +thereof, is at Your sole and entire risk. THE ORIGINAL CODE IS +PROVIDED "AS IS" AND WITHOUT WARRANTY, UPGRADES OR SUPPORT OF ANY KIND +AND APPLE AND APPLE'S LICENSOR(S) (FOR THE PURPOSES OF SECTIONS 8 AND +9, APPLE AND APPLE'S LICENSOR(S) ARE COLLECTIVELY REFERRED TO AS +"APPLE") EXPRESSLY DISCLAIM ALL WARRANTIES AND/OR CONDITIONS, EXPRESS +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +AND/OR CONDITIONS OF MERCHANTABILITY OR SATISFACTORY QUALITY AND +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY +RIGHTS. APPLE DOES NOT WARRANT THAT THE FUNCTIONS CONTAINED IN THE +ORIGINAL CODE WILL MEET YOUR REQUIREMENTS, OR THAT THE OPERATION OF +THE ORIGINAL CODE WILL BE UNINTERRUPTED OR ERROR- FREE, OR THAT +DEFECTS IN THE ORIGINAL CODE WILL BE CORRECTED. NO ORAL OR WRITTEN +INFORMATION OR ADVICE GIVEN BY APPLE OR AN APPLE AUTHORIZED +REPRESENTATIVE SHALL CREATE A WARRANTY OR IN ANY WAY INCREASE THE +SCOPE OF THIS WARRANTY. You acknowledge that the Original Code is not +intended for use in the operation of nuclear facilities, aircraft +navigation, communication systems, or air traffic control machines in +which case the failure of the Original Code could lead to death, +personal injury, or severe physical or environmental damage. + +9. Liability. + +9.1 Infringement. If any portion of, or functionality implemented by, +the Original Code becomes the subject of a claim of infringement, +Apple may, at its option: (a) attempt to procure the rights necessary +for Apple and You to continue using the Affected Original Code; (b) +modify the Affected Original Code so that it is no longer infringing; +or (c) suspend Your rights to use, reproduce, modify, sublicense and +distribute the Affected Original Code until a final determination of +the claim is made by a court or governmental administrative agency of +competent jurisdiction and Apple lifts the suspension as set forth +below. Such suspension of rights will be effective immediately upon +Apple's posting of a notice to such effect on the Apple web site that +is used for implementation of this License. Upon such final +determination being made, if Apple is legally able, without the +payment of a fee or royalty, to resume use, reproduction, +modification, sublicensing and distribution of the Affected Original +Code, Apple will lift the suspension of rights to the Affected +Original Code by posting a notice to such effect on the Apple web site +that is used for implementation of this License. If Apple suspends +Your rights to Affected Original Code, nothing in this License shall +be construed to restrict You, at Your option and subject to applicable +law, from replacing the Affected Original Code with non-infringing +code or independently negotiating for necessary rights from such third +party. + +9.2 LIMITATION OF LIABILITY. UNDER NO CIRCUMSTANCES SHALL APPLE BE +LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES +ARISING OUT OF OR RELATING TO THIS LICENSE OR YOUR USE OR INABILITY TO +USE THE ORIGINAL CODE, OR ANY PORTION THEREOF, WHETHER UNDER A THEORY +OF CONTRACT, WARRANTY, TORT (INCLUDING NEGLIGENCE), PRODUCTS LIABILITY +OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES AND NOTWITHSTANDING THE FAILURE OF ESSENTIAL PURPOSE OF +ANY REMEDY. In no event shall Apple's total liability to You for all +damages under this License exceed the amount of fifty dollars +($50.00). + +10. Trademarks. This License does not grant any rights to use the +trademarks or trade names "Apple", "Apple Computer", "Mac OS X", "Mac +OS X Server" or any other trademarks or trade names belonging to Apple +(collectively "Apple Marks") and no Apple Marks may be used to endorse +or promote products derived from the Original Code other than as +permitted by and in strict compliance at all times with Apple's third +party trademark usage guidelines which are posted at +http://www.apple.com/legal/guidelinesfor3rdparties.html. + +11. Ownership. Apple retains all rights, title and interest in and to +the Original Code and any Modifications made by or on behalf of Apple +("Apple Modifications"), and such Apple Modifications will not be +automatically subject to this License. Apple may, at its sole +discretion, choose to license such Apple Modifications under this +License, or on different terms from those contained in this License or +may choose not to license them at all. Apple's development, use, +reproduction, modification, sublicensing and distribution of Covered +Code will not be subject to this License. + +12. Termination. + +12.1 Termination. This License and the rights granted hereunder will + terminate: + +(a) automatically without notice from Apple if You fail to comply with +any term(s) of this License and fail to cure such breach within 30 +days of becoming aware of such breach; (b) immediately in the event of +the circumstances described in Section 13.5(b); or (c) automatically +without notice from Apple if You, at any time during the term of this +License, commence an action for patent infringement against Apple. + +12.2 Effect of Termination. Upon termination, You agree to +immediately stop any further use, reproduction, modification, +sublicensing and distribution of the Covered Code and to destroy all +copies of the Covered Code that are in your possession or control. +All sublicenses to the Covered Code which have been properly granted +prior to termination shall survive any termination of this License. +Provisions which, by their nature, should remain in effect beyond the +termination of this License shall survive, including but not limited +to Sections 3, 5, 8, 9, 10, 11, 12.2 and 13. Neither party will be +liable to the other for compensation, indemnity or damages of any sort +solely as a result of terminating this License in accordance with its +terms, and termination of this License will be without prejudice to +any other right or remedy of either party. + +13. Miscellaneous. + +13.1 Government End Users. The Covered Code is a "commercial item" as +defined in FAR 2.101. Government software and technical data rights +in the Covered Code include only those rights customarily provided to +the public as defined in this License. This customary commercial +license in technical data and software is provided in accordance with +FAR 12.211 (Technical Data) and 12.212 (Computer Software) and, for +Department of Defense purchases, DFAR 252.227-7015 (Technical Data -- +Commercial Items) and 227.7202-3 (Rights in Commercial Computer +Software or Computer Software Documentation). Accordingly, all U.S. +Government End Users acquire Covered Code with only those rights set +forth herein. + +13.2 Relationship of Parties. This License will not be construed as +creating an agency, partnership, joint venture or any other form of +legal association between You and Apple, and You will not represent to +the contrary, whether expressly, by implication, appearance or +otherwise. + +13.3 Independent Development. Nothing in this License will impair +Apple's right to acquire, license, develop, have others develop for +it, market and/or distribute technology or products that perform the +same or similar functions as, or otherwise compete with, +Modifications, Larger Works, technology or products that You may +develop, produce, market or distribute. + +13.4 Waiver; Construction. Failure by Apple to enforce any provision +of this License will not be deemed a waiver of future enforcement of +that or any other provision. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +will not apply to this License. + +13.5 Severability. (a) If for any reason a court of competent +jurisdiction finds any provision of this License, or portion thereof, +to be unenforceable, that provision of the License will be enforced to +the maximum extent permissible so as to effect the economic benefits +and intent of the parties, and the remainder of this License will +continue in full force and effect. (b) Notwithstanding the foregoing, +if applicable law prohibits or restricts You from fully and/or +specifically complying with Sections 2 and/or 3 or prevents the +enforceability of either of those Sections, this License will +immediately terminate and You must immediately discontinue any use of +the Covered Code and destroy all copies of it that are in your +possession or control. + +13.6 Dispute Resolution. Any litigation or other dispute resolution +between You and Apple relating to this License shall take place in the +Northern District of California, and You and Apple hereby consent to +the personal jurisdiction of, and venue in, the state and federal +courts within that District with respect to this License. The +application of the United Nations Convention on Contracts for the +International Sale of Goods is expressly excluded. + +13.7 Entire Agreement; Governing Law. This License constitutes the +entire agreement between the parties with respect to the subject +matter hereof. This License shall be governed by the laws of the +United States and the State of California, except that body of +California law concerning conflicts of law. + +Where You are located in the province of Quebec, Canada, the following +clause applies: The parties hereby confirm that they have requested +that this License and all related documents be drafted in English. Les +parties ont exige que le present contrat et tous les documents +connexes soient rediges en anglais. + +EXHIBIT A. + +"Portions Copyright (c) 1999-2000 Apple Computer, Inc. All Rights +Reserved. This file contains Original Code and/or Modifications of +Original Code as defined in and that are subject to the Apple Public +Source License Version 1.1 (the "License"). You may not use this file +except in compliance with the License. Please obtain a copy of the +License at http://www.apple.com/publicsource and read it before using +this file. + +The Original Code and all software distributed under the License are +distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER +EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the +License for the specific language governing rights and limitations +under the License." diff --git a/CLIB-LIST b/CLIB-LIST new file mode 100644 index 0000000..7b30a40 --- /dev/null +++ b/CLIB-LIST @@ -0,0 +1,679 @@ +CIRCLEQ_ENTRY M +CIRCLEQ_HEAD M +CIRCLEQ_INIT M +CIRCLEQ_INSERT_AFTER M +CIRCLEQ_INSERT_BEFORE M +CIRCLEQ_INSERT_HEAD M +CIRCLEQ_INSERT_TAIL M +CIRCLEQ_REMOVE M +LIST_ENTRY M +LIST_HEAD M +LIST_INIT M +LIST_INSERT_AFTER M +LIST_REMOVE M +TAILQ_ENTRY M +TAILQ_HEAD M +TAILQ_INIT M +TAILQ_INSERT_AFTER M +TAILQ_INSERT_HEAD M +TAILQ_INSERT_TAIL M +TAILQ_REMOVE M +_longjmp +_setjmp +abort +abs +acl_add +acl_canocicalize_principal +acl_check +acl_delete +acl_exact_match +acl_initialize +acos +acosh +addch +addstr +alarm +alloca +alphasort +arc +asctime +asin +asinh +assert +atan +atan2 +atanh +atexit +atof +atoi +atol +bcmp +bcopy +bit_alloc M +bit_clear M +bit_decl M +bit_ffc M +bit_ffs M +bit_nclear M +bit_nset M +bit_test M +bitstr_size M +box +bsearch +bypot +bzero +cabs +calloc +cbreak +cbrt +ceil +cfgetispeed +cfgetospeed +cfmakeraw +cfsetispeed +cfsetospeed +cfsetspeed +cgetcap +cgetclose +cgetent +cgetfirst +cgetmatch +cgetnext +cgetnum +cgetset +cgetstr +cgetustr +circle +clear +clearerr +clearok +clock +closedir +closelog +closepl +clrtobot +clrtoeol +confstr +cont +copysign +cos +cosh +crypt +ctermid +ctime +daemon +dbopen +delch +delwin +des_cbc_cksum +des_cbc_encrypt +des_cipher +des_ecb_encrypt +des_pcbc_encrypt +des_quad_cksum +des_random_key +des_read_password +des_set_key +des_setkey +des_string_to_key +devanme +diffti8me +dirfd +div +dleteln +dn_comp +dn_expand +drem +echo +ectv +edata +encrypt +end +endfsent +endgrent +endhostent +endnetent +endnetgrent +endprotoent +endpwent +endservent +endttyent +endusershell +endwin +er +erase +erf +erfc +err +errx +etext +etfc +execl +execle +execlp +exect +execv +execvp +exit +exp +expm1 +fabs +fclose +fctv +fdopen +feof +ferror +fflush +ffs +fgetc +fgetline +fgetln +fgetpos +fgets +fileno +finite +floor +flusok +fmin MP +fmod +fmount MP +fnmatch +fopen +fprintf +fpurge +fputc +fputs +fread +free +freopen +frexp +fropen +fscanf +fseek +fsetpos +ftell +ftime +fts_children +fts_close +fts_open +fts_read +fts_set +funopen +fwopen +fwrite +gamma +gcd MP +gctv +getbsize +getc +getcap +getch +getchar +getcwd +getdiskbyname +getenv +getfsent +getfsfile +getfsspec +getgrent +getgrgid +getgrnam +getgrouplist +gethostbyaddr +gethostbyname +gethostent +gethostid +gethostname +getloadavg +getmntinfo +getmntopts +getmode +getnetbyaddr +getnetbyname +getnetent +getnetgrent +getopt +getpagesize +getpass +getprotobyname +getprotobynumber +getprotoent +getpw +getpwent +getpwnam +getpwuid +gets +getservbyname +getservbyport +getservent +getstr +getsubopt +gettmode +getttyent +getttynam +getusershell +getw +getwd +getyx +glob +globfree +gmtime +group_from_gid +gtty +heapsort +herror +htonl +htons +hypot +inch +index +inet_addr +inet_aton +inet_lnaof +inet_makeaddr +inet_netof +inet_network +inet_ntoa +infnan +initgroups +initscr +initstate +innetgr +insch +insetln +insque +invert MP +isalnum +isalpha +isascii +isatty +isblank +iscntrl +isdigit +isgraph +isinf +islower +isnan +iso_addr +iso_ntoa +isprint +ispunct +isspace +isupper +isxdigit +itom MP +j0 +j1 +jn +krb_err_txt +krb_get_admhst +krb_get_cred +krb_get_krbhst +krb_get_lrealm +krb_get_phost +krb_kntoln +krb_mk_err +krb_mk_priv +krb_mk_req +krb_mk_safe +krb_net_read +krb_net_write +krb_rd_err +krb_rd_priv +krb_rd_req +krb_rd_safe +krb_realmofhost +krb_recvauth +krb_sendauth +krb_set_key +krb_set_tkt_string +kuserok +kvm_close +kvm_getargv +kvm_getenvv +kvm_geterr +kvm_getfiles +kvm_getloadavg +kvm_getprocs +kvm_nlist +kvm_open +kvm_openfiles +kvm_read +kvm_write +label +labs +ldexp +ldiv +leaveok +lfind +lgamma +line +linemod +link_addr +link_ntoa +localeconv +localtime +log +log10 +log1p +logb +longjmp +longjmperror +longname +lsearch +m_in MP +m_out MP +madd MP +malloc +mamcpy +mblen +mbmb +mbrrune +mbrune +mbstowcs +mbtowc +mcmp MP +mdiv MP +memccpy +memchr +memcmp +memcpy +memmove +memset +mergesort +min MP +mkstemp +mktemp +mktime +modf +moncontrol +monstartup +mount MP +move +move MP +mpool_close +mpool_filter +mpool_get +mpool_new +mpool_open +mpool_put +mpool_sync +msqrt MP +msub MP +mult MP +mvcur +newein +nice +nl +nlist +nocbreak +noecho +nonl +noraw +ns_addr +ns_ntoa +ntohl +ntohs +omin MP +omount MP +opendir +openlog +openpl +optarg +opterr +optind +optopt +optreset +overlay +overwrite +pause +pclose +perror +point +popen +pow +pow MP +printf +printw +psignal +putc +putchar +putenv +puts +putw +qsort +radixsort +raise +rand +random +raw +rcmd +re_comp +re_exec +readdir +realloc +realpath +refresh +regcomp +regerror +regexec +regfree +regsub +remove +remque +res_init +res_mkquery +res_query +res_send +res_serach +resetty +rewind +rewinddir +rexec +rindex +rint +rpow MP +rresvport +ruserok +savetty +scalb +scandir +scanf +scanw +scroll +scrollok +sdiv MP +seekdir +setbuf +setbuffer +setenv +setfsent +setgrent +setgroupent +sethostent +sethostid +sethostname +setinvalidrunt +setjmp +setkey +setlinebuf +setlocale +setlogmask +setmode +setnetent +setnetgrent +setpassent +setprotoent +setpwent +setrgid +setruid +setrunelocale +setservent +setstate +setterm +setttyent +setusershell +setvbuf +sgetrune +sigaddset +sigdelset +sigemptyset +sigfillset +siginterrupt +sigismember +siglongjmp +signal +signgam +sigsetjmp +sin +sinh +sleep +snprintf +space +sprintf +sputrune +sqrt +sradixsort +srand +sreandom +sscanf +standend +standout +stderr +stdin +stdout +strcasecmp +strcat +strchr +strcmp +strcoll +strcpy +strcspn +strdup +strerror +strftime +strlen +strmode +strncasecmp +strncat +strncmp +strncpy +strpbrk +strrchr +strsep +strspc +strspn +strstr +strtod +strtok +strtol +strtoq +strtoul +strtouq +strunvis +strvis +strvisx +strxfrm +stty +subwin +swab +sys_errlist +sys_nerr +sys_siglist +sys_signame +sysconf +sysctl +syslog +system +tan +tanh +tcdrain +tcflow +tcflush +tcgetattr +tcgetpgrp +tcsendbreak +tcsetattr +tcsetpgrp +telldir +tempnam +tf_close +tf_get_cred +tf_get_pinst +tf_get_pname +tf_init +tgetent +tgetflag +tgetnum +tgetstr +tgoto +time +times +timezone +tmpfile +tmpnam +toascii +tolower +touchline +touchoverlap +touchwin +toupper +tputs +ttynam +ttyslot +tzset +tzsetwall +ualarm +uname +unctrl +ungetc +unsetenv +unvis +user_from_uid +usleep +utime +va_arg M +va_end M +va_start M +valloc +verr +verrx +vfprintf +vfscanf +vis +vlimit +vprintf +vscanf +vsnprintf +vsprintf +vsscanf +vsyslog +vtimes +vwarn +vwarnx +waddch +waddstr +warn +warnx +wclear +wclreol +wclrtobot +wcstombs +wctomb +wdelch +wdeleteln +werase +wgetch +wgetstr +winch +winsch +winsertln +wmove +wprintw +wrefreash +wscanw +wstandend +wstandout +y0 +y1 +yn diff --git a/GNUmakefile b/GNUmakefile new file mode 100644 index 0000000..36f4c91 --- /dev/null +++ b/GNUmakefile @@ -0,0 +1,211 @@ +ifndef $(OBJROOT) +OBJROOT = . +endif +ifndef $(SYMROOT) +SYMROOT = . +endif +ARCH = $(shell arch) +ifndef RC_ppc +ifndef RC_i386 +RC_ppc = 1 +endif +endif + +# Remove the arch stuff, since we know better here. +LOCAL_CFLAGS = $(filter-out -arch ppc -arch i386,$(RC_CFLAGS)) + +all: build +# These are the non B&I defaults +ifndef RC_ProjectName +installhdrs: installhdrs-real +build: build-static build-profile build-debug build-dynamic +install: installhdrs install-all +endif + +# And these are to deal with B&I building libc differently +# based on RC_ProjectName. +ifeq ($(RC_ProjectName),Libc) +installhdrs: installhdrs-real +build: build-man build-dynamic +install: installhdrs-real BI-install-dynamic install-man +endif +ifeq ($(RC_ProjectName),Libc_static) +installhdrs: +build: build-static +install: BI-install-static +endif +ifeq ($(RC_ProjectName),Libc_debug) +installhdrs: +build: build-debug +install: BI-install-debug +endif +ifeq ($(RC_ProjectName),Libc_profile) +installhdrs: +build: build-profile +install: BI-install-profile +endif + +build-man: + MAKEOBJDIR="$(OBJROOT)" MACHINE_ARCH="$(shell arch)" \ + MAKEFLAGS="" bsdmake buildman +build-static: build-ppc-static build-i386-static + @echo "Checking for libc_static.a" + @if [ -f "$(OBJROOT)/obj.ppc/libc_static.a" -a -f "$(OBJROOT)/obj.i386/libc_static.a" ]; then\ + lipo -create -arch ppc "$(OBJROOT)/obj.ppc/libc_static.a" \ + -arch i386 "$(OBJROOT)/obj.i386/libc_static.a" \ + -output $(SYMROOT)/libc_static.a;\ + elif [ -f "$(OBJROOT)/obj.ppc/libc_static.a" ]; then \ + cp -p "$(OBJROOT)/obj.ppc/libc_static.a" "$(SYMROOT)"; \ + elif [ -f "$(OBJROOT)/obj.i386/libc_static.a" ]; then \ + cp -p "$(OBJROOT)/obj.i386/libc_static.a" "$(SYMROOT)"; \ + fi +build-profile: build-ppc-profile build-i386-profile + @echo "Checking for libc_profile.a" + @if [ -f "$(OBJROOT)/obj.ppc/libc_profile.a" -a -f "$(OBJROOT)/obj.i386/libc_profile.a" ]; then\ + lipo -create -arch ppc "$(OBJROOT)/obj.ppc/libc_profile.a" \ + -arch i386 "$(OBJROOT)/obj.i386/libc_profile.a" \ + -output $(SYMROOT)/libc_profile.a;\ + elif [ -f "$(OBJROOT)/obj.ppc/libc_profile.a" ]; then \ + cp -p "$(OBJROOT)/obj.ppc/libc_profile.a" "$(SYMROOT)"; \ + elif [ -f "$(OBJROOT)/obj.i386/libc_profile.a" ]; then \ + cp -p "$(OBJROOT)/obj.i386/libc_profile.a" "$(SYMROOT)"; \ + fi +build-debug: build-ppc-debug build-i386-debug + @echo "Checking for libc_debug.a" + @if [ -f "$(OBJROOT)/obj.ppc/libc_debug.a" -a -f "$(OBJROOT)/obj.i386/libc_debug.a" ]; then\ + lipo -create -arch ppc "$(OBJROOT)/obj.ppc/libc_debug.a" \ + -arch i386 "$(OBJROOT)/obj.i386/libc_debug.a" \ + -output $(SYMROOT)/libc_debug.a;\ + elif [ -f "$(OBJROOT)/obj.ppc/libc_debug.a" ]; then \ + cp -p "$(OBJROOT)/obj.ppc/libc_debug.a" "$(SYMROOT)"; \ + elif [ -f "$(OBJROOT)/obj.i386/libc_debug.a" ]; then \ + cp -p "$(OBJROOT)/obj.i386/libc_debug.a" "$(SYMROOT)"; \ + fi +build-dynamic: build-ppc-dynamic build-i386-dynamic + @echo "Checking for libc.a" + @if [ -f "$(OBJROOT)/obj.ppc/libc.a" -a -f "$(OBJROOT)/obj.i386/libc.a" ]; then\ + echo "Creating FAT libc.a"; \ + lipo -create -arch ppc "$(OBJROOT)/obj.ppc/libc.a" -arch i386 \ + "$(OBJROOT)/obj.i386/libc.a" -output $(SYMROOT)/libc.a;\ + elif [ -f "$(OBJROOT)/obj.ppc/libc.a" ]; then \ + echo "Using thin PPC libc.a" ;\ + cp -p "$(OBJROOT)/obj.ppc/libc.a" "$(SYMROOT)"; \ + elif [ -f "$(OBJROOT)/obj.i386/libc.a" ]; then \ + echo "Using thin i386 libc.a" ;\ + cp -p "$(OBJROOT)/obj.i386/libc.a" "$(SYMROOT)"; \ + fi +build-ppc-static: + @if [ ! -z "$(RC_ppc)" ]; then \ + mkdir -p $(OBJROOT)/obj.ppc ; \ + MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \ + MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" bsdmake libc_static.a;\ + fi +build-i386-static: + @if [ ! -z "$(RC_i386)" ]; then \ + mkdir -p $(OBJROOT)/obj.i386 ; \ + MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \ + MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" bsdmake libc_static.a;\ + fi +build-ppc-profile: + @if [ ! -z "$(RC_ppc)" ]; then \ + mkdir -p $(OBJROOT)/obj.ppc ; \ + MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \ + MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" bsdmake libc_profile.a;\ + fi +build-i386-profile: + @if [ ! -z "$(RC_i386)" ]; then \ + mkdir -p $(OBJROOT)/obj.i386 ; \ + MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \ + MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" bsdmake libc_profile.a;\ + fi +build-ppc-debug: + @if [ ! -z "$(RC_ppc)" ]; then \ + mkdir -p $(OBJROOT)/obj.ppc ; \ + MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \ + MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" bsdmake libc_debug.a;\ + fi +build-i386-debug: + @if [ ! -z "$(RC_i386)" ]; then \ + mkdir -p $(OBJROOT)/obj.i386 ; \ + MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \ + MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" bsdmake libc_debug.a;\ + fi +build-ppc-dynamic: + @if [ ! -z "$(RC_ppc)" ]; then \ + mkdir -p $(OBJROOT)/obj.ppc ; \ + MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \ + MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" bsdmake libc.a;\ + fi +build-i386-dynamic: + @if [ ! -z "$(RC_i386)" ]; then \ + mkdir -p $(OBJROOT)/obj.i386 ; \ + MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \ + MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" bsdmake libc.a;\ + fi + +build-ppc: + @if [ ! -z "$(RC_ppc)" ]; then \ + mkdir -p $(OBJROOT)/obj.ppc ; \ + MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \ + MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" bsdmake build;\ + fi +build-i386: + @if [ ! -z "$(RC_i386)" ]; then \ + mkdir -p $(OBJROOT)/obj.i386 ; \ + MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \ + MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" bsdmake build;\ + fi +installsrc: + $(_v) pax -rw . "$(SRCROOT)" +installhdrs-real: + MAKEOBJDIR="$(OBJROOT)" DESTDIR="$(DSTROOT)" \ + MACHINE_ARCH="$(shell arch)" MAKEFLAGS="" bsdmake installhdrs + +BI-install-static: build-static + mkdir -p $(DSTROOT)/usr/local/lib/system + if [ -f "$(SYMROOT)/libc_static.a" ]; then \ + echo "Installing libc_static.a" ; \ + install -c -m 444 "$(SYMROOT)/libc_static.a" \ + $(DSTROOT)/usr/local/lib/system; \ + ranlib "$(DSTROOT)/usr/local/lib/system/libc_static.a"; \ + fi +BI-install-profile: build-profile + mkdir -p $(DSTROOT)/usr/local/lib/system + if [ -f "$(SYMROOT)/libc_profile.a" ]; then \ + echo "Installing libc_profile.a" ; \ + install -c -m 444 "$(SYMROOT)/libc_profile.a" \ + $(DSTROOT)/usr/local/lib/system; \ + ranlib "$(DSTROOT)/usr/local/lib/system/libc_profile.a"; \ + fi +BI-install-debug: build-debug + mkdir -p $(DSTROOT)/usr/local/lib/system + if [ -f "$(SYMROOT)/libc_debug.a" ]; then \ + echo "Installing libc_debug.a" ; \ + install -c -m 444 "$(SYMROOT)/libc_debug.a" \ + $(DSTROOT)/usr/local/lib/system; \ + ranlib "$(DSTROOT)/usr/local/lib/system/libc_debug.a"; \ + fi +BI-install-dynamic: build-dynamic + mkdir -p $(DSTROOT)/usr/local/lib/system + if [ -f "$(SYMROOT)/libc.a" ]; then \ + echo "Installing libc.a" ; \ + install -c -m 444 "$(SYMROOT)/libc.a" \ + $(DSTROOT)/usr/local/lib/system; \ + ranlib "$(DSTROOT)/usr/local/lib/system/libc.a"; \ + fi + +install-man: + mkdir -p $(DSTROOT)/usr/share/man/man2 + mkdir -p $(DSTROOT)/usr/share/man/man3 + mkdir -p $(DSTROOT)/usr/share/man/man4 + mkdir -p $(DSTROOT)/usr/share/man/man5 + mkdir -p $(DSTROOT)/usr/share/man/man7 + MAKEOBJDIR="$(OBJROOT)" DESTDIR="$(DSTROOT)" NOMANCOMPRESS=1 \ + MACHINE_ARCH="$(shell arch)" MAKEFLAGS="" bsdmake maninstall + +install-all: build install-man BI-install-dynamic BI-install-static BI-install-profile + +clean: + rm -rf $(OBJROOT)/obj.ppc $(OBJROOT)/obj.i386 $(OBJROOT)/libc.a \ + $(OBJROOT)/libc_static.a $(OBJROOT)/libc_debug.a \ + $(OBJROOT)/libc_profile.a diff --git a/Info.plist b/Info.plist new file mode 100644 index 0000000..2b4e967 --- /dev/null +++ b/Info.plist @@ -0,0 +1 @@ +{NSExecutable = net; NSExtensions = {}; } diff --git a/MISSING-MANPAGE b/MISSING-MANPAGE new file mode 100644 index 0000000..6aa16bd --- /dev/null +++ b/MISSING-MANPAGE @@ -0,0 +1,9 @@ +creat (obsoleted by open) +killpg +ptarce +setregid +setreuid +sigblock (obsoleted by sigprocmask) +sigpause (obsoleted by sigsuspend) +sigsetmask (obsoleted by sigprocmask) +sigvec (obsoleted by sigaction) diff --git a/MISSING_SYSCALLS b/MISSING_SYSCALLS new file mode 100644 index 0000000..2cb3246 --- /dev/null +++ b/MISSING_SYSCALLS @@ -0,0 +1,8 @@ +madvise UNIX +mincore UNIX +mlock UNIX +mprotect UNIX +msync UNIX +munlock UNIX +sigpending POSIX +sigstack compat[sigaltstack] diff --git a/Makefile b/Makefile index 8e603be..069ccc4 100644 --- a/Makefile +++ b/Makefile @@ -1,65 +1,40 @@ +# @(#)Makefile 8.2 (Berkeley) 2/3/94 +# $FreeBSD: src/lib/libc/Makefile,v 1.31 2001/08/13 21:48:43 peter Exp $ # -# Generated by the Apple Project Builder. +# All library objects contain rcsid strings by default; they may be +# excluded as a space-saving measure. To produce a library that does +# not contain these strings, delete -DLIBC_RCS and -DSYSLIBC_RCS +# from CFLAGS below. To remove these strings from just the system call +# stubs, remove just -DSYSLIBC_RCS from CFLAGS. # -# NOTE: Do NOT change this file -- Project Builder maintains it. +# Yes, we build everything with -g, and strip it out later... # -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = c - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Library - -CFILES = crt_externs.c -HFILES = - -SUBPROJECTS = compat43.subproj db.subproj gen.subproj headers.subproj\ - internat.subproj locale.subproj mach.subproj net.subproj\ - pthreads.subproj regex.subproj stdio.subproj\ - stdlib.subproj string.subproj sys.subproj threads.subproj\ - util.subproj - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble - - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CURRENTLY_ACTIVE_VERSION = YES -DEPLOY_WITH_VERSION_NAME = A -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = library.make -NEXTSTEP_INSTALLDIR = /usr/local/lib/system -WINDOWS_INSTALLDIR = /Developer/Libraries -PDO_UNIX_INSTALLDIR = /lib -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - - - -NEXTSTEP_BUILD_OUTPUT_DIR = /Users/Shared/$(USER)/BUILD/$(NAME) - -NEXTSTEP_PUBLIC_HEADERS_DIR = /usr/include - -WINDOWS_PUBLIC_HEADERS_DIR = $(HOMEDRIVE)$(LOCAL_DEVELOPER_DIR)/Headers/$(NAME) - -PDO_UNIX_PUBLIC_HEADERS_DIR = $(LOCAL_DEVELOPER_DIR)/Headers/$(NAME) - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies +LIB=c +SHLIB_MAJOR= 1 +SHLIB_MINOR= 0 +.if (${MACHINE_ARCH} == unknown) +MACHINE_ARCH = ppc +.endif +.if (${MACHINE_ARCH} == ppc) +CFLAGS += -faltivec -DALTIVEC +.endif +CFLAGS += -DNOID -DALL_STATE -I${.CURDIR}/include -I${.CURDIR}/include/objc +CFLAGS += -DLIBC_MAJOR=${SHLIB_MAJOR} -no-cpp-precomp -force_cpusubtype_ALL +CFLAGS += -arch ${MACHINE_ARCH} -fno-common -pipe -Wmost -g +CFLAGS += -finline-limit=5000 +AINC= -I${.CURDIR}/${MACHINE_ARCH} -no-cpp-precomp -force_cpusubtype_ALL +AINC+=-arch ${MACHINE_ARCH} -g +CLEANFILES+=tags +INSTALL_PIC_ARCHIVE= yes +PRECIOUSLIB= yes + +# If these aren't set give it expected defaults +DSTROOT ?= / +OBJROOT ?= . +SRCROOT ?= ${.CURDIR} +DESTDIR ?= ${DSTROOT} +MAKEOBJDIR ?= ${OBJROOT} + +.include "${.CURDIR}/Makefile.inc" +.include "Makefile.xbs" +.include diff --git a/Makefile.inc b/Makefile.inc new file mode 100644 index 0000000..e05962e --- /dev/null +++ b/Makefile.inc @@ -0,0 +1,66 @@ +# $FreeBSD: src/lMakefile.inc,v 1.7 2001/04/04 18:17:25 tmm Exp $ +# +# This file contains make rules that are shared by libc and libc_r. +# +# Define (empty) variables so that make doesn't give substitution +# errors if the included makefiles don't change these: +MDSRCS= +MISRCS= +MDASM= +MIASM= +NOASM= + +# +# If there is a machine dependent makefile, use it: +# +.if exists(${.CURDIR}/${MACHINE_ARCH}/Makefile.inc) +.include "${.CURDIR}/${MACHINE_ARCH}/Makefile.inc" +.endif + +.include "${.CURDIR}/db/Makefile.inc" +.include "${.CURDIR}/compat-43/Makefile.inc" +.include "${.CURDIR}/gen/Makefile.inc" +.include "${.CURDIR}/gmon/Makefile.inc" +.include "${.CURDIR}/include/Makefile.inc" +.include "${.CURDIR}/internat/Makefile.inc" +.include "${.CURDIR}/locale/Makefile.inc" +.include "${.CURDIR}/mach/Makefile.inc" +.include "${.CURDIR}/net/Makefile.inc" +#.include "${.CURDIR}/nls/Makefile.inc" +#.include "${.CURDIR}/posix1e/Makefile.inc" +.include "${.CURDIR}/pthreads/Makefile.inc" +.if !defined(NO_QUAD) +#.include "${.CURDIR}/quad/Makefile.inc" +.endif +.include "${.CURDIR}/regex/Makefile.inc" +.include "${.CURDIR}/stdio/Makefile.inc" +.include "${.CURDIR}/stdlib/Makefile.inc" +.include "${.CURDIR}/stdtime/Makefile.inc" +.include "${.CURDIR}/string/Makefile.inc" +.include "${.CURDIR}/sys/Makefile.inc" +.include "${.CURDIR}/threads/Makefile.inc" +.include "${.CURDIR}/util/Makefile.inc" +#.include "${.CURDIR}/rpc/Makefile.inc" +#.include "${.CURDIR}/xdr/Makefile.inc" +.if !defined(NO_YP_LIBC) +CFLAGS+= -DYP +#.include "${.CURDIR}/yp/Makefile.inc" +.endif +.if !defined(NO_HESIOD_LIBC) +CFLAGS+= -DHESIOD +.endif + +# If there are no machine dependent sources, append all the +# machine-independent sources: +.if empty(MDSRCS) +SRCS+= ${MISRCS} +.else +# Append machine-dependent sources, then append machine-independent sources +# for which there is no machine-dependent variant. +SRCS+= ${MDSRCS} +.for _src in ${MISRCS} +.if ${MDSRCS:R:M${_src:R}} == "" +SRCS+= ${_src} +.endif +.endfor +.endif diff --git a/Makefile.postamble b/Makefile.postamble deleted file mode 100644 index 2083c13..0000000 --- a/Makefile.postamble +++ /dev/null @@ -1,12 +0,0 @@ -override DEBUG_SUFFIX = _debug -override OPTIMIZE_BUILD_CFLAGS = -O3 -STATIC_SUFFIX = _static -PRODUCTS += $(LIBRARY_PREFIX)$(NAME)$(DEBUG_SUFFIX)$(LIBRARY_EXT) -PRODUCTS += $(LIBRARY_PREFIX)$(NAME)$(PROFILE_SUFFIX)$(LIBRARY_EXT) -PRODUCTS += $(LIBRARY_PREFIX)$(NAME)$(STATIC_SUFFIX)$(LIBRARY_EXT) -RECURSIVE_FLAGS += "LINK_SUBPROJECTS = NO" -OTHER_CFLAGS += -no-cpp-precomp -force_cpusubtype_ALL - -static: - $(SILENT) unset $(CUMULATIVE_VARIABLES) ||: ; \ - $(MAKE) BUILD_TYPE=$@ BUILD_TYPE_SUFFIX=$(STATIC_SUFFIX) diff --git a/Makefile.preamble b/Makefile.preamble deleted file mode 100644 index 438e0bb..0000000 --- a/Makefile.preamble +++ /dev/null @@ -1,12 +0,0 @@ -LIBRARY_STYLE = STATIC -STRIP_ON_INSTALL = NO -BEFORE_INSTALL += static debug profile -ifeq "$(BUILD_TYPE)" "static" -RECURSIVE_CFLAGS += -static -OFILE_DIR_SUFFIX := $(OFILE_DIR_SUFFIX)-static -#OTHER_LIBS = $(NEXT_ROOT)/usr/local/lib/libcc.a -else -#OTHER_LIBS = $(NEXT_ROOT)/usr/local/lib/libcc_noc++.a -endif -PRIVATE_HDR_INSTALLDIR = $(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/Versions/B/PrivateHeaders -override LINK_SUBPROJECTS = NO diff --git a/Makefile.xbs b/Makefile.xbs new file mode 100644 index 0000000..7409a24 --- /dev/null +++ b/Makefile.xbs @@ -0,0 +1,125 @@ +# This is a replacement for bsd.lib.mk for the libc project to get it +# doing the Right Thing in XBS, which is substantially different than +# the BSD build system. +# +# The main problems arise when libc.a isn't meant to be static, but +# libc_static.a is. We also build a debug version of the library +# in addition to shared, static, and profile. Also, we build all +# versions of libc with debugging enabled, unstripped. The BSD style +# is to strip every object file after it is built but here, libc.a +# will get merged into the larger libSystem.dylib, which will eventually +# be stripped. We also don't build a libc.dylib, since it will be +# munged into libSystem.dylib. +# +# And another difference, B&I wishes to build the 4 incarnations of Libc +# in parallel on different machines. To do this, we must look at the +# RC_ProjectName variable (which B&I sets) to determine which of the 4 +# versions of Libc we will be building. Remember that the installhdrs +# pass should only be invoked on one of the 4 versions, and man pages +# should only be installed once as well. Both of these get done when +# we're invoked as "Libc". + +.PATH: . +.MAIN: all +all: libc.a libc_static.a libc_debug.a libc_profile.a +install: installhdrs install_libc.a install_libc_static.a \ + install_libc_profile.a install_libc_debug.a maninstall + +.SUFFIXES: +.SUFFIXES: .o .po .So .do .S .s .c .cc .cpp .cxx .m .C .f .y .l .defs .h + +OBJS+= ${SRCS:N*.h:R:S/$/.o/g} +POBJS+= ${OBJS:.o=.po} ${STATICOBJS:.o=.po} +SOBJS+= ${OBJS:.o=.So} + +.c.o: + ${CC} -static ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} +.c.po: + ${CC} -pg -DPROFILE ${CFLAGS} -Os -c ${.IMPSRC} -o ${.TARGET} +.c.So: + ${CC} ${CFLAGS} -Os -c ${.IMPSRC} -o ${.TARGET} +.c.do: + ${CC} -g -DDEBUG ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} +.s.o: + ${CC} -x assembler-with-cpp ${CFLAGS:M-[BID]*} -static ${AINC} -c \ + ${.IMPSRC} -o ${.TARGET} +.s.po: + ${CC} -pg -DPROFILE -x assembler-with-cpp ${CFLAGS:M-[BID]*} -Os \ + ${AINC} -c ${.IMPSRC} -o ${.TARGET} +.s.So: + ${CC} -x assembler-with-cpp \ + ${CFLAGS:M-[BID]*} -Os ${AINC} -c ${.IMPSRC} -o ${.TARGET} +.s.do: + ${CC} -DDEBUG -g -x assembler-with-cpp ${CFLAGS:M-[BID]*} ${AINC} -c \ + ${.IMPSRC} -o ${.TARGET} +.defs.h: + mig -user ${.TARGET:S/.h$/User.c/} \ + -server ${.TARGET:S/.h$/Server.c/} -header ${.TARGET} ${.IMPSRC} + +gen_mig_defs: ${SRVMIGHDRS} ${MIGHDRS} +lib${LIB}_static.a:: ${OBJS} ${STATICOBJS} + @${ECHO} building static ${LIB} library + @rm -f lib${LIB}_static.a + @${AR} cq lib${LIB}_static.a `lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD} + ${RANLIB} lib${LIB}_static.a + +lib${LIB}_profile.a:: ${POBJS} + @${ECHO} building profiled ${LIB} library + @rm -f lib${LIB}_profile.a + @${AR} cq lib${LIB}_profile.a `lorder ${POBJS} | tsort -q` ${ARADD} + ${RANLIB} lib${LIB}_profile.a + +DOBJS+= ${OBJS:.o=.do} +lib${LIB}_debug.a:: ${DOBJS} + @${ECHO} building debug ${LIB} library + @rm -f lib${LIB}_debug.a + @${AR} cq lib${LIB}_debug.a `lorder ${DOBJS} | tsort -q` ${ARADD} + ${RANLIB} lib${LIB}_debug.a + +lib${LIB}.a:: ${SOBJS} + @${ECHO} building standard ${LIB} library + @rm -f lib${LIB}.a + @${AR} cq lib${LIB}.a `lorder ${SOBJS} | tsort -q` ${ARADD} + ${RANLIB} lib${LIB}.a + +CLEANFILES += ${DOBJS} libc_static.a libc_profile.a libc_debug.a + +installhdrs: gen_mig_defs + mkdir -p ${DESTDIR}/usr/include/arpa + mkdir -p ${DESTDIR}/usr/include/protocols + mkdir -p ${DESTDIR}/usr/include/mach + mkdir -p ${DESTDIR}/usr/include/objc + mkdir -p ${DESTDIR}/usr/include/servers + ${INSTALL} -c -m 444 ${INSTHDRS} ${DESTDIR}/usr/include + ${INSTALL} -c -m 444 ${ARPA_INSTHDRS} ${DESTDIR}/usr/include/arpa + ${INSTALL} -c -m 444 ${PROTO_INSTHDRS} ${DESTDIR}/usr/include/protocols + ${INSTALL} -c -m 444 ${MACH_INSTHDRS} ${DESTDIR}/usr/include/mach + ${INSTALL} -c -m 444 ${OBJC_INSTHDRS} ${DESTDIR}/usr/include/objc + ${INSTALL} -c -m 444 ${SRVHDRS} ${DESTDIR}/usr/include/servers + mv ${DESTDIR}/usr/include/servers/srvbootstrap.h ${DESTDIR}/usr/include/servers/bootstrap.h + mkdir -p ${DESTDIR}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/ + mkdir -p ${DESTDIR}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/architecture + mkdir -p ${DESTDIR}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/architecture/ppc + mkdir -p ${DESTDIR}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/btree + mkdir -p ${DESTDIR}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/machine + mkdir -p ${DESTDIR}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/objc + install -c -m 444 ${SRCROOT}/db/btree/btree.h ${DESTDIR}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/btree + install -c -m 444 ${SRCROOT}/db/btree/bt_extern.h ${DESTDIR}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/btree + install -c -m 444 ${SRCROOT}/ppc/sys/processor_facilities.h ${DESTDIR}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/architecture/ppc + install -c -m 444 ${SRCROOT}/internat/NXCType.h ${DESTDIR}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/objc + install -c -m 444 ${SRCROOT}/gen/stack_logging.h ${DESTDIR}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/ + mv ${DESTDIR}/usr/include/asm.h ${DESTDIR}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/machine + +install_lib${LIB}_static.a: + ${INSTALL} -c -m 444 lib${LIB}_static.a ${DESTDIR}/usr/local/lib/system/ +install_lib${LIB}_profile.a: + ${INSTALL} -c -m 444 lib${LIB}_profile.a ${DESTDIR}/usr/local/lib/system +install_lib${LIB}_debug.a: + ${INSTALL} -c -m 444 lib${LIB}_debug.a ${DESTDIR}/usr/local/lib/system/ +install_lib${LIB}.a: + ${INSTALL} -c -m 444 lib${LIB}.a ${DESTDIR}/usr/local/lib/system/ + +clean: + rm -f ${OBJS} ${POBJS} ${DOBJS} ${SOBJS} ${CLEANFILES} + rm -f lib${LIB}.a lib${LIB}_static.a lib${LIB}_profile.a \ + lib${LIB}_debug.a diff --git a/PB.project b/PB.project deleted file mode 100644 index ef095b6..0000000 --- a/PB.project +++ /dev/null @@ -1,50 +0,0 @@ -{ - CURRENTLY_ACTIVE_VERSION = YES; - DEPLOY_WITH_VERSION_NAME = A; - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - FRAMEWORKS = (); - H_FILES = (); - OTHER_LINKED = (crt_externs.c); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble); - SUBPROJECTS = ( - compat43.subproj, - db.subproj, - gen.subproj, - headers.subproj, - internat.subproj, - locale.subproj, - mach.subproj, - net.subproj, - pthreads.subproj, - regex.subproj, - stdio.subproj, - stdlib.subproj, - string.subproj, - sys.subproj, - threads.subproj, - util.subproj - ); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDDIR = "/Users/Shared/$(USER)/BUILD/$(NAME)"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_INSTALLDIR = /usr/local/lib/system; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - NEXTSTEP_PUBLICHEADERSDIR = /usr/include; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_INSTALLDIR = /lib; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PDO_UNIX_PUBLICHEADERSDIR = "$(LOCAL_DEVELOPER_DIR)/Headers/$(NAME)"; - PROJECTNAME = c; - PROJECTTYPE = Library; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_INSTALLDIR = /Developer/Libraries; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; - WINDOWS_PUBLICHEADERSDIR = "$(HOMEDRIVE)$(LOCAL_DEVELOPER_DIR)/Headers/$(NAME)"; -} diff --git a/REQUIRED-MACROS b/REQUIRED-MACROS new file mode 100644 index 0000000..4482b7a --- /dev/null +++ b/REQUIRED-MACROS @@ -0,0 +1,3 @@ +sigmask +WCOREDUMP + diff --git a/SYSCALL-LIST b/SYSCALL-LIST new file mode 100644 index 0000000..d9b9511 --- /dev/null +++ b/SYSCALL-LIST @@ -0,0 +1,142 @@ +accept +access +acct +adjtime +bind +brk +sbrk +chdir +fchdir +chflags +creat +fchflags +chmod +fchmod +chown +fchown +chroot +close +connect +dup +dup2 +execve +_exit +fcntl +flock +fork +fsync +getdirentries +getdtablesize +getfh +getfsstat +getgid +getegid +getgroups +getitimer +setitimer +getlogin +setlogin +getpeername +getpgrp +getpid +getppid +getpriority +setpriority +getrlimit +setrlimit +getrusage +getsockname +getsockopt +setsockopt +gettimeofday +settimeofday +getuid +geteuid +ioctl +kill +killpg +ktrace +link +listen +lseek +madvise +mincore +mkdir +mkfifo +mknod +mlock +munlock +mmap +mount +unmount +mprotect +msync +munmap +nfssvc +open +pathconf +fpathconf +pipe +profil +ptrace +quotactl +read +readv +readlink +reboot +recv +recvfrom +recvmsg +rename +revoke +rmdir +select +send +sendto +sendmsg +setgroups +setpgid +setpgrp +setregid +setreuid +setsid +setuid +seteuid +setgid +setegid +shutdown +sigaction +sigaltstack +sigblock +sigpause +sigpending +sigprocmask +sigreturn +sigsetmask +sigstack +sigsuspend +sigvec +socket +socketpair +stat +lstat +fstat +statfs +fstatfs +swapon +symlink +sync +syscall +__syscall +truncate +ftruncate +umask +unlink +utimes +vfork +wait +waitpid +wait3 +wait4 +write +writev diff --git a/compat-43/Makefile.inc b/compat-43/Makefile.inc new file mode 100644 index 0000000..8d6a7e0 --- /dev/null +++ b/compat-43/Makefile.inc @@ -0,0 +1,18 @@ +# @(#)Makefile.inc 8.1 (Berkeley) 6/2/93 +# $FreeBSD: src/lib/libc/compat-43/Makefile.inc,v 1.11 2001/03/27 17:26:46 ru Exp $ + +# compat-43 sources +.PATH: ${.CURDIR}/${MACHINE_ARCH}/compat-43 ${.CURDIR}/compat-43 + +SRCS+= creat.c getwd.c send.c setpgrp.c setreuid.c setruid.c \ + gethostid.c killpg.c sethostid.c setregid.c setrgid.c sigcompat.c + + +.if ${LIB} == "c" +MAN2+= creat.2 killpg.2 sigpause.2 sigvec.2 +MAN3+= gethostid.3 setruid.3 + +MLINKS+=gethostid.3 sethostid.3 +MLINKS+=setruid.3 setrgid.3 + +.endif diff --git a/compat-43/creat.2 b/compat-43/creat.2 new file mode 100644 index 0000000..a6e1828 --- /dev/null +++ b/compat-43/creat.2 @@ -0,0 +1,64 @@ +.\" Copyright (c) 1989, 1990, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)creat.2 8.1 (Berkeley) 6/2/93 +.\" $FreeBSD: src/lib/libc/compat-43/creat.2,v 1.6.2.3 2001/12/14 18:33:49 ru Exp $ +.\" +.Dd June 2, 1993 +.Dt CREAT 2 +.Os +.Sh NAME +.Nm creat +.Nd create a new file +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In fcntl.h +.Ft int +.Fn creat "const char *path" "mode_t mode" +.Sh DESCRIPTION +.Bf -symbolic +This interface is made obsolete by: +.Ef +.Xr open 2 . +.Pp +.Fn Creat +is the same as: +.Bd -literal -offset indent +open(path, O_CREAT | O_TRUNC | O_WRONLY, mode); +.Ed +.Sh SEE ALSO +.Xr open 2 +.Sh HISTORY +The +.Fn creat +function call appeared in +.At v6 . diff --git a/compat43.subproj/creat.c b/compat-43/creat.c similarity index 100% rename from compat43.subproj/creat.c rename to compat-43/creat.c diff --git a/compat-43/gethostid.3 b/compat-43/gethostid.3 new file mode 100644 index 0000000..9ab2e09 --- /dev/null +++ b/compat-43/gethostid.3 @@ -0,0 +1,78 @@ +.\" Copyright (c) 1983, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)gethostid.3 8.1 (Berkeley) 6/2/93 +.\" $FreeBSD: src/lib/libc/compat-43/gethostid.3,v 1.5.2.5 2001/12/14 18:33:49 ru Exp $ +.\" +.Dd June 2, 1993 +.Dt GETHOSTID 3 +.Os +.Sh NAME +.Nm gethostid , +.Nm sethostid +.Nd get/set unique identifier of current host +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft long +.Fn gethostid void +.Ft void +.Fn sethostid "long hostid" +.Sh DESCRIPTION +.Fn Sethostid +establishes a 32-bit identifier for the +current processor that is intended to be unique among all +UNIX systems in existence. This is normally a DARPA Internet +address for the local machine. This call is allowed only to the +super-user and is normally performed at boot time. +.Pp +.Fn Gethostid +returns the 32-bit identifier for the current processor. +.Pp +This function has been deprecated. +The hostid should be set or retrieved by use of +.Xr sysctl 3 . +.Sh SEE ALSO +.Xr gethostname 3 , +.Xr sysctl 3 , +.Xr sysctl 8 +.Sh BUGS +32 bits for the identifier is too small. +.Sh HISTORY +The +.Fn gethostid +and +.Fn sethostid +syscalls appeared in +.Bx 4.2 +and were dropped in +.Bx 4.4 . diff --git a/compat43.subproj/gethostid.c b/compat-43/gethostid.c similarity index 100% rename from compat43.subproj/gethostid.c rename to compat-43/gethostid.c diff --git a/compat43.subproj/getwd.c b/compat-43/getwd.c similarity index 100% rename from compat43.subproj/getwd.c rename to compat-43/getwd.c diff --git a/compat-43/killpg.2 b/compat-43/killpg.2 new file mode 100644 index 0000000..3e4d963 --- /dev/null +++ b/compat-43/killpg.2 @@ -0,0 +1,96 @@ +.\" Copyright (c) 1980, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)killpg.2 8.1 (Berkeley) 6/2/93 +.\" $FreeBSD: src/lib/libc/compat-43/killpg.2,v 1.6.2.3 2001/12/14 18:33:49 ru Exp $ +.\" +.Dd June 2, 1993 +.Dt KILLPG 2 +.Os +.Sh NAME +.Nm killpg +.Nd send signal to a process group +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In signal.h +.Ft int +.Fn killpg "pid_t pgrp" "int sig" +.Sh DESCRIPTION +.Fn Killpg +sends the signal +.Fa sig +to the process group +.Fa pgrp . +See +.Xr sigaction 2 +for a list of signals. +If +.Fa pgrp +is 0, +.Fn killpg +sends the signal to the sending process's process group. +.Pp +The sending process and members of the process group must +have the same effective user ID, or +the sender must be the super-user. +As a single special case the continue signal SIGCONT may be sent +to any process that is a descendant of the current process. +.Sh RETURN VALUES +.Rv -std killpg +.Sh ERRORS +.Fn Killpg +will fail and no signal will be sent if: +.Bl -tag -width Er +.It Bq Er EINVAL +.Fa Sig +is not a valid signal number. +.It Bq Er ESRCH +No process can be found in the process group specified by +.Fa pgrp . +.It Bq Er ESRCH +The process group was given as 0 +but the sending process does not have a process group. +.It Bq Er EPERM +The sending process is not the super-user and one or more +of the target processes has an effective user ID different from that +of the sending process. +.El +.Sh SEE ALSO +.Xr getpgrp 2 , +.Xr kill 2 , +.Xr sigaction 2 +.Sh HISTORY +The +.Fn killpg +function call appeared in +.Bx 4.0 . diff --git a/compat43.subproj/killpg.c b/compat-43/killpg.c similarity index 100% rename from compat43.subproj/killpg.c rename to compat-43/killpg.c diff --git a/compat43.subproj/send.c b/compat-43/send.c similarity index 100% rename from compat43.subproj/send.c rename to compat-43/send.c diff --git a/compat43.subproj/sethostid.c b/compat-43/sethostid.c similarity index 100% rename from compat43.subproj/sethostid.c rename to compat-43/sethostid.c diff --git a/compat43.subproj/setpgrp.c b/compat-43/setpgrp.c similarity index 100% rename from compat43.subproj/setpgrp.c rename to compat-43/setpgrp.c diff --git a/compat43.subproj/setregid.c b/compat-43/setregid.c similarity index 100% rename from compat43.subproj/setregid.c rename to compat-43/setregid.c diff --git a/compat43.subproj/setreuid.c b/compat-43/setreuid.c similarity index 100% rename from compat43.subproj/setreuid.c rename to compat-43/setreuid.c diff --git a/compat43.subproj/setrgid.c b/compat-43/setrgid.c similarity index 100% rename from compat43.subproj/setrgid.c rename to compat-43/setrgid.c diff --git a/compat-43/setruid.3 b/compat-43/setruid.3 new file mode 100644 index 0000000..4ab8b72 --- /dev/null +++ b/compat-43/setruid.3 @@ -0,0 +1,84 @@ +.\" Copyright (c) 1983, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)setruid.3 8.1 (Berkeley) 6/2/93 +.\" $FreeBSD: src/lib/libc/compat-43/setruid.3,v 1.5.2.5 2001/12/14 18:33:49 ru Exp $ +.\" +.Dd June 2, 1993 +.Dt SETRUID 3 +.Os +.Sh NAME +.Nm setruid , +.Nm setrgid +.Nd set user and group ID +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft int +.Fn setruid "uid_t ruid" +.Ft int +.Fn setrgid "gid_t rgid" +.Sh DESCRIPTION +The +.Fn setruid +function +.Pq Fn setrgid +sets the real user ID (group ID) of the +current process. +.Sh RETURN VALUES +.Rv -std +.Sh ERRORS +The functions fail if: +.Bl -tag -width Er +.It Bq Er EPERM +The user is not the super user and the ID +specified is not the real or effective ID. +.El +.Sh COMPATIBILITY +The use of these calls is not portable. +Their use is discouraged; they will be removed in the future. +.Sh SEE ALSO +.Xr getgid 2 , +.Xr getuid 2 , +.Xr setegid 2 , +.Xr seteuid 2 , +.Xr setgid 2 , +.Xr setuid 2 +.Sh HISTORY +The +.Fn setruid +and +.Fn setrgid +syscalls appeared in +.Bx 4.2 +and were dropped in +.Bx 4.4 . diff --git a/compat43.subproj/setruid.c b/compat-43/setruid.c similarity index 100% rename from compat43.subproj/setruid.c rename to compat-43/setruid.c diff --git a/compat-43/sigblock.2 b/compat-43/sigblock.2 new file mode 100644 index 0000000..43920c7 --- /dev/null +++ b/compat-43/sigblock.2 @@ -0,0 +1,87 @@ +.\" Copyright (c) 1983, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)sigblock.2 8.1 (Berkeley) 6/2/93 +.\" $FreeBSD: src/lib/libc/compat-43/sigblock.2,v 1.5.2.2 2001/12/21 10:07:08 ru Exp $ +.\" +.Dd June 2, 1993 +.Dt SIGBLOCK 2 +.Os +.Sh NAME +.Nm sigblock +.Nd block signals +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In signal.h +.Ft int +.Fn sigblock "int mask" +.Ft int +.Fn sigmask signum +.Sh DESCRIPTION +.Bf -symbolic +This interface is made obsolete by +.Xr sigprocmask 2 . +.Ef +.Pp +.Fn Sigblock +adds the signals specified in +.Fa mask +to the set of signals currently +being blocked from delivery. +Signals are blocked if the +corresponding bit in +.Fa mask +is a 1; the macro +.Fn sigmask +is provided to construct the mask for a given +.Fa signum . +.Pp +It is not possible to block +.Dv SIGKILL +or +.Dv SIGSTOP ; +this restriction is silently +imposed by the system. +.Sh RETURN VALUES +The previous set of masked signals is returned. +.Sh SEE ALSO +.Xr kill 2 , +.Xr sigaction 2 , +.Xr sigprocmask 2 , +.Xr sigsetmask 2 , +.Xr sigsetops 3 +.Sh HISTORY +The +.Fn sigblock +function call appeared in +.Bx 4.2 +and has been deprecated. diff --git a/compat43.subproj/sigcompat.c b/compat-43/sigcompat.c similarity index 90% rename from compat43.subproj/sigcompat.c rename to compat-43/sigcompat.c index 827075b..a0f5721 100644 --- a/compat43.subproj/sigcompat.c +++ b/compat-43/sigcompat.c @@ -55,6 +55,7 @@ #include #include +#include static int sigvec__(signo, sv, osv, bind) int signo; @@ -122,3 +123,27 @@ int sigpause(mask) { return (sigsuspend((sigset_t *)&mask)); } + +int sighold(sig) + int sig; +{ + sigset_t mask; + + if ((sig < 0) || (sig > NSIG)) + return(EINVAL); + sigemptyset(&mask); + sigaddset(&mask, sig); + return(sigprocmask(SIG_BLOCK, &mask,(sigset_t *)0)); +} +int sigrelse(sig) + int sig; +{ + sigset_t mask; + + if ((sig < 0) || (sig > NSIG)) + return(EINVAL); + sigemptyset(&mask); + sigaddset(&mask, sig); + return(sigprocmask(SIG_UNBLOCK, &mask,(sigset_t *)0)); +} + diff --git a/compat-43/sigpause.2 b/compat-43/sigpause.2 new file mode 100644 index 0000000..cd39071 --- /dev/null +++ b/compat-43/sigpause.2 @@ -0,0 +1,77 @@ +.\" Copyright (c) 1983, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)sigpause.2 8.1 (Berkeley) 6/2/93 +.\" $FreeBSD: src/lib/libc/compat-43/sigpause.2,v 1.5.2.5 2001/12/14 18:33:49 ru Exp $ +.\" +.Dd June 2, 1993 +.Dt SIGPAUSE 2 +.Os +.Sh NAME +.Nm sigpause +.Nd atomically release blocked signals and wait for interrupt +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In signal.h +.Ft int +.Fn sigpause "int sigmask" +.Sh DESCRIPTION +.Sy This interface is made obsolete by +.Xr sigsuspend 2 . +.Pp +.Fn Sigpause +assigns +.Fa sigmask +to the set of masked signals +and then waits for a signal to arrive; +on return the set of masked signals is restored. +.Fa Sigmask +is usually 0 to indicate that no +signals are to be blocked. +.Fn Sigpause +always terminates by being interrupted, returning -1 with +.Va errno +set to +.Er EINTR +.Sh SEE ALSO +.Xr kill 2 , +.Xr sigaction 2 , +.Xr sigblock 2 , +.Xr sigprocmask 2 , +.Xr sigsuspend 2 , +.Xr sigvec 2 +.Sh HISTORY +The +.Fn sigpause +function call appeared in +.Bx 4.2 +and has been deprecated. diff --git a/compat-43/sigsetmask.2 b/compat-43/sigsetmask.2 new file mode 100644 index 0000000..96ae7d3 --- /dev/null +++ b/compat-43/sigsetmask.2 @@ -0,0 +1,85 @@ +.\" Copyright (c) 1983, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)sigsetmask.2 8.1 (Berkeley) 6/2/93 +.\" $FreeBSD: src/lib/libc/compat-43/sigsetmask.2,v 1.7.2.4 2001/12/14 18:33:49 ru Exp $ +.\" +.Dd June 2, 1993 +.Dt SIGSETMASK 2 +.Os +.Sh NAME +.Nm sigsetmask +.Nd set current signal mask +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In signal.h +.Ft int +.Fn sigsetmask "int mask" +.Fn sigmask signum +.Sh DESCRIPTION +.Bf -symbolic +This interface is made obsolete by: +.Ef +.Xr sigprocmask 2 . +.Pp +.Fn Sigsetmask +sets the current signal mask. Signals +are blocked from delivery if the +corresponding bit in +.Fa mask +is a 1; the macro +.Fn sigmask +is provided to construct the mask for a given +.Fa signum . +.Pp +The system +quietly disallows +.Dv SIGKILL +or +.Dv SIGSTOP +to be blocked. +.Sh RETURN VALUES +The previous set of masked signals is returned. +.Sh SEE ALSO +.Xr kill 2 , +.Xr sigaction 2 , +.Xr sigblock 2 , +.Xr sigprocmask 2 , +.Xr sigsuspend 2 , +.Xr sigvec 2 , +.Xr sigsetops 3 +.Sh HISTORY +The +.Fn sigsetmask +function call appeared in +.Bx 4.2 +and has been deprecated. diff --git a/compat-43/sigvec.2 b/compat-43/sigvec.2 new file mode 100644 index 0000000..dbbcf2c --- /dev/null +++ b/compat-43/sigvec.2 @@ -0,0 +1,327 @@ +.\" Copyright (c) 1980, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)sigvec.2 8.2 (Berkeley) 4/19/94 +.\" $FreeBSD: src/lib/libc/compat-43/sigvec.2,v 1.9.2.7 2001/12/14 18:33:49 ru Exp $ +.\" +.Dd April 19, 1994 +.Dt SIGVEC 2 +.Os +.Sh NAME +.Nm sigvec +.Nd software signal facilities +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In signal.h +.Bd -literal +struct sigvec { + void (*sv_handler)(); + int sv_mask; + int sv_flags; +}; +.Ed +.Ft int +.Fn sigvec "int sig" "struct sigvec *vec" "struct sigvec *ovec" +.Sh DESCRIPTION +.Bf -symbolic +This interface is made obsolete by +.Xr sigaction 2 . +.Ef +.Pp +The system defines a set of signals that may be delivered to a process. +Signal delivery resembles the occurrence of a hardware interrupt: +the signal is blocked from further occurrence, the current process +context is saved, and a new one is built. A process may specify a +.Em handler +to which a signal is delivered, or specify that a signal is to be +.Em blocked +or +.Em ignored . +A process may also specify that a default action is to be taken +by the system when a signal occurs. +Normally, signal handlers execute on the current stack +of the process. This may be changed, on a per-handler basis, +so that signals are taken on a special +.Em "signal stack" . +.Pp +All signals have the same +.Em priority . +Signal routines execute with the signal that caused their +invocation +.Em blocked , +but other signals may yet occur. +A global +.Em "signal mask" +defines the set of signals currently blocked from delivery +to a process. The signal mask for a process is initialized +from that of its parent (normally 0). It +may be changed with a +.Xr sigblock 2 +or +.Xr sigsetmask 2 +call, or when a signal is delivered to the process. +.Pp +When a signal +condition arises for a process, the signal is added to a set of +signals pending for the process. If the signal is not currently +.Em blocked +by the process then it is delivered to the process. When a signal +is delivered, the current state of the process is saved, +a new signal mask is calculated (as described below), +and the signal handler is invoked. The call to the handler +is arranged so that if the signal handling routine returns +normally the process will resume execution in the context +from before the signal's delivery. +If the process wishes to resume in a different context, then it +must arrange to restore the previous context itself. +.Pp +When a signal is delivered to a process a new signal mask is +installed for the duration of the process' signal handler +(or until a +.Xr sigblock 2 +or +.Xr sigsetmask 2 +call is made). +This mask is formed by taking the current signal mask, +adding the signal to be delivered, and +.Em or Ns 'ing +in the signal mask associated with the handler to be invoked. +.Pp +.Fn Sigvec +assigns a handler for a specific signal. If +.Fa vec +is non-zero, it +specifies a handler routine and mask +to be used when delivering the specified signal. +Further, if the +.Dv SV_ONSTACK +bit is set in +.Fa sv_flags , +the system will deliver the signal to the process on a +.Em "signal stack" , +specified with +.Xr sigaltstack 2 . +If +.Fa ovec +is non-zero, the previous handling information for the signal +is returned to the user. +.Pp +The following is a list of all signals +with names as in the include file +.Aq Pa signal.h : +.Bl -column SIGVTALARMXX "create core imagexxx" +.It Sy "NAME Default Action Description" +.It Dv SIGHUP No " terminate process" " terminal line hangup" +.It Dv SIGINT No " terminate process" " interrupt program" +.It Dv SIGQUIT No " create core image" " quit program" +.It Dv SIGILL No " create core image" " illegal instruction" +.It Dv SIGTRAP No " create core image" " trace trap" +.It Dv SIGABRT No " create core image" Ta Xr abort 3 +call (formerly +.Dv SIGIOT ) +.It Dv SIGEMT No " create core image" " emulate instruction executed" +.It Dv SIGFPE No " create core image" " floating-point exception" +.It Dv SIGKILL No " terminate process" " kill program" +.It Dv SIGBUS No " create core image" " bus error" +.It Dv SIGSEGV No " create core image" " segmentation violation" +.It Dv SIGSYS No " create core image" " non-existent system call invoked" +.It Dv SIGPIPE No " terminate process" " write on a pipe with no reader" +.It Dv SIGALRM No " terminate process" " real-time timer expired" +.It Dv SIGTERM No " terminate process" " software termination signal" +.It Dv SIGURG No " discard signal" " urgent condition present on socket" +.It Dv SIGSTOP No " stop process" " stop (cannot be caught or ignored)" +.It Dv SIGTSTP No " stop process" " stop signal generated from keyboard" +.It Dv SIGCONT No " discard signal" " continue after stop" +.It Dv SIGCHLD No " discard signal" " child status has changed" +.It Dv SIGTTIN No " stop process" " background read attempted from control terminal" +.It Dv SIGTTOU No " stop process" " background write attempted to control terminal" +.It Dv SIGIO No " discard signal" Tn " I/O" +is possible on a descriptor (see +.Xr fcntl 2 ) +.It Dv SIGXCPU No " terminate process" " cpu time limit exceeded (see" +.Xr setrlimit 2 ) +.It Dv SIGXFSZ No " terminate process" " file size limit exceeded (see" +.Xr setrlimit 2 ) +.It Dv SIGVTALRM No " terminate process" " virtual time alarm (see" +.Xr setitimer 2 ) +.It Dv SIGPROF No " terminate process" " profiling timer alarm (see" +.Xr setitimer 2 ) +.It Dv SIGWINCH No " discard signal" " Window size change" +.It Dv SIGINFO No " discard signal" " status request from keyboard" +.It Dv SIGUSR1 No " terminate process" " User defined signal 1" +.It Dv SIGUSR2 No " terminate process" " User defined signal 2" +.El +.Pp +Once a signal handler is installed, it remains installed +until another +.Fn sigvec +call is made, or an +.Xr execve 2 +is performed. +A signal-specific default action may be reset by +setting +.Fa sv_handler +to +.Dv SIG_DFL . +The defaults are process termination, possibly with core dump; +no action; stopping the process; or continuing the process. +See the above signal list for each signal's default action. +If +.Fa sv_handler +is +.Dv SIG_IGN +current and pending instances +of the signal are ignored and discarded. +.Pp +If a signal is caught during the system calls listed below, +the call is normally restarted. +The call can be forced to terminate prematurely with an +.Er EINTR +error return by setting the +.Dv SV_INTERRUPT +bit in +.Fa sv_flags . +The affected system calls include +.Xr read 2 , +.Xr write 2 , +.Xr sendto 2 , +.Xr recvfrom 2 , +.Xr sendmsg 2 +and +.Xr recvmsg 2 +on a communications channel or a slow device (such as a terminal, +but not a regular file) +and during a +.Xr wait 2 +or +.Xr ioctl 2 . +However, calls that have already committed are not restarted, +but instead return a partial success (for example, a short read count). +.Pp +After a +.Xr fork 2 +or +.Xr vfork 2 +all signals, the signal mask, the signal stack, +and the restart/interrupt flags are inherited by the child. +.Pp +.Xr Execve 2 +reinstates the default +action for all signals which were caught and +resets all signals to be caught on the user stack. +Ignored signals remain ignored; +the signal mask remains the same; +signals that interrupt system calls continue to do so. +.Sh NOTES +The mask specified in +.Fa vec +is not allowed to block +.Dv SIGKILL +or +.Dv SIGSTOP . +This is done silently by the system. +.Pp +The +.Dv SV_INTERRUPT +flag is not available in +.Bx 4.2 , +hence it should not be used if backward compatibility is needed. +.Sh RETURN VALUES +.Rv -std sigvec +.Sh ERRORS +.Fn Sigvec +will fail and no new signal handler will be installed if one +of the following occurs: +.Bl -tag -width Er +.It Bq Er EFAULT +Either +.Fa vec +or +.Fa ovec +points to memory that is not a valid part of the process +address space. +.It Bq Er EINVAL +.Fa Sig +is not a valid signal number. +.It Bq Er EINVAL +An attempt is made to ignore or supply a handler for +.Dv SIGKILL +or +.Dv SIGSTOP . +.El +.Sh SEE ALSO +.Xr kill 1 , +.Xr kill 2 , +.Xr ptrace 2 , +.Xr sigaction 2 , +.Xr sigaltstack 2 , +.Xr sigblock 2 , +.Xr sigpause 2 , +.Xr sigprocmask 2 , +.Xr sigsetmask 2 , +.Xr sigsuspend 2 , +.Xr setjmp 3 , +.Xr siginterrupt 3 , +.Xr signal 3 , +.Xr sigsetops 3 , +.Xr tty 4 +.Sh EXAMPLES +On the +.Tn VAX\-11 +The handler routine can be declared: +.Bd -literal -offset indent +void handler(sig, code, scp) +int sig, code; +struct sigcontext *scp; +.Ed +.Pp +Here +.Fa sig +is the signal number, into which the hardware faults and traps are +mapped as defined below. +.Fa Code +is a parameter that is either a constant +as given below or, for compatibility mode faults, the code provided by +the hardware (Compatibility mode faults are distinguished from the +other +.Dv SIGILL +traps by having +.Dv PSL_CM +set in the psl). +.Fa Scp +is a pointer to the +.Fa sigcontext +structure (defined in +.Aq Pa signal.h ) , +used to restore the context from before the signal. +.Sh BUGS +This manual page is still confusing. diff --git a/compat43.subproj/Makefile b/compat43.subproj/Makefile deleted file mode 100644 index 5e7d581..0000000 --- a/compat43.subproj/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -# -# Generated by the NeXT Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = compat43 - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -CFILES = creat.c gethostid.c getwd.c killpg.c send.c sethostid.c\ - setpgrp.c setregid.c setreuid.c setrgid.c setruid.c\ - sigcompat.c - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble - - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - - - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/compat43.subproj/Makefile.postamble b/compat43.subproj/Makefile.postamble deleted file mode 100644 index 411cde6..0000000 --- a/compat43.subproj/Makefile.postamble +++ /dev/null @@ -1,100 +0,0 @@ -############################################################################### -# Makefile.postamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile, which is imported after all other makefiles, to -# override attributes for a project's Makefile environment. This allows you -# to take advantage of the environment set up by the other Makefiles. -# You can also define custom rules at the end of this file. -# -############################################################################### -# -# These variables are exported by the standard makefiles and can be -# used in any customizations you make. They are *outputs* of -# the Makefiles and should be used, not set. -# -# PRODUCTS: products to install. All of these products will be placed in -# the directory $(DSTROOT)$(INSTALLDIR) -# GLOBAL_RESOURCE_DIR: The directory to which resources are copied. -# LOCAL_RESOURCE_DIR: The directory to which localized resources are copied. -# OFILE_DIR: Directory into which .o object files are generated. -# DERIVED_SRC_DIR: Directory used for all other derived files -# -# ALL_CFLAGS: flags to pass when compiling .c files -# ALL_MFLAGS: flags to pass when compiling .m files -# ALL_CCFLAGS: flags to pass when compiling .cc, .cxx, and .C files -# ALL_MMFLAGS: flags to pass when compiling .mm, .mxx, and .M files -# ALL_PRECOMPFLAGS: flags to pass when precompiling .h files -# ALL_LDFLAGS: flags to pass when linking object files -# ALL_LIBTOOL_FLAGS: flags to pass when libtooling object files -# ALL_PSWFLAGS: flags to pass when processing .psw and .pswm (pswrap) files -# ALL_RPCFLAGS: flags to pass when processing .rpc (rpcgen) files -# ALL_YFLAGS: flags to pass when processing .y (yacc) files -# ALL_LFLAGS: flags to pass when processing .l (lex) files -# -# NAME: name of application, bundle, subproject, palette, etc. -# LANGUAGES: langages in which the project is written (default "English") -# English_RESOURCES: localized resources (e.g. nib's, images) of project -# GLOBAL_RESOURCES: non-localized resources of project -# -# SRCROOT: base directory in which to place the new source files -# SRCPATH: relative path from SRCROOT to present subdirectory -# -# INSTALLDIR: Directory the product will be installed into by 'install' target -# PUBLIC_HDR_INSTALLDIR: where to install public headers. Don't forget -# to prefix this with DSTROOT when you use it. -# PRIVATE_HDR_INSTALLDIR: where to install private headers. Don't forget -# to prefix this with DSTROOT when you use it. -# -# EXECUTABLE_EXT: Executable extension for the platform (i.e. .exe on Windows) -# -############################################################################### - -# Some compiler flags can be overridden here for certain build situations. -# -# WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost) -# DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults -# to -g) -# DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG) -# OPTIMIZE_BUILD_CFLAGS: flags passed during optimized builds (defaults -# to -O) -# PROFILE_BUILD_CFLAGS: flags passed during profile builds (defaults -# to -pg -DPROFILE) -# LOCAL_DIR_INCLUDE_DIRECTIVE: flag used to add current directory to -# the include path (defaults to -I.) -# DEBUG_BUILD_LDFLAGS, OPTIMIZE_BUILD_LDFLAGS, PROFILE_BUILD_LDFLAGS: flags -# passed to ld/libtool (defaults to nothing) - - -# Library and Framework projects only: -# INSTALL_NAME_DIRECTIVE: This directive ensures that executables linked -# against the framework will run against the correct version even if -# the current version of the framework changes. You may override this -# to "" as an alternative to using the DYLD_LIBRARY_PATH during your -# development cycle, but be sure to restore it before installing. - - -# Ownership and permissions of files installed by 'install' target - -#INSTALL_AS_USER = root - # User/group ownership -#INSTALL_AS_GROUP = wheel - # (probably want to set both of these) -#INSTALL_PERMISSIONS = - # If set, 'install' chmod's executable to this - - -# Options to strip. Note: -S strips debugging symbols (executables can be stripped -# down further with -x or, if they load no bundles, with no options at all). - -#STRIPFLAGS = -S - - -######################################################################### -# Put rules to extend the behavior of the standard Makefiles here. Include them in -# the dependency tree via cvariables like AFTER_INSTALL in the Makefile.preamble. -# -# You should avoid redefining things like "install" or "app", as they are -# owned by the top-level Makefile API and no context has been set up for where -# derived files should go. -# diff --git a/compat43.subproj/Makefile.preamble b/compat43.subproj/Makefile.preamble deleted file mode 100644 index c1624b4..0000000 --- a/compat43.subproj/Makefile.preamble +++ /dev/null @@ -1,137 +0,0 @@ -############################################################################### -# Makefile.preamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile for configuring the standard application makefiles -# associated with ProjectBuilder. It is included before the main makefile. -# In Makefile.preamble you set attributes for a project, so they are available -# to the project's makefiles. In contrast, you typically write additional rules or -# override built-in behavior in the Makefile.postamble. -# -# Each directory in a project tree (main project plus subprojects) should -# have its own Makefile.preamble and Makefile.postamble. -############################################################################### -# -# Before the main makefile is included for this project, you may set: -# -# MAKEFILEDIR: Directory in which to find $(MAKEFILE) -# MAKEFILE: Top level mechanism Makefile (e.g., app.make, bundle.make) - -# Compiler/linker flags added to the defaults: The OTHER_* variables will be -# inherited by all nested sub-projects, but the LOCAL_ versions of the same -# variables will not. Put your -I, -D, -U, and -L flags in ProjectBuilder's -# Build Attributes inspector if at all possible. To override the default flags -# that get passed to ${CC} (e.g. change -O to -O2), see Makefile.postamble. The -# variables below are *inputs* to the build process and distinct from the override -# settings done (less often) in the Makefile.postamble. -# -# OTHER_CFLAGS, LOCAL_CFLAGS: additional flags to pass to the compiler -# Note that $(OTHER_CFLAGS) and $(LOCAL_CFLAGS) are used for .h, ...c, .m, -# .cc, .cxx, .C, and .M files. There is no need to respecify the -# flags in OTHER_MFLAGS, etc. -# OTHER_MFLAGS, LOCAL_MFLAGS: additional flags for .m files -# OTHER_CCFLAGS, LOCAL_CCFLAGS: additional flags for .cc, .cxx, and ...C files -# OTHER_MMFLAGS, LOCAL_MMFLAGS: additional flags for .mm and .M files -# OTHER_PRECOMPFLAGS, LOCAL_PRECOMPFLAGS: additional flags used when -# precompiling header files -# OTHER_LDFLAGS, LOCAL_LDFLAGS: additional flags passed to ld and libtool -# OTHER_PSWFLAGS, LOCAL_PSWFLAGS: additional flags passed to pswrap -# OTHER_RPCFLAGS, LOCAL_RPCFLAGS: additional flags passed to rpcgen -# OTHER_YFLAGS, LOCAL_YFLAGS: additional flags passed to yacc -# OTHER_LFLAGS, LOCAL_LFLAGS: additional flags passed to lex - -# These variables provide hooks enabling you to add behavior at almost every -# stage of the make: -# -# BEFORE_PREBUILD: targets to build before installing headers for a subproject -# AFTER_PREBUILD: targets to build after installing headers for a subproject -# BEFORE_BUILD_RECURSION: targets to make before building subprojects -# BEFORE_BUILD: targets to make before a build, but after subprojects -# AFTER_BUILD: targets to make after a build -# -# BEFORE_INSTALL: targets to build before installing the product -# AFTER_INSTALL: targets to build after installing the product -# BEFORE_POSTINSTALL: targets to build before postinstalling every subproject -# AFTER_POSTINSTALL: targts to build after postinstalling every subproject -# -# BEFORE_INSTALLHDRS: targets to build before installing headers for a -# subproject -# AFTER_INSTALLHDRS: targets to build after installing headers for a subproject -# BEFORE_INSTALLSRC: targets to build before installing source for a subproject -# AFTER_INSTALLSRC: targets to build after installing source for a subproject -# -# BEFORE_DEPEND: targets to build before building dependencies for a -# subproject -# AFTER_DEPEND: targets to build after building dependencies for a -# subproject -# -# AUTOMATIC_DEPENDENCY_INFO: if YES, then the dependency file is -# updated every time the project is built. If NO, the dependency -# file is only built when the depend target is invoked. - -# Framework-related variables: -# FRAMEWORK_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the framework's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables - -# Library-related variables: -# PUBLIC_HEADER_DIR: Determines where public exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. For library projects you should -# set this to something like /Developer/Headers/$(NAME). Do not set -# this variable for framework projects unless you do not want the -# header files included in the framework. -# PRIVATE_HEADER_DIR: Determines where private exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. -# LIBRARY_STYLE: This may be either STATIC or DYNAMIC, and determines -# whether the libraries produced are statically linked when they -# are used or if they are dynamically loadable. This defaults to -# DYNAMIC. -# LIBRARY_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the library's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables -# -# INSTALL_AS_USER: owner of the intalled products (default root) -# INSTALL_AS_GROUP: group of the installed products (default wheel) -# INSTALL_PERMISSIONS: permissions of the installed product (default o+rX) -# -# OTHER_RECURSIVE_VARIABLES: The names of variables which you want to be -# passed on the command line to recursive invocations of make. Note that -# the values in OTHER_*FLAGS are inherited by subprojects automatically -- -# you do not have to (and shouldn't) add OTHER_*FLAGS to -# OTHER_RECURSIVE_VARIABLES. - -# Additional headers to export beyond those in the PB.project: -# OTHER_PUBLIC_HEADERS -# OTHER_PROJECT_HEADERS -# OTHER_PRIVATE_HEADERS - -# Additional files for the project's product: <> -# OTHER_RESOURCES: (non-localized) resources for this project -# OTHER_OFILES: relocatables to be linked into this project -# OTHER_LIBS: more libraries to link against -# OTHER_PRODUCT_DEPENDS: other dependencies of this project -# OTHER_SOURCEFILES: other source files maintained by .pre/postamble -# OTHER_GARBAGE: additional files to be removed by `make clean' - -# Set this to YES if you don't want a final libtool call for a library/framework. -# BUILD_OFILES_LIST_ONLY - -# To include a version string, project source must exist in a directory named -# $(NAME).%d[.%d][.%d] and the following line must be uncommented. -# OTHER_GENERATED_OFILES = $(VERS_OFILE) - -# This definition will suppress stripping of debug symbols when an executable -# is installed. By default it is YES. -# STRIP_ON_INSTALL = NO - -# Uncomment to suppress generation of a KeyValueCoding index when installing -# frameworks (This index is used by WOB and IB to determine keys available -# for an object). Set to YES by default. -# PREINDEX_FRAMEWORK = NO - -# Change this definition to install projects somewhere other than the -# standard locations. NEXT_ROOT defaults to "C:/Apple" on Windows systems -# and "" on other systems. -DSTROOT = $(HOME) diff --git a/compat43.subproj/PB.project b/compat43.subproj/PB.project deleted file mode 100644 index 846afeb..0000000 --- a/compat43.subproj/PB.project +++ /dev/null @@ -1,36 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - H_FILES = (); - OTHER_LINKED = ( - creat.c, - gethostid.c, - getwd.c, - killpg.c, - send.c, - sethostid.c, - setpgrp.c, - setregid.c, - setreuid.c, - setrgid.c, - setruid.c, - sigcompat.c - ); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble); - SUBPROJECTS = (); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = compat43; - PROJECTTYPE = Component; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/db.subproj/Makefile b/db.subproj/Makefile deleted file mode 100644 index 7ce1eb5..0000000 --- a/db.subproj/Makefile +++ /dev/null @@ -1,51 +0,0 @@ -# -# Generated by the NeXT Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = db - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -SUBPROJECTS = btree.subproj db.subproj hash.subproj mpool.subproj\ - recno.subproj - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -NEXTSTEP_INSTALLDIR = /Local/Developer/System -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - -NEXTSTEP_PB_CFLAGS = -D__DBINTERFACE_PRIVATE - - -NEXTSTEP_BUILD_OUTPUT_DIR = /Local/Public/Sandbox/$(USER)/BUILD/$(NAME) - -NEXTSTEP_PUBLIC_HEADERS_DIR = /usr/include - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/db.subproj/Makefile.postamble b/db.subproj/Makefile.postamble deleted file mode 100644 index 411cde6..0000000 --- a/db.subproj/Makefile.postamble +++ /dev/null @@ -1,100 +0,0 @@ -############################################################################### -# Makefile.postamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile, which is imported after all other makefiles, to -# override attributes for a project's Makefile environment. This allows you -# to take advantage of the environment set up by the other Makefiles. -# You can also define custom rules at the end of this file. -# -############################################################################### -# -# These variables are exported by the standard makefiles and can be -# used in any customizations you make. They are *outputs* of -# the Makefiles and should be used, not set. -# -# PRODUCTS: products to install. All of these products will be placed in -# the directory $(DSTROOT)$(INSTALLDIR) -# GLOBAL_RESOURCE_DIR: The directory to which resources are copied. -# LOCAL_RESOURCE_DIR: The directory to which localized resources are copied. -# OFILE_DIR: Directory into which .o object files are generated. -# DERIVED_SRC_DIR: Directory used for all other derived files -# -# ALL_CFLAGS: flags to pass when compiling .c files -# ALL_MFLAGS: flags to pass when compiling .m files -# ALL_CCFLAGS: flags to pass when compiling .cc, .cxx, and .C files -# ALL_MMFLAGS: flags to pass when compiling .mm, .mxx, and .M files -# ALL_PRECOMPFLAGS: flags to pass when precompiling .h files -# ALL_LDFLAGS: flags to pass when linking object files -# ALL_LIBTOOL_FLAGS: flags to pass when libtooling object files -# ALL_PSWFLAGS: flags to pass when processing .psw and .pswm (pswrap) files -# ALL_RPCFLAGS: flags to pass when processing .rpc (rpcgen) files -# ALL_YFLAGS: flags to pass when processing .y (yacc) files -# ALL_LFLAGS: flags to pass when processing .l (lex) files -# -# NAME: name of application, bundle, subproject, palette, etc. -# LANGUAGES: langages in which the project is written (default "English") -# English_RESOURCES: localized resources (e.g. nib's, images) of project -# GLOBAL_RESOURCES: non-localized resources of project -# -# SRCROOT: base directory in which to place the new source files -# SRCPATH: relative path from SRCROOT to present subdirectory -# -# INSTALLDIR: Directory the product will be installed into by 'install' target -# PUBLIC_HDR_INSTALLDIR: where to install public headers. Don't forget -# to prefix this with DSTROOT when you use it. -# PRIVATE_HDR_INSTALLDIR: where to install private headers. Don't forget -# to prefix this with DSTROOT when you use it. -# -# EXECUTABLE_EXT: Executable extension for the platform (i.e. .exe on Windows) -# -############################################################################### - -# Some compiler flags can be overridden here for certain build situations. -# -# WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost) -# DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults -# to -g) -# DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG) -# OPTIMIZE_BUILD_CFLAGS: flags passed during optimized builds (defaults -# to -O) -# PROFILE_BUILD_CFLAGS: flags passed during profile builds (defaults -# to -pg -DPROFILE) -# LOCAL_DIR_INCLUDE_DIRECTIVE: flag used to add current directory to -# the include path (defaults to -I.) -# DEBUG_BUILD_LDFLAGS, OPTIMIZE_BUILD_LDFLAGS, PROFILE_BUILD_LDFLAGS: flags -# passed to ld/libtool (defaults to nothing) - - -# Library and Framework projects only: -# INSTALL_NAME_DIRECTIVE: This directive ensures that executables linked -# against the framework will run against the correct version even if -# the current version of the framework changes. You may override this -# to "" as an alternative to using the DYLD_LIBRARY_PATH during your -# development cycle, but be sure to restore it before installing. - - -# Ownership and permissions of files installed by 'install' target - -#INSTALL_AS_USER = root - # User/group ownership -#INSTALL_AS_GROUP = wheel - # (probably want to set both of these) -#INSTALL_PERMISSIONS = - # If set, 'install' chmod's executable to this - - -# Options to strip. Note: -S strips debugging symbols (executables can be stripped -# down further with -x or, if they load no bundles, with no options at all). - -#STRIPFLAGS = -S - - -######################################################################### -# Put rules to extend the behavior of the standard Makefiles here. Include them in -# the dependency tree via cvariables like AFTER_INSTALL in the Makefile.preamble. -# -# You should avoid redefining things like "install" or "app", as they are -# owned by the top-level Makefile API and no context has been set up for where -# derived files should go. -# diff --git a/db.subproj/Makefile.preamble b/db.subproj/Makefile.preamble deleted file mode 100644 index c1624b4..0000000 --- a/db.subproj/Makefile.preamble +++ /dev/null @@ -1,137 +0,0 @@ -############################################################################### -# Makefile.preamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile for configuring the standard application makefiles -# associated with ProjectBuilder. It is included before the main makefile. -# In Makefile.preamble you set attributes for a project, so they are available -# to the project's makefiles. In contrast, you typically write additional rules or -# override built-in behavior in the Makefile.postamble. -# -# Each directory in a project tree (main project plus subprojects) should -# have its own Makefile.preamble and Makefile.postamble. -############################################################################### -# -# Before the main makefile is included for this project, you may set: -# -# MAKEFILEDIR: Directory in which to find $(MAKEFILE) -# MAKEFILE: Top level mechanism Makefile (e.g., app.make, bundle.make) - -# Compiler/linker flags added to the defaults: The OTHER_* variables will be -# inherited by all nested sub-projects, but the LOCAL_ versions of the same -# variables will not. Put your -I, -D, -U, and -L flags in ProjectBuilder's -# Build Attributes inspector if at all possible. To override the default flags -# that get passed to ${CC} (e.g. change -O to -O2), see Makefile.postamble. The -# variables below are *inputs* to the build process and distinct from the override -# settings done (less often) in the Makefile.postamble. -# -# OTHER_CFLAGS, LOCAL_CFLAGS: additional flags to pass to the compiler -# Note that $(OTHER_CFLAGS) and $(LOCAL_CFLAGS) are used for .h, ...c, .m, -# .cc, .cxx, .C, and .M files. There is no need to respecify the -# flags in OTHER_MFLAGS, etc. -# OTHER_MFLAGS, LOCAL_MFLAGS: additional flags for .m files -# OTHER_CCFLAGS, LOCAL_CCFLAGS: additional flags for .cc, .cxx, and ...C files -# OTHER_MMFLAGS, LOCAL_MMFLAGS: additional flags for .mm and .M files -# OTHER_PRECOMPFLAGS, LOCAL_PRECOMPFLAGS: additional flags used when -# precompiling header files -# OTHER_LDFLAGS, LOCAL_LDFLAGS: additional flags passed to ld and libtool -# OTHER_PSWFLAGS, LOCAL_PSWFLAGS: additional flags passed to pswrap -# OTHER_RPCFLAGS, LOCAL_RPCFLAGS: additional flags passed to rpcgen -# OTHER_YFLAGS, LOCAL_YFLAGS: additional flags passed to yacc -# OTHER_LFLAGS, LOCAL_LFLAGS: additional flags passed to lex - -# These variables provide hooks enabling you to add behavior at almost every -# stage of the make: -# -# BEFORE_PREBUILD: targets to build before installing headers for a subproject -# AFTER_PREBUILD: targets to build after installing headers for a subproject -# BEFORE_BUILD_RECURSION: targets to make before building subprojects -# BEFORE_BUILD: targets to make before a build, but after subprojects -# AFTER_BUILD: targets to make after a build -# -# BEFORE_INSTALL: targets to build before installing the product -# AFTER_INSTALL: targets to build after installing the product -# BEFORE_POSTINSTALL: targets to build before postinstalling every subproject -# AFTER_POSTINSTALL: targts to build after postinstalling every subproject -# -# BEFORE_INSTALLHDRS: targets to build before installing headers for a -# subproject -# AFTER_INSTALLHDRS: targets to build after installing headers for a subproject -# BEFORE_INSTALLSRC: targets to build before installing source for a subproject -# AFTER_INSTALLSRC: targets to build after installing source for a subproject -# -# BEFORE_DEPEND: targets to build before building dependencies for a -# subproject -# AFTER_DEPEND: targets to build after building dependencies for a -# subproject -# -# AUTOMATIC_DEPENDENCY_INFO: if YES, then the dependency file is -# updated every time the project is built. If NO, the dependency -# file is only built when the depend target is invoked. - -# Framework-related variables: -# FRAMEWORK_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the framework's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables - -# Library-related variables: -# PUBLIC_HEADER_DIR: Determines where public exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. For library projects you should -# set this to something like /Developer/Headers/$(NAME). Do not set -# this variable for framework projects unless you do not want the -# header files included in the framework. -# PRIVATE_HEADER_DIR: Determines where private exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. -# LIBRARY_STYLE: This may be either STATIC or DYNAMIC, and determines -# whether the libraries produced are statically linked when they -# are used or if they are dynamically loadable. This defaults to -# DYNAMIC. -# LIBRARY_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the library's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables -# -# INSTALL_AS_USER: owner of the intalled products (default root) -# INSTALL_AS_GROUP: group of the installed products (default wheel) -# INSTALL_PERMISSIONS: permissions of the installed product (default o+rX) -# -# OTHER_RECURSIVE_VARIABLES: The names of variables which you want to be -# passed on the command line to recursive invocations of make. Note that -# the values in OTHER_*FLAGS are inherited by subprojects automatically -- -# you do not have to (and shouldn't) add OTHER_*FLAGS to -# OTHER_RECURSIVE_VARIABLES. - -# Additional headers to export beyond those in the PB.project: -# OTHER_PUBLIC_HEADERS -# OTHER_PROJECT_HEADERS -# OTHER_PRIVATE_HEADERS - -# Additional files for the project's product: <> -# OTHER_RESOURCES: (non-localized) resources for this project -# OTHER_OFILES: relocatables to be linked into this project -# OTHER_LIBS: more libraries to link against -# OTHER_PRODUCT_DEPENDS: other dependencies of this project -# OTHER_SOURCEFILES: other source files maintained by .pre/postamble -# OTHER_GARBAGE: additional files to be removed by `make clean' - -# Set this to YES if you don't want a final libtool call for a library/framework. -# BUILD_OFILES_LIST_ONLY - -# To include a version string, project source must exist in a directory named -# $(NAME).%d[.%d][.%d] and the following line must be uncommented. -# OTHER_GENERATED_OFILES = $(VERS_OFILE) - -# This definition will suppress stripping of debug symbols when an executable -# is installed. By default it is YES. -# STRIP_ON_INSTALL = NO - -# Uncomment to suppress generation of a KeyValueCoding index when installing -# frameworks (This index is used by WOB and IB to determine keys available -# for an object). Set to YES by default. -# PREINDEX_FRAMEWORK = NO - -# Change this definition to install projects somewhere other than the -# standard locations. NEXT_ROOT defaults to "C:/Apple" on Windows systems -# and "" on other systems. -DSTROOT = $(HOME) diff --git a/db.subproj/PB.project b/db.subproj/PB.project deleted file mode 100644 index 3a69a6c..0000000 --- a/db.subproj/PB.project +++ /dev/null @@ -1,26 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - H_FILES = (); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble); - SUBPROJECTS = (btree.subproj, db.subproj, hash.subproj, mpool.subproj, recno.subproj); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDDIR = "/Local/Public/Sandbox/$(USER)/BUILD/$(NAME)"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_COMPILEROPTIONS = "-D__DBINTERFACE_PRIVATE"; - NEXTSTEP_INSTALLDIR = /Local/Developer/System; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - NEXTSTEP_PUBLICHEADERSDIR = /usr/include; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = db; - PROJECTTYPE = Component; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/db.subproj/btree.subproj/Makefile b/db.subproj/btree.subproj/Makefile deleted file mode 100644 index c185508..0000000 --- a/db.subproj/btree.subproj/Makefile +++ /dev/null @@ -1,56 +0,0 @@ -# -# Generated by the NeXT Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = btree - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -HFILES = bt_extern.h btree.h - -CFILES = bt_close.c bt_conv.c bt_debug.c bt_delete.c bt_get.c\ - bt_open.c bt_overflow.c bt_page.c bt_put.c bt_search.c\ - bt_seq.c bt_split.c bt_stack.c bt_utils.c - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble - - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -NEXTSTEP_INSTALLDIR = /Local/Developer/System -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - -PROJECT_HEADERS = btree.h bt_extern.h - - - -NEXTSTEP_BUILD_OUTPUT_DIR = /Local/Public/Sandbox/$(USER)/BUILD/$(NAME) - -NEXTSTEP_PUBLIC_HEADERS_DIR = /usr/include - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/db.subproj/btree.subproj/Makefile.postamble b/db.subproj/btree.subproj/Makefile.postamble deleted file mode 100644 index 411cde6..0000000 --- a/db.subproj/btree.subproj/Makefile.postamble +++ /dev/null @@ -1,100 +0,0 @@ -############################################################################### -# Makefile.postamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile, which is imported after all other makefiles, to -# override attributes for a project's Makefile environment. This allows you -# to take advantage of the environment set up by the other Makefiles. -# You can also define custom rules at the end of this file. -# -############################################################################### -# -# These variables are exported by the standard makefiles and can be -# used in any customizations you make. They are *outputs* of -# the Makefiles and should be used, not set. -# -# PRODUCTS: products to install. All of these products will be placed in -# the directory $(DSTROOT)$(INSTALLDIR) -# GLOBAL_RESOURCE_DIR: The directory to which resources are copied. -# LOCAL_RESOURCE_DIR: The directory to which localized resources are copied. -# OFILE_DIR: Directory into which .o object files are generated. -# DERIVED_SRC_DIR: Directory used for all other derived files -# -# ALL_CFLAGS: flags to pass when compiling .c files -# ALL_MFLAGS: flags to pass when compiling .m files -# ALL_CCFLAGS: flags to pass when compiling .cc, .cxx, and .C files -# ALL_MMFLAGS: flags to pass when compiling .mm, .mxx, and .M files -# ALL_PRECOMPFLAGS: flags to pass when precompiling .h files -# ALL_LDFLAGS: flags to pass when linking object files -# ALL_LIBTOOL_FLAGS: flags to pass when libtooling object files -# ALL_PSWFLAGS: flags to pass when processing .psw and .pswm (pswrap) files -# ALL_RPCFLAGS: flags to pass when processing .rpc (rpcgen) files -# ALL_YFLAGS: flags to pass when processing .y (yacc) files -# ALL_LFLAGS: flags to pass when processing .l (lex) files -# -# NAME: name of application, bundle, subproject, palette, etc. -# LANGUAGES: langages in which the project is written (default "English") -# English_RESOURCES: localized resources (e.g. nib's, images) of project -# GLOBAL_RESOURCES: non-localized resources of project -# -# SRCROOT: base directory in which to place the new source files -# SRCPATH: relative path from SRCROOT to present subdirectory -# -# INSTALLDIR: Directory the product will be installed into by 'install' target -# PUBLIC_HDR_INSTALLDIR: where to install public headers. Don't forget -# to prefix this with DSTROOT when you use it. -# PRIVATE_HDR_INSTALLDIR: where to install private headers. Don't forget -# to prefix this with DSTROOT when you use it. -# -# EXECUTABLE_EXT: Executable extension for the platform (i.e. .exe on Windows) -# -############################################################################### - -# Some compiler flags can be overridden here for certain build situations. -# -# WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost) -# DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults -# to -g) -# DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG) -# OPTIMIZE_BUILD_CFLAGS: flags passed during optimized builds (defaults -# to -O) -# PROFILE_BUILD_CFLAGS: flags passed during profile builds (defaults -# to -pg -DPROFILE) -# LOCAL_DIR_INCLUDE_DIRECTIVE: flag used to add current directory to -# the include path (defaults to -I.) -# DEBUG_BUILD_LDFLAGS, OPTIMIZE_BUILD_LDFLAGS, PROFILE_BUILD_LDFLAGS: flags -# passed to ld/libtool (defaults to nothing) - - -# Library and Framework projects only: -# INSTALL_NAME_DIRECTIVE: This directive ensures that executables linked -# against the framework will run against the correct version even if -# the current version of the framework changes. You may override this -# to "" as an alternative to using the DYLD_LIBRARY_PATH during your -# development cycle, but be sure to restore it before installing. - - -# Ownership and permissions of files installed by 'install' target - -#INSTALL_AS_USER = root - # User/group ownership -#INSTALL_AS_GROUP = wheel - # (probably want to set both of these) -#INSTALL_PERMISSIONS = - # If set, 'install' chmod's executable to this - - -# Options to strip. Note: -S strips debugging symbols (executables can be stripped -# down further with -x or, if they load no bundles, with no options at all). - -#STRIPFLAGS = -S - - -######################################################################### -# Put rules to extend the behavior of the standard Makefiles here. Include them in -# the dependency tree via cvariables like AFTER_INSTALL in the Makefile.preamble. -# -# You should avoid redefining things like "install" or "app", as they are -# owned by the top-level Makefile API and no context has been set up for where -# derived files should go. -# diff --git a/db.subproj/btree.subproj/Makefile.preamble b/db.subproj/btree.subproj/Makefile.preamble deleted file mode 100644 index c9fa330..0000000 --- a/db.subproj/btree.subproj/Makefile.preamble +++ /dev/null @@ -1,3 +0,0 @@ -OTHER_PRIVATE_HEADERS = btree.h bt_extern.h -PUBLIC_HEADER_DIR_SUFFIX = /btree -PRIVATE_HEADER_DIR_SUFFIX = /btree diff --git a/db.subproj/db.subproj/Makefile b/db.subproj/db.subproj/Makefile deleted file mode 100644 index b3f08b6..0000000 --- a/db.subproj/db.subproj/Makefile +++ /dev/null @@ -1,45 +0,0 @@ -# -# Generated by the NeXT Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = db - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -CFILES = db.c - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble - - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - - - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/db.subproj/db.subproj/Makefile.postamble b/db.subproj/db.subproj/Makefile.postamble deleted file mode 100644 index 411cde6..0000000 --- a/db.subproj/db.subproj/Makefile.postamble +++ /dev/null @@ -1,100 +0,0 @@ -############################################################################### -# Makefile.postamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile, which is imported after all other makefiles, to -# override attributes for a project's Makefile environment. This allows you -# to take advantage of the environment set up by the other Makefiles. -# You can also define custom rules at the end of this file. -# -############################################################################### -# -# These variables are exported by the standard makefiles and can be -# used in any customizations you make. They are *outputs* of -# the Makefiles and should be used, not set. -# -# PRODUCTS: products to install. All of these products will be placed in -# the directory $(DSTROOT)$(INSTALLDIR) -# GLOBAL_RESOURCE_DIR: The directory to which resources are copied. -# LOCAL_RESOURCE_DIR: The directory to which localized resources are copied. -# OFILE_DIR: Directory into which .o object files are generated. -# DERIVED_SRC_DIR: Directory used for all other derived files -# -# ALL_CFLAGS: flags to pass when compiling .c files -# ALL_MFLAGS: flags to pass when compiling .m files -# ALL_CCFLAGS: flags to pass when compiling .cc, .cxx, and .C files -# ALL_MMFLAGS: flags to pass when compiling .mm, .mxx, and .M files -# ALL_PRECOMPFLAGS: flags to pass when precompiling .h files -# ALL_LDFLAGS: flags to pass when linking object files -# ALL_LIBTOOL_FLAGS: flags to pass when libtooling object files -# ALL_PSWFLAGS: flags to pass when processing .psw and .pswm (pswrap) files -# ALL_RPCFLAGS: flags to pass when processing .rpc (rpcgen) files -# ALL_YFLAGS: flags to pass when processing .y (yacc) files -# ALL_LFLAGS: flags to pass when processing .l (lex) files -# -# NAME: name of application, bundle, subproject, palette, etc. -# LANGUAGES: langages in which the project is written (default "English") -# English_RESOURCES: localized resources (e.g. nib's, images) of project -# GLOBAL_RESOURCES: non-localized resources of project -# -# SRCROOT: base directory in which to place the new source files -# SRCPATH: relative path from SRCROOT to present subdirectory -# -# INSTALLDIR: Directory the product will be installed into by 'install' target -# PUBLIC_HDR_INSTALLDIR: where to install public headers. Don't forget -# to prefix this with DSTROOT when you use it. -# PRIVATE_HDR_INSTALLDIR: where to install private headers. Don't forget -# to prefix this with DSTROOT when you use it. -# -# EXECUTABLE_EXT: Executable extension for the platform (i.e. .exe on Windows) -# -############################################################################### - -# Some compiler flags can be overridden here for certain build situations. -# -# WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost) -# DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults -# to -g) -# DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG) -# OPTIMIZE_BUILD_CFLAGS: flags passed during optimized builds (defaults -# to -O) -# PROFILE_BUILD_CFLAGS: flags passed during profile builds (defaults -# to -pg -DPROFILE) -# LOCAL_DIR_INCLUDE_DIRECTIVE: flag used to add current directory to -# the include path (defaults to -I.) -# DEBUG_BUILD_LDFLAGS, OPTIMIZE_BUILD_LDFLAGS, PROFILE_BUILD_LDFLAGS: flags -# passed to ld/libtool (defaults to nothing) - - -# Library and Framework projects only: -# INSTALL_NAME_DIRECTIVE: This directive ensures that executables linked -# against the framework will run against the correct version even if -# the current version of the framework changes. You may override this -# to "" as an alternative to using the DYLD_LIBRARY_PATH during your -# development cycle, but be sure to restore it before installing. - - -# Ownership and permissions of files installed by 'install' target - -#INSTALL_AS_USER = root - # User/group ownership -#INSTALL_AS_GROUP = wheel - # (probably want to set both of these) -#INSTALL_PERMISSIONS = - # If set, 'install' chmod's executable to this - - -# Options to strip. Note: -S strips debugging symbols (executables can be stripped -# down further with -x or, if they load no bundles, with no options at all). - -#STRIPFLAGS = -S - - -######################################################################### -# Put rules to extend the behavior of the standard Makefiles here. Include them in -# the dependency tree via cvariables like AFTER_INSTALL in the Makefile.preamble. -# -# You should avoid redefining things like "install" or "app", as they are -# owned by the top-level Makefile API and no context has been set up for where -# derived files should go. -# diff --git a/db.subproj/db.subproj/Makefile.preamble b/db.subproj/db.subproj/Makefile.preamble deleted file mode 100644 index c1624b4..0000000 --- a/db.subproj/db.subproj/Makefile.preamble +++ /dev/null @@ -1,137 +0,0 @@ -############################################################################### -# Makefile.preamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile for configuring the standard application makefiles -# associated with ProjectBuilder. It is included before the main makefile. -# In Makefile.preamble you set attributes for a project, so they are available -# to the project's makefiles. In contrast, you typically write additional rules or -# override built-in behavior in the Makefile.postamble. -# -# Each directory in a project tree (main project plus subprojects) should -# have its own Makefile.preamble and Makefile.postamble. -############################################################################### -# -# Before the main makefile is included for this project, you may set: -# -# MAKEFILEDIR: Directory in which to find $(MAKEFILE) -# MAKEFILE: Top level mechanism Makefile (e.g., app.make, bundle.make) - -# Compiler/linker flags added to the defaults: The OTHER_* variables will be -# inherited by all nested sub-projects, but the LOCAL_ versions of the same -# variables will not. Put your -I, -D, -U, and -L flags in ProjectBuilder's -# Build Attributes inspector if at all possible. To override the default flags -# that get passed to ${CC} (e.g. change -O to -O2), see Makefile.postamble. The -# variables below are *inputs* to the build process and distinct from the override -# settings done (less often) in the Makefile.postamble. -# -# OTHER_CFLAGS, LOCAL_CFLAGS: additional flags to pass to the compiler -# Note that $(OTHER_CFLAGS) and $(LOCAL_CFLAGS) are used for .h, ...c, .m, -# .cc, .cxx, .C, and .M files. There is no need to respecify the -# flags in OTHER_MFLAGS, etc. -# OTHER_MFLAGS, LOCAL_MFLAGS: additional flags for .m files -# OTHER_CCFLAGS, LOCAL_CCFLAGS: additional flags for .cc, .cxx, and ...C files -# OTHER_MMFLAGS, LOCAL_MMFLAGS: additional flags for .mm and .M files -# OTHER_PRECOMPFLAGS, LOCAL_PRECOMPFLAGS: additional flags used when -# precompiling header files -# OTHER_LDFLAGS, LOCAL_LDFLAGS: additional flags passed to ld and libtool -# OTHER_PSWFLAGS, LOCAL_PSWFLAGS: additional flags passed to pswrap -# OTHER_RPCFLAGS, LOCAL_RPCFLAGS: additional flags passed to rpcgen -# OTHER_YFLAGS, LOCAL_YFLAGS: additional flags passed to yacc -# OTHER_LFLAGS, LOCAL_LFLAGS: additional flags passed to lex - -# These variables provide hooks enabling you to add behavior at almost every -# stage of the make: -# -# BEFORE_PREBUILD: targets to build before installing headers for a subproject -# AFTER_PREBUILD: targets to build after installing headers for a subproject -# BEFORE_BUILD_RECURSION: targets to make before building subprojects -# BEFORE_BUILD: targets to make before a build, but after subprojects -# AFTER_BUILD: targets to make after a build -# -# BEFORE_INSTALL: targets to build before installing the product -# AFTER_INSTALL: targets to build after installing the product -# BEFORE_POSTINSTALL: targets to build before postinstalling every subproject -# AFTER_POSTINSTALL: targts to build after postinstalling every subproject -# -# BEFORE_INSTALLHDRS: targets to build before installing headers for a -# subproject -# AFTER_INSTALLHDRS: targets to build after installing headers for a subproject -# BEFORE_INSTALLSRC: targets to build before installing source for a subproject -# AFTER_INSTALLSRC: targets to build after installing source for a subproject -# -# BEFORE_DEPEND: targets to build before building dependencies for a -# subproject -# AFTER_DEPEND: targets to build after building dependencies for a -# subproject -# -# AUTOMATIC_DEPENDENCY_INFO: if YES, then the dependency file is -# updated every time the project is built. If NO, the dependency -# file is only built when the depend target is invoked. - -# Framework-related variables: -# FRAMEWORK_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the framework's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables - -# Library-related variables: -# PUBLIC_HEADER_DIR: Determines where public exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. For library projects you should -# set this to something like /Developer/Headers/$(NAME). Do not set -# this variable for framework projects unless you do not want the -# header files included in the framework. -# PRIVATE_HEADER_DIR: Determines where private exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. -# LIBRARY_STYLE: This may be either STATIC or DYNAMIC, and determines -# whether the libraries produced are statically linked when they -# are used or if they are dynamically loadable. This defaults to -# DYNAMIC. -# LIBRARY_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the library's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables -# -# INSTALL_AS_USER: owner of the intalled products (default root) -# INSTALL_AS_GROUP: group of the installed products (default wheel) -# INSTALL_PERMISSIONS: permissions of the installed product (default o+rX) -# -# OTHER_RECURSIVE_VARIABLES: The names of variables which you want to be -# passed on the command line to recursive invocations of make. Note that -# the values in OTHER_*FLAGS are inherited by subprojects automatically -- -# you do not have to (and shouldn't) add OTHER_*FLAGS to -# OTHER_RECURSIVE_VARIABLES. - -# Additional headers to export beyond those in the PB.project: -# OTHER_PUBLIC_HEADERS -# OTHER_PROJECT_HEADERS -# OTHER_PRIVATE_HEADERS - -# Additional files for the project's product: <> -# OTHER_RESOURCES: (non-localized) resources for this project -# OTHER_OFILES: relocatables to be linked into this project -# OTHER_LIBS: more libraries to link against -# OTHER_PRODUCT_DEPENDS: other dependencies of this project -# OTHER_SOURCEFILES: other source files maintained by .pre/postamble -# OTHER_GARBAGE: additional files to be removed by `make clean' - -# Set this to YES if you don't want a final libtool call for a library/framework. -# BUILD_OFILES_LIST_ONLY - -# To include a version string, project source must exist in a directory named -# $(NAME).%d[.%d][.%d] and the following line must be uncommented. -# OTHER_GENERATED_OFILES = $(VERS_OFILE) - -# This definition will suppress stripping of debug symbols when an executable -# is installed. By default it is YES. -# STRIP_ON_INSTALL = NO - -# Uncomment to suppress generation of a KeyValueCoding index when installing -# frameworks (This index is used by WOB and IB to determine keys available -# for an object). Set to YES by default. -# PREINDEX_FRAMEWORK = NO - -# Change this definition to install projects somewhere other than the -# standard locations. NEXT_ROOT defaults to "C:/Apple" on Windows systems -# and "" on other systems. -DSTROOT = $(HOME) diff --git a/db.subproj/db.subproj/PB.project b/db.subproj/db.subproj/PB.project deleted file mode 100644 index b93a5d0..0000000 --- a/db.subproj/db.subproj/PB.project +++ /dev/null @@ -1,23 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - H_FILES = (); - OTHER_LINKED = (db.c); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble); - SUBPROJECTS = (); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = db; - PROJECTTYPE = Component; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/db.subproj/hash.subproj/Makefile b/db.subproj/hash.subproj/Makefile deleted file mode 100644 index f27af80..0000000 --- a/db.subproj/hash.subproj/Makefile +++ /dev/null @@ -1,48 +0,0 @@ -# -# Generated by the NeXT Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = hash - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -HFILES = extern.h hash.h page.h search.h - -CFILES = hash.c hash_bigkey.c hash_buf.c hash_func.c hash_log2.c\ - hash_page.c hsearch.c ndbm.c - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble - - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - - - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/db.subproj/hash.subproj/Makefile.postamble b/db.subproj/hash.subproj/Makefile.postamble deleted file mode 100644 index 411cde6..0000000 --- a/db.subproj/hash.subproj/Makefile.postamble +++ /dev/null @@ -1,100 +0,0 @@ -############################################################################### -# Makefile.postamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile, which is imported after all other makefiles, to -# override attributes for a project's Makefile environment. This allows you -# to take advantage of the environment set up by the other Makefiles. -# You can also define custom rules at the end of this file. -# -############################################################################### -# -# These variables are exported by the standard makefiles and can be -# used in any customizations you make. They are *outputs* of -# the Makefiles and should be used, not set. -# -# PRODUCTS: products to install. All of these products will be placed in -# the directory $(DSTROOT)$(INSTALLDIR) -# GLOBAL_RESOURCE_DIR: The directory to which resources are copied. -# LOCAL_RESOURCE_DIR: The directory to which localized resources are copied. -# OFILE_DIR: Directory into which .o object files are generated. -# DERIVED_SRC_DIR: Directory used for all other derived files -# -# ALL_CFLAGS: flags to pass when compiling .c files -# ALL_MFLAGS: flags to pass when compiling .m files -# ALL_CCFLAGS: flags to pass when compiling .cc, .cxx, and .C files -# ALL_MMFLAGS: flags to pass when compiling .mm, .mxx, and .M files -# ALL_PRECOMPFLAGS: flags to pass when precompiling .h files -# ALL_LDFLAGS: flags to pass when linking object files -# ALL_LIBTOOL_FLAGS: flags to pass when libtooling object files -# ALL_PSWFLAGS: flags to pass when processing .psw and .pswm (pswrap) files -# ALL_RPCFLAGS: flags to pass when processing .rpc (rpcgen) files -# ALL_YFLAGS: flags to pass when processing .y (yacc) files -# ALL_LFLAGS: flags to pass when processing .l (lex) files -# -# NAME: name of application, bundle, subproject, palette, etc. -# LANGUAGES: langages in which the project is written (default "English") -# English_RESOURCES: localized resources (e.g. nib's, images) of project -# GLOBAL_RESOURCES: non-localized resources of project -# -# SRCROOT: base directory in which to place the new source files -# SRCPATH: relative path from SRCROOT to present subdirectory -# -# INSTALLDIR: Directory the product will be installed into by 'install' target -# PUBLIC_HDR_INSTALLDIR: where to install public headers. Don't forget -# to prefix this with DSTROOT when you use it. -# PRIVATE_HDR_INSTALLDIR: where to install private headers. Don't forget -# to prefix this with DSTROOT when you use it. -# -# EXECUTABLE_EXT: Executable extension for the platform (i.e. .exe on Windows) -# -############################################################################### - -# Some compiler flags can be overridden here for certain build situations. -# -# WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost) -# DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults -# to -g) -# DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG) -# OPTIMIZE_BUILD_CFLAGS: flags passed during optimized builds (defaults -# to -O) -# PROFILE_BUILD_CFLAGS: flags passed during profile builds (defaults -# to -pg -DPROFILE) -# LOCAL_DIR_INCLUDE_DIRECTIVE: flag used to add current directory to -# the include path (defaults to -I.) -# DEBUG_BUILD_LDFLAGS, OPTIMIZE_BUILD_LDFLAGS, PROFILE_BUILD_LDFLAGS: flags -# passed to ld/libtool (defaults to nothing) - - -# Library and Framework projects only: -# INSTALL_NAME_DIRECTIVE: This directive ensures that executables linked -# against the framework will run against the correct version even if -# the current version of the framework changes. You may override this -# to "" as an alternative to using the DYLD_LIBRARY_PATH during your -# development cycle, but be sure to restore it before installing. - - -# Ownership and permissions of files installed by 'install' target - -#INSTALL_AS_USER = root - # User/group ownership -#INSTALL_AS_GROUP = wheel - # (probably want to set both of these) -#INSTALL_PERMISSIONS = - # If set, 'install' chmod's executable to this - - -# Options to strip. Note: -S strips debugging symbols (executables can be stripped -# down further with -x or, if they load no bundles, with no options at all). - -#STRIPFLAGS = -S - - -######################################################################### -# Put rules to extend the behavior of the standard Makefiles here. Include them in -# the dependency tree via cvariables like AFTER_INSTALL in the Makefile.preamble. -# -# You should avoid redefining things like "install" or "app", as they are -# owned by the top-level Makefile API and no context has been set up for where -# derived files should go. -# diff --git a/db.subproj/hash.subproj/Makefile.preamble b/db.subproj/hash.subproj/Makefile.preamble deleted file mode 100644 index c1624b4..0000000 --- a/db.subproj/hash.subproj/Makefile.preamble +++ /dev/null @@ -1,137 +0,0 @@ -############################################################################### -# Makefile.preamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile for configuring the standard application makefiles -# associated with ProjectBuilder. It is included before the main makefile. -# In Makefile.preamble you set attributes for a project, so they are available -# to the project's makefiles. In contrast, you typically write additional rules or -# override built-in behavior in the Makefile.postamble. -# -# Each directory in a project tree (main project plus subprojects) should -# have its own Makefile.preamble and Makefile.postamble. -############################################################################### -# -# Before the main makefile is included for this project, you may set: -# -# MAKEFILEDIR: Directory in which to find $(MAKEFILE) -# MAKEFILE: Top level mechanism Makefile (e.g., app.make, bundle.make) - -# Compiler/linker flags added to the defaults: The OTHER_* variables will be -# inherited by all nested sub-projects, but the LOCAL_ versions of the same -# variables will not. Put your -I, -D, -U, and -L flags in ProjectBuilder's -# Build Attributes inspector if at all possible. To override the default flags -# that get passed to ${CC} (e.g. change -O to -O2), see Makefile.postamble. The -# variables below are *inputs* to the build process and distinct from the override -# settings done (less often) in the Makefile.postamble. -# -# OTHER_CFLAGS, LOCAL_CFLAGS: additional flags to pass to the compiler -# Note that $(OTHER_CFLAGS) and $(LOCAL_CFLAGS) are used for .h, ...c, .m, -# .cc, .cxx, .C, and .M files. There is no need to respecify the -# flags in OTHER_MFLAGS, etc. -# OTHER_MFLAGS, LOCAL_MFLAGS: additional flags for .m files -# OTHER_CCFLAGS, LOCAL_CCFLAGS: additional flags for .cc, .cxx, and ...C files -# OTHER_MMFLAGS, LOCAL_MMFLAGS: additional flags for .mm and .M files -# OTHER_PRECOMPFLAGS, LOCAL_PRECOMPFLAGS: additional flags used when -# precompiling header files -# OTHER_LDFLAGS, LOCAL_LDFLAGS: additional flags passed to ld and libtool -# OTHER_PSWFLAGS, LOCAL_PSWFLAGS: additional flags passed to pswrap -# OTHER_RPCFLAGS, LOCAL_RPCFLAGS: additional flags passed to rpcgen -# OTHER_YFLAGS, LOCAL_YFLAGS: additional flags passed to yacc -# OTHER_LFLAGS, LOCAL_LFLAGS: additional flags passed to lex - -# These variables provide hooks enabling you to add behavior at almost every -# stage of the make: -# -# BEFORE_PREBUILD: targets to build before installing headers for a subproject -# AFTER_PREBUILD: targets to build after installing headers for a subproject -# BEFORE_BUILD_RECURSION: targets to make before building subprojects -# BEFORE_BUILD: targets to make before a build, but after subprojects -# AFTER_BUILD: targets to make after a build -# -# BEFORE_INSTALL: targets to build before installing the product -# AFTER_INSTALL: targets to build after installing the product -# BEFORE_POSTINSTALL: targets to build before postinstalling every subproject -# AFTER_POSTINSTALL: targts to build after postinstalling every subproject -# -# BEFORE_INSTALLHDRS: targets to build before installing headers for a -# subproject -# AFTER_INSTALLHDRS: targets to build after installing headers for a subproject -# BEFORE_INSTALLSRC: targets to build before installing source for a subproject -# AFTER_INSTALLSRC: targets to build after installing source for a subproject -# -# BEFORE_DEPEND: targets to build before building dependencies for a -# subproject -# AFTER_DEPEND: targets to build after building dependencies for a -# subproject -# -# AUTOMATIC_DEPENDENCY_INFO: if YES, then the dependency file is -# updated every time the project is built. If NO, the dependency -# file is only built when the depend target is invoked. - -# Framework-related variables: -# FRAMEWORK_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the framework's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables - -# Library-related variables: -# PUBLIC_HEADER_DIR: Determines where public exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. For library projects you should -# set this to something like /Developer/Headers/$(NAME). Do not set -# this variable for framework projects unless you do not want the -# header files included in the framework. -# PRIVATE_HEADER_DIR: Determines where private exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. -# LIBRARY_STYLE: This may be either STATIC or DYNAMIC, and determines -# whether the libraries produced are statically linked when they -# are used or if they are dynamically loadable. This defaults to -# DYNAMIC. -# LIBRARY_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the library's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables -# -# INSTALL_AS_USER: owner of the intalled products (default root) -# INSTALL_AS_GROUP: group of the installed products (default wheel) -# INSTALL_PERMISSIONS: permissions of the installed product (default o+rX) -# -# OTHER_RECURSIVE_VARIABLES: The names of variables which you want to be -# passed on the command line to recursive invocations of make. Note that -# the values in OTHER_*FLAGS are inherited by subprojects automatically -- -# you do not have to (and shouldn't) add OTHER_*FLAGS to -# OTHER_RECURSIVE_VARIABLES. - -# Additional headers to export beyond those in the PB.project: -# OTHER_PUBLIC_HEADERS -# OTHER_PROJECT_HEADERS -# OTHER_PRIVATE_HEADERS - -# Additional files for the project's product: <> -# OTHER_RESOURCES: (non-localized) resources for this project -# OTHER_OFILES: relocatables to be linked into this project -# OTHER_LIBS: more libraries to link against -# OTHER_PRODUCT_DEPENDS: other dependencies of this project -# OTHER_SOURCEFILES: other source files maintained by .pre/postamble -# OTHER_GARBAGE: additional files to be removed by `make clean' - -# Set this to YES if you don't want a final libtool call for a library/framework. -# BUILD_OFILES_LIST_ONLY - -# To include a version string, project source must exist in a directory named -# $(NAME).%d[.%d][.%d] and the following line must be uncommented. -# OTHER_GENERATED_OFILES = $(VERS_OFILE) - -# This definition will suppress stripping of debug symbols when an executable -# is installed. By default it is YES. -# STRIP_ON_INSTALL = NO - -# Uncomment to suppress generation of a KeyValueCoding index when installing -# frameworks (This index is used by WOB and IB to determine keys available -# for an object). Set to YES by default. -# PREINDEX_FRAMEWORK = NO - -# Change this definition to install projects somewhere other than the -# standard locations. NEXT_ROOT defaults to "C:/Apple" on Windows systems -# and "" on other systems. -DSTROOT = $(HOME) diff --git a/db.subproj/hash.subproj/PB.project b/db.subproj/hash.subproj/PB.project deleted file mode 100644 index 6cfb553..0000000 --- a/db.subproj/hash.subproj/PB.project +++ /dev/null @@ -1,32 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - H_FILES = (extern.h, hash.h, page.h, search.h); - OTHER_LINKED = ( - hash.c, - hash_bigkey.c, - hash_buf.c, - hash_func.c, - hash_log2.c, - hash_page.c, - hsearch.c, - ndbm.c - ); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble); - SUBPROJECTS = (); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = hash; - PROJECTTYPE = Component; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/db.subproj/mpool.subproj/Makefile b/db.subproj/mpool.subproj/Makefile deleted file mode 100644 index a127134..0000000 --- a/db.subproj/mpool.subproj/Makefile +++ /dev/null @@ -1,45 +0,0 @@ -# -# Generated by the NeXT Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = mpool - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -CFILES = mpool.c - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble - - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - - - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/db.subproj/mpool.subproj/Makefile.postamble b/db.subproj/mpool.subproj/Makefile.postamble deleted file mode 100644 index 411cde6..0000000 --- a/db.subproj/mpool.subproj/Makefile.postamble +++ /dev/null @@ -1,100 +0,0 @@ -############################################################################### -# Makefile.postamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile, which is imported after all other makefiles, to -# override attributes for a project's Makefile environment. This allows you -# to take advantage of the environment set up by the other Makefiles. -# You can also define custom rules at the end of this file. -# -############################################################################### -# -# These variables are exported by the standard makefiles and can be -# used in any customizations you make. They are *outputs* of -# the Makefiles and should be used, not set. -# -# PRODUCTS: products to install. All of these products will be placed in -# the directory $(DSTROOT)$(INSTALLDIR) -# GLOBAL_RESOURCE_DIR: The directory to which resources are copied. -# LOCAL_RESOURCE_DIR: The directory to which localized resources are copied. -# OFILE_DIR: Directory into which .o object files are generated. -# DERIVED_SRC_DIR: Directory used for all other derived files -# -# ALL_CFLAGS: flags to pass when compiling .c files -# ALL_MFLAGS: flags to pass when compiling .m files -# ALL_CCFLAGS: flags to pass when compiling .cc, .cxx, and .C files -# ALL_MMFLAGS: flags to pass when compiling .mm, .mxx, and .M files -# ALL_PRECOMPFLAGS: flags to pass when precompiling .h files -# ALL_LDFLAGS: flags to pass when linking object files -# ALL_LIBTOOL_FLAGS: flags to pass when libtooling object files -# ALL_PSWFLAGS: flags to pass when processing .psw and .pswm (pswrap) files -# ALL_RPCFLAGS: flags to pass when processing .rpc (rpcgen) files -# ALL_YFLAGS: flags to pass when processing .y (yacc) files -# ALL_LFLAGS: flags to pass when processing .l (lex) files -# -# NAME: name of application, bundle, subproject, palette, etc. -# LANGUAGES: langages in which the project is written (default "English") -# English_RESOURCES: localized resources (e.g. nib's, images) of project -# GLOBAL_RESOURCES: non-localized resources of project -# -# SRCROOT: base directory in which to place the new source files -# SRCPATH: relative path from SRCROOT to present subdirectory -# -# INSTALLDIR: Directory the product will be installed into by 'install' target -# PUBLIC_HDR_INSTALLDIR: where to install public headers. Don't forget -# to prefix this with DSTROOT when you use it. -# PRIVATE_HDR_INSTALLDIR: where to install private headers. Don't forget -# to prefix this with DSTROOT when you use it. -# -# EXECUTABLE_EXT: Executable extension for the platform (i.e. .exe on Windows) -# -############################################################################### - -# Some compiler flags can be overridden here for certain build situations. -# -# WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost) -# DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults -# to -g) -# DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG) -# OPTIMIZE_BUILD_CFLAGS: flags passed during optimized builds (defaults -# to -O) -# PROFILE_BUILD_CFLAGS: flags passed during profile builds (defaults -# to -pg -DPROFILE) -# LOCAL_DIR_INCLUDE_DIRECTIVE: flag used to add current directory to -# the include path (defaults to -I.) -# DEBUG_BUILD_LDFLAGS, OPTIMIZE_BUILD_LDFLAGS, PROFILE_BUILD_LDFLAGS: flags -# passed to ld/libtool (defaults to nothing) - - -# Library and Framework projects only: -# INSTALL_NAME_DIRECTIVE: This directive ensures that executables linked -# against the framework will run against the correct version even if -# the current version of the framework changes. You may override this -# to "" as an alternative to using the DYLD_LIBRARY_PATH during your -# development cycle, but be sure to restore it before installing. - - -# Ownership and permissions of files installed by 'install' target - -#INSTALL_AS_USER = root - # User/group ownership -#INSTALL_AS_GROUP = wheel - # (probably want to set both of these) -#INSTALL_PERMISSIONS = - # If set, 'install' chmod's executable to this - - -# Options to strip. Note: -S strips debugging symbols (executables can be stripped -# down further with -x or, if they load no bundles, with no options at all). - -#STRIPFLAGS = -S - - -######################################################################### -# Put rules to extend the behavior of the standard Makefiles here. Include them in -# the dependency tree via cvariables like AFTER_INSTALL in the Makefile.preamble. -# -# You should avoid redefining things like "install" or "app", as they are -# owned by the top-level Makefile API and no context has been set up for where -# derived files should go. -# diff --git a/db.subproj/mpool.subproj/Makefile.preamble b/db.subproj/mpool.subproj/Makefile.preamble deleted file mode 100644 index c1624b4..0000000 --- a/db.subproj/mpool.subproj/Makefile.preamble +++ /dev/null @@ -1,137 +0,0 @@ -############################################################################### -# Makefile.preamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile for configuring the standard application makefiles -# associated with ProjectBuilder. It is included before the main makefile. -# In Makefile.preamble you set attributes for a project, so they are available -# to the project's makefiles. In contrast, you typically write additional rules or -# override built-in behavior in the Makefile.postamble. -# -# Each directory in a project tree (main project plus subprojects) should -# have its own Makefile.preamble and Makefile.postamble. -############################################################################### -# -# Before the main makefile is included for this project, you may set: -# -# MAKEFILEDIR: Directory in which to find $(MAKEFILE) -# MAKEFILE: Top level mechanism Makefile (e.g., app.make, bundle.make) - -# Compiler/linker flags added to the defaults: The OTHER_* variables will be -# inherited by all nested sub-projects, but the LOCAL_ versions of the same -# variables will not. Put your -I, -D, -U, and -L flags in ProjectBuilder's -# Build Attributes inspector if at all possible. To override the default flags -# that get passed to ${CC} (e.g. change -O to -O2), see Makefile.postamble. The -# variables below are *inputs* to the build process and distinct from the override -# settings done (less often) in the Makefile.postamble. -# -# OTHER_CFLAGS, LOCAL_CFLAGS: additional flags to pass to the compiler -# Note that $(OTHER_CFLAGS) and $(LOCAL_CFLAGS) are used for .h, ...c, .m, -# .cc, .cxx, .C, and .M files. There is no need to respecify the -# flags in OTHER_MFLAGS, etc. -# OTHER_MFLAGS, LOCAL_MFLAGS: additional flags for .m files -# OTHER_CCFLAGS, LOCAL_CCFLAGS: additional flags for .cc, .cxx, and ...C files -# OTHER_MMFLAGS, LOCAL_MMFLAGS: additional flags for .mm and .M files -# OTHER_PRECOMPFLAGS, LOCAL_PRECOMPFLAGS: additional flags used when -# precompiling header files -# OTHER_LDFLAGS, LOCAL_LDFLAGS: additional flags passed to ld and libtool -# OTHER_PSWFLAGS, LOCAL_PSWFLAGS: additional flags passed to pswrap -# OTHER_RPCFLAGS, LOCAL_RPCFLAGS: additional flags passed to rpcgen -# OTHER_YFLAGS, LOCAL_YFLAGS: additional flags passed to yacc -# OTHER_LFLAGS, LOCAL_LFLAGS: additional flags passed to lex - -# These variables provide hooks enabling you to add behavior at almost every -# stage of the make: -# -# BEFORE_PREBUILD: targets to build before installing headers for a subproject -# AFTER_PREBUILD: targets to build after installing headers for a subproject -# BEFORE_BUILD_RECURSION: targets to make before building subprojects -# BEFORE_BUILD: targets to make before a build, but after subprojects -# AFTER_BUILD: targets to make after a build -# -# BEFORE_INSTALL: targets to build before installing the product -# AFTER_INSTALL: targets to build after installing the product -# BEFORE_POSTINSTALL: targets to build before postinstalling every subproject -# AFTER_POSTINSTALL: targts to build after postinstalling every subproject -# -# BEFORE_INSTALLHDRS: targets to build before installing headers for a -# subproject -# AFTER_INSTALLHDRS: targets to build after installing headers for a subproject -# BEFORE_INSTALLSRC: targets to build before installing source for a subproject -# AFTER_INSTALLSRC: targets to build after installing source for a subproject -# -# BEFORE_DEPEND: targets to build before building dependencies for a -# subproject -# AFTER_DEPEND: targets to build after building dependencies for a -# subproject -# -# AUTOMATIC_DEPENDENCY_INFO: if YES, then the dependency file is -# updated every time the project is built. If NO, the dependency -# file is only built when the depend target is invoked. - -# Framework-related variables: -# FRAMEWORK_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the framework's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables - -# Library-related variables: -# PUBLIC_HEADER_DIR: Determines where public exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. For library projects you should -# set this to something like /Developer/Headers/$(NAME). Do not set -# this variable for framework projects unless you do not want the -# header files included in the framework. -# PRIVATE_HEADER_DIR: Determines where private exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. -# LIBRARY_STYLE: This may be either STATIC or DYNAMIC, and determines -# whether the libraries produced are statically linked when they -# are used or if they are dynamically loadable. This defaults to -# DYNAMIC. -# LIBRARY_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the library's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables -# -# INSTALL_AS_USER: owner of the intalled products (default root) -# INSTALL_AS_GROUP: group of the installed products (default wheel) -# INSTALL_PERMISSIONS: permissions of the installed product (default o+rX) -# -# OTHER_RECURSIVE_VARIABLES: The names of variables which you want to be -# passed on the command line to recursive invocations of make. Note that -# the values in OTHER_*FLAGS are inherited by subprojects automatically -- -# you do not have to (and shouldn't) add OTHER_*FLAGS to -# OTHER_RECURSIVE_VARIABLES. - -# Additional headers to export beyond those in the PB.project: -# OTHER_PUBLIC_HEADERS -# OTHER_PROJECT_HEADERS -# OTHER_PRIVATE_HEADERS - -# Additional files for the project's product: <> -# OTHER_RESOURCES: (non-localized) resources for this project -# OTHER_OFILES: relocatables to be linked into this project -# OTHER_LIBS: more libraries to link against -# OTHER_PRODUCT_DEPENDS: other dependencies of this project -# OTHER_SOURCEFILES: other source files maintained by .pre/postamble -# OTHER_GARBAGE: additional files to be removed by `make clean' - -# Set this to YES if you don't want a final libtool call for a library/framework. -# BUILD_OFILES_LIST_ONLY - -# To include a version string, project source must exist in a directory named -# $(NAME).%d[.%d][.%d] and the following line must be uncommented. -# OTHER_GENERATED_OFILES = $(VERS_OFILE) - -# This definition will suppress stripping of debug symbols when an executable -# is installed. By default it is YES. -# STRIP_ON_INSTALL = NO - -# Uncomment to suppress generation of a KeyValueCoding index when installing -# frameworks (This index is used by WOB and IB to determine keys available -# for an object). Set to YES by default. -# PREINDEX_FRAMEWORK = NO - -# Change this definition to install projects somewhere other than the -# standard locations. NEXT_ROOT defaults to "C:/Apple" on Windows systems -# and "" on other systems. -DSTROOT = $(HOME) diff --git a/db.subproj/mpool.subproj/PB.project b/db.subproj/mpool.subproj/PB.project deleted file mode 100644 index 06d52a0..0000000 --- a/db.subproj/mpool.subproj/PB.project +++ /dev/null @@ -1,23 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - H_FILES = (); - OTHER_LINKED = (mpool.c); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble); - SUBPROJECTS = (); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = mpool; - PROJECTTYPE = Component; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/db.subproj/recno.subproj/Makefile b/db.subproj/recno.subproj/Makefile deleted file mode 100644 index 56520b7..0000000 --- a/db.subproj/recno.subproj/Makefile +++ /dev/null @@ -1,48 +0,0 @@ -# -# Generated by the NeXT Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = recno - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -HFILES = extern.h recno.h - -CFILES = rec_close.c rec_delete.c rec_get.c rec_open.c rec_put.c\ - rec_search.c rec_seq.c rec_utils.c - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble - - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - - - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/db.subproj/recno.subproj/Makefile.postamble b/db.subproj/recno.subproj/Makefile.postamble deleted file mode 100644 index 411cde6..0000000 --- a/db.subproj/recno.subproj/Makefile.postamble +++ /dev/null @@ -1,100 +0,0 @@ -############################################################################### -# Makefile.postamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile, which is imported after all other makefiles, to -# override attributes for a project's Makefile environment. This allows you -# to take advantage of the environment set up by the other Makefiles. -# You can also define custom rules at the end of this file. -# -############################################################################### -# -# These variables are exported by the standard makefiles and can be -# used in any customizations you make. They are *outputs* of -# the Makefiles and should be used, not set. -# -# PRODUCTS: products to install. All of these products will be placed in -# the directory $(DSTROOT)$(INSTALLDIR) -# GLOBAL_RESOURCE_DIR: The directory to which resources are copied. -# LOCAL_RESOURCE_DIR: The directory to which localized resources are copied. -# OFILE_DIR: Directory into which .o object files are generated. -# DERIVED_SRC_DIR: Directory used for all other derived files -# -# ALL_CFLAGS: flags to pass when compiling .c files -# ALL_MFLAGS: flags to pass when compiling .m files -# ALL_CCFLAGS: flags to pass when compiling .cc, .cxx, and .C files -# ALL_MMFLAGS: flags to pass when compiling .mm, .mxx, and .M files -# ALL_PRECOMPFLAGS: flags to pass when precompiling .h files -# ALL_LDFLAGS: flags to pass when linking object files -# ALL_LIBTOOL_FLAGS: flags to pass when libtooling object files -# ALL_PSWFLAGS: flags to pass when processing .psw and .pswm (pswrap) files -# ALL_RPCFLAGS: flags to pass when processing .rpc (rpcgen) files -# ALL_YFLAGS: flags to pass when processing .y (yacc) files -# ALL_LFLAGS: flags to pass when processing .l (lex) files -# -# NAME: name of application, bundle, subproject, palette, etc. -# LANGUAGES: langages in which the project is written (default "English") -# English_RESOURCES: localized resources (e.g. nib's, images) of project -# GLOBAL_RESOURCES: non-localized resources of project -# -# SRCROOT: base directory in which to place the new source files -# SRCPATH: relative path from SRCROOT to present subdirectory -# -# INSTALLDIR: Directory the product will be installed into by 'install' target -# PUBLIC_HDR_INSTALLDIR: where to install public headers. Don't forget -# to prefix this with DSTROOT when you use it. -# PRIVATE_HDR_INSTALLDIR: where to install private headers. Don't forget -# to prefix this with DSTROOT when you use it. -# -# EXECUTABLE_EXT: Executable extension for the platform (i.e. .exe on Windows) -# -############################################################################### - -# Some compiler flags can be overridden here for certain build situations. -# -# WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost) -# DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults -# to -g) -# DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG) -# OPTIMIZE_BUILD_CFLAGS: flags passed during optimized builds (defaults -# to -O) -# PROFILE_BUILD_CFLAGS: flags passed during profile builds (defaults -# to -pg -DPROFILE) -# LOCAL_DIR_INCLUDE_DIRECTIVE: flag used to add current directory to -# the include path (defaults to -I.) -# DEBUG_BUILD_LDFLAGS, OPTIMIZE_BUILD_LDFLAGS, PROFILE_BUILD_LDFLAGS: flags -# passed to ld/libtool (defaults to nothing) - - -# Library and Framework projects only: -# INSTALL_NAME_DIRECTIVE: This directive ensures that executables linked -# against the framework will run against the correct version even if -# the current version of the framework changes. You may override this -# to "" as an alternative to using the DYLD_LIBRARY_PATH during your -# development cycle, but be sure to restore it before installing. - - -# Ownership and permissions of files installed by 'install' target - -#INSTALL_AS_USER = root - # User/group ownership -#INSTALL_AS_GROUP = wheel - # (probably want to set both of these) -#INSTALL_PERMISSIONS = - # If set, 'install' chmod's executable to this - - -# Options to strip. Note: -S strips debugging symbols (executables can be stripped -# down further with -x or, if they load no bundles, with no options at all). - -#STRIPFLAGS = -S - - -######################################################################### -# Put rules to extend the behavior of the standard Makefiles here. Include them in -# the dependency tree via cvariables like AFTER_INSTALL in the Makefile.preamble. -# -# You should avoid redefining things like "install" or "app", as they are -# owned by the top-level Makefile API and no context has been set up for where -# derived files should go. -# diff --git a/db.subproj/recno.subproj/Makefile.preamble b/db.subproj/recno.subproj/Makefile.preamble deleted file mode 100644 index c1624b4..0000000 --- a/db.subproj/recno.subproj/Makefile.preamble +++ /dev/null @@ -1,137 +0,0 @@ -############################################################################### -# Makefile.preamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile for configuring the standard application makefiles -# associated with ProjectBuilder. It is included before the main makefile. -# In Makefile.preamble you set attributes for a project, so they are available -# to the project's makefiles. In contrast, you typically write additional rules or -# override built-in behavior in the Makefile.postamble. -# -# Each directory in a project tree (main project plus subprojects) should -# have its own Makefile.preamble and Makefile.postamble. -############################################################################### -# -# Before the main makefile is included for this project, you may set: -# -# MAKEFILEDIR: Directory in which to find $(MAKEFILE) -# MAKEFILE: Top level mechanism Makefile (e.g., app.make, bundle.make) - -# Compiler/linker flags added to the defaults: The OTHER_* variables will be -# inherited by all nested sub-projects, but the LOCAL_ versions of the same -# variables will not. Put your -I, -D, -U, and -L flags in ProjectBuilder's -# Build Attributes inspector if at all possible. To override the default flags -# that get passed to ${CC} (e.g. change -O to -O2), see Makefile.postamble. The -# variables below are *inputs* to the build process and distinct from the override -# settings done (less often) in the Makefile.postamble. -# -# OTHER_CFLAGS, LOCAL_CFLAGS: additional flags to pass to the compiler -# Note that $(OTHER_CFLAGS) and $(LOCAL_CFLAGS) are used for .h, ...c, .m, -# .cc, .cxx, .C, and .M files. There is no need to respecify the -# flags in OTHER_MFLAGS, etc. -# OTHER_MFLAGS, LOCAL_MFLAGS: additional flags for .m files -# OTHER_CCFLAGS, LOCAL_CCFLAGS: additional flags for .cc, .cxx, and ...C files -# OTHER_MMFLAGS, LOCAL_MMFLAGS: additional flags for .mm and .M files -# OTHER_PRECOMPFLAGS, LOCAL_PRECOMPFLAGS: additional flags used when -# precompiling header files -# OTHER_LDFLAGS, LOCAL_LDFLAGS: additional flags passed to ld and libtool -# OTHER_PSWFLAGS, LOCAL_PSWFLAGS: additional flags passed to pswrap -# OTHER_RPCFLAGS, LOCAL_RPCFLAGS: additional flags passed to rpcgen -# OTHER_YFLAGS, LOCAL_YFLAGS: additional flags passed to yacc -# OTHER_LFLAGS, LOCAL_LFLAGS: additional flags passed to lex - -# These variables provide hooks enabling you to add behavior at almost every -# stage of the make: -# -# BEFORE_PREBUILD: targets to build before installing headers for a subproject -# AFTER_PREBUILD: targets to build after installing headers for a subproject -# BEFORE_BUILD_RECURSION: targets to make before building subprojects -# BEFORE_BUILD: targets to make before a build, but after subprojects -# AFTER_BUILD: targets to make after a build -# -# BEFORE_INSTALL: targets to build before installing the product -# AFTER_INSTALL: targets to build after installing the product -# BEFORE_POSTINSTALL: targets to build before postinstalling every subproject -# AFTER_POSTINSTALL: targts to build after postinstalling every subproject -# -# BEFORE_INSTALLHDRS: targets to build before installing headers for a -# subproject -# AFTER_INSTALLHDRS: targets to build after installing headers for a subproject -# BEFORE_INSTALLSRC: targets to build before installing source for a subproject -# AFTER_INSTALLSRC: targets to build after installing source for a subproject -# -# BEFORE_DEPEND: targets to build before building dependencies for a -# subproject -# AFTER_DEPEND: targets to build after building dependencies for a -# subproject -# -# AUTOMATIC_DEPENDENCY_INFO: if YES, then the dependency file is -# updated every time the project is built. If NO, the dependency -# file is only built when the depend target is invoked. - -# Framework-related variables: -# FRAMEWORK_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the framework's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables - -# Library-related variables: -# PUBLIC_HEADER_DIR: Determines where public exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. For library projects you should -# set this to something like /Developer/Headers/$(NAME). Do not set -# this variable for framework projects unless you do not want the -# header files included in the framework. -# PRIVATE_HEADER_DIR: Determines where private exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. -# LIBRARY_STYLE: This may be either STATIC or DYNAMIC, and determines -# whether the libraries produced are statically linked when they -# are used or if they are dynamically loadable. This defaults to -# DYNAMIC. -# LIBRARY_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the library's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables -# -# INSTALL_AS_USER: owner of the intalled products (default root) -# INSTALL_AS_GROUP: group of the installed products (default wheel) -# INSTALL_PERMISSIONS: permissions of the installed product (default o+rX) -# -# OTHER_RECURSIVE_VARIABLES: The names of variables which you want to be -# passed on the command line to recursive invocations of make. Note that -# the values in OTHER_*FLAGS are inherited by subprojects automatically -- -# you do not have to (and shouldn't) add OTHER_*FLAGS to -# OTHER_RECURSIVE_VARIABLES. - -# Additional headers to export beyond those in the PB.project: -# OTHER_PUBLIC_HEADERS -# OTHER_PROJECT_HEADERS -# OTHER_PRIVATE_HEADERS - -# Additional files for the project's product: <> -# OTHER_RESOURCES: (non-localized) resources for this project -# OTHER_OFILES: relocatables to be linked into this project -# OTHER_LIBS: more libraries to link against -# OTHER_PRODUCT_DEPENDS: other dependencies of this project -# OTHER_SOURCEFILES: other source files maintained by .pre/postamble -# OTHER_GARBAGE: additional files to be removed by `make clean' - -# Set this to YES if you don't want a final libtool call for a library/framework. -# BUILD_OFILES_LIST_ONLY - -# To include a version string, project source must exist in a directory named -# $(NAME).%d[.%d][.%d] and the following line must be uncommented. -# OTHER_GENERATED_OFILES = $(VERS_OFILE) - -# This definition will suppress stripping of debug symbols when an executable -# is installed. By default it is YES. -# STRIP_ON_INSTALL = NO - -# Uncomment to suppress generation of a KeyValueCoding index when installing -# frameworks (This index is used by WOB and IB to determine keys available -# for an object). Set to YES by default. -# PREINDEX_FRAMEWORK = NO - -# Change this definition to install projects somewhere other than the -# standard locations. NEXT_ROOT defaults to "C:/Apple" on Windows systems -# and "" on other systems. -DSTROOT = $(HOME) diff --git a/db.subproj/recno.subproj/PB.project b/db.subproj/recno.subproj/PB.project deleted file mode 100644 index 3a7b202..0000000 --- a/db.subproj/recno.subproj/PB.project +++ /dev/null @@ -1,32 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - H_FILES = (extern.h, recno.h); - OTHER_LINKED = ( - rec_close.c, - rec_delete.c, - rec_get.c, - rec_open.c, - rec_put.c, - rec_search.c, - rec_seq.c, - rec_utils.c - ); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble); - SUBPROJECTS = (); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = recno; - PROJECTTYPE = Component; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/db/Makefile.inc b/db/Makefile.inc new file mode 100644 index 0000000..5806603 --- /dev/null +++ b/db/Makefile.inc @@ -0,0 +1,11 @@ +# from @(#)Makefile.inc 8.2 (Berkeley) 2/21/94 +# $FreeBSD: src/ldb/Makefile.inc,v 1.3 1999/08/27 23:58:15 peter Exp $ +# +CFLAGS+=-D__DBINTERFACE_PRIVATE + +.include "${.CURDIR}/db/btree/Makefile.inc" +.include "${.CURDIR}/db/db/Makefile.inc" +.include "${.CURDIR}/db/hash/Makefile.inc" +.include "${.CURDIR}/db/man/Makefile.inc" +.include "${.CURDIR}/db/mpool/Makefile.inc" +.include "${.CURDIR}/db/recno/Makefile.inc" diff --git a/db/btree/Makefile.inc b/db/btree/Makefile.inc new file mode 100644 index 0000000..9b80605 --- /dev/null +++ b/db/btree/Makefile.inc @@ -0,0 +1,8 @@ +# from @(#)Makefile.inc 8.2 (Berkeley) 7/14/94 +# $FreeBSD: src/lib/libc/db/btree/Makefile.inc,v 1.3 1999/08/27 23:58:16 peter Exp $ + +.PATH: ${.CURDIR}/db/btree + +SRCS+= bt_close.c bt_conv.c bt_debug.c bt_delete.c bt_get.c bt_open.c \ + bt_overflow.c bt_page.c bt_put.c bt_search.c bt_seq.c bt_split.c \ + bt_utils.c bt_stack.c diff --git a/db.subproj/btree.subproj/PB.project b/db/btree/PB.project similarity index 100% rename from db.subproj/btree.subproj/PB.project rename to db/btree/PB.project diff --git a/db.subproj/btree.subproj/bt_close.c b/db/btree/bt_close.c similarity index 100% rename from db.subproj/btree.subproj/bt_close.c rename to db/btree/bt_close.c diff --git a/db.subproj/btree.subproj/bt_conv.c b/db/btree/bt_conv.c similarity index 100% rename from db.subproj/btree.subproj/bt_conv.c rename to db/btree/bt_conv.c diff --git a/db.subproj/btree.subproj/bt_debug.c b/db/btree/bt_debug.c similarity index 100% rename from db.subproj/btree.subproj/bt_debug.c rename to db/btree/bt_debug.c diff --git a/db.subproj/btree.subproj/bt_delete.c b/db/btree/bt_delete.c similarity index 100% rename from db.subproj/btree.subproj/bt_delete.c rename to db/btree/bt_delete.c diff --git a/db.subproj/btree.subproj/bt_extern.h b/db/btree/bt_extern.h similarity index 100% rename from db.subproj/btree.subproj/bt_extern.h rename to db/btree/bt_extern.h diff --git a/db.subproj/btree.subproj/bt_get.c b/db/btree/bt_get.c similarity index 100% rename from db.subproj/btree.subproj/bt_get.c rename to db/btree/bt_get.c diff --git a/db.subproj/btree.subproj/bt_open.c b/db/btree/bt_open.c similarity index 100% rename from db.subproj/btree.subproj/bt_open.c rename to db/btree/bt_open.c diff --git a/db.subproj/btree.subproj/bt_overflow.c b/db/btree/bt_overflow.c similarity index 100% rename from db.subproj/btree.subproj/bt_overflow.c rename to db/btree/bt_overflow.c diff --git a/db.subproj/btree.subproj/bt_page.c b/db/btree/bt_page.c similarity index 100% rename from db.subproj/btree.subproj/bt_page.c rename to db/btree/bt_page.c diff --git a/db.subproj/btree.subproj/bt_put.c b/db/btree/bt_put.c similarity index 100% rename from db.subproj/btree.subproj/bt_put.c rename to db/btree/bt_put.c diff --git a/db.subproj/btree.subproj/bt_search.c b/db/btree/bt_search.c similarity index 100% rename from db.subproj/btree.subproj/bt_search.c rename to db/btree/bt_search.c diff --git a/db.subproj/btree.subproj/bt_seq.c b/db/btree/bt_seq.c similarity index 100% rename from db.subproj/btree.subproj/bt_seq.c rename to db/btree/bt_seq.c diff --git a/db.subproj/btree.subproj/bt_split.c b/db/btree/bt_split.c similarity index 100% rename from db.subproj/btree.subproj/bt_split.c rename to db/btree/bt_split.c diff --git a/db.subproj/btree.subproj/bt_stack.c b/db/btree/bt_stack.c similarity index 100% rename from db.subproj/btree.subproj/bt_stack.c rename to db/btree/bt_stack.c diff --git a/db.subproj/btree.subproj/bt_utils.c b/db/btree/bt_utils.c similarity index 100% rename from db.subproj/btree.subproj/bt_utils.c rename to db/btree/bt_utils.c diff --git a/db.subproj/btree.subproj/btree.h b/db/btree/btree.h similarity index 100% rename from db.subproj/btree.subproj/btree.h rename to db/btree/btree.h diff --git a/db/db/Makefile.inc b/db/db/Makefile.inc new file mode 100644 index 0000000..67c4fef --- /dev/null +++ b/db/db/Makefile.inc @@ -0,0 +1,6 @@ +# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 +# $FreeBSD: src/lib/libc/db/db/Makefile.inc,v 1.3 1999/08/27 23:58:17 peter Exp $ + +.PATH: ${.CURDIR}/db/db + +SRCS+= db.c diff --git a/db.subproj/db.subproj/db.c b/db/db/db.c similarity index 100% rename from db.subproj/db.subproj/db.c rename to db/db/db.c diff --git a/db/hash/Makefile.inc b/db/hash/Makefile.inc new file mode 100644 index 0000000..b5874e8 --- /dev/null +++ b/db/hash/Makefile.inc @@ -0,0 +1,7 @@ +# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 +# $FreeBSD: src/lib/libc/db/hash/Makefile.inc,v 1.4 2001/05/15 07:08:17 ru Exp $ + +.PATH: ${.CURDIR}/db/hash + +SRCS+= hash.c hash_bigkey.c hash_buf.c hash_func.c hash_log2.c \ + hash_page.c ndbm.c hsearch.c diff --git a/db.subproj/hash.subproj/extern.h b/db/hash/extern.h similarity index 100% rename from db.subproj/hash.subproj/extern.h rename to db/hash/extern.h diff --git a/db.subproj/hash.subproj/hash.c b/db/hash/hash.c similarity index 100% rename from db.subproj/hash.subproj/hash.c rename to db/hash/hash.c diff --git a/db.subproj/hash.subproj/hash.h b/db/hash/hash.h similarity index 100% rename from db.subproj/hash.subproj/hash.h rename to db/hash/hash.h diff --git a/db.subproj/hash.subproj/hash_bigkey.c b/db/hash/hash_bigkey.c similarity index 100% rename from db.subproj/hash.subproj/hash_bigkey.c rename to db/hash/hash_bigkey.c diff --git a/db.subproj/hash.subproj/hash_buf.c b/db/hash/hash_buf.c similarity index 100% rename from db.subproj/hash.subproj/hash_buf.c rename to db/hash/hash_buf.c diff --git a/db.subproj/hash.subproj/hash_func.c b/db/hash/hash_func.c similarity index 100% rename from db.subproj/hash.subproj/hash_func.c rename to db/hash/hash_func.c diff --git a/db.subproj/hash.subproj/hash_log2.c b/db/hash/hash_log2.c similarity index 100% rename from db.subproj/hash.subproj/hash_log2.c rename to db/hash/hash_log2.c diff --git a/db.subproj/hash.subproj/hash_page.c b/db/hash/hash_page.c similarity index 100% rename from db.subproj/hash.subproj/hash_page.c rename to db/hash/hash_page.c diff --git a/db.subproj/hash.subproj/hsearch.c b/db/hash/hsearch.c similarity index 100% rename from db.subproj/hash.subproj/hsearch.c rename to db/hash/hsearch.c diff --git a/db.subproj/hash.subproj/ndbm.c b/db/hash/ndbm.c similarity index 100% rename from db.subproj/hash.subproj/ndbm.c rename to db/hash/ndbm.c diff --git a/db.subproj/hash.subproj/page.h b/db/hash/page.h similarity index 100% rename from db.subproj/hash.subproj/page.h rename to db/hash/page.h diff --git a/db.subproj/hash.subproj/search.h b/db/hash/search.h similarity index 100% rename from db.subproj/hash.subproj/search.h rename to db/hash/search.h diff --git a/db/man/Makefile.inc b/db/man/Makefile.inc new file mode 100644 index 0000000..3ee0369 --- /dev/null +++ b/db/man/Makefile.inc @@ -0,0 +1,20 @@ +# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 +# $FreeBSD: src/lib/libc/db/man/Makefile.inc,v 1.10 2001/03/27 17:26:46 ru Exp $ + +.PATH: ${.CURDIR}/db/man + +.if ${LIB} == "c" +MAN3+= btree.3 dbm.3 dbopen.3 hash.3 mpool.3 recno.3 + +MLINKS+= dbm.3 dbm_clearerr.3 +MLINKS+= dbm.3 dbm_close.3 +MLINKS+= dbm.3 dbm_delete.3 +MLINKS+= dbm.3 dbm_dirnfo.3 +MLINKS+= dbm.3 dbm_error.3 +MLINKS+= dbm.3 dbm_fetch.3 +MLINKS+= dbm.3 dbm_firstkey.3 +MLINKS+= dbm.3 dbm_nextkey.3 +MLINKS+= dbm.3 dbm_open.3 +MLINKS+= dbm.3 dbm_store.3 +MLINKS+= dbopen.3 db.3 +.endif diff --git a/db/man/btree.3 b/db/man/btree.3 new file mode 100644 index 0000000..b8cee89 --- /dev/null +++ b/db/man/btree.3 @@ -0,0 +1,272 @@ +.\" Copyright (c) 1990, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)btree.3 8.4 (Berkeley) 8/18/94 +.\" $FreeBSD: src/lib/libc/db/man/btree.3,v 1.5 2001/10/01 16:08:50 ru Exp $ +.\" +.Dd August 18, 1994 +.Dt BTREE 3 +.Os +.Sh NAME +.Nm btree +.Nd "btree database access method" +.Sh SYNOPSIS +.In sys/types.h +.In db.h +.Sh DESCRIPTION +The routine +.Fn dbopen +is the library interface to database files. +One of the supported file formats is +.Nm +files. +The general description of the database access methods is in +.Xr dbopen 3 , +this manual page describes only the +.Nm +specific information. +.Pp +The +.Nm +data structure is a sorted, balanced tree structure storing +associated key/data pairs. +.Pp +The +.Nm +access method specific data structure provided to +.Fn dbopen +is defined in the +.Aq Pa db.h +include file as follows: +.Bd -literal +typedef struct { + u_long flags; + u_int cachesize; + int maxkeypage; + int minkeypage; + u_int psize; + int (*compare)(const DBT *key1, const DBT *key2); + size_t (*prefix)(const DBT *key1, const DBT *key2); + int lorder; +} BTREEINFO; +.Ed +.Pp +The elements of this structure are as follows: +.Bl -tag -width indent +.It Va flags +The flag value is specified by +.Em or Ns 'ing +any of the following values: +.Bl -tag -width indent +.It Dv R_DUP +Permit duplicate keys in the tree, i.e. permit insertion if the key to be +inserted already exists in the tree. +The default behavior, as described in +.Xr dbopen 3 , +is to overwrite a matching key when inserting a new key or to fail if +the +.Dv R_NOOVERWRITE +flag is specified. +The +.Dv R_DUP +flag is overridden by the +.Dv R_NOOVERWRITE +flag, and if the +.Dv R_NOOVERWRITE +flag is specified, attempts to insert duplicate keys into +the tree will fail. +.Pp +If the database contains duplicate keys, the order of retrieval of +key/data pairs is undefined if the +.Va get +routine is used, however, +.Va seq +routine calls with the +.Dv R_CURSOR +flag set will always return the logical +.Dq first +of any group of duplicate keys. +.El +.It Va cachesize +A suggested maximum size (in bytes) of the memory cache. +This value is +.Em only +advisory, and the access method will allocate more memory rather than fail. +Since every search examines the root page of the tree, caching the most +recently used pages substantially improves access time. +In addition, physical writes are delayed as long as possible, so a moderate +cache can reduce the number of I/O operations significantly. +Obviously, using a cache increases (but only increases) the likelihood of +corruption or lost data if the system crashes while a tree is being modified. +If +.Va cachesize +is 0 (no size is specified) a default cache is used. +.It Va maxkeypage +The maximum number of keys which will be stored on any single page. +Not currently implemented. +.\" The maximum number of keys which will be stored on any single page. +.\" Because of the way the +.\" .Nm +.\" data structure works, +.\" .Va maxkeypage +.\" must always be greater than or equal to 2. +.\" If +.\" .Va maxkeypage +.\" is 0 (no maximum number of keys is specified) the page fill factor is +.\" made as large as possible (which is almost invariably what is wanted). +.It Va minkeypage +The minimum number of keys which will be stored on any single page. +This value is used to determine which keys will be stored on overflow +pages, i.e. if a key or data item is longer than the pagesize divided +by the minkeypage value, it will be stored on overflow pages instead +of in the page itself. +If +.Va minkeypage +is 0 (no minimum number of keys is specified) a value of 2 is used. +.It Va psize +Page size is the size (in bytes) of the pages used for nodes in the tree. +The minimum page size is 512 bytes and the maximum page size is 64K. +If +.Va psize +is 0 (no page size is specified) a page size is chosen based on the +underlying file system I/O block size. +.It Va compare +Compare is the key comparison function. +It must return an integer less than, equal to, or greater than zero if the +first key argument is considered to be respectively less than, equal to, +or greater than the second key argument. +The same comparison function must be used on a given tree every time it +is opened. +If +.Va compare +is +.Dv NULL +(no comparison function is specified), the keys are compared +lexically, with shorter keys considered less than longer keys. +.It Va prefix +.Va Prefix +is the prefix comparison function. +If specified, this routine must return the number of bytes of the second key +argument which are necessary to determine that it is greater than the first +key argument. +If the keys are equal, the key length should be returned. +Note, the usefulness of this routine is very data dependent, but, in some +data sets can produce significantly reduced tree sizes and search times. +If +.Va prefix +is +.Dv NULL +(no prefix function is specified), +.Em and +no comparison function is specified, a default lexical comparison routine +is used. +If +.Va prefix +is +.Dv NULL +and a comparison routine is specified, no prefix comparison is +done. +.It Va lorder +The byte order for integers in the stored database metadata. +The number should represent the order as an integer; for example, +big endian order would be the number 4,321. +If +.Va lorder +is 0 (no order is specified) the current host order is used. +.El +.Pp +If the file already exists (and the +.Dv O_TRUNC +flag is not specified), the +values specified for the parameters +.Va flags , lorder +and +.Va psize +are ignored +in favor of the values used when the tree was created. +.Pp +Forward sequential scans of a tree are from the least key to the greatest. +.Pp +Space freed up by deleting key/data pairs from the tree is never reclaimed, +although it is normally made available for reuse. +This means that the +.Nm +storage structure is grow-only. +The only solutions are to avoid excessive deletions, or to create a fresh +tree periodically from a scan of an existing one. +.Pp +Searches, insertions, and deletions in a +.Nm +will all complete in +O lg base N where base is the average fill factor. +Often, inserting ordered data into +.Nm Ns s +results in a low fill factor. +This implementation has been modified to make ordered insertion the best +case, resulting in a much better than normal page fill factor. +.Sh ERRORS +The +.Nm +access method routines may fail and set +.Va errno +for any of the errors specified for the library routine +.Xr dbopen 3 . +.Sh SEE ALSO +.Xr dbopen 3 , +.Xr hash 3 , +.Xr mpool 3 , +.Xr recno 3 +.Rs +.%T "The Ubiquitous B-tree" +.%A Douglas Comer +.%J "ACM Comput. Surv. 11" +.%N 2 +.%D June 1979 +.%P 121-138 +.Re +.Rs +.%A Bayer +.%A Unterauer +.%T "Prefix B-trees" +.%J "ACM Transactions on Database Systems" +.%N 1 +.%V Vol. 2 +.%D March 1977 +.%P 11-26 +.Re +.Rs +.%B "The Art of Computer Programming Vol. 3: Sorting and Searching" +.%A D. E. Knuth +.%D 1968 +.%P 471-480 +.Re +.Sh BUGS +Only big and little endian byte order is supported. diff --git a/db/man/dbm.3 b/db/man/dbm.3 new file mode 100644 index 0000000..55b076b --- /dev/null +++ b/db/man/dbm.3 @@ -0,0 +1,196 @@ +.\" Copyright (c) 1999 Tim Singletary +.\" No copyright is claimed. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. +.\" +.\" $FreeBSD: src/lib/libc/db/man/dbm.3,v 1.5 2001/10/01 16:08:50 ru Exp $ +.\" +.\" Note: The date here should be updated whenever a non-trivial +.\" change is made to the manual page. +.Dd July 7, 1999 +.Dt DBM 3 +.Os +.Sh NAME +.Nm dbm_clearerr , +.Nm dbm_close , +.Nm dbm_delete , +.Nm dbm_dirfno , +.Nm dbm_error , +.Nm dbm_fetch , +.Nm dbm_firstkey , +.Nm dbm_nextkey , +.Nm dbm_open , +.Nm dbm_store +.Nd database access functions +.Sh SYNOPSIS +.In fcntl.h +.In ndbm.h +.Ft DBM * +.Fn dbm_open "const char *base" "int flags" "int mode" +.Ft void +.Fn dbm_close "DBM *db" +.Ft int +.Fn dbm_store "DBM *db" "datum key" "datum data" "int flags" +.Ft datum +.Fn dbm_fetch "DBM *db" "datum key" +.Ft int +.Fn dbm_delete "DBM *db" "datum key" +.Ft datum +.Fn dbm_firstkey "DBM *db" +.Ft datum +.Fn dbm_nextkey "DBM *db" +.Ft int +.Fn dbm_error "DBM *db" +.Ft int +.Fn dbm_clearerr "DBM *db" +.Ft int +.Fn dbm_dirfno "DBM *db" +.Sh DESCRIPTION +Database access functions. +These functions are implemented using +.Xr dbopen 3 +with a +.Xr hash 3 +database. +.Pp +.Vt datum +is declared in +.Aq Pa ndbm.h : +.Bd -literal +typedef struct { + char *dptr; + int dsize; +} datum; +.Ed +.Pp +.Fn dbm_open base flags mode +opens or creates a database. +.Fa base +is the basename of the file containing +the database; the actual database has a +.Pa .db +suffix. +I.e., if +.Fa base +is +.Qq Li /home/me/mystuff +then the actual database is in the file +.Pa /home/me/mystuff.db . +.Fa flags +and +.Fa mode +are passed to +.Xr open 2 . +.Pq Dv O_RDWR | O_CREAT +is a typical value for +.Fa flags ; +.Li 0660 +is a typical value for +.Fa mode . +.Dv O_WRONLY +is not allowed in +.Fa flags . +The pointer returned by +.Fn dbm_open +identifies the database and is the +.Fa db +argument to the other functions. +.Fn dbm_open +returns +.Dv NULL +and sets +.Va errno +if there were any errors. +.Pp +.Fn dbm_close db +closes the database. +.Fn dbm_close +normally returns zero. +.Pp +.Fn dbm_store db key data flags +inserts or replaces an entry in the database. +.Fa flags +is either +.Dv DBM_INSERT +or +.Dv DBM_REPLACE . +If +.Fa flags +is +.Dv DBM_INSERT +and the database already contains an entry for +.Fa key , +that entry is not replaced. +Otherwise the entry is replaced or inserted. +.Fn dbm_store +normally returns zero but returns 1 if the entry could not be +inserted (because +.Fa flags +is +.Dv DBM_INSERT , +and an entry with +.Fa key +already exists) or returns -1 and sets +.Va errno +if there were any errors. +.Pp +.Fn dbm_fetch db key +returns +.Dv NULL +or the +.Fa data +corresponding to +.Fa key . +.Pp +.Fn dbm_delete db key +deletes the entry for +.Fa key . +.Fn dbm_delete +normally returns zero but returns 1 if there was no entry with +.Fa key +in the database or returns -1 and sets +.Va errno +if there were any errors. +.Pp +.Fn dbm_firstkey db +returns the first key in the database. +.Fn dbm_nextkey db +returns subsequent keys. +.Fn db_firstkey +must be called before +.Fn dbm_nextkey . +The order in which keys are returned is unspecified and may appear +random. +.Fn dbm_nextkey +returns +.Dv NULL +after all keys have been returned. +.Pp +.Fn dbm_error db +returns the +.Va errno +value of the most recent error. +.Fn dbm_clearerr db +resets this value to 0 and returns 0. +.Pp +.Fn dbm_dirfno db +returns the file descriptor to the database. +.Sh SEE ALSO +.Xr open 2 , +.Xr dbopen 3 , +.Xr hash 3 +.Sh STANDARDS +These functions (except +.Fn dbm_dirfno ) +are included in the +.St -susv2 . diff --git a/db/man/dbopen.3 b/db/man/dbopen.3 new file mode 100644 index 0000000..f04c771 --- /dev/null +++ b/db/man/dbopen.3 @@ -0,0 +1,539 @@ +.\" Copyright (c) 1990, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)dbopen.3 8.5 (Berkeley) 1/2/94 +.\" $FreeBSD: src/lib/libc/db/man/dbopen.3,v 1.5 2001/10/01 16:08:50 ru Exp $ +.\" +.Dd January 2, 1994 +.Dt DBOPEN 3 +.Os +.Sh NAME +.Nm dbopen +.Nd "database access methods" +.Sh SYNOPSIS +.In sys/types.h +.In limits.h +.In db.h +.Ft DB * +.Fn dbopen "const char *file" "int flags" "int mode" "DBTYPE type" "const void *openinfo" +.Sh DESCRIPTION +.Fn Dbopen +is the library interface to database files. +The supported file formats are btree, hashed and UNIX file oriented. +The btree format is a representation of a sorted, balanced tree structure. +The hashed format is an extensible, dynamic hashing scheme. +The flat-file format is a byte stream file with fixed or variable length +records. +The formats and file format specific information are described in detail +in their respective manual pages +.Xr btree 3 , +.Xr hash 3 +and +.Xr recno 3 . +.Pp +.Fn Dbopen +opens +.Fa file +for reading and/or writing. +Files never intended to be preserved on disk may be created by setting +the file parameter to +.Dv NULL . +.Pp +The +.Fa flags +and +.Fa mode +arguments +are as specified to the +.Xr open 2 +routine, however, only the +.Dv O_CREAT , O_EXCL , O_EXLOCK , O_NONBLOCK , +.Dv O_RDONLY , O_RDWR , O_SHLOCK +and +.Dv O_TRUNC +flags are meaningful. +(Note, opening a database file +.Dv O_WRONLY +is not possible.) +.\"Three additional options may be specified by +.\".Em or Ns 'ing +.\"them into the +.\".Fa flags +.\"argument. +.\".Bl -tag -width indent +.\".It Dv DB_LOCK +.\"Do the necessary locking in the database to support concurrent access. +.\"If concurrent access isn't needed or the database is read-only this +.\"flag should not be set, as it tends to have an associated performance +.\"penalty. +.\".It Dv DB_SHMEM +.\"Place the underlying memory pool used by the database in shared +.\"memory. +.\"Necessary for concurrent access. +.\".It Dv DB_TXN +.\"Support transactions in the database. +.\"The +.\".Dv DB_LOCK +.\"and +.\".Dv DB_SHMEM +.\"flags must be set as well. +.\".El +.Pp +The +.Fa type +argument is of type +.Ft DBTYPE +(as defined in the +.Aq Pa db.h +include file) and +may be set to +.Dv DB_BTREE , DB_HASH +or +.Dv DB_RECNO . +.Pp +The +.Fa openinfo +argument is a pointer to an access method specific structure described +in the access method's manual page. +If +.Fa openinfo +is +.Dv NULL , +each access method will use defaults appropriate for the system +and the access method. +.Pp +.Fn Dbopen +returns a pointer to a +.Ft DB +structure on success and +.Dv NULL +on error. +The +.Ft DB +structure is defined in the +.Aq Pa db.h +include file, and contains at +least the following fields: +.Bd -literal +typedef struct { + DBTYPE type; + int (*close)(const DB *db); + int (*del)(const DB *db, const DBT *key, u_int flags); + int (*fd)(const DB *db); + int (*get)(const DB *db, DBT *key, DBT *data, u_int flags); + int (*put)(const DB *db, DBT *key, const DBT *data, + u_int flags); + int (*sync)(const DB *db, u_int flags); + int (*seq)(const DB *db, DBT *key, DBT *data, u_int flags); +} DB; +.Ed +.Pp +These elements describe a database type and a set of functions performing +various actions. +These functions take a pointer to a structure as returned by +.Fn dbopen , +and sometimes one or more pointers to key/data structures and a flag value. +.Bl -tag -width indent +.It Va type +The type of the underlying access method (and file format). +.It Va close +A pointer to a routine to flush any cached information to disk, free any +allocated resources, and close the underlying file(s). +Since key/data pairs may be cached in memory, failing to sync the file +with a +.Va close +or +.Va sync +function may result in inconsistent or lost information. +.Va Close +routines return -1 on error (setting +.Va errno ) +and 0 on success. +.It Va del +A pointer to a routine to remove key/data pairs from the database. +.Pp +The parameter +.Fa flags +may be set to the following value: +.Bl -tag -width indent +.It Dv R_CURSOR +Delete the record referenced by the cursor. +The cursor must have previously been initialized. +.El +.Pp +.Va Delete +routines return -1 on error (setting +.Va errno ) , +0 on success, and 1 if the specified +.Fa key +was not in the file. +.It Va fd +A pointer to a routine which returns a file descriptor representative +of the underlying database. +A file descriptor referencing the same file will be returned to all +processes which call +.Fn dbopen +with the same +.Fa file +name. +This file descriptor may be safely used as an argument to the +.Xr fcntl 2 +and +.Xr flock 2 +locking functions. +The file descriptor is not necessarily associated with any of the +underlying files used by the access method. +No file descriptor is available for in memory databases. +.Va \&Fd +routines return -1 on error (setting +.Va errno ) , +and the file descriptor on success. +.It Va get +A pointer to a routine which is the interface for keyed retrieval from +the database. +The address and length of the data associated with the specified +.Fa key +are returned in the structure referenced by +.Fa data . +.Va Get +routines return -1 on error (setting +.Va errno ) , +0 on success, and 1 if the +.Fa key +was not in the file. +.It Va put +A pointer to a routine to store key/data pairs in the database. +.Pp +The parameter +.Fa flags +may be set to one of the following values: +.Bl -tag -width indent +.It Dv R_CURSOR +Replace the key/data pair referenced by the cursor. +The cursor must have previously been initialized. +.It Dv R_IAFTER +Append the data immediately after the data referenced by +.Fa key , +creating a new key/data pair. +The record number of the appended key/data pair is returned in the +.Fa key +structure. +(Applicable only to the +.Dv DB_RECNO +access method.) +.It Dv R_IBEFORE +Insert the data immediately before the data referenced by +.Fa key , +creating a new key/data pair. +The record number of the inserted key/data pair is returned in the +.Fa key +structure. +(Applicable only to the +.Dv DB_RECNO +access method.) +.It Dv R_NOOVERWRITE +Enter the new key/data pair only if the key does not previously exist. +.It Dv R_SETCURSOR +Store the key/data pair, setting or initializing the position of the +cursor to reference it. +(Applicable only to the +.Dv DB_BTREE +and +.Dv DB_RECNO +access methods.) +.El +.Pp +.Dv R_SETCURSOR +is available only for the +.Dv DB_BTREE +and +.Dv DB_RECNO +access +methods because it implies that the keys have an inherent order +which does not change. +.Pp +.Dv R_IAFTER +and +.Dv R_IBEFORE +are available only for the +.Dv DB_RECNO +access method because they each imply that the access method is able to +create new keys. +This is only true if the keys are ordered and independent, record numbers +for example. +.Pp +The default behavior of the +.Va put +routines is to enter the new key/data pair, replacing any previously +existing key. +.Pp +.Va Put +routines return -1 on error (setting +.Va errno ) , +0 on success, and 1 if the +.Dv R_NOOVERWRITE +flag +was set and the key already exists in the file. +.It Va seq +A pointer to a routine which is the interface for sequential +retrieval from the database. +The address and length of the key are returned in the structure +referenced by +.Fa key , +and the address and length of the data are returned in the +structure referenced +by +.Fa data . +.Pp +Sequential key/data pair retrieval may begin at any time, and the +position of the +.Dq cursor +is not affected by calls to the +.Va del , +.Va get , +.Va put , +or +.Va sync +routines. +Modifications to the database during a sequential scan will be reflected +in the scan, i.e. records inserted behind the cursor will not be returned +while records inserted in front of the cursor will be returned. +.Pp +The +.Fa flags +value +.Em must +be set to one of the following values: +.Bl -tag -width indent +.It Dv R_CURSOR +The data associated with the specified key is returned. +This differs from the +.Va get +routines in that it sets or initializes the cursor to the location of +the key as well. +(Note, for the +.Dv DB_BTREE +access method, the returned key is not necessarily an +exact match for the specified key. +The returned key is the smallest key greater than or equal to the specified +key, permitting partial key matches and range searches.) +.It Dv R_FIRST +The first key/data pair of the database is returned, and the cursor +is set or initialized to reference it. +.It Dv R_LAST +The last key/data pair of the database is returned, and the cursor +is set or initialized to reference it. +(Applicable only to the +.Dv DB_BTREE +and +.Dv DB_RECNO +access methods.) +.It Dv R_NEXT +Retrieve the key/data pair immediately after the cursor. +If the cursor is not yet set, this is the same as the +.Dv R_FIRST +flag. +.It Dv R_PREV +Retrieve the key/data pair immediately before the cursor. +If the cursor is not yet set, this is the same as the +.Dv R_LAST +flag. +(Applicable only to the +.Dv DB_BTREE +and +.Dv DB_RECNO +access methods.) +.El +.Pp +.Dv R_LAST +and +.Dv R_PREV +are available only for the +.Dv DB_BTREE +and +.Dv DB_RECNO +access methods because they each imply that the keys have an inherent +order which does not change. +.Pp +.Va Seq +routines return -1 on error (setting +.Va errno ) , +0 on success and 1 if there are no key/data pairs less than or greater +than the specified or current key. +If the +.Dv DB_RECNO +access method is being used, and if the database file +is a character special file and no complete key/data pairs are currently +available, the +.Va seq +routines return 2. +.It Va sync +A pointer to a routine to flush any cached information to disk. +If the database is in memory only, the +.Va sync +routine has no effect and will always succeed. +.Pp +The +.Fa flags +value may be set to the following value: +.Bl -tag -width indent +.It Dv R_RECNOSYNC +If the +.Dv DB_RECNO +access method is being used, this flag causes +the +.Va sync +routine to apply to the btree file which underlies the +recno file, not the recno file itself. +(See the +.Va bfname +field of the +.Xr recno 3 +manual page for more information.) +.El +.Pp +.Va Sync +routines return -1 on error (setting +.Va errno ) +and 0 on success. +.El +.Sh "KEY/DATA PAIRS" +Access to all file types is based on key/data pairs. +Both keys and data are represented by the following data structure: +.Bd -literal +typedef struct { + void *data; + size_t size; +} DBT; +.Ed +.Pp +The elements of the +.Ft DBT +structure are defined as follows: +.Bl -tag -width "data" +.It Va data +A pointer to a byte string. +.It Va size +The length of the byte string. +.El +.Pp +Key and data byte strings may reference strings of essentially unlimited +length although any two of them must fit into available memory at the same +time. +It should be noted that the access methods provide no guarantees about +byte string alignment. +.Sh ERRORS +The +.Fn dbopen +routine may fail and set +.Va errno +for any of the errors specified for the library routines +.Xr open 2 +and +.Xr malloc 3 +or the following: +.Bl -tag -width Er +.It Bq Er EFTYPE +A file is incorrectly formatted. +.It Bq Er EINVAL +A parameter has been specified (hash function, pad byte etc.) that is +incompatible with the current file specification or which is not +meaningful for the function (for example, use of the cursor without +prior initialization) or there is a mismatch between the version +number of file and the software. +.El +.Pp +The +.Va close +routines may fail and set +.Va errno +for any of the errors specified for the library routines +.Xr close 2 , +.Xr read 2 , +.Xr write 2 , +.Xr free 3 , +or +.Xr fsync 2 . +.Pp +The +.Va del , +.Va get , +.Va put +and +.Va seq +routines may fail and set +.Va errno +for any of the errors specified for the library routines +.Xr read 2 , +.Xr write 2 , +.Xr free 3 +or +.Xr malloc 3 . +.Pp +The +.Va fd +routines will fail and set +.Va errno +to +.Er ENOENT +for in memory databases. +.Pp +The +.Va sync +routines may fail and set +.Va errno +for any of the errors specified for the library routine +.Xr fsync 2 . +.Sh SEE ALSO +.Xr btree 3 , +.Xr hash 3 , +.Xr mpool 3 , +.Xr recno 3 +.Rs +.%T "LIBTP: Portable, Modular Transactions for UNIX" +.%A Margo Seltzer +.%A Michael Olson +.%R "USENIX proceedings" +.%D Winter 1992 +.Re +.Sh BUGS +The typedef +.Ft DBT +is a mnemonic for +.Dq "data base thang" , +and was used +because noone could think of a reasonable name that wasn't already used. +.Pp +The file descriptor interface is a kluge and will be deleted in a +future version of the interface. +.Pp +None of the access methods provide any form of concurrent access, +locking, or transactions. diff --git a/db/man/hash.3 b/db/man/hash.3 new file mode 100644 index 0000000..f51bb06 --- /dev/null +++ b/db/man/hash.3 @@ -0,0 +1,191 @@ +.\" Copyright (c) 1990, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)hash.3 8.6 (Berkeley) 8/18/94 +.\" $FreeBSD: src/lib/libc/db/man/hash.3,v 1.6 2001/10/01 16:08:50 ru Exp $ +.\" +.Dd August 18, 1994 +.Dt HASH 3 +.Os +.Sh NAME +.Nm hash +.Nd "hash database access method" +.Sh SYNOPSIS +.In sys/types.h +.In db.h +.Sh DESCRIPTION +The routine +.Fn dbopen +is the library interface to database files. +One of the supported file formats is +.Nm +files. +The general description of the database access methods is in +.Xr dbopen 3 , +this manual page describes only the +.Nm +specific information. +.Pp +The +.Nm +data structure is an extensible, dynamic hashing scheme. +.Pp +The access method specific data structure provided to +.Fn dbopen +is defined in the +.Aq Pa db.h +include file as follows: +.Bd -literal +typedef struct { + u_int bsize; + u_int ffactor; + u_int nelem; + u_int cachesize; + u_int32_t (*hash)(const void *, size_t); + int lorder; +} HASHINFO; +.Ed +.Pp +The elements of this structure are as follows: +.Bl -tag -width indent +.It Va bsize +.Va Bsize +defines the +.Nm +table bucket size, and is, by default, 256 bytes. +It may be preferable to increase the page size for disk-resident tables +and tables with large data items. +.It Va ffactor +.Va Ffactor +indicates a desired density within the +.Nm +table. +It is an approximation of the number of keys allowed to accumulate in any +one bucket, determining when the +.Nm +table grows or shrinks. +The default value is 8. +.It Va nelem +.Va Nelem +is an estimate of the final size of the +.Nm +table. +If not set or set too low, +.Nm +tables will expand gracefully as keys +are entered, although a slight performance degradation may be noticed. +The default value is 1. +.It Va cachesize +A suggested maximum size, in bytes, of the memory cache. +This value is +.Em only +advisory, and the access method will allocate more memory rather +than fail. +.It Va hash +.Va Hash +is a user defined +.Nm +function. +Since no +.Nm +function performs equally well on all possible data, the +user may find that the built-in +.Nm +function does poorly on a particular +data set. +User specified +.Nm +functions must take two arguments (a pointer to a byte +string and a length) and return a 32-bit quantity to be used as the +.Nm +value. +.It Va lorder +The byte order for integers in the stored database metadata. +The number should represent the order as an integer; for example, +big endian order would be the number 4,321. +If +.Va lorder +is 0 (no order is specified) the current host order is used. +If the file already exists, the specified value is ignored and the +value specified when the tree was created is used. +.El +.Pp +If the file already exists (and the +.Dv O_TRUNC +flag is not specified), the +values specified for the parameters +.Va bsize , ffactor , lorder +and +.Va nelem +are +ignored and the values specified when the tree was created are used. +.Pp +If a +.Nm +function is specified, +.Fn hash_open +will attempt to determine if the +.Nm +function specified is the same as +the one with which the database was created, and will fail if it is not. +.Pp +Backward compatible interfaces to the older +.Em dbm +and +.Em ndbm +routines are provided, however these interfaces are not compatible with +previous file formats. +.Sh ERRORS +The +.Nm +access method routines may fail and set +.Va errno +for any of the errors specified for the library routine +.Xr dbopen 3 . +.Sh SEE ALSO +.Xr btree 3 , +.Xr dbopen 3 , +.Xr mpool 3 , +.Xr recno 3 +.Rs +.%T "Dynamic Hash Tables" +.%A Per-Ake Larson +.%R "Communications of the ACM" +.%D April 1988 +.Re +.Rs +.%T "A New Hash Package for UNIX" +.%A Margo Seltzer +.%R "USENIX Proceedings" +.%D Winter 1991 +.Re +.Sh BUGS +Only big and little endian byte order is supported. diff --git a/db/man/mpool.3 b/db/man/mpool.3 new file mode 100644 index 0000000..36c91e1 --- /dev/null +++ b/db/man/mpool.3 @@ -0,0 +1,238 @@ +.\" Copyright (c) 1990, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)mpool.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/db/man/mpool.3,v 1.9 2001/10/01 16:08:50 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt MPOOL 3 +.Os +.Sh NAME +.Nm mpool +.Nd "shared memory buffer pool" +.Sh SYNOPSIS +.In db.h +.In mpool.h +.Ft MPOOL * +.Fn mpool_open "void *key" "int fd" "pgno_t pagesize" "pgno_t maxcache" +.Ft void +.Fo mpool_filter +.Fa "MPOOL *mp" +.Fa "void (*pgin)(void *, pgno_t, void *)" +.Fa "void (*pgout)(void *, pgno_t, void *)" +.Fa "void *pgcookie" +.Fc +.Ft void * +.Fn mpool_new "MPOOL *mp" "pgno_t *pgnoaddr" +.Ft void * +.Fn mpool_get "MPOOL *mp" "pgno_t pgno" "u_int flags" +.Ft int +.Fn mpool_put "MPOOL *mp" "void *pgaddr" "u_int flags" +.Ft int +.Fn mpool_sync "MPOOL *mp" +.Ft int +.Fn mpool_close "MPOOL *mp" +.Sh DESCRIPTION +.Nm Mpool +is the library interface intended to provide page oriented buffer management +of files. +The buffers may be shared between processes. +.Pp +The function +.Fn mpool_open +initializes a memory pool. +The +.Fa key +argument is the byte string used to negotiate between multiple +processes wishing to share buffers. +If the file buffers are mapped in shared memory, all processes using +the same key will share the buffers. +If +.Fa key +is +.Dv NULL , +the buffers are mapped into private memory. +The +.Fa fd +argument is a file descriptor for the underlying file, which must be seekable. +If +.Fa key +is +.No non\- Ns Dv NULL +and matches a file already being mapped, the +.Fa fd +argument is ignored. +.Pp +The +.Fa pagesize +argument is the size, in bytes, of the pages into which the file is broken up. +The +.Fa maxcache +argument is the maximum number of pages from the underlying file to cache +at any one time. +This value is not relative to the number of processes which share a file's +buffers, but will be the largest value specified by any of the processes +sharing the file. +.Pp +The +.Fn mpool_filter +function is intended to make transparent input and output processing of the +pages possible. +If the +.Fa pgin +function is specified, it is called each time a buffer is read into the memory +pool from the backing file. +If the +.Fa pgout +function is specified, it is called each time a buffer is written into the +backing file. +Both functions are called with the +.Fa pgcookie +pointer, the page number and a pointer to the page to being read or written. +.Pp +The function +.Fn mpool_new +takes an +.Ft MPOOL +pointer and an address as arguments. +If a new page can be allocated, a pointer to the page is returned and +the page number is stored into the +.Fa pgnoaddr +address. +Otherwise, +.Dv NULL +is returned and +.Va errno +is set. +.Pp +The function +.Fn mpool_get +takes a +.Ft MPOOL +pointer and a page number as arguments. +If the page exists, a pointer to the page is returned. +Otherwise, +.Dv NULL +is returned and +.Va errno +is set. +The +.Fa flags +parameter is not currently used. +.Pp +The function +.Fn mpool_put +unpins the page referenced by +.Fa pgaddr . +.Fa Pgaddr +must be an address previously returned by +.Fn mpool_get +or +.Fn mpool_new . +The +.Fa flags +value is specified by +.Em or Ns 'ing +any of the following values: +.Bl -tag -width indent +.It Dv MPOOL_DIRTY +The page has been modified and needs to be written to the backing file. +.El +.Pp +.Fn Mpool_put +returns 0 on success and -1 if an error occurs. +.Pp +The function +.Fn mpool_sync +writes all modified pages associated with the +.Ft MPOOL +pointer to the +backing file. +.Fn Mpool_sync +returns 0 on success and -1 if an error occurs. +.Pp +The +.Fn mpool_close +function free's up any allocated memory associated with the memory pool +cookie. +Modified pages are +.Em not +written to the backing file. +.Fn Mpool_close +returns 0 on success and -1 if an error occurs. +.Sh ERRORS +The +.Fn mpool_open +function may fail and set +.Va errno +for any of the errors specified for the library routine +.Xr malloc 3 . +.Pp +The +.Fn mpool_get +function may fail and set +.Va errno +for the following: +.Bl -tag -width Er +.It Bq Er EINVAL +The requested record doesn't exist. +.El +.Pp +The +.Fn mpool_new +and +.Fn mpool_get +functions may fail and set +.Va errno +for any of the errors specified for the library routines +.Xr read 2 , +.Xr write 2 , +and +.Xr malloc 3 . +.Pp +The +.Fn mpool_sync +function may fail and set +.Va errno +for any of the errors specified for the library routine +.Xr write 2 . +.Pp +The +.Fn mpool_close +function may fail and set +.Va errno +for any of the errors specified for the library routine +.Xr free 3 . +.Sh SEE ALSO +.Xr btree 3 , +.Xr dbopen 3 , +.Xr hash 3 , +.Xr recno 3 diff --git a/db/man/recno.3 b/db/man/recno.3 new file mode 100644 index 0000000..7f069cf --- /dev/null +++ b/db/man/recno.3 @@ -0,0 +1,232 @@ +.\" Copyright (c) 1990, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)recno.3 8.5 (Berkeley) 8/18/94 +.\" $FreeBSD: src/lib/libc/db/man/recno.3,v 1.6 2001/10/01 16:08:50 ru Exp $ +.\" +.Dd August 18, 1994 +.Dt RECNO 3 +.Os +.Sh NAME +.Nm recno +.Nd "record number database access method" +.Sh SYNOPSIS +.In sys/types.h +.In db.h +.Sh DESCRIPTION +The routine +.Fn dbopen +is the library interface to database files. +One of the supported file formats is record number files. +The general description of the database access methods is in +.Xr dbopen 3 , +this manual page describes only the +.Nm +specific information. +.Pp +The record number data structure is either variable or fixed-length +records stored in a flat-file format, accessed by the logical record +number. +The existence of record number five implies the existence of records +one through four, and the deletion of record number one causes +record number five to be renumbered to record number four, as well +as the cursor, if positioned after record number one, to shift down +one record. +.Pp +The +.Nm +access method specific data structure provided to +.Fn dbopen +is defined in the +.Aq Pa db.h +include file as follows: +.Bd -literal +typedef struct { + u_long flags; + u_int cachesize; + u_int psize; + int lorder; + size_t reclen; + u_char bval; + char *bfname; +} RECNOINFO; +.Ed +.Pp +The elements of this structure are defined as follows: +.Bl -tag -width indent +.It Va flags +The flag value is specified by +.Em or Ns 'ing +any of the following values: +.Bl -tag -width indent +.It Dv R_FIXEDLEN +The records are fixed-length, not byte delimited. +The structure element +.Va reclen +specifies the length of the record, and the structure element +.Va bval +is used as the pad character. +Any records, inserted into the database, that are less than +.Va reclen +bytes long are automatically padded. +.It Dv R_NOKEY +In the interface specified by +.Fn dbopen , +the sequential record retrieval fills in both the caller's key and +data structures. +If the +.Dv R_NOKEY +flag is specified, the +.Em cursor +routines are not required to fill in the key structure. +This permits applications to retrieve records at the end of files without +reading all of the intervening records. +.It Dv R_SNAPSHOT +This flag requires that a snapshot of the file be taken when +.Fn dbopen +is called, instead of permitting any unmodified records to be read from +the original file. +.El +.It Va cachesize +A suggested maximum size, in bytes, of the memory cache. +This value is +.Em only +advisory, and the access method will allocate more memory rather than fail. +If +.Va cachesize +is 0 (no size is specified) a default cache is used. +.It Va psize +The +.Nm +access method stores the in-memory copies of its records +in a btree. +This value is the size (in bytes) of the pages used for nodes in that tree. +If +.Va psize +is 0 (no page size is specified) a page size is chosen based on the +underlying file system I/O block size. +See +.Xr btree 3 +for more information. +.It Va lorder +The byte order for integers in the stored database metadata. +The number should represent the order as an integer; for example, +big endian order would be the number 4,321. +If +.Va lorder +is 0 (no order is specified) the current host order is used. +.It Va reclen +The length of a fixed-length record. +.It Va bval +The delimiting byte to be used to mark the end of a record for +variable-length records, and the pad character for fixed-length +records. +If no value is specified, newlines +.Pq Dq \en +are used to mark the end +of variable-length records and fixed-length records are padded with +spaces. +.It Va bfname +The +.Nm +access method stores the in-memory copies of its records +in a btree. +If +.Va bfname +is +.No non\- Ns Dv NULL , +it specifies the name of the btree file, +as if specified as the file name for a +.Fn dbopen +of a btree file. +.El +.Pp +The data part of the key/data pair used by the +.Nm +access method +is the same as other access methods. +The key is different. +The +.Va data +field of the key should be a pointer to a memory location of type +.Ft recno_t , +as defined in the +.Aq Pa db.h +include file. +This type is normally the largest unsigned integral type available to +the implementation. +The +.Va size +field of the key should be the size of that type. +.Pp +Because there can be no meta-data associated with the underlying +.Nm +access method files, any changes made to the default values +(e.g. fixed record length or byte separator value) must be explicitly +specified each time the file is opened. +.Pp +In the interface specified by +.Fn dbopen , +using the +.Va put +interface to create a new record will cause the creation of multiple, +empty records if the record number is more than one greater than the +largest record currently in the database. +.Sh ERRORS +The +.Nm +access method routines may fail and set +.Va errno +for any of the errors specified for the library routine +.Xr dbopen 3 +or the following: +.Bl -tag -width Er +.It Bq Er EINVAL +An attempt was made to add a record to a fixed-length database that +was too large to fit. +.El +.Sh SEE ALSO +.Xr btree 3 , +.Xr dbopen 3 , +.Xr hash 3 , +.Xr mpool 3 +.Rs +.%T "Document Processing in a Relational Database System" +.%A Michael Stonebraker +.%A Heidi Stettner +.%A Joseph Kalash +.%A Antonin Guttman +.%A Nadene Lynn +.%R "Memorandum No. UCB/ERL M82/32" +.%D May 1982 +.Re +.Sh BUGS +Only big and little endian byte order is supported. diff --git a/db/mpool/Makefile.inc b/db/mpool/Makefile.inc new file mode 100644 index 0000000..4438d14 --- /dev/null +++ b/db/mpool/Makefile.inc @@ -0,0 +1,6 @@ +# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 +# $FreeBSD: src/lib/libc/db/mpool/Makefile.inc,v 1.3 1999/08/27 23:58:23 peter Exp $ + +.PATH: ${.CURDIR}/db/mpool + +SRCS+= mpool.c diff --git a/db.subproj/mpool.subproj/mpool.c b/db/mpool/mpool.c similarity index 100% rename from db.subproj/mpool.subproj/mpool.c rename to db/mpool/mpool.c diff --git a/db/recno/Makefile.inc b/db/recno/Makefile.inc new file mode 100644 index 0000000..63ff12a --- /dev/null +++ b/db/recno/Makefile.inc @@ -0,0 +1,9 @@ +# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 +# $FreeBSD: src/lib/libc/db/recno/Makefile.inc,v 1.3 1999/08/27 23:58:25 peter Exp $ + +.PATH: ${.CURDIR}/db/recno + +CFLAGS+= -I${.CURDIR}/db/btree + +SRCS+= rec_close.c rec_delete.c rec_get.c rec_open.c rec_put.c rec_search.c \ + rec_seq.c rec_utils.c diff --git a/db.subproj/recno.subproj/extern.h b/db/recno/extern.h similarity index 100% rename from db.subproj/recno.subproj/extern.h rename to db/recno/extern.h diff --git a/db.subproj/recno.subproj/rec_close.c b/db/recno/rec_close.c similarity index 100% rename from db.subproj/recno.subproj/rec_close.c rename to db/recno/rec_close.c diff --git a/db.subproj/recno.subproj/rec_delete.c b/db/recno/rec_delete.c similarity index 100% rename from db.subproj/recno.subproj/rec_delete.c rename to db/recno/rec_delete.c diff --git a/db.subproj/recno.subproj/rec_get.c b/db/recno/rec_get.c similarity index 100% rename from db.subproj/recno.subproj/rec_get.c rename to db/recno/rec_get.c diff --git a/db.subproj/recno.subproj/rec_open.c b/db/recno/rec_open.c similarity index 100% rename from db.subproj/recno.subproj/rec_open.c rename to db/recno/rec_open.c diff --git a/db.subproj/recno.subproj/rec_put.c b/db/recno/rec_put.c similarity index 100% rename from db.subproj/recno.subproj/rec_put.c rename to db/recno/rec_put.c diff --git a/db.subproj/recno.subproj/rec_search.c b/db/recno/rec_search.c similarity index 100% rename from db.subproj/recno.subproj/rec_search.c rename to db/recno/rec_search.c diff --git a/db.subproj/recno.subproj/rec_seq.c b/db/recno/rec_seq.c similarity index 100% rename from db.subproj/recno.subproj/rec_seq.c rename to db/recno/rec_seq.c diff --git a/db.subproj/recno.subproj/rec_utils.c b/db/recno/rec_utils.c similarity index 100% rename from db.subproj/recno.subproj/rec_utils.c rename to db/recno/rec_utils.c diff --git a/db.subproj/recno.subproj/recno.h b/db/recno/recno.h similarity index 100% rename from db.subproj/recno.subproj/recno.h rename to db/recno/recno.h diff --git a/dpkg/control b/dpkg/control new file mode 100644 index 0000000..836adea --- /dev/null +++ b/dpkg/control @@ -0,0 +1,4 @@ +Package: libc +Maintainer: Darwin Developers +Description: C library +Build-Depends: cctools, libsystem, gnumake, libinfo-hdrs, project-makefiles, pb-makefiles, system-cmds, shell-cmds, zsh, file-cmds, bootstrap-cmds, text-cmds, gcc, xnu, architecture, gnutar diff --git a/gen.subproj/Makefile b/gen.subproj/Makefile deleted file mode 100644 index 0148fde..0000000 --- a/gen.subproj/Makefile +++ /dev/null @@ -1,72 +0,0 @@ -# -# Generated by the Apple Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = gen - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -HFILES = zone.h scalable_malloc.h malloc.h stack_logging.h - -CFILES = alarm.c assert.c clock.c closedir.c confstr.c crypt.c\ - ctermid.c ctime.c daemon.c devname.c difftime.c disklabel.c\ - err.c errlst.c exec.c fnmatch.c ftok.c fts.c getbsize.c\ - getcap.c getcwd.c gethostname.c getloadavg.c getlogin.c\ - getmntinfo.c getpagesize.c getpass.c getttyent.c\ - getusershell.c getvfsbyname.c gmon.c isatty.c isnan.c\ - malloc.c nanosleep.c nice.c nlist.c NSSystemDirectories.c\ - opendir.c pause.c popen.c psignal.c raise.c readdir.c\ - rewinddir.c scalable_malloc.c scandir.c seekdir.c\ - sethostname.c setlogin.c setmode.c siginterrupt.c siglist.c\ - signal.c sigsetops.c sleep.c stack_logging.c sysconf.c\ - sysctl.c syslog.c telldir.c termios.c time.c times.c\ - timezone.c ttyname.c ttyslot.c ualarm.c uname.c unvis.c\ - usleep.c utime.c vis.c wait.c wait3.c waitpid.c zone.c\ - sysctlbyname.c - -SUBPROJECTS = i386.subproj ppc.subproj - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble ftok.3 - - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -NEXTSTEP_INSTALLDIR = /Local/Developer/System -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - -PUBLIC_HEADERS = zone.h malloc.h - -PROJECT_HEADERS = malloc.h zone.h stack_logging.h - - - -NEXTSTEP_BUILD_OUTPUT_DIR = /Local/Public/SandBox/$(USER)/BUILD/$(NAME) - -NEXTSTEP_PUBLIC_HEADERS_DIR = /usr/include - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/gen.subproj/Makefile.postamble b/gen.subproj/Makefile.postamble deleted file mode 100644 index b0473f2..0000000 --- a/gen.subproj/Makefile.postamble +++ /dev/null @@ -1,4 +0,0 @@ -PROFILE_CFLAGS = $(filter-out -DPROFILE, $(filter-out -pg, $(ALL_CFLAGS))) -$(OFILE_DIR)/gmon.i386.o $(OFILE_DIR)/gmon.ppc.o: gmon.c - $(CC) -arch $(CURRENT_ARCH) $(PROFILE_CFLAGS) $(LOCAL_DIR_INCLUDE_DIRECTIVE) -c gmon.c -o $@ - diff --git a/gen.subproj/Makefile.preamble b/gen.subproj/Makefile.preamble deleted file mode 100644 index 3be9dcf..0000000 --- a/gen.subproj/Makefile.preamble +++ /dev/null @@ -1,2 +0,0 @@ -PUBLIC_HEADER_DIR_SUFFIX = /objc -PROJECT_HEADER_DIR_SUFFIX = /objc diff --git a/gen.subproj/PB.project b/gen.subproj/PB.project deleted file mode 100644 index 5401699..0000000 --- a/gen.subproj/PB.project +++ /dev/null @@ -1,108 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - H_FILES = (zone.h, scalable_malloc.h, malloc.h, stack_logging.h); - OTHER_LINKED = ( - alarm.c, - assert.c, - clock.c, - closedir.c, - confstr.c, - crypt.c, - ctermid.c, - ctime.c, - daemon.c, - devname.c, - difftime.c, - disklabel.c, - err.c, - errlst.c, - exec.c, - fnmatch.c, - ftok.c, - fts.c, - getbsize.c, - getcap.c, - getcwd.c, - gethostname.c, - getloadavg.c, - getlogin.c, - getmntinfo.c, - getpagesize.c, - getpass.c, - getttyent.c, - getusershell.c, - getvfsbyname.c, - gmon.c, - isatty.c, - isnan.c, - malloc.c, - nanosleep.c, - nice.c, - nlist.c, - NSSystemDirectories.c, - opendir.c, - pause.c, - popen.c, - psignal.c, - raise.c, - readdir.c, - rewinddir.c, - scalable_malloc.c, - scandir.c, - seekdir.c, - sethostname.c, - setlogin.c, - setmode.c, - siginterrupt.c, - siglist.c, - signal.c, - sigsetops.c, - sleep.c, - stack_logging.c, - sysconf.c, - sysctl.c, - syslog.c, - telldir.c, - termios.c, - time.c, - times.c, - timezone.c, - ttyname.c, - ttyslot.c, - ualarm.c, - uname.c, - unvis.c, - usleep.c, - utime.c, - vis.c, - wait.c, - wait3.c, - waitpid.c, - zone.c, - sysctlbyname.c - ); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble, ftok.3); - PRECOMPILED_HEADERS = (); - PROJECT_HEADERS = (malloc.h, zone.h, stack_logging.h); - PUBLIC_HEADERS = (zone.h, malloc.h); - SUBPROJECTS = (i386.subproj, ppc.subproj); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDDIR = "/Local/Public/SandBox/$(USER)/BUILD/$(NAME)"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_INSTALLDIR = /Local/Developer/System; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - NEXTSTEP_PUBLICHEADERSDIR = /usr/include; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = gen; - PROJECTTYPE = Component; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/gen.subproj/i386.subproj/Makefile b/gen.subproj/i386.subproj/Makefile deleted file mode 100644 index 5aea859..0000000 --- a/gen.subproj/i386.subproj/Makefile +++ /dev/null @@ -1,50 +0,0 @@ -# -# Generated by the NeXT Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = i386 - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -OTHERLINKED = mcount.s - -CFILES = abs.c bcmp.c bcopy.c bzero.c ecvt.c ffs.c insque.c isinf.c\ - memcpy.c memmove.c remque.c setjmperr.c strcat.c strcpy.c\ - strlen.c strncat.c strncmp.c strncpy.c - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble - -OTHERLINKEDOFILES = mcount.o - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - - - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/gen.subproj/i386.subproj/Makefile.postamble b/gen.subproj/i386.subproj/Makefile.postamble deleted file mode 100644 index 411cde6..0000000 --- a/gen.subproj/i386.subproj/Makefile.postamble +++ /dev/null @@ -1,100 +0,0 @@ -############################################################################### -# Makefile.postamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile, which is imported after all other makefiles, to -# override attributes for a project's Makefile environment. This allows you -# to take advantage of the environment set up by the other Makefiles. -# You can also define custom rules at the end of this file. -# -############################################################################### -# -# These variables are exported by the standard makefiles and can be -# used in any customizations you make. They are *outputs* of -# the Makefiles and should be used, not set. -# -# PRODUCTS: products to install. All of these products will be placed in -# the directory $(DSTROOT)$(INSTALLDIR) -# GLOBAL_RESOURCE_DIR: The directory to which resources are copied. -# LOCAL_RESOURCE_DIR: The directory to which localized resources are copied. -# OFILE_DIR: Directory into which .o object files are generated. -# DERIVED_SRC_DIR: Directory used for all other derived files -# -# ALL_CFLAGS: flags to pass when compiling .c files -# ALL_MFLAGS: flags to pass when compiling .m files -# ALL_CCFLAGS: flags to pass when compiling .cc, .cxx, and .C files -# ALL_MMFLAGS: flags to pass when compiling .mm, .mxx, and .M files -# ALL_PRECOMPFLAGS: flags to pass when precompiling .h files -# ALL_LDFLAGS: flags to pass when linking object files -# ALL_LIBTOOL_FLAGS: flags to pass when libtooling object files -# ALL_PSWFLAGS: flags to pass when processing .psw and .pswm (pswrap) files -# ALL_RPCFLAGS: flags to pass when processing .rpc (rpcgen) files -# ALL_YFLAGS: flags to pass when processing .y (yacc) files -# ALL_LFLAGS: flags to pass when processing .l (lex) files -# -# NAME: name of application, bundle, subproject, palette, etc. -# LANGUAGES: langages in which the project is written (default "English") -# English_RESOURCES: localized resources (e.g. nib's, images) of project -# GLOBAL_RESOURCES: non-localized resources of project -# -# SRCROOT: base directory in which to place the new source files -# SRCPATH: relative path from SRCROOT to present subdirectory -# -# INSTALLDIR: Directory the product will be installed into by 'install' target -# PUBLIC_HDR_INSTALLDIR: where to install public headers. Don't forget -# to prefix this with DSTROOT when you use it. -# PRIVATE_HDR_INSTALLDIR: where to install private headers. Don't forget -# to prefix this with DSTROOT when you use it. -# -# EXECUTABLE_EXT: Executable extension for the platform (i.e. .exe on Windows) -# -############################################################################### - -# Some compiler flags can be overridden here for certain build situations. -# -# WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost) -# DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults -# to -g) -# DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG) -# OPTIMIZE_BUILD_CFLAGS: flags passed during optimized builds (defaults -# to -O) -# PROFILE_BUILD_CFLAGS: flags passed during profile builds (defaults -# to -pg -DPROFILE) -# LOCAL_DIR_INCLUDE_DIRECTIVE: flag used to add current directory to -# the include path (defaults to -I.) -# DEBUG_BUILD_LDFLAGS, OPTIMIZE_BUILD_LDFLAGS, PROFILE_BUILD_LDFLAGS: flags -# passed to ld/libtool (defaults to nothing) - - -# Library and Framework projects only: -# INSTALL_NAME_DIRECTIVE: This directive ensures that executables linked -# against the framework will run against the correct version even if -# the current version of the framework changes. You may override this -# to "" as an alternative to using the DYLD_LIBRARY_PATH during your -# development cycle, but be sure to restore it before installing. - - -# Ownership and permissions of files installed by 'install' target - -#INSTALL_AS_USER = root - # User/group ownership -#INSTALL_AS_GROUP = wheel - # (probably want to set both of these) -#INSTALL_PERMISSIONS = - # If set, 'install' chmod's executable to this - - -# Options to strip. Note: -S strips debugging symbols (executables can be stripped -# down further with -x or, if they load no bundles, with no options at all). - -#STRIPFLAGS = -S - - -######################################################################### -# Put rules to extend the behavior of the standard Makefiles here. Include them in -# the dependency tree via cvariables like AFTER_INSTALL in the Makefile.preamble. -# -# You should avoid redefining things like "install" or "app", as they are -# owned by the top-level Makefile API and no context has been set up for where -# derived files should go. -# diff --git a/gen.subproj/i386.subproj/Makefile.preamble b/gen.subproj/i386.subproj/Makefile.preamble deleted file mode 100644 index 6544e5f..0000000 --- a/gen.subproj/i386.subproj/Makefile.preamble +++ /dev/null @@ -1,137 +0,0 @@ -############################################################################### -# Makefile.preamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile for configuring the standard application makefiles -# associated with ProjectBuilder. It is included before the main makefile. -# In Makefile.preamble you set attributes for a project, so they are available -# to the project's makefiles. In contrast, you typically write additional rules or -# override built-in behavior in the Makefile.postamble. -# -# Each directory in a project tree (main project plus subprojects) should -# have its own Makefile.preamble and Makefile.postamble. -############################################################################### -# -# Before the main makefile is included for this project, you may set: -# -# MAKEFILEDIR: Directory in which to find $(MAKEFILE) -# MAKEFILE: Top level mechanism Makefile (e.g., app.make, bundle.make) - -# Compiler/linker flags added to the defaults: The OTHER_* variables will be -# inherited by all nested sub-projects, but the LOCAL_ versions of the same -# variables will not. Put your -I, -D, -U, and -L flags in ProjectBuilder's -# Build Attributes inspector if at all possible. To override the default flags -# that get passed to ${CC} (e.g. change -O to -O2), see Makefile.postamble. The -# variables below are *inputs* to the build process and distinct from the override -# settings done (less often) in the Makefile.postamble. -# -# OTHER_CFLAGS, LOCAL_CFLAGS: additional flags to pass to the compiler -# Note that $(OTHER_CFLAGS) and $(LOCAL_CFLAGS) are used for .h, ...c, .m, -# .cc, .cxx, .C, and .M files. There is no need to respecify the -# flags in OTHER_MFLAGS, etc. -# OTHER_MFLAGS, LOCAL_MFLAGS: additional flags for .m files -# OTHER_CCFLAGS, LOCAL_CCFLAGS: additional flags for .cc, .cxx, and ...C files -# OTHER_MMFLAGS, LOCAL_MMFLAGS: additional flags for .mm and .M files -# OTHER_PRECOMPFLAGS, LOCAL_PRECOMPFLAGS: additional flags used when -# precompiling header files -# OTHER_LDFLAGS, LOCAL_LDFLAGS: additional flags passed to ld and libtool -# OTHER_PSWFLAGS, LOCAL_PSWFLAGS: additional flags passed to pswrap -# OTHER_RPCFLAGS, LOCAL_RPCFLAGS: additional flags passed to rpcgen -# OTHER_YFLAGS, LOCAL_YFLAGS: additional flags passed to yacc -# OTHER_LFLAGS, LOCAL_LFLAGS: additional flags passed to lex - -# These variables provide hooks enabling you to add behavior at almost every -# stage of the make: -# -# BEFORE_PREBUILD: targets to build before installing headers for a subproject -# AFTER_PREBUILD: targets to build after installing headers for a subproject -# BEFORE_BUILD_RECURSION: targets to make before building subprojects -# BEFORE_BUILD: targets to make before a build, but after subprojects -# AFTER_BUILD: targets to make after a build -# -# BEFORE_INSTALL: targets to build before installing the product -# AFTER_INSTALL: targets to build after installing the product -# BEFORE_POSTINSTALL: targets to build before postinstalling every subproject -# AFTER_POSTINSTALL: targts to build after postinstalling every subproject -# -# BEFORE_INSTALLHDRS: targets to build before installing headers for a -# subproject -# AFTER_INSTALLHDRS: targets to build after installing headers for a subproject -# BEFORE_INSTALLSRC: targets to build before installing source for a subproject -# AFTER_INSTALLSRC: targets to build after installing source for a subproject -# -# BEFORE_DEPEND: targets to build before building dependencies for a -# subproject -# AFTER_DEPEND: targets to build after building dependencies for a -# subproject -# -# AUTOMATIC_DEPENDENCY_INFO: if YES, then the dependency file is -# updated every time the project is built. If NO, the dependency -# file is only built when the depend target is invoked. - -# Framework-related variables: -# FRAMEWORK_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the framework's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables - -# Library-related variables: -# PUBLIC_HEADER_DIR: Determines where public exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. For library projects you should -# set this to something like /Developer/Headers/$(NAME). Do not set -# this variable for framework projects unless you do not want the -# header files included in the framework. -# PRIVATE_HEADER_DIR: Determines where private exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. -# LIBRARY_STYLE: This may be either STATIC or DYNAMIC, and determines -# whether the libraries produced are statically linked when they -# are used or if they are dynamically loadable. This defaults to -# DYNAMIC. -# LIBRARY_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the library's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables -# -# INSTALL_AS_USER: owner of the intalled products (default root) -# INSTALL_AS_GROUP: group of the installed products (default wheel) -# INSTALL_PERMISSIONS: permissions of the installed product (default o+rX) -# -# OTHER_RECURSIVE_VARIABLES: The names of variables which you want to be -# passed on the command line to recursive invocations of make. Note that -# the values in OTHER_*FLAGS are inherited by subprojects automatically -- -# you do not have to (and shouldn't) add OTHER_*FLAGS to -# OTHER_RECURSIVE_VARIABLES. - -# Additional headers to export beyond those in the PB.project: -# OTHER_PUBLIC_HEADERS -# OTHER_PROJECT_HEADERS -# OTHER_PRIVATE_HEADERS - -# Additional files for the project's product: <> -# OTHER_RESOURCES: (non-localized) resources for this project -# OTHER_OFILES: relocatables to be linked into this project -# OTHER_LIBS: more libraries to link against -# OTHER_PRODUCT_DEPENDS: other dependencies of this project -# OTHER_SOURCEFILES: other source files maintained by .pre/postamble -# OTHER_GARBAGE: additional files to be removed by `make clean' - -# Set this to YES if you don't want a final libtool call for a library/framework. -# BUILD_OFILES_LIST_ONLY - -# To include a version string, project source must exist in a directory named -# $(NAME).%d[.%d][.%d] and the following line must be uncommented. -# OTHER_GENERATED_OFILES = $(VERS_OFILE) - -# This definition will suppress stripping of debug symbols when an executable -# is installed. By default it is YES. -# STRIP_ON_INSTALL = NO - -# Uncomment to suppress generation of a KeyValueCoding index when installing -# frameworks (This index is used by WOB and IB to determine keys available -# for an object). Set to YES by default. -# PREINDEX_FRAMEWORK = NO - -# Change this definition to install projects somewhere other than the -# standard locations. NEXT_ROOT defaults to "C:/Apple" on Windows systems -# and "" on other systems. -INCLUDED_ARCHS = i386 diff --git a/gen.subproj/i386.subproj/PB.project b/gen.subproj/i386.subproj/PB.project deleted file mode 100644 index 6bad7ee..0000000 --- a/gen.subproj/i386.subproj/PB.project +++ /dev/null @@ -1,43 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - H_FILES = (); - OTHER_LINKED = ( - abs.c, - bcmp.c, - bcopy.c, - bzero.c, - ecvt.c, - ffs.c, - insque.c, - isinf.c, - mcount.s, - memcpy.c, - memmove.c, - remque.c, - setjmperr.c, - strcat.c, - strcpy.c, - strlen.c, - strncat.c, - strncmp.c, - strncpy.c - ); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble); - SUBPROJECTS = (); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = i386; - PROJECTTYPE = Component; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/gen.subproj/ppc.subproj/Makefile b/gen.subproj/ppc.subproj/Makefile deleted file mode 100644 index 0c95a7b..0000000 --- a/gen.subproj/ppc.subproj/Makefile +++ /dev/null @@ -1,53 +0,0 @@ -# -# Generated by the NeXT Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = ppc - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -HFILES = fp.h genassym.h - -OTHERLINKED = abs.s blockmoof.s bzero.s ffs.s mcount.s \ - strlen.s - -CFILES = bcmp.c ecvt.c insque.c isinf.c remque.c setjmperr.c\ - strcat.c strcpy.c strncat.c strncmp.c strncpy.c - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble - -OTHERLINKEDOFILES = abs.o blockmoof.o bzero.o ffs.o mcount.o \ - strlen.o - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - - - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/gen.subproj/ppc.subproj/Makefile.postamble b/gen.subproj/ppc.subproj/Makefile.postamble deleted file mode 100644 index 411cde6..0000000 --- a/gen.subproj/ppc.subproj/Makefile.postamble +++ /dev/null @@ -1,100 +0,0 @@ -############################################################################### -# Makefile.postamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile, which is imported after all other makefiles, to -# override attributes for a project's Makefile environment. This allows you -# to take advantage of the environment set up by the other Makefiles. -# You can also define custom rules at the end of this file. -# -############################################################################### -# -# These variables are exported by the standard makefiles and can be -# used in any customizations you make. They are *outputs* of -# the Makefiles and should be used, not set. -# -# PRODUCTS: products to install. All of these products will be placed in -# the directory $(DSTROOT)$(INSTALLDIR) -# GLOBAL_RESOURCE_DIR: The directory to which resources are copied. -# LOCAL_RESOURCE_DIR: The directory to which localized resources are copied. -# OFILE_DIR: Directory into which .o object files are generated. -# DERIVED_SRC_DIR: Directory used for all other derived files -# -# ALL_CFLAGS: flags to pass when compiling .c files -# ALL_MFLAGS: flags to pass when compiling .m files -# ALL_CCFLAGS: flags to pass when compiling .cc, .cxx, and .C files -# ALL_MMFLAGS: flags to pass when compiling .mm, .mxx, and .M files -# ALL_PRECOMPFLAGS: flags to pass when precompiling .h files -# ALL_LDFLAGS: flags to pass when linking object files -# ALL_LIBTOOL_FLAGS: flags to pass when libtooling object files -# ALL_PSWFLAGS: flags to pass when processing .psw and .pswm (pswrap) files -# ALL_RPCFLAGS: flags to pass when processing .rpc (rpcgen) files -# ALL_YFLAGS: flags to pass when processing .y (yacc) files -# ALL_LFLAGS: flags to pass when processing .l (lex) files -# -# NAME: name of application, bundle, subproject, palette, etc. -# LANGUAGES: langages in which the project is written (default "English") -# English_RESOURCES: localized resources (e.g. nib's, images) of project -# GLOBAL_RESOURCES: non-localized resources of project -# -# SRCROOT: base directory in which to place the new source files -# SRCPATH: relative path from SRCROOT to present subdirectory -# -# INSTALLDIR: Directory the product will be installed into by 'install' target -# PUBLIC_HDR_INSTALLDIR: where to install public headers. Don't forget -# to prefix this with DSTROOT when you use it. -# PRIVATE_HDR_INSTALLDIR: where to install private headers. Don't forget -# to prefix this with DSTROOT when you use it. -# -# EXECUTABLE_EXT: Executable extension for the platform (i.e. .exe on Windows) -# -############################################################################### - -# Some compiler flags can be overridden here for certain build situations. -# -# WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost) -# DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults -# to -g) -# DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG) -# OPTIMIZE_BUILD_CFLAGS: flags passed during optimized builds (defaults -# to -O) -# PROFILE_BUILD_CFLAGS: flags passed during profile builds (defaults -# to -pg -DPROFILE) -# LOCAL_DIR_INCLUDE_DIRECTIVE: flag used to add current directory to -# the include path (defaults to -I.) -# DEBUG_BUILD_LDFLAGS, OPTIMIZE_BUILD_LDFLAGS, PROFILE_BUILD_LDFLAGS: flags -# passed to ld/libtool (defaults to nothing) - - -# Library and Framework projects only: -# INSTALL_NAME_DIRECTIVE: This directive ensures that executables linked -# against the framework will run against the correct version even if -# the current version of the framework changes. You may override this -# to "" as an alternative to using the DYLD_LIBRARY_PATH during your -# development cycle, but be sure to restore it before installing. - - -# Ownership and permissions of files installed by 'install' target - -#INSTALL_AS_USER = root - # User/group ownership -#INSTALL_AS_GROUP = wheel - # (probably want to set both of these) -#INSTALL_PERMISSIONS = - # If set, 'install' chmod's executable to this - - -# Options to strip. Note: -S strips debugging symbols (executables can be stripped -# down further with -x or, if they load no bundles, with no options at all). - -#STRIPFLAGS = -S - - -######################################################################### -# Put rules to extend the behavior of the standard Makefiles here. Include them in -# the dependency tree via cvariables like AFTER_INSTALL in the Makefile.preamble. -# -# You should avoid redefining things like "install" or "app", as they are -# owned by the top-level Makefile API and no context has been set up for where -# derived files should go. -# diff --git a/gen.subproj/ppc.subproj/Makefile.preamble b/gen.subproj/ppc.subproj/Makefile.preamble deleted file mode 100644 index 7211b2b..0000000 --- a/gen.subproj/ppc.subproj/Makefile.preamble +++ /dev/null @@ -1,137 +0,0 @@ -############################################################################### -# Makefile.preamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile for configuring the standard application makefiles -# associated with ProjectBuilder. It is included before the main makefile. -# In Makefile.preamble you set attributes for a project, so they are available -# to the project's makefiles. In contrast, you typically write additional rules or -# override built-in behavior in the Makefile.postamble. -# -# Each directory in a project tree (main project plus subprojects) should -# have its own Makefile.preamble and Makefile.postamble. -############################################################################### -# -# Before the main makefile is included for this project, you may set: -# -# MAKEFILEDIR: Directory in which to find $(MAKEFILE) -# MAKEFILE: Top level mechanism Makefile (e.g., app.make, bundle.make) - -# Compiler/linker flags added to the defaults: The OTHER_* variables will be -# inherited by all nested sub-projects, but the LOCAL_ versions of the same -# variables will not. Put your -I, -D, -U, and -L flags in ProjectBuilder's -# Build Attributes inspector if at all possible. To override the default flags -# that get passed to ${CC} (e.g. change -O to -O2), see Makefile.postamble. The -# variables below are *inputs* to the build process and distinct from the override -# settings done (less often) in the Makefile.postamble. -# -# OTHER_CFLAGS, LOCAL_CFLAGS: additional flags to pass to the compiler -# Note that $(OTHER_CFLAGS) and $(LOCAL_CFLAGS) are used for .h, ...c, .m, -# .cc, .cxx, .C, and .M files. There is no need to respecify the -# flags in OTHER_MFLAGS, etc. -# OTHER_MFLAGS, LOCAL_MFLAGS: additional flags for .m files -# OTHER_CCFLAGS, LOCAL_CCFLAGS: additional flags for .cc, .cxx, and ...C files -# OTHER_MMFLAGS, LOCAL_MMFLAGS: additional flags for .mm and .M files -# OTHER_PRECOMPFLAGS, LOCAL_PRECOMPFLAGS: additional flags used when -# precompiling header files -# OTHER_LDFLAGS, LOCAL_LDFLAGS: additional flags passed to ld and libtool -# OTHER_PSWFLAGS, LOCAL_PSWFLAGS: additional flags passed to pswrap -# OTHER_RPCFLAGS, LOCAL_RPCFLAGS: additional flags passed to rpcgen -# OTHER_YFLAGS, LOCAL_YFLAGS: additional flags passed to yacc -# OTHER_LFLAGS, LOCAL_LFLAGS: additional flags passed to lex - -# These variables provide hooks enabling you to add behavior at almost every -# stage of the make: -# -# BEFORE_PREBUILD: targets to build before installing headers for a subproject -# AFTER_PREBUILD: targets to build after installing headers for a subproject -# BEFORE_BUILD_RECURSION: targets to make before building subprojects -# BEFORE_BUILD: targets to make before a build, but after subprojects -# AFTER_BUILD: targets to make after a build -# -# BEFORE_INSTALL: targets to build before installing the product -# AFTER_INSTALL: targets to build after installing the product -# BEFORE_POSTINSTALL: targets to build before postinstalling every subproject -# AFTER_POSTINSTALL: targts to build after postinstalling every subproject -# -# BEFORE_INSTALLHDRS: targets to build before installing headers for a -# subproject -# AFTER_INSTALLHDRS: targets to build after installing headers for a subproject -# BEFORE_INSTALLSRC: targets to build before installing source for a subproject -# AFTER_INSTALLSRC: targets to build after installing source for a subproject -# -# BEFORE_DEPEND: targets to build before building dependencies for a -# subproject -# AFTER_DEPEND: targets to build after building dependencies for a -# subproject -# -# AUTOMATIC_DEPENDENCY_INFO: if YES, then the dependency file is -# updated every time the project is built. If NO, the dependency -# file is only built when the depend target is invoked. - -# Framework-related variables: -# FRAMEWORK_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the framework's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables - -# Library-related variables: -# PUBLIC_HEADER_DIR: Determines where public exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. For library projects you should -# set this to something like /Developer/Headers/$(NAME). Do not set -# this variable for framework projects unless you do not want the -# header files included in the framework. -# PRIVATE_HEADER_DIR: Determines where private exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. -# LIBRARY_STYLE: This may be either STATIC or DYNAMIC, and determines -# whether the libraries produced are statically linked when they -# are used or if they are dynamically loadable. This defaults to -# DYNAMIC. -# LIBRARY_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the library's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables -# -# INSTALL_AS_USER: owner of the intalled products (default root) -# INSTALL_AS_GROUP: group of the installed products (default wheel) -# INSTALL_PERMISSIONS: permissions of the installed product (default o+rX) -# -# OTHER_RECURSIVE_VARIABLES: The names of variables which you want to be -# passed on the command line to recursive invocations of make. Note that -# the values in OTHER_*FLAGS are inherited by subprojects automatically -- -# you do not have to (and shouldn't) add OTHER_*FLAGS to -# OTHER_RECURSIVE_VARIABLES. - -# Additional headers to export beyond those in the PB.project: -# OTHER_PUBLIC_HEADERS -# OTHER_PROJECT_HEADERS -# OTHER_PRIVATE_HEADERS - -# Additional files for the project's product: <> -# OTHER_RESOURCES: (non-localized) resources for this project -# OTHER_OFILES: relocatables to be linked into this project -# OTHER_LIBS: more libraries to link against -# OTHER_PRODUCT_DEPENDS: other dependencies of this project -# OTHER_SOURCEFILES: other source files maintained by .pre/postamble -# OTHER_GARBAGE: additional files to be removed by `make clean' - -# Set this to YES if you don't want a final libtool call for a library/framework. -# BUILD_OFILES_LIST_ONLY - -# To include a version string, project source must exist in a directory named -# $(NAME).%d[.%d][.%d] and the following line must be uncommented. -# OTHER_GENERATED_OFILES = $(VERS_OFILE) - -# This definition will suppress stripping of debug symbols when an executable -# is installed. By default it is YES. -# STRIP_ON_INSTALL = NO - -# Uncomment to suppress generation of a KeyValueCoding index when installing -# frameworks (This index is used by WOB and IB to determine keys available -# for an object). Set to YES by default. -# PREINDEX_FRAMEWORK = NO - -# Change this definition to install projects somewhere other than the -# standard locations. NEXT_ROOT defaults to "C:/Apple" on Windows systems -# and "" on other systems. -INCLUDED_ARCHS = ppc diff --git a/gen.subproj/ppc.subproj/PB.project b/gen.subproj/ppc.subproj/PB.project deleted file mode 100644 index 6fec101..0000000 --- a/gen.subproj/ppc.subproj/PB.project +++ /dev/null @@ -1,41 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - H_FILES = (fp.h, genassym.h); - OTHER_LINKED = ( - abs.s, - bcmp.c, - blockmoof.s, - bzero.s, - ecvt.c, - ffs.s, - insque.c, - isinf.c, - mcount.s, - remque.c, - setjmperr.c, - strcat.c, - strcpy.c, - strlen.s, - strncat.c, - strncmp.c, - strncpy.c - ); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble); - SUBPROJECTS = (); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = ppc; - PROJECTTYPE = Component; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/gen.subproj/ppc.subproj/blockmoof.s b/gen.subproj/ppc.subproj/blockmoof.s deleted file mode 100755 index 947e7f0..0000000 --- a/gen.subproj/ppc.subproj/blockmoof.s +++ /dev/null @@ -1,940 +0,0 @@ -/* - * Copyright (c) 1992-2001 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ -#include - -// ================================================================================================= -// *** The easiest way to assemble things on Mac OS X is via "cc", so this uses #defines and such. -// ================================================================================================= - -// Keep track of whether we have Altivec -// This gets set in pthread_init() - -.data -.align 2 -.globl __cpu_has_altivec -__cpu_has_altivec: -.long 0 - -.text -.align 2 -.globl _bcopy -.globl _memcpy -.globl _memmove - -_bcopy: - mr r2,r4 // Since bcopy uses (src,dest,count), swap r3,r4 - mr r4,r3 - mr r3,r2 -_memcpy: -_memmove: - mr r2,r3 // Store dest ptr in r2 to preserve r3 on return - -// ------------------ -// Standard registers - -#define rs r4 -#define rd r2 -#define rc r5 - -// Should we bother using Altivec? - - cmpwi r5, 128 - blt+ LScalar - -// Determine whether we have Altivec enabled - - mflr r0 - bcl 20,31,1f -1: - mflr r6 - mtlr r0 - addis r6, r6, ha16(__cpu_has_altivec - 1b) - lwz r6, lo16(__cpu_has_altivec - 1b)(r6) - cmpwi r6, 0 - bne+ LAltivec - -// ================================================================================================= - -// ***************************************** -// * S c a l a r B l o c k M o o f D a t a * -// ***************************************** -// -// This is the scalar (non-AltiVec) version of BlockMoofData. -// -// void ScalarBlockMoofData (ptr sou, ptr dest, long len) -// void ScalarBlockMoofDataUncached (ptr sou, ptr dest, long len) -// -// -// Calling Sequence: r3 = source pointer -// r4 = destination pointer -// r5 = length in bytes -// -// Uses: all volatile registers. - -LScalar: - cmplwi cr7,rc,32 // length <= 32 bytes? - cmplw cr6,rd,rs // up or down? - mr. r0,rc // copy to r0 for MoveShort, and test for negative - bgt cr7,Lbm1 // skip if count > 32 - -// Handle short moves (<=32 bytes.) - - beq cr7,LMove32 // special case 32-byte blocks - blt cr6,LMoveDownShort // move down in memory and return - add rs,rs,rc // moving up (right-to-left), so adjust pointers - add rd,rd,rc - b LMoveUpShort // move up in memory and return - -// Handle long moves (>32 bytes.) - -Lbm1: - beqlr cr6 // rs==rd, so nothing to move - bltlr cr0 // length<0, so ignore call and return - mflr r12 // save return address - bge cr6,Lbm2 // rd>=rs, so move up - -// Long moves down (left-to-right.) - - neg r6,rd // start to 32-byte-align destination - andi. r0,r6,0x1F // r0 <- bytes to move to align destination - bnel LMoveDownShort // align destination if necessary - bl LMoveDownLong // move 32-byte chunks down - andi. r0,rc,0x1F // done? - mtlr r12 // restore caller's return address - bne LMoveDownShort // move trailing leftover bytes and done - blr // no leftovers, so done - -// Long moves up (right-to-left.) - -Lbm2: - add rs,rs,rc // moving up (right-to-left), so adjust pointers - add rd,rd,rc - andi. r0,rd,0x1F // r0 <- bytes to move to align destination - bnel LMoveUpShort // align destination if necessary - bl LMoveUpLong // move 32-byte chunks up - andi. r0,rc,0x1F // done? - mtlr r12 // restore caller's return address - bne LMoveUpShort // move trailing leftover bytes and done - blr // no leftovers, so done - -// *************** -// * M O V E 3 2 * -// *************** -// -// Special case subroutine to move a 32-byte block. MoveDownShort and -// MoveUpShort only handle 0..31 bytes, and we believe 32 bytes is too -// common a case to send it through the general purpose long-block code. -// Since it moves both up and down, we must load all 32 bytes before -// storing any. -// -// Calling Sequence: rs = source ptr -// rd = destination ptr -// -// Uses: r0,r5-r11. -// - -LMove32: - lwz r0,0(rs) - lwz r5,4(rs) - lwz r6,8(rs) - lwz r7,12(rs) - lwz r8,16(rs) - lwz r9,20(rs) - lwz r10,24(rs) - lwz r11,28(rs) - stw r0,0(rd) - stw r5,4(rd) - stw r6,8(rd) - stw r7,12(rd) - stw r8,16(rd) - stw r9,20(rd) - stw r10,24(rd) - stw r11,28(rd) - blr - - -// ************************* -// * M o v e U p S h o r t * -// ************************* -// -// Subroutine called to move <32 bytes up in memory (ie, right-to-left). -// -// Entry conditions: rs = last byte moved from source (right-to-left) -// rd = last byte moved into destination -// r0 = #bytes to move (0..31) -// -// Exit conditions: rs = updated source ptr -// rd = updated destination ptr -// rc = decremented by #bytes moved -// -// Uses: r0,r6,r7,r8,cr7. -// - -LMoveUpShort: - andi. r6,r0,0x10 // test 0x10 bit in length - mtcrf 0x1,r0 // move count to cr7 so we can test bits - sub rc,rc,r0 // decrement count of bytes remaining to be moved - beq Lmus1 // skip if 0x10 bit in length is 0 - lwzu r0,-16(rs) // set, so copy up 16 bytes - lwz r6,4(rs) - lwz r7,8(rs) - lwz r8,12(rs) - stwu r0,-16(rd) - stw r6,4(rd) - stw r7,8(rd) - stw r8,12(rd) - -Lmus1: - bf 28,Lmus2 // test 0x08 bit - lwzu r0,-8(rs) - lwz r6,4(rs) - stwu r0,-8(rd) - stw r6,4(rd) - -Lmus2: - bf 29,Lmus3 // test 0x4 bit - lwzu r0,-4(rs) - stwu r0,-4(rd) - -Lmus3: - bf 30,Lmus4 // test 0x2 bit - lhzu r0,-2(rs) - sthu r0,-2(rd) - -Lmus4: - bflr 31 // test 0x1 bit, return if 0 - lbzu r0,-1(rs) - stbu r0,-1(rd) - blr - - -// ***************************** -// * M o v e D o w n S h o r t * -// ***************************** -// -// Subroutine called to move <32 bytes down in memory (ie, left-to-right). -// -// Entry conditions: rs = source pointer -// rd = destination pointer -// r0 = #bytes to move (0..31) -// -// Exit conditions: rs = ptr to 1st byte not moved -// rd = ptr to 1st byte not moved -// rc = decremented by #bytes moved -// -// Uses: r0,r6,r7,r8,cr7. -// - -LMoveDownShort: - andi. r6,r0,0x10 // test 0x10 bit in length - mtcrf 0x1,r0 // move count to cr7 so we can test bits - sub rc,rc,r0 // decrement count of bytes remaining to be moved - beq Lmds1 // skip if 0x10 bit in length is 0 - lwz r0,0(rs) // set, so copy up 16 bytes - lwz r6,4(rs) - lwz r7,8(rs) - lwz r8,12(rs) - addi rs,rs,16 - stw r0,0(rd) - stw r6,4(rd) - stw r7,8(rd) - stw r8,12(rd) - addi rd,rd,16 - -Lmds1: - bf 28,Lmds2 // test 0x08 bit - lwz r0,0(rs) - lwz r6,4(rs) - addi rs,rs,8 - stw r0,0(rd) - stw r6,4(rd) - addi rd,rd,8 - -Lmds2: - bf 29,Lmds3 // test 0x4 bit - lwz r0,0(rs) - addi rs,rs,4 - stw r0,0(rd) - addi rd,rd,4 - -Lmds3: - bf 30,Lmds4 // test 0x2 bit - lhz r0,0(rs) - addi rs,rs,2 - sth r0,0(rd) - addi rd,rd,2 - -Lmds4: - bflr 31 // test 0x1 bit, return if 0 - lbz r0,0(rs) - addi rs,rs,1 - stb r0,0(rd) - addi rd,rd,1 - blr - - -// *********************** -// * M o v e U p L o n g * -// *********************** -// -// Subroutine to move 32-byte chunks of memory up (ie, right-to-left.) -// The destination is known to be 32-byte aligned, but the source is -// *not* necessarily aligned. -// -// Entry conditions: rs = last byte moved from source (right-to-left) -// rd = last byte moved into destination -// rc = count of bytes to move -// cr = crCached set iff destination is cacheable -// -// Exit conditions: rs = updated source ptr -// rd = updated destination ptr -// rc = low order 8 bits of count of bytes to move -// -// Uses: r0,r5-r11,fr0-fr3,ctr,cr0,cr6,cr7. -// - -LMoveUpLong: - srwi. r11,rc,5 // r11 <- #32 byte chunks to move - mtctr r11 // prepare loop count - beqlr // return if no chunks to move - andi. r0,rs,7 // is source at least doubleword aligned? - beq Lmup3 // yes, can optimize this case - mtcrf 0x1,rc // save low bits of count - mtcrf 0x2,rc // (one cr at a time, as 604 prefers) - -Lmup1: // loop over each 32-byte-chunk - lwzu r0,-32(rs) - subi rd,rd,32 // prepare destination address for 'dcbz' - lwz r5,4(rs) - lwz r6,8(rs) - lwz r7,12(rs) - lwz r8,16(rs) - lwz r9,20(rs) - lwz r10,24(rs) - lwz r11,28(rs) - stw r0,0(rd) - stw r5,4(rd) - stw r6,8(rd) - stw r7,12(rd) - stw r8,16(rd) - stw r9,20(rd) - stw r10,24(rd) - stw r11,28(rd) - bdnz Lmup1 - mfcr rc // restore low bits of count - blr // return to caller - -// Aligned operands, so use d.p. floating point registers to move data. - -Lmup3: - lfdu f0,-32(rs) - subi rd,rd,32 // prepare destination address for 'dcbz' - lfd f1,8(rs) - lfd f2,16(rs) - lfd f3,24(rs) - stfd f0,0(rd) - stfd f1,8(rd) - stfd f2,16(rd) - stfd f3,24(rd) - bdnz Lmup3 - blr // return to caller - - -// *************************** -// * M o v e D o w n L o n g * -// *************************** -// -// Subroutine to move 32-byte chunks of memory down (ie, left-to-right.) -// The destination is known to be 32-byte aligned, but the source is -// *not* necessarily aligned. -// -// Entry conditions: rs = source ptr (next byte to move) -// rd = dest ptr (next byte to move into) -// rc = count of bytes to move -// cr = crCached set iff destination is cacheable -// -// Exit conditions: rs = updated source ptr -// rd = updated destination ptr -// rc = low order 8 bits of count of bytes to move -// -// Uses: r0,r5-r11,fr0-fr3,ctr,cr0,cr6,cr7. -// - -LMoveDownLong: - srwi. r11,rc,5 // r11 <- #32 byte chunks to move - mtctr r11 // prepare loop count - beqlr // return if no chunks to move - andi. r0,rs,7 // is source at least doubleword aligned? - beq Lmdown3 // yes, can optimize this case - mtcrf 0x1,rc // save low 8 bits of count - mtcrf 0x2,rc // (one cr at a time, as 604 prefers) - -Lmdown1: // loop over each 32-byte-chunk - lwz r0,0(rs) - lwz r5,4(rs) - lwz r6,8(rs) - lwz r7,12(rs) - lwz r8,16(rs) - lwz r9,20(rs) - lwz r10,24(rs) - lwz r11,28(rs) - stw r0,0(rd) - stw r5,4(rd) - stw r6,8(rd) - stw r7,12(rd) - stw r8,16(rd) - stw r9,20(rd) - addi rs,rs,32 - stw r10,24(rd) - stw r11,28(rd) - addi rd,rd,32 - bdnz Lmdown1 - mfcr rc // restore low bits of count - blr // return to caller - -// Aligned operands, so use d.p. floating point registers to move data. - -Lmdown3: - lfd f0,0(rs) - lfd f1,8(rs) - lfd f2,16(rs) - lfd f3,24(rs) - addi rs,rs,32 - stfd f0,0(rd) - stfd f1,8(rd) - stfd f2,16(rd) - stfd f3,24(rd) - addi rd,rd,32 - bdnz Lmdown3 - blr // return to caller - -// -// Register use conventions are as follows: -// -// r0 - temp -// r6 - copy of VMX SPR at entry -// r7 - temp -// r8 - constant -1 (also temp and a string op buffer) -// r9 - constant 16 or -17 (also temp and a string op buffer) -// r10- constant 32 or -33 (also temp and a string op buffer) -// r11- constant 48 or -49 (also temp and a string op buffer) -// r12- chunk count ("c") in long moves -// -// v0 - vp - permute vector -// v1 - va - 1st quadword of source -// v2 - vb - 2nd quadword of source -// v3 - vc - 3rd quadword of source -// v4 - vd - 4th quadword of source -// v5 - vx - temp -// v6 - vy - temp -// v7 - vz - temp - -#define vp v0 -#define va v1 -#define vb v2 -#define vc v3 -#define vd v4 -#define vx v5 -#define vy v6 -#define vz v7 - -#define VRSave 256 - -// kShort should be the crossover point where the long algorithm is faster than the short. -// WARNING: kShort must be >= 64 - -// Yes, I know, we just checked rc > 128 to get here... - -#define kShort 128 -LAltivec: - cmpwi cr1,rc,kShort //(1) too short to bother using vector regs? - sub. r0,rd,rs //(1) must move reverse if (rd-rs)<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> -// <><> S H O R T O P E R A N D S <><> -// <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> - -LAlignedLoop: // word aligned operands (the common case) - lfd f0,0(rs) //(1) - lfd f1,8(rs) //(2) - addi rs,rs,16 //(2) - stfd f0,0(rd) //(3) - stfd f1,8(rd) //(4) - addi rd,rd,16 //(4) - bdnz LAlignedLoop //(4) - -Leftovers: - beqlr- cr7 //(8) done if r7==0, ie no leftover bytes - mtxer r7 //(9) count of bytes to move (1-15) - lswx r8,0,rs - stswx r8,0,rd - blr //(17) - -LUnalignedLoop: // not word aligned, cannot use lfd/stfd - lwz r8,0(rs) //(1) - lwz r9,4(rs) //(2) - lwz r10,8(rs) //(3) - lwz r11,12(rs) //(4) - addi rs,rs,16 //(4) - stw r8,0(rd) //(5) - stw r9,4(rd) //(6) - stw r10,8(rd) //(7) - stw r11,12(rd) //(8) - addi rd,rd,16 //(8) - bdnz LUnalignedLoop //(8) - - b Leftovers - - -// <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> -// <><> S H O R T R E V E R S E M O V E S <><> -// <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> - - // cr0 & r9 <- #doublewords to move (>=0) - // cr1 <- beq if word aligned - // r7 <- #leftover bytes to move (0-15) - -LShortReverse: - cmpwi cr7,r7,0 // leftover bytes? - add rs,rs,rc // point 1 past end of string for reverse moves - add rd,rd,rc - beq- LeftoversReverse // r9==0, ie no words to move - mtctr r9 // set up for quadword loop - bne- cr1,LUnalignedLoopReverse - -LAlignedLoopReverse: // word aligned, so use lfd/stfd - lfd f0,-8(rs) - lfdu f1,-16(rs) - stfd f0,-8(rd) - stfdu f1,-16(rd) - bdnz LAlignedLoopReverse - -LeftoversReverse: - beqlr- cr7 // done if r7==0, ie no leftover bytes - mtxer r7 // count of bytes to move (1-15) - neg r7,r7 // index back by #bytes - lswx r8,r7,rs - stswx r8,r7,rd - blr - -LUnalignedLoopReverse: // not word aligned, cannot use lfd/stfd - lwz r8,-4(rs) - lwz r9,-8(rs) - lwz r10,-12(rs) - lwzu r11,-16(rs) - stw r8,-4(rd) - stw r9,-8(rd) - stw r10,-12(rd) - stwu r11,-16(rd) - bdnz LUnalignedLoopReverse - - b LeftoversReverse - -// <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> -// <><> L O N G O P E R A N D S <><> -// <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> - - // cr6 set (blt) if must move reverse - // r0 <- (rd - rs) - -LMoveLong: - mfspr r6,VRSave //(5) save caller's VMX mask register - stw r6,-4(r1) // use CR save area so we can use r6 later - neg r8,rd //(5) start to compute #bytes to fill in 1st dest quadword - rlwinm r0,r0,0,28,31 //(6) start to determine relative alignment - andi. r7,r8,0xF //(6) r7 <- #bytes to fill in 1st dest quadword - cmpwi cr7,r0,0 //(7) relatively aligned? (ie, 16 bytes apart?) - oris r9,r6,0xFF00 //(7) light bits for regs we use (v0-v7) - mtspr VRSave,r9 //(8) update live register bitmask - blt- cr6,LongReverse //(8) must move reverse direction - sub rc,rc,r7 //(9) adjust length while we wait - beq- LDest16Aligned //(9) r7==0, ie destination already quadword aligned - - // Align destination on a quadword. - - mtxer r7 //(10) set up byte count (1-15) - lswx r8,0,rs // load into r8-r11 - stswx r8,0,rd // store r8-r11 (measured latency on arthur is 7.2 cycles) - add rd,rd,r7 //(18) adjust ptrs - add rs,rs,r7 //(18) - - // Begin preparation for inner loop and "dst" stream. - -LDest16Aligned: - andi. r0,rd,0x10 //(19) is destination cache-block aligned? - li r9,16 //(19) r9 <- constant used to access 2nd quadword - li r10,32 //(20) r10<- constant used to access 3rd quadword - beq- cr7,LAligned //(20) handle relatively aligned operands - lvx va,0,rs //(20) prefetch 1st source quadword - li r11,48 //(21) r11<- constant used to access 4th quadword - lvsl vp,0,rs //(21) get permute vector to left shift - beq LDest32Aligned //(22) destination already cache-block aligned - - // Copy 16 bytes to align destination on 32-byte (cache block) boundary - // to maximize store gathering. - - lvx vb,r9,rs //(23) get 2nd source qw - subi rc,rc,16 //(23) adjust count - addi rs,rs,16 //(24) adjust source ptr - vperm vx,va,vb,vp //(25) vx <- 1st destination qw - vor va,vb,vb //(25) va <- vb - stvx vx,0,rd //(26) assuming store Q deep enough to avoid latency - addi rd,rd,16 //(26) adjust dest ptr - - // Destination 32-byte aligned, source alignment unknown. - -LDest32Aligned: - srwi. r12,rc,6 //(27) r12<- count of 64-byte chunks to move - rlwinm r7,rc,28,30,31 //(27) r7 <- count of 16-byte chunks to move - cmpwi cr1,r7,0 //(28) remember if any 16-byte chunks - rlwinm r8,r12,0,26,31 //(29) mask chunk count down to 0-63 - subi r0,r8,1 //(30) r8==0? - beq- LNoChunks //(30) r12==0, ie no chunks to move - rlwimi r8,r0,0,25,25 //(31) if r8==0, then r8 <- 64 - li r0,64 //(31) r0 <- used to get 1st quadword of next chunk - sub. r12,r12,r8 //(32) adjust chunk count, set cr0 - mtctr r8 //(32) set up loop count - li r8,96 //SKP - li r6,128 //SKP - // Inner loop for unaligned sources. We copy 64 bytes per iteration. - // We loop at most 64 times, then reprime the "dst" and loop again for - // the next 4KB. This loop is tuned to keep the CPU flat out, which - // means we need to execute a lvx or stvx every cycle. - -LoopBy64: - dcbt rs,r8 //SKP - dcbt rs,r6 //SKP - lvx vb,r9,rs //(1) 2nd source quadword (1st already in va) - lvx vc,r10,rs //(2) 3rd - lvx vd,r11,rs //(3) 4th - vperm vx,va,vb,vp //(3) vx <- 1st destination quadword - lvx va,rs,r0 //(4) get 1st qw of next 64-byte chunk (r0 must be RB!) - vperm vy,vb,vc,vp //(4) vy <- 2nd dest qw - stvx vx,0,rd //(5) - vperm vz,vc,vd,vp //(5) vz <- 3rd dest qw - stvx vy,r9,rd //(6) - vperm vx,vd,va,vp //(6) vx <- 4th - stvx vz,r10,rd //(7) - addi rs,rs,64 //(7) - stvx vx,r11,rd //(8) - addi rd,rd,64 //(8) - bdnz LoopBy64 //(8) - - // End of inner loop. Should we reprime dst stream and restart loop? - // This block is only executed when we're moving more than 4KB. - // It is usually folded out because cr0 is set in the loop prologue. - - beq+ LNoChunks // r12==0, ie no more chunks to move - sub. r12,r12,r0 // set cr0 if more than 4KB remain to xfer - mtctr r0 // initialize loop count to 64 - b LoopBy64 // restart inner loop, xfer another 4KB - - // Fewer than 64 bytes remain to be moved. - -LNoChunks: // r7 and cr1 are set with the number of QWs - andi. rc,rc,0xF //(33) rc <- leftover bytes - beq- cr1,LCleanup //(33) r7==0, ie fewer than 16 bytes remaining - mtctr r7 //(34) we will loop over 1-3 QWs - -LoopBy16: - lvx vb,r9,rs //(1) vb <- 2nd source quadword - addi rs,rs,16 //(1) - vperm vx,va,vb,vp //(3) vx <- next destination quadword - vor va,vb,vb //(3) va <- vb - stvx vx,0,rd //(4) assuming store Q is deep enough to mask latency - addi rd,rd,16 //(4) - bdnz LoopBy16 //(4) - - // Move remaining bytes in last quadword. rc and cr0 have the count. - -LCleanup: - lwz r6,-4(r1) // load VRSave from CR save area - mtspr VRSave,r6 //(35) restore caller's live-register bitmask - beqlr //(36) rc==0, ie no leftovers, so done - mtxer rc //(37) load byte count (1-15) - lswx r8,0,rs - stswx r8,0,rd - blr //(45) - - -// <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> -// <><> L O N G A L I G N E D M O V E S <><> -// <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> - - // rs, rd <- both quadword aligned - // cr0 <- beq if dest is cache block (32-byte) aligned - // r9 <- 16 - // r10 <- 32 - -LAligned: - lvx va,0,rs // prefetch 1st source quadword - li r11,48 // r11<- constant used to access 4th quadword - beq LAligned32 // destination already cache-block aligned - - // Copy 16 bytes to align destination on 32-byte (cache block) boundary - // to maximize store gathering. - - subi rc,rc,16 // adjust count - addi rs,rs,16 // adjust source ptr - stvx va,0,rd // assuming store Q deep enough to avoid latency - addi rd,rd,16 // adjust dest ptr - - // Destination 32-byte aligned, source 16-byte aligned. Set up for inner loop. - -LAligned32: - srwi. r12,rc,6 // r12<- count of 64-byte chunks to move - rlwinm r7,rc,28,30,31 // r7 <- count of 16-byte chunks to move - cmpwi cr1,r7,0 // remember if any 16-byte chunks - rlwinm r8,r12,0,26,31 // mask chunk count down to 0-63 - subi r0,r8,1 // r8==0? - beq- LAlignedNoChunks // r12==0, ie no chunks to move - rlwimi r8,r0,0,25,25 // if r8==0, then r8 <- 64 - li r0,64 // r0 <- used at end of loop - sub. r12,r12,r8 // adjust chunk count, set cr0 - mtctr r8 // set up loop count - li r8,96 //SKP - li r6,128 //SKP - - // Inner loop for aligned sources. We copy 64 bytes per iteration. - -LAlignedLoopBy64: - dcbt rs,r8 //SKP - dcbt rs,r6 //SKP - lvx va,0,rs //(1) - lvx vb,r9,rs //(2) - lvx vc,r10,rs //(3) - lvx vd,r11,rs //(4) - addi rs,rs,64 //(4) - stvx va,0,rd //(5) - stvx vb,r9,rd //(6) - stvx vc,r10,rd //(7) - stvx vd,r11,rd //(8) - addi rd,rd,64 //(8) - bdnz LAlignedLoopBy64 //(8) - - // End of inner loop. Loop again for next 4KB iff any. - - beq+ LAlignedNoChunks // r12==0, ie no more chunks to move - sub. r12,r12,r0 // set cr0 if more than 4KB remain to xfer - mtctr r0 // reinitialize loop count to 64 - b LAlignedLoopBy64 // restart inner loop, xfer another 4KB - - // Fewer than 64 bytes remain to be moved. - -LAlignedNoChunks: // r7 and cr1 are set with the number of QWs - andi. rc,rc,0xF // rc <- leftover bytes - beq- cr1,LCleanup // r7==0, ie fewer than 16 bytes remaining - mtctr r7 // we will loop over 1-3 QWs - -LAlignedLoopBy16: - lvx va,0,rs // get next quadword - addi rs,rs,16 - stvx va,0,rd - addi rd,rd,16 - bdnz LAlignedLoopBy16 - - b LCleanup // handle last 0-15 bytes, if any - - -// <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> -// <><> L O N G R E V E R S E M O V E S <><> -// <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> - - // Reverse moves. These involve overlapping operands, with the source - // lower in memory (lower addresses) than the destination. They must be - // done right-to-left, ie from high addresses down to low addresses. - // Throughout this code, we maintain rs and rd as pointers one byte past - // the end of the untransferred operands. - // - // The byte count is >=kShort and the following registers are already loaded: - // - // r6 - VMX mask at entry - // cr7 - beq if relatively aligned - // - -LongReverse: - add rd,rd,rc // update source/dest ptrs to be 1 byte past end - add rs,rs,rc - andi. r7,rd,0xF // r7 <- #bytes needed to move to align destination - sub rc,rc,r7 // adjust length while we wait - sub rs,rs,r7 // adjust ptrs by #bytes to xfer, also while we wait - sub rd,rd,r7 - beq- LDest16AlignedReverse - - // Align destination on a quadword. Note that we do NOT align on a cache - // block boundary for store gathering etc// since all these operands overlap - // many dest cache blocks will already be in the L1, so its not clear that - // this would be a win. - - mtxer r7 // load byte count - lswx r8,0,rs - stswx r8,0,rd - - // Prepare for inner loop and start "dstst" stream. Frankly, its not - // clear whether "dst" or "dstst" would be better// somebody should - // measure. We use "dstst" because, being overlapped, at least some - // source cache blocks will also be stored into. - -LDest16AlignedReverse: - srwi. r12,rc,6 // r12 <- count of 64-byte chunks to move - rlwinm r0,rc,11,9,15 // position quadword count for dst - rlwinm r11,r12,0,26,31 // mask chunk count down to 0-63 - li r9,-17 // r9 <- constant used to access 2nd quadword - oris r0,r0,0x0100 // set dst block size to 1 qw - li r10,-33 // r10<- constant used to access 3rd quadword - ori r0,r0,0xFFE0 // set dst stride to -16 bytes - li r8,-1 // r8<- constant used to access 1st quadword - dstst rs,r0,3 // start stream 0 - subi r0,r11,1 // r11==0 ? - lvx va,r8,rs // prefetch 1st source quadword - rlwinm r7,rc,28,30,31 // r7 <- count of 16-byte chunks to move - lvsl vp,0,rs // get permute vector to right shift - cmpwi cr1,r7,0 // remember if any 16-byte chunks - beq- LNoChunksReverse // r12==0, so skip inner loop - rlwimi r11,r0,0,25,25 // if r11==0, then r11 <- 64 - sub. r12,r12,r11 // adjust chunk count, set cr0 - mtctr r11 // set up loop count - li r11,-49 // r11<- constant used to access 4th quadword - li r0,-64 // r0 <- used for several purposes - beq- cr7,LAlignedLoopBy64Reverse - - // Inner loop for unaligned sources. We copy 64 bytes per iteration. - -LoopBy64Reverse: - lvx vb,r9,rs //(1) 2nd source quadword (1st already in va) - lvx vc,r10,rs //(2) 3rd quadword - lvx vd,r11,rs //(3) 4th - vperm vx,vb,va,vp //(3) vx <- 1st destination quadword - lvx va,rs,r0 //(4) get 1st qw of next 64-byte chunk (note r0 must be RB) - vperm vy,vc,vb,vp //(4) vy <- 2nd dest qw - stvx vx,r8,rd //(5) - vperm vz,vd,vc,vp //(5) vz <- 3rd destination quadword - stvx vy,r9,rd //(6) - vperm vx,va,vd,vp //(6) vx <- 4th qw - stvx vz,r10,rd //(7) - subi rs,rs,64 //(7) - stvx vx,r11,rd //(8) - subi rd,rd,64 //(8) - bdnz LoopBy64Reverse //(8) - - // End of inner loop. Should we reprime dst stream and restart loop? - // This block is only executed when we're moving more than 4KB. - // It is usually folded out because cr0 is set in the loop prologue. - - beq+ LNoChunksReverse // r12==0, ie no more chunks to move - lis r8,0x0440 // dst control: 64 4-qw blocks - add. r12,r12,r0 // set cr0 if more than 4KB remain to xfer - ori r8,r8,0xFFC0 // stride is -64 bytes - dstst rs,r8,3 // restart the prefetch stream - li r8,64 // inner loop count - mtctr r8 // initialize loop count to 64 - li r8,-1 // restore qw1 offset for inner loop - b LoopBy64Reverse // restart inner loop, xfer another 4KB - - // Fewer than 64 bytes remain to be moved. - -LNoChunksReverse: // r7 and cr1 are set with the number of QWs - andi. rc,rc,0xF // rc <- leftover bytes - beq- cr1,LCleanupReverse // r7==0, ie fewer than 16 bytes left - mtctr r7 - beq- cr7,LAlignedLoopBy16Reverse - -LoopBy16Reverse: - lvx vb,r9,rs // vb <- 2nd source quadword - subi rs,rs,16 - vperm vx,vb,va,vp // vx <- next destination quadword - vor va,vb,vb // va <- vb - stvx vx,r8,rd - subi rd,rd,16 - bdnz LoopBy16Reverse - - // Fewer that 16 bytes remain to be moved. - -LCleanupReverse: // rc and cr0 set with remaining byte count - lwz r6,-4(r1) // load VRSave from CR save area - mtspr VRSave,r6 // restore caller's live-register bitmask - beqlr // rc==0, ie no leftovers so done - neg r7,rc // get -(#bytes) - mtxer rc // byte count - lswx r8,r7,rs - stswx r8,r7,rd - blr - - -// <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> -// <><> A L I G N E D L O N G R E V E R S E M O V E S <><> -// <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> - - // Inner loop. We copy 64 bytes per iteration. - -LAlignedLoopBy64Reverse: - lvx va,r8,rs //(1) - lvx vb,r9,rs //(2) - lvx vc,r10,rs //(3) - lvx vd,r11,rs //(4) - subi rs,rs,64 //(4) - stvx va,r8,rd //(5) - stvx vb,r9,rd //(6) - stvx vc,r10,rd //(7) - stvx vd,r11,rd //(8) - subi rd,rd,64 //(8) - bdnz LAlignedLoopBy64Reverse //(8) - - // End of inner loop. Loop for next 4KB iff any. - - beq+ LNoChunksReverse // r12==0, ie no more chunks to move - lis r8,0x0440 // dst control: 64 4-qw blocks - add. r12,r12,r0 // r12 <- r12 - 64, set cr0 - ori r8,r8,0xFFC0 // stride is -64 bytes - dstst rs,r8,3 // restart the prefetch stream - li r8,64 // inner loop count - mtctr r8 // initialize loop count to 64 - li r8,-1 // restore qw1 offset for inner loop - b LAlignedLoopBy64Reverse - - // Loop to copy leftover quadwords (1-3). - -LAlignedLoopBy16Reverse: - lvx va,r8,rs // get next qw - subi rs,rs,16 - stvx va,r8,rd - subi rd,rd,16 - bdnz LAlignedLoopBy16Reverse - - b LCleanupReverse // handle up to 15 bytes in last qw diff --git a/gen.subproj/ppc.subproj/bzero.s b/gen.subproj/ppc.subproj/bzero.s deleted file mode 100644 index f320437..0000000 --- a/gen.subproj/ppc.subproj/bzero.s +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ -/* Copyright (c) 1992, 1997 NeXT Software, Inc. All rights reserved. - * - * File: libc/gen/ppc/bzero.s - * - * HISTORY - * 24-Jan-1997 Umesh Vaishampayan (umeshv@NeXT.com) - * Ported to PPC. - * 18-Jan-93 Derek B Clegg (dclegg@next.com) - * Created. - * - * void bzero(void *s, size_t n); - * - * Description: - * The `bzero' function copies a zero into the first `n' bytes of - * the object pointed to by `s'. - * Returns: - * The `bzero' function does not return a value. - */ -#import -#import - -#define a8 ep -#define a9 at - -.at_off - -LEAF(_bzero) - li32 a2,0 // Clear registers a2 - a9. - li32 a3,0 - li32 a4,0 - li32 a5,0 - li32 a6,0 - li32 a7,0 - li32 a8,0 - li32 a9,0 - andi. zt,a0,31 // We want `s' to be 32-byte aligned. - subfic zt,zt,32 // Get the number of bytes to start with. - cmplw a1,zt // Don't move more than we were asked to. - ble- L_finish - mtxer zt // Load xer with the number of bytes to move. - stswx a2,0,a0 // Store into `s'. - add a0,a0,zt // Advance the pointer; a0 is now aligned. - sub a1,a1,zt // Calculate the bytes remaining to move. - srwi. zt,a1,5 // Get the number of 32-byte blocks to move. - beq- L_finish // Branch if fewer than 32 bytes are left. - mtctr zt // Setup counter for loop. - andi. a1,a1,31 // Get the number of bytes left over. -L_loop: - dcbz 0,a0 // Clear 32 bytes. - addi a0,a0,32 // Advance the pointer. - bdnz+ L_loop // Continue if there are still blocks to move. - - /* At this point, `a1' contains the number of bytes left to move. */ -L_finish: - mtxer a1 // Setup xer with # of bytes left to move. - stswx a2,0,a0 // Store. - blr -END(_bzero) diff --git a/gen.subproj/ppc.subproj/strlen.s b/gen.subproj/ppc.subproj/strlen.s deleted file mode 100644 index baa1216..0000000 --- a/gen.subproj/ppc.subproj/strlen.s +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ -/* Copyright (c) 1992, 1997 NeXT Software, Inc. All rights reserved. - * - * File: libc/gen/ppc/strlen.s - * - * HISTORY - * 24-Jan-1997 Umesh Vaishampayan (umeshv@NeXT.com) - * Ported to PPC. - * 12-Nov-92 Derek B Clegg (dclegg@next.com) - * Created. - * - * size_t strlen(const char *s); - * - * Description: - * - * Returns: - */ -#import -#import - -/* size_t strlen(const char *s); */ - -#define a8 ep -#define a9 at - -.at_off - -#define check_for_zero(reg, tmp, found_zero, checked_all) \ - extrwi. tmp,reg,8,0 @\ - beq- found_zero @\ - bdz- checked_all @\ - extrwi. tmp,reg,8,8 @\ - beq- found_zero @\ - bdz- checked_all @\ - extrwi. tmp,reg,8,16 @\ - beq- found_zero @\ - bdz- checked_all @\ - extrwi. tmp,reg,8,24 @\ - beq- found_zero @\ - bdz- checked_all - -#define check_32(tmp, found_zero) \ - check_for_zero(a2, tmp, found_zero, 1f) @\ - check_for_zero(a3, tmp, found_zero, 1f) @\ - check_for_zero(a4, tmp, found_zero, 1f) @\ - check_for_zero(a5, tmp, found_zero, 1f) @\ - check_for_zero(a6, tmp, found_zero, 1f) @\ - check_for_zero(a7, tmp, found_zero, 1f) @\ - check_for_zero(a8, tmp, found_zero, 1f) @\ - check_for_zero(a9, tmp, found_zero, 1f) @\ -1: - -LEAF(_strlen) - dcbt 0,a0 // Try to load the cache line. - andi. a1,a0,31 // We want to be 32-byte aligned. - subfic a1,a1,32 // Get the number of bytes to start with. - mtxer a1 // Setup xer for load. - lswx a2,0,a0 // Load the bytes. - mtctr a1 // Setup ctr for zero check. - check_32(zt, L_found_zero) - - /* Now check 32-byte blocks. At this point, ctr is zero, so we can - * use it as our running count. */ - dcbt a1,a0 // Try to load the cache line. - li32 a2,32 - mtxer a2 - li32 a2,0 - mtctr a2 - -2: lswx a2,a1,a0 // Load 32 bytes. - check_32(zt, L_found_zero) - addi a0,a0,32 // Increment the pointer. - dcbt a1,a0 // Try to load the cache. - b 2b // Loop - -L_found_zero: - mfctr a0 - sub a0,a1,a0 // Get the number of bytes before 0. - blr // Return. -END(_strlen) diff --git a/gen/Makefile.inc b/gen/Makefile.inc new file mode 100644 index 0000000..ed08ce0 --- /dev/null +++ b/gen/Makefile.inc @@ -0,0 +1,139 @@ +# @(#)Makefile.inc 8.6 (Berkeley) 5/4/95 +# $FreeBSD: src/lib/libc/gen/Makefile.inc,v 1.80 2001/08/17 22:09:15 dd Exp $ + +# machine-independent gen sources +.PATH: ${.CURDIR}/${MACHINE_ARCH}/gen ${.CURDIR}/gen + +CFLAGS+= -I${.CURDIR}/pthreads + +SRCS += NSSystemDirectories.c getpagesize.c siginterrupt.c \ + alarm.c getpass.c siglist.c \ + assert.c getttyent.c signal.c \ + getusershell.c sigsetops.c \ + clock.c getvfsbyname.c sleep.c \ + closedir.c stack_logging.c \ + confstr.c strchr.c \ + crypt.c sysconf.c \ + ctermid.c isatty.c sysctl.c \ + isnan.c sysctlbyname.c \ + daemon.c malloc.c syslog.c \ + devname.c nanosleep.c telldir.c \ + difftime.c nice.c termios.c \ + disklabel.c nlist.c time.c \ + err.c opendir.c times.c \ + errlst.c pause.c timezone.c \ + exec.c popen.c ttyname.c \ + fnmatch.c psignal.c ttyslot.c \ + ualarm.c \ + ftok.c raise.c uname.c \ + fts.c unvis.c \ + getbsize.c readdir.c usleep.c \ + getcap.c rewinddir.c utime.c \ + getcwd.c scalable_malloc.c vis.c \ + scandir.c wait.c \ + gethostname.c seekdir.c wait3.c \ + getloadavg.c sethostname.c waitpid.c \ + getlogin.c setlogin.c zone.c \ + getmntinfo.c setmode.c \ + _rand48.c erand48.c lcong48.c mrand48.c seed48.c drand48.c jrand48.c \ + nrand48.c srand48.c lrand48.c basename.c dirname.c arc4random.c \ + strtofflags.c lockf.c readdir_r.c ulimit.c + + +# machine-dependent gen sources +.if exists(${.CURDIR}/${MACHINE_ARCH}/gen/Makefile.inc) +.include "${.CURDIR}/${MACHINE_ARCH}/gen/Makefile.inc" +.endif + +.if ${LIB} == "c" +MAN3+= alarm.3 arc4random.3 clock.3 \ + basename.3 \ + confstr.3 ctermid.3 daemon.3 \ + devname.3 directory.3 dirname.3 \ + err.3 exec.3 fmtcheck.3 fnmatch.3 frexp.3 ftok.3 fts.3 \ + getbootfile.3 getbsize.3 getcap.3 getcwd.3 \ + getdomainname.3 getfsent.3 \ + getgrent.3 getgrouplist.3 gethostname.3 getloadavg.3 \ + getmntinfo.3 getnetgrent.3 getobjformat.3 \ + getpagesize.3 getpass.3 getpeereid.3 getpwent.3 \ + getttyent.3 getusershell.3 getvfsbyname.3 getvfsent.3 \ + glob.3 initgroups.3 isinf.3 \ + ldexp.3 lockf.3 modf.3 msgctl.3 msgget.3 msgrcv.3 msgsnd.3 \ + nice.3 nlist.3 pause.3 popen.3 psignal.3 pwcache.3 \ + raise.3 rand48.3 rfork_thread.3 \ + scandir.3 setjmp.3 setmode.3 \ + siginterrupt.3 signal.3 sigsetops.3 sleep.3 stringlist.3 \ + strtofflags.3 sysconf.3 sysctl.3 syslog.3 tcgetpgrp.3 \ + tcsendbreak.3 tcsetattr.3 tcsetpgrp.3 time.3 times.3 timezone.3 \ + ttyname.3 tzset.3 ualarm.3 uname.3 unvis.3 usleep.3 utime.3 \ + valloc.3 vis.3 + +MLINKS+=arc4random.3 arc4random_addrandom.3 arc4random.3 arc4random_stir.3 +MLINKS+=ctermid.3 ctermid_r.3 +MLINKS+=directory.3 closedir.3 directory.3 dirfd.3 directory.3 opendir.3 \ + directory.3 readdir.3 directory.3 rewinddir.3 directory.3 seekdir.3 \ + directory.3 telldir.3 +MLINKS+=err.3 err_set_exit.3 err.3 err_set_file.3 err.3 errc.3 err.3 errx.3 \ + err.3 verr.3 err.3 verrc.3 err.3 verrx.3 err.3 vwarn.3 err.3 vwarnc.3 \ + err.3 vwarnx.3 err.3 warnc.3 err.3 warn.3 err.3 warnx.3 +MLINKS+=exec.3 execl.3 exec.3 execle.3 exec.3 execlp.3 exec.3 exect.3 \ + exec.3 execv.3 exec.3 execvp.3 +MLINKS+=fts.3 fts_children.3 fts.3 fts_close.3 fts.3 fts_open.3 \ + fts.3 fts_read.3 fts.3 fts_set.3 +MLINKS+=getcap.3 cgetcap.3 getcap.3 cgetclose.3 getcap.3 cgetent.3 \ + getcap.3 cgetfirst.3 getcap.3 cgetmatch.3 getcap.3 cgetnext.3 \ + getcap.3 cgetnum.3 getcap.3 cgetset.3 getcap.3 cgetstr.3 \ + getcap.3 cgetustr.3 +MLINKS+=getcwd.3 getwd.3 +MLINKS+=getdomainname.3 setdomainname.3 +MLINKS+=getfsent.3 endfsent.3 getfsent.3 getfsfile.3 getfsent.3 getfsspec.3 \ + getfsent.3 getfstype.3 getfsent.3 setfsent.3 +MLINKS+=getgrent.3 endgrent.3 getgrent.3 getgrgid.3 getgrent.3 getgrnam.3 \ + getgrent.3 setgrent.3 getgrent.3 setgroupent.3 +MLINKS+=gethostname.3 sethostname.3 +MLINKS+=getnetgrent.3 endnetgrent.3 getnetgrent.3 innetgr.3 \ + getnetgrent.3 setnetgrent.3 +MLINKS+=getpwent.3 endpwent.3 getpwent.3 getpwnam.3 getpwent.3 getpwuid.3 \ + getpwent.3 setpassent.3 getpwent.3 setpwent.3 getpwent.3 setpwfile.3 +MLINKS+=getttyent.3 endttyent.3 getttyent.3 getttynam.3 \ + getttyent.3 isdialuptty.3 getttyent.3 isnettty.3 \ + getttyent.3 setttyent.3 +MLINKS+=getusershell.3 endusershell.3 getusershell.3 setusershell.3 +MLINKS+=getvfsent.3 endvfsent.3 getvfsent.3 getvfsbytype.3 \ + getvfsent.3 setvfsent.3 getvfsent.3 vfsisloadable.3 \ + getvfsent.3 vfsload.3 +MLINKS+=glob.3 globfree.3 +MLINKS+=isinf.3 isnan.3 isinf.3 isnanf.3 +MLINKS+=popen.3 pclose.3 +MLINKS+=psignal.3 sys_siglist.3 psignal.3 sys_signame.3 +MLINKS+=psignal.3 strsignal.3 psignal.3 sys_siglist.3 psignal.3 sys_signame.3 +MLINKS+=pwcache.3 group_from_gid.3 pwcache.3 user_from_uid.3 +MLINKS+=rand48.3 _rand48.3 rand48.3 drand48.3 rand48.3 erand48.3 \ + rand48.3 jrand48.3 rand48.3 lcong48.3 rand48.3 lrand48.3 \ + rand48.3 mrand48.3 rand48.3 nrand48.3 rand48.3 seed48.3 \ + rand48.3 srand48.3 +MLINKS+=scandir.3 alphasort.3 +MLINKS+=strtofflags.3 fflagstostr.3 +MLINKS+=setjmp.3 _longjmp.3 setjmp.3 _setjmp.3 setjmp.3 longjmp.3 \ + setjmp.3 longjmperr.3 setjmp.3 longjmperror.3 \ + setjmp.3 siglongjmp.3 setjmp.3 sigsetjmp.3 +MLINKS+=setmode.3 getmode.3 +MLINKS+=sigsetops.3 sigaddset.3 sigsetops.3 sigdelset.3 \ + sigsetops.3 sigemptyset.3 sigsetops.3 sigfillset.3 \ + sigsetops.3 sigismember.3 +MLINKS+=stringlist.3 sl_add.3 stringlist.3 sl_find.3 \ + stringlist.3 sl_free.3 stringlist.3 sl_init.3 +MLINKS+=sysctl.3 sysctlbyname.3 sysctl.3 sysctlnametomib.3 +MLINKS+=syslog.3 closelog.3 syslog.3 openlog.3 syslog.3 setlogmask.3 \ + syslog.3 vsyslog.3 +MLINKS+=tcsendbreak.3 tcdrain.3 tcsendbreak.3 tcflow.3 tcsendbreak.3 tcflush.3 +MLINKS+=tcsetattr.3 cfgetispeed.3 tcsetattr.3 cfgetospeed.3 \ + tcsetattr.3 cfmakeraw.3 tcsetattr.3 cfsetispeed.3 \ + tcsetattr.3 cfsetospeed.3 tcsetattr.3 cfsetspeed.3 \ + tcsetattr.3 tcgetattr.3 +MLINKS+=ttyname.3 isatty.3 ttyname.3 ttyslot.3 +MLINKS+=tzset.3 tzsetwall.3 +MLINKS+=unvis.3 strunvis.3 unvis.3 strunvisx.3 +MLINKS+=vis.3 strvis.3 vis.3 strvisx.3 +MLINKS+=readdir.3 readdir_r.3 +.endif diff --git a/gen.subproj/NSSystemDirectories.c b/gen/NSSystemDirectories.c similarity index 96% rename from gen.subproj/NSSystemDirectories.c rename to gen/NSSystemDirectories.c index 1e37408..fcbdb05 100644 --- a/gen.subproj/NSSystemDirectories.c +++ b/gen/NSSystemDirectories.c @@ -27,7 +27,7 @@ #import // Names of directories; index into this with NSSearchPathDirectory - 1 -#define numDirs 8 +#define numDirs 10 static const struct { unsigned char invalidDomainMask; // Domains in which this dir does not appear unsigned char alternateDomainMask; // Domains in which this dir uses the alternate domain path @@ -40,7 +40,9 @@ static const struct { {0, 0x8, "Library"}, // Uses alternate form in System domain {0, 0, "Developer"}, {0x9, 0, "Users"}, // Not valid in the System and User domains - {0, 0x8, "Library/Documentation"} // Uses alternate form in System domain + {0, 0x8, "Library/Documentation"}, // Uses alternate form in System domain + {0xe, 0, "Documents"}, // Only valid in user domain + {0x7, 0, "Library/CoreServices"} // Only valid in System domain }; // Ordered list of where to find applications in each domain (the numbers are NSSearchPathDirectory) diff --git a/gen/_rand48.c b/gen/_rand48.c new file mode 100644 index 0000000..990e2c8 --- /dev/null +++ b/gen/_rand48.c @@ -0,0 +1,46 @@ +/* + * Copyright (c) 1993 Martin Birgmeier + * All rights reserved. + * + * You may redistribute unmodified or modified versions of this source + * code provided that the above copyright notice and this and the + * following conditions are retained. + * + * This software is provided ``as is'', and comes with no warranties + * of any kind. I shall in no event be liable for anything that happens + * to anyone/anything when using this software. + */ + +#include "rand48.h" + +unsigned short _rand48_seed[3] = { + RAND48_SEED_0, + RAND48_SEED_1, + RAND48_SEED_2 +}; +unsigned short _rand48_mult[3] = { + RAND48_MULT_0, + RAND48_MULT_1, + RAND48_MULT_2 +}; +unsigned short _rand48_add = RAND48_ADD; + +void +_dorand48(unsigned short xseed[3]) +{ + unsigned long accu; + unsigned short temp[2]; + + accu = (unsigned long) _rand48_mult[0] * (unsigned long) xseed[0] + + (unsigned long) _rand48_add; + temp[0] = (unsigned short) accu; /* lower 16 bits */ + accu >>= sizeof(unsigned short) * 8; + accu += (unsigned long) _rand48_mult[0] * (unsigned long) xseed[1] + + (unsigned long) _rand48_mult[1] * (unsigned long) xseed[0]; + temp[1] = (unsigned short) accu; /* middle 16 bits */ + accu >>= sizeof(unsigned short) * 8; + accu += _rand48_mult[0] * xseed[2] + _rand48_mult[1] * xseed[1] + _rand48_mult[2] * xseed[0]; + xseed[0] = temp[0]; + xseed[1] = temp[1]; + xseed[2] = (unsigned short) accu; +} diff --git a/gen/alarm.3 b/gen/alarm.3 new file mode 100644 index 0000000..d2725b1 --- /dev/null +++ b/gen/alarm.3 @@ -0,0 +1,98 @@ +.\" Copyright (c) 1980, 1991, 1993, 1994 +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)alarm.3 8.2 (Berkeley) 4/19/94 +.\" $FreeBSD: src/lib/libc/gen/alarm.3,v 1.15 2001/10/01 16:08:50 ru Exp $ +.\" +.Dd April 19, 1994 +.Dt ALARM 3 +.Os +.Sh NAME +.Nm alarm +.Nd set signal timer alarm +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft unsigned int +.Fn alarm "unsigned int seconds" +.Sh DESCRIPTION +.Bf -symbolic +This interface is made obsolete by +.Xr setitimer 2 . +.Ef +.Pp +The +.Fn alarm +function sets a timer to deliver the signal +.Dv SIGALRM +to the calling process after the specified number of +.Fa seconds . +If an alarm has already been set with +.Fn alarm +but has not been delivered, another call to +.Fn alarm +will supersede the prior call. +The request +.Fn alarm "0" +voids the current +alarm and the signal SIGALRM will not be delivered. +.Pp +Due to +.Xr setitimer 2 +restriction the maximum number of +.Ar seconds +allowed is 100000000. +.Sh RETURN VALUES +The return value of +.Fn alarm +is the amount of time left on the timer from a previous call to +.Fn alarm . +If no alarm is currently set, the return value is 0. +.Sh SEE ALSO +.Xr setitimer 2 , +.Xr sigaction 2 , +.Xr sigpause 2 , +.Xr sigvec 2 , +.Xr signal 3 , +.Xr sleep 3 , +.Xr ualarm 3 , +.Xr usleep 3 +.\" .Sh STANDARDS +.\" The +.\" .Fn alarm +.\" function conforms to +.\" .St -p1003.1-90 . +.Sh HISTORY +An +.Fn alarm +function appeared in +.At v7 . diff --git a/gen.subproj/alarm.c b/gen/alarm.c similarity index 100% rename from gen.subproj/alarm.c rename to gen/alarm.c diff --git a/gen/arc4random.3 b/gen/arc4random.3 new file mode 100644 index 0000000..85e6eb0 --- /dev/null +++ b/gen/arc4random.3 @@ -0,0 +1,89 @@ +.\" $OpenBSD: arc4random.3,v 1.2 1997/04/27 22:40:25 angelos Exp $ +.\" Copyright 1997 Niels Provos +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by Niels Provos. +.\" 4. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" Manual page, using -mandoc macros +.\" $FreeBSD: src/lib/libc/gen/arc4random.3,v 1.12 2001/10/01 16:08:50 ru Exp $ +.\" +.Dd April 15, 1997 +.Dt ARC4RANDOM 3 +.Os +.Sh NAME +.Nm arc4random , +.Nm arc4random_stir , +.Nm arc4random_addrandom +.Nd arc4 random number generator +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft u_int32_t +.Fn arc4random "void" +.Ft void +.Fn arc4random_stir "void" +.Ft void +.Fn arc4random_addrandom "unsigned char *dat" "int datlen" +.Sh DESCRIPTION +The +.Fn arc4random +function uses the key stream generator employed by the +arc4 cipher, which uses 8*8 8 bit S-Boxes. +The S-Boxes +can be in about +.if t 2\u\s71700\s10\d +.if n (2**1700) +states. +.Pp +The +.Fn arc4random_stir +function reads data from +.Pa /dev/urandom +and uses it to permute the S-Boxes via +.Fn arc4random_addrandom . +.Pp +There is no need to call +.Fn arc4random_stir +before using +.Fn arc4random , +since +.Fn arc4random +automatically initializes itself. +.Sh SEE ALSO +.Xr rand 3 , +.Xr random 3 , +.Xr srandomdev 3 +.Sh HISTORY +.Pa RC4 +has been designed by RSA Data Security, Inc. +It was posted anonymously +to the USENET and was confirmed to be equivalent by several sources who +had access to the original cipher. +Since +.Pa RC4 +used to be a trade secret, the cipher is now referred to as +.Pa ARC4 . diff --git a/gen/arc4random.c b/gen/arc4random.c new file mode 100644 index 0000000..0dce7ef --- /dev/null +++ b/gen/arc4random.c @@ -0,0 +1,177 @@ +/* $FreeBSD: src/lib/libc/gen/arc4random.c,v 1.4 2000/01/27 23:06:13 jasone Exp $ */ + +/* + * Arc4 random number generator for OpenBSD. + * Copyright 1996 David Mazieres . + * + * Modification and redistribution in source and binary forms is + * permitted provided that due credit is given to the author and the + * OpenBSD project (for instance by leaving this copyright notice + * intact). + */ + +/* + * This code is derived from section 17.1 of Applied Cryptography, + * second edition, which describes a stream cipher allegedly + * compatible with RSA Labs "RC4" cipher (the actual description of + * which is a trade secret). The same algorithm is used as a stream + * cipher called "arcfour" in Tatu Ylonen's ssh package. + * + * Here the stream cipher has been modified always to include the time + * when initializing the state. That makes it impossible to + * regenerate the same random sequence twice, so this can't be used + * for encryption, but will generate good random numbers. + * + * RC4 is a registered trademark of RSA Laboratories. + */ + +#include +#include +#include +#include +#include + +struct arc4_stream { + u_int8_t i; + u_int8_t j; + u_int8_t s[256]; +}; + +static int rs_initialized; +static struct arc4_stream *rs = NULL; + +static inline void +arc4_init(as) + struct arc4_stream *as; +{ + int n; + + for (n = 0; n < 256; n++) + as->s[n] = n; + as->i = 0; + as->j = 0; +} + +static inline void +arc4_addrandom(as, dat, datlen) + struct arc4_stream *as; + u_char *dat; + int datlen; +{ + int n; + u_int8_t si; + + as->i--; + for (n = 0; n < 256; n++) { + as->i = (as->i + 1); + si = as->s[as->i]; + as->j = (as->j + si + dat[n % datlen]); + as->s[as->i] = as->s[as->j]; + as->s[as->j] = si; + } +} + +static void +arc4_stir(as) + struct arc4_stream *as; +{ + int fd; + struct { + struct timeval tv; + pid_t pid; + u_int8_t rnd[128 - sizeof(struct timeval) - sizeof(pid_t)]; + } rdat; + + gettimeofday(&rdat.tv, NULL); + rdat.pid = getpid(); + fd = open("/dev/urandom", O_RDONLY, 0); + if (fd >= 0) { + (void) read(fd, rdat.rnd, sizeof(rdat.rnd)); + close(fd); + } + /* fd < 0? Ah, what the heck. We'll just take whatever was on the + * stack... */ + + arc4_addrandom(as, (void *) &rdat, sizeof(rdat)); +} + +static inline u_int8_t +arc4_getbyte(as) + struct arc4_stream *as; +{ + u_int8_t si, sj; + + as->i = (as->i + 1); + si = as->s[as->i]; + as->j = (as->j + si); + sj = as->s[as->j]; + as->s[as->i] = sj; + as->s[as->j] = si; + return (as->s[(si + sj) & 0xff]); +} + +static inline u_int32_t +arc4_getword(as) + struct arc4_stream *as; +{ + u_int32_t val; + val = arc4_getbyte(as) << 24; + val |= arc4_getbyte(as) << 16; + val |= arc4_getbyte(as) << 8; + val |= arc4_getbyte(as); + return val; +} + +void +arc4random_stir() +{ + if ( rs == NULL ) { + rs = malloc( sizeof(struct arc4_stream) ); + if( rs == NULL ) + return ; /* Hmmm. */ + } + if (!rs_initialized) { + arc4_init(rs); + rs_initialized = 1; + } + arc4_stir(rs); +} + +void +arc4random_addrandom(dat, datlen) + u_char *dat; + int datlen; +{ + if (!rs_initialized) + arc4random_stir(); + arc4_addrandom(rs, dat, datlen); +} + +u_int32_t +arc4random() +{ + if (!rs_initialized) + arc4random_stir(); + return arc4_getword(rs); +} + +#if 0 +/*-------- Test code for i386 --------*/ +#include +#include +int +main(int argc, char **argv) +{ + const int iter = 1000000; + int i; + pctrval v; + + v = rdtsc(); + for (i = 0; i < iter; i++) + arc4random(); + v = rdtsc() - v; + v /= iter; + + printf("%qd cycles\n", v); +} +#endif diff --git a/gen.subproj/assert.c b/gen/assert.c similarity index 100% rename from gen.subproj/assert.c rename to gen/assert.c diff --git a/gen/authentication.c b/gen/authentication.c new file mode 100644 index 0000000..54ac361 --- /dev/null +++ b/gen/authentication.c @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "authentication.h" + +int isAuthenticatedAsAdministrator(void) +{ + if (isAuthenticatedAsRoot()) { + return 1; + } + // otherwise ... + return isAuthenticatedAsAdministratorForTask(0); +} + +int isAuthenticatedAsAdministratorForTask(int taskNum) +{ + int admin = 0; + uid_t ruid; + + if (isAuthenticatedAsRoot()) { + return 1; + } + + ruid = getuid(); + + if (ruid) { + gid_t groups[NGROUPS_MAX]; + int numgroups; + + /* + * Only allow those in group taskNum group (By default admin) to authenticate. + */ + if ((numgroups = getgroups(NGROUPS_MAX, groups)) > 0) { + int i; + gid_t admingid = 0; + struct group *admingroup; + + if ((admingroup = getgrnam(groupNameForTask(taskNum))) != NULL) { + admingid = admingroup->gr_gid; + + for (i = 0; i < numgroups; i++) { + if (groups[i] == admingid) { + admin = 1; + break; + } + } + } + + } + } + // otherwise + return admin; +} + +int isAuthenticatedAsRoot(void) +{ + if (getuid() == 0) { + return 1; + } + return 0; +} + +char *groupNameForTask(int taskNum) +{ + if (taskNum == 0) + return "admin"; + + return "admin"; +} + diff --git a/gen/basename.3 b/gen/basename.3 new file mode 100644 index 0000000..3385318 --- /dev/null +++ b/gen/basename.3 @@ -0,0 +1,101 @@ +.\" +.\" Copyright (c) 1997 Todd C. Miller +.\" 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. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +.\" AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +.\" THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +.\" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +.\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +.\" OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" $OpenBSD: basename.3,v 1.12 2000/04/18 03:01:25 aaron Exp $ +.\" $FreeBSD: src/lib/libc/gen/basename.3,v 1.4 2001/10/01 16:08:50 ru Exp $ +.\" +.Dd August 17, 1997 +.Dt BASENAME 3 +.Os +.Sh NAME +.Nm basename +.Nd extract the base portion of a pathname +.Sh SYNOPSIS +.In libgen.h +.Ft char * +.Fn basename "const char *path" +.Sh DESCRIPTION +The +.Fn basename +function +returns the last component from the pathname pointed to by +.Ar path , +deleting any trailing +.Sq \&/ +characters. +If +.Ar path +consists entirely of +.Sq \&/ +characters, a pointer to the string +.Qq \&/ +is returned. +If +.Ar path +is a null pointer or the empty string, a pointer to the string +.Qq \&. +is returned. +.Sh RETURN VALUES +On successful completion, +.Fn basename +returns a pointer to the last component of +.Ar path . +.Pp +If +.Fn basename +fails, a null pointer is returned and the global variable +.Va errno +is set to indicate the error. +.Sh ERRORS +The following error codes may be set in +.Va errno : +.Bl -tag -width Er +.It Bq Er ENAMETOOLONG +The path component to be returned was larger than +.Dv MAXPATHLEN . +.El +.Sh WARNINGS +.Fn basename +returns a pointer to internal static storage space that will be overwritten +by subsequent calls. +.Sh SEE ALSO +.Xr basename 1 , +.Xr dirname 1 , +.Xr dirname 3 +.Sh STANDARDS +The +.Fn basename +function conforms to +.St -xpg4.2 . +.Sh HISTORY +The +.Fn basename +function first appeared in +.Ox 2.2 +and +.Fx 4.2 . +.Sh AUTHORS +Todd C. Miller diff --git a/gen/basename.c b/gen/basename.c new file mode 100644 index 0000000..a138177 --- /dev/null +++ b/gen/basename.c @@ -0,0 +1,83 @@ +/* $OpenBSD: basename.c,v 1.4 1999/05/30 17:10:30 espie Exp $ */ +/* $FreeBSD: src/lib/libc/gen/basename.c,v 1.1.2.2 2001/07/23 10:13:04 dd Exp $ */ + +/* + * Copyright (c) 1997 Todd C. Miller + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#if defined(LIBC_RCS) && !defined(lint) +static char rcsid[] = "$OpenBSD: basename.c,v 1.4 1999/05/30 17:10:30 espie Exp $"; +#endif /* not lint */ + +#include +#include +#include +#include +#include + +char * +basename(path) + const char *path; +{ + static char *bname = NULL; + register const char *endp, *startp; + + if( bname == NULL ) { + bname = malloc(MAXPATHLEN); + if( bname == NULL ) + return NULL; + } + + /* Empty or NULL string gets treated as "." */ + if (path == NULL || *path == '\0') { + (void)strcpy(bname, "."); + return(bname); + } + + /* Strip trailing slashes */ + endp = path + strlen(path) - 1; + while (endp > path && *endp == '/') + endp--; + + /* All slashes becomes "/" */ + if (endp == path && *endp == '/') { + (void)strcpy(bname, "/"); + return(bname); + } + + /* Find the start of the base */ + startp = endp; + while (startp > path && *(startp - 1) != '/') + startp--; + + if (endp - startp + 2 > MAXPATHLEN) { + errno = ENAMETOOLONG; + return(NULL); + } + (void)strncpy(bname, startp, endp - startp + 1); + bname[endp - startp + 1] = '\0'; + return(bname); +} diff --git a/gen/clock.3 b/gen/clock.3 new file mode 100644 index 0000000..2f053a6 --- /dev/null +++ b/gen/clock.3 @@ -0,0 +1,80 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)clock.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/clock.3,v 1.10 2001/11/05 21:30:43 dwmalone Exp $ +.\" +.Dd June 4, 1993 +.Dt CLOCK 3 +.Os +.Sh NAME +.Nm clock +.Nd determine processor time used +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In time.h +.Ft clock_t +.Fn clock void +.Sh DESCRIPTION +The +.Fn clock +function +determines the amount of processor time used since the invocation of the +calling process, measured in +.Dv CLOCKS_PER_SEC Ns s +of a second. +.Sh RETURN VALUES +The +.Fn clock +function returns the amount of time used unless an error occurs, in which +case the return value is \-1. +.Sh SEE ALSO +.Xr getrusage 2 , +.Xr clocks 7 +.Sh STANDARDS +The +.Fn clock +function conforms to +.St -isoC . +However, +.St -susv2 +requires +.Dv CLOCKS_PER_SEC +to be defined as one million. +.Fx +does not conform to this requirement; +changing the value would introduce binary incompatibility +and one million is still inadequate on modern processors. diff --git a/gen.subproj/clock.c b/gen/clock.c similarity index 100% rename from gen.subproj/clock.c rename to gen/clock.c diff --git a/gen.subproj/closedir.c b/gen/closedir.c similarity index 100% rename from gen.subproj/closedir.c rename to gen/closedir.c diff --git a/gen/confstr.3 b/gen/confstr.3 new file mode 100644 index 0000000..ccecf7e --- /dev/null +++ b/gen/confstr.3 @@ -0,0 +1,136 @@ +.\" Copyright (c) 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)confstr.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/confstr.3,v 1.11 2001/10/01 16:08:50 ru Exp $ +.\" +.Dd June 18, 2001 +.Dt CONFSTR 3 +.Os +.Sh NAME +.Nm confstr +.Nd get string-valued configurable variables +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft size_t +.Fn confstr "int name" "char *buf" "size_t len" +.Sh DESCRIPTION +This interface is specified by +.\" .St -p1003.1-200x . +.Tn POSIX . +A more flexible (but non-portable) interface is provided by +.Xr sysctl 3 . +.Pp +The +.Fn confstr +function provides a method for applications to get configuration +defined string values. +Shell programmers needing access to these parameters should use the +.Xr getconf 1 +utility. +.Pp +The +.Fa name +argument specifies the system variable to be queried. +Symbolic constants for each name value are found in the include file +.Aq Pa unistd.h . +The +.Fa len +argument specifies the size of the buffer referenced by the +argument +.Fa buf . +If +.Fa len +is non-zero, +.Fa buf +is a non-null pointer, and +.Fa name +has a value, up to +.Fa len +\- 1 bytes of the value are copied into the buffer +.Fa buf . +The copied value is always null terminated. +.Pp +The available values are as follows: +.Pp +.Bl -tag -width 6n +.Pp +.It Li _CS_PATH +Return a value for the +.Ev PATH +environment variable that finds all the standard utilities. +.El +.Sh RETURN VALUES +If the call to +.Fn confstr +is not successful, \-1 is returned and +.Va errno +is set appropriately. +Otherwise, if the variable does not have a configuration defined value, +0 is returned and +.Va errno +is not modified. +Otherwise, the buffer size needed to hold the entire configuration-defined +value is returned. +If this size is greater than the argument +.Fa len , +the string in +.Fa buf +was truncated. +.Sh ERRORS +The +.Fn confstr +function may fail and set +.Va errno +for any of the errors specified for the library functions +.Xr malloc 3 +and +.Xr sysctl 3 . +.Pp +In addition, the following errors may be reported: +.Bl -tag -width Er +.It Bq Er EINVAL +The value of the +.Fa name +argument is invalid. +.El +.Sh SEE ALSO +.Xr getconf 1 , +.Xr pathconf 2 , +.Xr sysconf 3 , +.Xr sysctl 3 +.Sh HISTORY +The +.Fn confstr +function first appeared in +.Bx 4.4 . diff --git a/gen.subproj/confstr.c b/gen/confstr.c similarity index 100% rename from gen.subproj/confstr.c rename to gen/confstr.c diff --git a/gen.subproj/crypt.c b/gen/crypt.c similarity index 100% rename from gen.subproj/crypt.c rename to gen/crypt.c diff --git a/gen/ctermid.3 b/gen/ctermid.3 new file mode 100644 index 0000000..8206dcd --- /dev/null +++ b/gen/ctermid.3 @@ -0,0 +1,109 @@ +.\" Copyright (c) 1990, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)ctermid.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/ctermid.3,v 1.8 2001/10/01 16:08:50 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt CTERMID 3 +.Os +.Sh NAME +.Nm ctermid +.Nd generate terminal pathname +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.Ft char * +.Fn ctermid "char *buf" +.Ft char * +.Fn ctermid_r "char *buf" +.Sh DESCRIPTION +The +.Fn ctermid +function generates a string, that, when used as a pathname, refers to +the current controlling terminal of the calling process. +.Pp +If +.Ar buf +is the +.Dv NULL +pointer, a pointer to a static area is returned. +Otherwise, the pathname is copied into the memory referenced by +.Ar buf . +The argument +.Ar buf +is assumed to be at least +.Dv L_ctermid +(as defined in the include +file +.Aq Pa stdio.h ) +bytes long. +.Pp +.Fn ctermid_r +provides the same functionality as +.Fn ctermid +except that if +.Ar buf +is a +.Dv NULL +pointer, +.Dv NULL +is returned. +.Pp +The current implementation simply returns +.Ql /dev/tty . +.Sh RETURN VALUES +Upon successful completion, a +.Pf non- Dv NULL +pointer is returned. +Otherwise, a +.Dv NULL +pointer is returned and the global variable +.Va errno +is set to indicate the error. +.Sh ERRORS +The current implementation detects no error conditions. +.Sh SEE ALSO +.Xr ttyname 3 +.Sh STANDARDS +The +.Fn ctermid +function conforms to +.St -p1003.1-88 . +.Sh BUGS +By default the +.Fn ctermid +function +writes all information to an internal static object. +Subsequent calls to +.Fn ctermid +will modify the same object. diff --git a/gen.subproj/ctermid.c b/gen/ctermid.c similarity index 100% rename from gen.subproj/ctermid.c rename to gen/ctermid.c diff --git a/gen.subproj/ctime.c b/gen/ctime.c similarity index 100% rename from gen.subproj/ctime.c rename to gen/ctime.c diff --git a/gen/daemon.3 b/gen/daemon.3 new file mode 100644 index 0000000..0a95ff8 --- /dev/null +++ b/gen/daemon.3 @@ -0,0 +1,81 @@ +.\" Copyright (c) 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)daemon.3 8.1 (Berkeley) 6/9/93 +.\" $FreeBSD: src/lib/libc/gen/daemon.3,v 1.10 2001/10/01 16:08:50 ru Exp $ +.\" +.Dd June 9, 1993 +.Dt DAEMON 3 +.Os +.Sh NAME +.Nm daemon +.Nd run in the background +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft int +.Fn daemon "int nochdir" "int noclose" +.Sh DESCRIPTION +The +.Fn daemon +function is for programs wishing to detach themselves from the +controlling terminal and run in the background as system daemons. +.Pp +Unless the argument +.Fa nochdir +is non-zero, +.Fn daemon +changes the current working directory to the root (``/''). +.Pp +Unless the argument +.Fa noclose +is non-zero, +.Fn daemon +will redirect standard input, standard output and standard error +to ``/dev/null''. +.Sh ERRORS +If an error occurs, +.Fn daemon +returns -1 and sets the global variable +.Va errno +to any of the errors specified for the library functions +.Xr fork 2 +and +.Xr setsid 2 . +.Sh SEE ALSO +.Xr fork 2 , +.Xr setsid 2 +.Sh HISTORY +The +.Fn daemon +function first appeared in +.Bx 4.4 . diff --git a/gen.subproj/daemon.c b/gen/daemon.c similarity index 100% rename from gen.subproj/daemon.c rename to gen/daemon.c diff --git a/gen/devname.3 b/gen/devname.3 new file mode 100644 index 0000000..1a08e34 --- /dev/null +++ b/gen/devname.3 @@ -0,0 +1,72 @@ +.\" Copyright (c) 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)devname.3 8.2 (Berkeley) 4/29/95 +.\" $FreeBSD: src/lib/libc/gen/devname.3,v 1.11 2001/10/01 16:08:50 ru Exp $ +.\" +.Dd April 29, 1995 +.Dt DEVNAME 3 +.Os +.Sh NAME +.Nm devname +.Nd get device name +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/stat.h +.In stdlib.h +.Ft char * +.Fn devname "dev_t dev" "mode_t type" +.Sh DESCRIPTION +The +.Fn devname +function returns a pointer to the name of the block or character +device in +.Dq Pa /dev +with a device number of +.Fa dev , +and a file type matching the one encoded in +.Fa type +which must be one of S_IFBLK or S_IFCHR. +If no device matches the specified values, or no information is +available, NULL is returned. +.Pp +The traditional display for applications when no device is +found is the string +.Dq ?? . +.Sh SEE ALSO +.Xr stat 2 , +.Xr dev_mkdb 8 +.Sh HISTORY +The +.Fn devname +function call appeared in +.Bx 4.4 . diff --git a/gen.subproj/devname.c b/gen/devname.c similarity index 80% rename from gen.subproj/devname.c rename to gen/devname.c index 3a03f5a..451fb8f 100644 --- a/gen.subproj/devname.c +++ b/gen/devname.c @@ -65,52 +65,24 @@ #include #include -static char buf[sizeof(_PATH_DEV) + MAXNAMLEN] = _PATH_DEV; -static char *olddevname __P((dev_t, mode_t)); - char * devname(dev, type) dev_t dev; mode_t type; -{ - struct { - mode_t type; - dev_t dev; - } bkey; - static DB *db; - static int failure; - DBT data, key; - - if (!db && !failure && - !(db = dbopen(_PATH_DEVDB, O_RDONLY, 0, DB_HASH, NULL))) { - failure = 1; - } - if (failure) - return (olddevname(dev, type)); - - /* - * Keys are a mode_t followed by a dev_t. The former is the type of - * the file (mode & S_IFMT), the latter is the st_rdev field. Be - * sure to clear any padding that may be found in bkey. - */ - memset(&bkey, 0, sizeof(bkey)); - bkey.dev = dev; - bkey.type = type; - key.data = &bkey; - key.size = sizeof(bkey); - return ((db->get)(db, &key, &data, 0) ? NULL : (char *)data.data); -} - -static char * -olddevname(dev, type) - dev_t dev; - mode_t type; { register DIR *dp; register struct dirent *dirp; struct stat sb; + static char *buf = NULL; + + if( buf == NULL ) { + buf = malloc(sizeof(_PATH_DEV) + MAXNAMLEN); + if( buf == NULL ) + return NULL; + strcpy(buf, _PATH_DEV); + } - if ((dp = opendir(_PATH_DEV)) == NULL) + if ((dp = opendir(_PATH_DEV)) == NULL) return (NULL); while ( (dirp = readdir(dp)) ) { diff --git a/gen.subproj/difftime.c b/gen/difftime.c similarity index 100% rename from gen.subproj/difftime.c rename to gen/difftime.c diff --git a/gen/directory.3 b/gen/directory.3 new file mode 100644 index 0000000..347767e --- /dev/null +++ b/gen/directory.3 @@ -0,0 +1,200 @@ +.\" Copyright (c) 1983, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)directory.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/directory.3,v 1.12 2001/10/01 16:08:50 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt DIRECTORY 3 +.Os +.Sh NAME +.Nm opendir , +.Nm readdir , +.Nm readdir_r , +.Nm telldir , +.Nm seekdir , +.Nm rewinddir , +.Nm closedir , +.Nm dirfd +.Nd directory operations +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In dirent.h +.Ft DIR * +.Fn opendir "const char *filename" +.Ft struct dirent * +.Fn readdir "DIR *dirp" +.Ft int +.Fn readdir_r "DIR *dirp" "struct dirent *entry" "struct dirent **result" +.Ft long +.Fn telldir "DIR *dirp" +.Ft void +.Fn seekdir "DIR *dirp" "long loc" +.Ft void +.Fn rewinddir "DIR *dirp" +.Ft int +.Fn closedir "DIR *dirp" +.Ft int +.Fn dirfd "DIR *dirp" +.Sh DESCRIPTION +The +.Fn opendir +function +opens the directory named by +.Fa filename , +associates a +.Em directory stream +with it +and +returns a pointer to be used to identify the +.Em directory stream +in subsequent operations. The pointer +.Dv NULL +is returned if +.Fa filename +cannot be accessed, or if it cannot +.Xr malloc 3 +enough memory to hold the whole thing. +.Pp +The +.Fn readdir +function +returns a pointer to the next directory entry. It returns +.Dv NULL +upon reaching the end of the directory or detecting an invalid +.Fn seekdir +operation. +.Pp +.Fn readdir_r +provides the same functionality as +.Fn readdir , +but the caller must provide a directory +.Fa entry +buffer to store the results in. If the read succeeds, +.Fa result +is pointed at the +.Fa entry ; +upon reaching the end of the directory +.Fa result +is set to +.Dv NULL . +.Fn readdir_r +returns 0 on success or an error number to indicate failure. +.Pp +The +.Fn telldir +function +returns the current location associated with the named +.Em directory stream . +Values returned by +.Fn telldir +are good only for the lifetime of the +.Dv DIR +pointer, +.Fa dirp , +from which they are derived. If the directory is closed and then +reopened, prior values returned by +.Fn telldir +will no longer be valid. +.Pp +The +.Fn seekdir +function +sets the position of the next +.Fn readdir +operation on the +.Em directory stream . +The new position reverts to the one associated with the +.Em directory stream +when the +.Fn telldir +operation was performed. +.Pp +The +.Fn rewinddir +function +resets the position of the named +.Em directory stream +to the beginning of the directory. +.Pp +The +.Fn closedir +function +closes the named +.Em directory stream +and frees the structure associated with the +.Fa dirp +pointer, +returning 0 on success. +On failure, \-1 is returned and the global variable +.Va errno +is set to indicate the error. +.Pp +The +.Fn dirfd +function +returns the integer file descriptor associated with the named +.Em directory stream , +see +.Xr open 2 . +.Pp +Sample code which searches a directory for entry ``name'' is: +.Bd -literal -offset indent +len = strlen(name); +dirp = opendir("."); +while ((dp = readdir(dirp)) != NULL) + if (dp->d_namlen == len && !strcmp(dp->d_name, name)) { + (void)closedir(dirp); + return FOUND; + } +(void)closedir(dirp); +return NOT_FOUND; +.Ed +.Sh SEE ALSO +.Xr close 2 , +.Xr lseek 2 , +.Xr open 2 , +.Xr read 2 , +.Xr dir 5 +.Sh HISTORY +The +.Fn opendir , +.Fn readdir , +.Fn telldir , +.Fn seekdir , +.Fn rewinddir , +.Fn closedir , +and +.Fn dirfd +functions appeared in +.Bx 4.2 . diff --git a/gen/dirname.3 b/gen/dirname.3 new file mode 100644 index 0000000..2b160a9 --- /dev/null +++ b/gen/dirname.3 @@ -0,0 +1,108 @@ +.\" +.\" Copyright (c) 1997 Todd C. Miller +.\" 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. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +.\" AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +.\" THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +.\" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +.\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +.\" OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" $OpenBSD: dirname.3,v 1.9 2000/04/18 03:01:25 aaron Exp $ +.\" $FreeBSD: src/lib/libc/gen/dirname.3,v 1.4 2001/10/01 16:08:50 ru Exp $ +.\" +.Dd August 17, 1997 +.Dt DIRNAME 3 +.Os +.Sh NAME +.Nm dirname +.Nd extract the directory portition of a pathname +.Sh SYNOPSIS +.In libgen.h +.Ft char * +.Fn dirname "const char *path" +.Sh DESCRIPTION +The +.Fn dirname +function +is the converse of +.Xr basename 3 ; +it returns a pointer to the parent directory of the pathname pointed to by +.Ar path . +Any trailing +.Sq \&/ +characters are not counted as part of the directory +name. +If +.Ar path +is a null pointer, the empty string, or contains no +.Sq \&/ +characters, +.Fn dirname +returns a pointer to the string +.Qq \&. , +signifying the current directory. +.Sh RETURN VALUES +On successful completion, +.Fn dirname +returns a pointer to the parent directory of +.Ar path . +.Pp +If +.Fn dirname +fails, a null pointer is returned and the global variable +.Va errno +is set to indicate the error. +.Sh ERRORS +The following error codes may be set in +.Va errno : +.Bl -tag -width Er +.It Bq Er ENAMETOOLONG +The path component to be returned was larger than +.Dv MAXPATHLEN . +.El +.Sh WARNINGS +.Fn dirname +returns a pointer to internal static storage space that will be overwritten +by subsequent calls (each function has its own separate storage). +.Pp +Other vendor implementations of +.Fn dirname +may modify the contents of the string passed to +.Fn dirname ; +this should be taken into account when writing code which calls this function +if portability is desired. +.Sh SEE ALSO +.Xr basename 1 , +.Xr dirname 1 , +.Xr basename 3 +.Sh STANDARDS +The +.Fn dirname +function conforms to +.St -xpg4.2 . +.Sh HISTORY +The +.Fn dirname +function first appeared in +.Ox 2.2 +and +.Fx 4.2 . +.Sh AUTHORS +Todd C. Miller diff --git a/gen/dirname.c b/gen/dirname.c new file mode 100644 index 0000000..709c157 --- /dev/null +++ b/gen/dirname.c @@ -0,0 +1,86 @@ +/* $OpenBSD: dirname.c,v 1.4 1999/05/30 17:10:30 espie Exp $ */ +/* $FreeBSD: src/lib/libc/gen/dirname.c,v 1.1.2.2 2001/07/23 10:13:04 dd Exp $ */ + +/* + * Copyright (c) 1997 Todd C. Miller + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#if defined(LIBC_RCS) && !defined(lint) +static char rcsid[] = "$OpenBSD: dirname.c,v 1.4 1999/05/30 17:10:30 espie Exp $"; +#endif /* not lint */ + +#include +#include +#include +#include +#include + +char * +dirname(path) + const char *path; +{ + static char *bname = NULL; + register const char *endp; + + if ( bname == NULL ) { + bname = malloc(MAXPATHLEN); + if( bname == NULL ) + return NULL; + } + + /* Empty or NULL string gets treated as "." */ + if (path == NULL || *path == '\0') { + (void)strcpy(bname, "."); + return(bname); + } + + /* Strip trailing slashes */ + endp = path + strlen(path) - 1; + while (endp > path && *endp == '/') + endp--; + + /* Find the start of the dir */ + while (endp > path && *endp != '/') + endp--; + + /* Either the dir is "/" or there are no slashes */ + if (endp == path) { + (void)strcpy(bname, *endp == '/' ? "/" : "."); + return(bname); + } else { + do { + endp--; + } while (endp > path && *endp == '/'); + } + + if (endp - path + 2 > MAXPATHLEN) { + errno = ENAMETOOLONG; + return(NULL); + } + (void)strncpy(bname, path, endp - path + 1); + bname[endp - path + 1] = '\0'; + return(bname); +} diff --git a/gen.subproj/disklabel.c b/gen/disklabel.c similarity index 100% rename from gen.subproj/disklabel.c rename to gen/disklabel.c diff --git a/gen/drand48.c b/gen/drand48.c new file mode 100644 index 0000000..cec04a6 --- /dev/null +++ b/gen/drand48.c @@ -0,0 +1,22 @@ +/* + * Copyright (c) 1993 Martin Birgmeier + * All rights reserved. + * + * You may redistribute unmodified or modified versions of this source + * code provided that the above copyright notice and this and the + * following conditions are retained. + * + * This software is provided ``as is'', and comes with no warranties + * of any kind. I shall in no event be liable for anything that happens + * to anyone/anything when using this software. + */ + +#include "rand48.h" + +extern unsigned short _rand48_seed[3]; + +double +drand48(void) +{ + return erand48(_rand48_seed); +} diff --git a/gen/erand48.c b/gen/erand48.c new file mode 100644 index 0000000..286904c --- /dev/null +++ b/gen/erand48.c @@ -0,0 +1,23 @@ +/* + * Copyright (c) 1993 Martin Birgmeier + * All rights reserved. + * + * You may redistribute unmodified or modified versions of this source + * code provided that the above copyright notice and this and the + * following conditions are retained. + * + * This software is provided ``as is'', and comes with no warranties + * of any kind. I shall in no event be liable for anything that happens + * to anyone/anything when using this software. + */ + +#include "rand48.h" + +double +erand48(unsigned short xseed[3]) +{ + _dorand48(xseed); + return ldexp((double) xseed[0], -48) + + ldexp((double) xseed[1], -32) + + ldexp((double) xseed[2], -16); +} diff --git a/gen/err.3 b/gen/err.3 new file mode 100644 index 0000000..08e6316 --- /dev/null +++ b/gen/err.3 @@ -0,0 +1,230 @@ +.\" Copyright (c) 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" From: @(#)err.3 8.1 (Berkeley) 6/9/93 +.\" $FreeBSD: src/lib/libc/gen/err.3,v 1.18 2001/10/01 16:08:50 ru Exp $ +.\" +.Dd March 6, 1999 +.Dt ERR 3 +.Os +.Sh NAME +.Nm err , +.Nm verr , +.Nm errc , +.Nm verrc , +.Nm errx , +.Nm verrx , +.Nm warn , +.Nm vwarn , +.Nm warnc , +.Nm vwarnc , +.Nm warnx , +.Nm vwarnx , +.Nm err_set_exit , +.Nm err_set_file +.Nd formatted error messages +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In err.h +.Ft void +.Fn err "int eval" "const char *fmt" "..." +.Ft void +.Fn err_set_exit "void (*exitf)(int)" +.Ft void +.Fn err_set_file "void *vfp" +.Ft void +.Fn errc "int eval" "int code" "const char *fmt" "..." +.Ft void +.Fn errx "int eval" "const char *fmt" "..." +.Ft void +.Fn warn "const char *fmt" "..." +.Ft void +.Fn warnc "int code" "const char *fmt" "..." +.Ft void +.Fn warnx "const char *fmt" "..." +.In stdarg.h +.Ft void +.Fn verr "int eval" "const char *fmt" "va_list args" +.Ft void +.Fn verrc "int eval" "int code" "const char *fmt" "va_list args" +.Ft void +.Fn verrx "int eval" "const char *fmt" "va_list args" +.Ft void +.Fn vwarn "const char *fmt" "va_list args" +.Ft void +.Fn vwarnc "int code" "const char *fmt" "va_list args" +.Ft void +.Fn vwarnx "const char *fmt" "va_list args" +.Sh DESCRIPTION +The +.Fn err +and +.Fn warn +family of functions display a formatted error message on the standard +error output, or on another file specified using the +.Fn err_set_file +function. +In all cases, the last component of the program name, a colon character, +and a space are output. +If the +.Fa fmt +argument is not NULL, the +.Xr printf 3 +-like formatted error message is output. +The output is terminated by a newline character. +.Pp +The +.Fn err , +.Fn errc , +.Fn verr , +.Fn verrc , +.Fn warn , +.Fn warnc , +.Fn vwarn , +and +.Fn vwarnc +functions append an error message obtained from +.Xr strerror 3 +based on a code or the global variable +.Va errno , +preceded by another colon and space unless the +.Fa fmt +argument is +.Dv NULL . +.Pp +In the case of the +.Fn errc , +.Fn verrc , +.Fn warnc , +and +.Fn vwarnc +functions, +the +.Fa code +argument is used to look up the error message. +.Pp +The +.Fn err , +.Fn verr , +.Fn warn , +and +.Fn vwarn +functions use the global variable +.Va errno +to look up the error message. +.Pp +The +.Fn errx +and +.Fn warnx +functions do not append an error message. +.Pp +The +.Fn err , +.Fn verr , +.Fn errc , +.Fn verrc , +.Fn errx , +and +.Fn verrx +functions do not return, but exit with the value of the argument +.Fa eval . +The +.Fn err_set_exit +function can be used to specify a function which is called before +.Xr exit 3 +to perform any necessary cleanup; passing a null function pointer for +.Va exitf +resets the hook to do nothing. +The +.Fn err_set_file +function sets the output stream used by the other functions. +Its +.Fa vfp +argument must be either a pointer to an open stream +(possibly already converted to void *) +or a null pointer +(in which case the output stream is set to standard error). +.Sh EXAMPLES +Display the current errno information string and exit: +.Bd -literal -offset indent +if ((p = malloc(size)) == NULL) + err(1, NULL); +if ((fd = open(file_name, O_RDONLY, 0)) == -1) + err(1, "%s", file_name); +.Ed +.Pp +Display an error message and exit: +.Bd -literal -offset indent +if (tm.tm_hour < START_TIME) + errx(1, "too early, wait until %s", start_time_string); +.Ed +.Pp +Warn of an error: +.Bd -literal -offset indent +if ((fd = open(raw_device, O_RDONLY, 0)) == -1) + warnx("%s: %s: trying the block device", + raw_device, strerror(errno)); +if ((fd = open(block_device, O_RDONLY, 0)) == -1) + err(1, "%s", block_device); +.Ed +.Pp +Warn of an error without using the global variable +.Va errno : +.Bd -literal -offset indent +error = my_function(); /* returns a value from */ +if (error != 0) + warnc(error, "my_function"); +.Ed +.Sh SEE ALSO +.Xr exit 3 , +.Xr printf 3 , +.Xr strerror 3 +.Sh HISTORY +The +.Fn err +and +.Fn warn +functions first appeared in +.Bx 4.4 . +The +.Fn err_set_exit +and +.Fn err_set_file +functions first appeared in +.Fx 2.1 . +The +.Fn errc +and +.Fn warnc +functions first appeared in +.Fx 3.0 . diff --git a/gen.subproj/err.c b/gen/err.c similarity index 100% rename from gen.subproj/err.c rename to gen/err.c diff --git a/gen.subproj/errlst.c b/gen/errlst.c similarity index 100% rename from gen.subproj/errlst.c rename to gen/errlst.c diff --git a/gen/exec.3 b/gen/exec.3 new file mode 100644 index 0000000..69d4dfa --- /dev/null +++ b/gen/exec.3 @@ -0,0 +1,296 @@ +.\" Copyright (c) 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)exec.3 8.3 (Berkeley) 1/24/94 +.\" $FreeBSD: src/lib/libc/gen/exec.3,v 1.16 2001/10/01 16:08:50 ru Exp $ +.\" +.Dd January 24, 1994 +.Dt EXEC 3 +.Os +.Sh NAME +.Nm execl , +.Nm execlp , +.Nm execle , +.Nm exect , +.Nm execv , +.Nm execvp +.Nd execute a file +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Vt extern char **environ ; +.Ft int +.Fn execl "const char *path" "const char *arg" ... +.Ft int +.Fn execlp "const char *file" "const char *arg" ... +.Ft int +.Fn execle "const char *path" "const char *arg" ... +.Ft int +.Fn exect "const char *path" "char *const argv[]" "char *const envp[]" +.Ft int +.Fn execv "const char *path" "char *const argv[]" +.Ft int +.Fn execvp "const char *file" "char *const argv[]" +.Sh DESCRIPTION +The +.Nm exec +family of functions replaces the current process image with a +new process image. +The functions described in this manual page are front-ends for the function +.Xr execve 2 . +(See the manual page for +.Xr execve 2 +for detailed information about the replacement of the current process.) +.Pp +The initial argument for these functions is the pathname of a file which +is to be executed. +.Pp +The +.Fa "const char *arg" +and subsequent ellipses in the +.Fn execl , +.Fn execlp , +and +.Fn execle +functions can be thought of as +.Em arg0 , +.Em arg1 , +\&..., +.Em argn . +Together they describe a list of one or more pointers to null-terminated +strings that represent the argument list available to the executed program. +The first argument, by convention, should point to the file name associated +with the file being executed. +The list of arguments +.Em must +be terminated by a +.Dv NULL +pointer. +.Pp +The +.Fn exect , +.Fn execv , +and +.Fn execvp +functions provide an array of pointers to null-terminated strings that +represent the argument list available to the new program. +The first argument, by convention, should point to the file name associated +with the file being executed. +The array of pointers +.Sy must +be terminated by a +.Dv NULL +pointer. +.Pp +The +.Fn execle +and +.Fn exect +functions also specify the environment of the executed process by following +the +.Dv NULL +pointer that terminates the list of arguments in the parameter list +or the pointer to the argv array with an additional parameter. +This additional parameter is an array of pointers to null-terminated strings +and +.Em must +be terminated by a +.Dv NULL +pointer. +The other functions take the environment for the new process image from the +external variable +.Va environ +in the current process. +.Pp +Some of these functions have special semantics. +.Pp +The functions +.Fn execlp +and +.Fn execvp +will duplicate the actions of the shell in searching for an executable file +if the specified file name does not contain a slash +.Dq Li / +character. +The search path is the path specified in the environment by +.Dq Ev PATH +variable. +If this variable isn't specified, +the default path is set according to the +.Dv _PATH_DEFPATH +definition in +.Aq paths.h , +which is set to +.Dq Ev /usr/bin:/bin . +In addition, certain errors are treated specially. +.Pp +If an error is ambiguous (for simplicity, we shall consider all +errors except +.Er ENOEXEC +as being ambiguous here, although only the critical error +.Er EACCES +is really ambiguous), +then these functions will act as if they stat the file to determine +whether the file exists and has suitable execute permissions. +If it does, they will return immediately with the global variable +.Va errno +restored to the value set by +.Fn execve . +Otherwise, the search will be continued. +If the search completes without performing a successful +.Fn execve +or terminating due to an error, +these functions will return with the global variable +.Va errno +set to +.Er EACCES +or +.Er ENOENT +according to whether at least one file with suitable execute permissions +was found. +.Pp +If the header of a file isn't recognized (the attempted +.Fn execve +returned +.Er ENOEXEC ) , +these functions will execute the shell with the path of +the file as its first argument. +(If this attempt fails, no further searching is done.) +.Pp +The function +.Fn exect +executes a file with the program tracing facilities enabled (see +.Xr ptrace 2 ) . +.Sh RETURN VALUES +If any of the +.Fn exec +functions returns, an error will have occurred. +The return value is \-1, and the global variable +.Va errno +will be set to indicate the error. +.Sh FILES +.Bl -tag -width /bin/sh -compact +.It Pa /bin/sh +The shell. +.El +.Sh ERRORS +.Fn Execl , +.Fn execle , +.Fn execlp +and +.Fn execvp +may fail and set +.Va errno +for any of the errors specified for the library functions +.Xr execve 2 +and +.Xr malloc 3 . +.Pp +.Fn Exect +and +.Fn execv +may fail and set +.Va errno +for any of the errors specified for the library function +.Xr execve 2 . +.Sh SEE ALSO +.Xr sh 1 , +.Xr execve 2 , +.Xr fork 2 , +.Xr ktrace 2 , +.Xr ptrace 2 , +.Xr environ 7 +.Sh COMPATIBILITY +Historically, the default path for the +.Fn execlp +and +.Fn execvp +functions was +.Dq Pa :/bin:/usr/bin . +This was changed to place the current directory last to enhance system +security. +.Pp +The behavior of +.Fn execlp +and +.Fn execvp +when errors occur while attempting to execute the file is not quite historic +practice, and has not traditionally been documented and is not specified +by the +.Tn POSIX +standard. +.Pp +Traditionally, the functions +.Fn execlp +and +.Fn execvp +ignored all errors except for the ones described above and +.Er ETXTBSY , +upon which they retried after sleeping for several seconds, and +.Er ENOMEM +and +.Er E2BIG , +upon which they returned. +They now return for +.Er ETXTBSY , +and determine existence and executability more carefully. +In particular, +.Er EACCES +for inaccessible directories in the path prefix is no longer +confused with +.Er EACCES +for files with unsuitable execute permissions. +In +.Bx 4.4 , +they returned upon all errors except +.Er EACCES , +.Er ENOENT , +.Er ENOEXEC +and +.Er ETXTBSY . +This was inferior to the traditional error handling, +since it breaks the ignoring of errors for path prefixes +and only improves the handling of the unusual ambiguous error +.Er EFAULT +and the unusual error +.Er EIO . +The behaviour was changed to match the behaviour of +.Xr sh 1 . +.Sh STANDARDS +.Fn Execl , +.Fn execv , +.Fn execle , +.Fn execlp +and +.Fn execvp +conform to +.St -p1003.1-88 . diff --git a/gen.subproj/exec.c b/gen/exec.c similarity index 100% rename from gen.subproj/exec.c rename to gen/exec.c diff --git a/gen/fmtcheck.3 b/gen/fmtcheck.3 new file mode 100644 index 0000000..ec67305 --- /dev/null +++ b/gen/fmtcheck.3 @@ -0,0 +1,108 @@ +.\" Copyright (c) 2000 The NetBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This file was contributed to The NetBSD Foundation by Allen Briggs. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the NetBSD +.\" Foundation, Inc. and its contributors. +.\" 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +.\" +.\" $FreeBSD: src/lib/libc/gen/fmtcheck.3,v 1.4 2001/10/01 16:08:50 ru Exp $ +.Dd October 17, 2000 +.Os +.Dt FMTCHECK 3 +.Sh NAME +.Nm fmtcheck +.Nd sanitizes user-supplied +.Xr printf 3 Ns -style +format string +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.Ft const char * +.Fn fmtcheck "const char *fmt_suspect" "const char *fmt_default" +.Sh DESCRIPTION +The +.Fn fmtcheck +scans +.Fa fmt_suspect +and +.Fa fmt_default +to determine if +.Fa fmt_suspect +will consume the same argument types as +.Fa fmt_default +and to ensure that +.Fa fmt_suspect +is a valid format string. +.Pp +The +.Xr printf 3 +family of functions can not verify the types of arguments that they are +passed at run-time. In some cases, like +.Xr catgets 3 , +it is useful or necessary to use a user-supplied format string with no +guarantee that the format string matches the specified parameters. +.Pp +The +.Fn fmtcheck +was designed to be used in these cases, as in: +.Bd -literal -offset indent +printf(fmtcheck(user_format, standard_format), arg1, arg2); +.Ed +.Pp +In the check, field widths, fillers, precisions, etc. are ignored (unless +the field width or precision is an asterisk +.Ql * +instead of a digit string). Also, any text other than the format specifiers +is completely ignored. +.Pp +Note that the formats may be quite different as long as they accept the +same parameters. For example, +.Qq Li "%p %o %30s %#llx %-10.*e %n" +is compatible with +.Qq Li "This number %lu %d%% and string %s has %qd numbers and %.*g floats (%n)" . +However, +.Qq Li %o +is not equivalent to +.Qq Li %lx +because +the first requires an integer and the second requires a long. +.Sh RETURN VALUES +If +.Fa fmt_suspect +is a valid format and consumes the same argument types as +.Fa fmt_default , +then the +.Fn fmtcheck +will return +.Fa fmt_suspect . +Otherwise, it will return +.Fa fmt_default . +.Sh SEE ALSO +.Xr printf 3 diff --git a/gen/fnmatch.3 b/gen/fnmatch.3 new file mode 100644 index 0000000..7442408 --- /dev/null +++ b/gen/fnmatch.3 @@ -0,0 +1,151 @@ +.\" Copyright (c) 1989, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Guido van Rossum. +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)fnmatch.3 8.3 (Berkeley) 4/28/95 +.\" $FreeBSD: src/lib/libc/gen/fnmatch.3,v 1.9.2.3 2001/12/14 18:33:51 ru Exp $ +.\" +.Dd April 28, 1995 +.Dt FNMATCH 3 +.Os +.Sh NAME +.Nm fnmatch +.Nd match filename or pathname +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In fnmatch.h +.Ft int +.Fn fnmatch "const char *pattern" "const char *string" "int flags" +.Sh DESCRIPTION +The +.Fn fnmatch +function +matches patterns according to the rules used by the shell. +It checks the string specified by the +.Fa string +argument to see if it matches the pattern specified by the +.Fa pattern +argument. +.Pp +The +.Fa flags +argument modifies the interpretation of +.Fa pattern +and +.Fa string . +The value of +.Fa flags +is the bitwise inclusive +.Tn OR +of any of the following +constants, which are defined in the include file +.Pa fnmatch.h . +.Bl -tag -width FNM_PATHNAME +.It Dv FNM_NOESCAPE +Normally, every occurrence of a backslash +.Pq Ql \e +followed by a character in +.Fa pattern +is replaced by that character. +This is done to negate any special meaning for the character. +If the +.Dv FNM_NOESCAPE +flag is set, a backslash character is treated as an ordinary character. +.It Dv FNM_PATHNAME +Slash characters in +.Fa string +must be explicitly matched by slashes in +.Fa pattern . +If this flag is not set, then slashes are treated as regular characters. +.It Dv FNM_PERIOD +Leading periods in +.Fa string +must be explicitly matched by periods in +.Fa pattern . +If this flag is not set, then leading periods are treated as regular +characters. +The definition of +.Dq leading +is related to the specification of +.Dv FNM_PATHNAME . +A period is always +.Dq leading +if it is the first character in +.Ar string . +Additionally, if +.Dv FNM_PATHNAME +is set, +a period is +leading +if it immediately follows a slash. +.It Dv FNM_LEADING_DIR +Ignore +.Nm /* +rest after successful +.Fa pattern +matching. +.It Dv FNM_CASEFOLD +Ignore case distinctions in both the +.Fa pattern +and the +.Fa string . +.El +.Sh RETURN VALUES +The +.Fn fnmatch +function returns zero if +.Fa string +matches the pattern specified by +.Fa pattern , +otherwise, it returns the value +.Dv FNM_NOMATCH . +.Sh SEE ALSO +.Xr sh 1 , +.Xr glob 3 , +.Xr regex 3 +.Sh STANDARDS +The +.Fn fnmatch +function conforms to +.St -p1003.2 . +.Sh HISTORY +The +.Fn fnmatch +function first appeared in +.Bx 4.4 . +.Sh BUGS +The pattern +.Ql * +matches the empty string, even if +.Dv FNM_PATHNAME +is specified. diff --git a/gen.subproj/fnmatch.c b/gen/fnmatch.c similarity index 68% rename from gen.subproj/fnmatch.c rename to gen/fnmatch.c index 93bb361..c3312b4 100644 --- a/gen.subproj/fnmatch.c +++ b/gen/fnmatch.c @@ -1,24 +1,3 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ /* * Copyright (c) 1989, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -55,18 +34,29 @@ * SUCH DAMAGE. */ +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)fnmatch.c 8.2 (Berkeley) 4/16/94"; +#endif /* LIBC_SCCS and not lint */ /* * Function fnmatch() as specified in POSIX 1003.2-1992, section B.6. * Compares a filename or pathname to a pattern. */ +#include #include #include +#include + +#include "collate.h" #define EOS '\0' -static const char *rangematch __P((const char *, int, int)); +#define RANGE_MATCH 1 +#define RANGE_NOMATCH 0 +#define RANGE_ERROR (-1) + +static int rangematch __P((const char *, char, int, char **)); int fnmatch(pattern, string, flags) @@ -74,11 +64,14 @@ fnmatch(pattern, string, flags) int flags; { const char *stringstart; + char *newp; char c, test; for (stringstart = string;;) switch (c = *pattern++) { case EOS: + if ((flags & FNM_LEADING_DIR) && *string == '/') + return (0); return (*string == EOS ? 0 : FNM_NOMATCH); case '?': if (*string == EOS) @@ -105,7 +98,8 @@ fnmatch(pattern, string, flags) /* Optimize for pattern with * at end or before /. */ if (c == EOS) if (flags & FNM_PATHNAME) - return (strchr(string, '/') == NULL ? + return ((flags & FNM_LEADING_DIR) || + strchr(string, '/') == NULL ? 0 : FNM_NOMATCH); else return (0); @@ -127,11 +121,22 @@ fnmatch(pattern, string, flags) case '[': if (*string == EOS) return (FNM_NOMATCH); - if (*string == '/' && flags & FNM_PATHNAME) + if (*string == '/' && (flags & FNM_PATHNAME)) + return (FNM_NOMATCH); + if (*string == '.' && (flags & FNM_PERIOD) && + (string == stringstart || + ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) return (FNM_NOMATCH); - if ((pattern = - rangematch(pattern, *string, flags)) == NULL) + + switch (rangematch(pattern, *string, flags, &newp)) { + case RANGE_ERROR: + goto norm; + case RANGE_MATCH: + pattern = newp; + break; + case RANGE_NOMATCH: return (FNM_NOMATCH); + } ++string; break; case '\\': @@ -143,17 +148,27 @@ fnmatch(pattern, string, flags) } /* FALLTHROUGH */ default: - if (c != *string++) + norm: + if (c == *string) + ; + else if ((flags & FNM_CASEFOLD) && + (tolower((unsigned char)c) == + tolower((unsigned char)*string))) + ; + else return (FNM_NOMATCH); + string++; break; } /* NOTREACHED */ } -static const char * -rangematch(pattern, test, flags) +static int +rangematch(pattern, test, flags, newp) const char *pattern; - int test, flags; + char test; + int flags; + char **newp; { int negate, ok; char c, c2; @@ -165,25 +180,52 @@ rangematch(pattern, test, flags) * consistency with the regular expression syntax. * J.T. Conklin (conklin@ngai.kaleida.com) */ - if (negate = (*pattern == '!' || *pattern == '^')) + if ( (negate = (*pattern == '!' || *pattern == '^')) ) ++pattern; - - for (ok = 0; (c = *pattern++) != ']';) { + + if (flags & FNM_CASEFOLD) + test = tolower((unsigned char)test); + + /* + * A right bracket shall lose its special meaning and represent + * itself in a bracket expression if it occurs first in the list. + * -- POSIX.2 2.8.3.2 + */ + ok = 0; + c = *pattern++; + do { if (c == '\\' && !(flags & FNM_NOESCAPE)) c = *pattern++; if (c == EOS) - return (NULL); - if (*pattern == '-' + return (RANGE_ERROR); + + if (c == '/' && (flags & FNM_PATHNAME)) + return (RANGE_NOMATCH); + + if (flags & FNM_CASEFOLD) + c = tolower((unsigned char)c); + + if (*pattern == '-' && (c2 = *(pattern+1)) != EOS && c2 != ']') { pattern += 2; if (c2 == '\\' && !(flags & FNM_NOESCAPE)) c2 = *pattern++; if (c2 == EOS) - return (NULL); - if (c <= test && test <= c2) + return (RANGE_ERROR); + + if (flags & FNM_CASEFOLD) + c2 = tolower((unsigned char)c2); + + if (__collate_load_error ? + c <= test && test <= c2 : + __collate_range_cmp(c, test) <= 0 + && __collate_range_cmp(test, c2) <= 0 + ) ok = 1; } else if (c == test) ok = 1; - } - return (ok == negate ? NULL : pattern); + } while ((c = *pattern++) != ']'); + + *newp = (char *)pattern; + return (ok == negate ? RANGE_NOMATCH : RANGE_MATCH); } diff --git a/gen/frexp.3 b/gen/frexp.3 new file mode 100644 index 0000000..74836cc --- /dev/null +++ b/gen/frexp.3 @@ -0,0 +1,88 @@ +.\" Copyright (c) 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)frexp.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/frexp.3,v 1.9 2001/10/01 16:08:50 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt FREXP 3 +.Os +.Sh NAME +.Nm frexp +.Nd convert floating-point number to fractional and integral components +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In math.h +.Ft double +.Fn frexp "double value" "int *exp" +.Sh DESCRIPTION +The +.Fn frexp +function breaks a floating-point number into a normalized +fraction and an integral power of 2. +It stores the integer in the +.Em int +object pointed to by +.Fa exp . +.Sh RETURN VALUES +The +.Fn frexp +function returns the value +.Em x , +such that +.Em x +is a +.Em double +with magnitude in the interval +.Bo 1/2 , 1 Pc +or zero, and +.Fa value +equals +.Em x +times 2 raised to the power +.Fa *exp . +If +.Fa value +is zero, both parts of the result are zero. +.Sh SEE ALSO +.Xr ldexp 3 , +.Xr math 3 , +.Xr modf 3 +.Sh STANDARDS +The +.Fn frexp +function conforms to +.St -isoC . diff --git a/gen/fstab.c b/gen/fstab.c new file mode 100644 index 0000000..ebdf2c9 --- /dev/null +++ b/gen/fstab.c @@ -0,0 +1,225 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1980, 1988, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + */ + +#include +#include +#include +#include +#include +#include + +static FILE *_fs_fp; +static struct fstab _fs_fstab; + +static error __P((int)); +static fstabscan __P((void)); + +static +fstabscan() +{ + register char *cp; +#define MAXLINELENGTH 1024 + static char *line = NULL; + char subline[MAXLINELENGTH]; + int typexx; + + if( line == NULL ) { + line = malloc(MAXLINELENGTH); + if( line == NULL ) + return(1); + } + + for (;;) { + if (!(cp = fgets(line, sizeof(line), _fs_fp))) + return(0); +/* OLD_STYLE_FSTAB */ + if (!strpbrk(cp, " \t")) { + _fs_fstab.fs_spec = strtok(cp, ":\n"); + _fs_fstab.fs_file = strtok((char *)NULL, ":\n"); + _fs_fstab.fs_type = strtok((char *)NULL, ":\n"); + if (_fs_fstab.fs_type) { + if (!strcmp(_fs_fstab.fs_type, FSTAB_XX)) + continue; + _fs_fstab.fs_mntops = _fs_fstab.fs_type; + _fs_fstab.fs_vfstype = + strcmp(_fs_fstab.fs_type, FSTAB_SW) ? + "ufs" : "swap"; + if (cp = strtok((char *)NULL, ":\n")) { + _fs_fstab.fs_freq = atoi(cp); + if (cp = strtok((char *)NULL, ":\n")) { + _fs_fstab.fs_passno = atoi(cp); + return(1); + } + } + } + goto bad; + } +/* OLD_STYLE_FSTAB */ + _fs_fstab.fs_spec = strtok(cp, " \t\n"); + if (!_fs_fstab.fs_spec || *_fs_fstab.fs_spec == '#') + continue; + _fs_fstab.fs_file = strtok((char *)NULL, " \t\n"); + _fs_fstab.fs_vfstype = strtok((char *)NULL, " \t\n"); + _fs_fstab.fs_mntops = strtok((char *)NULL, " \t\n"); + if (_fs_fstab.fs_mntops == NULL) + goto bad; + _fs_fstab.fs_freq = 0; + _fs_fstab.fs_passno = 0; + if ((cp = strtok((char *)NULL, " \t\n")) != NULL) { + _fs_fstab.fs_freq = atoi(cp); + if ((cp = strtok((char *)NULL, " \t\n")) != NULL) + _fs_fstab.fs_passno = atoi(cp); + } + strcpy(subline, _fs_fstab.fs_mntops); + for (typexx = 0, cp = strtok(subline, ","); cp; + cp = strtok((char *)NULL, ",")) { + if (strlen(cp) != 2) + continue; + if (!strcmp(cp, FSTAB_RW)) { + _fs_fstab.fs_type = FSTAB_RW; + break; + } + if (!strcmp(cp, FSTAB_RQ)) { + _fs_fstab.fs_type = FSTAB_RQ; + break; + } + if (!strcmp(cp, FSTAB_RO)) { + _fs_fstab.fs_type = FSTAB_RO; + break; + } + if (!strcmp(cp, FSTAB_SW)) { + _fs_fstab.fs_type = FSTAB_SW; + break; + } + if (!strcmp(cp, FSTAB_XX)) { + _fs_fstab.fs_type = FSTAB_XX; + typexx++; + break; + } + } + if (typexx) + continue; + if (cp != NULL) + return(1); + +bad: /* no way to distinguish between EOF and syntax error */ + error(EFTYPE); + } + /* NOTREACHED */ +} + +struct fstab * +getfsent() +{ + if (!_fs_fp && !setfsent() || !fstabscan()) + return((struct fstab *)NULL); + return(&_fs_fstab); +} + +struct fstab * +getfsspec(name) + register const char *name; +{ + if (setfsent()) + while (fstabscan()) + if (!strcmp(_fs_fstab.fs_spec, name)) + return(&_fs_fstab); + return((struct fstab *)NULL); +} + +struct fstab * +getfsfile(name) + register const char *name; +{ + if (setfsent()) + while (fstabscan()) + if (!strcmp(_fs_fstab.fs_file, name)) + return(&_fs_fstab); + return((struct fstab *)NULL); +} + +setfsent() +{ + if (_fs_fp) { + rewind(_fs_fp); + return(1); + } + if (_fs_fp = fopen(_PATH_FSTAB, "r")) + return(1); + error(errno); + return(0); +} + +void +endfsent() +{ + if (_fs_fp) { + (void)fclose(_fs_fp); + _fs_fp = NULL; + } +} + +static +error(err) + int err; +{ + char *p; + + (void)write(STDERR_FILENO, "fstab: ", 7); + (void)write(STDERR_FILENO, _PATH_FSTAB, sizeof(_PATH_FSTAB) - 1); + (void)write(STDERR_FILENO, ": ", 1); + p = strerror(err); + (void)write(STDERR_FILENO, p, strlen(p)); + (void)write(STDERR_FILENO, "\n", 1); +} diff --git a/gen.subproj/ftok.3 b/gen/ftok.3 similarity index 72% rename from gen.subproj/ftok.3 rename to gen/ftok.3 index ceed639..b706e88 100644 --- a/gen.subproj/ftok.3 +++ b/gen/ftok.3 @@ -1,5 +1,3 @@ -.\" $OpenBSD: ftok.3,v 1.8 1999/07/07 10:55:36 aaron Exp $ -.\" .\" Copyright (c) 1994 SigmaSoft, Th. Lockert .\" All rights reserved. .\" @@ -25,22 +23,28 @@ .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF .\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" +.\" $FreeBSD: src/lib/libc/gen/ftok.3,v 1.14 2001/10/01 16:08:50 ru Exp $ .Dd June 24, 1994 -.Dt FTOK 3 .Os +.Dt FTOK 3 .Sh NAME .Nm ftok -.Nd create IPC indentifier from a pathname +.Nd create IPC identifier from path name +.Sh LIBRARY +.Lb libc .Sh SYNOPSIS -.Fd #include -.Fd #include +.In sys/types.h +.In sys/ipc.h .Ft key_t -.Fn ftok "const char *path" "int id" ; +.Fn ftok "const char *path" "int id" .Sh DESCRIPTION +.Bf -symbolic +This function is available from the compatibility library, libcompat. +.Ef The .Fn ftok function attempts to create a unique key suitable for use with the -.Xr msgget 2 , +.Xr msgget 3 , .Xr semget 2 and .Xr shmget 2 @@ -51,37 +55,31 @@ of an existing file and a user-selectable .Pp The specified .Fa path -must refer to an existing file that is accessible to the calling process +must specify an existing file that is accessible to the calling process or the call will fail. Also, note that links to files will return the same key, given the same .Fa id . -Only the 8 least significant bits of -.Fa id -are used in the key generation; the rest of the bits are ignored. .Sh RETURN VALUES The .Fn ftok -function will return (key_t)\-1 if +function will return -1 if .Fa path does not exist or if it cannot be accessed by the calling process. .Sh SEE ALSO -.Xr msgget 2 , .Xr semget 2 , -.Xr shmget 2 +.Xr shmget 2 , +.Xr msgget 3 .Sh HISTORY The .Fn ftok -function originated with System V and is typically used by programs +function originates with System V and is typically used by programs that use the System V IPC routines. -.Sh AUTHOR -Thorsten Lockert +.Sh AUTHORS +.An Thorsten Lockert Aq tholo@sigmasoft.com .Sh BUGS -The returned key is computed based on the device and inode of the +The returned key is computed based on the device minor number and inode of the specified .Fa path -in combination with the given +in combination with the lower 8 bits of the given .Fa id . -Thus it is quite possible for the routine to return duplicate keys -given that those fields are not 8- and 16-bit quantities like they -were on System V based systems where this library routine's ancestors -were originally created. +Thus it is quite possible for the routine to return duplicate keys. diff --git a/gen.subproj/ftok.c b/gen/ftok.c similarity index 100% rename from gen.subproj/ftok.c rename to gen/ftok.c diff --git a/gen/fts.3 b/gen/fts.3 new file mode 100644 index 0000000..9a02ab3 --- /dev/null +++ b/gen/fts.3 @@ -0,0 +1,761 @@ +.\" Copyright (c) 1989, 1991, 1993, 1994 +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)fts.3 8.5 (Berkeley) 4/16/94 +.\" $FreeBSD: src/lib/libc/gen/fts.3,v 1.13 2001/09/20 12:32:45 ru Exp $ +.\" +.Dd April 16, 1994 +.Dt FTS 3 +.Os +.Sh NAME +.Nm fts +.Nd traverse a file hierarchy +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In sys/stat.h +.In fts.h +.Ft FTS * +.Fn fts_open "char * const *path_argv" "int options" "int (*compar)(const FTSENT **, const FTSENT **)" +.Ft FTSENT * +.Fn fts_read "FTS *ftsp" +.Ft FTSENT * +.Fn fts_children "FTS *ftsp" "int options" +.Ft int +.Fn fts_set "FTS *ftsp" "FTSENT *f" "int options" +.Ft int +.Fn fts_close "FTS *ftsp" +.Sh DESCRIPTION +The +.Nm +functions are provided for traversing +.Tn UNIX +file hierarchies. +A simple overview is that the +.Fn fts_open +function returns a +.Dq handle +on a file hierarchy, which is then supplied to +the other +.Nm +functions. +The function +.Fn fts_read +returns a pointer to a structure describing one of the files in the file +hierarchy. +The function +.Fn fts_children +returns a pointer to a linked list of structures, each of which describes +one of the files contained in a directory in the hierarchy. +In general, directories are visited two distinguishable times; in pre-order +(before any of their descendants are visited) and in post-order (after all +of their descendants have been visited). +Files are visited once. +It is possible to walk the hierarchy +.Dq logically +(ignoring symbolic links) +or physically (visiting symbolic links), order the walk of the hierarchy or +prune and/or re-visit portions of the hierarchy. +.Pp +Two structures are defined (and typedef'd) in the include file +.Aq Pa fts.h . +The first is +.Fa FTS , +the structure that represents the file hierarchy itself. +The second is +.Fa FTSENT , +the structure that represents a file in the file +hierarchy. +Normally, an +.Fa FTSENT +structure is returned for every file in the file +hierarchy. +In this manual page, +.Dq file +and +.Dq Fa FTSENT No structure +are generally +interchangeable. +The +.Fa FTSENT +structure contains at least the following fields, which are +described in greater detail below: +.Bd -literal +typedef struct _ftsent { + u_short fts_info; /* flags for FTSENT structure */ + char *fts_accpath; /* access path */ + char *fts_path; /* root path */ + u_short fts_pathlen; /* strlen(fts_path) */ + char *fts_name; /* file name */ + u_short fts_namelen; /* strlen(fts_name) */ + short fts_level; /* depth (\-1 to N) */ + int fts_errno; /* file errno */ + long fts_number; /* local numeric value */ + void *fts_pointer; /* local address value */ + struct ftsent *fts_parent; /* parent directory */ + struct ftsent *fts_link; /* next file structure */ + struct ftsent *fts_cycle; /* cycle structure */ + struct stat *fts_statp; /* stat(2) information */ +} FTSENT; +.Ed +.Pp +These fields are defined as follows: +.Bl -tag -width "fts_namelen" +.It Fa fts_info +One of the following values describing the returned +.Fa FTSENT +structure and +the file it represents. +With the exception of directories without errors +.Pq Dv FTS_D , +all of these +entries are terminal, that is, they will not be revisited, nor will any +of their descendants be visited. +.Bl -tag -width FTS_DEFAULT +.It Dv FTS_D +A directory being visited in pre-order. +.It Dv FTS_DC +A directory that causes a cycle in the tree. +(The +.Fa fts_cycle +field of the +.Fa FTSENT +structure will be filled in as well.) +.It Dv FTS_DEFAULT +Any +.Fa FTSENT +structure that represents a file type not explicitly described +by one of the other +.Fa fts_info +values. +.It Dv FTS_DNR +A directory which cannot be read. +This is an error return, and the +.Fa fts_errno +field will be set to indicate what caused the error. +.It Dv FTS_DOT +A file named +.Ql .\& +or +.Ql ..\& +which was not specified as a file name to +.Fn fts_open +(see +.Dv FTS_SEEDOT ) . +.It Dv FTS_DP +A directory being visited in post-order. +The contents of the +.Fa FTSENT +structure will be unchanged from when +it was returned in pre-order, i.e. with the +.Fa fts_info +field set to +.Dv FTS_D . +.It Dv FTS_ERR +This is an error return, and the +.Fa fts_errno +field will be set to indicate what caused the error. +.It Dv FTS_F +A regular file. +.It Dv FTS_NS +A file for which no +.Xr stat 2 +information was available. +The contents of the +.Fa fts_statp +field are undefined. +This is an error return, and the +.Fa fts_errno +field will be set to indicate what caused the error. +.It Dv FTS_NSOK +A file for which no +.Xr stat 2 +information was requested. +The contents of the +.Fa fts_statp +field are undefined. +.It Dv FTS_SL +A symbolic link. +.It Dv FTS_SLNONE +A symbolic link with a non-existent target. +The contents of the +.Fa fts_statp +field reference the file characteristic information for the symbolic link +itself. +.El +.It Fa fts_accpath +A path for accessing the file from the current directory. +.It Fa fts_path +The path for the file relative to the root of the traversal. +This path contains the path specified to +.Fn fts_open +as a prefix. +.It Fa fts_pathlen +The length of the string referenced by +.Fa fts_path . +.It Fa fts_name +The name of the file. +.It Fa fts_namelen +The length of the string referenced by +.Fa fts_name . +.It Fa fts_level +The depth of the traversal, numbered from \-1 to N, where this file +was found. +The +.Fa FTSENT +structure representing the parent of the starting point (or root) +of the traversal is numbered +.Dv FTS_ROOTPARENTLEVEL +(\-1), and the +.Fa FTSENT +structure for the root +itself is numbered +.Dv FTS_ROOTLEVEL +(0). +.It Fa fts_errno +Upon return of a +.Fa FTSENT +structure from the +.Fn fts_children +or +.Fn fts_read +functions, with its +.Fa fts_info +field set to +.Dv FTS_DNR , +.Dv FTS_ERR +or +.Dv FTS_NS , +the +.Fa fts_errno +field contains the value of the external variable +.Va errno +specifying the cause of the error. +Otherwise, the contents of the +.Fa fts_errno +field are undefined. +.It Fa fts_number +This field is provided for the use of the application program and is +not modified by the +.Nm +functions. +It is initialized to 0. +.It Fa fts_pointer +This field is provided for the use of the application program and is +not modified by the +.Nm +functions. +It is initialized to +.Dv NULL . +.It Fa fts_parent +A pointer to the +.Fa FTSENT +structure referencing the file in the hierarchy +immediately above the current file, i.e. the directory of which this +file is a member. +A parent structure for the initial entry point is provided as well, +however, only the +.Fa fts_level , +.Fa fts_number +and +.Fa fts_pointer +fields are guaranteed to be initialized. +.It Fa fts_link +Upon return from the +.Fn fts_children +function, the +.Fa fts_link +field points to the next structure in the NULL-terminated linked list of +directory members. +Otherwise, the contents of the +.Fa fts_link +field are undefined. +.It Fa fts_cycle +If a directory causes a cycle in the hierarchy (see +.Dv FTS_DC ) , +either because +of a hard link between two directories, or a symbolic link pointing to a +directory, the +.Fa fts_cycle +field of the structure will point to the +.Fa FTSENT +structure in the hierarchy that references the same file as the current +.Fa FTSENT +structure. +Otherwise, the contents of the +.Fa fts_cycle +field are undefined. +.It Fa fts_statp +A pointer to +.Xr stat 2 +information for the file. +.El +.Pp +A single buffer is used for all of the paths of all of the files in the +file hierarchy. +Therefore, the +.Fa fts_path +and +.Fa fts_accpath +fields are guaranteed to be +.Dv NUL Ns -terminated +.Em only +for the file most recently returned by +.Fn fts_read . +To use these fields to reference any files represented by other +.Fa FTSENT +structures will require that the path buffer be modified using the +information contained in that +.Fa FTSENT +structure's +.Fa fts_pathlen +field. +Any such modifications should be undone before further calls to +.Fn fts_read +are attempted. +The +.Fa fts_name +field is always +.Dv NUL Ns -terminated . +.Sh FTS_OPEN +The +.Fn fts_open +function takes a pointer to an array of character pointers naming one +or more paths which make up a logical file hierarchy to be traversed. +The array must be terminated by a +.Dv NULL +pointer. +.Pp +There are +a number of options, at least one of which (either +.Dv FTS_LOGICAL +or +.Dv FTS_PHYSICAL ) +must be specified. +The options are selected by +.Em or Ns 'ing +the following values: +.Bl -tag -width "FTS_PHYSICAL" +.It Dv FTS_COMFOLLOW +This option causes any symbolic link specified as a root path to be +followed immediately whether or not +.Dv FTS_LOGICAL +is also specified. +.It Dv FTS_LOGICAL +This option causes the +.Nm +routines to return +.Fa FTSENT +structures for the targets of symbolic links +instead of the symbolic links themselves. +If this option is set, the only symbolic links for which +.Fa FTSENT +structures +are returned to the application are those referencing non-existent files. +Either +.Dv FTS_LOGICAL +or +.Dv FTS_PHYSICAL +.Em must +be provided to the +.Fn fts_open +function. +.It Dv FTS_NOCHDIR +As a performance optimization, the +.Nm +functions change directories as they walk the file hierarchy. +This has the side-effect that an application cannot rely on being +in any particular directory during the traversal. +The +.Dv FTS_NOCHDIR +option turns off this optimization, and the +.Nm +functions will not change the current directory. +Note that applications should not themselves change their current directory +and try to access files unless +.Dv FTS_NOCHDIR +is specified and absolute +pathnames were provided as arguments to +.Fn fts_open . +.It Dv FTS_NOSTAT +By default, returned +.Fa FTSENT +structures reference file characteristic information (the +.Fa statp +field) for each file visited. +This option relaxes that requirement as a performance optimization, +allowing the +.Nm +functions to set the +.Fa fts_info +field to +.Dv FTS_NSOK +and leave the contents of the +.Fa statp +field undefined. +.It Dv FTS_PHYSICAL +This option causes the +.Nm +routines to return +.Fa FTSENT +structures for symbolic links themselves instead +of the target files they point to. +If this option is set, +.Fa FTSENT +structures for all symbolic links in the +hierarchy are returned to the application. +Either +.Dv FTS_LOGICAL +or +.Dv FTS_PHYSICAL +.Em must +be provided to the +.Fn fts_open +function. +.It Dv FTS_SEEDOT +By default, unless they are specified as path arguments to +.Fn fts_open , +any files named +.Ql .\& +or +.Ql ..\& +encountered in the file hierarchy are ignored. +This option causes the +.Nm +routines to return +.Fa FTSENT +structures for them. +.It Dv FTS_XDEV +This option prevents +.Nm +from descending into directories that have a different device number +than the file from which the descent began. +.El +.Pp +The argument +.Fn compar +specifies a user-defined function which may be used to order the traversal +of the hierarchy. +It +takes two pointers to pointers to +.Fa FTSENT +structures as arguments and +should return a negative value, zero, or a positive value to indicate +if the file referenced by its first argument comes before, in any order +with respect to, or after, the file referenced by its second argument. +The +.Fa fts_accpath , +.Fa fts_path +and +.Fa fts_pathlen +fields of the +.Fa FTSENT +structures may +.Em never +be used in this comparison. +If the +.Fa fts_info +field is set to +.Dv FTS_NS +or +.Dv FTS_NSOK , +the +.Fa fts_statp +field may not either. +If the +.Fn compar +argument is +.Dv NULL , +the directory traversal order is in the order listed in +.Fa path_argv +for the root paths, and in the order listed in the directory for +everything else. +.Sh FTS_READ +The +.Fn fts_read +function returns a pointer to an +.Fa FTSENT +structure describing a file in +the hierarchy. +Directories (that are readable and do not cause cycles) are visited at +least twice, once in pre-order and once in post-order. +All other files are visited at least once. +(Hard links between directories that do not cause cycles or symbolic +links to symbolic links may cause files to be visited more than once, +or directories more than twice.) +.Pp +If all the members of the hierarchy have been returned, +.Fn fts_read +returns +.Dv NULL +and sets the external variable +.Va errno +to 0. +If an error unrelated to a file in the hierarchy occurs, +.Fn fts_read +returns +.Dv NULL +and sets +.Va errno +appropriately. +If an error related to a returned file occurs, a pointer to an +.Fa FTSENT +structure is returned, and +.Va errno +may or may not have been set (see +.Fa fts_info ) . +.Pp +The +.Fa FTSENT +structures returned by +.Fn fts_read +may be overwritten after a call to +.Fn fts_close +on the same file hierarchy stream, or, after a call to +.Fn fts_read +on the same file hierarchy stream unless they represent a file of type +directory, in which case they will not be overwritten until after a call to +.Fn fts_read +after the +.Fa FTSENT +structure has been returned by the function +.Fn fts_read +in post-order. +.Sh FTS_CHILDREN +The +.Fn fts_children +function returns a pointer to an +.Fa FTSENT +structure describing the first entry in a NULL-terminated linked list of +the files in the directory represented by the +.Fa FTSENT +structure most recently returned by +.Fn fts_read . +The list is linked through the +.Fa fts_link +field of the +.Fa FTSENT +structure, and is ordered by the user-specified comparison function, if any. +Repeated calls to +.Fn fts_children +will recreate this linked list. +.Pp +As a special case, if +.Fn fts_read +has not yet been called for a hierarchy, +.Fn fts_children +will return a pointer to the files in the logical directory specified to +.Fn fts_open , +i.e. the arguments specified to +.Fn fts_open . +Otherwise, if the +.Fa FTSENT +structure most recently returned by +.Fn fts_read +is not a directory being visited in pre-order, +or the directory does not contain any files, +.Fn fts_children +returns +.Dv NULL +and sets +.Va errno +to zero. +If an error occurs, +.Fn fts_children +returns +.Dv NULL +and sets +.Va errno +appropriately. +.Pp +The +.Fa FTSENT +structures returned by +.Fn fts_children +may be overwritten after a call to +.Fn fts_children , +.Fn fts_close +or +.Fn fts_read +on the same file hierarchy stream. +.Pp +.Em Option +may be set to the following value: +.Bl -tag -width FTS_NAMEONLY +.It Dv FTS_NAMEONLY +Only the names of the files are needed. +The contents of all the fields in the returned linked list of structures +are undefined with the exception of the +.Fa fts_name +and +.Fa fts_namelen +fields. +.El +.Sh FTS_SET +The function +.Fn fts_set +allows the user application to determine further processing for the +file +.Fa f +of the stream +.Fa ftsp . +The +.Fn fts_set +function +returns 0 on success, and \-1 if an error occurs. +.Em Option +must be set to one of the following values: +.Bl -tag -width FTS_PHYSICAL +.It Dv FTS_AGAIN +Re-visit the file; any file type may be re-visited. +The next call to +.Fn fts_read +will return the referenced file. +The +.Fa fts_stat +and +.Fa fts_info +fields of the structure will be reinitialized at that time, +but no other fields will have been changed. +This option is meaningful only for the most recently returned +file from +.Fn fts_read . +Normal use is for post-order directory visits, where it causes the +directory to be re-visited (in both pre and post-order) as well as all +of its descendants. +.It Dv FTS_FOLLOW +The referenced file must be a symbolic link. +If the referenced file is the one most recently returned by +.Fn fts_read , +the next call to +.Fn fts_read +returns the file with the +.Fa fts_info +and +.Fa fts_statp +fields reinitialized to reflect the target of the symbolic link instead +of the symbolic link itself. +If the file is one of those most recently returned by +.Fn fts_children , +the +.Fa fts_info +and +.Fa fts_statp +fields of the structure, when returned by +.Fn fts_read , +will reflect the target of the symbolic link instead of the symbolic link +itself. +In either case, if the target of the symbolic link does not exist the +fields of the returned structure will be unchanged and the +.Fa fts_info +field will be set to +.Dv FTS_SLNONE . +.Pp +If the target of the link is a directory, the pre-order return, followed +by the return of all of its descendants, followed by a post-order return, +is done. +.It Dv FTS_SKIP +No descendants of this file are visited. +The file may be one of those most recently returned by either +.Fn fts_children +or +.Fn fts_read . +.El +.Sh FTS_CLOSE +The +.Fn fts_close +function closes a file hierarchy stream +.Fa ftsp +and restores the current directory to the directory from which +.Fn fts_open +was called to open +.Fa ftsp . +The +.Fn fts_close +function +returns 0 on success, and \-1 if an error occurs. +.Sh ERRORS +The function +.Fn fts_open +may fail and set +.Va errno +for any of the errors specified for the library functions +.Xr open 2 +and +.Xr malloc 3 . +.Pp +The function +.Fn fts_close +may fail and set +.Va errno +for any of the errors specified for the library functions +.Xr chdir 2 +and +.Xr close 2 . +.Pp +The functions +.Fn fts_read +and +.Fn fts_children +may fail and set +.Va errno +for any of the errors specified for the library functions +.Xr chdir 2 , +.Xr malloc 3 , +.Xr opendir 3 , +.Xr readdir 3 +and +.Xr stat 2 . +.Pp +In addition, +.Fn fts_children , +.Fn fts_open +and +.Fn fts_set +may fail and set +.Va errno +as follows: +.Bl -tag -width Er +.It Bq Er EINVAL +The options were invalid. +.El +.Sh SEE ALSO +.Xr find 1 , +.Xr chdir 2 , +.Xr stat 2 , +.Xr qsort 3 +.Sh STANDARDS +The +.Nm +utility is expected to be included in a future +.St -p1003.1-88 +revision. diff --git a/gen.subproj/fts.c b/gen/fts.c similarity index 100% rename from gen.subproj/fts.c rename to gen/fts.c diff --git a/gen/getbootfile.3 b/gen/getbootfile.3 new file mode 100644 index 0000000..55cb6fe --- /dev/null +++ b/gen/getbootfile.3 @@ -0,0 +1,72 @@ +.\" Copyright (c) 1983, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" From: @(#)gethostname.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/getbootfile.3,v 1.9 2001/10/01 16:08:50 ru Exp $ +.\" +.Dd September 23, 1994 +.Dt GETBOOTFILE 3 +.Os +.Sh NAME +.Nm getbootfile +.Nd get kernel boot file name +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In paths.h +.Ft const char * +.Fn getbootfile void +.Sh DESCRIPTION +The +.Fn getbootfile +function retrieves the full pathname of the file from which the +current kernel was loaded, and returns a static pointer to the name. +A read/write interface to this information is available via the +.Xr sysctl 3 +MIB variable +.Dq Li kern.bootfile . +.Sh RETURN VALUES +If the call succeeds a string giving the pathname is returned. If it +fails, a null pointer is returned and an error code is +placed in the global location +.Va errno . +.Sh SEE ALSO +.Xr sysctl 3 +.Sh BUGS +If the boot blocks have not been modified to pass this information into +the kernel at boot time, the static string +.Dq Pa /kernel +is returned instead of the real boot file. +.Sh HISTORY +The +.Fn getbootfile +function call appeared in +.Fx 2.0 . diff --git a/gen/getbsize.3 b/gen/getbsize.3 new file mode 100644 index 0000000..8653389 --- /dev/null +++ b/gen/getbsize.3 @@ -0,0 +1,82 @@ +.\" Copyright (c) 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)getbsize.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/getbsize.3,v 1.8 2001/10/01 16:08:50 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt GETBSIZE 3 +.Os +.Sh NAME +.Nm getbsize +.Nd get user block size +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft char * +.Fn getbsize "int *headerlenp" "long *blocksizep" +.Sh DESCRIPTION +The +.Fn getbsize +function determines the user's preferred block size based on the value of the +.Dq BLOCKSIZE +environment variable; see +.Xr environ 7 +for details on its use and format. +.Pp +The +.Fn getbsize +function returns a pointer to a null-terminated string describing +the block size, something like +.Dq 1K-blocks . +The memory referenced by +.Fa headerlenp +is filled in with the length of the string (not including the +terminating null). +The memory referenced by +.Fa blocksizep +is filled in with block size, in bytes. +.Pp +If the user's block size is unreasonable, a warning message is +written to standard error and the returned information reflects +a block size of 512 bytes. +.Sh SEE ALSO +.Xr df 1 , +.Xr du 1 , +.Xr ls 1 , +.Xr systat 1 , +.Xr environ 7 +.Sh HISTORY +The +.Fn getbsize +function first appeared in +.Bx 4.4 . diff --git a/gen.subproj/getbsize.c b/gen/getbsize.c similarity index 100% rename from gen.subproj/getbsize.c rename to gen/getbsize.c diff --git a/gen/getcap.3 b/gen/getcap.3 new file mode 100644 index 0000000..0af2a4f --- /dev/null +++ b/gen/getcap.3 @@ -0,0 +1,542 @@ +.\" Copyright (c) 1992, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Casey Leedom of Lawrence Livermore National Laboratory. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)getcap.3 8.4 (Berkeley) 5/13/94 +.\" $FreeBSD: src/lib/libc/gen/getcap.3,v 1.20 2001/10/01 16:08:50 ru Exp $ +.\" +.Dd May 13, 1994 +.Dt GETCAP 3 +.Os +.Sh NAME +.Nm cgetent , +.Nm cgetset , +.Nm cgetmatch , +.Nm cgetcap , +.Nm cgetnum , +.Nm cgetstr , +.Nm cgetustr , +.Nm cgetfirst , +.Nm cgetnext , +.Nm cgetclose +.Nd capability database access routines +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft int +.Fn cgetent "char **buf" "char **db_array" "char *name" +.Ft int +.Fn cgetset "char *ent" +.Ft int +.Fn cgetmatch "char *buf" "char *name" +.Ft char * +.Fn cgetcap "char *buf" "char *cap" "int type" +.Ft int +.Fn cgetnum "char *buf" "char *cap" "long *num" +.Ft int +.Fn cgetstr "char *buf" "char *cap" "char **str" +.Ft int +.Fn cgetustr "char *buf" "char *cap" "char **str" +.Ft int +.Fn cgetfirst "char **buf" "char **db_array" +.Ft int +.Fn cgetnext "char **buf" "char **db_array" +.Ft int +.Fn cgetclose "void" +.Sh DESCRIPTION +The +.Fn cgetent +function extracts the capability +.Fa name +from the database specified by the +.Dv NULL +terminated file array +.Fa db_array +and returns a pointer to a +.Xr malloc 3 Ns \&'d +copy of it in +.Fa buf . +The +.Fn cgetent +function will first look for files ending in +.Pa .db +(see +.Xr cap_mkdb 1 ) +before accessing the ASCII file. +.Fa Buf +must be retained through all subsequent calls to +.Fn cgetmatch , +.Fn cgetcap , +.Fn cgetnum , +.Fn cgetstr , +and +.Fn cgetustr , +but may then be +.Xr free 3 Ns \&'d . +On success 0 is returned, 1 if the returned +record contains an unresolved +.Nm tc +expansion, +\-1 if the requested record couldn't be found, +\-2 if a system error was encountered (couldn't open/read a file, etc.) also +setting +.Va errno , +and \-3 if a potential reference loop is detected (see +.Ic tc= +comments below). +.Pp +The +.Fn cgetset +function enables the addition of a character buffer containing a single capability +record entry +to the capability database. +Conceptually, the entry is added as the first ``file'' in the database, and +is therefore searched first on the call to +.Fn cgetent . +The entry is passed in +.Fa ent . +If +.Fa ent +is +.Dv NULL , +the current entry is removed from the database. +A call to +.Fn cgetset +must precede the database traversal. It must be called before the +.Fn cgetent +call. If a sequential access is being performed (see below), it must be called +before the first sequential access call +.Fn ( cgetfirst +or +.Fn cgetnext ) , +or be directly preceded by a +.Fn cgetclose +call. +On success 0 is returned and \-1 on failure. +.Pp +The +.Fn cgetmatch +function will return 0 if +.Fa name +is one of the names of the capability record +.Fa buf , +\-1 if +not. +.Pp +The +.Fn cgetcap +function searches the capability record +.Fa buf +for the capability +.Fa cap +with type +.Fa type . +A +.Fa type +is specified using any single character. If a colon (`:') is used, an +untyped capability will be searched for (see below for explanation of +types). A pointer to the value of +.Fa cap +in +.Fa buf +is returned on success, +.Dv NULL +if the requested capability couldn't be +found. The end of the capability value is signaled by a `:' or +.Tn ASCII +.Dv NUL +(see below for capability database syntax). +.Pp +The +.Fn cgetnum +function retrieves the value of the numeric capability +.Fa cap +from the capability record pointed to by +.Fa buf . +The numeric value is returned in the +.Ft long +pointed to by +.Fa num . +0 is returned on success, \-1 if the requested numeric capability couldn't +be found. +.Pp +The +.Fn cgetstr +function retrieves the value of the string capability +.Fa cap +from the capability record pointed to by +.Fa buf . +A pointer to a decoded, +.Dv NUL +terminated, +.Xr malloc 3 Ns \&'d +copy of the string is returned in the +.Ft char * +pointed to by +.Fa str . +The number of characters in the decoded string not including the trailing +.Dv NUL +is returned on success, \-1 if the requested string capability couldn't +be found, \-2 if a system error was encountered (storage allocation +failure). +.Pp +The +.Fn cgetustr +function is identical to +.Fn cgetstr +except that it does not expand special characters, but rather returns each +character of the capability string literally. +.Pp +The +.Fn cgetfirst +and +.Fn cgetnext +functions comprise a function group that provides for sequential +access of the +.Dv NULL +pointer terminated array of file names, +.Fa db_array . +The +.Fn cgetfirst +function returns the first record in the database and resets the access +to the first record. +The +.Fn cgetnext +function returns the next record in the database with respect to the +record returned by the previous +.Fn cgetfirst +or +.Fn cgetnext +call. If there is no such previous call, the first record in the database is +returned. +Each record is returned in a +.Xr malloc 3 Ns \&'d +copy pointed to by +.Fa buf . +.Ic Tc +expansion is done (see +.Ic tc= +comments below). +Upon completion of the database 0 is returned, 1 is returned upon successful +return of record with possibly more remaining (we haven't reached the end of +the database yet), 2 is returned if the record contains an unresolved +.Nm tc +expansion, \-1 is returned if an system error occurred, and \-2 +is returned if a potential reference loop is detected (see +.Ic tc= +comments below). +Upon completion of database (0 return) the database is closed. +.Pp +The +.Fn cgetclose +function closes the sequential access and frees any memory and file descriptors +being used. Note that it does not erase the buffer pushed by a call to +.Fn cgetset . +.Sh CAPABILITY DATABASE SYNTAX +Capability databases are normally +.Tn ASCII +and may be edited with standard +text editors. Blank lines and lines beginning with a `#' are comments +and are ignored. Lines ending with a `\|\e' indicate that the next line +is a continuation of the current line; the `\|\e' and following newline +are ignored. Long lines are usually continued onto several physical +lines by ending each line except the last with a `\|\e'. +.Pp +Capability databases consist of a series of records, one per logical +line. Each record contains a variable number of `:'-separated fields +(capabilities). Empty fields consisting entirely of white space +characters (spaces and tabs) are ignored. +.Pp +The first capability of each record specifies its names, separated by `|' +characters. These names are used to reference records in the database. +By convention, the last name is usually a comment and is not intended as +a lookup tag. For example, the +.Em vt100 +record from the +.Nm termcap +database begins: +.Pp +.Dl "d0\||\|vt100\||\|vt100-am\||\|vt100am\||\|dec vt100:" +.Pp +giving four names that can be used to access the record. +.Pp +The remaining non-empty capabilities describe a set of (name, value) +bindings, consisting of a names optionally followed by a typed value: +.Bl -column "nameTvalue" +.It name Ta "typeless [boolean] capability" +.Em name No "is present [true]" +.It name Ns Em \&T Ns value Ta capability +.Pq Em name , \&T +has value +.Em value +.It name@ Ta "no capability" Em name No exists +.It name Ns Em T Ns \&@ Ta capability +.Pq Em name , T +does not exist +.El +.Pp +Names consist of one or more characters. Names may contain any character +except `:', but it's usually best to restrict them to the printable +characters and avoid use of graphics like `#', `=', `%', `@', etc. Types +are single characters used to separate capability names from their +associated typed values. Types may be any character except a `:'. +Typically, graphics like `#', `=', `%', etc. are used. Values may be any +number of characters and may contain any character except `:'. +.Sh CAPABILITY DATABASE SEMANTICS +Capability records describe a set of (name, value) bindings. Names may +have multiple values bound to them. Different values for a name are +distinguished by their +.Fa types . +The +.Fn cgetcap +function will return a pointer to a value of a name given the capability +name and the type of the value. +.Pp +The types `#' and `=' are conventionally used to denote numeric and +string typed values, but no restriction on those types is enforced. The +functions +.Fn cgetnum +and +.Fn cgetstr +can be used to implement the traditional syntax and semantics of `#' +and `='. +Typeless capabilities are typically used to denote boolean objects with +presence or absence indicating truth and false values respectively. +This interpretation is conveniently represented by: +.Pp +.Dl "(getcap(buf, name, ':') != NULL)" +.Pp +A special capability, +.Ic tc= name , +is used to indicate that the record specified by +.Fa name +should be substituted for the +.Ic tc +capability. +.Ic Tc +capabilities may interpolate records which also contain +.Ic tc +capabilities and more than one +.Ic tc +capability may be used in a record. A +.Ic tc +expansion scope (i.e., where the argument is searched for) contains the +file in which the +.Ic tc +is declared and all subsequent files in the file array. +.Pp +When a database is searched for a capability record, the first matching +record in the search is returned. When a record is scanned for a +capability, the first matching capability is returned; the capability +.Ic :nameT@: +will hide any following definition of a value of type +.Em T +for +.Fa name ; +and the capability +.Ic :name@: +will prevent any following values of +.Fa name +from being seen. +.Pp +These features combined with +.Ic tc +capabilities can be used to generate variations of other databases and +records by either adding new capabilities, overriding definitions with new +definitions, or hiding following definitions via `@' capabilities. +.Sh EXAMPLES +.Bd -unfilled -offset indent +example\||\|an example of binding multiple values to names:\e + :foo%bar:foo^blah:foo@:\e + :abc%xyz:abc^frap:abc$@:\e + :tc=more: +.Ed +.Pp +The capability foo has two values bound to it (bar of type `%' and blah of +type `^') and any other value bindings are hidden. The capability abc +also has two values bound but only a value of type `$' is prevented from +being defined in the capability record more. +.Pp +.Bd -unfilled -offset indent +file1: + new\||\|new_record\||\|a modification of "old":\e + :fript=bar:who-cares@:tc=old:blah:tc=extensions: +file2: + old\||\|old_record\||\|an old database record:\e + :fript=foo:who-cares:glork#200: +.Ed +.Pp +The records are extracted by calling +.Fn cgetent +with file1 preceding file2. +In the capability record new in file1, fript=bar overrides the definition +of fript=foo interpolated from the capability record old in file2, +who-cares@ prevents the definition of any who-cares definitions in old +from being seen, glork#200 is inherited from old, and blah and anything +defined by the record extensions is added to those definitions in old. +Note that the position of the fript=bar and who-cares@ definitions before +tc=old is important here. If they were after, the definitions in old +would take precedence. +.Sh CGETNUM AND CGETSTR SYNTAX AND SEMANTICS +Two types are predefined by +.Fn cgetnum +and +.Fn cgetstr : +.Bl -column "nameXnumber" +.Sm off +.It Em name No \&# Em number Ta numeric +.Sm on +capability +.Em name +has value +.Em number +.Sm off +.It Em name No = Em string Ta "string capability" +.Sm on +.Em name +has value +.Em string +.Sm off +.It Em name No \&#@ Ta "the numeric capability" +.Sm on +.Em name +does not exist +.Sm off +.It Em name No \&=@ Ta "the string capability" +.Sm on +.Em name +does not exist +.El +.Pp +Numeric capability values may be given in one of three numeric bases. +If the number starts with either +.Ql 0x +or +.Ql 0X +it is interpreted as a hexadecimal number (both upper and lower case a-f +may be used to denote the extended hexadecimal digits). +Otherwise, if the number starts with a +.Ql 0 +it is interpreted as an octal number. +Otherwise the number is interpreted as a decimal number. +.Pp +String capability values may contain any character. Non-printable +.Dv ASCII +codes, new lines, and colons may be conveniently represented by the use +of escape sequences: +.Bl -column "\e\|X,X\e\|X" "(ASCII octal nnn)" +^X ('X' & 037) control-X +\e\|b, \e\|B (ASCII 010) backspace +\e\|t, \e\|T (ASCII 011) tab +\e\|n, \e\|N (ASCII 012) line feed (newline) +\e\|f, \e\|F (ASCII 014) form feed +\e\|r, \e\|R (ASCII 015) carriage return +\e\|e, \e\|E (ASCII 027) escape +\e\|c, \e\|C (:) colon +\e\|\e (\e\|) back slash +\e\|^ (^) caret +\e\|nnn (ASCII octal nnn) +.El +.Pp +A `\|\e' may be followed by up to three octal digits directly specifies +the numeric code for a character. The use of +.Tn ASCII +.Dv NUL Ns s , +while easily +encoded, causes all sorts of problems and must be used with care since +.Dv NUL Ns s +are typically used to denote the end of strings; many applications +use `\e\|200' to represent a +.Dv NUL . +.Sh DIAGNOSTICS +The +.Fn cgetent , +.Fn cgetset , +.Fn cgetmatch , +.Fn cgetnum , +.Fn cgetstr , +.Fn cgetustr , +.Fn cgetfirst , +and +.Fn cgetnext +functions +return a value greater than or equal to 0 on success and a value less +than 0 on failure. +The +.Fn cgetcap +function returns a character pointer on success and a +.Dv NULL +on failure. +.Pp +The +.Fn cgetent , +and +.Fn cgetseq +functions may fail and set +.Va errno +for any of the errors specified for the library functions: +.Xr fopen 3 , +.Xr fclose 3 , +.Xr open 2 , +and +.Xr close 2 . +.Pp +The +.Fn cgetent , +.Fn cgetset , +.Fn cgetstr , +and +.Fn cgetustr +functions +may fail and set +.Va errno +as follows: +.Bl -tag -width Er +.It Bq Er ENOMEM +No memory to allocate. +.El +.Sh SEE ALSO +.Xr cap_mkdb 1 , +.Xr malloc 3 +.Sh BUGS +Colons (`:') can't be used in names, types, or values. +.Pp +There are no checks for +.Ic tc Ns = Ns Ic name +loops in +.Fn cgetent . +.Pp +The buffer added to the database by a call to +.Fn cgetset +is not unique to the database but is rather prepended to any database used. diff --git a/gen.subproj/getcap.c b/gen/getcap.c similarity index 100% rename from gen.subproj/getcap.c rename to gen/getcap.c diff --git a/gen/getcwd.3 b/gen/getcwd.3 new file mode 100644 index 0000000..b095a46 --- /dev/null +++ b/gen/getcwd.3 @@ -0,0 +1,158 @@ +.\" Copyright (c) 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)getcwd.3 8.2 (Berkeley) 12/11/93 +.\" $FreeBSD: src/lib/libc/gen/getcwd.3,v 1.15 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd November 24, 1997 +.Dt GETCWD 3 +.Os +.Sh NAME +.Nm getcwd , +.Nm getwd +.Nd get working directory pathname +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft char * +.Fn getcwd "char *buf" "size_t size" +.Ft char * +.Fn getwd "char *buf" +.Sh DESCRIPTION +The +.Fn getcwd +function copies the absolute pathname of the current working directory +into the memory referenced by +.Fa buf +and returns a pointer to +.Fa buf . +The +.Fa size +argument is the size, in bytes, of the array referenced by +.Fa buf . +.Pp +If +.Fa buf +is +.Dv NULL , +space is allocated as necessary to store the pathname. +This space may later be +.Xr free 3 Ns 'd . +.Pp +The function +.Fn getwd +is a compatibility routine which calls +.Fn getcwd +with its +.Fa buf +argument and a size of +.Dv MAXPATHLEN +(as defined in the include +file +.Aq Pa sys/param.h ) . +Obviously, +.Fa buf +should be at least +.Dv MAXPATHLEN +bytes in length. +.Pp +These routines have traditionally been used by programs to save the +name of a working directory for the purpose of returning to it. +A much faster and less error-prone method of accomplishing this is to +open the current directory +.Pq Ql .\& +and use the +.Xr fchdir 2 +function to return. +.Sh RETURN VALUES +Upon successful completion, a pointer to the pathname is returned. +Otherwise a +.Dv NULL +pointer is returned and the global variable +.Va errno +is set to indicate the error. +In addition, +.Fn getwd +copies the error message associated with +.Va errno +into the memory referenced by +.Fa buf . +.Sh ERRORS +The +.Fn getcwd +function +will fail if: +.Bl -tag -width Er +.It Bq Er EACCES +Read or search permission was denied for a component of the pathname. +.It Bq Er EINVAL +The +.Fa size +argument is zero. +.It Bq Er ENOENT +A component of the pathname no longer exists. +.It Bq Er ENOMEM +Insufficient memory is available. +.It Bq Er ERANGE +The +.Fa size +argument is greater than zero but smaller than the length of the pathname +plus 1. +.El +.Sh SEE ALSO +.Xr chdir 2 , +.Xr fchdir 2 , +.Xr malloc 3 , +.Xr strerror 3 +.Sh STANDARDS +The +.Fn getcwd +function +conforms to +.St -p1003.1-90 . +The ability to specify a +.Dv NULL +pointer and have +.Fn getcwd +allocate memory as necessary is an extension. +.Sh HISTORY +The +.Fn getwd +function appeared in +.Bx 4.0 . +.Sh BUGS +The +.Fn getwd +function +does not do sufficient error checking and is not able to return very +long, but valid, paths. +It is provided for compatibility. diff --git a/gen.subproj/getcwd.c b/gen/getcwd.c similarity index 100% rename from gen.subproj/getcwd.c rename to gen/getcwd.c diff --git a/gen/getdomainname.3 b/gen/getdomainname.3 new file mode 100644 index 0000000..bb2b8a1 --- /dev/null +++ b/gen/getdomainname.3 @@ -0,0 +1,98 @@ +.\" Copyright (c) 1983, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)gethostname.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/getdomainname.3,v 1.14 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd May 6, 1994 +.Dt GETDOMAINNAME 3 +.Os +.Sh NAME +.Nm getdomainname , +.Nm setdomainname +.Nd get/set domain name of current host +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft int +.Fn getdomainname "char *name" "int namelen" +.Ft int +.Fn setdomainname "const char *name" "int namelen" +.Sh DESCRIPTION +.Fn Getdomainname +returns the standard domain name for the current processor, as +previously set by +.Fn setdomainname . +The parameter +.Fa namelen +specifies the size of the +.Fa name +array. The returned name is null-terminated unless insufficient +space is provided. +.Pp +.Fn Setdomainname +sets the domain name of the host machine to be +.Fa name , +which has length +.Fa namelen . +This call is restricted to the super-user and +is normally used only when the system is bootstrapped. +.Sh RETURN VALUES +.Rv -std +.Sh ERRORS +The following errors may be returned by these calls: +.Bl -tag -width Er +.It Bq Er EFAULT +The +.Fa name +or +.Fa namelen +parameter gave an +invalid address. +.It Bq Er EPERM +The caller tried to set the hostname and was not the super-user. +.El +.Sh SEE ALSO +.Xr gethostid 3 , +.Xr gethostname 3 , +.Xr sysctl 3 +.Sh BUGS +Domain names are limited to +.Dv MAXHOSTNAMELEN +(from +.Ao Pa sys/param.h Ac ) +characters, currently 256. +.Sh HISTORY +The +.Fn getdomainname +function call appeared in +.Bx 4.2 . diff --git a/gen/getfsent.3 b/gen/getfsent.3 new file mode 100644 index 0000000..a898b04 --- /dev/null +++ b/gen/getfsent.3 @@ -0,0 +1,153 @@ +.\" Copyright (c) 1983, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)getfsent.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/getfsent.3,v 1.9 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt GETFSENT 3 +.Os +.Sh NAME +.Nm getfsent , +.Nm getfsspec , +.Nm getfsfile , +.Nm setfsent , +.Nm endfsent +.Nd get file system descriptor file entry +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In fstab.h +.Ft struct fstab * +.Fn getfsent void +.Ft struct fstab * +.Fn getfsspec "const char *spec" +.Ft struct fstab * +.Fn getfsfile "const char *file" +.Ft int +.Fn setfsent void +.Ft void +.Fn endfsent void +.Sh DESCRIPTION +The +.Fn getfsent , +.Fn getfsspec , +and +.Fn getfsfile +functions +each return a pointer to an object with the following structure +containing the broken-out fields of a line in the file system +description file, +.Aq Pa fstab.h . +.Bd -literal -offset indent +struct fstab { + char *fs_spec; /* block special device name */ + char *fs_file; /* file system path prefix */ + char *fs_vfstype; /* File system type, ufs, nfs */ + char *fs_mntops; /* Mount options ala -o */ + char *fs_type; /* FSTAB_* from fs_mntops */ + int fs_freq; /* dump frequency, in days */ + int fs_passno; /* pass number on parallel fsck */ +}; +.Ed +.Pp +The fields have meanings described in +.Xr fstab 5 . +.Pp +The +.Fn setfsent +function +opens the file (closing any previously opened file) or rewinds it +if it is already open. +.Pp +The +.Fn endfsent +function +closes the file. +.Pp +The +.Fn getfsspec +and +.Fn getfsfile +functions +search the entire file (opening it if necessary) for a matching special +file name or file system file name. +.Pp +For programs wishing to read the entire database, +.Fn getfsent +reads the next entry (opening the file if necessary). +.Pp +All entries in the file with a type field equivalent to +.Dv FSTAB_XX +are ignored. +.Sh RETURN VALUES +The +.Fn getfsent , +.Fn getfsspec , +and +.Fn getfsfile +functions +return a +.Dv NULL +pointer on +.Dv EOF +or error. +The +.Fn setfsent +function +returns 0 on failure, 1 on success. +The +.Fn endfsent +function +returns nothing. +.Sh FILES +.Bl -tag -width /etc/fstab -compact +.It Pa /etc/fstab +.El +.Sh SEE ALSO +.Xr fstab 5 +.Sh HISTORY +The +.Fn getfsent +function appeared in +.Bx 4.0 ; +the +.Fn endfsent , +.Fn getfsfile , +.Fn getfsspec , +and +.Fn setfsent +functions appeared in +.Bx 4.3 . +.Sh BUGS +These functions use static data storage; +if the data is needed for future use, it should be +copied before any subsequent calls overwrite it. diff --git a/gen/getgrent.3 b/gen/getgrent.3 new file mode 100644 index 0000000..6b12306 --- /dev/null +++ b/gen/getgrent.3 @@ -0,0 +1,203 @@ +.\" Copyright (c) 1989, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" From: @(#)getgrent.3 8.2 (Berkeley) 4/19/94 +.\" $FreeBSD: src/lib/libc/gen/getgrent.3,v 1.16 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd September 29, 1994 +.Dt GETGRENT 3 +.Os +.Sh NAME +.Nm getgrent , +.Nm getgrnam , +.Nm getgrgid , +.Nm setgroupent , +.\" .Nm setgrfile , +.Nm setgrent , +.Nm endgrent +.Nd group database operations +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In grp.h +.Ft struct group * +.Fn getgrent void +.Ft struct group * +.Fn getgrnam "const char *name" +.Ft struct group * +.Fn getgrgid "gid_t gid" +.Ft int +.Fn setgroupent "int stayopen" +.\" .Ft void +.\" .Fn setgrfile "const char *name" +.Ft int +.Fn setgrent void +.Ft void +.Fn endgrent void +.Sh DESCRIPTION +These functions operate on the group database file +.Pa /etc/group +which is described +in +.Xr group 5 . +Each line of the database is defined by the structure +.Ar group +found in the include +file +.Aq Pa grp.h : +.Bd -literal -offset indent +struct group { + char *gr_name; /* group name */ + char *gr_passwd; /* group password */ + int gr_gid; /* group id */ + char **gr_mem; /* group members */ +}; +.Ed +.Pp +The functions +.Fn getgrnam +and +.Fn getgrgid +search the group database for the given group name pointed to by +.Ar name +or the group id pointed to by +.Ar gid , +respectively, returning the first one encountered. Identical group +names or group gids may result in undefined behavior. +.Pp +The +.Fn getgrent +function +sequentially reads the group database and is intended for programs +that wish to step through the complete list of groups. +.Pp +All three routines will open the group file for reading, if necessary. +.Pp +The +.Fn setgroupent +function +opens the file, or rewinds it if it is already open. If +.Fa stayopen +is non-zero, file descriptors are left open, significantly speeding +functions subsequent calls. This functionality is unnecessary for +.Fn getgrent +as it doesn't close its file descriptors by default. It should also +be noted that it is dangerous for long-running programs to use this +functionality as the group file may be updated. +.Pp +The +.Fn setgrent +function +is identical to +.Fn setgroupent +with an argument of zero. +.Pp +The +.Fn endgrent +function +closes any open files. +.Sh RETURN VALUES +The functions +.Fn getgrent , +.Fn getgrnam , +and +.Fn getgrgid , +return a pointer to the group entry if successful; if end-of-file +is reached or an error occurs a null pointer is returned. +The functions +.Fn setgroupent +and +.Fn setgrent +return the value 1 if successful, otherwise the value +0 is returned. +The functions +.Fn endgrent +and +.Fn setgrfile +have no return value. +.Sh FILES +.Bl -tag -width /etc/group -compact +.It Pa /etc/group +group database file +.El +.Sh SEE ALSO +.Xr getpwent 3 , +.Xr yp 4 , +.Xr group 5 , +.Xr nsswitch.conf 5 +.Sh HISTORY +The functions +.Fn endgrent , +.Fn getgrent , +.Fn getgrnam , +.Fn getgrgid , +and +.Fn setgrent +appeared in +.At v7 . +The functions +.Fn setgrfile +and +.Fn setgroupent +appeared in +.Bx 4.3 Reno . +.Sh COMPATIBILITY +The historic function +.Fn setgrfile , +which allowed the specification of alternate password databases, has +been deprecated and is no longer available. +.Sh BUGS +The functions +.Fn getgrent , +.Fn getgrnam , +.Fn getgrgid , +.Fn setgroupent +and +.Fn setgrent +leave their results in an internal static object and return +a pointer to that object. +Subsequent calls to +the same function +will modify the same object. +.Pp +The functions +.Fn getgrent , +.Fn endgrent , +.Fn setgroupent , +and +.Fn setgrent +are fairly useless in a networked environment and should be +avoided, if possible. +.Fn getgrent +makes no attempt to suppress duplicate information if multiple +sources are specified in +.Xr nsswitch.conf 5 . diff --git a/gen/getgrouplist.3 b/gen/getgrouplist.3 new file mode 100644 index 0000000..28364eb --- /dev/null +++ b/gen/getgrouplist.3 @@ -0,0 +1,96 @@ +.\" Copyright (c) 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)getgrouplist.3 8.1 (Berkeley) 6/9/93 +.\" $FreeBSD: src/lib/libc/gen/getgrouplist.3,v 1.7 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd June 9, 1993 +.Dt GETGROUPLIST 3 +.Os +.Sh NAME +.Nm getgrouplist +.Nd calculate group access list +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft int +.Fn getgrouplist "const char *name" "int basegid" "int *groups" "int *ngroups" +.Sh DESCRIPTION +The +.Fn getgrouplist +function reads through the group file and calculates +the group access list for the user specified in +.Fa name . +The +.Fa basegid +is automatically included in the groups list. +Typically this value is given as +the group number from the password file. +.Pp +The resulting group list is returned in the integer array pointed to by +.Fa groups . +The caller specifies the size of the +.Fa groups +array in the integer pointed to by +.Fa ngroups ; +the actual number of groups found is returned in +.Fa ngroups . +.Sh RETURN VALUES +The +.Fn getgrouplist +function +returns \-1 if the size of the group list is too small to +hold all the user's groups. +Here, the group array will be filled with as many groups as will fit. +.Sh FILES +.Bl -tag -width /etc/group -compact +.It Pa /etc/group +group membership list +.El +.Sh SEE ALSO +.Xr setgroups 2 , +.Xr initgroups 3 +.Sh HISTORY +The +.Fn getgrouplist +function first appeared in +.Bx 4.4 . +.Sh BUGS +The +.Fn getgrouplist +function +uses the routines based on +.Xr getgrent 3 . +If the invoking program uses any of these routines, +the group structure will +be overwritten in the call to +.Fn getgrouplist . diff --git a/string.subproj/strtok.c b/gen/getgrouplist.c similarity index 71% rename from string.subproj/strtok.c rename to gen/getgrouplist.c index 16521c3..ff9b54d 100644 --- a/string.subproj/strtok.c +++ b/gen/getgrouplist.c @@ -20,7 +20,7 @@ * @APPLE_LICENSE_HEADER_END@ */ /* - * Copyright (c) 1988, 1993 + * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,57 +52,59 @@ * SUCH DAMAGE. */ +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)getgrouplist.c 8.2 (Berkeley) 12/8/94"; +#endif /* LIBC_SCCS and not lint */ -#include +/* + * get credential + */ +#include #include +#include -char * -strtok(s, delim) - register char *s; - register const char *delim; +int +getgrouplist(uname, agroup, groups, grpcnt) + const char *uname; + int agroup; + register int *groups; + int *grpcnt; { - register char *spanp; - register int c, sc; - char *tok; - static char *last; - - - if (s == NULL && (s = last) == NULL) - return (NULL); + register struct group *grp; + register struct passwd *pw; + register int i, ngroups; + int ret, maxgroups; + ret = 0; + ngroups = 0; + maxgroups = *grpcnt; /* - * Skip (span) leading delimiters (s += strspn(s, delim), sort of). + * When installing primary group, duplicate it; + * the first element of groups is the effective gid + * and will be overwritten when a setgid file is executed. */ -cont: - c = *s++; - for (spanp = (char *)delim; (sc = *spanp++) != 0;) { - if (c == sc) - goto cont; - } - - if (c == 0) { /* no non-delimiter characters */ - last = NULL; - return (NULL); - } - tok = s - 1; - + groups[ngroups++] = agroup; + if (maxgroups > 1) + groups[ngroups++] = agroup; /* - * Scan token (scan for delimiters: s += strcspn(s, delim), sort of). - * Note that delim must have one NUL; we stop if we see that, too. + * Scan the group file to find additional groups. */ - for (;;) { - c = *s++; - spanp = (char *)delim; - do { - if ((sc = *spanp++) == c) { - if (c == 0) - s = NULL; - else - s[-1] = 0; - last = s; - return (tok); + setgrent(); + while (grp = getgrent()) { + if (grp->gr_gid == agroup) + continue; + for (i = 0; grp->gr_mem[i]; i++) { + if (!strcmp(grp->gr_mem[i], uname)) { + if (ngroups >= maxgroups) { + ret = -1; + break; + } + groups[ngroups++] = grp->gr_gid; + break; } - } while (sc != 0); + } } - /* NOTREACHED */ + endgrent(); + *grpcnt = ngroups; + return (ret); } diff --git a/gen/gethostname.3 b/gen/gethostname.3 new file mode 100644 index 0000000..9651d8d --- /dev/null +++ b/gen/gethostname.3 @@ -0,0 +1,99 @@ +.\" Copyright (c) 1983, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)gethostname.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/gethostname.3,v 1.11 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt GETHOSTNAME 3 +.Os +.Sh NAME +.Nm gethostname , +.Nm sethostname +.Nd get/set name of current host +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft int +.Fn gethostname "char *name" "int namelen" +.Ft int +.Fn sethostname "const char *name" "int namelen" +.Sh DESCRIPTION +.Fn Gethostname +returns the standard host name for the current processor, as +previously set by +.Fn sethostname . +The parameter +.Fa namelen +specifies the size of the +.Fa name +array. The returned name is null-terminated unless insufficient +space is provided. +.Pp +.Fn Sethostname +sets the name of the host machine to be +.Fa name , +which has length +.Fa namelen . +This call is restricted to the super-user and +is normally used only when the system is bootstrapped. +.Sh RETURN VALUES +.Rv -std +.Sh ERRORS +The following errors may be returned by these calls: +.Bl -tag -width Er +.It Bq Er EFAULT +The +.Fa name +or +.Fa namelen +parameter gave an +invalid address. +.It Bq Er EPERM +The caller tried to set the hostname and was not the super-user. +.El +.Sh SEE ALSO +.Xr gethostid 3 , +.Xr sysctl 3 +.Sh BUGS +Host names are limited to +.Dv MAXHOSTNAMELEN +(from +.Ao Pa sys/param.h Ac ) +characters, currently 256. +This includes the trailing +.Dv NUL . +.Sh HISTORY +The +.Fn gethostname +function call appeared in +.Bx 4.2 . diff --git a/gen.subproj/gethostname.c b/gen/gethostname.c similarity index 100% rename from gen.subproj/gethostname.c rename to gen/gethostname.c diff --git a/gen/getloadavg.3 b/gen/getloadavg.3 new file mode 100644 index 0000000..24e7cdf --- /dev/null +++ b/gen/getloadavg.3 @@ -0,0 +1,69 @@ +.\" Copyright (c) 1989, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)getloadavg.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/getloadavg.3,v 1.8 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt GETLOADAVG 3 +.Os +.Sh NAME +.Nm getloadavg +.Nd get system load averages +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft int +.Fn getloadavg "double loadavg[]" "int nelem" +.Sh DESCRIPTION +The +.Fn getloadavg +function returns the number of processes in the system run queue +averaged over various periods of time. +Up to +.Fa nelem +samples are retrieved and assigned to successive elements of +.Fa loadavg Ns Bq . +The system imposes a maximum of 3 samples, representing averages +over the last 1, 5, and 15 minutes, respectively. +.Sh DIAGNOSTICS +If the load average was unobtainable, \-1 is returned; otherwise, +the number of samples actually retrieved is returned. +.Sh SEE ALSO +.Xr uptime 1 , +.Xr kvm_getloadavg 3 , +.Xr sysctl 3 +.Sh HISTORY +The +.Fn getloadavg +function appeared in +.Bx 4.3 Reno . diff --git a/gen.subproj/getloadavg.c b/gen/getloadavg.c similarity index 100% rename from gen.subproj/getloadavg.c rename to gen/getloadavg.c diff --git a/gen.subproj/getlogin.c b/gen/getlogin.c similarity index 93% rename from gen.subproj/getlogin.c rename to gen/getlogin.c index 02563a6..1d9b8f2 100644 --- a/gen.subproj/getlogin.c +++ b/gen/getlogin.c @@ -59,16 +59,23 @@ #include #include #include +#include int _logname_valid = 0; /* known to setlogin() */ char * getlogin() { - static char logname[MAXLOGNAME + 1]; + static char *logname = NULL; + + if ( logname == NULL ) { + logname = malloc(MAXLOGNAME+1); + if ( logname == NULL ) + return NULL; + } if (_logname_valid == 0) { - if (_getlogin(logname, sizeof(logname) - 1) < 0) + if (_getlogin(logname, MAXLOGNAME) < 0) return ((char *)NULL); _logname_valid = 1; } diff --git a/gen/getmntinfo.3 b/gen/getmntinfo.3 new file mode 100644 index 0000000..58c08b8 --- /dev/null +++ b/gen/getmntinfo.3 @@ -0,0 +1,113 @@ +.\" Copyright (c) 1989, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)getmntinfo.3 8.1 (Berkeley) 6/9/93 +.\" $FreeBSD: src/lib/libc/gen/getmntinfo.3,v 1.11 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd June 9, 1993 +.Dt GETMNTINFO 3 +.Os +.Sh NAME +.Nm getmntinfo +.Nd get information about mounted file systems +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/param.h +.In sys/ucred.h +.In sys/mount.h +.Ft int +.Fn getmntinfo "struct statfs **mntbufp" "int flags" +.Sh DESCRIPTION +The +.Fn getmntinfo +function +returns an array of +.Fn statfs +structures describing each currently mounted file system (see +.Xr statfs 2 ) . +.Pp +The +.Fn getmntinfo +function +passes its +.Fa flags +parameter transparently to +.Xr getfsstat 2 . +.Sh RETURN VALUES +On successful completion, +.Fn getmntinfo +returns a count of the number of elements in the array. +The pointer to the array is stored into +.Fa mntbufp . +.Pp +If an error occurs, zero is returned and the external variable +.Va errno +is set to indicate the error. +Although the pointer +.Fa mntbufp +will be unmodified, any information previously returned by +.Fn getmntinfo +will be lost. +.Sh ERRORS +The +.Fn getmntinfo +function +may fail and set errno for any of the errors specified for the library +routines +.Xr getfsstat 2 +or +.Xr malloc 3 . +.Sh SEE ALSO +.Xr getfsstat 2 , +.Xr mount 2 , +.Xr statfs 2 , +.Xr mount 8 +.Sh HISTORY +The +.Fn getmntinfo +function first appeared in +.Bx 4.4 . +.Sh BUGS +The +.Fn getmntinfo +function writes the array of structures to an internal static object +and returns +a pointer to that object. +Subsequent calls to +.Fn getmntinfo +will modify the same object. +.Pp +The memory allocated by +.Fn getmntinfo +cannot be +.Xr free 3 Ns 'd +by the application. diff --git a/gen.subproj/getmntinfo.c b/gen/getmntinfo.c similarity index 100% rename from gen.subproj/getmntinfo.c rename to gen/getmntinfo.c diff --git a/gen/getnetgrent.3 b/gen/getnetgrent.3 new file mode 100644 index 0000000..7124aef --- /dev/null +++ b/gen/getnetgrent.3 @@ -0,0 +1,133 @@ +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)getnetgrent.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/getnetgrent.3,v 1.10 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt GETNETGRENT 3 +.Os +.Sh NAME +.Nm getnetgrent , +.Nm innetgr , +.Nm setnetgrent , +.Nm endnetgrent +.Nd netgroup database operations +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In netdb.h +.Ft int +.Fn getnetgrent "char **host" "char **user" "char **domain" +.Ft int +.Fn innetgr "const char *netgroup" "const char *host" "const char *user" "const char *domain" +.Ft void +.Fn setnetgrent "const char *netgroup" +.Ft void +.Fn endnetgrent void +.Sh DESCRIPTION +These functions operate on the netgroup database file +.Pa /etc/netgroup +which is described +in +.Xr netgroup 5 . +The database defines a set of netgroups, each made up of one or more triples: +.Bd -literal -offset indent +(host, user, domain) +.Ed +that defines a combination of host, user and domain. +Any of the three fields may be specified as ``wildcards'' that match any +string. +.Pp +The function +.Fn getnetgrent +sets the three pointer arguments to the strings of the next member of the +current netgroup. +If any of the string pointers are +.Sy (char *)0 +that field is considered a wildcard. +.Pp +The functions +.Fn setnetgrent +and +.Fn endnetgrent +set the current netgroup and terminate the current netgroup respectively. +If +.Fn setnetgrent +is called with a different netgroup than the previous call, an implicit +.Fn endnetgrent +is implied. +.Fn Setnetgrent +also sets the offset to the first member of the netgroup. +.Pp +The function +.Fn innetgr +searches for a match of all fields within the specified group. +If any of the +.Sy host , +.Sy user , +or +.Sy domain +arguments are +.Sy (char *)0 +those fields will match any string value in the netgroup member. +.Sh RETURN VALUES +The function +.Fn getnetgrent +returns 0 for ``no more netgroup members'' and 1 otherwise. +The function +.Fn innetgr +returns 1 for a successful match and 0 otherwise. +The functions +.Fn setnetgrent +and +.Fn endnetgrent +have no return value. +.Sh FILES +.Bl -tag -width /etc/netgroup -compact +.It Pa /etc/netgroup +netgroup database file +.El +.Sh SEE ALSO +.Xr netgroup 5 +.Sh COMPATIBILITY +The netgroup members have three string fields to maintain compatibility +with other vendor implementations, however it is not obvious what use the +.Sy domain +string has within +.Bx . +.Sh BUGS +The function +.Fn getnetgrent +returns pointers to dynamically allocated data areas that are freed when +the function +.Fn endnetgrent +is called. diff --git a/gen/getobjformat.3 b/gen/getobjformat.3 new file mode 100644 index 0000000..ce1144c --- /dev/null +++ b/gen/getobjformat.3 @@ -0,0 +1,128 @@ +.\" Copyright (c) 1998 John D. Polstra +.\" 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. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. +.\" +.\" $FreeBSD: src/lib/libc/gen/getobjformat.3,v 1.8 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd September 7, 1998 +.Dt GETOBJFORMAT 3 +.Os +.Sh NAME +.Nm getobjformat +.Nd get preferred object file format +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In objformat.h +.Ft int +.Fn getobjformat "char *buf" "size_t bufsize" "int *argcp" "char **argv" +.Sh DESCRIPTION +.Fn getobjformat +queries several sources to determine the preferred object file +format, and copies its name into a buffer provided by the caller. +.Pp +The object file format is determined as follows. If +.Va argv +is +.No non- Ns Ev NULL +and an explicit command line argument such as +.Fl aout +or +.Fl elf +is present, then that determines the object file format. +.Pp +Otherwise, if the variable +.Ev OBJFORMAT +is set in the environment, the object file format is taken from its +value. +.Pp +Otherwise, if the file +.Pa /etc/objformat +is readable and contains a line of the form +.Ql OBJFORMAT=xxx , +the object file format is taken from there. +.Pp +Otherwise, a built-in system default object file format is returned. +.Pp +.Va buf +points to a user-supplied buffer into which the name of the object +file format is copied. +.Va bufsize +gives the size of the buffer in bytes. The string placed in +.Va buf +is always null-terminated. It is an error if the buffer is too +small to hold the null-terminated name. +.Pp +.Va argv +points to a +.Dv NULL Ns -terminated +argument vector to be scanned for object +format options. +.Va argv +may be +.Dv NULL , +in which case the argument vector is not scanned. +.Pp +If +.Va argcp +is non-NULL, any object format options are deleted from the +argument vector, and the updated argument count is stored into +the integer referenced by +.Va argcp . +If +.Va argcp +is +.Dv NULL , +the argument vector is left unchanged. +.Sh RETURN VALUES +On success, +.Fn getobjformat +returns the length of the object file format name, not counting the +null terminator. +If the supplied buffer is too small to hold the object file format +and its null terminator, +.Fn getobjformat +returns -1. In that case, the contents of the buffer and argument +vector supplied by the caller are indeterminate. +.Sh ENVIRONMENT +.Bl -tag -width OBJFORMAT +.It Ev OBJFORMAT +If the environment variable +.Ev OBJFORMAT +is set, it overrides the default object file format. +.Ev OBJFORMAT takes precedence over +.Pa /etc/objformat . +.El +.Sh FILES +.Bl -tag -width /etc/objformat -compact +.It Pa /etc/objformat +If present, specifies the object file format to use. Syntax is +.Ql OBJFORMAT=xxx . +.El +.Sh SEE ALSO +.Xr objformat 1 +.Sh HISTORY +The +.Fn getobjformat +function first appeared in +.Fx 3.0 . diff --git a/gen/getpagesize.3 b/gen/getpagesize.3 new file mode 100644 index 0000000..8f4cad3 --- /dev/null +++ b/gen/getpagesize.3 @@ -0,0 +1,63 @@ +.\" Copyright (c) 1983, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)getpagesize.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/getpagesize.3,v 1.9 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt GETPAGESIZE 3 +.Os +.Sh NAME +.Nm getpagesize +.Nd get system page size +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft int +.Fn getpagesize void +.Sh DESCRIPTION +.Fn Getpagesize +returns the number of bytes in a page. +Page granularity is the granularity of many of the memory +management calls. +.Pp +The page size is a system +page size and may not be the same as the underlying +hardware page size. +.Sh SEE ALSO +.Xr pagesize 1 , +.Xr sbrk 2 +.Sh HISTORY +The +.Fn getpagesze +function call appeared in +.Bx 4.2 . diff --git a/gen.subproj/getpagesize.c b/gen/getpagesize.c similarity index 100% rename from gen.subproj/getpagesize.c rename to gen/getpagesize.c diff --git a/gen/getpass.3 b/gen/getpass.3 new file mode 100644 index 0000000..430a47e --- /dev/null +++ b/gen/getpass.3 @@ -0,0 +1,96 @@ +.\" Copyright (c) 1989, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)getpass.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/getpass.3,v 1.9 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt GETPASS 3 +.Os +.Sh NAME +.Nm getpass +.Nd get a password +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In pwd.h +.In unistd.h +.Ft char * +.Fn getpass "const char *prompt" +.Sh DESCRIPTION +The +.Fn getpass +function displays a prompt to, and reads in a password from, +.Pa /dev/tty . +If this file is not accessible, +.Fn getpass +displays the prompt on the standard error output and reads from the standard +input. +.Pp +The password may be up to _PASSWORD_LEN (currently 128) +characters in length. +Any additional +characters and the terminating newline character are discarded. +.Pp +The +.Fn getpass +function turns off character echoing while reading the password. +.Sh RETURN VALUES +The +.Fn getpass +function returns a pointer to the null terminated password. +.Sh FILES +.Bl -tag -width /dev/tty -compact +.It Pa /dev/tty +.El +.Sh SEE ALSO +.Xr crypt 3 +.Sh HISTORY +A +.Fn getpass +function appeared in +.At v7 . +.Sh BUGS +The +.Fn getpass +function leaves its result in an internal static object and returns +a pointer to that object. +Subsequent calls to +.Fn getpass +will modify the same object. +.Pp +The calling process should zero the password as soon as possible to +avoid leaving the cleartext password visible in the process's address +space. +.Pp +Upon receipt of a SIGTSTP, the input buffer will be flushed, so any +partially typed password must be retyped when the process +continues. diff --git a/gen.subproj/getpass.c b/gen/getpass.c similarity index 100% rename from gen.subproj/getpass.c rename to gen/getpass.c diff --git a/gen/getpeereid.3 b/gen/getpeereid.3 new file mode 100644 index 0000000..ef07e29 --- /dev/null +++ b/gen/getpeereid.3 @@ -0,0 +1,134 @@ +.\" +.\" Copyright (c) 2001 Dima Dorfman. +.\" 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. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. +.\" +.\" $FreeBSD: src/lib/libc/gen/getpeereid.3,v 1.2 2001/08/21 19:32:47 dd Exp $ +.\" +.Dd July 15, 2001 +.Dt GETPEEREID 3 +.Os +.Sh NAME +.Nm getpeereid +.Nd get the effective credentials of a UNIX-domain peer +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In unistd.h +.Ft int +.Fn getpeereid "int s" "uid_t *euid" "gid_t *egid" +.Sh DESCRIPTION +The +.Fn getpeereid +function returns the effective user and group IDs of the +peer connected to a +.Ux Ns -domain +socket. +The argument +.Fa s +must be a +.Ux Ns -domain +socket +.Pq Xr unix 4 +of type +.Dv SOCK_STREAM +on which either +.Xr connect 2 +or +.Xr listen 2 +have been called. +The effective used ID is placed in +.Fa euid , +and the effective group ID in +.Fa egid . +.Pp +The credentials returned to the +.Xr listen 2 +caller are those of its peer at the time it called +.Xr connect 2 ; +the credentials returned to the +.Xr connect 2 +caller are those of its peer at the time it called +.Xr listen 2 . +This mechanism is reliable; there is no way for either side to influence +the credentials returned to its peer except by calling the appropriate +system call (i.e., either +.Xr connect 2 +or +.Xr listen 2 ) +under different effective credentials. +.Pp +One common use of this routine is for a +.Ux Ns -domain +server +to verify the credentials of its client. +Likewise, the client can verify the credentials of the server. +.Sh IMPLEMENTATION NOTES +On +.Fx , +.Fn getpeereid +is implemented in terms of the +.Dv LOCAL_PEERCRED +.Xr unix 4 +socket option. +.Sh RETURN VALUES +.Rv -std getpeerid +.Sh ERRORS +.Fn getpeerid +fails if: +.Bl -tag -width Er +.It Bq Er EBADF +The argument +.Fa s +is not a valid descriptor. +.It Bq Er ENOTSOCK +The argument +.Fa s +is a file, not a socket. +.It Bq Er ENOTCONN +The argument +.Fa s +does not refer to a socket on which +.Xr connect 2 +or +.Xr listen 2 +have been called. +.It Bq Er EINVAL +The argument +.Fa s +does not refer to a socket of type +.Dv SOCK_STREAM . +.El +.Sh SEE ALSO +.Xr connect 2 , +.Xr getpeername 2 , +.Xr getsockname 2 , +.Xr getsockopt 2 , +.Xr listen 2 , +.Xr unix 4 +.Sh HISTORY +The +.Fn getpeereid +function appeared in +.Fx 5.0 . diff --git a/gen/getpwent.3 b/gen/getpwent.3 new file mode 100644 index 0000000..6ce2003 --- /dev/null +++ b/gen/getpwent.3 @@ -0,0 +1,218 @@ +.\" Copyright (c) 1988, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" From: @(#)getpwent.3 8.2 (Berkeley) 12/11/93 +.\" $FreeBSD: src/lib/libc/gen/getpwent.3,v 1.18 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd September 20, 1994 +.Dt GETPWENT 3 +.Os +.Sh NAME +.Nm getpwent , +.Nm getpwnam , +.Nm getpwuid , +.Nm setpassent , +.Nm setpwent , +.Nm endpwent +.Nd password database operations +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In pwd.h +.Ft struct passwd * +.Fn getpwent void +.Ft struct passwd * +.Fn getpwnam "const char *login" +.Ft struct passwd * +.Fn getpwuid "uid_t uid" +.Ft int +.Fn setpassent "int stayopen" +.Ft void +.Fn setpwent void +.Ft void +.Fn endpwent void +.Sh DESCRIPTION +These functions +operate on the password database file +which is described +in +.Xr passwd 5 . +Each entry in the database is defined by the structure +.Ar passwd +found in the include +file +.Aq Pa pwd.h : +.Bd -literal -offset indent +struct passwd { + char *pw_name; /* user name */ + char *pw_passwd; /* encrypted password */ + uid_t pw_uid; /* user uid */ + gid_t pw_gid; /* user gid */ + time_t pw_change; /* password change time */ + char *pw_class; /* user access class */ + char *pw_gecos; /* Honeywell login info */ + char *pw_dir; /* home directory */ + char *pw_shell; /* default shell */ + time_t pw_expire; /* account expiration */ + int pw_fields; /* internal: fields filled in */ +}; +.Ed +.Pp +The functions +.Fn getpwnam +and +.Fn getpwuid +search the password database for the given login name or user uid, +respectively, always returning the first one encountered. +.Pp +The +.Fn getpwent +function +sequentially reads the password database and is intended for programs +that wish to process the complete list of users. +.Pp +The +.Fn setpassent +function +accomplishes two purposes. +First, it causes +.Fn getpwent +to ``rewind'' to the beginning of the database. +Additionally, if +.Fa stayopen +is non-zero, file descriptors are left open, significantly speeding +up subsequent accesses for all of the routines. +(This latter functionality is unnecessary for +.Fn getpwent +as it doesn't close its file descriptors by default.) +.Pp +It is dangerous for long-running programs to keep the file descriptors +open as the database will become out of date if it is updated while the +program is running. +.Pp +The +.Fn setpwent +function +is identical to +.Fn setpassent +with an argument of zero. +.Pp +The +.Fn endpwent +function +closes any open files. +.Pp +These routines have been written to ``shadow'' the password file, e.g.\& +allow only certain programs to have access to the encrypted password. +If the process which calls them has an effective uid of 0, the encrypted +password will be returned, otherwise, the password field of the returned +structure will point to the string +.Ql * . +.Sh RETURN VALUES +The functions +.Fn getpwent , +.Fn getpwnam , +and +.Fn getpwuid , +return a valid pointer to a passwd structure on success +and a null pointer if end-of-file is reached or an error occurs. +The +.Fn setpassent +function returns 0 on failure and 1 on success. +The +.Fn endpwent +and +.Fn setpwent +functions +have no return value. +.Sh FILES +.Bl -tag -width /etc/master.passwd -compact +.It Pa /etc/pwd.db +The insecure password database file +.It Pa /etc/spwd.db +The secure password database file +.It Pa /etc/master.passwd +The current password file +.It Pa /etc/passwd +A Version 7 format password file +.El +.Sh SEE ALSO +.Xr getlogin 2 , +.Xr getgrent 3 , +.Xr yp 4 , +.Xr nsswitch.conf 5 , +.Xr passwd 5 , +.Xr pwd_mkdb 8 , +.Xr vipw 8 +.Sh HISTORY +The +.Fn getpwent , +.Fn getpwnam , +.Fn getpwuid , +.Fn setpwent , +and +.Fn endpwent +functions appeared in +.At v7 . +The +.Fn setpassent +function appeared in +.Bx 4.3 Reno . +.Sh COMPATIBILITY +The historic function +.Xr setpwfile 3 , +which allowed the specification of alternate password databases, +has been deprecated and is no longer available. +.Sh BUGS +The functions +.Fn getpwent , +.Fn getpwnam , +and +.Fn getpwuid , +leave their results in an internal static object and return +a pointer to that object. +Subsequent calls to +the same function +will modify the same object. +.Pp +The functions +.Fn getpwent , +.Fn endpwent , +.Fn setpassent , +and +.Fn setpwent +are fairly useless in a networked environment and should be +avoided, if possible. +.Fn getpwent +makes no attempt to suppress duplicate information if multiple +sources are specified in +.Xr nsswitch.conf 5 . diff --git a/gen/getttyent.3 b/gen/getttyent.3 new file mode 100644 index 0000000..56d7a5d --- /dev/null +++ b/gen/getttyent.3 @@ -0,0 +1,212 @@ +.\" Copyright (c) 1989, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)getttyent.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/getttyent.3,v 1.12 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd November 17, 1996 +.Dt GETTTYENT 3 +.Os +.Sh NAME +.Nm getttyent , +.Nm getttynam , +.Nm setttyent , +.Nm endttyent +.Nd get ttys file entry +.Nm isdialuptty , +.Nm isnettty +.Nd determine tty type from ttys file entry +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In ttyent.h +.Ft struct ttyent * +.Fn getttyent void +.Ft struct ttyent * +.Fn getttynam "const char *name" +.Ft int +.Fn setttyent void +.Ft int +.Fn endttyent void +.Ft int +.Fn isdialuptty "const char *name" +.Ft int +.Fn isnettty "const char *name" +.Sh DESCRIPTION +The +.Fn getttyent , +and +.Fn getttynam +functions +each return a pointer to an object, with the following structure, +containing the broken-out fields of a line from the tty description +file. +.Bd -literal +struct ttyent { + char *ty_name; /* terminal device name */ + char *ty_getty; /* command to execute, usually getty */ + char *ty_type; /* terminal type for termcap */ +#define TTY_ON 0x01 /* enable logins (start ty_getty program) */ +#define TTY_SECURE 0x02 /* allow uid of 0 to login */ +#define TTY_DIALUP 0x04 /* is a dialup tty */ +#define TTY_NETWORK 0x08 /* is a network tty */ + int ty_status; /* status flags */ + char *ty_window; /* command to start up window manager */ + char *ty_comment; /* comment field */ + char *ty_group; /* tty group name */ +}; +.Ed +.Pp +The fields are as follows: +.Bl -tag -width ty_comment +.It Fa ty_name +The name of the character-special file. +.It Fa ty_getty +The name of the command invoked by +.Xr init 8 +to initialize tty line characteristics. +.It Fa ty_type +The name of the default terminal type connected to this tty line. +.It Fa ty_status +A mask of bit fields which indicate various actions allowed on this +tty line. +The possible flags are as follows: +.Bl -tag -width TTY_NETWORK +.It Dv TTY_ON +Enables logins (i.e., +.Xr init 8 +will start the command referenced by +.Fa ty_getty +on this entry). +.It Dv TTY_SECURE +Allow users with a uid of 0 to login on this terminal. +.It Dv TTY_DIALUP +Identifies a tty as a dialin line. +If this flag is set, then +.Fn isdialuptty +will return a non-zero value. +.It Dv TTY_NETWORK +Identifies a tty used for network connections. +If this flag is set, then +.Fn isnettty +will return a non-zero value. +.El +.It Fa ty_window +The command to execute for a window system associated with the line. +.It Fa ty_group +A group name to which the tty belongs. +If no group is specified in the ttys description file, +then the tty is placed in an anonymous group called "none". +.It Fa ty_comment +Any trailing comment field, with any leading hash marks (``#'') or +whitespace removed. +.El +.Pp +If any of the fields pointing to character strings are unspecified, +they are returned as null pointers. +The field +.Fa ty_status +will be zero if no flag values are specified. +.Pp +See +.Xr ttys 5 +for a more complete discussion of the meaning and usage of the +fields. +.Pp +The +.Fn getttyent +function +reads the next line from the ttys file, opening the file if necessary. +The +.Fn setttyent +function +rewinds the file if open, or opens the file if it is unopened. +The +.Fn endttyent +function +closes any open files. +.Pp +The +.Fn getttynam +function +searches from the beginning of the file until a matching +.Fa name +is found +(or until +.Dv EOF +is encountered). +.Sh RETURN VALUES +The routines +.Fn getttyent +and +.Fn getttynam +return a null pointer on +.Dv EOF +or error. +The +.Fn setttyent +function +and +.Fn endttyent +return 0 on failure and 1 on success. +.Pp +The routines +.Fn isdialuptty +and +.Fn isnettty +return non-zero if the dialup or network flag is set for the +tty entry relating to the tty named by the parameter, and +zero otherwise. +.Sh FILES +.Bl -tag -width /etc/ttys -compact +.It Pa /etc/ttys +.El +.Sh SEE ALSO +.Xr login 1 , +.Xr ttyslot 3 , +.Xr gettytab 5 , +.Xr termcap 5 , +.Xr ttys 5 , +.Xr getty 8 , +.Xr init 8 +.Sh HISTORY +The +.Fn getttyent , +.Fn getttynam , +.Fn setttyent , +and +.Fn endttyent +functions appeared in +.Bx 4.3 . +.Sh BUGS +These functions use static data storage; +if the data is needed for future use, it should be +copied before any subsequent calls overwrite it. diff --git a/gen.subproj/getttyent.c b/gen/getttyent.c similarity index 96% rename from gen.subproj/getttyent.c rename to gen/getttyent.c index f033908..89bf092 100644 --- a/gen.subproj/getttyent.c +++ b/gen/getttyent.c @@ -57,6 +57,7 @@ #include #include #include +#include static char zapchar; static FILE *tf; @@ -82,13 +83,19 @@ getttyent() register int c; register char *p; #define MAXLINELENGTH 1024 - static char line[MAXLINELENGTH]; + static char *line = NULL; static char *skip(), *value(); + if ( line == NULL ) { + line = malloc(MAXLINELENGTH); + if( line == NULL ) + return NULL; + } + if (!tf && !setttyent()) return (NULL); for (;;) { - if (!fgets(p = line, sizeof(line), tf)) + if (!fgets(p = line, MAXLINELENGTH, tf)) return (NULL); /* skip lines that are too big */ if (!index(p, '\n')) { diff --git a/gen/getusershell.3 b/gen/getusershell.3 new file mode 100644 index 0000000..4d8805e --- /dev/null +++ b/gen/getusershell.3 @@ -0,0 +1,103 @@ +.\" $NetBSD: getusershell.3,v 1.6 1999/03/22 19:44:42 garbled Exp $ +.\" $FreeBSD: src/lib/libc/gen/getusershell.3,v 1.10 2001/10/01 16:08:51 ru Exp $ +.\" +.\" Copyright (c) 1985, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)getusershell.3 8.1 (Berkeley) 6/4/93 +.\" +.Dd January 16, 1999 +.Dt GETUSERSHELL 3 +.Os +.Sh NAME +.Nm getusershell , +.Nm setusershell , +.Nm endusershell +.Nd get valid user shells +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft char * +.Fn getusershell void +.Ft void +.Fn setusershell void +.Ft void +.Fn endusershell void +.Sh DESCRIPTION +The +.Fn getusershell +function +returns a pointer to a valid user shell as defined by the +system manager in the shells database as described in +.Xr shells 5 . +If the shells database is not available, +.Fn getusershell +behaves as if +.Pa /bin/sh +and +.Pa /bin/csh +were listed. +.Pp +The +.Fn getusershell +function +reads the next +line (opening the file if necessary); +.Fn setusershell +rewinds the file; +.Fn endusershell +closes it. +.Sh FILES +.Bl -tag -width /etc/shells -compact +.It Pa /etc/shells +.El +.Sh DIAGNOSTICS +The routine +.Fn getusershell +returns a null pointer (0) on +.Dv EOF . +.Sh SEE ALSO +.Xr nsswitch.conf 5 , +.Xr shells 5 +.Sh HISTORY +The +.Fn getusershell +function appeared in +.Bx 4.3 . +.Sh BUGS +The +.Fn getusershell +function leaves its result in an internal static object and returns +a pointer to that object. +Subsequent calls to +.Fn getusershell +will modify the same object. diff --git a/gen.subproj/getusershell.c b/gen/getusershell.c similarity index 100% rename from gen.subproj/getusershell.c rename to gen/getusershell.c diff --git a/gen/getvfsbyname.3 b/gen/getvfsbyname.3 new file mode 100644 index 0000000..3b38bc1 --- /dev/null +++ b/gen/getvfsbyname.3 @@ -0,0 +1,97 @@ +.\" Copyright (c) 1995 +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)kvm_getvfsbyname.3 8.3 (Berkeley) 5/4/95 +.\" $FreeBSD: src/lib/libc/gen/getvfsbyname.3,v 1.12 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd May 4, 1995 +.Dt GETVFSBYNAME 3 +.Os +.Sh NAME +.Nm getvfsbyname +.Nd get information about a filesystem +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/param.h +.In sys/mount.h +.Ft int +.Fn getvfsbyname "const char *name" "struct vfsconf *vfc" +.Sh DESCRIPTION +The +.Fn getvfsbyname +function provides access to information about a +filesystem module that is configured in the kernel. +If successful, +the requested filesystem +.Fa vfsconf +is returned in the location pointed to by +.Fa vfc . +The fields in a +.Dq Li struct vfsconf +are defined as follows: +.Pp +.Bl -tag -compact -width vfc_refcount +.It vfc_name +the name of the filesystem +.It vfc_typenum +the filesystem type number assigned by the kernel +.It vfc_refcount +the number of active mount points using the filesystem +.It vfc_flags +flag bits as described in +.Xr getvfsent 3 +.El +.Sh RETURN VALUES +.Rv -std getvfsbyname +.Sh ERRORS +The following errors may be reported: +.Bl -tag -width Er +.It Bq Er EFAULT +The +.Fa vfc +pointer contains an invalid address. +.It Bq Er ENOENT +The +.Fa name +specifies a filesystem that is unknown or not configured in the kernel. +.El +.Sh SEE ALSO +.Xr mount 2 , +.Xr getvfsent 3 , +.Xr sysctl 3 , +.Xr mount 8 , +.Xr sysctl 8 +.Sh HISTORY +A variant of the +.Fn getvfsbyname +function first appeared in +.Fx 2.0 . diff --git a/gen.subproj/getvfsbyname.c b/gen/getvfsbyname.c similarity index 100% rename from gen.subproj/getvfsbyname.c rename to gen/getvfsbyname.c diff --git a/gen/getvfsent.3 b/gen/getvfsent.3 new file mode 100644 index 0000000..7795677 --- /dev/null +++ b/gen/getvfsent.3 @@ -0,0 +1,183 @@ +.\" $FreeBSD: src/lib/libc/gen/getvfsent.3,v 1.24 2001/10/01 16:08:51 ru Exp $ +.\" Written by Garrett A. Wollman, September 1994. +.\" This manual page is in the public domain. +.\" +.Dd September 24, 1994 +.Dt GETVFSENT 3 +.Os +.Sh NAME +.Nm getvfsent , +.Nm setvfsent , +.Nm endvfsent , +.Nm vfsisloadable , +.Nm vfsload +.Nd manage virtual filesystem modules +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/param.h +.In sys/mount.h +.Ft struct ovfsconf * +.Fn getvfsent "void" +.Ft void +.Fn setvfsent "int cachelist" +.Ft void +.Fn endvfsent "void" +.Ft int +.Fn vfsisloadable "const char *name" +.Ft int +.Fn vfsload "const char *name" +.Sh DESCRIPTION +The +.Fn getvfsent +function provides convenient access to a list of installed virtual +filesystem modules managed by the kernel. It steps through the +list of filesystems one at a time. A null pointer is returned when +no more data is available. The fields in a +.Dq Li struct ovfsconf +are as follows: +.Pp +.Bl -tag -compact -width vfc_refcount +.It vfc_name +the name of the filesystem +.It vfc_index +the filesystem type number assigned by the kernel and used in calls to +.Xr mount 2 +.It vfc_refcount +the number of references to this filesystem +(usually the number of mounts, but one greater for filesystems which +cannot be unloaded or which are statically linked into the kernel) +.It vfc_flags +flag bits +.El +.Pp +The flags are defined as follows: +.Pp +.Bl -tag -width VFCF_SYNTHETIC -compact +.It Dv VFCF_STATIC +statically compiled into kernel +.It Dv VFCF_NETWORK +may get data over the network +.It Dv VFCF_READONLY +writes are not implemented +.It Dv VFCF_SYNTHETIC +data does not represent real files +.It Dv VFCF_LOOPBACK +aliases some other mounted FS +.It Dv VFCF_UNICODE +stores file names as Unicode +.El +.Pp +The +.Fn setvfsent +and +.Fn endvfsent +functions are used to control caching of the filesystem list, which is +obtained in toto from the kernel via +.Xr sysctl 3 . +If the +.Fa cachelist +parameter to +.Fn setvfsent +is non-zero, the list will be retrieved only once, upon the first call +to one of the retrieval functions, until +.Fn endvfsent +is called to clear the cache. In general, +.Fn setvfsent 1 +should be called by programs using the +.Fn getvfsent +function, and +.Fn setvfsent 0 +(which is also the default state) +should be called by programs using the +.Fn vfsload +function. +.Pp +The +.Fn vfsisloadable +function returns a non-zero value if a later call to +.Fn vfsload name +is likely to succeed. We say +.Dq likely +because +.Fn vfsisloadable +does not check any of the conditions necessary for +.Fn vfsload +to succeed. +.Pp +The +.Fn vfsload +function attempts to load a kernel module implementing filesystem +.Fa name . +It returns zero if the filesystem module was successfully located and +loaded, or non-zero otherwise. It should only be called in the +following circumstances: +.Bl -enum +.It +.Fn getvfsbyname +has been called and returned a non-zero value. +.It +.Fn vfsisloadable +has been called and returned a non-zero value. +.El +.Pp +Here is an example, taken from the source to +.Xr mount_cd9660 8 : +.Bd -literal -offset indent + +struct vfsconf *vfc; +int error; + +/* setup code here */ + +error = getvfsbyname("cd9660", &vfc); +if (error && vfsisloadable("cd9660")) { + if (vfsload("cd9660")) + err(EX_OSERR, "vfsload(cd9660)"); + endvfsent(); /* flush cache */ + error = getvfsbyname("cd9660", &vfc); +} +if (error) + errx(1, "cd9660 filesystem is not available"); + +if (mount(vfc.vfc_name, dir, mntflags, &args) < 0) + err(1, NULL); + +.Ed +.Sh RETURN VALUES +The +.Fn getvfsent +routine returns a pointer to a static data structure when +it succeeds, and returns a null pointer when it fails. On failure, +.Va errno +may be set to one of the values documented for +.Xr sysctl 3 +or +.Xr malloc 3 , +if a failure of that function was the cause; otherwise +.Va errno +will be unmodified. +.Pp +The +.Fn vfsload +function returns a non-zero value on failure, or zero on success. If +.Fn vfsload +fails, +.Va errno +may be set to one of the values documented for +.Xr kldload 2 . +.Sh SEE ALSO +.Xr kldload 2 , +.Xr mount 2 , +.Xr mount 8 +.Sh AUTHORS +.An -nosplit +The loadable filesystem support was written by +.An Garrett A. Wollman , +based on generic loadable kernel module support by +.An Terry Lambert . +.Sh HISTORY +The +.Fn getvfsent +family of functions first appeared in +.Fx 2.0 . diff --git a/gen/glob.3 b/gen/glob.3 new file mode 100644 index 0000000..aa509a3 --- /dev/null +++ b/gen/glob.3 @@ -0,0 +1,466 @@ +.\" Copyright (c) 1989, 1991, 1993, 1994 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Guido van Rossum. +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)glob.3 8.3 (Berkeley) 4/16/94 +.\" $FreeBSD: src/lib/libc/gen/glob.3,v 1.20 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd April 16, 1994 +.Dt GLOB 3 +.Os +.Sh NAME +.Nm glob , +.Nm globfree +.Nd generate pathnames matching a pattern +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In glob.h +.Ft int +.Fn glob "const char *pattern" "int flags" "int (*errfunc)(const char *, int)" "glob_t *pglob" +.Ft void +.Fn globfree "glob_t *pglob" +.Sh DESCRIPTION +The +.Fn glob +function +is a pathname generator that implements the rules for file name pattern +matching used by the shell. +.Pp +The include file +.Pa glob.h +defines the structure type +.Fa glob_t , +which contains at least the following fields: +.Bd -literal +typedef struct { + int gl_pathc; /* count of total paths so far */ + int gl_matchc; /* count of paths matching pattern */ + int gl_offs; /* reserved at beginning of gl_pathv */ + int gl_flags; /* returned flags */ + char **gl_pathv; /* list of paths matching pattern */ +} glob_t; +.Ed +.Pp +The argument +.Fa pattern +is a pointer to a pathname pattern to be expanded. +The +.Fn glob +argument +matches all accessible pathnames against the pattern and creates +a list of the pathnames that match. +In order to have access to a pathname, +.Fn glob +requires search permission on every component of a path except the last +and read permission on each directory of any filename component of +.Fa pattern +that contains any of the special characters +.Ql * , +.Ql ?\& +or +.Ql \&[ . +.Pp +The +.Fn glob +argument +stores the number of matched pathnames into the +.Fa gl_pathc +field, and a pointer to a list of pointers to pathnames into the +.Fa gl_pathv +field. +The first pointer after the last pathname is +.Dv NULL . +If the pattern does not match any pathnames, the returned number of +matched paths is set to zero. +.Pp +It is the caller's responsibility to create the structure pointed to by +.Fa pglob . +The +.Fn glob +function allocates other space as needed, including the memory pointed +to by +.Fa gl_pathv . +.Pp +The argument +.Fa flags +is used to modify the behavior of +.Fn glob . +The value of +.Fa flags +is the bitwise inclusive +.Tn OR +of any of the following +values defined in +.Pa glob.h : +.Bl -tag -width GLOB_ALTDIRFUNC +.It Dv GLOB_APPEND +Append pathnames generated to the ones from a previous call (or calls) +to +.Fn glob . +The value of +.Fa gl_pathc +will be the total matches found by this call and the previous call(s). +The pathnames are appended to, not merged with the pathnames returned by +the previous call(s). +Between calls, the caller must not change the setting of the +.Dv GLOB_DOOFFS +flag, nor change the value of +.Fa gl_offs +when +.Dv GLOB_DOOFFS +is set, nor (obviously) call +.Fn globfree +for +.Fa pglob . +.It Dv GLOB_DOOFFS +Make use of the +.Fa gl_offs +field. +If this flag is set, +.Fa gl_offs +is used to specify how many +.Dv NULL +pointers to prepend to the beginning +of the +.Fa gl_pathv +field. +In other words, +.Fa gl_pathv +will point to +.Fa gl_offs +.Dv NULL +pointers, +followed by +.Fa gl_pathc +pathname pointers, followed by a +.Dv NULL +pointer. +.It Dv GLOB_ERR +Causes +.Fn glob +to return when it encounters a directory that it cannot open or read. +Ordinarily, +.Fn glob +continues to find matches. +.It Dv GLOB_MARK +Each pathname that is a directory that matches +.Fa pattern +has a slash +appended. +.It Dv GLOB_NOCHECK +If +.Fa pattern +does not match any pathname, then +.Fn glob +returns a list +consisting of only +.Fa pattern , +with the number of total pathnames is set to 1, and the number of matched +pathnames set to 0. +If +.Dv GLOB_QUOTE +is set, its effect is present in the pattern returned. +.It Dv GLOB_NOSORT +By default, the pathnames are sorted in ascending +.Tn ASCII +order; +this flag prevents that sorting (speeding up +.Fn glob ) . +.El +.Pp +The following values may also be included in +.Fa flags , +however, they are non-standard extensions to +.St -p1003.2 . +.Bl -tag -width GLOB_ALTDIRFUNC +.It Dv GLOB_ALTDIRFUNC +The following additional fields in the pglob structure have been +initialized with alternate functions for glob to use to open, read, +and close directories and to get stat information on names found +in those directories. +.Bd -literal +void *(*gl_opendir)(const char * name); +struct dirent *(*gl_readdir)(void *); +void (*gl_closedir)(void *); +int (*gl_lstat)(const char *name, struct stat *st); +int (*gl_stat)(const char *name, struct stat *st); +.Ed +.Pp +This extension is provided to allow programs such as +.Xr restore 8 +to provide globbing from directories stored on tape. +.It Dv GLOB_BRACE +Pre-process the pattern string to expand +.Ql {pat,pat,...} +strings like +.Xr csh 1 . +The pattern +.Ql {} +is left unexpanded for historical reasons (and +.Xr csh 1 +does the same thing to +ease typing +of +.Xr find 1 +patterns). +.It Dv GLOB_MAGCHAR +Set by the +.Fn glob +function if the pattern included globbing characters. +See the description of the usage of the +.Fa gl_matchc +structure member for more details. +.It Dv GLOB_NOMAGIC +Is the same as +.Dv GLOB_NOCHECK +but it only appends the +.Fa pattern +if it does not contain any of the special characters ``*'', ``?'' or ``[''. +.Dv GLOB_NOMAGIC +is provided to simplify implementing the historic +.Xr csh 1 +globbing behavior and should probably not be used anywhere else. +.It Dv GLOB_QUOTE +Use the backslash +.Pq Ql \e +character for quoting: every occurrence of +a backslash followed by a character in the pattern is replaced by that +character, avoiding any special interpretation of the character. +.It Dv GLOB_TILDE +Expand patterns that start with +.Ql ~ +to user name home directories. +.It Dv GLOB_LIMIT +Limit the total number of returned pathnames to the value provided in +.Fa gl_matchc +(default +.Dv ARG_MAX ) . +This option should be set for programs +that can be coerced into a denial of service attack +via patterns that expand to a very large number of matches, +such as a long string of +.Ql */../*/.. . +.El +.Pp +If, during the search, a directory is encountered that cannot be opened +or read and +.Fa errfunc +is +.Pf non- Dv NULL , +.Fn glob +calls +.Fa \*(lp*errfunc\*(rp Ns ( Fa path , errno ) . +This may be unintuitive: a pattern like +.Ql */Makefile +will try to +.Xr stat 2 +.Ql foo/Makefile +even if +.Ql foo +is not a directory, resulting in a +call to +.Fa errfunc . +The error routine can suppress this action by testing for +.Er ENOENT +and +.Er ENOTDIR ; +however, the +.Dv GLOB_ERR +flag will still cause an immediate +return when this happens. +.Pp +If +.Fa errfunc +returns non-zero, +.Fn glob +stops the scan and returns +.Dv GLOB_ABEND +after setting +.Fa gl_pathc +and +.Fa gl_pathv +to reflect any paths already matched. +This also happens if an error is encountered and +.Dv GLOB_ERR +is set in +.Fa flags , +regardless of the return value of +.Fa errfunc , +if called. +If +.Dv GLOB_ERR +is not set and either +.Fa errfunc +is +.Dv NULL +or +.Fa errfunc +returns zero, the error is ignored. +.Pp +The +.Fn globfree +function frees any space associated with +.Fa pglob +from a previous call(s) to +.Fn glob . +.Sh RETURN VALUES +On successful completion, +.Fn glob +returns zero. +In addition the fields of +.Fa pglob +contain the values described below: +.Bl -tag -width GLOB_NOCHECK +.It Fa gl_pathc +contains the total number of matched pathnames so far. +This includes other matches from previous invocations of +.Fn glob +if +.Dv GLOB_APPEND +was specified. +.It Fa gl_matchc +contains the number of matched pathnames in the current invocation of +.Fn glob . +.It Fa gl_flags +contains a copy of the +.Fa flags +parameter with the bit +.Dv GLOB_MAGCHAR +set if +.Fa pattern +contained any of the special characters ``*'', ``?'' or ``['', cleared +if not. +.It Fa gl_pathv +contains a pointer to a +.Dv NULL Ns -terminated +list of matched pathnames. +However, if +.Fa gl_pathc +is zero, the contents of +.Fa gl_pathv +are undefined. +.El +.Pp +If +.Fn glob +terminates due to an error, it sets errno and returns one of the +following non-zero constants, which are defined in the include +file +.Aq Pa glob.h : +.Bl -tag -width GLOB_NOCHECK +.It Dv GLOB_NOSPACE +An attempt to allocate memory failed, or if +.Fa errno +was 0 +.Dv GLOB_LIMIT +was specified in the flags and +.Fa pglob\->gl_matchc +or more patterns were matched. +.It Dv GLOB_ABEND +The scan was stopped because an error was encountered and either +.Dv GLOB_ERR +was set or +.Fa \*(lp*errfunc\*(rp\*(lp\*(rp +returned non-zero. +.El +.Pp +The arguments +.Fa pglob\->gl_pathc +and +.Fa pglob\->gl_pathv +are still set as specified above. +.Sh EXAMPLES +A rough equivalent of +.Ql "ls -l *.c *.h" +can be obtained with the +following code: +.Bd -literal -offset indent +glob_t g; + +g.gl_offs = 2; +glob("*.c", GLOB_DOOFFS, NULL, &g); +glob("*.h", GLOB_DOOFFS | GLOB_APPEND, NULL, &g); +g.gl_pathv[0] = "ls"; +g.gl_pathv[1] = "-l"; +execvp("ls", g.gl_pathv); +.Ed +.Sh SEE ALSO +.Xr sh 1 , +.Xr fnmatch 3 , +.Xr regexp 3 +.Sh STANDARDS +The +.Fn glob +function is expected to be +.St -p1003.2 +compatible with the exception +that the flags +.Dv GLOB_ALTDIRFUNC , +.Dv GLOB_BRACE , +.Dv GLOB_LIMIT , +.Dv GLOB_MAGCHAR , +.Dv GLOB_NOMAGIC , +.Dv GLOB_QUOTE , +and +.Dv GLOB_TILDE , +and the fields +.Fa gl_matchc +and +.Fa gl_flags +should not be used by applications striving for strict +.Tn POSIX +conformance. +.Sh HISTORY +The +.Fn glob +and +.Fn globfree +functions first appeared in +.Bx 4.4 . +.Sh BUGS +Patterns longer than +.Dv MAXPATHLEN +may cause unchecked errors. +.Pp +The +.Fn glob +argument +may fail and set errno for any of the errors specified for the +library routines +.Xr stat 2 , +.Xr closedir 3 , +.Xr opendir 3 , +.Xr readdir 3 , +.Xr malloc 3 , +and +.Xr free 3 . diff --git a/gen/glob.c b/gen/glob.c new file mode 100644 index 0000000..273d6c9 --- /dev/null +++ b/gen/glob.c @@ -0,0 +1,864 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Guido van Rossum. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + */ + + +/* + * glob(3) -- a superset of the one defined in POSIX 1003.2. + * + * The [!...] convention to negate a range is supported (SysV, Posix, ksh). + * + * Optional extra services, controlled by flags not defined by POSIX: + * + * GLOB_QUOTE: + * Escaping convention: \ inhibits any special meaning the following + * character might have (except \ at end of string is retained). + * GLOB_MAGCHAR: + * Set in gl_flags if pattern contained a globbing character. + * GLOB_NOMAGIC: + * Same as GLOB_NOCHECK, but it will only append pattern if it did + * not contain any magic characters. [Used in csh style globbing] + * GLOB_ALTDIRFUNC: + * Use alternately specified directory access functions. + * GLOB_TILDE: + * expand ~user/foo to the /home/dir/of/user/foo + * GLOB_BRACE: + * expand {1,2}{a,b} to 1a 1b 2a 2b + * gl_matchc: + * Number of matches in the current invocation of glob. + */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DOLLAR '$' +#define DOT '.' +#define EOS '\0' +#define LBRACKET '[' +#define NOT '!' +#define QUESTION '?' +#define QUOTE '\\' +#define RANGE '-' +#define RBRACKET ']' +#define SEP '/' +#define STAR '*' +#define TILDE '~' +#define UNDERSCORE '_' +#define LBRACE '{' +#define RBRACE '}' +#define SLASH '/' +#define COMMA ',' + +#ifndef DEBUG + +#define M_QUOTE 0x8000 +#define M_PROTECT 0x4000 +#define M_MASK 0xffff +#define M_ASCII 0x00ff + +typedef u_short Char; + +#else + +#define M_QUOTE 0x80 +#define M_PROTECT 0x40 +#define M_MASK 0xff +#define M_ASCII 0x7f + +typedef char Char; + +#endif + + +#define CHAR(c) ((Char)((c)&M_ASCII)) +#define META(c) ((Char)((c)|M_QUOTE)) +#define M_ALL META('*') +#define M_END META(']') +#define M_NOT META('!') +#define M_ONE META('?') +#define M_RNG META('-') +#define M_SET META('[') +#define ismeta(c) (((c)&M_QUOTE) != 0) + + +static int compare __P((const void *, const void *)); +static void g_Ctoc __P((const Char *, char *)); +static int g_lstat __P((Char *, struct stat *, glob_t *)); +static DIR *g_opendir __P((Char *, glob_t *)); +static Char *g_strchr __P((Char *, int)); +#ifdef notdef +static Char *g_strcat __P((Char *, const Char *)); +#endif +static int g_stat __P((Char *, struct stat *, glob_t *)); +static int glob0 __P((const Char *, glob_t *)); +static int glob1 __P((Char *, glob_t *)); +static int glob2 __P((Char *, Char *, Char *, glob_t *)); +static int glob3 __P((Char *, Char *, Char *, Char *, glob_t *)); +static int globextend __P((const Char *, glob_t *)); +static const Char * globtilde __P((const Char *, Char *, glob_t *)); +static int globexp1 __P((const Char *, glob_t *)); +static int globexp2 __P((const Char *, const Char *, glob_t *, int *)); +static int match __P((Char *, Char *, Char *)); +#ifdef DEBUG +static void qprintf __P((const char *, Char *)); +#endif + +int +glob(pattern, flags, errfunc, pglob) + const char *pattern; + int flags, (*errfunc) __P((const char *, int)); + glob_t *pglob; +{ + const u_char *patnext; + int c; + Char *bufnext, *bufend, patbuf[MAXPATHLEN+1]; + + patnext = (u_char *) pattern; + if (!(flags & GLOB_APPEND)) { + pglob->gl_pathc = 0; + pglob->gl_pathv = NULL; + if (!(flags & GLOB_DOOFFS)) + pglob->gl_offs = 0; + } + pglob->gl_flags = flags & ~GLOB_MAGCHAR; + pglob->gl_errfunc = errfunc; + pglob->gl_matchc = 0; + + bufnext = patbuf; + bufend = bufnext + MAXPATHLEN; + if (flags & GLOB_QUOTE) { + /* Protect the quoted characters. */ + while (bufnext < bufend && (c = *patnext++) != EOS) + if (c == QUOTE) { + if ((c = *patnext++) == EOS) { + c = QUOTE; + --patnext; + } + *bufnext++ = c | M_PROTECT; + } + else + *bufnext++ = c; + } + else + while (bufnext < bufend && (c = *patnext++) != EOS) + *bufnext++ = c; + *bufnext = EOS; + + if (flags & GLOB_BRACE) + return globexp1(patbuf, pglob); + else + return glob0(patbuf, pglob); +} + +/* + * Expand recursively a glob {} pattern. When there is no more expansion + * invoke the standard globbing routine to glob the rest of the magic + * characters + */ +static int globexp1(pattern, pglob) + const Char *pattern; + glob_t *pglob; +{ + const Char* ptr = pattern; + int rv; + + /* Protect a single {}, for find(1), like csh */ + if (pattern[0] == LBRACE && pattern[1] == RBRACE && pattern[2] == EOS) + return glob0(pattern, pglob); + + while ((ptr = (const Char *) g_strchr((Char *) ptr, LBRACE)) != NULL) + if (!globexp2(ptr, pattern, pglob, &rv)) + return rv; + + return glob0(pattern, pglob); +} + + +/* + * Recursive brace globbing helper. Tries to expand a single brace. + * If it succeeds then it invokes globexp1 with the new pattern. + * If it fails then it tries to glob the rest of the pattern and returns. + */ +static int globexp2(ptr, pattern, pglob, rv) + const Char *ptr, *pattern; + glob_t *pglob; + int *rv; +{ + int i; + Char *lm, *ls; + const Char *pe, *pm, *pl; + Char patbuf[MAXPATHLEN + 1]; + + /* copy part up to the brace */ + for (lm = patbuf, pm = pattern; pm != ptr; *lm++ = *pm++) + continue; + ls = lm; + + /* Find the balanced brace */ + for (i = 0, pe = ++ptr; *pe; pe++) + if (*pe == LBRACKET) { + /* Ignore everything between [] */ + for (pm = pe++; *pe != RBRACKET && *pe != EOS; pe++) + continue; + if (*pe == EOS) { + /* + * We could not find a matching RBRACKET. + * Ignore and just look for RBRACE + */ + pe = pm; + } + } + else if (*pe == LBRACE) + i++; + else if (*pe == RBRACE) { + if (i == 0) + break; + i--; + } + + /* Non matching braces; just glob the pattern */ + if (i != 0 || *pe == EOS) { + *rv = glob0(patbuf, pglob); + return 0; + } + + for (i = 0, pl = pm = ptr; pm <= pe; pm++) + switch (*pm) { + case LBRACKET: + /* Ignore everything between [] */ + for (pl = pm++; *pm != RBRACKET && *pm != EOS; pm++) + continue; + if (*pm == EOS) { + /* + * We could not find a matching RBRACKET. + * Ignore and just look for RBRACE + */ + pm = pl; + } + break; + + case LBRACE: + i++; + break; + + case RBRACE: + if (i) { + i--; + break; + } + /* FALLTHROUGH */ + case COMMA: + if (i && *pm == COMMA) + break; + else { + /* Append the current string */ + for (lm = ls; (pl < pm); *lm++ = *pl++) + continue; + /* + * Append the rest of the pattern after the + * closing brace + */ + for (pl = pe + 1; (*lm++ = *pl++) != EOS;) + continue; + + /* Expand the current pattern */ +#ifdef DEBUG + qprintf("globexp2:", patbuf); +#endif + *rv = globexp1(patbuf, pglob); + + /* move after the comma, to the next string */ + pl = pm + 1; + } + break; + + default: + break; + } + *rv = 0; + return 0; +} + + + +/* + * expand tilde from the passwd file. + */ +static const Char * +globtilde(pattern, patbuf, pglob) + const Char *pattern; + Char *patbuf; + glob_t *pglob; +{ + struct passwd *pwd; + char *h; + const Char *p; + Char *b; + + if (*pattern != TILDE || !(pglob->gl_flags & GLOB_TILDE)) + return pattern; + + /* Copy up to the end of the string or / */ + for (p = pattern + 1, h = (char *) patbuf; *p && *p != SLASH; + *h++ = *p++) + continue; + + *h = EOS; + + if (((char *) patbuf)[0] == EOS) { + /* + * handle a plain ~ or ~/ by expanding $HOME + * first and then trying the password file + */ + if ((h = getenv("HOME")) == NULL) { + if ((pwd = getpwuid(getuid())) == NULL) + return pattern; + else + h = pwd->pw_dir; + } + } + else { + /* + * Expand a ~user + */ + if ((pwd = getpwnam((char*) patbuf)) == NULL) + return pattern; + else + h = pwd->pw_dir; + } + + /* Copy the home directory */ + for (b = patbuf; *h; *b++ = *h++) + continue; + + /* Append the rest of the pattern */ + while ((*b++ = *p++) != EOS) + continue; + + return patbuf; +} + + +/* + * The main glob() routine: compiles the pattern (optionally processing + * quotes), calls glob1() to do the real pattern matching, and finally + * sorts the list (unless unsorted operation is requested). Returns 0 + * if things went well, nonzero if errors occurred. It is not an error + * to find no matches. + */ +static int +glob0(pattern, pglob) + const Char *pattern; + glob_t *pglob; +{ + const Char *qpatnext; + int c, err, oldpathc; + Char *bufnext, patbuf[MAXPATHLEN+1]; + + qpatnext = globtilde(pattern, patbuf, pglob); + oldpathc = pglob->gl_pathc; + bufnext = patbuf; + + /* We don't need to check for buffer overflow any more. */ + while ((c = *qpatnext++) != EOS) { + switch (c) { + case LBRACKET: + c = *qpatnext; + if (c == NOT) + ++qpatnext; + if (*qpatnext == EOS || + g_strchr((Char *) qpatnext+1, RBRACKET) == NULL) { + *bufnext++ = LBRACKET; + if (c == NOT) + --qpatnext; + break; + } + *bufnext++ = M_SET; + if (c == NOT) + *bufnext++ = M_NOT; + c = *qpatnext++; + do { + *bufnext++ = CHAR(c); + if (*qpatnext == RANGE && + (c = qpatnext[1]) != RBRACKET) { + *bufnext++ = M_RNG; + *bufnext++ = CHAR(c); + qpatnext += 2; + } + } while ((c = *qpatnext++) != RBRACKET); + pglob->gl_flags |= GLOB_MAGCHAR; + *bufnext++ = M_END; + break; + case QUESTION: + pglob->gl_flags |= GLOB_MAGCHAR; + *bufnext++ = M_ONE; + break; + case STAR: + pglob->gl_flags |= GLOB_MAGCHAR; + /* collapse adjacent stars to one, + * to avoid exponential behavior + */ + if (bufnext == patbuf || bufnext[-1] != M_ALL) + *bufnext++ = M_ALL; + break; + default: + *bufnext++ = CHAR(c); + break; + } + } + *bufnext = EOS; +#ifdef DEBUG + qprintf("glob0:", patbuf); +#endif + + if ((err = glob1(patbuf, pglob)) != 0) + return(err); + + /* + * If there was no match we are going to append the pattern + * if GLOB_NOCHECK was specified or if GLOB_NOMAGIC was specified + * and the pattern did not contain any magic characters + * GLOB_NOMAGIC is there just for compatibility with csh. + */ + if (pglob->gl_pathc == oldpathc && + ((pglob->gl_flags & GLOB_NOCHECK) || + ((pglob->gl_flags & GLOB_NOMAGIC) && + !(pglob->gl_flags & GLOB_MAGCHAR)))) + return(globextend(pattern, pglob)); + else if (!(pglob->gl_flags & GLOB_NOSORT)) + qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc, + pglob->gl_pathc - oldpathc, sizeof(char *), compare); + return(0); +} + +static int +compare(p, q) + const void *p, *q; +{ + return(strcmp(*(char **)p, *(char **)q)); +} + +static int +glob1(pattern, pglob) + Char *pattern; + glob_t *pglob; +{ + Char pathbuf[MAXPATHLEN+1]; + + /* A null pathname is invalid -- POSIX 1003.1 sect. 2.4. */ + if (*pattern == EOS) + return(0); + return(glob2(pathbuf, pathbuf, pattern, pglob)); +} + +/* + * The functions glob2 and glob3 are mutually recursive; there is one level + * of recursion for each segment in the pattern that contains one or more + * meta characters. + */ +static int +glob2(pathbuf, pathend, pattern, pglob) + Char *pathbuf, *pathend, *pattern; + glob_t *pglob; +{ + struct stat sb; + Char *p, *q; + int anymeta; + + /* + * Loop over pattern segments until end of pattern or until + * segment with meta character found. + */ + for (anymeta = 0;;) { + if (*pattern == EOS) { /* End of pattern? */ + *pathend = EOS; + if (g_lstat(pathbuf, &sb, pglob)) + return(0); + + if (((pglob->gl_flags & GLOB_MARK) && + pathend[-1] != SEP) && (S_ISDIR(sb.st_mode) + || (S_ISLNK(sb.st_mode) && + (g_stat(pathbuf, &sb, pglob) == 0) && + S_ISDIR(sb.st_mode)))) { + *pathend++ = SEP; + *pathend = EOS; + } + ++pglob->gl_matchc; + return(globextend(pathbuf, pglob)); + } + + /* Find end of next segment, copy tentatively to pathend. */ + q = pathend; + p = pattern; + while (*p != EOS && *p != SEP) { + if (ismeta(*p)) + anymeta = 1; + *q++ = *p++; + } + + if (!anymeta) { /* No expansion, do next segment. */ + pathend = q; + pattern = p; + while (*pattern == SEP) + *pathend++ = *pattern++; + } else /* Need expansion, recurse. */ + return(glob3(pathbuf, pathend, pattern, p, pglob)); + } + /* NOTREACHED */ +} + +static int +glob3(pathbuf, pathend, pattern, restpattern, pglob) + Char *pathbuf, *pathend, *pattern, *restpattern; + glob_t *pglob; +{ + register struct dirent *dp; + DIR *dirp; + int err; + char buf[MAXPATHLEN]; + + /* + * The readdirfunc declaration can't be prototyped, because it is + * assigned, below, to two functions which are prototyped in glob.h + * and dirent.h as taking pointers to differently typed opaque + * structures. + */ + struct dirent *(*readdirfunc)(); + + *pathend = EOS; + errno = 0; + + if ((dirp = g_opendir(pathbuf, pglob)) == NULL) { + /* TODO: don't call for ENOENT or ENOTDIR? */ + if (pglob->gl_errfunc) { + g_Ctoc(pathbuf, buf); + if (pglob->gl_errfunc(buf, errno) || + pglob->gl_flags & GLOB_ERR) + return (GLOB_ABEND); + } + return(0); + } + + err = 0; + + /* Search directory for matching names. */ + if (pglob->gl_flags & GLOB_ALTDIRFUNC) + readdirfunc = pglob->gl_readdir; + else + readdirfunc = readdir; + while ((dp = (*readdirfunc)(dirp))) { + register u_char *sc; + register Char *dc; + + /* Initial DOT must be matched literally. */ + if (dp->d_name[0] == DOT && *pattern != DOT) + continue; + for (sc = (u_char *) dp->d_name, dc = pathend; + (*dc++ = *sc++) != EOS;) + continue; + if (!match(pathend, pattern, restpattern)) { + *pathend = EOS; + continue; + } + err = glob2(pathbuf, --dc, restpattern, pglob); + if (err) + break; + } + + if (pglob->gl_flags & GLOB_ALTDIRFUNC) + (*pglob->gl_closedir)(dirp); + else + closedir(dirp); + return(err); +} + + +/* + * Extend the gl_pathv member of a glob_t structure to accomodate a new item, + * add the new item, and update gl_pathc. + * + * This assumes the BSD realloc, which only copies the block when its size + * crosses a power-of-two boundary; for v7 realloc, this would cause quadratic + * behavior. + * + * Return 0 if new item added, error code if memory couldn't be allocated. + * + * Invariant of the glob_t structure: + * Either gl_pathc is zero and gl_pathv is NULL; or gl_pathc > 0 and + * gl_pathv points to (gl_offs + gl_pathc + 1) items. + */ +static int +globextend(path, pglob) + const Char *path; + glob_t *pglob; +{ + register char **pathv; + register int i; + u_int newsize; + char *copy; + const Char *p; + + newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs); + pathv = pglob->gl_pathv ? + realloc((char *)pglob->gl_pathv, newsize) : + malloc(newsize); + if (pathv == NULL) + return(GLOB_NOSPACE); + + if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) { + /* first time around -- clear initial gl_offs items */ + pathv += pglob->gl_offs; + for (i = pglob->gl_offs; --i >= 0; ) + *--pathv = NULL; + } + pglob->gl_pathv = pathv; + + for (p = path; *p++;) + continue; + if ((copy = malloc(p - path)) != NULL) { + g_Ctoc(path, copy); + pathv[pglob->gl_offs + pglob->gl_pathc++] = copy; + } + pathv[pglob->gl_offs + pglob->gl_pathc] = NULL; + return(copy == NULL ? GLOB_NOSPACE : 0); +} + + +/* + * pattern matching function for filenames. Each occurrence of the * + * pattern causes a recursion level. + */ +static int +match(name, pat, patend) + register Char *name, *pat, *patend; +{ + int ok, negate_range; + Char c, k; + + while (pat < patend) { + c = *pat++; + switch (c & M_MASK) { + case M_ALL: + if (pat == patend) + return(1); + do + if (match(name, pat, patend)) + return(1); + while (*name++ != EOS); + return(0); + case M_ONE: + if (*name++ == EOS) + return(0); + break; + case M_SET: + ok = 0; + if ((k = *name++) == EOS) + return(0); + if ((negate_range = ((*pat & M_MASK) == M_NOT)) != EOS) + ++pat; + while (((c = *pat++) & M_MASK) != M_END) + if ((*pat & M_MASK) == M_RNG) { + if (c <= k && k <= pat[1]) + ok = 1; + pat += 2; + } else if (c == k) + ok = 1; + if (ok == negate_range) + return(0); + break; + default: + if (*name++ != c) + return(0); + break; + } + } + return(*name == EOS); +} + +/* Free allocated data belonging to a glob_t structure. */ +void +globfree(pglob) + glob_t *pglob; +{ + register int i; + register char **pp; + + if (pglob->gl_pathv != NULL) { + pp = pglob->gl_pathv + pglob->gl_offs; + for (i = pglob->gl_pathc; i--; ++pp) + if (*pp) + free(*pp); + free(pglob->gl_pathv); + } +} + +static DIR * +g_opendir(str, pglob) + register Char *str; + glob_t *pglob; +{ + char buf[MAXPATHLEN]; + + if (!*str) + strcpy(buf, "."); + else + g_Ctoc(str, buf); + + if (pglob->gl_flags & GLOB_ALTDIRFUNC) + return((*pglob->gl_opendir)(buf)); + + return(opendir(buf)); +} + +static int +g_lstat(fn, sb, pglob) + register Char *fn; + struct stat *sb; + glob_t *pglob; +{ + char buf[MAXPATHLEN]; + + g_Ctoc(fn, buf); + if (pglob->gl_flags & GLOB_ALTDIRFUNC) + return((*pglob->gl_lstat)(buf, sb)); + return(lstat(buf, sb)); +} + +static int +g_stat(fn, sb, pglob) + register Char *fn; + struct stat *sb; + glob_t *pglob; +{ + char buf[MAXPATHLEN]; + + g_Ctoc(fn, buf); + if (pglob->gl_flags & GLOB_ALTDIRFUNC) + return((*pglob->gl_stat)(buf, sb)); + return(stat(buf, sb)); +} + +static Char * +g_strchr(str, ch) + Char *str; + int ch; +{ + do { + if (*str == ch) + return (str); + } while (*str++); + return (NULL); +} + +#ifdef notdef +static Char * +g_strcat(dst, src) + Char *dst; + const Char* src; +{ + Char *sdst = dst; + + while (*dst++) + continue; + --dst; + while((*dst++ = *src++) != EOS) + continue; + + return (sdst); +} +#endif + +static void +g_Ctoc(str, buf) + register const Char *str; + char *buf; +{ + register char *dc; + + for (dc = buf; (*dc++ = *str++) != EOS;) + continue; +} + +#ifdef DEBUG +static void +qprintf(str, s) + const char *str; + register Char *s; +{ + register Char *p; + + (void)printf("%s:\n", str); + for (p = s; *p; p++) + (void)printf("%c", CHAR(*p)); + (void)printf("\n"); + for (p = s; *p; p++) + (void)printf("%c", *p & M_PROTECT ? '"' : ' '); + (void)printf("\n"); + for (p = s; *p; p++) + (void)printf("%c", ismeta(*p) ? '_' : ' '); + (void)printf("\n"); +} +#endif diff --git a/gen.subproj/i386.subproj/bzero.c b/gen/hton.c similarity index 64% rename from gen.subproj/i386.subproj/bzero.c rename to gen/hton.c index b0c8884..734e5dc 100644 --- a/gen.subproj/i386.subproj/bzero.c +++ b/gen/hton.c @@ -19,24 +19,32 @@ * * @APPLE_LICENSE_HEADER_END@ */ -/* Copyright (c) 1992 NeXT Computer, Inc. All rights reserved. +/* Copyright (c) 1994 NeXT Computer, Inc. All rights reserved. * - * File: libc/i386/gen/bzero.c - * Author: Bruce Martin, NeXT Computer, Inc. + * File: hton.c + * Author: Matt Watson, NeXT Computer, Inc. * - * This file contains machine dependent code for the bzero function - * on NeXT i386-based products. Currently tuned for the i486. + * Use the machine independent byte-swapping code for htonl-type functions. * * HISTORY - * 26-Aug-92 Bruce Martin (Bruce_Martin@NeXT.COM) + * 15-Dec-94 Matt Watson (Matt_Watson@NeXT.COM) * Created. */ -#include +#import -#undef bzero +long ntohl(long x) { + return NXSwapBigLongToHost(x); +} + +short ntohs(short x) { + return NXSwapBigShortToHost(x); +} + +long htonl(long x) { + return NXSwapHostLongToBig(x); +} -void bzero (void *b, size_t length) -{ - memset((void *) b, 0, (size_t) length); +short htons(short x) { + return NXSwapHostShortToBig(x); } diff --git a/gen/initgroups.3 b/gen/initgroups.3 new file mode 100644 index 0000000..039b87f --- /dev/null +++ b/gen/initgroups.3 @@ -0,0 +1,86 @@ +.\" Copyright (c) 1983, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)initgroups.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/initgroups.3,v 1.10 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt INITGROUPS 3 +.Os +.Sh NAME +.Nm initgroups +.Nd initialize group access list +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft int +.Fn initgroups "const char *name" "int basegid" +.Sh DESCRIPTION +The +.Fn initgroups +function +uses the +.Xr getgrouplist 3 +function to calculate the group access list for the user +specified in +.Fa name . +This group list is then setup for the current process using +.Xr setgroups 2 . +The +.Fa basegid +is automatically included in the groups list. +Typically this value is given as +the group number from the password file. +.Sh RETURN VALUES +The +.Fn initgroups +function +returns \-1 if it was not invoked by the super-user. +.Sh SEE ALSO +.Xr setgroups 2 , +.Xr getgrouplist 3 +.Sh HISTORY +The +.Fn initgroups +function appeared in +.Bx 4.2 . +.Sh BUGS +The +.Fn getgrouplist +function called by +.Fn initgroups +uses the routines based on +.Xr getgrent 3 . +If the invoking program uses any of these routines, +the group structure will +be overwritten in the call to +.Fn initgroups . diff --git a/gen.subproj/isatty.c b/gen/isatty.c similarity index 100% rename from gen.subproj/isatty.c rename to gen/isatty.c diff --git a/gen/isinf.3 b/gen/isinf.3 new file mode 100644 index 0000000..dfc7efc --- /dev/null +++ b/gen/isinf.3 @@ -0,0 +1,80 @@ +.\" Copyright (c) 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)isinf.3 8.2 (Berkeley) 1/29/94 +.\" $FreeBSD: src/lib/libc/gen/isinf.3,v 1.7 2000/10/30 13:23:18 asmodai Exp $ +.\" +.Dd January 29, 1994 +.Dt ISINF 3 +.Os +.Sh NAME +.Nm isinf , +.Nm isnan , +.Nm isnanf +.Nd test for infinity or not-a-number +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.Ft int +.Fn isinf double +.Ft int +.Fn isnan double +.Ft int +.Fn isnanf float +.Sh DESCRIPTION +The +.Fn isinf +function +returns 1 if the number is +.Dq \\*(If , +otherwise 0. +.Pp +The +.Fn isnan +and +.Fn isnanf +functions +return 1 if the double or float (respectively) is +.Dq not-a-number , +otherwise 0. +.Sh SEE ALSO +.Xr math 3 +.Rs +.%T "IEEE Standard for Binary Floating-Point Arithmetic" +.%Q ANSI +.%R Std 754-1985 +.Re +.Sh BUGS +Neither the +.Tn VAX +nor the Tahoe floating point have distinguished values +for either infinity or not-a-number. +These routines always return 0 on those architectures. diff --git a/gen.subproj/isnan.c b/gen/isnan.c similarity index 100% rename from gen.subproj/isnan.c rename to gen/isnan.c diff --git a/gen/jrand48.c b/gen/jrand48.c new file mode 100644 index 0000000..051d5a6 --- /dev/null +++ b/gen/jrand48.c @@ -0,0 +1,21 @@ +/* + * Copyright (c) 1993 Martin Birgmeier + * All rights reserved. + * + * You may redistribute unmodified or modified versions of this source + * code provided that the above copyright notice and this and the + * following conditions are retained. + * + * This software is provided ``as is'', and comes with no warranties + * of any kind. I shall in no event be liable for anything that happens + * to anyone/anything when using this software. + */ + +#include "rand48.h" + +long +jrand48(unsigned short xseed[3]) +{ + _dorand48(xseed); + return ((long) xseed[2] << 16) + (long) xseed[1]; +} diff --git a/gen/lcong48.c b/gen/lcong48.c new file mode 100644 index 0000000..f13826b --- /dev/null +++ b/gen/lcong48.c @@ -0,0 +1,30 @@ +/* + * Copyright (c) 1993 Martin Birgmeier + * All rights reserved. + * + * You may redistribute unmodified or modified versions of this source + * code provided that the above copyright notice and this and the + * following conditions are retained. + * + * This software is provided ``as is'', and comes with no warranties + * of any kind. I shall in no event be liable for anything that happens + * to anyone/anything when using this software. + */ + +#include "rand48.h" + +extern unsigned short _rand48_seed[3]; +extern unsigned short _rand48_mult[3]; +extern unsigned short _rand48_add; + +void +lcong48(unsigned short p[7]) +{ + _rand48_seed[0] = p[0]; + _rand48_seed[1] = p[1]; + _rand48_seed[2] = p[2]; + _rand48_mult[0] = p[3]; + _rand48_mult[1] = p[4]; + _rand48_mult[2] = p[5]; + _rand48_add = p[6]; +} diff --git a/gen/ldexp.3 b/gen/ldexp.3 new file mode 100644 index 0000000..88c0d2f --- /dev/null +++ b/gen/ldexp.3 @@ -0,0 +1,80 @@ +.\" Copyright (c) 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)ldexp.3 8.2 (Berkeley) 4/19/94 +.\" $FreeBSD: src/lib/libc/gen/ldexp.3,v 1.8 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd April 19, 1994 +.Dt LDEXP 3 +.Os +.Sh NAME +.Nm ldexp +.Nd multiply floating-point number by integral power of 2 +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In math.h +.Ft double +.Fn ldexp "double x" "int exp" +.Sh DESCRIPTION +The +.Fn ldexp +function multiplies a floating-point number by an integral +power of 2. +.Sh RETURN VALUES +The +.Fn ldexp +function returns the value of +.Fa x +times 2 raised to the power +.Fa exp . +.Pp +If the resultant value would cause an overflow, +the global variable +.Va errno +is set to +.Er ERANGE +and the value +.Dv HUGE +is returned. +.Sh SEE ALSO +.Xr frexp 3 , +.Xr math 3 , +.Xr modf 3 +.Sh STANDARDS +The +.Fn ldexp +function conforms to +.St -isoC . diff --git a/gen/lockf.3 b/gen/lockf.3 new file mode 100644 index 0000000..83f7818 --- /dev/null +++ b/gen/lockf.3 @@ -0,0 +1,254 @@ +.\" $NetBSD: lockf.3,v 1.2 1998/02/05 18:47:28 perry Exp $ +.\" +.\" Copyright (c) 1997 The NetBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to The NetBSD Foundation +.\" by Klaus Klein and S.P. Zeidler. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the NetBSD +.\" Foundation, Inc. and its contributors. +.\" 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +.\" +.\" $FreeBSD: src/lib/libc/gen/lockf.3,v 1.10 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd December 19, 1997 +.Dt LOCKF 3 +.Os +.Sh NAME +.Nm lockf +.Nd record locking on files +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft int +.Fn lockf "int filedes" "int function" "off_t size" +.Sh DESCRIPTION +The +.Fn lockf +function allows sections of a file to be locked with advisory-mode locks. +Calls to +.Fn lockf +from other processes which attempt to lock the locked file section will +either return an error value or block until the section becomes unlocked. +All the locks for a process are removed when the process terminates. +.Pp +The argument +.Fa filedes +is an open file descriptor. +The file descriptor must have been opened either for write-only +.Dv ( O_WRONLY ) +or read/write +.Dv ( O_RDWR ) +operation. +.Pp +The +.Fa function +argument is a control value which specifies the action to be taken. +The permissible values for +.Fa function +are as follows: +.Bl -tag -width F_ULOCKXX -compact -offset indent +.It Sy Function +.Sy Description +.It Dv F_ULOCK +unlock locked sections +.It Dv F_LOCK +lock a section for exclusive use +.It Dv F_TLOCK +test and lock a section for exclusive use +.It Dv F_TEST +test a section for locks by other processes +.El +.Pp +.Dv F_ULOCK +removes locks from a section of the file; +.Dv F_LOCK +and +.Dv F_TLOCK +both lock a section of a file if the section is available; +.Dv F_TEST +detects if a lock by another process is present on the specified section. +.Pp +The +.Fa size +argument is the number of contiguous bytes to be locked or +unlocked. +The section to be locked or unlocked starts at the current +offset in the file and extends forward for a positive size or backward +for a negative size (the preceding bytes up to but not including the +current offset). However, it is not permitted to lock a section that +starts or extends before the beginning of the file. +If +.Fa size +is 0, the section from the current offset through the largest possible +file offset is locked (that is, from the current offset through the +present or any future end-of-file). +.Pp +The sections locked with +.Dv F_LOCK +or +.Dv F_TLOCK +may, in whole or in part, contain or be contained by a previously +locked section for the same process. +When this occurs, or if adjacent +locked sections would occur, the sections are combined into a single +locked section. +If the request would cause the number of locks to +exceed a system-imposed limit, the request will fail. +.Pp +.Dv F_LOCK +and +.Dv F_TLOCK +requests differ only by the action taken if the section is not +available. +.Dv F_LOCK +blocks the calling process until the section is available. +.Dv F_TLOCK +makes the function fail if the section is already locked by another +process. +.Pp +File locks are released on first close by the locking process of any +file descriptor for the file. +.Pp +.Dv F_ULOCK +requests release (wholly or in part) one or more locked sections +controlled by the process. +Locked sections will be unlocked starting +at the current file offset through +.Fa size +bytes or to the end of file if size is 0. When all of a locked section +is not released (that is, when the beginning or end of the area to be +unlocked falls within a locked section), the remaining portions of +that section are still locked by the process. +Releasing the center +portion of a locked section will cause the remaining locked beginning +and end portions to become two separate locked sections. +If the +request would cause the number of locks in the system to exceed a +system-imposed limit, the request will fail. +.Pp +An +.Dv F_ULOCK +request in which size is non-zero and the offset of the last byte of +the requested section is the maximum value for an object of type +off_t, when the process has an existing lock in which size is 0 and +which includes the last byte of the requested section, will be treated +as a request to unlock from the start of the requested section with a +size equal to 0. Otherwise an +.Dv F_ULOCK +request will attempt to unlock only the requested section. +.Pp +A potential for deadlock occurs if a process controlling a locked +region is put to sleep by attempting to lock the locked region of +another process. This implementation detects that sleeping until a +locked region is unlocked would cause a deadlock and fails with an +.Er EDEADLK +error. +.Pp +.Fn lockf , +.Xr fcntl 2 +and +.Xr flock 2 +locks may be safely used concurrently. +.Pp +Blocking on a section is interrupted by any signal. +.Sh RETURN VALUES +.Rv -std lockf +In the case of a failure, existing locks are not changed. +.Sh ERRORS +.Fn lockf +will fail if: +.Bl -tag -width Er +.It Bq Er EAGAIN +The argument +.Fa function +is +.Dv F_TLOCK +or +.Dv F_TEST +and the section is already locked by another process. +.It Bq Er EBADF +The argument +.Fa filedes +is not a valid open file descriptor. +.Pp +The argument +.Fa function +is +.Dv F_LOCK +or +.Dv F_TLOCK , +and +.Fa filedes +is not a valid file descriptor open for writing. +.It Bq Er EDEADLK +The argument +.Fa function +is +.Dv F_LOCK +and a deadlock is detected. +.It Bq Er EINTR +The argument +.Fa function +is F_LOCK +and +.Fn lockf +was interrupted by the delivery of a signal. +.It Bq Er EINVAL +The argument +.Fa function +is not one of +.Dv F_ULOCK , +.Dv F_LOCK , +.Dv F_TLOCK +or +.Dv F_TEST . +.Pp +The argument +.Fa filedes +refers to a file that does not support locking. +.It Bq Er ENOLCK +The argument +.Fa function +is +.Dv F_ULOCK , +.Dv F_LOCK +or +.Dv F_TLOCK , +and satisfying the lock or unlock request would result in the number +of locked regions in the system exceeding a system-imposed limit. +.El +.Sh SEE ALSO +.Xr fcntl 2 , +.Xr flock 2 +.Sh STANDARDS +The +.Fn lockf +function conforms to +.St -xpg4.2 . diff --git a/gen/lockf.c b/gen/lockf.c new file mode 100644 index 0000000..da94a3f --- /dev/null +++ b/gen/lockf.c @@ -0,0 +1,92 @@ +/* $NetBSD: lockf.c,v 1.1 1997/12/20 20:23:18 kleink Exp $ */ + +/*- + * Copyright (c) 1997 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Klaus Klein. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + * + * $FreeBSD: src/lib/libc/gen/lockf.c,v 1.5 2000/01/27 23:06:17 jasone Exp $ + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static const char rcsid[]= + "$FreeBSD: src/lib/libc/gen/lockf.c,v 1.5 2000/01/27 23:06:17 jasone Exp $"; +#endif + +#include +#include +#include + +int +lockf(filedes, function, size) + int filedes; + int function; + off_t size; +{ + struct flock fl; + int cmd; + + fl.l_start = 0; + fl.l_len = size; + fl.l_whence = SEEK_CUR; + + switch (function) { + case F_ULOCK: + cmd = F_SETLK; + fl.l_type = F_UNLCK; + break; + case F_LOCK: + cmd = F_SETLKW; + fl.l_type = F_WRLCK; + break; + case F_TLOCK: + cmd = F_SETLK; + fl.l_type = F_WRLCK; + break; + case F_TEST: + fl.l_type = F_WRLCK; + if (fcntl(filedes, F_GETLK, &fl) == -1) + return (-1); + if (fl.l_type == F_UNLCK || fl.l_pid == getpid()) + return (0); + errno = EAGAIN; + return (-1); + /* NOTREACHED */ + default: + errno = EINVAL; + return (-1); + /* NOTREACHED */ + } + + return (fcntl(filedes, cmd, &fl)); +} diff --git a/gen/lrand48.c b/gen/lrand48.c new file mode 100644 index 0000000..a3d0111 --- /dev/null +++ b/gen/lrand48.c @@ -0,0 +1,23 @@ +/* + * Copyright (c) 1993 Martin Birgmeier + * All rights reserved. + * + * You may redistribute unmodified or modified versions of this source + * code provided that the above copyright notice and this and the + * following conditions are retained. + * + * This software is provided ``as is'', and comes with no warranties + * of any kind. I shall in no event be liable for anything that happens + * to anyone/anything when using this software. + */ + +#include "rand48.h" + +extern unsigned short _rand48_seed[3]; + +long +lrand48(void) +{ + _dorand48(_rand48_seed); + return ((long) _rand48_seed[2] << 15) + ((long) _rand48_seed[1] >> 1); +} diff --git a/gen.subproj/malloc.c b/gen/malloc.c similarity index 80% rename from gen.subproj/malloc.c rename to gen/malloc.c index 5393b99..1261d58 100644 --- a/gen.subproj/malloc.c +++ b/gen/malloc.c @@ -615,160 +615,3 @@ int malloc_debug(int level) { fprintf(stderr, "*** malloc[%d]: OBSOLETE: malloc_debug()\n", getpid()); return 0; } - -/********* exo_zone - FOR emacs freeze drying ************/ - -typedef struct { - malloc_zone_t basic_zone; - vm_range_t range; - unsigned flags; -} exo_zone_t; - -#define MALLOC_EXO_ZONE_SIZE_IS_OLD 1 -#define MALLOC_EXO_ZONE_SIZE_IS_SCALABLE 2 - -typedef struct { - unsigned int lastguyfree:1; - unsigned int free:1; - unsigned int size:30; -} old_header_t; - -#define THIS_FREE 0x8000 // indicates this block is free -#define PREV_FREE 0x4000 // indicates previous block is free -#define SHIFT_QUANTUM 4 - -static size_t exo_zone_size(exo_zone_t *zone, const void *ptr) { - if (zone->flags == MALLOC_EXO_ZONE_SIZE_IS_OLD) { - if (ptr == (void *)zone->range.address) return zone->range.size; - return ((old_header_t *)ptr)[-1].size - sizeof(old_header_t); - } - if (zone->flags == MALLOC_EXO_ZONE_SIZE_IS_SCALABLE) { - // this is indeed a valid pointer - unsigned short msize_and_free = ((unsigned short *)ptr)[-1]; - return (msize_and_free & THIS_FREE) ? 0 : ((msize_and_free & ~PREV_FREE) << SHIFT_QUANTUM) - sizeof(unsigned short); - } - fprintf(stderr, "*** malloc[%d]: exo_zone_size unknown flags()\n", getpid()); - return 0; -} - -static void *exo_zone_malloc(exo_zone_t *zone, size_t new_size) { - return malloc(new_size); -} - -static void *exo_zone_calloc(exo_zone_t *zone, size_t num_items, size_t size) { - return calloc(num_items, size); -} - -static void *exo_zone_valloc(exo_zone_t *zone, size_t new_size) { - return valloc(new_size); -} - -static void *exo_zone_realloc(exo_zone_t *zone, void *ptr, size_t new_size) { - size_t old_size = exo_zone_size(zone, ptr); - void *new_ptr; - if (new_size <= old_size) return ptr; - new_ptr = malloc(new_size); - if (old_size) memcpy(new_ptr, ptr, old_size); - return new_ptr; -} - -static void exo_zone_free(exo_zone_t *zone, void *ptr) { -} - -static void exo_zone_destroy(exo_zone_t *zone) { - free(zone); -} - -static kern_return_t exo_zone_noop(void) { - return 0; -} - -static size_t exo_zone_good_size(exo_zone_t *zone, size_t size) { - return size; -} - -static struct malloc_introspection_t exo_zone_introspect = {(void *)exo_zone_noop, (void *)exo_zone_good_size, (void *)exo_zone_noop, (void *)exo_zone_noop, (void *)exo_zone_noop, (void *)exo_zone_noop, (void *)exo_zone_noop}; - -static malloc_zone_t *create_exo_zone(vm_address_t start, vm_size_t size, unsigned flags) { - exo_zone_t *zone = calloc(sizeof(exo_zone_t), 1); - zone->basic_zone.size = (void *)exo_zone_size; - zone->basic_zone.malloc = (void *)exo_zone_malloc; - zone->basic_zone.calloc = (void *)exo_zone_calloc; - zone->basic_zone.valloc = (void *)exo_zone_valloc; - zone->basic_zone.free = (void *)exo_zone_free; - zone->basic_zone.realloc = (void *)exo_zone_realloc; - zone->basic_zone.destroy = (void *)exo_zone_destroy; - zone->basic_zone.introspect = &exo_zone_introspect; - zone->flags = flags; - return (malloc_zone_t *)zone; -} - -/********* Support for emacs FreezeDrying ************/ - -#define OLD_MALLOC_VERSION 1 -#define SCALABLE_MALLOC_VERSION 2 - -#define MAX_RANGES 1023 -typedef struct { - unsigned version; - unsigned num; - vm_range_t ranges[MAX_RANGES]; -} malloc_freezedry_ranges; - -static void malloc_freezedry_recorder(task_t task, void *rr, unsigned type, vm_range_t *ranges, unsigned num) { - malloc_freezedry_ranges *recorded = rr; - while (num && (recorded->num < MAX_RANGES)) { - recorded->ranges[recorded->num++] = *ranges; - ranges++; num--; - } - if (recorded->num == MAX_RANGES) fprintf(stderr, "*** malloc[%d]: malloc_freezedry_recorder: exceeding capacity\n", getpid()); -} - -#define ADDINT(cp,i) (*((int *)cp) = i, cp += sizeof(int)) -static kern_return_t default_reader(task_t task, vm_address_t address, vm_size_t size, void **ptr) { - *ptr = (void *)address; - return 0; -} - -int malloc_freezedry(void) { - malloc_freezedry_ranges rr; - unsigned index = 0; - char *cp; - size_t size; - rr.version = SCALABLE_MALLOC_VERSION; - rr.num = 0; - while (index < malloc_num_zones) { - malloc_zone_t *zone = malloc_zones[index++]; - zone->introspect->enumerator(mach_task_self(), &rr, MALLOC_PTR_REGION_RANGE_TYPE | MALLOC_ADMIN_REGION_RANGE_TYPE, (vm_address_t)zone, default_reader, malloc_freezedry_recorder); - } - size = sizeof(rr) - (MAX_RANGES - rr.num) * sizeof(vm_range_t); - cp = valloc(size); - memcpy(cp, (void *)&rr, size); - return (int)cp; -} - -#define FETCHINT(i) (i = *((int *)cp), cp += sizeof(int)) -int malloc_jumpstart(int cookie) { - char *cp = (char *)cookie; - int version, regions; - FETCHINT(version); - if ((version != OLD_MALLOC_VERSION) && (version != SCALABLE_MALLOC_VERSION)) return 1; - FETCHINT(regions); - // fprintf(stderr, "malloc_jumpstart got (version %d): %d regions\n", version, regions); - while (--regions >= 0) { - malloc_zone_t *zone; - void **region = (void **)cp; - if (version == OLD_MALLOC_VERSION) { - cp += 3 * sizeof(void *); - // printf("Should add region beginadd=%p endadd=%p zone=%p\n", region[0], region[1], region[2]); - zone = create_exo_zone((vm_address_t)(region[0]), (vm_size_t)(region[1] - region[0]), MALLOC_EXO_ZONE_SIZE_IS_OLD); - } else { - cp += 2 * sizeof(void *); - // printf("Should add region beginadd=%p endadd=%p zone=%p\n", region[0], region[1], region[2]); - zone = create_exo_zone((vm_address_t)(region[0]), (vm_size_t)region[1], MALLOC_EXO_ZONE_SIZE_IS_SCALABLE); - } - malloc_zone_register(zone); - } - return 0; -} - diff --git a/gen/modf.3 b/gen/modf.3 new file mode 100644 index 0000000..3971000 --- /dev/null +++ b/gen/modf.3 @@ -0,0 +1,75 @@ +.\" Copyright (c) 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)modf.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/modf.3,v 1.7 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt MODF 3 +.Os +.Sh NAME +.Nm modf +.Nd extract signed integral and fractional values from floating-point number +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In math.h +.Ft double +.Fn modf "double value" "double *iptr" +.Sh DESCRIPTION +The +.Fn modf +function breaks the argument +.Fa value +into integral and fractional parts, each of which has the +same sign as the argument. +It stores the integral part as a +.Em double +in the object pointed to by +.Fa iptr . +.Sh RETURN VALUES +The +.Fn modf +function returns the signed fractional part of +.Fa value . +.Sh SEE ALSO +.Xr frexp 3 , +.Xr ldexp 3 , +.Xr math 3 +.Sh STANDARDS +The +.Fn modf +function conforms to +.St -isoC . diff --git a/gen/mrand48.c b/gen/mrand48.c new file mode 100644 index 0000000..b23db51 --- /dev/null +++ b/gen/mrand48.c @@ -0,0 +1,23 @@ +/* + * Copyright (c) 1993 Martin Birgmeier + * All rights reserved. + * + * You may redistribute unmodified or modified versions of this source + * code provided that the above copyright notice and this and the + * following conditions are retained. + * + * This software is provided ``as is'', and comes with no warranties + * of any kind. I shall in no event be liable for anything that happens + * to anyone/anything when using this software. + */ + +#include "rand48.h" + +extern unsigned short _rand48_seed[3]; + +long +mrand48(void) +{ + _dorand48(_rand48_seed); + return ((long) _rand48_seed[2] << 16) + (long) _rand48_seed[1]; +} diff --git a/gen/msgctl.3 b/gen/msgctl.3 new file mode 100644 index 0000000..83af0c3 --- /dev/null +++ b/gen/msgctl.3 @@ -0,0 +1,206 @@ +.\" $NetBSD: msgctl.2,v 1.1 1995/10/16 23:49:15 jtc Exp $ +.\" +.\" Copyright (c) 1995 Frank van der Linden +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed for the NetBSD Project +.\" by Frank van der Linden +.\" 4. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" $FreeBSD: src/lib/libc/gen/msgctl.3,v 1.16 2001/10/01 16:08:51 ru Exp $ +.\"/ +.Dd November 24, 1997 +.Dt MSGCTL 3 +.Os +.Sh NAME +.Nm msgctl +.Nd message control operations +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In sys/ipc.h +.In sys/msg.h +.Ft int +.Fn msgctl "int msqid" "int cmd" "struct msqid_ds *buf" +.Sh DESCRIPTION +The +.Fn msgctl +system call performs some control operations on the message queue specified +by +.Fa msqid . +.Pp +Each message queue has a data structure associated with it, parts of which +may be altered by +.Fn msgctl +and parts of which determine the actions of +.Fn msgctl . +The data structure is defined in +.Aq Pa sys/msg.h +and contains (amongst others) the following members: +.Bd -literal +struct msqid_ds { + struct ipc_perm msg_perm; /* msg queue permission bits */ + struct msg *msg_first; /* first message in the queue */ + struct msg *msg_last; /* last message in the queue */ + u_long msg_cbytes; /* number of bytes in use on the queue */ + u_long msg_qnum; /* number of msgs in the queue */ + u_long msg_qbytes; /* max # of bytes on the queue */ + pid_t msg_lspid; /* pid of last msgsnd() */ + pid_t msg_lrpid; /* pid of last msgrcv() */ + time_t msg_stime; /* time of last msgsnd() */ + long msg_pad1; + time_t msg_rtime; /* time of last msgrcv() */ + long msg_pad2; + time_t msg_ctime; /* time of last msgctl() */ + long msg_pad3; + long msg_pad4[4]; +}; +.Ed +.Pp +The +.Vt ipc_perm +structure used inside the +.Vt shmid_ds +structure is defined in +.Aq Pa sys/ipc.h +and looks like this: +.Bd -literal +struct ipc_perm { + ushort cuid; /* creator user id */ + ushort cgid; /* creator group id */ + ushort uid; /* user id */ + ushort gid; /* group id */ + ushort mode; /* r/w permission */ + ushort seq; /* sequence # (to generate unique msg/sem/shm id) */ + key_t key; /* user specified msg/sem/shm key */ +}; +.Ed +.Pp +The operation to be performed by +.Fn msgctl +is specified in +.Fa cmd +and is one of: +.Bl -tag -width IPC_RMIDX +.It Dv IPC_STAT +Gather information about the message queue and place it in the +structure pointed to by +.Fa buf . +.It Dv IPC_SET +Set the value of the +.Va msg_perm.uid , +.Va msg_perm.gid , +.Va msg_perm.mode +and +.Va msg_qbytes +fields in the structure associated with +.Fa msqid . +The values are taken from the corresponding fields in the structure +pointed to by +.Fa buf . +This operation can only be executed by the super-user, or a process that +has an effective user id equal to either +.Va msg_perm.cuid +or +.Va msg_perm.uid +in the data structure associated with the message queue. +The value of +.Va msg_qbytes +can only be increased by the super-user. +Values for +.Va msg_qbytes +that exceed the system limit (MSGMNB from +.Aq Pa sys/msg.h ) +are silently truncated to that limit. +.It Dv IPC_RMID +Remove the message queue specified by +.Fa msqid +and destroy the data associated with it. +Only the super-user or a process +with an effective uid equal to the +.Va msg_perm.cuid +or +.Va msg_perm.uid +values in the data structure associated with the queue can do this. +.El +.Pp +The permission to read from or write to a message queue (see +.Xr msgsnd 3 +and +.Xr msgrcv 3 ) +is determined by the +.Va msg_perm.mode +field in the same way as is +done with files (see +.Xr chmod 2 ) , +but the effective uid can match either the +.Va msg_perm.cuid +field or the +.Va msg_perm.uid +field, and the +effective gid can match either +.Va msg_perm.cgid +or +.Va msg_perm.gid . +.Sh RETURN VALUES +.Rv -std msgctl +.Sh ERRORS +.Fn msgctl +will fail if: +.Bl -tag -width Er +.It Bq Er EPERM +.Fa cmd +is equal to IPC_SET or IPC_RMID and the caller is not the super-user, nor does +the effective uid match either the +.Va msg_perm.uid +or +.Va msg_perm.cuid +fields of the data structure associated with the message queue. +.Pp +An attempt is made to increase the value of +.Va msg_qbytes +through IPC_SET +but the caller is not the super-user. +.It Bq Er EACCES +The command is IPC_STAT +and the caller has no read permission for this message queue. +.It Bq Er EINVAL +.Fa msqid +is not a valid message queue identifier. +.Pp +.Va cmd +is not a valid command. +.It Bq Er EFAULT +.Fa buf +specifies an invalid address. +.El +.Sh SEE ALSO +.Xr msgget 3 , +.Xr msgrcv 3 , +.Xr msgsnd 3 +.Sh HISTORY +Message queues appeared in the first release of +.At V . diff --git a/gen/msgget.3 b/gen/msgget.3 new file mode 100644 index 0000000..6a7ee9e --- /dev/null +++ b/gen/msgget.3 @@ -0,0 +1,139 @@ +.\" $NetBSD: msgget.2,v 1.1 1995/10/16 23:49:19 jtc Exp $ +.\" +.\" Copyright (c) 1995 Frank van der Linden +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed for the NetBSD Project +.\" by Frank van der Linden +.\" 4. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" $FreeBSD: src/lib/libc/gen/msgget.3,v 1.12 2001/10/01 16:08:51 ru Exp $ +.\" +.\"/ +.Dd August 17, 1995 +.Dt MSGGET 3 +.Os +.Sh NAME +.Nm msgget +.Nd get message queue +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In sys/ipc.h +.In sys/msg.h +.Ft int +.Fn msgget "key_t key" "int msgflg" +.Sh DESCRIPTION +.Fn msgget +returns the message queue identifier associated with +.Fa key . +A message queue identifier is a unique integer greater than zero. +.Pp +A message queue is created if either +.Fa key +is equal to +.Dv IPC_PRIVATE , +or +.Fa key +does not have a message queue identifier associated with it, and the +.Dv IPC_CREAT +bit is set in +.Fa msgflg . +.Pp +If a new message queue is created, the data structure associated with it (the +.Va msqid_ds +structure, see +.Xr msgctl 3 ) +is initialized as follows: +.Bl -bullet +.It +.Va msg_perm.cuid +and +.Va msg_perm.uid +are set to the effective uid of the calling process. +.It +.Va msg_perm.gid +and +.Va msg_perm.cgid +are set to the effective gid of the calling process. +.It +.Va msg_perm.mode +is set to the lower 9 bits of +.Fa msgflg . +.It +.Va msg_cbytes , +.Va msg_qnum , +.Va msg_lspid , +.Va msg_lrpid , +.Va msg_rtime , +and +.Va msg_stime +are set to 0. +.It +.Va msg_qbytes +is set to the system wide maximum value for the number of bytes in a queue +.Pf ( Dv MSGMNB ) . +.It +.Va msg_ctime +is set to the current time. +.El +.Sh RETURN VALUES +Upon successful completion a positive message queue identifier is returned. +Otherwise, -1 is returned and the global variable +.Va errno +is set to indicate the error. +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er EACCES +A message queue is already associated with +.Fa key +and the caller has no permission to access it. +.It Bq Er EEXIST +Both +.Dv IPC_CREAT +and +.Dv IPC_EXCL +are set in +.Fa msgflg , +and a message queue is already associated with +.Fa key . +.It Bq Er ENOSPC +A new message queue could not be created because the system limit for +the number of message queues has been reached. +.It Bq Er ENOENT +.Dv IPC_CREAT +was not set in +.Fa msgflg +and no message queue associated with +.Fa key +was found. +.El +.Sh SEE ALSO +.Xr msgctl 3 , +.Xr msgrcv 3 , +.Xr msgsnd 3 +.Sh HISTORY +Message queues appeared in the first release of +.At V . diff --git a/gen/msgrcv.3 b/gen/msgrcv.3 new file mode 100644 index 0000000..b80f987 --- /dev/null +++ b/gen/msgrcv.3 @@ -0,0 +1,202 @@ +.\" $NetBSD: msgrcv.2,v 1.1 1995/10/16 23:49:20 jtc Exp $ +.\" +.\" Copyright (c) 1995 Frank van der Linden +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed for the NetBSD Project +.\" by Frank van der Linden +.\" 4. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" $FreeBSD: src/lib/libc/gen/msgrcv.3,v 1.16 2001/10/01 16:08:51 ru Exp $ +.\" +.\"/ +.Dd November 24, 1997 +.Dt MSGRCV 3 +.Os +.Sh NAME +.Nm msgrcv +.Nd receive a message from a message queue +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In sys/ipc.h +.In sys/msg.h +.Ft int +.Fn msgrcv "int msqid" "void *msgp" "size_t msgsz" "long msgtyp" "int msgflg" +.Sh DESCRIPTION +The +.Fn msgrcv +function receives a message from the message queue specified in +.Fa msqid , +and places it into the structure pointed to by +.Fa msgp . +This structure should consist of the following members: +.Bd -literal + long mtype; /* message type */ + char mtext[1]; /* body of message */ +.Ed +.Pp +.Va mtype +is an integer greater than 0 that can be used for selecting messages, +.Va mtext +is an array of bytes, with a size up to that of the system limit +.Pf ( Dv MSGMAX ) . +.Pp +The value of +.Fa msgtyp +has one of the following meanings: +.Bl -bullet +.It +.Fa msgtyp +is greater than 0. The first message of type +.Fa msgtyp +will be received. +.It +.Fa msgtyp +is equal to 0. The first message on the queue will be received. +.It +.Fa msgtyp +is less than 0. The first message of the lowest message type that is +less than or equal to the absolute value of +.Fa msgtyp +will be received. +.El +.Pp +.Fa msgsz +specifies the maximum length of the requested message. +If the received +message has a length greater than +.Fa msgsz +it will be silently truncated if the +.Dv MSG_NOERROR +flag is set in +.Fa msgflg , +otherwise an error will be returned. +.Pp +If no matching message is present on the message queue specified by +.Fa msqid , +the behavior of +.Fn msgrcv +depends on whether the +.Dv IPC_NOWAIT +flag is set in +.Fa msgflg +or not. +If +.Dv IPC_NOWAIT +is set, +.Fn msgrcv +will immediately return a value of -1, and set +.Va errno +to +.Er EAGAIN . +If +.Dv IPC_NOWAIT +is not set, the calling process will be blocked +until: +.Bl -bullet +.It +A message of the requested type becomes available on the message queue. +.It +The message queue is removed, in which case -1 will be returned, and +.Va errno +set to +.Er EINVAL . +.It +A signal is received and caught. -1 is returned, and +.Va errno +set to +.Er EINTR . +.El +.Pp +If a message is successfully received, the data structure associated with +.Fa msqid +is updated as follows: +.Bl -bullet +.It +.Va msg_cbytes +is decremented by the size of the message. +.It +.Va msg_lrpid +is set to the pid of the caller. +.It +.Va msg_lrtime +is set to the current time. +.It +.Va msg_qnum +is decremented by 1. +.El +.Sh RETURN VALUES +Upon successful completion, +.Fn msgrcv +returns the number of bytes received into the +.Va mtext +field of the structure pointed to by +.Fa msgp . +Otherwise, -1 is returned, and +.Va errno +set to indicate the error. +.Sh ERRORS +.Fn msgrcv +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +.Fa msqid +is not a valid message queue identifier. +.Pp +The message queue was removed while +.Fn msgrcv +was waiting for a message of the requested type to become available on it. +.Pp +.Fa msgsz +is less than 0. +.It Bq Er E2BIG +A matching message was received, but its size was greater than +.Fa msgsz +and the +.Dv MSG_NOERROR +flag was not set in +.Fa msgflg . +.It Bq Er EACCES +The calling process does not have read access to the message queue. +.It Bq Er EFAULT +.Fa msgp +points to an invalid address. +.It Bq Er EINTR +The system call was interrupted by the delivery of a signal. +.It Bq Er EAGAIN +There is no message of the requested type available on the message queue, +and +.Dv IPC_NOWAIT +is set in +.Fa msgflg . +.El +.Sh SEE ALSO +.Xr msgctl 3 , +.Xr msgget 3 , +.Xr msgsnd 3 +.Sh HISTORY +Message queues appeared in the first release of +.At V . diff --git a/gen/msgsnd.3 b/gen/msgsnd.3 new file mode 100644 index 0000000..ee70922 --- /dev/null +++ b/gen/msgsnd.3 @@ -0,0 +1,167 @@ +.\" $NetBSD: msgsnd.2,v 1.1 1995/10/16 23:49:24 jtc Exp $ +.\" +.\" Copyright (c) 1995 Frank van der Linden +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed for the NetBSD Project +.\" by Frank van der Linden +.\" 4. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" $FreeBSD: src/lib/libc/gen/msgsnd.3,v 1.16 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd November 24, 1997 +.Dt MSGSND 3 +.Os +.Sh NAME +.Nm msgsnd +.Nd send a message to a message queue +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In sys/ipc.h +.In sys/msg.h +.Ft int +.Fn msgsnd "int msqid" "void *msgp" "size_t msgsz" "int msgflg" +.Sh DESCRIPTION +The +.Fn msgsnd +function sends a message to the message queue specified in +.Fa msqid . +.Fa msgp +points to a structure containing the message. +This structure should +consist of the following members: +.Bd -literal + long mtype; /* message type */ + char mtext[1]; /* body of message */ +.Ed +.Pp +.Va mtype +is an integer greater than 0 that can be used for selecting messages (see +.Xr msgrcv 3 ) , +.Va mtext +is an array of bytes, with a size up to that of the system limit +.Pf ( Dv MSGMAX ) . +.Pp +If the number of bytes already on the message queue plus +.Fa msgsz +is bigger than the maximum number of bytes on the message queue +.Pf ( Va msg_qbytes , +see +.Xr msgctl 3 ) , +or the number of messages on all queues system-wide is already equal to +the system limit, +.Fa msgflg +determines the action of +.Fn msgsnd . +If +.Fa msgflg +has +.Dv IPC_NOWAIT +mask set in it, the call will return immediately. +If +.Fa msgflg +does not have +.Dv IPC_NOWAIT +set in it, the call will block until: +.Bl -bullet +.It +The condition which caused the call to block does no longer exist. +The message will be sent. +.It +The message queue is removed, in which case -1 will be returned, and +.Va errno +is set to +.Er EINVAL . +.It +The caller catches a signal. +The call returns with +.Va errno +set to +.Er EINTR . +.El +.Pp +After a successful call, the data structure associated with the message +queue is updated in the following way: +.Bl -bullet +.It +.Va msg_cbytes +is incremented by the size of the message. +.It +.Va msg_qnum +is incremented by 1. +.It +.Va msg_lspid +is set to the pid of the calling process. +.It +.Va msg_stime +is set to the current time. +.El +.Sh RETURN VALUES +.Rv -std msgsnd +.Sh ERRORS +.Fn msgsnd +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +.Fa msqid +is not a valid message queue identifier +.Pp +The message queue was removed while +.Fn msgsnd +was waiting for a resource to become available in order to deliver the +message. +.Pp +.Fa msgsz +is less than 0, or greater than +.Va msg_qbytes . +.Pp +.Fa mtype +is not greater than 0. +.It Bq Er EACCES +The calling process does not have write access to the message queue. +.It Bq Er EAGAIN +There was no space for this message either on the queue, or in the whole +system, and +.Dv IPC_NOWAIT +was set in +.Fa msgflg . +.It Bq Er EFAULT +.Fa msgp +points to an invalid address. +.It Bq Er EINTR +The system call was interrupted by the delivery of a signal. +.El +.Sh BUGS +.Nx +and +.Fx +do not define the +.Er EIDRM +error value, which should be used +in the case of a removed message queue. +.Sh HISTORY +Message queues appeared in the first release of AT&T Unix System V. diff --git a/gen.subproj/nanosleep.c b/gen/nanosleep.c similarity index 100% rename from gen.subproj/nanosleep.c rename to gen/nanosleep.c diff --git a/gen/nice.3 b/gen/nice.3 new file mode 100644 index 0000000..6a98d9e --- /dev/null +++ b/gen/nice.3 @@ -0,0 +1,73 @@ +.\" Copyright (c) 1980, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)nice.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/nice.3,v 1.11 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt NICE 3 +.Os +.Sh NAME +.Nm nice +.Nd set program scheduling priority +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft int +.Fn nice "int incr" +.Sh DESCRIPTION +.Bf -symbolic +This interface is obsoleted by +.Xr setpriority 2 . +.Ef +.Pp +The +.Fn nice +function obtains the scheduling priority of the process +from the system and sets it to the priority value specified in +.Fa incr . +The priority is a value in the range -20 to 20. +The default priority is 0; lower priorities cause more favorable scheduling. +Only the super-user may lower priorities. +.Pp +Children inherit the priority of their parent processes via +.Xr fork 2 . +.Sh SEE ALSO +.Xr nice 1 , +.Xr fork 2 , +.Xr setpriority 2 , +.Xr renice 8 +.Sh HISTORY +A +.Fn nice +syscall appeared in +.At v6 . diff --git a/gen.subproj/nice.c b/gen/nice.c similarity index 100% rename from gen.subproj/nice.c rename to gen/nice.c diff --git a/gen/nlist.3 b/gen/nlist.3 new file mode 100644 index 0000000..09df218 --- /dev/null +++ b/gen/nlist.3 @@ -0,0 +1,77 @@ +.\" $OpenBSD: nlist.3,v 1.2 1996/08/19 08:25:07 tholo Exp $ +.\" +.\" Copyright (c) 1980, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.Dd April 19, 1994 +.Dt NLIST 3 +.Os Darwin +.Sh NAME +.Nm nlist +.Nd retrieve symbol table name list from an executable file +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn nlist "const char *filename" "struct nlist *nl" +.Sh DESCRIPTION +The +.Fn nlist +function +retrieves name list entries from the symbol table of an +executable file. (See ) +The argument +.Fa \&nl +is set to reference the +beginning of the list. +The list is preened of binary and invalid data; +if an entry in the +name list is valid, the +.Fa n_type +and +.Fa n_value +for the entry are copied into the list +referenced by +.Fa \&nl . +No other data is copied. +The last entry in the list is always +.Dv NULL . +.Sh RETURN VALUES +The number of invalid entries is returned if successful; otherwise, +if the file +.Fa filename +does not exist or is not executable, the returned value is \-1. +.Sh SEE ALSO +.Xr Mach-O 5 +.Sh HISTORY +A +.Fn nlist +function appeared in +.At v6 . diff --git a/gen.subproj/nlist.c b/gen/nlist.c similarity index 98% rename from gen.subproj/nlist.c rename to gen/nlist.c index e6fca65..ab17ad2 100644 --- a/gen.subproj/nlist.c +++ b/gen/nlist.c @@ -156,13 +156,16 @@ __fdnlist(fd, list) struct fat_header fh; struct fat_arch *fat_archs, *fap; unsigned i; + host_t host; /* Get our host info */ + host = mach_host_self(); i = HOST_BASIC_INFO_COUNT; - if (host_info(mach_host_self(), HOST_BASIC_INFO, + if (host_info(host, HOST_BASIC_INFO, (host_info_t)(&hbi), &i) != KERN_SUCCESS) { return (-1); } + mach_port_deallocate(mach_task_self(), host); /* Read in the fat header */ lseek(fd, 0, SEEK_SET); diff --git a/gen/nrand48.c b/gen/nrand48.c new file mode 100644 index 0000000..6c54065 --- /dev/null +++ b/gen/nrand48.c @@ -0,0 +1,21 @@ +/* + * Copyright (c) 1993 Martin Birgmeier + * All rights reserved. + * + * You may redistribute unmodified or modified versions of this source + * code provided that the above copyright notice and this and the + * following conditions are retained. + * + * This software is provided ``as is'', and comes with no warranties + * of any kind. I shall in no event be liable for anything that happens + * to anyone/anything when using this software. + */ + +#include "rand48.h" + +long +nrand48(unsigned short xseed[3]) +{ + _dorand48(xseed); + return ((long) xseed[2] << 15) + ((long) xseed[1] >> 1); +} diff --git a/gen.subproj/opendir.c b/gen/opendir.c similarity index 100% rename from gen.subproj/opendir.c rename to gen/opendir.c diff --git a/gen/pause.3 b/gen/pause.3 new file mode 100644 index 0000000..b8c257e --- /dev/null +++ b/gen/pause.3 @@ -0,0 +1,86 @@ +.\" Copyright (c) 1980, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)pause.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/pause.3,v 1.8 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt PAUSE 3 +.Os +.Sh NAME +.Nm pause +.Nd stop until signal +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft int +.Fn pause void +.Sh DESCRIPTION +.Sy Pause is made obsolete by +.Xr sigsuspend 2 . +.Pp +The +.Fn pause +function +forces a process to pause until +a signal is received from either the +.Xr kill 2 +function +or an interval timer. +(See +.Xr setitimer 2 . ) +Upon termination of a signal handler started during a +.Fn pause , +the +.Fn pause +call will return. +.Sh RETURN VALUES +Always returns \-1. +.Sh ERRORS +The +.Fn pause +function +always returns: +.Bl -tag -width Er +.It Bq Er EINTR +The call was interrupted. +.El +.Sh SEE ALSO +.Xr kill 2 , +.Xr select 2 , +.Xr sigsuspend 2 +.Sh HISTORY +A +.Fn pause +syscall +appeared in +.At v6 . diff --git a/gen.subproj/pause.c b/gen/pause.c similarity index 100% rename from gen.subproj/pause.c rename to gen/pause.c diff --git a/gen/popen.3 b/gen/popen.3 new file mode 100644 index 0000000..757531b --- /dev/null +++ b/gen/popen.3 @@ -0,0 +1,201 @@ +.\" Copyright (c) 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)popen.3 8.2 (Berkeley) 5/3/95 +.\" $FreeBSD: src/lib/libc/gen/popen.3,v 1.14 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd May 3, 1995 +.Dt POPEN 3 +.Os +.Sh NAME +.Nm popen , +.Nm pclose +.Nd process +.Tn I/O +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.Ft FILE * +.Fn popen "const char *command" "const char *type" +.Ft int +.Fn pclose "FILE *stream" +.Sh DESCRIPTION +The +.Fn popen +function +.Dq opens +a process by creating a bidirectional pipe +forking, +and invoking the shell. +Any streams opened by previous +.Fn popen +calls in the parent process are closed in the new child process. +Historically, +.Fn popen +was implemented with a unidirectional pipe; +hence many implementations of +.Fn popen +only allow the +.Fa type +argument to specify reading or writing, not both. +Since +.Fn popen +is now implemented using a bidirectional pipe, the +.Fa type +argument may request a bidirectional data flow. +The +.Fa type +argument is a pointer to a null-terminated string +which must be +.Ql r +for reading, +.Ql w +for writing, or +.Ql r+ +for reading and writing. +.Pp +The +.Fa command +argument is a pointer to a null-terminated string +containing a shell command line. +This command is passed to +.Pa /bin/sh +using the +.Fl c +flag; interpretation, if any, is performed by the shell. +.Pp +The return value from +.Fn popen +is a normal standard +.Tn I/O +stream in all respects +save that it must be closed with +.Fn pclose +rather than +.Fn fclose . +Writing to such a stream +writes to the standard input of the command; +the command's standard output is the same as that of the process that called +.Fn popen , +unless this is altered by the command itself. +Conversely, reading from a +.Dq popened +stream reads the command's standard output, and +the command's standard input is the same as that of the process that called +.Fn popen . +.Pp +Note that output +.Fn popen +streams are fully buffered by default. +.Pp +The +.Fn pclose +function waits for the associated process to terminate +and returns the exit status of the command +as returned by +.Fn wait4 . +.Sh RETURN VALUES +The +.Fn popen +function returns +.Dv NULL +if the +.Xr fork 2 +or +.Xr pipe 2 +calls fail, +or if it cannot allocate memory. +.Pp +The +.Fn pclose +function +returns \-1 if +.Fa stream +is not associated with a +.Dq popened +command, if +.Fa stream +already +.Dq pclosed , +or if +.Xr wait4 +returns an error. +.Sh ERRORS +The +.Fn popen +function does not reliably set +.Va errno . +.Sh SEE ALSO +.Xr sh 1 , +.Xr fork 2 , +.Xr pipe 2 , +.Xr wait4 2 , +.Xr fclose 3 , +.Xr fflush 3 , +.Xr fopen 3 , +.Xr stdio 3 , +.Xr system 3 +.Sh BUGS +Since the standard input of a command opened for reading +shares its seek offset with the process that called +.Fn popen , +if the original process has done a buffered read, +the command's input position may not be as expected. +Similarly, the output from a command opened for writing +may become intermingled with that of the original process. +The latter can be avoided by calling +.Xr fflush 3 +before +.Fn popen . +.Pp +Failure to execute the shell +is indistinguishable from the shell's failure to execute command, +or an immediate exit of the command. +The only hint is an exit status of 127. +.Pp +The +.Fn popen +argument +always calls +.Xr sh 1 , +never calls +.Xr csh 1 . +.Sh HISTORY +A +.Fn popen +and a +.Fn pclose +function appeared in +.At v7 . +.Pp +Bidirectional functionality was added in +.Fx 2.2.6 . diff --git a/gen.subproj/popen.c b/gen/popen.c similarity index 100% rename from gen.subproj/popen.c rename to gen/popen.c diff --git a/gen/psignal.3 b/gen/psignal.3 new file mode 100644 index 0000000..67bed20 --- /dev/null +++ b/gen/psignal.3 @@ -0,0 +1,113 @@ +.\" Copyright (c) 1983, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)psignal.3 8.2 (Berkeley) 2/27/95 +.\" $FreeBSD: src/lib/libc/gen/psignal.3,v 1.15 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd February 27, 1995 +.Dt PSIGNAL 3 +.Os +.Sh NAME +.Nm psignal , +.Nm strsignal , +.Nm sys_siglist , +.Nm sys_signame +.Nd system signal messages +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In signal.h +.Ft void +.Fn psignal "unsigned sig" "const char *s" +.Vt extern const char * const sys_siglist[] ; +.Vt extern const char * const sys_signame[] ; +.In string.h +.Ft "char *" +.Fn strsignal "int sig" +.Sh DESCRIPTION +The +.Fn psignal +and +.Fn strsignal +functions locate the descriptive message +string for a signal number. +.Pp +The +.Fn strsignal +function accepts a signal number argument +.Fa sig +and returns a pointer to the corresponding message string. +.Pp +The +.Fn psignal +function accepts an signal number argument +.Fa sig +and writes it to the standard error. +If the argument +.Fa s +is +.Pf non- Dv NULL +and does not point to the null character, +.Fa s +is written to the standard error file descriptor +prior to the message string, +immediately followed by a colon and a space. +If the signal number is not recognized +.Pq Xr sigaction 2 , +the string +.Dq "Unknown signal +is produced. +.Pp +The message strings can be accessed directly +through the external array +.Va sys_siglist , +indexed by recognized signal numbers. +The external array +.Va sys_signame +is used similarly and +contains short, lower-case abbreviations for signals +which are useful for recognizing signal names +in user input. +The defined variable +.Dv NSIG +contains a count of the strings in +.Va sys_siglist +and +.Va sys_signame . +.Sh SEE ALSO +.Xr sigaction 2 , +.Xr perror 3 , +.Xr strerror 3 +.Sh HISTORY +The +.Fn psignal +function appeared in +.Bx 4.2 . diff --git a/gen.subproj/psignal.c b/gen/psignal.c similarity index 100% rename from gen.subproj/psignal.c rename to gen/psignal.c diff --git a/gen/pwcache.3 b/gen/pwcache.3 new file mode 100644 index 0000000..42f2592 --- /dev/null +++ b/gen/pwcache.3 @@ -0,0 +1,96 @@ +.\" Copyright (c) 1989, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)pwcache.3 8.1 (Berkeley) 6/9/93 +.\" $FreeBSD: src/lib/libc/gen/pwcache.3,v 1.10 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd June 9, 1993 +.Dt PWCACHE 3 +.Os +.Sh NAME +.Nm pwcache +.Nd cache password and group entries +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft char * +.Fn user_from_uid "unsigned long uid" "int nouser" +.Ft char * +.Fn group_from_gid "unsigned long gid" "int nogroup" +.Sh DESCRIPTION +The +.Fn user_from_uid +function returns the user name associated with the argument +.Fa uid . +The user name is cached so that multiple calls with the same +.Fa uid +do not require additional calls to +.Xr getpwuid 3 . +If there is no user associated with the +.Fa uid , +a pointer is returned +to a string representation of the +.Fa uid , +unless the argument +.Fa nouser +is non-zero, in which case a +.Dv NULL +pointer is returned. +.Pp +The +.Fn group_from_gid +function returns the group name associated with the argument +.Fa gid . +The group name is cached so that multiple calls with the same +.Fa gid +do not require additional calls to +.Xr getgrgid 3 . +If there is no group associated with the +.Fa gid , +a pointer is returned +to a string representation of the +.Fa gid , +unless the argument +.Fa nogroup +is non-zero, in which case a +.Dv NULL +pointer is returned. +.Sh SEE ALSO +.Xr getgrgid 3 , +.Xr getpwuid 3 +.Sh HISTORY +The +.Fn user_from_uid +and +.Fn group_from_gid +functions first appeared in +.Bx 4.4 . diff --git a/net.subproj/iso_addr.c b/gen/pwcache.c similarity index 58% rename from net.subproj/iso_addr.c rename to gen/pwcache.c index 3267fa8..9a5f33c 100644 --- a/net.subproj/iso_addr.c +++ b/gen/pwcache.c @@ -54,84 +54,105 @@ #include -#include -#include -/* States*/ -#define VIRGIN 0 -#define GOTONE 1 -#define GOTTWO 2 -/* Inputs */ -#define DIGIT (4*0) -#define END (4*1) -#define DELIM (4*2) +#include +#include +#include +#include -struct iso_addr * -iso_addr(addr) - register const char *addr; +#define NCACHE 64 /* power of 2 */ +#define MASK NCACHE - 1 /* bits to store with */ + +#ifdef NeXT +/* lookupd caches users, so there's no point in another cache here */ +char * +user_from_uid(uid, nouser) + uid_t uid; + int nouser; { - static struct iso_addr out_addr; - register char *cp = out_addr.isoa_genaddr; - char *cplim = cp + sizeof(out_addr.isoa_genaddr); - register int byte = 0, state = VIRGIN, new; + static struct passwd *pw; - bzero((char *)&out_addr, sizeof(out_addr)); - do { - if ((*addr >= '0') && (*addr <= '9')) { - new = *addr - '0'; - } else if ((*addr >= 'a') && (*addr <= 'f')) { - new = *addr - 'a' + 10; - } else if ((*addr >= 'A') && (*addr <= 'F')) { - new = *addr - 'A' + 10; - } else if (*addr == 0) - state |= END; - else - state |= DELIM; - addr++; - switch (state /* | INPUT */) { - case GOTTWO | DIGIT: - *cp++ = byte; /*FALLTHROUGH*/ - case VIRGIN | DIGIT: - state = GOTONE; byte = new; continue; - case GOTONE | DIGIT: - state = GOTTWO; byte = new + (byte << 4); continue; - default: /* | DELIM */ - state = VIRGIN; *cp++ = byte; byte = 0; continue; - case GOTONE | END: - case GOTTWO | END: - *cp++ = byte; /* FALLTHROUGH */ - case VIRGIN | END: - break; + if ((pw = getpwuid(uid)) == NULL) return (NULL); + return pw->pw_name; +} +#else +char * +user_from_uid(uid, nouser) + uid_t uid; + int nouser; +{ + static struct ncache { + uid_t uid; + char name[UT_NAMESIZE + 1]; + } c_uid[NCACHE]; + static int pwopen; + static char nbuf[15]; /* 32 bits == 10 digits */ + register struct passwd *pw; + register struct ncache *cp; + + cp = c_uid + (uid & MASK); + if (cp->uid != uid || !*cp->name) { + if (pwopen == 0) { + setpassent(1); + pwopen = 1; + } + if ((pw = getpwuid(uid)) == NULL) { + if (nouser) + return (NULL); + (void)snprintf(nbuf, sizeof(nbuf), "%u", uid); + return (nbuf); } - break; - } while (cp < cplim); - out_addr.isoa_len = cp - out_addr.isoa_genaddr; - return (&out_addr); + cp->uid = uid; + (void)strncpy(cp->name, pw->pw_name, UT_NAMESIZE); + cp->name[UT_NAMESIZE] = '\0'; + } + return (cp->name); } -static char hexlist[] = "0123456789abcdef"; +#endif +#ifdef NeXT +/* lookupd caches groups, so there's no point in another cache here */ char * -iso_ntoa(isoa) - const struct iso_addr *isoa; +group_from_gid(gid, nogroup) + gid_t gid; + int nogroup; { - static char obuf[64]; - register char *out = obuf; - register int i; - register u_char *in = (u_char *)isoa->isoa_genaddr; - u_char *inlim = in + isoa->isoa_len; + static struct group *gr; - out[1] = 0; - while (in < inlim) { - i = *in++; - *out++ = '.'; - if (i > 0xf) { - out[1] = hexlist[i & 0xf]; - i >>= 4; - out[0] = hexlist[i]; - out += 2; - } else - *out++ = hexlist[i]; + if ((gr = getgrgid(gid)) == NULL) return (NULL); + return gr->gr_name; +} +#else +char * +group_from_gid(gid, nogroup) + gid_t gid; + int nogroup; +{ + static struct ncache { + gid_t gid; + char name[UT_NAMESIZE + 1]; + } c_gid[NCACHE]; + static int gropen; + static char nbuf[15]; /* 32 bits == 10 digits */ + struct group *gr; + struct ncache *cp; + + cp = c_gid + (gid & MASK); + if (cp->gid != gid || !*cp->name) { + if (gropen == 0) { + setgroupent(1); + gropen = 1; + } + if ((gr = getgrgid(gid)) == NULL) { + if (nogroup) + return (NULL); + (void)snprintf(nbuf, sizeof(nbuf), "%u", gid); + return (nbuf); + } + cp->gid = gid; + (void)strncpy(cp->name, gr->gr_name, UT_NAMESIZE); + cp->name[UT_NAMESIZE] = '\0'; } - *out = 0; - return(obuf + 1); + return (cp->name); } +#endif NeXT diff --git a/gen/raise.3 b/gen/raise.3 new file mode 100644 index 0000000..1a8fcd7 --- /dev/null +++ b/gen/raise.3 @@ -0,0 +1,77 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)raise.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/raise.3,v 1.7 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt RAISE 3 +.Os +.Sh NAME +.Nm raise +.Nd send a signal to the current process +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In signal.h +.Ft int +.Fn raise "int sig" +.Sh DESCRIPTION +The +.Fn raise +function sends the signal +.Fa sig +to the current process. +.Sh RETURN VALUES +.Rv -std raise +.Sh ERRORS +The +.Fn raise +function +may fail and set +.Va errno +for any of the errors specified for the +library functions +.Xr getpid 2 +and +.Xr kill 2 . +.Sh SEE ALSO +.Xr kill 2 +.Sh STANDARDS +The +.Fn raise +function +conforms to +.St -isoC . diff --git a/gen.subproj/raise.c b/gen/raise.c similarity index 100% rename from gen.subproj/raise.c rename to gen/raise.c diff --git a/gen/rand48.3 b/gen/rand48.3 new file mode 100644 index 0000000..08aafec --- /dev/null +++ b/gen/rand48.3 @@ -0,0 +1,167 @@ +.\" Copyright (c) 1993 Martin Birgmeier +.\" All rights reserved. +.\" +.\" You may redistribute unmodified or modified versions of this source +.\" code provided that the above copyright notice and this and the +.\" following conditions are retained. +.\" +.\" This software is provided ``as is'', and comes with no warranties +.\" of any kind. I shall in no event be liable for anything that happens +.\" to anyone/anything when using this software. +.\" +.\" @(#)rand48.3 V1.0 MB 8 Oct 1993 +.\" $FreeBSD: src/lib/libc/gen/rand48.3,v 1.13 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd October 8, 1993 +.Dt RAND48 3 +.Os +.Sh NAME +.Nm drand48 , +.Nm erand48 , +.Nm lrand48 , +.Nm nrand48 , +.Nm mrand48 , +.Nm jrand48 , +.Nm srand48 , +.Nm seed48 , +.Nm lcong48 +.Nd pseudo random number generators and initialization routines +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft double +.Fn drand48 void +.Ft double +.Fn erand48 "unsigned short xseed[3]" +.Ft long +.Fn lrand48 void +.Ft long +.Fn nrand48 "unsigned short xseed[3]" +.Ft long +.Fn mrand48 void +.Ft long +.Fn jrand48 "unsigned short xseed[3]" +.Ft void +.Fn srand48 "long seed" +.Ft "unsigned short *" +.Fn seed48 "unsigned short xseed[3]" +.Ft void +.Fn lcong48 "unsigned short p[7]" +.Sh DESCRIPTION +The +.Fn rand48 +family of functions generates pseudo-random numbers using a linear +congruential algorithm working on integers 48 bits in size. +The +particular formula employed is +r(n+1) = (a * r(n) + c) mod m +where the default values are +for the multiplicand a = 0xfdeece66d = 25214903917 and +the addend c = 0xb = 11. +The modulo is always fixed at m = 2 ** 48. +r(n) is called the seed of the random number generator. +.Pp +For all the six generator routines described next, the first +computational step is to perform a single iteration of the algorithm. +.Pp +.Fn drand48 +and +.Fn erand48 +return values of type double. +The full 48 bits of r(n+1) are +loaded into the mantissa of the returned value, with the exponent set +such that the values produced lie in the interval [0.0, 1.0). +.Pp +.Fn lrand48 +and +.Fn nrand48 +return values of type long in the range +[0, 2**31-1]. The high-order (31) bits of +r(n+1) are loaded into the lower bits of the returned value, with +the topmost (sign) bit set to zero. +.Pp +.Fn mrand48 +and +.Fn jrand48 +return values of type long in the range +[-2**31, 2**31-1]. The high-order (32) bits of +r(n+1) are loaded into the returned value. +.Pp +.Fn drand48 , +.Fn lrand48 , +and +.Fn mrand48 +use an internal buffer to store r(n). For these functions +the initial value of r(0) = 0x1234abcd330e = 20017429951246. +.Pp +On the other hand, +.Fn erand48 , +.Fn nrand48 , +and +.Fn jrand48 +use a user-supplied buffer to store the seed r(n), +which consists of an array of 3 shorts, where the zeroth member +holds the least significant bits. +.Pp +All functions share the same multiplicand and addend. +.Pp +.Fn srand48 +is used to initialize the internal buffer r(n) of +.Fn drand48 , +.Fn lrand48 , +and +.Fn mrand48 +such that the 32 bits of the seed value are copied into the upper 32 bits +of r(n), with the lower 16 bits of r(n) arbitrarily being set to 0x330e. +Additionally, the constant multiplicand and addend of the algorithm are +reset to the default values given above. +.Pp +.Fn seed48 +also initializes the internal buffer r(n) of +.Fn drand48 , +.Fn lrand48 , +and +.Fn mrand48 , +but here all 48 bits of the seed can be specified in an array of 3 shorts, +where the zeroth member specifies the lowest bits. +Again, +the constant multiplicand and addend of the algorithm are +reset to the default values given above. +.Fn seed48 +returns a pointer to an array of 3 shorts which contains the old seed. +This array is statically allocated, thus its contents are lost after +each new call to +.Fn seed48 . +.Pp +Finally, +.Fn lcong48 +allows full control over the multiplicand and addend used in +.Fn drand48 , +.Fn erand48 , +.Fn lrand48 , +.Fn nrand48 , +.Fn mrand48 , +and +.Fn jrand48 , +and the seed used in +.Fn drand48 , +.Fn lrand48 , +and +.Fn mrand48 . +An array of 7 shorts is passed as parameter; the first three shorts are +used to initialize the seed; the second three are used to initialize the +multiplicand; and the last short is used to initialize the addend. +It is thus not possible to use values greater than 0xffff as the addend. +.Pp +Note that all three methods of seeding the random number generator +always also set the multiplicand and addend for any of the six +generator calls. +.Pp +For a more powerful random number generator, see +.Xr random 3 . +.Sh AUTHORS +.An Martin Birgmeier +.Sh SEE ALSO +.Xr rand 3 , +.Xr random 3 diff --git a/gen/rand48.h b/gen/rand48.h new file mode 100644 index 0000000..5b9f87d --- /dev/null +++ b/gen/rand48.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 1993 Martin Birgmeier + * All rights reserved. + * + * You may redistribute unmodified or modified versions of this source + * code provided that the above copyright notice and this and the + * following conditions are retained. + * + * This software is provided ``as is'', and comes with no warranties + * of any kind. I shall in no event be liable for anything that happens + * to anyone/anything when using this software. + */ + +#ifndef _RAND48_H_ +#define _RAND48_H_ + +#include +#include + +void _dorand48 __P((unsigned short[3])); + +#define RAND48_SEED_0 (0x330e) +#define RAND48_SEED_1 (0xabcd) +#define RAND48_SEED_2 (0x1234) +#define RAND48_MULT_0 (0xe66d) +#define RAND48_MULT_1 (0xdeec) +#define RAND48_MULT_2 (0x0005) +#define RAND48_ADD (0x000b) + +#endif /* _RAND48_H_ */ diff --git a/gen/rcmd.c b/gen/rcmd.c new file mode 100644 index 0000000..b884c9e --- /dev/null +++ b/gen/rcmd.c @@ -0,0 +1,429 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1983, 1993, 1994 + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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 8.3 (Berkeley) 3/26/94"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int __ivaliduser __P((FILE *, u_long, const char *, const char *)); +static int __icheckhost __P((u_long, char *)); + +int +rcmd(ahost, rport, locuser, remuser, cmd, fd2p) + char **ahost; + u_short rport; + const char *locuser, *remuser, *cmd; + int *fd2p; +{ + struct hostent *hp; + struct sockaddr_in sin, from; + fd_set reads; + long oldmask; + pid_t pid; + int s, lport, timo; + char c; + + pid = getpid(); + hp = gethostbyname(*ahost); + if (hp == NULL) { + herror(*ahost); + return (-1); + } + *ahost = hp->h_name; + oldmask = sigblock(sigmask(SIGURG)); + for (timo = 1, lport = IPPORT_RESERVED - 1;;) { + s = rresvport(&lport); + if (s < 0) { + if (errno == EAGAIN) + (void)fprintf(stderr, + "rcmd: socket: All ports in use\n"); + else + (void)fprintf(stderr, "rcmd: socket: %s\n", + strerror(errno)); + sigsetmask(oldmask); + return (-1); + } + fcntl(s, F_SETOWN, pid); + sin.sin_family = hp->h_addrtype; + bcopy(hp->h_addr_list[0], &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) { + (void)sleep(timo); + timo *= 2; + continue; + } + if (hp->h_addr_list[1] != NULL) { + int oerrno = errno; + + (void)fprintf(stderr, "connect to address %s: ", + inet_ntoa(sin.sin_addr)); + errno = oerrno; + perror(0); + hp->h_addr_list++; + bcopy(hp->h_addr_list[0], &sin.sin_addr, hp->h_length); + (void)fprintf(stderr, "Trying %s...\n", + inet_ntoa(sin.sin_addr)); + continue; + } + (void)fprintf(stderr, "%s: %s\n", hp->h_name, strerror(errno)); + sigsetmask(oldmask); + 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) { + (void)fprintf(stderr, + "rcmd: write (setting up stderr): %s\n", + strerror(errno)); + (void)close(s2); + goto bad; + } + FD_ZERO(&reads); + FD_SET(s, &reads); + FD_SET(s2, &reads); + errno = 0; + if (select(32, &reads, 0, 0, 0) < 1 || !FD_ISSET(s2, &reads)) { + if (errno != 0) + (void)fprintf(stderr, + "rcmd: select (setting up stderr): %s\n", + strerror(errno)); + else + (void)fprintf(stderr, + "select: protocol failure in circuit setup\n"); + (void)close(s2); + goto bad; + } + s3 = accept(s2, (struct sockaddr *)&from, &len); + (void)close(s2); + if (s3 < 0) { + (void)fprintf(stderr, + "rcmd: accept: %s\n", strerror(errno)); + 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 || + from.sin_port < IPPORT_RESERVED / 2) { + (void)fprintf(stderr, + "socket: protocol failure in circuit setup.\n"); + 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) { + (void)fprintf(stderr, + "rcmd: %s: %s\n", *ahost, strerror(errno)); + goto bad2; + } + if (c != 0) { + while (read(s, &c, 1) == 1) { + (void)write(STDERR_FILENO, &c, 1); + if (c == '\n') + break; + } + goto bad2; + } + sigsetmask(oldmask); + return (s); +bad2: + if (lport) + (void)close(*fd2p); +bad: + (void)close(s); + sigsetmask(oldmask); + return (-1); +} + +int +rresvport(alport) + 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); + } + } +} + +int __check_rhosts_file = 1; +char *__rcmd_errstr; + +int +ruserok(rhost, superuser, ruser, luser) + const char *rhost, *ruser, *luser; + int superuser; +{ + struct hostent *hp; + u_long addr; + char **ap; + + if ((hp = gethostbyname(rhost)) == NULL) + return (-1); + for (ap = hp->h_addr_list; *ap; ++ap) { + bcopy(*ap, &addr, sizeof(addr)); + if (iruserok(addr, superuser, ruser, luser) == 0) + return (0); + } + return (-1); +} + +/* + * New .rhosts strategy: We are passed an ip address. We spin through + * hosts.equiv and .rhosts looking for a match. When the .rhosts only + * has ip addresses, we don't have to trust a nameserver. When it + * contains hostnames, we spin through the list of addresses the nameserver + * gives us and look for a match. + * + * Returns 0 if ok, -1 if not ok. + */ +int +iruserok(raddr, superuser, ruser, luser) + u_long raddr; + int superuser; + const char *ruser, *luser; +{ + register char *cp; + struct stat sbuf; + struct passwd *pwd; + FILE *hostf; + uid_t uid; + int first; + char pbuf[MAXPATHLEN]; + + first = 1; + hostf = superuser ? NULL : fopen(_PATH_HEQUIV, "r"); +again: + if (hostf) { + if (__ivaliduser(hostf, raddr, luser, ruser) == 0) { + (void)fclose(hostf); + return (0); + } + (void)fclose(hostf); + } + if (first == 1 && (__check_rhosts_file || superuser)) { + first = 0; + if ((pwd = getpwnam(luser)) == NULL) + return (-1); + (void)strcpy(pbuf, pwd->pw_dir); + (void)strcat(pbuf, "/.rhosts"); + + /* + * Change effective uid while opening .rhosts. If root and + * reading an NFS mounted file system, can't read files that + * are protected read/write owner only. + */ + uid = geteuid(); + (void)seteuid(pwd->pw_uid); + hostf = fopen(pbuf, "r"); + (void)seteuid(uid); + + if (hostf == NULL) + return (-1); + /* + * If not a regular file, or is owned by someone other than + * user or root or if writeable by anyone but the owner, quit. + */ + cp = NULL; + if (lstat(pbuf, &sbuf) < 0) + cp = ".rhosts lstat failed"; + else if (!S_ISREG(sbuf.st_mode)) + cp = ".rhosts not regular file"; + else if (fstat(fileno(hostf), &sbuf) < 0) + cp = ".rhosts fstat failed"; + else if (sbuf.st_uid && sbuf.st_uid != pwd->pw_uid) + cp = "bad .rhosts owner"; + else if (sbuf.st_mode & (S_IWGRP|S_IWOTH)) + cp = ".rhosts writeable by other than owner"; + /* If there were any problems, quit. */ + if (cp) { + __rcmd_errstr = cp; + (void)fclose(hostf); + return (-1); + } + goto again; + } + return (-1); +} + +/* + * XXX + * Don't make static, used by lpd(8). + * + * Returns 0 if ok, -1 if not ok. + */ +int +__ivaliduser(hostf, raddr, luser, ruser) + FILE *hostf; + u_long raddr; + const char *luser, *ruser; +{ + register char *user, *p; + int ch; + char buf[MAXHOSTNAMELEN + 128]; /* host + login */ + + while (fgets(buf, sizeof(buf), hostf)) { + p = buf; + /* Skip lines that are too long. */ + if (strchr(p, '\n') == NULL) { + while ((ch = getc(hostf)) != '\n' && ch != EOF); + continue; + } + 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'; + if (__icheckhost(raddr, buf) && + strcmp(ruser, *user ? user : luser) == 0) { + return (0); + } + } + return (-1); +} + +/* + * Returns "true" if match, 0 if no match. + */ +static int +__icheckhost(raddr, lhost) + u_long raddr; + register char *lhost; +{ + register struct hostent *hp; + register u_long laddr; + register char **pp; + + /* Try for raw ip address first. */ + if (isdigit(*lhost) && (long)(laddr = inet_addr(lhost)) != -1) + return (raddr == laddr); + + /* Better be a hostname. */ + if ((hp = gethostbyname(lhost)) == NULL) + return (0); + + /* Spin through ip addresses. */ + for (pp = hp->h_addr_list; *pp; ++pp) + if (!bcmp(&raddr, *pp, sizeof(u_long))) + return (1); + + /* No match. */ + return (0); +} diff --git a/gen.subproj/readdir.c b/gen/readdir.c similarity index 100% rename from gen.subproj/readdir.c rename to gen/readdir.c diff --git a/gen/readdir_r.c b/gen/readdir_r.c new file mode 100644 index 0000000..8e19ccc --- /dev/null +++ b/gen/readdir_r.c @@ -0,0 +1,51 @@ +#include +#include +#include + +/* + * Synopsis: + * dir_table is a global static array of pthread mutexes. The array is NMUTEXES + * in length (NMUTEXES * sizeof(pthread_mutex_t)). + * + * Whenever a call to readdir_r is made, the element in the array indexed by the + * modulus of the file descriptor associated with dirp is locked, and readdir is + * called on dirp. The result is returned in readdir_r semantics and the + * element in dir_table is unlocked. + */ + +static pthread_mutex_t dir_table[] = { + PTHREAD_MUTEX_INITIALIZER, + PTHREAD_MUTEX_INITIALIZER, + PTHREAD_MUTEX_INITIALIZER, + PTHREAD_MUTEX_INITIALIZER, + PTHREAD_MUTEX_INITIALIZER, + PTHREAD_MUTEX_INITIALIZER, + PTHREAD_MUTEX_INITIALIZER, + PTHREAD_MUTEX_INITIALIZER +#define NMUTEXES 8 +}; + +int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result) +{ + int ret; + int mindex = dirp->dd_fd % NMUTEXES; + struct dirent *tmpdp; + + pthread_mutex_lock(&dir_table[mindex]); + + tmpdp = readdir(dirp); + if( tmpdp == NULL ) { + *result = NULL; + ret = errno; + pthread_mutex_unlock(&dir_table[mindex]); + return ret; + } + + memcpy(entry, tmpdp, sizeof(struct dirent)); + *result = entry; + + pthread_mutex_unlock(&dir_table[mindex]); + return 0; +} + + diff --git a/gen.subproj/rewinddir.c b/gen/rewinddir.c similarity index 100% rename from gen.subproj/rewinddir.c rename to gen/rewinddir.c diff --git a/gen/rfork_thread.3 b/gen/rfork_thread.3 new file mode 100644 index 0000000..3d78998 --- /dev/null +++ b/gen/rfork_thread.3 @@ -0,0 +1,77 @@ +.\" +.\" Copyright (c) 2000 Peter Wemm +.\" 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. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. +.\" +.\" $FreeBSD: src/lib/libc/gen/rfork_thread.3,v 1.5 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd July 29, 2000 +.Dt RFORK_THREAD 3 +.Os +.Sh NAME +.Nm rfork_thread +.Nd create a rfork-based process thread +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft int +.Fn rfork_thread "int flags" "void *stack" "int (*func)(void *arg)" "void *arg" +.Sh DESCRIPTION +.Fn rfork_thread +is a helper function for +.Xr rfork 2 . +It arranges for a new process to be created and the child process will +call the specified function with the specified argument, while running on +the supplied stack. +.Pp +Using this function should avoid the need to implement complex stack +swap code. +.Sh RETURN VALUES +Upon successful completion, +.Fn rfork_thread +returns the process ID of the child process to the parent process. +Otherwise, a value of -1 is returned +to the parent process, no child process is created, and the global +variable +.Va errno +is set to indicate the error. +.Pp +The child process context is not aware of a return from the +.Fn rfork_thread +function as it begins executing directly with the supplied function. +.Sh ERRORS +See +.Xr rfork 2 +for error return codes. +.Sh SEE ALSO +.Xr fork 2 , +.Xr intro 2 , +.Xr minherit 2 , +.Xr rfork 2 , +.Xr vfork 2 +.Sh HISTORY +The +.Fn rfork_thread +function call first appeared in +.Fx 4.3 . diff --git a/gen.subproj/scalable_malloc.c b/gen/scalable_malloc.c similarity index 87% rename from gen.subproj/scalable_malloc.c rename to gen/scalable_malloc.c index a19c7a4..2bd6bcf 100644 --- a/gen.subproj/scalable_malloc.c +++ b/gen/scalable_malloc.c @@ -49,6 +49,8 @@ static unsigned vm_page_shift = 0; // guaranteed to be intialized by zone creati #define VM_COPY_THRESHOLD (40 * 1024) // When all memory is touched after a copy, vm_copy() is always a lose // But if the memory is only read, vm_copy() wins over memmove() at 3 or 4 pages (on a G3/300MHz) + // This must be larger than LARGE_THRESHOLD + #define KILL_THRESHOLD (32 * 1024) #define LARGE_THRESHOLD (3 * vm_page_size) // at or above this use "large" @@ -76,12 +78,9 @@ If 0 then the block is either free (in which case the size is directly at the bl #define PROTECT_SMALL 0 // Should be 0: 1 is too slow for normal use -#define LARGE_CACHE_SIZE 1 // define hysterisis of large chunks -#define MAX_LARGE_SIZE_TO_CACHE (128*1024) /* blocks larger than this are not cached */ - #define MAX_RECORDER_BUFFER 256 -#define MAX_GRAIN 64 +#define MAX_GRAIN 128 typedef unsigned short msize_t; // a size in multiples of SHIFT_QUANTUM @@ -124,12 +123,8 @@ typedef struct { unsigned num_small_objects; unsigned num_bytes_in_small_objects; - /* Cache of recently freed large object */ - vm_range_t large_to_deallocate[LARGE_CACHE_SIZE]; - // Entries that are 0 should be discarded - /* large objects: vm_page_shift <= log2(size) < 2 *vm_page_shift */ - unsigned num_large_objects_in_use; // does not count the large entries in large_to_deallocate + unsigned num_large_objects_in_use; unsigned num_large_entries; unsigned num_bytes_in_large_objects; large_entry_t *large_entries; @@ -209,6 +204,7 @@ static vm_address_t allocate_pages(szone_t *szone, size_t size, unsigned debug_f if (add_guard_pages) allocation_size += 2 * vm_page_size; err = vm_allocate(mach_task_self(), &addr, allocation_size, vm_page_label | 1); if (err) { + malloc_printf("*** malloc: vm_allocate(size=%d) failed with %d\n", size, err); szone_error(szone, "Can't allocate region", NULL); return NULL; } @@ -237,68 +233,6 @@ static kern_return_t _szone_default_reader(task_t task, vm_address_t address, vm return 0; } -/********************* RANGE UTILITIES ************************/ - -static const vm_range_t zero_range = {0, 0}; - -static vm_range_t coalesce_range(vm_range_t *ranges, unsigned count, vm_range_t range) { - // Given a sequence of ranges and a range, tries to find an abutting range - // If no, returns original range - // Else zeroes out coalesced range, and reapplies with coalesced range - unsigned index = count; - vm_range_t *current = ranges; - while (index--) { - vm_range_t this = *current++; - if (!this.size) continue; - if (this.address + this.size == range.address) { - range.address = this.address; - range.size += this.size; - current[-1] = zero_range; - return coalesce_range(ranges, count, range); - } - if (range.address + range.size == this.address) { - range.size += this.size; - current[-1] = zero_range; - return coalesce_range(ranges, count, range); - } - } - return range; -} - -static INLINE vm_range_t *first_zero_range(vm_range_t *ranges, unsigned count) { - // Given a sequence of ranges, find the first empty slot - // or returns NULL - while (count--) { - if (!ranges->size) return ranges; - ranges++; - } - return NULL; -} - -static vm_range_t *largest_range(vm_range_t *ranges, unsigned count) { - // Given a sequence of ranges, find the largest range - // Returns NULL on empty arrays - vm_range_t *largest_range; - if (!count) return NULL; - largest_range = ranges; - count--; ranges++; - while (count--) { - if (ranges->size > largest_range->size) largest_range = ranges; - ranges++; - } - return largest_range; -} - -static vm_range_t *first_range_greater_or_equal(vm_range_t *ranges, unsigned count, vm_size_t size) { - // Given a sequence of ranges, find the first range greater than range - // Returns NULL when none found - while (count--) { - if (ranges->size >= size) return ranges; - ranges++; - } - return NULL; -} - /********************* FREE LIST UTILITIES ************************/ static INLINE grain_t grain_for_msize(szone_t *szone, msize_t msize) { @@ -319,7 +253,7 @@ static INLINE msize_t msize_for_grain(szone_t *szone, grain_t grain) { static INLINE void free_list_checksum(szone_t *szone, free_list_t *ptr) { // We always checksum, as testing whether to do it (based on szone->debug_flags) is as fast as doing it if (ptr->checksum != (((unsigned)ptr->previous) ^ ((unsigned)ptr->next) ^ CHECKSUM_MAGIC)) { - szone_error(szone, "Incorrect check sum for freed object - object was probably modified after beeing freed; break at szone_error", ptr); + szone_error(szone, "Incorrect checksum for freed object - object was probably modified after being freed; break at szone_error", ptr); } } @@ -821,16 +755,6 @@ static INLINE void *small_malloc_cleared_no_lock(szone_t *szone, msize_t msize) #if DEBUG_MALLOC -static void large_cache_debug_print(szone_t *szone) { - unsigned index = LARGE_CACHE_SIZE; - malloc_printf("Cache to be dealloced: "); - while (index--) { - vm_range_t range = szone->large_to_deallocate[index]; - if (range.size) malloc_printf("0x%x(%dKB) ", range.address, range.size/1024); - } - malloc_printf("\n"); -} - static void large_debug_print(szone_t *szone) { unsigned num_large_entries = szone->num_large_entries; unsigned index = num_large_entries; @@ -934,7 +858,7 @@ static void large_entries_grow_no_lock(szone_t *szone) { static vm_range_t large_free_no_lock(szone_t *szone, large_entry_t *entry) { // frees the specific entry in the size table - // returns a range to truly deallocate, taking into account + // returns a range to truly deallocate vm_range_t range; range.address = LARGE_ENTRY_ADDRESS(*entry); range.size = LARGE_ENTRY_SIZE(*entry); @@ -951,7 +875,6 @@ static vm_range_t large_free_no_lock(szone_t *szone, large_entry_t *entry) { #if DEBUG_MALLOC if (large_entry_for_pointer_no_lock(szone, (void *)range.address)) { malloc_printf("*** malloc[%d]: Freed entry 0x%x still in use; num_large_entries=%d\n", getpid(), range.address, szone->num_large_entries); - large_cache_debug_print(szone); large_debug_print(szone); sleep(3600); } @@ -959,30 +882,6 @@ static vm_range_t large_free_no_lock(szone_t *szone, large_entry_t *entry) { return range; } -static vm_range_t large_find_better_range_to_deallocate(szone_t *szone, vm_range_t range) { - // enters the specified large entry into the cache of freed entries - // returns a range to truly deallocate - vm_range_t *range_to_use; - vm_range_t vm_range_to_deallocate; - - // if the specified range in larger than MAX_LARGE_SIZE_TO_CACHE the range is not cached - if (range.size > MAX_LARGE_SIZE_TO_CACHE) return range; - - range = coalesce_range(szone->large_to_deallocate, LARGE_CACHE_SIZE, range); - range_to_use = first_zero_range(szone->large_to_deallocate, LARGE_CACHE_SIZE); - if (range_to_use) { - // we fill an empty slot - *range_to_use = range; - return zero_range; - } - // we always try to deallocate the largest chunk - range_to_use = largest_range(szone->large_to_deallocate, LARGE_CACHE_SIZE); - if (!range_to_use) return range; - vm_range_to_deallocate = *range_to_use; - *range_to_use = range; - return vm_range_to_deallocate; -} - static kern_return_t large_in_use_enumerator(task_t task, void *context, unsigned type_mask, vm_address_t large_entries_address, unsigned num_entries, memory_reader_t reader, vm_range_recorder_t recorder) { unsigned index = 0; vm_range_t buffer[MAX_RECORDER_BUFFER]; @@ -1026,7 +925,7 @@ static huge_entry_t *huge_entry_for_pointer_no_lock(szone_t *szone, const void * return NULL; } -static void huge_entry_append(szone_t *szone, huge_entry_t huge) { +static boolean_t huge_entry_append(szone_t *szone, huge_entry_t huge) { // We do a little dance with locking because doing allocation (even in the default szone) may cause something to get freed in this szone, with a deadlock huge_entry_t *new_huge_entries = NULL; SZONE_LOCK(szone); @@ -1037,6 +936,8 @@ static void huge_entry_append(szone_t *szone, huge_entry_t huge) { // malloc_printf("In huge_entry_append currentEntries=%d\n", num_huge_entries); if (new_huge_entries) szone_free(szone, new_huge_entries); new_huge_entries = szone_malloc(szone, (num_huge_entries + 1) * sizeof(huge_entry_t)); + if (new_huge_entries == NULL) + return 1; SZONE_LOCK(szone); if (num_huge_entries == szone->num_huge_entries) { // No change - our malloc still applies @@ -1047,7 +948,7 @@ static void huge_entry_append(szone_t *szone, huge_entry_t huge) { SZONE_UNLOCK(szone); szone_free(szone, old_huge_entries); // malloc_printf("Done huge_entry_append now=%d\n", szone->num_huge_entries); - return; + return 0; } // try again! } @@ -1062,9 +963,8 @@ static kern_return_t huge_in_use_enumerator(task_t task, void *context, unsigned return 0; } -static void *large_and_huge_malloc(szone_t *szone, unsigned num_pages, boolean_t cleared_requested) { +static void *large_and_huge_malloc(szone_t *szone, unsigned num_pages) { vm_address_t addr = 0; - boolean_t cleared_needed = 0; // by default blocks will be freshly allocated and therefore no need to clean them if (!num_pages) num_pages = 1; // minimal allocation size for this szone // malloc_printf("In large_and_huge_malloc for %dKB\n", num_pages * vm_page_size / 1024); if (num_pages >= (1 << vm_page_shift)) { @@ -1073,55 +973,27 @@ static void *large_and_huge_malloc(szone_t *szone, unsigned num_pages, boolean_t addr = allocate_pages(szone, huge.size, szone->debug_flags, VM_MAKE_TAG(VM_MEMORY_MALLOC_HUGE)); if (!addr) return NULL; huge.address = addr; - huge_entry_append(szone, huge); + if (huge_entry_append(szone, huge)) + return NULL; SZONE_LOCK(szone); szone->num_bytes_in_huge_objects += huge.size; } else { vm_size_t size = num_pages << vm_page_shift; large_entry_t entry; - boolean_t add_guard_pages = szone->debug_flags & SCALABLE_MALLOC_ADD_GUARD_PAGES; - vm_size_t guard_pages = (add_guard_pages) ? 2 * vm_page_size : 0; - vm_range_t *range_to_use; - cleared_needed = cleared_requested; // in the "large" case set by default - SZONE_LOCK(szone); - // First check in the list large_to_deallocate if we can reuse - // malloc_printf("In szone_malloc checking recently deallocated\n"); - range_to_use = first_range_greater_or_equal(szone->large_to_deallocate, LARGE_CACHE_SIZE, size + guard_pages); - if (range_to_use) { - // that one will do! - addr = range_to_use->address + ((add_guard_pages) ? vm_page_size : 0); - if (add_guard_pages) protect(szone, addr, size, 0, szone->debug_flags); - // malloc_printf("In szone_malloc found recently deallocated at 0x%x for %d pages\n", addr, num_pages); - if (range_to_use->size == size + guard_pages) { - *range_to_use = zero_range; - } else { - range_to_use->address += size + guard_pages; - range_to_use->size -= size + guard_pages; - } -#if DEBUG_MALLOC - if (large_entry_for_pointer_no_lock(szone, (void *)addr)) { - malloc_printf("Entry about to be reused already in use: 0x%x\n", addr); - large_debug_print(szone); - sleep(3600); - } -#endif + addr = allocate_pages(szone, size, szone->debug_flags, VM_MAKE_TAG(VM_MEMORY_MALLOC_LARGE)); + if (LOG(szone, addr)) malloc_printf("In szone_malloc true large allocation at %p for %dKB\n", (void *)addr, size / 1024); + SZONE_LOCK(szone); + if (!addr) { + SZONE_UNLOCK(szone); + return NULL; } - if (!addr) { - // we need to really allocate_pages a new region - SZONE_UNLOCK(szone); - addr = allocate_pages(szone, size, szone->debug_flags, VM_MAKE_TAG(VM_MEMORY_MALLOC_LARGE)); - cleared_needed = 0; // since we allocated the pages, no need to clean them - if (LOG(szone, addr)) malloc_printf("In szone_malloc true large allocation at %p for %dKB\n", (void *)addr, size / 1024); - SZONE_LOCK(szone); - if (!addr) return NULL; #if DEBUG_MALLOC - if (large_entry_for_pointer_no_lock(szone, (void *)addr)) { - malloc_printf("Freshly allocated is already in use: 0x%x\n", addr); - large_debug_print(szone); - sleep(3600); - } + if (large_entry_for_pointer_no_lock(szone, (void *)addr)) { + malloc_printf("Freshly allocated is already in use: 0x%x\n", addr); + large_debug_print(szone); + sleep(3600); + } #endif - } if ((szone->num_large_objects_in_use + 1) * 4 > szone->num_large_entries) { // density of hash table too high; grow table // we do that under lock to avoid a race @@ -1150,7 +1022,6 @@ static void *large_and_huge_malloc(szone_t *szone, unsigned num_pages, boolean_t szone->num_bytes_in_large_objects += size; } SZONE_UNLOCK(szone); - if (cleared_needed) memset((void *)addr, 0, num_pages << vm_page_shift); return (void *)addr; } @@ -1197,11 +1068,9 @@ static void szone_free(szone_t *szone, void *ptr) { vm_msync(mach_task_self(), LARGE_ENTRY_ADDRESS(*entry), LARGE_ENTRY_SIZE(*entry), VM_SYNC_KILLPAGES); } vm_range_to_deallocate = large_free_no_lock(szone, entry); - vm_range_to_deallocate = large_find_better_range_to_deallocate(szone, vm_range_to_deallocate); #if DEBUG_MALLOC if (large_entry_for_pointer_no_lock(szone, ptr)) { malloc_printf("*** malloc[%d]: Just after freeing 0x%x still in use num_large_entries=%d\n", getpid(), ptr, szone->num_large_entries); - large_cache_debug_print(szone); large_debug_print(szone); sleep(3600); } @@ -1225,7 +1094,6 @@ static void szone_free(szone_t *szone, void *ptr) { #if DEBUG_MALLOC if (large_entry_for_pointer_no_lock(szone, (void *)vm_range_to_deallocate.address)) { malloc_printf("*** malloc[%d]: Invariant broken: 0x%x still in use num_large_entries=%d\n", getpid(), vm_range_to_deallocate.address, szone->num_large_entries); - large_cache_debug_print(szone); large_debug_print(szone); sleep(3600); } @@ -1256,7 +1124,7 @@ static INLINE void *szone_malloc_should_clear(szone_t *szone, size_t size, boole } else { unsigned num_pages; num_pages = round_page(size) >> vm_page_shift; - ptr = large_and_huge_malloc(szone, num_pages, cleared_requested); + ptr = large_and_huge_malloc(szone, num_pages); } if (LOG(szone, ptr)) malloc_printf("szone_malloc returned %p\n", ptr); return ptr; @@ -1274,7 +1142,7 @@ static void *szone_valloc(szone_t *szone, size_t size) { void *ptr; unsigned num_pages; num_pages = round_page(size) >> vm_page_shift; - ptr = large_and_huge_malloc(szone, num_pages, 1); + ptr = large_and_huge_malloc(szone, num_pages); if (LOG(szone, ptr)) malloc_printf("szone_valloc returned %p\n", ptr); return ptr; } @@ -1315,7 +1183,7 @@ static size_t szone_size(szone_t *szone, const void *ptr) { return size; } -static INLINE int szone_try_realloc_in_place(szone_t *szone, void *ptr, size_t old_size, size_t new_size) { +static INLINE int try_realloc_small_in_place(szone_t *szone, void *ptr, size_t old_size, size_t new_size) { // returns 1 on success void *next_block = (char *)ptr + old_size + PTR_HEADER_SIZE; msize_t next_msize_and_free; @@ -1339,7 +1207,7 @@ static INLINE int szone_try_realloc_in_place(szone_t *szone, void *ptr, size_t o szone_error(szone, "Internal invariant broken in realloc(next_block)", next_block); } if (next_msize_and_free & PREV_FREE) { - malloc_printf("szone_try_realloc_in_place: 0x%x=PREV_FREE|%d\n", next_msize_and_free, next_msize_and_free & ~PREV_FREE); + malloc_printf("try_realloc_small_in_place: 0x%x=PREV_FREE|%d\n", next_msize_and_free, next_msize_and_free & ~PREV_FREE); SZONE_UNLOCK(szone); return 0; } @@ -1383,9 +1251,37 @@ static INLINE int szone_try_realloc_in_place(szone_t *szone, void *ptr, size_t o return 1; } +static INLINE int try_realloc_large_in_place(szone_t *szone, void *ptr, size_t old_size, size_t new_size) { + vm_address_t addr = (vm_address_t)ptr + old_size; + large_entry_t *entry; + kern_return_t err; + if (((szone->debug_flags & SCALABLE_MALLOC_ADD_GUARD_PAGES) && PROTECT_SMALL)) return 0; // don't want to bother with the protected case +#if DEBUG_MALLOC + if (old_size != ((old_size >> vm_page_shift) << vm_page_shift)) malloc_printf("*** old_size is %d\n", old_size); +#endif + // malloc_printf("=== Trying (1) to extend %p from %d to %d\n", ptr, old_size, new_size); + SZONE_LOCK(szone); + entry = large_entry_for_pointer_no_lock(szone, (void *)addr); + SZONE_UNLOCK(szone); + if (entry) return 0; // large pointer already exist in table - extension is not going to work + new_size = round_page(new_size); + // malloc_printf("=== Trying (2) to extend %p from %d to %d\n", ptr, old_size, new_size); + err = vm_allocate(mach_task_self(), &addr, new_size - old_size, VM_MAKE_TAG(VM_MEMORY_MALLOC_LARGE)); // we ask for allocation specifically at addr + if (err) return 0; + // we can just extend the block + SZONE_LOCK(szone); + entry = large_entry_for_pointer_no_lock(szone, ptr); + if (!entry) szone_error(szone, "large entry reallocated is not properly in table", ptr); + // malloc_printf("=== Successfully reallocated at end of %p from %d to %d\n", ptr, old_size, new_size); + entry->address_and_num_pages = (vm_address_t)ptr | (new_size >> vm_page_shift); + szone->num_bytes_in_large_objects += new_size - old_size; + SZONE_UNLOCK(szone); // we release the lock asap + return 1; +} + static void *szone_realloc(szone_t *szone, void *ptr, size_t new_size) { size_t old_size = 0; - void *newPtr; + void *new_ptr; if (LOG(szone, ptr)) malloc_printf("In szone_realloc for %p, %d\n", ptr, (unsigned)new_size); if (!ptr) return szone_malloc(szone, new_size); old_size = szone_size(szone, ptr); @@ -1394,38 +1290,44 @@ static void *szone_realloc(szone_t *szone, void *ptr, size_t new_size) { return NULL; } if (old_size >= new_size) return ptr; - if (!((szone->debug_flags & SCALABLE_MALLOC_ADD_GUARD_PAGES) && PROTECT_SMALL) && (new_size < LARGE_THRESHOLD)) { + if (!((szone->debug_flags & SCALABLE_MALLOC_ADD_GUARD_PAGES) && PROTECT_SMALL) && ((new_size + PTR_HEADER_SIZE + QUANTUM - 1) < LARGE_THRESHOLD)) { // We now try to realloc in place - if (szone_try_realloc_in_place(szone, ptr, old_size, new_size)) return ptr; + if (try_realloc_small_in_place(szone, ptr, old_size, new_size)) return ptr; } - newPtr = szone_malloc(szone, new_size); - if ((old_size > VM_COPY_THRESHOLD) && (old_size < (1 << (vm_page_shift + vm_page_shift)))) { - // we know it's a large block, and not a huge block + if ((old_size > VM_COPY_THRESHOLD) && ((new_size + vm_page_size - 1) < (1 << (vm_page_shift + vm_page_shift)))) { + // we know it's a large block, and not a huge block (both for old and new) kern_return_t err = 0; - err = vm_copy(mach_task_self(), (vm_address_t)ptr, old_size, (vm_address_t)newPtr); + unsigned num_pages; + large_entry_t *entry; + vm_range_t range; + num_pages = round_page(new_size) >> vm_page_shift; + if (try_realloc_large_in_place(szone, ptr, old_size, new_size)) return ptr; + new_ptr = large_and_huge_malloc(szone, num_pages); + err = vm_copy(mach_task_self(), (vm_address_t)ptr, old_size, (vm_address_t)new_ptr); if (err) { szone_error(szone, "Can't vm_copy region", ptr); - } else { - large_entry_t *entry; - vm_range_t range; - SZONE_LOCK(szone); - entry = large_entry_for_pointer_no_lock(szone, ptr); - if (!entry) { - szone_error(szone, "Can't find entry for large copied block", ptr); - } - range = large_free_no_lock(szone, entry); - SZONE_UNLOCK(szone); // we release the lock asap - // we truly deallocate_pages, including guard pages - deallocate_pages(szone, range.address, range.size, 0); - if (LOG(szone, ptr)) malloc_printf("szone_realloc returned %p for %d\n", newPtr, (unsigned)new_size); - return newPtr; + } + // We do not want the kernel to alias the old and the new, so we deallocate the old pointer right away and tear down the ptr-to-size data structure + SZONE_LOCK(szone); + entry = large_entry_for_pointer_no_lock(szone, ptr); + if (!entry) { + szone_error(szone, "Can't find entry for large copied block", ptr); } + range = large_free_no_lock(szone, entry); + SZONE_UNLOCK(szone); // we release the lock asap + // we truly deallocate_pages, including guard pages + deallocate_pages(szone, range.address, range.size, 0); + if (LOG(szone, ptr)) malloc_printf("szone_realloc returned %p for %d\n", new_ptr, (unsigned)new_size); + return new_ptr; } else { - memcpy(newPtr, ptr, old_size); + new_ptr = szone_malloc(szone, new_size); + if (new_ptr == NULL) + return NULL; + memcpy(new_ptr, ptr, old_size); } szone_free(szone, ptr); - if (LOG(szone, ptr)) malloc_printf("szone_realloc returned %p for %d\n", newPtr, (unsigned)new_size); - return newPtr; + if (LOG(szone, ptr)) malloc_printf("szone_realloc returned %p for %d\n", new_ptr, (unsigned)new_size); + return new_ptr; } static void szone_destroy(szone_t *szone) { @@ -1441,11 +1343,6 @@ static void szone_destroy(szone_t *szone) { } } if (szone->num_large_entries * sizeof(large_entry_t) >= LARGE_THRESHOLD) large_entries_free_no_lock(szone, szone->large_entries, szone->num_large_entries); // we do not free in the small chunk case - index = LARGE_CACHE_SIZE; - while (index--) { - vm_range_t range = szone->large_to_deallocate[index]; - if (range.size) deallocate_pages(szone, range.address, range.size, 0); - } index = szone->num_huge_entries; while (index--) { huge_entry_t *huge = szone->huge_entries + index; @@ -1552,13 +1449,9 @@ static void szone_print_free_list(szone_t *szone) { static void szone_print(szone_t *szone, boolean_t verbose) { unsigned info[scalable_zone_info_count]; - unsigned index; - unsigned num = 0; - index = LARGE_CACHE_SIZE; - while (index--) if (szone->large_to_deallocate[index].size) num++; - index = 0; + unsigned index = 0; scalable_zone_info((void *)szone, info, scalable_zone_info_count); - malloc_printf("Scalable zone %p: inUse=%d(%dKB) small=%d(%dKB) large=%d(%dKB) to_be_deallocated=%d huge=%d(%dKB) guard_page=%d\n", szone, info[0], info[1] / 1024, info[2], info[3] / 1024, info[4], info[5] / 1024, num, info[6], info[7] / 1024, info[8]); + malloc_printf("Scalable zone %p: inUse=%d(%dKB) small=%d(%dKB) large=%d(%dKB) huge=%d(%dKB) guard_page=%d\n", szone, info[0], info[1] / 1024, info[2], info[3] / 1024, info[4], info[5] / 1024, info[6], info[7] / 1024, info[8]); malloc_printf("%d regions: \n", szone->num_regions); while (index < szone->num_regions) { region_t *region = szone->regions + index; @@ -1619,6 +1512,7 @@ malloc_zone_t *create_scalable_zone(size_t initial_size, unsigned debug_flags) { vm_address_t addr; size_t msize; size_t msize_used = 0; + // malloc_printf("=== create_scalable_zone(%d,%d);\n", initial_size, debug_flags); if (!vm_page_shift) { unsigned page; vm_page_shift = 12; // the minimal for page sizes @@ -1675,3 +1569,139 @@ void scalable_zone_info(malloc_zone_t *zone, unsigned *info_to_fill, unsigned co memcpy(info_to_fill, info, sizeof(unsigned)*count); } +/********* Support code for emacs unexec ************/ + +/* History of freezedry version numbers: + * + * 1) Old malloc (before the scalable malloc implementation in this file + * existed). + * 2) Original freezedrying code for scalable malloc. This code was apparently + * based on the old freezedrying code and was fundamentally flawed in its + * assumption that tracking allocated memory regions was adequate to fake + * operations on freezedried memory. This doesn't work, since scalable + * malloc does not store flags in front of large page-aligned allocations. + * 3) Original szone-based freezedrying code. + * + * No version backward compatibility is provided, but the version number does + * make it possible for malloc_jumpstart() to return an error if the application + * was freezedried with an older version of malloc. + */ +#define MALLOC_FREEZEDRY_VERSION 3 + +typedef struct { + unsigned version; + unsigned nszones; + szone_t *szones; +} malloc_frozen; + +static void *frozen_malloc(szone_t *zone, size_t new_size) { + return malloc(new_size); +} + +static void *frozen_calloc(szone_t *zone, size_t num_items, size_t size) { + return calloc(num_items, size); +} + +static void *frozen_valloc(szone_t *zone, size_t new_size) { + return valloc(new_size); +} + +static void *frozen_realloc(szone_t *zone, void *ptr, size_t new_size) { + size_t old_size = szone_size(zone, ptr); + void *new_ptr; + + if (new_size <= old_size) { + return ptr; + } + + new_ptr = malloc(new_size); + + if (old_size > 0) { + memcpy(new_ptr, ptr, old_size); + } + + return new_ptr; +} + +static void frozen_free(szone_t *zone, void *ptr) { +} + +static void frozen_destroy(szone_t *zone) { +} + +/********* Pseudo-private API for emacs unexec ************/ + +/* + * malloc_freezedry() records all of the szones in use, so that they can be + * partially reconstituted by malloc_jumpstart(). Due to the differences + * between reconstituted memory regions and those created by the szone code, + * care is taken not to reallocate from the freezedried memory, except in the + * case of a non-growing realloc(). + * + * Due to the flexibility provided by the zone registration mechanism, it is + * impossible to implement generic freezedrying for any zone type. This code + * only handles applications that use the szone allocator, so malloc_freezedry() + * returns 0 (error) if any non-szone zones are encountered. + */ + +int malloc_freezedry(void) { + extern unsigned malloc_num_zones; + extern malloc_zone_t **malloc_zones; + malloc_frozen *data; + unsigned i; + + /* Allocate space in which to store the freezedry state. */ + data = (malloc_frozen *) malloc(sizeof(malloc_frozen)); + + /* Set freezedry version number so that malloc_jumpstart() can check for + * compatibility. */ + data->version = MALLOC_FREEZEDRY_VERSION; + + /* Allocate the array of szone pointers. */ + data->nszones = malloc_num_zones; + data->szones = (szone_t *) calloc(malloc_num_zones, sizeof(szone_t)); + + /* Fill in the array of szone structures. They are copied rather than + * referenced, since the originals are likely to be clobbered during malloc + * initialization. */ + for (i = 0; i < malloc_num_zones; i++) { + if (strcmp(malloc_zones[i]->zone_name, "DefaultMallocZone")) { + /* Unknown zone type. */ + free(data->szones); + free(data); + return 0; + } + memcpy(&data->szones[i], malloc_zones[i], sizeof(szone_t)); + } + + return (int) data; +} + +int malloc_jumpstart(int cookie) { + malloc_frozen *data = (malloc_frozen *) cookie; + unsigned i; + + if (data->version != MALLOC_FREEZEDRY_VERSION) { + /* Unsupported freezedry version. */ + return 1; + } + + for (i = 0; i < data->nszones; i++) { + /* Set function pointers. Even the functions that stay the same must be + * set, since there are no guarantees that they will be mapped to the + * same addresses. */ + data->szones[i].basic_zone.size = (void *) szone_size; + data->szones[i].basic_zone.malloc = (void *) frozen_malloc; + data->szones[i].basic_zone.calloc = (void *) frozen_calloc; + data->szones[i].basic_zone.valloc = (void *) frozen_valloc; + data->szones[i].basic_zone.free = (void *) frozen_free; + data->szones[i].basic_zone.realloc = (void *) frozen_realloc; + data->szones[i].basic_zone.destroy = (void *) frozen_destroy; + data->szones[i].basic_zone.introspect = &szone_introspect; + + /* Register the freezedried zone. */ + malloc_zone_register(&data->szones[i].basic_zone); + } + + return 0; +} diff --git a/gen.subproj/scalable_malloc.h b/gen/scalable_malloc.h similarity index 100% rename from gen.subproj/scalable_malloc.h rename to gen/scalable_malloc.h diff --git a/gen/scandir.3 b/gen/scandir.3 new file mode 100644 index 0000000..f2a24e6 --- /dev/null +++ b/gen/scandir.3 @@ -0,0 +1,109 @@ +.\" Copyright (c) 1983, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)scandir.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/scandir.3,v 1.7 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt SCANDIR 3 +.Os +.Sh NAME +.Nm scandir , +.Nm alphasort +.Nd scan a directory +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In dirent.h +.Ft int +.Fn scandir "const char *dirname" "struct dirent ***namelist" "int \\*(lp*select\\*(rp\\*(lpstruct dirent *\\*(rp" "int \\*(lp*compar\\*(rp\\*(lpconst void *, const void *\\*(rp" +.Ft int +.Fn alphasort "const void *d1" "const void *d2" +.Sh DESCRIPTION +The +.Fn scandir +function +reads the directory +.Fa dirname +and builds an array of pointers to directory +entries using +.Xr malloc 3 . +It returns the number of entries in the array. +A pointer to the array of directory entries is stored in the location +referenced by +.Fa namelist . +.Pp +The +.Fa select +parameter is a pointer to a user supplied subroutine which is called by +.Fn scandir +to select which entries are to be included in the array. +The select routine is passed a +pointer to a directory entry and should return a non-zero +value if the directory entry is to be included in the array. +If +.Fa select +is null, then all the directory entries will be included. +.Pp +The +.Fa compar +parameter is a pointer to a user supplied subroutine which is passed to +.Xr qsort 3 +to sort the completed array. +If this pointer is null, the array is not sorted. +.Pp +The +.Fn alphasort +function +is a routine which can be used for the +.Fa compar +parameter to sort the array alphabetically. +.Pp +The memory allocated for the array can be deallocated with +.Xr free 3 , +by freeing each pointer in the array and then the array itself. +.Sh DIAGNOSTICS +Returns \-1 if the directory cannot be opened for reading or if +.Xr malloc 3 +cannot allocate enough memory to hold all the data structures. +.Sh SEE ALSO +.Xr directory 3 , +.Xr malloc 3 , +.Xr qsort 3 , +.Xr dir 5 +.Sh HISTORY +The +.Fn scandir +and +.Fn alphasort +functions appeared in +.Bx 4.2 . diff --git a/gen.subproj/scandir.c b/gen/scandir.c similarity index 100% rename from gen.subproj/scandir.c rename to gen/scandir.c diff --git a/gen/seed48.c b/gen/seed48.c new file mode 100644 index 0000000..258c4ba --- /dev/null +++ b/gen/seed48.c @@ -0,0 +1,36 @@ +/* + * Copyright (c) 1993 Martin Birgmeier + * All rights reserved. + * + * You may redistribute unmodified or modified versions of this source + * code provided that the above copyright notice and this and the + * following conditions are retained. + * + * This software is provided ``as is'', and comes with no warranties + * of any kind. I shall in no event be liable for anything that happens + * to anyone/anything when using this software. + */ + +#include "rand48.h" + +extern unsigned short _rand48_seed[3]; +extern unsigned short _rand48_mult[3]; +extern unsigned short _rand48_add; + +unsigned short * +seed48(unsigned short xseed[3]) +{ + static unsigned short sseed[3]; + + sseed[0] = _rand48_seed[0]; + sseed[1] = _rand48_seed[1]; + sseed[2] = _rand48_seed[2]; + _rand48_seed[0] = xseed[0]; + _rand48_seed[1] = xseed[1]; + _rand48_seed[2] = xseed[2]; + _rand48_mult[0] = RAND48_MULT_0; + _rand48_mult[1] = RAND48_MULT_1; + _rand48_mult[2] = RAND48_MULT_2; + _rand48_add = RAND48_ADD; + return sseed; +} diff --git a/gen.subproj/seekdir.c b/gen/seekdir.c similarity index 100% rename from gen.subproj/seekdir.c rename to gen/seekdir.c diff --git a/gen.subproj/sethostname.c b/gen/sethostname.c similarity index 100% rename from gen.subproj/sethostname.c rename to gen/sethostname.c diff --git a/gen/setjmp.3 b/gen/setjmp.3 new file mode 100644 index 0000000..7707734 --- /dev/null +++ b/gen/setjmp.3 @@ -0,0 +1,176 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)setjmp.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/setjmp.3,v 1.9 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt SETJMP 3 +.Os +.Sh NAME +.Nm sigsetjmp , +.Nm siglongjmp , +.Nm setjmp , +.Nm longjmp , +.Nm _setjmp , +.Nm _longjmp , +.Nm longjmperror +.Nd non-local jumps +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In setjmp.h +.Ft int +.Fn sigsetjmp "sigjmp_buf env" "int savemask" +.Ft void +.Fn siglongjmp "sigjmp_buf env" "int val" +.Ft int +.Fn setjmp "jmp_buf env" +.Ft void +.Fn longjmp "jmp_buf env" "int val" +.Ft int +.Fn _setjmp "jmp_buf env" +.Ft void +.Fn _longjmp "jmp_buf env" "int val" +.Ft void +.Fn longjmperror void +.Sh DESCRIPTION +The +.Fn sigsetjmp , +.Fn setjmp , +and +.Fn _setjmp +functions save their calling environment in +.Fa env . +Each of these functions returns 0. +.Pp +The corresponding +.Fn longjmp +functions restore the environment saved by their most recent respective +invocations +of the +.Fn setjmp +function. +They then return so that program execution continues as if the corresponding +invocation of the +.Fn setjmp +call had just returned the value specified by +.Fa val , +instead of 0. +.Pp +Pairs of calls may be intermixed, i.e. both +.Fn sigsetjmp +and +.Fn siglongjmp +and +.Fn setjmp +and +.Fn longjmp +combinations may be used in the same program, however, individual +calls may not, e.g. the +.Fa env +argument to +.Fn setjmp +may not be passed to +.Fn siglongjmp . +.Pp +The +.Fn longjmp +routines may not be called after the routine which called the +.Fn setjmp +routines returns. +.Pp +All accessible objects have values as of the time +.Fn longjmp +routine was called, except that the values of objects of automatic storage +invocation duration that do not have the +.Em volatile +type and have been changed between the +.Fn setjmp +invocation and +.Fn longjmp +call are indeterminate. +.Pp +The +.Fn setjmp Ns / Ns Fn longjmp +pairs save and restore the signal mask while +.Fn _setjmp Ns / Ns Fn _longjmp +pairs save and restore only the register set and the stack. +(See +.Fn sigprocmask 2 . ) +.Pp +The +.Fn sigsetjmp Ns / Ns Fn siglongjmp +function +pairs save and restore the signal mask if the argument +.Fa savemask +is non-zero, otherwise only the register set and the stack are saved. +.Sh ERRORS +If the contents of the +.Fa env +are corrupted, or correspond to an environment that has already returned, +the +.Fn longjmp +routine calls the routine +.Fn longjmperror 3 . +If +.Fn longjmperror +returns the program is aborted (see +.Xr abort 3 ) . +The default version of +.Fn longjmperror +prints the message +.Dq Li longjmp botch +to standard error and returns. +User programs wishing to exit more gracefully should write their own +versions of +.Fn longjmperror . +.Sh SEE ALSO +.Xr sigaction 2 , +.Xr sigaltstack 2 , +.Xr signal 3 +.Sh STANDARDS +The +.Fn setjmp +and +.Fn longjmp +functions conform to +.St -isoC . +The +.Fn sigsetjmp +and +.Fn siglongjmp +functions conform to +.St -p1003.1-88 . diff --git a/gen.subproj/setlogin.c b/gen/setlogin.c similarity index 100% rename from gen.subproj/setlogin.c rename to gen/setlogin.c diff --git a/gen/setmode.3 b/gen/setmode.3 new file mode 100644 index 0000000..07909bd --- /dev/null +++ b/gen/setmode.3 @@ -0,0 +1,118 @@ +.\" Copyright (c) 1989, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)setmode.3 8.2 (Berkeley) 4/28/95 +.\" $FreeBSD: src/lib/libc/gen/setmode.3,v 1.8.2.3 2001/12/14 18:33:51 ru Exp $ +.\" +.Dd April 28, 1995 +.Dt SETMODE 3 +.Os +.Sh NAME +.Nm getmode , +.Nm setmode +.Nd modify mode bits +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft mode_t +.Fn getmode "const void *set" "mode_t mode" +.Ft void * +.Fn setmode "const char *mode_str" +.Sh DESCRIPTION +The +.Fn getmode +function +returns a copy of the file permission bits +.Fa mode +as altered by the values pointed to by +.Fa set . +While only the mode bits are altered, other parts of the file mode +may be examined. +.Pp +The +.Fn setmode +function +takes an absolute (octal) or symbolic value, as described in +.Xr chmod 1 , +as an argument +and returns a pointer to mode values to be supplied to +.Fn getmode . +Because some of the symbolic values are relative to the file +creation mask, +.Fn setmode +may call +.Xr umask 2 . +If this occurs, the file creation mask will be restored before +.Fn setmode +returns. +If the calling program changes the value of its file creation mask +after calling +.Fn setmode , +.Fn setmode +must be called again if +.Fn getmode +is to modify future file modes correctly. +.Pp +If the mode passed to +.Fn setmode +is invalid or if memory cannot be allocated for the return value, +.Fn setmode +returns +.Dv NULL . +.Pp +The value returned from +.Fn setmode +is obtained from +.Fn malloc +and should be returned to the system with +.Fn free +when the program is done with it, generally after a call to +.Fn getmode . +.Sh ERRORS +The +.Fn setmode +function +may fail and set errno for any of the errors specified for the library +routine +.Xr malloc 3 . +.Sh SEE ALSO +.Xr chmod 1 , +.Xr stat 2 , +.Xr umask 2 , +.Xr malloc 3 +.Sh HISTORY +The +.Fn getmode +and +.Fn setmode +functions first appeared in +.Bx 4.4 . diff --git a/gen.subproj/setmode.c b/gen/setmode.c similarity index 90% rename from gen.subproj/setmode.c rename to gen/setmode.c index dc2cc3a..181af06 100644 --- a/gen.subproj/setmode.c +++ b/gen/setmode.c @@ -1,24 +1,3 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ /* * Copyright (c) 1989, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -55,12 +34,18 @@ * SUCH DAMAGE. */ +#if defined(LIBC_SCCS) && !defined(lint) +#if 0 +static char sccsid[] = "@(#)setmode.c 8.2 (Berkeley) 3/25/94"; +#endif +static const char rcsid[] = + "$FreeBSD: src/lib/libc/gen/setmode.c,v 1.5.2.1 2001/03/05 09:34:10 obrien Exp $"; +#endif /* LIBC_SCCS and not lint */ #include #include #include -#include #include #include #include @@ -85,7 +70,7 @@ typedef struct bitcmd { #define CMD2_UBITS 0x10 static BITCMD *addcmd __P((BITCMD *, int, int, int, u_int)); -static int compress_mode __P((BITCMD *)); +static void compress_mode __P((BITCMD *)); #ifdef SETMODE_DEBUG static void dumpmode __P((BITCMD *)); #endif @@ -190,7 +175,7 @@ setmode(p) BITCMD *set, *saveset, *endset; sigset_t sigset, sigoset; mode_t mask; - int equalopdone, permXbits, setlen; + int equalopdone=0, permXbits, setlen; if (!*p) return (NULL); @@ -208,7 +193,7 @@ setmode(p) (void)sigprocmask(SIG_SETMASK, &sigoset, NULL); setlen = SET_LEN + 2; - + if ((set = malloc((u_int)(sizeof(BITCMD) * setlen))) == NULL) return (NULL); saveset = set; @@ -218,7 +203,7 @@ setmode(p) * If an absolute number, get it and return; disallow non-octal digits * or illegal bits. */ - if (isdigit(*p)) { + if (isdigit((unsigned char)*p)) { perm = (mode_t)strtol(p, NULL, 8); if (perm & ~(STANDARD_BITS|S_ISTXT)) { free(saveset); @@ -273,12 +258,12 @@ getop: if ((op = *p++) != '+' && op != '-' && op != '=') { break; case 's': /* If only "other" bits ignore set-id. */ - if (who & ~S_IRWXO) + if (!who || who & ~S_IRWXO) perm |= S_ISUID|S_ISGID; break; case 't': /* If only "other" bits ignore sticky. */ - if (who & ~S_IRWXO) { + if (!who || who & ~S_IRWXO) { who |= S_ISTXT; perm |= S_ISTXT; } @@ -386,7 +371,7 @@ addcmd(set, op, who, oparg, mask) set->cmd2 = CMD2_UBITS | CMD2_GBITS | CMD2_OBITS; set->bits = mask; } - + if (oparg == '+') set->cmd2 |= CMD2_SET; else if (oparg == '-') @@ -417,10 +402,10 @@ dumpmode(set) /* * Given an array of bitcmd structures, compress by compacting consecutive * '+', '-' and 'X' commands into at most 3 commands, one of each. The 'u', - * 'g' and 'o' commands continue to be separate. They could probably be + * 'g' and 'o' commands continue to be separate. They could probably be * compacted, but it's not worth the effort. */ -static int +static void compress_mode(set) register BITCMD *set; { diff --git a/gen/siginterrupt.3 b/gen/siginterrupt.3 new file mode 100644 index 0000000..d587425 --- /dev/null +++ b/gen/siginterrupt.3 @@ -0,0 +1,122 @@ +.\" Copyright (c) 1985, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)siginterrupt.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/siginterrupt.3,v 1.13 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt SIGINTERRUPT 3 +.Os +.Sh NAME +.Nm siginterrupt +.Nd allow signals to interrupt system calls +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In signal.h +.Ft int +.Fn siginterrupt "int sig" "int flag" +.Sh DESCRIPTION +The +.Fn siginterrupt +function +is used to change the system call restart +behavior when a system call is interrupted by the specified signal. +If the flag is false (0), then system calls will be restarted if +they are interrupted by the specified signal +and no data has been transferred yet. +System call restart has been the default behavior since +.Bx 4.2 , +and is the default behaviour for +.Xr signal 3 +on +.Fx . +.Pp +If the flag is true (1), +then restarting of system calls is disabled. +If a system call is interrupted by the specified signal +and no data has been transferred, +the system call will return \-1 with the global variable +.Va errno +set to +.Er EINTR . +Interrupted system calls that have started transferring +data will return the amount of data actually transferred. +System call interrupt is the signal behavior found on +.Bx 4.1 +and +.At V +systems. +.Pp +Note that the new +.Bx 4.2 +signal handling semantics are not +altered in any other way. +Most notably, signal handlers always remain installed until +explicitly changed by a subsequent +.Xr sigaction 2 +call, and the signal mask operates as documented in +.Xr sigaction 2 . +Programs may switch between restartable and interruptible +system call operation as often as desired in the execution of a program. +.Pp +Issuing a +.Fn siginterrupt 3 +call during the execution of a signal handler will cause +the new action to take place on the next signal to be caught. +.Sh NOTES +This library routine uses an extension of the +.Xr sigaction 2 +system call that is not available in +.Bx 4.2 , +hence it should not be used if backward compatibility is needed. +.Sh RETURN VALUES +.Rv -std siginterrupt +.Sh ERRORS +The +.Fn siginterrupt +call fails if: +.Bl -tag -width Er +.It Bq Er EINVAL +.Fa sig +is not a valid signal number. +.El +.Sh SEE ALSO +.Xr sigaction 2 , +.Xr sigblock 2 , +.Xr sigpause 2 , +.Xr sigsetmask 2 , +.Xr signal 3 +.Sh HISTORY +The +.Fn siginterrupt +function appeared in +.Bx 4.3 . diff --git a/gen.subproj/siginterrupt.c b/gen/siginterrupt.c similarity index 100% rename from gen.subproj/siginterrupt.c rename to gen/siginterrupt.c diff --git a/gen.subproj/siglist.c b/gen/siglist.c similarity index 100% rename from gen.subproj/siglist.c rename to gen/siglist.c diff --git a/gen/signal.3 b/gen/signal.3 new file mode 100644 index 0000000..6073b7b --- /dev/null +++ b/gen/signal.3 @@ -0,0 +1,243 @@ +.\" Copyright (c) 1980, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)signal.3 8.3 (Berkeley) 4/19/94 +.\" $FreeBSD: src/lib/libc/gen/signal.3,v 1.28 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd April 19, 1994 +.Dt SIGNAL 3 +.Os +.Sh NAME +.Nm signal +.Nd simplified software signal facilities +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In signal.h +.\" The following is Quite Ugly, but syntactically correct. Don't try to +.\" fix it. +.Ft void \*(lp* +.Fn signal "int sig" "void \*(lp*func\*(rp\*(lpint\*(rp\*(rp\*(rp\*(lpint" +.Pp +or in +.Fx Ns 's +equivalent but easier to read typedef'd version: +.Ft typedef "void \*(lp*sig_t\*(rp \*(lpint\*(rp" +.Ft sig_t +.Fn signal "int sig" "sig_t func" +.Sh DESCRIPTION +This +.Fn signal +facility +is a simplified interface to the more general +.Xr sigaction 2 +facility. +.Pp +Signals allow the manipulation of a process from outside its +domain as well as allowing the process to manipulate itself or +copies of itself (children). There are two general types of signals: +those that cause termination of a process and those that do not. +Signals which cause termination of a program might result from +an irrecoverable error or might be the result of a user at a terminal +typing the `interrupt' character. +Signals are used when a process is stopped because it wishes to access +its control terminal while in the background (see +.Xr tty 4 ) . +Signals are optionally generated +when a process resumes after being stopped, +when the status of child processes changes, +or when input is ready at the control terminal. +Most signals result in the termination of the process receiving them +if no action +is taken; some signals instead cause the process receiving them +to be stopped, or are simply discarded if the process has not +requested otherwise. +Except for the +.Dv SIGKILL +and +.Dv SIGSTOP +signals, the +.Fn signal +function allows for a signal to be caught, to be ignored, or to generate +an interrupt. +These signals are defined in the file +.Aq Pa signal.h : +.Bl -column SIGVTALARMXX "create core imagexxx" +.It Sy "Name Default Action Description" +.It Dv SIGHUP Ta "terminate process" Ta "terminal line hangup" +.It Dv SIGINT Ta "terminate process" Ta "interrupt program" +.It Dv SIGQUIT Ta "create core image" Ta "quit program" +.It Dv SIGILL Ta "create core image" Ta "illegal instruction" +.It Dv SIGTRAP Ta "create core image" Ta "trace trap" +.It Dv SIGABRT Ta "create core image" Ta "abort program" +(formerly +.Dv SIGIOT ) +.It Dv SIGEMT Ta "create core image" Ta "emulate instruction executed" +.It Dv SIGFPE Ta "create core image" Ta "floating-point exception" +.It Dv SIGKILL Ta "terminate process" Ta "kill program" +.It Dv SIGBUS Ta "create core image" Ta "bus error" +.It Dv SIGSEGV Ta "create core image" Ta "segmentation violation" +.It Dv SIGSYS Ta "create core image" Ta "non-existent system call invoked" +.It Dv SIGPIPE Ta "terminate process" Ta "write on a pipe with no reader" +.It Dv SIGALRM Ta "terminate process" Ta "real-time timer expired" +.It Dv SIGTERM Ta "terminate process" Ta "software termination signal" +.It Dv SIGURG Ta "discard signal" Ta "urgent condition present on socket" +.It Dv SIGSTOP Ta "stop process" Ta "stop (cannot be caught or ignored)" +.It Dv SIGTSTP Ta "stop process" Ta "stop signal generated from keyboard" +.It Dv SIGCONT Ta "discard signal" Ta "continue after stop" +.It Dv SIGCHLD Ta "discard signal" Ta "child status has changed" +.It Dv SIGTTIN Ta "stop process" Ta "background read attempted from control terminal" +.It Dv SIGTTOU Ta "stop process" Ta "background write attempted to control terminal" +.It Dv SIGIO Ta "discard signal" Ta Tn "I/O" +is possible on a descriptor (see +.Xr fcntl 2 ) +.It Dv SIGXCPU Ta "terminate process" Ta "cpu time limit exceeded (see" +.Xr setrlimit 2 ) +.It Dv SIGXFSZ Ta "terminate process" Ta "file size limit exceeded (see" +.Xr setrlimit 2 ) +.It Dv SIGVTALRM Ta "terminate process" Ta "virtual time alarm (see" +.Xr setitimer 2 ) +.It Dv SIGPROF Ta "terminate process" Ta "profiling timer alarm (see" +.Xr setitimer 2 ) +.It Dv SIGWINCH Ta "discard signal" Ta "Window size change" +.It Dv SIGINFO Ta "discard signal" Ta "status request from keyboard" +.It Dv SIGUSR1 Ta "terminate process" Ta "User defined signal 1" +.It Dv SIGUSR2 Ta "terminate process" Ta "User defined signal 2" +.El +.Pp +The +.Fa sig +parameter specifies which signal was received. +The +.Fa func +procedure allows a user to choose the action upon receipt of a signal. +To set the default action of the signal to occur as listed above, +.Fa func +should be +.Dv SIG_DFL . +A +.Dv SIG_DFL +resets the default action. +To ignore the signal +.Fa func +should be +.Dv SIG_IGN . +This will cause subsequent instances of the signal to be ignored +and pending instances to be discarded. +If +.Dv SIG_IGN +is not used, +further occurrences of the signal are +automatically blocked and +.Fa func +is called. +.Pp +The handled signal is unblocked when the +function returns and +the process continues from where it left off when the signal occurred. +.Bf -symbolic +Unlike previous signal facilities, the handler +func() remains installed after a signal has been delivered. +.Ef +.Pp +For some system calls, if a signal is caught while the call is +executing and the call is prematurely terminated, +the call is automatically restarted. +(The handler is installed using the +.Dv SA_RESTART +flag with +.Xr sigaction 2 . ) +The affected system calls include +.Xr read 2 , +.Xr write 2 , +.Xr sendto 2 , +.Xr recvfrom 2 , +.Xr sendmsg 2 +and +.Xr recvmsg 2 +on a communications channel or a low speed device +and during a +.Xr ioctl 2 +or +.Xr wait 2 . +However, calls that have already committed are not restarted, +but instead return a partial success (for example, a short read count). +This semantics could be changed with +.Xr siginterrupt 3 . +.Pp +When a process which has installed signal handlers forks, +the child process inherits the signals. +All caught signals may be reset to their default action by a call +to the +.Xr execve 2 +function; +ignored signals remain ignored. +.Pp +See +.Xr sigaction 2 +for a list of functions +that are considered safe for use in signal handler. +.Sh RETURN VALUES +The previous action is returned on a successful call. +Otherwise, SIG_ERR is returned and the global variable +.Va errno +is set to indicate the error. +.Sh ERRORS +.Fn Signal +will fail and no action will take place if one of the +following occur: +.Bl -tag -width Er +.It Bq Er EINVAL +.Em Sig +is not a valid signal number. +.It Bq Er EINVAL +An attempt is made to ignore or supply a handler for +.Dv SIGKILL +or +.Ev SIGSTOP . +.El +.Sh SEE ALSO +.Xr kill 1 , +.Xr kill 2 , +.Xr ptrace 2 , +.Xr sigaction 2 , +.Xr sigaltstack 2 , +.Xr sigprocmask 2 , +.Xr sigsuspend 2 , +.Xr fpsetmask 3 , +.Xr setjmp 3 , +.Xr siginterrupt 3 , +.Xr tty 4 +.Sh HISTORY +This +.Fn signal +facility appeared in +.Bx 4.0 . diff --git a/gen.subproj/signal.c b/gen/signal.c similarity index 100% rename from gen.subproj/signal.c rename to gen/signal.c diff --git a/gen/sigsetops.3 b/gen/sigsetops.3 new file mode 100644 index 0000000..5c8f0dd --- /dev/null +++ b/gen/sigsetops.3 @@ -0,0 +1,116 @@ +.\" Copyright (c) 1983, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)sigsetops.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/sigsetops.3,v 1.6 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt SIGSETOPS 3 +.Os +.Sh NAME +.Nm sigemptyset , +.Nm sigfillset , +.Nm sigaddset , +.Nm sigdelset , +.Nm sigismember +.Nd manipulate signal sets +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In signal.h +.Ft int +.Fn sigemptyset "sigset_t *set" +.Ft int +.Fn sigfillset "sigset_t *set" +.Ft int +.Fn sigaddset "sigset_t *set" "int signo" +.Ft int +.Fn sigdelset "sigset_t *set" "int signo" +.Ft int +.Fn sigismember "const sigset_t *set" "int signo" +.Sh DESCRIPTION +These functions manipulate signal sets stored in a +.Fa sigset_t . +Either +.Fn sigemptyset +or +.Fn sigfillset +must be called for every object of type +.Fa sigset_t +before any other use of the object. +.Pp +The +.Fn sigemptyset +function initializes a signal set to be empty. +.Pp +The +.Fn sigfillset +function initializes a signal set to contain all signals. +.Pp +The +.Fn sigaddset +function adds the specified signal +.Fa signo +to the signal set. +.Pp +The +.Fn sigdelset +function deletes the specified signal +.Fa signo +from the signal set. +.Pp +The +.Fn sigismember +function returns whether a specified signal +.Fa signo +is contained in the signal set. +.Pp +These functions +are provided as macros in the include file . +Actual functions are available +if their names are undefined (with #undef +.Em name ) . +.Sh RETURN VALUES +The +.Fn sigismember +function returns 1 +if the signal is a member of the set, +0 otherwise. +The other functions return 0. +.Sh ERRORS +Currently no errors are detected. +.Sh SEE ALSO +.Xr kill 2 , +.Xr sigaction 2 , +.Xr sigsuspend 2 +.Sh STANDARDS +These functions are defined by +.St -p1003.1-88 . diff --git a/gen.subproj/sigsetops.c b/gen/sigsetops.c similarity index 93% rename from gen.subproj/sigsetops.c rename to gen/sigsetops.c index 9588381..eeca678 100644 --- a/gen.subproj/sigsetops.c +++ b/gen/sigsetops.c @@ -54,6 +54,7 @@ #include +#include #undef sigemptyset #undef sigfillset @@ -79,6 +80,10 @@ sigaddset(set, signo) sigset_t *set; int signo; { + if ((signo < 0 ) || (signo > NSIG)) { + errno = EINVAL; + return(-1); + } *set |= sigmask(signo); return (0); } @@ -87,6 +92,10 @@ sigdelset(set, signo) sigset_t *set; int signo; { + if ((signo < 0 ) || (signo > NSIG)) { + errno = EINVAL; + return(-1); + } *set &= ~sigmask(signo); return (0); } @@ -95,5 +104,9 @@ sigismember(set, signo) const sigset_t *set; int signo; { + if ((signo < 0 ) || (signo > NSIG)) { + errno = EINVAL; + return(-1); + } return ((*set & ~sigmask(signo)) != 0); } diff --git a/gen/sleep.3 b/gen/sleep.3 new file mode 100644 index 0000000..ba5985f --- /dev/null +++ b/gen/sleep.3 @@ -0,0 +1,86 @@ +.\" Copyright (c) 1986, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)sleep.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/sleep.3,v 1.15 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd February 13, 1998 +.Dt SLEEP 3 +.Os +.Sh NAME +.Nm sleep +.Nd suspend process execution for an interval measured in seconds +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft unsigned int +.Fn sleep "unsigned int seconds" +.Sh DESCRIPTION +The +.Fn sleep +function suspends execution of the calling process until either +.Fa seconds +seconds have elapsed or a signal is delivered to the process and its +action is to invoke a signal-catching function or to terminate the +process. +System activity may lengthen the sleep by an indeterminate amount. +.Pp +This function is implemented using +.Xr nanosleep 2 +by pausing for +.Fa seconds +seconds or until a signal occurs. +Consequently, in this implementation, +sleeping has no effect on the state of process timers, +and there is no special handling for SIGALRM. +.Sh RETURN VALUES +If the +.Fn sleep +function returns because the requested time has elapsed, the value +returned will be zero. If the +.Fn sleep +function returns due to the delivery of a signal, the value returned +will be the unslept amount (the requested time minus the time actually +slept) in seconds. +.Sh SEE ALSO +.Xr nanosleep 2 , +.Xr usleep 3 +.Sh STANDARDS +The +.Fn sleep +function conforms to +.St -p1003.1-90 . +.Sh HISTORY +A +.Fn sleep +function appeared in +.At v7 . diff --git a/gen.subproj/sleep.c b/gen/sleep.c similarity index 100% rename from gen.subproj/sleep.c rename to gen/sleep.c diff --git a/gen/srand48.c b/gen/srand48.c new file mode 100644 index 0000000..fd369a0 --- /dev/null +++ b/gen/srand48.c @@ -0,0 +1,30 @@ +/* + * Copyright (c) 1993 Martin Birgmeier + * All rights reserved. + * + * You may redistribute unmodified or modified versions of this source + * code provided that the above copyright notice and this and the + * following conditions are retained. + * + * This software is provided ``as is'', and comes with no warranties + * of any kind. I shall in no event be liable for anything that happens + * to anyone/anything when using this software. + */ + +#include "rand48.h" + +extern unsigned short _rand48_seed[3]; +extern unsigned short _rand48_mult[3]; +extern unsigned short _rand48_add; + +void +srand48(long seed) +{ + _rand48_seed[0] = RAND48_SEED_0; + _rand48_seed[1] = (unsigned short) seed; + _rand48_seed[2] = (unsigned short) (seed >> 16); + _rand48_mult[0] = RAND48_MULT_0; + _rand48_mult[1] = RAND48_MULT_1; + _rand48_mult[2] = RAND48_MULT_2; + _rand48_add = RAND48_ADD; +} diff --git a/gen.subproj/stack_logging.c b/gen/stack_logging.c similarity index 99% rename from gen.subproj/stack_logging.c rename to gen/stack_logging.c index a8e7a4d..8389420 100644 --- a/gen.subproj/stack_logging.c +++ b/gen/stack_logging.c @@ -69,7 +69,7 @@ static void *next_frame_address(void *addr) { #if defined(__MACH__) && defined(__i386__) __asm__ volatile("movl (%1),%0" : "=r" (ret) : "r" (addr)); #elif defined(__MACH__) && defined(__ppc__) - __asm__ volatile("lwz %0,0x0(%1)" : "=r" (ret) : "r" (addr)); + __asm__ volatile("lwz %0,0x0(%1)" : "=r" (ret) : "b" (addr)); #elif defined(__hpux__) __asm__ volatile("ldw 0x0(%1),%0" : "=r" (ret) : "r" (addr)); #elif defined(__svr4__) diff --git a/gen.subproj/stack_logging.h b/gen/stack_logging.h similarity index 100% rename from gen.subproj/stack_logging.h rename to gen/stack_logging.h diff --git a/gen/strchr.c b/gen/strchr.c new file mode 100644 index 0000000..c1469d1 --- /dev/null +++ b/gen/strchr.c @@ -0,0 +1,41 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* Copyright (c) 1992, 1995 NeXT Computer, Inc. All rights reserved. + * + * File: libc/gen/strchr.c + * + * This file contains machine independent code for string index + * + */ +#import + +/* This routine needs to be optimized. */ + +char *strchr(const char *s, int c) +{ + const char ch = c; + + for ( ; *s != ch; s++) + if (*s == '\0') + return 0; + return (char *)s; +} diff --git a/gen/stringlist.3 b/gen/stringlist.3 new file mode 100644 index 0000000..559d5da --- /dev/null +++ b/gen/stringlist.3 @@ -0,0 +1,124 @@ +.\" $NetBSD: stringlist.3,v 1.2 1997/04/09 08:59:25 kleink Exp $ +.\" +.\" Copyright (c) 1997 The NetBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This file was contributed to The NetBSD Foundation by Luke Mewburn. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the NetBSD +.\" Foundation, Inc. and its contributors. +.\" 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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. +.\" +.\" $FreeBSD: src/lib/libc/gen/stringlist.3,v 1.7 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd February 24, 1997 +.Os +.Dt STRINGLIST 3 +.Sh NAME +.Nm stringlist , +.Nm sl_init , +.Nm sl_add , +.Nm sl_free , +.Nm sl_find +.Nd stringlist manipulation functions +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stringlist.h +.Ft StringList * +.Fn sl_init +.Ft void +.Fn sl_add "StringList *sl" "char *item" +.Ft void +.Fn sl_free "StringList *sl" "int freeall" +.Ft char * +.Fn sl_find "StringList *sl" "char *item" +.Sh DESCRIPTION +The +.Nm +functions manipulate stringlists, which are lists of +strings that extend automatically if necessary. +.Pp +The +.Ar StringList +structure has the following definition: +.Bd -literal -offset indent +typedef struct _stringlist { + char **sl_str; + size_t sl_max; + size_t sl_cur; +} StringList; +.Ed +.Pp +.Bl -tag -width "sl_str" -offset indent +.It Ar sl_str +a pointer to the base of the array containing the list. +.It Ar sl_max +the size of +.Ar sl_str . +.It Ar sl_cur +the offset in +.Ar sl_str +of the current element. +.El +.Pp +The following stringlist manipulation functions are available: +.Bl -tag -width "sl_init()" +.It Fn sl_init +Create a stringlist. +Returns a pointer to a +.Ar StringList . +.It Fn sl_free +Releases memory occupied by +.Ar sl +and the +.Ar sl->sl_str +array. +If +.Ar freeall +is non-zero, then each of the items within +.Ar sl->sl_str +is released as well. +.It Fn sl_add +Add +.Ar item +to +.Ar sl->sl_str +at +.Ar sl->sl_cur , +extending the size of +.Ar sl->sl_str +.It Fn sl_find +Find +.Ar item +in +.Ar sl , +returning NULL if it's not found. +.El +.Sh SEE ALSO +.Xr free 3 , +.Xr malloc 3 diff --git a/gen/strtofflags.3 b/gen/strtofflags.3 new file mode 100644 index 0000000..355e81a --- /dev/null +++ b/gen/strtofflags.3 @@ -0,0 +1,99 @@ +.\" Copyright (c) 1989, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)setmode.3 8.2 (Berkeley) 4/28/95 +.\" $FreeBSD: src/lib/libc/gen/strtofflags.3,v 1.7 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd January 1, 2000 +.Dt STRTOFFLAGS 3 +.Os +.Sh NAME +.Nm fflagstostr , +.Nm strtofflags +.Nd convert between file flag bits and their string names +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft char * +.Fn fflagstostr "u_long flags" +.Ft int +.Fn strtofflags "char **stringp" "u_long *setp" "u_long *clrp" +.Sh DESCRIPTION +The +.Fn fflagstostr +function returns a comma separated string of the file flags represented by +.Fa flags . +If no flags are set a zero length string is returned. +.Pp +If memory cannot be allocated for the return value, +.Fn fflagstostr +returns +.Dv NULL . +.Pp +The value returned from +.Fn fflagstostr +is obtained from +.Fn malloc +and should be returned to the system with +.Fn free +when the program is done with it. +.Pp +The +.Fn strtofflags +function takes a string of file flags, as described in +.Xr chflags 1 , +parses it, and returns the 'set' flags and 'clear' flags +such as would be given as arguments to +.Xr chflags 2 . +On success +.Fn strtofflags +returns 0, otherwise it returns non-zero and +.Fa stringp +is left pointing to the offending token. +.Sh ERRORS +The +.Fn fflagstostr +function +may fail and set errno for any of the errors specified for the library +routine +.Xr malloc 3 . +.Sh SEE ALSO +.Xr chflags 1 , +.Xr chflags 2 , +.Xr malloc 3 +.Sh HISTORY +The +.Fn fflagstostr +and +.Fn strtofflags +functions first appeared in +.Fx 4.0 . diff --git a/gen/strtofflags.c b/gen/strtofflags.c new file mode 100644 index 0000000..ba27a29 --- /dev/null +++ b/gen/strtofflags.c @@ -0,0 +1,154 @@ +/*- + * Copyright (c) 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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 +#if 0 +static char sccsid[] = "@(#)stat_flags.c 8.1 (Berkeley) 5/31/93"; +#else +static const char rcsid[] = + "$FreeBSD: src/lib/libc/gen/strtofflags.c,v 1.18.2.1 2000/06/28 01:52:24 joe Exp $"; +#endif +#endif /* not lint */ + +#include +#include + +#include +#include +#include + +static struct { + char *name; + u_long flag; + int invert; +} mapping[] = { + /* shorter names per flag first, all prefixed by "no" */ + { "nosappnd", SF_APPEND, 0 }, + { "nosappend", SF_APPEND, 0 }, + { "noarch", SF_ARCHIVED, 0 }, + { "noarchived", SF_ARCHIVED, 0 }, + { "noschg", SF_IMMUTABLE, 0 }, + { "noschange", SF_IMMUTABLE, 0 }, + { "nosimmutable", SF_IMMUTABLE, 0 }, + { "nouappnd", UF_APPEND, 0 }, + { "nouappend", UF_APPEND, 0 }, + { "nouchg", UF_IMMUTABLE, 0 }, + { "nouchange", UF_IMMUTABLE, 0 }, + { "nouimmutable", UF_IMMUTABLE, 0 }, + { "nodump", UF_NODUMP, 1 }, + { "noopaque", UF_OPAQUE, 0 }, +}; +#define longestflaglen 12 +#define nmappings (sizeof(mapping) / sizeof(mapping[0])) + +/* + * fflagstostr -- + * Convert file flags to a comma-separated string. If no flags + * are set, return the empty string. + */ +char * +fflagstostr(flags) + u_long flags; +{ + char *string; + char *sp, *dp; + u_long setflags; + int i; + + if ((string = (char *)malloc(nmappings * (longestflaglen + 1))) == NULL) + return (NULL); + + setflags = flags; + dp = string; + for (i = 0; i < nmappings; i++) { + if (setflags & mapping[i].flag) { + if (dp > string) + *dp++ = ','; + for (sp = mapping[i].invert ? mapping[i].name : + mapping[i].name + 2; *sp; *dp++ = *sp++) ; + setflags &= ~mapping[i].flag; + } + } + *dp = '\0'; + return (string); +} + +/* + * strtofflags -- + * Take string of arguments and return file flags. Return 0 on + * success, 1 on failure. On failure, stringp is set to point + * to the offending token. + */ +int +strtofflags(stringp, setp, clrp) + char **stringp; + u_long *setp, *clrp; +{ + char *string, *p; + int i; + + if (setp) + *setp = 0; + if (clrp) + *clrp = 0; + string = *stringp; + while ((p = strsep(&string, "\t ,")) != NULL) { + *stringp = p; + if (*p == '\0') + continue; + for (i = 0; i < nmappings; i++) { + if (strcmp(p, mapping[i].name + 2) == 0) { + if (mapping[i].invert) { + if (clrp) + *clrp |= mapping[i].flag; + } else { + if (setp) + *setp |= mapping[i].flag; + } + break; + } else if (strcmp(p, mapping[i].name) == 0) { + if (mapping[i].invert) { + if (setp) + *setp |= mapping[i].flag; + } else { + if (clrp) + *clrp |= mapping[i].flag; + } + break; + } + } + if (i == nmappings) + return 1; + } + return 0; +} diff --git a/gen/sysconf.3 b/gen/sysconf.3 new file mode 100644 index 0000000..e3a47f1 --- /dev/null +++ b/gen/sysconf.3 @@ -0,0 +1,208 @@ +.\" Copyright (c) 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)sysconf.3 8.3 (Berkeley) 4/19/94 +.\" $FreeBSD: src/lib/libc/gen/sysconf.3,v 1.16 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd June 18, 2001 +.Dt SYSCONF 3 +.Os +.Sh NAME +.Nm sysconf +.Nd get configurable system variables +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft long +.Fn sysconf "int name" +.Sh DESCRIPTION +This interface is defined by +.St -p1003.1-88 . +A far more complete interface is available using +.Xr sysctl 3 . +.Pp +The +.Fn sysconf +function provides a method for applications to determine the current +value of a configurable system limit or option variable. +The +.Fa name +argument specifies the system variable to be queried. +Symbolic constants for each name value are found in the include file +.Aq Pa unistd.h . +Shell programmers who need access to these parameters should use the +.Xr getconf 1 +utility. +.Pp +The available values are as follows: +.Pp +.Bl -tag -width 6n +.Pp +.It Li _SC_ARG_MAX +The maximum bytes of argument to +.Xr execve 2 . +.It Li _SC_CHILD_MAX +The maximum number of simultaneous processes per user id. +.It Li _SC_CLK_TCK +The frequency of the statistics clock in ticks per second. +.It Li _SC_IOV_MAX +The maximum number of elements in the I/O vector used by +.Xr readv 2 , +.Xr writev 2 , +.Xr recvmsg 2 , +and +.Xr sendmsg 2 . +.It Li _SC_NGROUPS_MAX +The maximum number of supplemental groups. +.It Li _SC_OPEN_MAX +The maximum number of open files per user id. +.It Li _SC_STREAM_MAX +The minimum maximum number of streams that a process may have open +at any one time. +.It Li _SC_TZNAME_MAX +The minimum maximum number of types supported for the name of a +timezone. +.It Li _SC_JOB_CONTROL +Return 1 if job control is available on this system, otherwise \-1. +.It Li _SC_SAVED_IDS +Returns 1 if saved set-group and saved set-user ID is available, +otherwise \-1. +.It Li _SC_VERSION +The version of +.St -p1003.1 +with which the system +attempts to comply. +.It Li _SC_BC_BASE_MAX +The maximum ibase/obase values in the +.Xr bc 1 +utility. +.It Li _SC_BC_DIM_MAX +The maximum array size in the +.Xr bc 1 +utility. +.It Li _SC_BC_SCALE_MAX +The maximum scale value in the +.Xr bc 1 +utility. +.It Li _SC_BC_STRING_MAX +The maximum string length in the +.Xr bc 1 +utility. +.It Li _SC_COLL_WEIGHTS_MAX +The maximum number of weights that can be assigned to any entry of +the LC_COLLATE order keyword in the locale definition file. +.It Li _SC_EXPR_NEST_MAX +The maximum number of expressions that can be nested within +parenthesis by the +.Xr expr 1 +utility. +.It Li _SC_LINE_MAX +The maximum length in bytes of a text-processing utility's input +line. +.It Li _SC_RE_DUP_MAX +The maximum number of repeated occurrences of a regular expression +permitted when using interval notation. +.It Li _SC_2_VERSION +The version of +.St -p1003.2 +with which the system attempts to comply. +.It Li _SC_2_C_BIND +Return 1 if the system's C-language development facilities support the +C-Language Bindings Option, otherwise \-1. +.It Li _SC_2_C_DEV +Return 1 if the system supports the C-Language Development Utilities Option, +otherwise \-1. +.It Li _SC_2_CHAR_TERM +Return 1 if the system supports at least one terminal type capable of +all operations described in +.St -p1003.2 , +otherwise \-1. +.It Li _SC_2_FORT_DEV +Return 1 if the system supports the FORTRAN Development Utilities Option, +otherwise \-1. +.It Li _SC_2_FORT_RUN +Return 1 if the system supports the FORTRAN Runtime Utilities Option, +otherwise \-1. +.It Li _SC_2_LOCALEDEF +Return 1 if the system supports the creation of locales, otherwise \-1. +.It Li _SC_2_SW_DEV +Return 1 if the system supports the Software Development Utilities Option, +otherwise \-1. +.It Li _SC_2_UPE +Return 1 if the system supports the User Portability Utilities Option, +otherwise \-1. +.El +.Sh RETURN VALUES +If the call to +.Fn sysconf +is not successful, \-1 is returned and +.Va errno +is set appropriately. +Otherwise, if the variable is associated with functionality that is not +supported, \-1 is returned and +.Va errno +is not modified. +Otherwise, the current variable value is returned. +.Sh ERRORS +The +.Fn sysconf +function may fail and set +.Va errno +for any of the errors specified for the library function +.Xr sysctl 3 . +In addition, the following error may be reported: +.Bl -tag -width Er +.It Bq Er EINVAL +The value of the +.Fa name +argument is invalid. +.El +.Sh SEE ALSO +.Xr getconf 1 , +.Xr pathconf 2 , +.Xr confstr 3 , +.Xr sysctl 3 +.Sh BUGS +The value for _SC_STREAM_MAX is a minimum maximum, and required to be +the same as ANSI C's FOPEN_MAX, so the returned value is a ridiculously +small and misleading number. +.Sh STANDARDS +Except for the fact that values returned by +.Fn sysconf +may change over the lifetime of the calling process, +this function conforms to +.St -p1003.1-88 . +.Sh HISTORY +The +.Fn sysconf +function first appeared in +.Bx 4.4 . diff --git a/gen.subproj/sysconf.c b/gen/sysconf.c similarity index 100% rename from gen.subproj/sysconf.c rename to gen/sysconf.c diff --git a/gen/sysctl.3 b/gen/sysctl.3 new file mode 100644 index 0000000..9fa2a4a --- /dev/null +++ b/gen/sysctl.3 @@ -0,0 +1,827 @@ +.\" Copyright (c) 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95 +.\" $FreeBSD: src/lib/libc/gen/sysctl.3,v 1.51 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd January 23, 2001 +.Dt SYSCTL 3 +.Os +.Sh NAME +.Nm sysctl , +.Nm sysctlbyname , +.Nm sysctlnametomib +.Nd get or set system information +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In sys/sysctl.h +.Ft int +.Fn sysctl "int *name" "u_int namelen" "void *oldp" "size_t *oldlenp" "void *newp" "size_t newlen" +.Ft int +.Fn sysctlbyname "const char *name" "void *oldp" "size_t *oldlenp" "void *newp" "size_t newlen" +.Ft int +.Fn sysctlnametomib "const char *name" "int *mibp" "size_t *sizep" +.Sh DESCRIPTION +The +.Fn sysctl +function retrieves system information and allows processes with +appropriate privileges to set system information. +The information available from +.Fn sysctl +consists of integers, strings, and tables. +Information may be retrieved and set from the command interface +using the +.Xr sysctl 8 +utility. +.Pp +Unless explicitly noted below, +.Fn sysctl +returns a consistent snapshot of the data requested. +Consistency is obtained by locking the destination +buffer into memory so that the data may be copied out without blocking. +Calls to +.Fn sysctl +are serialized to avoid deadlock. +.Pp +The state is described using a ``Management Information Base'' (MIB) +style name, listed in +.Fa name , +which is a +.Fa namelen +length array of integers. +.Pp +The +.Fn sysctlbyname +function accepts an ASCII representation of the name and internally +looks up the integer name vector. Apart from that, it behaves the same +as the standard +.Fn sysctl +function. +.Pp +The information is copied into the buffer specified by +.Fa oldp . +The size of the buffer is given by the location specified by +.Fa oldlenp +before the call, +and that location gives the amount of data copied after a successful call +and after a call that returns with the error code +.Er ENOMEM . +If the amount of data available is greater +than the size of the buffer supplied, +the call supplies as much data as fits in the buffer provided +and returns with the error code +.Er ENOMEM . +If the old value is not desired, +.Fa oldp +and +.Fa oldlenp +should be set to NULL. +.Pp +The size of the available data can be determined by calling +.Fn sysctl +with a NULL parameter for +.Fa oldp . +The size of the available data will be returned in the location pointed to by +.Fa oldlenp . +For some operations, the amount of space may change often. +For these operations, +the system attempts to round up so that the returned size is +large enough for a call to return the data shortly thereafter. +.Pp +To set a new value, +.Fa newp +is set to point to a buffer of length +.Fa newlen +from which the requested value is to be taken. +If a new value is not to be set, +.Fa newp +should be set to NULL and +.Fa newlen +set to 0. +.Pp +The +.Fn sysctlnametomib +function accepts an ASCII representation of the name, +looks up the integer name vector, +and returns the numeric representation in the mib array pointed to by +.Fa mibp . +The number of elements in the mib array is given by the location specified by +.Fa sizep +before the call, +and that location gives the number of entries copied after a successful call. +The resulting +.Fa mib +and +.Fa size +may be used in subsequent +.Fn sysctl +calls to get the data associated with the requested ASCII name. +This interface is intended for use by applications that want to +repeatedly request the same variable (the +.Fn sysctl +function runs in about a third the time as the same request made via the +.Fn sysctlbyname +function). +The +.Fn sysctlbyname +function is also useful for fetching mib prefixes and then adding +a final component. +For example, to fetch process information +for processes with pid's less than 100: +.Pp +.Bd -literal -offset indent -compact +int i, mib[4]; +size_t len; +struct kinfo_proc kp; + +/* Fill out the first three components of the mib */ +len = 4; +sysctlnametomib("kern.proc.pid", mib, &len); + +/* Fetch and print entries for pid's < 100 */ +for (i = 0; i < 100; i++) { + mib[3] = i; + len = sizeof(kp); + if (sysctl(mib, 4, &kp, &len, NULL, 0) == -1) + perror("sysctl"); + else if (len > 0) + printkproc(&kp); +} +.Ed +.Pp +The top level names are defined with a CTL_ prefix in +.Aq Pa sys/sysctl.h , +and are as follows. +The next and subsequent levels down are found in the include files +listed here, and described in separate sections below. +.Pp +.Bl -column CTLXMACHDEPXXX "Next level namesXXXXXX" -offset indent +.It Sy "Name Next level names Description" +.It "CTL\_DEBUG sys/sysctl.h Debugging" +.It "CTL\_VFS sys/mount.h Filesystem" +.It "CTL\_HW sys/sysctl.h Generic CPU, I/O" +.It "CTL\_KERN sys/sysctl.h High kernel limits" +.It "CTL\_MACHDEP sys/sysctl.h Machine dependent" +.It "CTL\_NET sys/socket.h Networking" +.It "CTL\_USER sys/sysctl.h User-level" +.It "CTL\_VM vm/vm_param.h Virtual memory" +.El +.Pp +For example, the following retrieves the maximum number of processes allowed +in the system: +.Pp +.Bd -literal -offset indent -compact +int mib[2], maxproc; +size_t len; + +mib[0] = CTL_KERN; +mib[1] = KERN_MAXPROC; +len = sizeof(maxproc); +sysctl(mib, 2, &maxproc, &len, NULL, 0); +.Ed +.Pp +To retrieve the standard search path for the system utilities: +.Pp +.Bd -literal -offset indent -compact +int mib[2]; +size_t len; +char *p; + +mib[0] = CTL_USER; +mib[1] = USER_CS_PATH; +sysctl(mib, 2, NULL, &len, NULL, 0); +p = malloc(len); +sysctl(mib, 2, p, &len, NULL, 0); +.Ed +.Ss CTL_DEBUG +The debugging variables vary from system to system. +A debugging variable may be added or deleted without need to recompile +.Fn sysctl +to know about it. +Each time it runs, +.Fn sysctl +gets the list of debugging variables from the kernel and +displays their current values. +The system defines twenty +.Ns ( Va struct ctldebug ) +variables named +.Nm debug0 +through +.Nm debug19 . +They are declared as separate variables so that they can be +individually initialized at the location of their associated variable. +The loader prevents multiple use of the same variable by issuing errors +if a variable is initialized in more than one place. +For example, to export the variable +.Nm dospecialcheck +as a debugging variable, the following declaration would be used: +.Bd -literal -offset indent -compact +int dospecialcheck = 1; +struct ctldebug debug5 = { "dospecialcheck", &dospecialcheck }; +.Ed +.Ss CTL_VFS +A distinguished second level name, VFS_GENERIC, +is used to get general information about all filesystems. +One of its third level identifiers is VFS_MAXTYPENUM +that gives the highest valid filesystem type number. +Its other third level identifier is VFS_CONF that +returns configuration information about the filesystem +type given as a fourth level identifier (see +.Xr getvfsbyname 3 +as an example of its use). +The remaining second level identifiers are the +filesystem type number returned by a +.Xr statfs 2 +call or from VFS_CONF. +The third level identifiers available for each filesystem +are given in the header file that defines the mount +argument structure for that filesystem. +.Ss CTL_HW +The string and integer information available for the CTL_HW level +is detailed below. +The changeable column shows whether a process with appropriate +privilege may change the value. +.Bl -column "Second level nameXXXXXX" integerXXX -offset indent +.It Sy "Second level name Type Changeable" +.It "HW\_MACHINE string no" +.It "HW\_MODEL string no" +.It "HW\_NCPU integer no" +.It "HW\_BYTEORDER integer no" +.It "HW\_PHYSMEM integer no" +.It "HW\_USERMEM integer no" +.It "HW\_PAGESIZE integer no" +.It "HW\_FLOATINGPOINT integer no" +.It "HW\_MACHINE\_ARCH string no" +.\".It "HW\_DISKNAMES integer no" +.\".It "HW\_DISKSTATS integer no" +.El +.Pp +.Bl -tag -width 6n +.It Li HW_MACHINE +The machine class. +.It Li HW_MODEL +The machine model +.It Li HW_NCPU +The number of cpus. +.It Li HW_BYTEORDER +The byteorder (4,321, or 1,234). +.It Li HW_PHYSMEM +The bytes of physical memory. +.It Li HW_USERMEM +The bytes of non-kernel memory. +.It Li HW_PAGESIZE +The software page size. +.It Li HW_FLOATINGPOINT +Nonzero if the floating point support is in hardware. +.It Li HW_MACHINE_ARCH +The machine dependent architecture type. +.\".It Fa HW_DISKNAMES +.\".It Fa HW_DISKSTATS +.El +.Ss CTL_KERN +The string and integer information available for the CTL_KERN level +is detailed below. +The changeable column shows whether a process with appropriate +privilege may change the value. +The types of data currently available are process information, +system vnodes, the open file entries, routing table entries, +virtual memory statistics, load average history, and clock rate +information. +.Bl -column "KERNXMAXFILESPERPROCXXX" "struct clockrateXXX" -offset indent +.It Sy "Second level name Type Changeable" +.It "KERN\_ARGMAX integer no" +.It "KERN\_BOOTFILE string yes" +.It "KERN\_BOOTTIME struct timeval no" +.It "KERN\_CLOCKRATE struct clockinfo no" +.It "KERN\_FILE struct file no" +.It "KERN\_HOSTID integer yes" +.It "KERN\_HOSTNAME string yes" +.It "KERN\_JOB\_CONTROL integer no" +.It "KERN\_MAXFILES integer yes" +.It "KERN\_MAXFILESPERPROC integer yes" +.It "KERN\_MAXPROC integer no" +.It "KERN\_MAXPROCPERUID integer yes" +.It "KERN\_MAXVNODES integer yes" +.It "KERN\_NGROUPS integer no" +.It "KERN\_NISDOMAINNAME string yes" +.It "KERN\_OSRELDATE integer no" +.It "KERN\_OSRELEASE string no" +.It "KERN\_OSREV integer no" +.It "KERN\_OSTYPE string no" +.It "KERN\_POSIX1 integer no" +.It "KERN\_PROC struct proc no" +.It "KERN\_PROF node not applicable" +.It "KERN\_QUANTUM integer yes" +.It "KERN\_SAVED\_IDS integer no" +.It "KERN\_SECURELVL integer raise only" +.It "KERN\_UPDATEINTERVAL integer no" +.It "KERN\_VERSION string no" +.It "KERN\_VNODE struct vnode no" +.El +.Pp +.Bl -tag -width 6n +.It Li KERN_ARGMAX +The maximum bytes of argument to +.Xr execve 2 . +.It Li KERN_BOOTFILE +The full pathname of the file from which the kernel was loaded. +.It Li KERN_BOOTTIME +A +.Va struct timeval +structure is returned. +This structure contains the time that the system was booted. +.It Li KERN_CLOCKRATE +A +.Va struct clockinfo +structure is returned. +This structure contains the clock, statistics clock and profiling clock +frequencies, the number of micro-seconds per hz tick and the skew rate. +.It Li KERN_FILE +Return the entire file table. +The returned data consists of a single +.Va struct filehead +followed by an array of +.Va struct file , +whose size depends on the current number of such objects in the system. +.It Li KERN_HOSTID +Get or set the host id. +.It Li KERN_HOSTNAME +Get or set the hostname. +.It Li KERN_JOB_CONTROL +Return 1 if job control is available on this system, otherwise 0. +.It Li KERN_MAXFILES +The maximum number of files that may be open in the system. +.It Li KERN_MAXFILESPERPROC +The maximum number of files that may be open for a single process. +This limit only applies to processes with an effective uid of nonzero +at the time of the open request. +Files that have already been opened are not affected if the limit +or the effective uid is changed. +.It Li KERN_MAXPROC +The maximum number of concurrent processes the system will allow. +.It Li KERN_MAXPROCPERUID +The maximum number of concurrent processes the system will allow +for a single effective uid. +This limit only applies to processes with an effective uid of nonzero +at the time of a fork request. +Processes that have already been started are not affected if the limit +is changed. +.It Li KERN_MAXVNODES +The maximum number of vnodes available on the system. +.It Li KERN_NGROUPS +The maximum number of supplemental groups. +.It Li KERN_NISDOMAINNAME +The name of the current YP/NIS domain. +.It Li KERN_OSRELDATE +The system release date in YYYYMM format +(January 1996 is encoded as 199601). +.It Li KERN_OSRELEASE +The system release string. +.It Li KERN_OSREV +The system revision string. +.It Li KERN_OSTYPE +The system type string. +.It Li KERN_POSIX1 +The version of +.St -p1003.1 +with which the system +attempts to comply. +.It Li KERN_PROC +Return the entire process table, or a subset of it. +An array of pairs of +.Va struct proc +followed by corresponding +.Va struct eproc +structures is returned, +whose size depends on the current number of such objects in the system. +The third and fourth level names are as follows: +.Bl -column "Third level nameXXXXXX" "Fourth level is:XXXXXX" -offset indent +.It "Third level name Fourth level is:" +.It "KERN\_PROC\_ALL None" +.It "KERN\_PROC\_PID A process ID" +.It "KERN\_PROC\_PGRP A process group" +.It "KERN\_PROC\_TTY A tty device" +.It "KERN\_PROC\_UID A user ID" +.It "KERN\_PROC\_RUID A real user ID" +.El +.Pp +If the third level name is KERN_PROC_ARGS then the command line argument +array is returned in a flattened form, i.e. zero-terminated arguments +follow each other. +The total size of array is returned. +It is also possible for a process to set its own process title this way. +.Bl -column "Third level nameXXXXXX" "Fourth level is:XXXXXX" -offset indent +.It Sy "Third level name Fourth level is:" +.It "KERN\_PROC\_ARGS A process ID" +.El +.It Li KERN_PROF +Return profiling information about the kernel. +If the kernel is not compiled for profiling, +attempts to retrieve any of the KERN_PROF values will +fail with +.Er EOPNOTSUPP . +The third level names for the string and integer profiling information +is detailed below. +The changeable column shows whether a process with appropriate +privilege may change the value. +.Bl -column "GPROFXGMONPARAMXXX" "struct gmonparamXXX" -offset indent +.It Sy "Third level name Type Changeable" +.It "GPROF\_STATE integer yes" +.It "GPROF\_COUNT u_short[\|] yes" +.It "GPROF\_FROMS u_short[\|] yes" +.It "GPROF\_TOS struct tostruct yes" +.It "GPROF\_GMONPARAM struct gmonparam no" +.El +.Pp +The variables are as follows: +.Bl -tag -width 6n +.It Li GPROF_STATE +Returns GMON_PROF_ON or GMON_PROF_OFF to show that profiling +is running or stopped. +.It Li GPROF_COUNT +Array of statistical program counter counts. +.It Li GPROF_FROMS +Array indexed by program counter of call-from points. +.It Li GPROF_TOS +Array of +.Va struct tostruct +describing destination of calls and their counts. +.It Li GPROF_GMONPARAM +Structure giving the sizes of the above arrays. +.El +.It Li KERN_QUANTUM +The maximum period of time, in microseconds, for which a process is allowed +to run without being preempted if other processes are in the run queue. +.It Li KERN_SAVED_IDS +Returns 1 if saved set-group and saved set-user ID is available. +.It Li KERN_SECURELVL +The system security level. +This level may be raised by processes with appropriate privilege. +It may not be lowered. +.It Li KERN_VERSION +The system version string. +.It Li KERN_VNODE +Return the entire vnode table. +Note, the vnode table is not necessarily a consistent snapshot of +the system. +The returned data consists of an array whose size depends on the +current number of such objects in the system. +Each element of the array contains the kernel address of a vnode +.Va struct vnode * +followed by the vnode itself +.Va struct vnode . +.El +.Ss CTL_MACHDEP +The set of variables defined is architecture dependent. +The following variables are defined for the i386 architecture. +.Bl -column "CONSOLE_DEVICEXXX" "struct bootinfoXXX" -offset indent +.It Sy "Second level name Type Changeable" +.It Li "CPU_CONSDEV dev_t no" +.It Li "CPU_ADJKERNTZ int yes" +.It Li "CPU_DISRTCSET int yes" +.It Li "CPU_BOOTINFO struct bootinfo no" +.It Li "CPU_WALLCLOCK int yes" +.El +.Ss CTL_NET +The string and integer information available for the CTL_NET level +is detailed below. +The changeable column shows whether a process with appropriate +privilege may change the value. +.Bl -column "Second level nameXXXXXX" "routing messagesXXX" -offset indent +.It Sy "Second level name Type Changeable" +.It "PF\_ROUTE routing messages no" +.It "PF\_INET IPv4 values yes" +.It "PF\_INET6 IPv6 values yes" +.El +.Pp +.Bl -tag -width 6n +.It Li PF_ROUTE +Return the entire routing table or a subset of it. +The data is returned as a sequence of routing messages (see +.Xr route 4 +for the header file, format and meaning). +The length of each message is contained in the message header. +.Pp +The third level name is a protocol number, which is currently always 0. +The fourth level name is an address family, which may be set to 0 to +select all address families. +The fifth and sixth level names are as follows: +.Bl -column "Fifth level nameXXXXXX" "Sixth level is:XXX" -offset indent +.It Sy "Fifth level name Sixth level is:" +.It "NET\_RT\_FLAGS rtflags" +.It "NET\_RT\_DUMP None" +.It "NET\_RT\_IFLIST None" +.El +.It Li PF_INET +Get or set various global information about the IPv4 +(Internet Protocol version 4). +The third level name is the protocol. +The fourth level name is the variable name. +The currently defined protocols and names are: +.Bl -column ProtocolXX VariableXX TypeXX ChangeableXX +.It Sy "Protocol Variable Type Changeable" +.It "icmp bmcastecho integer yes" +.It "icmp maskrepl integer yes" +.It "ip forwarding integer yes" +.It "ip redirect integer yes" +.It "ip ttl integer yes" +.It "udp checksum integer yes" +.El +.Pp +The variables are as follows: +.Bl -tag -width 6n +.It Li icmp.bmcastecho +Returns 1 if an ICMP echo request to a broadcast or multicast address is +to be answered. +.It Li icmp.maskrepl +Returns 1 if ICMP network mask requests are to be answered. +.It Li ip.forwarding +Returns 1 when IP forwarding is enabled for the host, +meaning that the host is acting as a router. +.It Li ip.redirect +Returns 1 when ICMP redirects may be sent by the host. +This option is ignored unless the host is routing IP packets, +and should normally be enabled on all systems. +.It Li ip.ttl +The maximum time-to-live (hop count) value for an IP packet sourced by +the system. +This value applies to normal transport protocols, not to ICMP. +.It Li udp.checksum +Returns 1 when UDP checksums are being computed and checked. +Disabling UDP checksums is strongly discouraged. +.Pp +For variables net.inet.*.ipsec, please refer to +.Xr ipsec 4 . +.El +.It Li PF_INET6 +Get or set various global information about the IPv6 +(Internet Protocol version 6). +The third level name is the protocol. +The fourth level name is the variable name. +.Pp +For variables net.inet6.* please refer to +.Xr inet6 4 . +For variables net.inet6.*.ipsec6, please refer to +.Xr ipsec 4 . +.El +.Ss CTL_USER +The string and integer information available for the CTL_USER level +is detailed below. +The changeable column shows whether a process with appropriate +privilege may change the value. +.Bl -column "USER_COLL_WEIGHTS_MAXXXX" "integerXXX" -offset indent +.It Sy "Second level name Type Changeable" +.It "USER\_BC\_BASE\_MAX integer no" +.It "USER\_BC\_DIM\_MAX integer no" +.It "USER\_BC\_SCALE\_MAX integer no" +.It "USER\_BC\_STRING\_MAX integer no" +.It "USER\_COLL\_WEIGHTS\_MAX integer no" +.It "USER\_CS\_PATH string no" +.It "USER\_EXPR\_NEST\_MAX integer no" +.It "USER\_LINE\_MAX integer no" +.It "USER\_POSIX2\_CHAR\_TERM integer no" +.It "USER\_POSIX2\_C\_BIND integer no" +.It "USER\_POSIX2\_C\_DEV integer no" +.It "USER\_POSIX2\_FORT\_DEV integer no" +.It "USER\_POSIX2\_FORT\_RUN integer no" +.It "USER\_POSIX2\_LOCALEDEF integer no" +.It "USER\_POSIX2\_SW\_DEV integer no" +.It "USER\_POSIX2\_UPE integer no" +.It "USER\_POSIX2\_VERSION integer no" +.It "USER\_RE\_DUP\_MAX integer no" +.It "USER\_STREAM\_MAX integer no" +.It "USER\_TZNAME\_MAX integer no" +.El +.Bl -tag -width 6n +.Pp +.It Li USER_BC_BASE_MAX +The maximum ibase/obase values in the +.Xr bc 1 +utility. +.It Li USER_BC_DIM_MAX +The maximum array size in the +.Xr bc 1 +utility. +.It Li USER_BC_SCALE_MAX +The maximum scale value in the +.Xr bc 1 +utility. +.It Li USER_BC_STRING_MAX +The maximum string length in the +.Xr bc 1 +utility. +.It Li USER_COLL_WEIGHTS_MAX +The maximum number of weights that can be assigned to any entry of +the LC_COLLATE order keyword in the locale definition file. +.It Li USER_CS_PATH +Return a value for the +.Ev PATH +environment variable that finds all the standard utilities. +.It Li USER_EXPR_NEST_MAX +The maximum number of expressions that can be nested within +parenthesis by the +.Xr expr 1 +utility. +.It Li USER_LINE_MAX +The maximum length in bytes of a text-processing utility's input +line. +.It Li USER_POSIX2_CHAR_TERM +Return 1 if the system supports at least one terminal type capable of +all operations described in +.St -p1003.2 , +otherwise 0. +.It Li USER_POSIX2_C_BIND +Return 1 if the system's C-language development facilities support the +C-Language Bindings Option, otherwise 0. +.It Li USER_POSIX2_C_DEV +Return 1 if the system supports the C-Language Development Utilities Option, +otherwise 0. +.It Li USER_POSIX2_FORT_DEV +Return 1 if the system supports the FORTRAN Development Utilities Option, +otherwise 0. +.It Li USER_POSIX2_FORT_RUN +Return 1 if the system supports the FORTRAN Runtime Utilities Option, +otherwise 0. +.It Li USER_POSIX2_LOCALEDEF +Return 1 if the system supports the creation of locales, otherwise 0. +.It Li USER_POSIX2_SW_DEV +Return 1 if the system supports the Software Development Utilities Option, +otherwise 0. +.It Li USER_POSIX2_UPE +Return 1 if the system supports the User Portability Utilities Option, +otherwise 0. +.It Li USER_POSIX2_VERSION +The version of +.St -p1003.2 +with which the system attempts to comply. +.It Li USER_RE_DUP_MAX +The maximum number of repeated occurrences of a regular expression +permitted when using interval notation. +.It Li USER_STREAM_MAX +The minimum maximum number of streams that a process may have open +at any one time. +.It Li USER_TZNAME_MAX +The minimum maximum number of types supported for the name of a +timezone. +.El +.Ss CTL_VM +The string and integer information available for the CTL_VM level +is detailed below. +The changeable column shows whether a process with appropriate +privilege may change the value. +.Bl -column "Second level nameXXXXXX" "struct loadavgXXX" -offset indent +.It Sy "Second level name Type Changeable" +.It "VM\_LOADAVG struct loadavg no" +.It "VM\_METER struct vmtotal no" +.It "VM\_PAGEOUT\_ALGORITHM integer yes" +.It "VM\_SWAPPING\_ENABLED integer maybe" +.It "VM\_V\_CACHE\_MAX integer yes" +.It "VM\_V\_CACHE\_MIN integer yes" +.It "VM\_V\_FREE\_MIN integer yes" +.It "VM\_V\_FREE\_RESERVED integer yes" +.It "VM\_V\_FREE\_TARGET integer yes" +.It "VM\_V\_INACTIVE\_TARGET integer yes" +.It "VM\_V\_PAGEOUT\_FREE\_MIN integer yes" +.El +.Pp +.Bl -tag -width 6n +.It Li VM_LOADAVG +Return the load average history. +The returned data consists of a +.Va struct loadavg . +.It Li VM_METER +Return the system wide virtual memory statistics. +The returned data consists of a +.Va struct vmtotal . +.It Li VM_PAGEOUT_ALGORITHM +0 if the statistics-based page management algorithm is in use +or 1 if the near-LRU algorithm is in use. +.It Li VM_SWAPPING_ENABLED +1 if process swapping is enabled or 0 if disabled. This variable is +permanently set to 0 if the kernel was built with swapping disabled. +.It Li VM_V_CACHE_MAX +Maximum desired size of the cache queue. +.It Li VM_V_CACHE_MIN +Minimum desired size of the cache queue. If the cache queue size +falls very far below this value, the pageout daemon is awakened. +.It Li VM_V_FREE_MIN +Minimum amount of memory (cache memory plus free memory) +required to be available before a process waiting on memory will be +awakened. +.It Li VM_V_FREE_RESERVED +Processes will awaken the pageout daemon and wait for memory if the +number of free and cached pages drops below this value. +.It Li VM_V_FREE_TARGET +The total amount of free memory (including cache memory) that the +pageout daemon tries to maintain. +.It Li VM_V_INACTIVE_TARGET +The desired number of inactive pages that the pageout daemon should +achieve when it runs. Inactive pages can be quickly inserted into +process address space when needed. +.It Li VM_V_PAGEOUT_FREE_MIN +If the amount of free and cache memory falls below this value, the +pageout daemon will enter "memory conserving mode" to avoid deadlock. +.El +.Sh RETURN VALUES +.Rv -std +.Sh ERRORS +The following errors may be reported: +.Bl -tag -width Er +.It Bq Er EFAULT +The buffer +.Fa name , +.Fa oldp , +.Fa newp , +or length pointer +.Fa oldlenp +contains an invalid address. +.It Bq Er EINVAL +The +.Fa name +array is less than two or greater than CTL_MAXNAME. +.It Bq Er EINVAL +A non-null +.Fa newp +is given and its specified length in +.Fa newlen +is too large or too small. +.It Bq Er ENOMEM +The length pointed to by +.Fa oldlenp +is too short to hold the requested value. +.It Bq Er ENOTDIR +The +.Fa name +array specifies an intermediate rather than terminal name. +.It Bq Er EISDIR +The +.Fa name +array specifies a terminal name, but the actual name is not terminal. +.It Bq Er EOPNOTSUPP +The +.Fa name +array specifies a value that is unknown. +.It Bq Er EPERM +An attempt is made to set a read-only value. +.It Bq Er EPERM +A process without appropriate privilege attempts to set a value. +.El +.Sh FILES +.Bl -tag -width -compact +.It Aq Pa sys/sysctl.h +definitions for top level identifiers, second level kernel and hardware +identifiers, and user level identifiers +.It Aq Pa sys/socket.h +definitions for second level network identifiers +.It Aq Pa sys/gmon.h +definitions for third level profiling identifiers +.It Aq Pa vm/vm_param.h +definitions for second level virtual memory identifiers +.It Aq Pa netinet/in.h +definitions for third level IPv4/IPv6 identifiers and +fourth level IPv4/v6 identifiers +.It Aq Pa netinet/icmp_var.h +definitions for fourth level ICMP identifiers +.It Aq Pa netinet/icmp6.h +definitions for fourth level ICMPv6 identifiers +.It Aq Pa netinet/udp_var.h +definitions for fourth level UDP identifiers +.El +.Sh SEE ALSO +.Xr sysconf 3 , +.Xr sysctl 8 +.Sh HISTORY +The +.Fn sysctl +function first appeared in +.Bx 4.4 . diff --git a/gen.subproj/sysctl.c b/gen/sysctl.c similarity index 100% rename from gen.subproj/sysctl.c rename to gen/sysctl.c diff --git a/gen.subproj/sysctlbyname.c b/gen/sysctlbyname.c similarity index 100% rename from gen.subproj/sysctlbyname.c rename to gen/sysctlbyname.c diff --git a/gen/syslog.3 b/gen/syslog.3 new file mode 100644 index 0000000..663c6d8 --- /dev/null +++ b/gen/syslog.3 @@ -0,0 +1,296 @@ +.\" Copyright (c) 1985, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)syslog.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/syslog.3,v 1.22 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt SYSLOG 3 +.Os +.Sh NAME +.Nm syslog , +.Nm vsyslog , +.Nm openlog , +.Nm closelog , +.Nm setlogmask +.Nd control system log +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In syslog.h +.In stdarg.h +.Ft void +.Fn syslog "int priority" "const char *message" "..." +.Ft void +.Fn vsyslog "int priority" "const char *message" "va_list args" +.Ft void +.Fn openlog "const char *ident" "int logopt" "int facility" +.Ft void +.Fn closelog void +.Ft int +.Fn setlogmask "int maskpri" +.Sh DESCRIPTION +The +.Fn syslog +function +writes +.Fa message +to the system message logger. +The message is then written to the system console, log files, +logged-in users, or forwarded to other machines as appropriate. +(See +.Xr syslogd 8 . ) +.Pp +The message is identical to a +.Xr printf 3 +format string, except that +.Ql %m +is replaced by the current error +message. +(As denoted by the global variable +.Va errno ; +see +.Xr strerror 3 . ) +A trailing newline is added if none is present. +.Pp +The +.Fn vsyslog +function +is an alternate form in which the arguments have already been captured +using the variable-length argument facilities of +.Xr stdarg 3 . +.Pp +The message is tagged with +.Fa priority . +Priorities are encoded as a +.Fa facility +and a +.Em level . +The facility describes the part of the system +generating the message. +The level is selected from the following +.Em ordered +(high to low) list: +.Bl -tag -width LOG_AUTHPRIV +.It Dv LOG_EMERG +A panic condition. +This is normally broadcast to all users. +.It Dv LOG_ALERT +A condition that should be corrected immediately, such as a corrupted +system database. +.It Dv LOG_CRIT +Critical conditions, e.g., hard device errors. +.It Dv LOG_ERR +Errors. +.It Dv LOG_WARNING +Warning messages. +.It Dv LOG_NOTICE +Conditions that are not error conditions, +but should possibly be handled specially. +.It Dv LOG_INFO +Informational messages. +.It Dv LOG_DEBUG +Messages that contain information +normally of use only when debugging a program. +.El +.Pp +The +.Fn openlog +function +provides for more specialized processing of the messages sent +by +.Fn syslog +and +.Fn vsyslog . +The parameter +.Fa ident +is a string that will be prepended to every message. +The +.Fa logopt +argument +is a bit field specifying logging options, which is formed by +.Tn OR Ns 'ing +one or more of the following values: +.Bl -tag -width LOG_AUTHPRIV +.It Dv LOG_CONS +If +.Fn syslog +cannot pass the message to +.Xr syslogd 8 +it will attempt to write the message to the console +.Pq Dq Pa /dev/console . +.It Dv LOG_NDELAY +Open the connection to +.Xr syslogd 8 +immediately. +Normally the open is delayed until the first message is logged. +Useful for programs that need to manage the order in which file +descriptors are allocated. +.It Dv LOG_PERROR +Write the message to standard error output as well to the system log. +.It Dv LOG_PID +Log the process id with each message: useful for identifying +instantiations of daemons. +.El +.Pp +The +.Fa facility +parameter encodes a default facility to be assigned to all messages +that do not have an explicit facility encoded: +.Bl -tag -width LOG_AUTHPRIV +.It Dv LOG_AUTH +The authorization system: +.Xr login 1 , +.Xr su 1 , +.Xr getty 8 , +etc. +.It Dv LOG_AUTHPRIV +The same as +.Dv LOG_AUTH , +but logged to a file readable only by +selected individuals. +.It Dv LOG_CONSOLE +Messages written to +.Pa /dev/console +by the kernel console output driver. +.It Dv LOG_CRON +The cron daemon: +.Xr cron 8 . +.It Dv LOG_DAEMON +System daemons, such as +.Xr routed 8 , +that are not provided for explicitly by other facilities. +.It Dv LOG_FTP +The file transfer protocol daemons: +.Xr ftpd 8 , +.Xr tftpd 8 . +.It Dv LOG_KERN +Messages generated by the kernel. +These cannot be generated by any user processes. +.It Dv LOG_LPR +The line printer spooling system: +.Xr lpr 1 , +.Xr lpc 8 , +.Xr lpd 8 , +etc. +.It Dv LOG_MAIL +The mail system. +.It Dv LOG_NEWS +The network news system. +.It Dv LOG_SECURITY +Security subsystems, such as +.Xr ipfw 4 . +.It Dv LOG_SYSLOG +Messages generated internally by +.Xr syslogd 8 . +.It Dv LOG_USER +Messages generated by random user processes. +This is the default facility identifier if none is specified. +.It Dv LOG_UUCP +The uucp system. +.It Dv LOG_LOCAL0 +Reserved for local use. +Similarly for +.Dv LOG_LOCAL1 +through +.Dv LOG_LOCAL7 . +.El +.Pp +The +.Fn closelog +function +can be used to close the log file. +.Pp +The +.Fn setlogmask +function +sets the log priority mask to +.Fa maskpri +and returns the previous mask. +Calls to +.Fn syslog +with a priority not set in +.Fa maskpri +are rejected. +The mask for an individual priority +.Fa pri +is calculated by the macro +.Fn LOG_MASK pri ; +the mask for all priorities up to and including +.Fa toppri +is given by the macro +.Fn LOG_UPTO toppri ; . +The default allows all priorities to be logged. +.Sh RETURN VALUES +The routines +.Fn closelog , +.Fn openlog , +.Fn syslog +and +.Fn vsyslog +return no value. +.Pp +The routine +.Fn setlogmask +always returns the previous log mask level. +.Sh EXAMPLES +.Bd -literal -offset indent -compact +syslog(LOG_ALERT, "who: internal error 23"); + +openlog("ftpd", LOG_PID | LOG_NDELAY, LOG_FTP); + +setlogmask(LOG_UPTO(LOG_ERR)); + +syslog(LOG_INFO, "Connection from host %d", CallingHost); + +syslog(LOG_INFO|LOG_LOCAL2, "foobar error: %m"); +.Ed +.Sh SEE ALSO +.Xr logger 1 , +.Xr syslogd 8 +.Sh HISTORY +These +functions appeared in +.Bx 4.2 . +.Sh BUGS +Never pass a string with user-supplied data as a format without using +.Ql %s . +An attacker can put format specifiers in the string to mangle your stack, +leading to a possible security hole. +This holds true even if the string was built using a function like +.Fn snprintf , +as the resulting string may still contain user-supplied conversion specifiers +for later interpolation by +.Fn syslog . +.Pp +Always use the proper secure idiom: +.Pp +.Dl syslog("%s", string); diff --git a/gen.subproj/syslog.c b/gen/syslog.c similarity index 100% rename from gen.subproj/syslog.c rename to gen/syslog.c diff --git a/gen/tcgetpgrp.3 b/gen/tcgetpgrp.3 new file mode 100644 index 0000000..b155763 --- /dev/null +++ b/gen/tcgetpgrp.3 @@ -0,0 +1,82 @@ +.\" Copyright (c) 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)tcgetpgrp.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/tcgetpgrp.3,v 1.8 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt TCGETPGRP 3 +.Os +.Sh NAME +.Nm tcgetpgrp +.Nd get foreground process group ID +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In unistd.h +.Ft pid_t +.Fn tcgetpgrp "int fd" +.Sh DESCRIPTION +The +.Fn tcgetpgrp +function returns the value of the process group ID of the foreground +process group associated with the terminal device. +If there is no foreground process group, +.Fn tcgetpgrp +returns an invalid process ID. +.Sh ERRORS +If an error occurs, +.Fn tcgetpgrp +returns -1 and the global variable +.Va errno +is set to indicate the error, as follows: +.Bl -tag -width Er +.It Bq Er EBADF +The +.Fa fd +argument is not a valid file descriptor. +.It Bq Er ENOTTY +The calling process does not have a controlling terminal or the +underlying terminal device represented by +.Fa fd +is not the controlling terminal. +.El +.Sh SEE ALSO +.Xr setpgid 2 , +.Xr setsid 2 , +.Xr tcsetpgrp 3 +.Sh STANDARDS +The +.Fn tcgetpgrp +function is expected to be compliant with the +.St -p1003.1-88 +specification. diff --git a/gen/tcsendbreak.3 b/gen/tcsendbreak.3 new file mode 100644 index 0000000..e47779a --- /dev/null +++ b/gen/tcsendbreak.3 @@ -0,0 +1,157 @@ +.\" Copyright (c) 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)tcsendbreak.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/tcsendbreak.3,v 1.8 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt TCSENDBREAK 3 +.Os +.Sh NAME +.Nm tcsendbreak , +.Nm tcdrain , +.Nm tcflush , +.Nm tcflow +.Nd line control functions +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In termios.h +.Ft int +.Fn tcdrain "int fd" +.Ft int +.Fn tcflow "int fd" "int action" +.Ft int +.Fn tcflush "int fd" "int action" +.Ft int +.Fn tcsendbreak "int fd" "int len" +.Sh DESCRIPTION +The +.Fn tcdrain +function waits until all output written to the terminal referenced by +.Fa fd +has been transmitted to the terminal. +.Pp +The +.Fn tcflow +function suspends transmission of data to or the reception of data from +the terminal referenced by +.Fa fd +depending on the value of +.Fa action . +The value of +.Fa action +must be one of the following: +.Bl -tag -width "TCIOFF" +.It Fa TCOOFF +Suspend output. +.It Fa TCOON +Restart suspended output. +.It Fa TCIOFF +Transmit a STOP character, which is intended to cause the terminal to stop +transmitting data to the system. +(See the description of IXOFF in the +.Ql Input Modes +section of +.Xr termios 4 ) . +.It Fa TCION +Transmit a START character, which is intended to cause the terminal to start +transmitting data to the system. +(See the description of IXOFF in the +.Ql Input Modes +section of +.Xr termios 4 ) . +.El +.Pp +The +.Fn tcflush +function discards any data written to the terminal referenced by +.Fa fd +which has not been transmitted to the terminal, or any data received +from the terminal but not yet read, depending on the value of +.Fa action . +The value of +.Fa action +must be one of the following: +.Bl -tag -width "TCIOFLUSH" +.It Fa TCIFLUSH +Flush data received but not read. +.It Fa TCOFLUSH +Flush data written but not transmitted. +.It Fa TCIOFLUSH +Flush both data received but not read and data written but not transmitted. +.El +.Pp +The +.Fn tcsendbreak +function transmits a continuous stream of zero-valued bits for four-tenths +of a second to the terminal referenced by +.Fa fd . +The +.Fa len +parameter is ignored in this implementation. +.Sh RETURN VALUES +Upon successful completion, all of these functions return a value of zero. +.Sh ERRORS +If any error occurs, a value of -1 is returned and the global variable +.Va errno +is set to indicate the error, as follows: +.Bl -tag -width Er +.It Bq Er EBADF +The +.Fa fd +argument is not a valid file descriptor. +.It Bq Er EINVAL +The +.Fa action +argument is not a proper value. +.It Bq Er ENOTTY +The file associated with +.Fa fd +is not a terminal. +.It Bq Er EINTR +A signal interrupted the +.Fn tcdrain +function. +.El +.Sh SEE ALSO +.Xr tcsetattr 3 , +.Xr termios 4 +.Sh STANDARDS +The +.Fn tcsendbreak , +.Fn tcdrain , +.Fn tcflush +and +.Fn tcflow +functions are expected to be compliant with the +.St -p1003.1-88 +specification. diff --git a/gen/tcsetattr.3 b/gen/tcsetattr.3 new file mode 100644 index 0000000..a4a3182 --- /dev/null +++ b/gen/tcsetattr.3 @@ -0,0 +1,333 @@ +.\" Copyright (c) 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)tcsetattr.3 8.3 (Berkeley) 1/2/94 +.\" $FreeBSD: src/lib/libc/gen/tcsetattr.3,v 1.9 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd January 2, 1994 +.Dt TCSETATTR 3 +.Os +.Sh NAME +.Nm cfgetispeed , +.Nm cfsetispeed , +.Nm cfgetospeed , +.Nm cfsetospeed , +.Nm cfsetspeed , +.Nm cfmakeraw , +.Nm tcgetattr , +.Nm tcsetattr +.Nd manipulating the termios structure +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In termios.h +.Ft speed_t +.Fn cfgetispeed "const struct termios *t" +.Ft int +.Fn cfsetispeed "struct termios *t" "speed_t speed" +.Ft speed_t +.Fn cfgetospeed "const struct termios *t" +.Ft int +.Fn cfsetospeed "struct termios *t" "speed_t speed" +.Ft int +.Fn cfsetspeed "struct termios *t" "speed_t speed" +.Ft void +.Fn cfmakeraw "struct termios *t" +.Ft int +.Fn tcgetattr "int fd" "struct termios *t" +.Ft int +.Fn tcsetattr "int fd" "int action" "const struct termios *t" +.Sh DESCRIPTION +The +.Fn cfmakeraw , +.Fn tcgetattr +and +.Fn tcsetattr +functions are provided for getting and setting the termios structure. +.Pp +The +.Fn cfgetispeed , +.Fn cfsetispeed , +.Fn cfgetospeed , +.Fn cfsetospeed +and +.Fn cfsetspeed +functions are provided for getting and setting the baud rate values in +the termios structure. +The effects of the functions on the terminal as described below +do not become effective, nor are all errors detected, until the +.Fn tcsetattr +function is called. +Certain values for baud rates set in the termios structure and passed to +.Fn tcsetattr +have special meanings. +These are discussed in the portion of the manual page that describes the +.Fn tcsetattr +function. +.Sh GETTING AND SETTING THE BAUD RATE +The input and output baud rates are found in the termios structure. +The unsigned integer +.Li speed_t +is typdef'd in the include file +.Aq Pa termios.h . +The value of the integer corresponds directly to the baud rate being +represented, however, the following symbolic values are defined. +.Bd -literal +#define B0 0 +#define B50 50 +#define B75 75 +#define B110 110 +#define B134 134 +#define B150 150 +#define B200 200 +#define B300 300 +#define B600 600 +#define B1200 1200 +#define B1800 1800 +#define B2400 2400 +#define B4800 4800 +#define B9600 9600 +#define B19200 19200 +#define B38400 38400 +#ifndef _POSIX_SOURCE +#define EXTA 19200 +#define EXTB 38400 +#endif /*_POSIX_SOURCE */ +.Ed +.Pp +The +.Fn cfgetispeed +function returns the input baud rate in the termios structure referenced by +.Fa tp . +.Pp +The +.Fn cfsetispeed +function sets the input baud rate in the termios structure referenced by +.Fa tp +to +.Fa speed . +.Pp +The +.Fn cfgetospeed +function returns the output baud rate in the termios structure referenced by +.Fa tp . +.Pp +The +.Fn cfsetospeed +function sets the output baud rate in the termios structure referenced by +.Fa tp +to +.Fa speed . +.Pp +The +.Fn cfsetspeed +function sets both the input and output baud rate in the termios structure +referenced by +.Fa tp +to +.Fa speed . +.Pp +Upon successful completion, the functions +.Fn cfsetispeed , +.Fn cfsetospeed , +and +.Fn cfsetspeed +return a value of 0. +Otherwise, a value of -1 is returned and the global variable +.Va errno +is set to indicate the error. +.Sh GETTING AND SETTING THE TERMIOS STATE +This section describes the functions that are used to control the general +terminal interface. +Unless otherwise noted for a specific command, these functions are restricted +from use by background processes. +Attempts to perform these operations shall cause the process group to be sent +a SIGTTOU signal. +If the calling process is blocking or ignoring SIGTTOU signals, the process +is allowed to perform the operation and the SIGTTOU signal is not sent. +.Pp +In all the functions, although +.Fa fd +is an open file descriptor, the functions affect the underlying terminal +file, not just the open file description associated with the particular +file descriptor. +.Pp +The +.Fn cfmakeraw +function sets the flags stored in the termios structure to a state disabling +all input and output processing, giving a +.Dq raw I/O path . +It should be noted that there is no function to reverse this effect. +This is because there are a variety of processing options that could be +re-enabled and the correct method is for an application to snapshot the +current terminal state using the function +.Fn tcgetattr , +setting raw mode with +.Fn cfmakeraw +and the subsequent +.Fn tcsetattr , +and then using another +.Fn tcsetattr +with the saved state to revert to the previous terminal state. +.Pp +The +.Fn tcgetattr +function copies the parameters associated with the terminal referenced +by +.Fa fd +in the termios structure referenced by +.Fa tp . +This function is allowed from a background process, however, the terminal +attributes may be subsequently changed by a foreground process. +.Pp +The +.Fn tcsetattr +function sets the parameters associated with the terminal from the +termios structure referenced by +.Fa tp . +The +.Fa action +field is created by +.Em or Ns 'ing +the following values, as specified in the include file +.Aq Pa termios.h . +.Bl -tag -width "TCSADRAIN" +.It Fa TCSANOW +The change occurs immediately. +.It Fa TCSADRAIN +The change occurs after all output written to +.Fa fd +has been transmitted to the terminal. +This value of +.Fa action +should be used when changing parameters that affect output. +.It Fa TCSAFLUSH +The change occurs after all output written to +.Fa fd +has been transmitted to the terminal. +Additionally, any input that has been received but not read is discarded. +.It Fa TCSASOFT +If this value is +.Em or Ns 'ed +into the +.Fa action +value, the values of the +.Em c_cflag , +.Em c_ispeed , +and +.Em c_ospeed +fields are ignored. +.El +.Pp +The 0 baud rate is used to terminate the connection. +If 0 is specified as the output speed to the function +.Fn tcsetattr , +modem control will no longer be asserted on the terminal, disconnecting +the terminal. +.Pp +If zero is specified as the input speed to the function +.Fn tcsetattr , +the input baud rate will be set to the same value as that specified by +the output baud rate. +.Pp +If +.Fn tcsetattr +is unable to make any of the requested changes, it returns -1 and +sets errno. +Otherwise, it makes all of the requested changes it can. +If the specified input and output baud rates differ and are a combination +that is not supported, neither baud rate is changed. +.Pp +Upon successful completion, the functions +.Fn tcgetattr +and +.Fn tcsetattr +return a value of 0. +Otherwise, they +return -1 and the global variable +.Va errno +is set to indicate the error, as follows: +.Bl -tag -width Er +.It Bq Er EBADF +The +.Fa fd +argument to +.Fn tcgetattr +or +.Fn tcsetattr +was not a valid file descriptor. +.It Bq Er EINTR +The +.Fn tcsetattr +function was interrupted by a signal. +.It Bq Er EINVAL +The +.Fa action +argument to the +.Fn tcsetattr +function was not valid, or an attempt was made to change an attribute +represented in the termios structure to an unsupported value. +.It Bq Er ENOTTY +The file associated with the +.Fa fd +argument to +.Fn tcgetattr +or +.Fn tcsetattr +is not a terminal. +.El +.Sh SEE ALSO +.Xr tcsendbreak 3 , +.Xr termios 4 +.Sh STANDARDS +The +.Fn cfgetispeed , +.Fn cfsetispeed , +.Fn cfgetospeed , +.Fn cfsetospeed , +.Fn tcgetattr +and +.Fn tcsetattr +functions are expected to be compliant with the +.St -p1003.1-88 +specification. +The +.Fn cfmakeraw +and +.Fn cfsetspeed +functions, +as well as the +.Li TCSASOFT +option to the +.Fn tcsetattr +function are extensions to the +.St -p1003.1-88 +specification. diff --git a/gen/tcsetpgrp.3 b/gen/tcsetpgrp.3 new file mode 100644 index 0000000..b50e6a8 --- /dev/null +++ b/gen/tcsetpgrp.3 @@ -0,0 +1,99 @@ +.\" Copyright (c) 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)tcsetpgrp.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/tcsetpgrp.3,v 1.9 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt TCSETPGRP 3 +.Os +.Sh NAME +.Nm tcsetpgrp +.Nd set foreground process group ID +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In unistd.h +.Ft int +.Fn tcsetpgrp "int fd" "pid_t pgrp_id" +.Sh DESCRIPTION +If the process has a controlling terminal, the +.Fn tcsetpgrp +function sets the foreground process group ID associated with the +terminal device to +.Fa pgrp_id . +The terminal device associated with +.Fa fd +must be the controlling terminal of the calling process and the +controlling terminal must be currently associated with the session +of the calling process. +The value of +.Fa pgrp_id +must be the same as the process group ID of a process in the same +session as the calling process. +.Sh RETURN VALUES +.Rv -std tcsetpgrp +.Sh ERRORS +The +.Fn tcsetpgrp +function will fail if: +.Bl -tag -width Er +.It Bq Er EBADF +The +.Fa fd +argument is not a valid file descriptor. +.It Bq Er EINVAL +An invalid value of +.Fa pgrp_id +was specified. +.It Bq Er ENOTTY +The calling process does not have a controlling terminal, or the file +represented by +.Fa fd +is not the controlling terminal, or the controlling terminal is no +longer associated with the session of the calling process. +.It Bq Er EPERM +The +.Fa pgrp_id +argument does not match the process group ID of a process in the same +session as the calling process. +.El +.Sh SEE ALSO +.Xr setpgid 2 , +.Xr setsid 2 , +.Xr tcgetpgrp 3 +.Sh STANDARDS +The +.Fn tcsetpgrp +function is expected to be compliant with the +.St -p1003.1-88 +specification. diff --git a/gen.subproj/telldir.c b/gen/telldir.c similarity index 100% rename from gen.subproj/telldir.c rename to gen/telldir.c diff --git a/gen.subproj/termios.c b/gen/termios.c similarity index 100% rename from gen.subproj/termios.c rename to gen/termios.c diff --git a/gen/time.3 b/gen/time.3 new file mode 100644 index 0000000..949c85a --- /dev/null +++ b/gen/time.3 @@ -0,0 +1,87 @@ +.\" Copyright (c) 1989, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)time.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/time.3,v 1.11 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt TIME 3 +.Os +.Sh NAME +.Nm time +.Nd get time of day +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In time.h +.Ft time_t +.Fn time "time_t *tloc" +.Sh DESCRIPTION +The +.Fn time +function +returns the value of time in seconds since 0 hours, 0 minutes, +0 seconds, January 1, 1970, Coordinated Universal Time. +.Pp +A copy of the time value may be saved to the area indicated by the +pointer +.Fa tloc . +If +.Fa tloc +is a NULL pointer, no value is stored. +.Pp +Upon successful completion, +.Fn time +returns the value of time. +Otherwise a value of +.Pq Po Vt time_t Pc \-1 +is returned and the global variable +.Va errno +is set to indicate the error. +.Sh ERRORS +The following error codes may be set in +.Va errno : +.Bl -tag -width Er +.It Bq Er EFAULT +An argument address referenced invalid memory. +.El +.Sh SEE ALSO +.Xr gettimeofday 2 , +.Xr ctime 3 +.Sh HISTORY +A +.Fn time +function appeared in +.At v6 . diff --git a/gen.subproj/time.c b/gen/time.c similarity index 100% rename from gen.subproj/time.c rename to gen/time.c diff --git a/gen/times.3 b/gen/times.3 new file mode 100644 index 0000000..6aa58c3 --- /dev/null +++ b/gen/times.3 @@ -0,0 +1,144 @@ +.\" Copyright (c) 1990, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)times.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/times.3,v 1.10 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt TIMES 3 +.Os +.Sh NAME +.Nm times +.Nd process times +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/times.h +.Ft clock_t +.Fn times "struct tms *tp" +.Sh DESCRIPTION +.Bf -symbolic +This interface is obsoleted by +.Xr getrusage 2 +and +.Xr gettimeofday 2 . +.Ef +.Pp +The +.Fn times +function returns the value of time in +.Dv CLK_TCK Ns 's +of a second since +0 hours, 0 minutes, 0 seconds, January 1, 1970, Coordinated Universal +Time. +.Pp +It also fills in the structure pointed to by +.Fa tp +with time-accounting information. +.Pp +The +.Vt tms +structure is defined as follows: +.Bd -literal -offset indent +struct tms { + clock_t tms_utime; + clock_t tms_stime; + clock_t tms_cutime; + clock_t tms_cstime; +}; +.Ed +.Pp +The elements of this structure are defined as follows: +.Bl -tag -width ".Va tms_cutime" +.It Va tms_utime +The +.Tn CPU +time charged for the execution of user instructions. +.It Va tms_stime +The +.Tn CPU +time charged for execution by the system on behalf of +the process. +.It Va tms_cutime +The sum of the +.Va tms_utime Ns s +and +.Va tms_cutime Ns s +of the child processes. +.It Va tms_cstime +The sum of the +.Fa tms_stime Ns s +and +.Fa tms_cstime Ns s +of the child processes. +.El +.Pp +All times are in +.Dv CLK_TCK Ns 's +of a second. +.Pp +The times of a terminated child process are included in the +.Va tms_cutime +and +.Va tms_cstime +elements of the parent when one of the +.Xr wait 2 +functions returns the process ID of the terminated child to the parent. +If an error occurs, +.Fn times +returns the value +.Pq Po Vt clock_t Pc Ns \-1 , +and sets +.Va errno +to indicate the error. +.Sh ERRORS +The +.Fn times +function +may fail and set the global variable +.Va errno +for any of the errors specified for the library +routines +.Xr getrusage 2 +and +.Xr gettimeofday 2 . +.Sh SEE ALSO +.Xr time 1 , +.Xr getrusage 2 , +.Xr gettimeofday 2 , +.Xr wait 2 , +.Xr clocks 7 +.Sh STANDARDS +The +.Fn times +function +conforms to +.St -p1003.1-88 . diff --git a/gen.subproj/times.c b/gen/times.c similarity index 100% rename from gen.subproj/times.c rename to gen/times.c diff --git a/gen/timezone.3 b/gen/timezone.3 new file mode 100644 index 0000000..bf1637f --- /dev/null +++ b/gen/timezone.3 @@ -0,0 +1,71 @@ +.\" Copyright (c) 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)timezone.3 8.2 (Berkeley) 4/19/94 +.\" $FreeBSD: src/lib/libc/gen/timezone.3,v 1.7 2000/11/10 17:44:58 ru Exp $ +.\" +.Dd April 19, 1994 +.Dt TIMEZONE 3 +.Os +.Sh NAME +.Nm timezone +.Nd return the timezone abbreviation +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.Ft char * +.Fn timezone "int zone" "int dst" +.Sh DESCRIPTION +.Bf Sy +This interface is for compatibility only; it is impossible to reliably +map timezone's arguments to a time zone abbreviation. +See +.Xr ctime 3 . +.Ef +.Pp +The +.Fn timezone +function returns a pointer to a time zone abbreviation for the specified +.Ar zone +and +.Ar dst +values. +.Ar Zone +is the number of minutes west of GMT and +.Ar dst +is non-zero if daylight savings time is in effect. +.Sh SEE ALSO +.Xr ctime 3 +.Sh HISTORY +A +.Fn timezone +function appeared in +.At v7 . diff --git a/gen.subproj/timezone.c b/gen/timezone.c similarity index 100% rename from gen.subproj/timezone.c rename to gen/timezone.c diff --git a/gen/ttyname.3 b/gen/ttyname.3 new file mode 100644 index 0000000..8a4b649 --- /dev/null +++ b/gen/ttyname.3 @@ -0,0 +1,131 @@ +.\" Copyright (c) 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)ttyname.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/ttyname.3,v 1.9 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt TTYNAME 3 +.Os +.Sh NAME +.Nm ttyname , +.Nm isatty , +.Nm ttyslot +.Nd get name of associated terminal (tty) from file descriptor +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft char * +.Fn ttyname "int fd" +.Ft int +.Fn isatty "int fd" +.Ft int +.Fn ttyslot void +.Sh DESCRIPTION +These functions operate on the system file descriptors for terminal +type devices. +These descriptors are not related to the standard +.Tn I/O +.Dv FILE +typedef, but refer to the special device files found in +.Pa /dev +and named +.Pa /dev/tty Ns Em xx +and for which an entry exists +in the initialization file +.Pa /etc/ttys . +(See +.Xr ttys 5 . ) +.Pp +The +.Fn isatty +function +determines if the file descriptor +.Fa fd +refers to a valid +terminal type device. +.Pp +The +.Fn ttyname +function +gets the related device name of +a file descriptor for which +.Fn isatty +is true +.Pp +The +.Fn ttyslot +function +fetches the current process' control terminal number from the +.Xr ttys 5 +file entry. +.Sh RETURN VALUES +The +.Fn ttyname +function +returns the null terminated name if the device is found and +.Fn isatty +is true; otherwise +a +.Dv NULL +pointer is returned. +.Pp +The +.Fn ttyslot +function +returns the unit number of the device file if found; otherwise +the value zero is returned. +.Sh FILES +.Bl -tag -width /etc/ttys -compact +.It Pa /dev/\(** +.It Pa /etc/ttys +.El +.Sh SEE ALSO +.Xr ioctl 2 , +.Xr ttys 5 +.Sh HISTORY +A +.Fn isatty , +.Fn ttyname , +and +.Fn ttyslot +function +appeared in +.At v7 . +.Sh BUGS +The +.Fn ttyname +function leaves its result in an internal static object and returns +a pointer to that object. +Subsequent calls to +.Fn ttyname +will modify the same object. diff --git a/gen.subproj/ttyname.c b/gen/ttyname.c similarity index 93% rename from gen.subproj/ttyname.c rename to gen/ttyname.c index a07b134..db31a9a 100644 --- a/gen.subproj/ttyname.c +++ b/gen/ttyname.c @@ -63,8 +63,9 @@ #include #include #include +#include -static char buf[sizeof(_PATH_DEV) + MAXNAMLEN] = _PATH_DEV; +static char *buf = NULL; static char *oldttyname __P((int, struct stat *)); char * @@ -80,6 +81,13 @@ ttyname(fd) dev_t dev; } bkey; + if( buf == NULL ) { + buf = malloc(sizeof(_PATH_DEV) + MAXNAMLEN); + if( buf == NULL ) + return NULL; + strcpy(buf, _PATH_DEV); + } + /* Must be a terminal. */ if (ioctl(fd, TIOCGETA, &term) < 0) return (NULL); @@ -114,6 +122,12 @@ oldttyname(fd, sb) register DIR *dp; struct stat dsb; + if( buf == NULL ) { + buf = malloc(sizeof(_PATH_DEV) + MAXNAMLEN); + if( buf == NULL ) + return NULL; + strcpy(buf, _PATH_DEV); + } if ((dp = opendir(_PATH_DEV)) == NULL) return (NULL); diff --git a/gen.subproj/ttyslot.c b/gen/ttyslot.c similarity index 100% rename from gen.subproj/ttyslot.c rename to gen/ttyslot.c diff --git a/gen/tzset.3 b/gen/tzset.3 new file mode 100644 index 0000000..0d718f0 --- /dev/null +++ b/gen/tzset.3 @@ -0,0 +1,327 @@ +.\" Copyright (c) 1989, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Arthur Olson. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)tzset.3 8.2 (Berkeley) 11/17/93 +.\" $FreeBSD: src/lib/libc/gen/tzset.3,v 1.12 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd November 17, 1993 +.Dt TZSET 3 +.Os +.Sh NAME +.Nm tzset , +.Nm tzsetwall +.Nd initialize time conversion information +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In time.h +.Ft void +.Fn tzset void +.Ft void +.Fn tzsetwall void +.Sh DESCRIPTION +The +.Fn tzset +function +initializes time conversion information used by the library routine +.Xr localtime 3 . +The environment variable +.Ev TZ +specifies how this is done. +.Pp +If +.Ev TZ +does not appear in the environment, the best available approximation to +local wall clock time, as specified by the +.Xr tzfile 5 Ns -format +file +.Pa /etc/localtime +is used. +.Pp +If +.Ev TZ +appears in the environment but its value is a null string, Coordinated +Universal Time +.Pq Tn UTC +is used (without leap second correction). +.Pp +If +.Ev TZ +appears in the environment and its value begins with a colon +.Pq Ql \&: , +the rest of its value is used as a pathname of a +.Xr tzfile 5 Ns -format +file from which to read the time conversion information. +If the first character of the pathname is a slash +.Pq Ql / +it is used as +an absolute pathname; otherwise, it is used as a pathname relative to +the system time conversion information directory. +.Pp +If its value does not begin with a colon, it is first used as the pathname +of a file (as described above) from which to read the time conversion +information. +If that file cannot be read, the value is then interpreted as a direct +specification (the format is described below) of the time conversion +information. +.Pp +If the +.Ev TZ +environment variable does not specify a +.Xr tzfile 5 Ns -format +file and cannot be interpreted as a direct specification, +.Tn UTC +is used. +.Pp +The +.Fn tzsetwall +function +sets things up so that +.Xr localtime +returns the best available approximation of local wall clock time. +.Sh SPECIFICATION FORMAT +When +.Ev TZ +is used directly as a specification of the time conversion information, +it must have the following syntax (spaces inserted for clarity): +.Bd -ragged -offset indent +.Em std offset +.Bo +.Em dst +.Bq Em offset +.Bq , Em rule +.Bc +.Ed +.Pp +Where: +.Bl -tag -width std_and_dst -offset indent +.It Em std No and Em dst +Three or more bytes that are the designation for the standard +.Pq Em std +or summer +.Pq Em dst +time zone. Only +.Em std +is required; if +.Em dst +is missing, then summer time does not apply in this locale. +Upper and lowercase letters are explicitly allowed. Any characters +except a leading colon +.Pq Ql \&: , +digits, comma +.Pq Ql \&, , +minus +.Pq Ql \- , +plus +.Pq Ql + , +and +.Tn ASCII +.Dv NUL +are allowed. +.It Em offset +Indicates the value one must add to the local time to arrive at +Coordinated Universal Time. The +.Em offset +has the form: +.Bd -ragged -offset indent +.Sm off +.Em hh Bo +.Em : mm +.Bq Em : ss +.Bc +.Sm on +.Ed +.Pp +The minutes +.Pq Em mm +and seconds +.Pq Em ss +are optional. The hour +.Pq Em hh +is required and may be a single digit. The +.Em offset +following +.Em std +is required. If no +.Em offset +follows +.Em dst , +summer time is assumed to be one hour ahead of standard time. One or +more digits may be used; the value is always interpreted as a decimal +number. The hour must be between zero and 24, and the minutes (and +seconds) \(em if present \(em between zero and 59. If preceded by a +.Pq Ql \- +the time zone shall be east of the Prime Meridian; otherwise it shall be +west (which may be indicated by an optional preceding +.Pq Ql + ) . +.It Em rule +Indicates when to change to and back from summer time. The +.Em rule +has the form: +.Bd -ragged -offset indent +.Em date/time,date/time +.Ed +.Pp +where the first +.Em date +describes when the change from standard to summer time occurs and the +second +.Em date +describes when the change back happens. Each +.Em time +field describes when, in current local time, the change to the other +time is made. +.Pp +The format of +.Em date +is one of the following: +.Bl -tag -width "M.m.n.d" +.It Sy J Em n +The Julian day +.Em n +(1 \*(Le +.Em n +\*(Le 365). +Leap days are not counted; that is, in all years \(em including leap +years \(em February 28 is day 59 and March 1 is day 60. It is +impossible to explicitly refer to the occasional February 29. +.It Em n +The zero-based Julian day +(0 \*(Le +.Em n +\*(Le 365 ) . +Leap days are counted, and it is possible to refer to February 29. +.It Sy M Em m.n.d +The +.Em d Ns 'th +day (0 \*(Le +.Em d +\*(Le 6) +of week +.Em n +of month +.Em m +of the year +(1 \*(Le +.Em n +\*(Le 5), +(1 \*(Le +.Em m +\*(Le 12), +where week 5 means +.Do +the last +.Em d +day in month +.Em m +.Dc +which may occur in either the fourth or the fifth week). Week 1 is the +first week in which the +.Em d Ns 'th +day occurs. Day zero is Sunday. +.Pp +The +.Em time +has the same format as +.Em offset +except that no leading sign +.Pq Ql \- +or +.Pq Ql + +is allowed. The default, if +.Em time +is not given, is +.Sy 02:00:00 . +.El +.Pp +If no +.Em rule +is present in the +.Ev TZ +specification, the rules specified +by the +.Xr tzfile 5 Ns -format +file +.Em posixrules +in the system time conversion information directory are used, with the +standard and summer time offsets from +.Tn UTC +replaced by those specified by +the +.Em offset +values in +.Ev TZ . +.El +.Pp +For compatibility with System V Release 3.1, a semicolon +.Pq Ql \&; +may be used to separate the +.Em rule +from the rest of the specification. +.Sh FILES +.Bl -tag -width /usr/share/zoneinfo/posixrules -compact +.It Pa /etc/localtime +local time zone file +.It Pa /usr/share/zoneinfo +time zone directory +.It Pa /usr/share/zoneinfo/posixrules +rules for +.Tn POSIX Ns -style +.Tn TZ Ns 's +.It Pa /usr/share/zoneinfo/GMT +for +.Tn UTC +leap seconds +.El +.Pp +If the file +.Pa /usr/share/zoneinfo/GMT +does not exist, +.Tn UTC +leap seconds are loaded from +.Pa /usr/share/zoneinfo/posixrules . +.Sh SEE ALSO +.Xr date 1 , +.Xr gettimeofday 2 , +.Xr ctime 3 , +.Xr getenv 3 , +.Xr time 3 , +.Xr tzfile 5 +.Sh HISTORY +The +.Fn tzset +and +.Fn tzsetwall +functions first appeared in +.Bx 4.4 . diff --git a/gen/ualarm.3 b/gen/ualarm.3 new file mode 100644 index 0000000..0f4774f --- /dev/null +++ b/gen/ualarm.3 @@ -0,0 +1,101 @@ +.\" Copyright (c) 1986, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" From: @(#)ualarm.3 8.2 (Berkeley) 4/19/94 +.\" $FreeBSD: src/lib/libc/gen/ualarm.3,v 1.15 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd April 19, 1994 +.Dt UALARM 3 +.Os +.Sh NAME +.Nm ualarm +.Nd schedule signal after specified time +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft u_int +.Fn ualarm "u_int microseconds" "u_int interval" +.Sh DESCRIPTION +.Bf -symbolic +This is a simplified interface to +.Xr setitimer 2 . +.Ef +.Pp +The +.Fn ualarm +function +waits a count of +.Ar microseconds +before asserting the terminating signal +.Dv SIGALRM . +System activity or time used in processing the call may cause a slight +delay. +.Pp +If the +.Fa interval +argument is non-zero, the +.Dv SIGALRM +signal will be sent +to the process every +.Fa interval +microseconds after the timer expires (e.g. after +.Fa value +microseconds have passed). +.Pp +Due to +.Xr setitimer 2 +restriction the maximum number of +.Ar microseconds +and +.Ar interval +is limited to 100000000000000 +(in case this value fit in the unsigned integer). +.Sh RETURN VALUES +When the signal has successfully been caught, +.Fn ualarm +returns the amount of time left on the clock. +.Sh NOTES +A microsecond is 0.000001 seconds. +.Sh SEE ALSO +.Xr getitimer 2 , +.Xr setitimer 2 , +.Xr sigpause 2 , +.Xr sigvec 2 , +.Xr alarm 3 , +.Xr signal 3 , +.Xr sleep 3 , +.Xr usleep 3 +.Sh HISTORY +The +.Fn ualarm +function appeared in +.Bx 4.3 . diff --git a/gen.subproj/ualarm.c b/gen/ualarm.c similarity index 100% rename from gen.subproj/ualarm.c rename to gen/ualarm.c diff --git a/gen/ulimit.c b/gen/ulimit.c new file mode 100644 index 0000000..af68b84 --- /dev/null +++ b/gen/ulimit.c @@ -0,0 +1,32 @@ +#include +#include +#include +#include +#include +#include +#include + +long int ulimit( int cmd, ... ) +{ + va_list ap; + struct rlimit rlim; + + switch (cmd ) { + case UL_GETFSIZE: + if( getrlimit( RLIMIT_FSIZE, &rlim ) < 0 ) + return -1; + return rlim.rlim_cur/512; + case UL_SETFSIZE: + va_start(ap, cmd); + rlim.rlim_cur = 512 * va_arg(ap, long int); + rlim.rlim_max = rlim.rlim_cur; + va_end(ap); + return setrlimit( RLIMIT_FSIZE, &rlim ); + default: + errno = EINVAL; + return -1; + } + /* NOT REACHED */ + errno = EINVAL; + return -1; +} diff --git a/gen/uname.3 b/gen/uname.3 new file mode 100644 index 0000000..85b417d --- /dev/null +++ b/gen/uname.3 @@ -0,0 +1,92 @@ +.\" Copyright (c) 1994 +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)uname.3 8.1 (Berkeley) 1/4/94 +.\" $FreeBSD: src/lib/libc/gen/uname.3,v 1.10 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd January 4, 1994 +.Dt UNAME 3 +.Os +.Sh NAME +.Nm uname +.Nd get system identification +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/utsname.h +.Ft int +.Fn uname "struct utsname *name" +.Sh DESCRIPTION +The +.Fn uname +function stores nul-terminated strings of information identifying +the current system into the structure referenced by +.Fa name . +.Pp +The +.Vt utsname +structure is defined in the +.Aq Pa sys/utsname.h +header file, and contains the following members: +.Bl -tag -width nodenameXXXX -offset indent +.It sysname +Name of the operating system implementation. +.It nodename +Network name of this machine. +.It release +Release level of the operating system. +.It version +Version level of the operating system. +.It machine +Machine hardware platform. +.El +.Sh RETURN VALUES +.Rv -std uname +.Sh ERRORS +The +.Fn uname +function may fail and set +.Va errno +for any of the errors specified for the library functions +.Xr sysctl 3 . +.Sh SEE ALSO +.Xr uname 1 , +.Xr sysctl 3 +.Sh STANDARDS +The +.Fn uname +function conforms to +.St -p1003.1-88 . +.Sh HISTORY +The +.Fn uname +function first appeared in +.Bx 4.4 . diff --git a/gen.subproj/uname.c b/gen/uname.c similarity index 100% rename from gen.subproj/uname.c rename to gen/uname.c diff --git a/gen/unvis.3 b/gen/unvis.3 new file mode 100644 index 0000000..35e36b6 --- /dev/null +++ b/gen/unvis.3 @@ -0,0 +1,196 @@ +.\" Copyright (c) 1989, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)unvis.3 8.2 (Berkeley) 12/11/93 +.\" $FreeBSD: src/lib/libc/gen/unvis.3,v 1.14 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd December 11, 1993 +.Dt UNVIS 3 +.Os +.Sh NAME +.Nm unvis , +.Nm strunvis +.Nd decode a visual representation of characters +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In vis.h +.Ft int +.Fn unvis "char *cp" "int c" "int *astate" "int flag" +.Ft int +.Fn strunvis "char *dst" "const char *src" +.Ft int +.Fn strunvisx "char *dst" "const char *src" "int flag" +.Sh DESCRIPTION +The +.Fn unvis , +.Fn strunvis +and +.Fn strunvisx +functions +are used to decode a visual representation of characters, as produced +by the +.Xr vis 3 +function, back into +the original form. Unvis is called with successive characters in +.Ar c +until a valid +sequence is recognized, at which time the decoded character is +available at the character pointed to by +.Ar cp . +Strunvis decodes the +characters pointed to by +.Ar src +into the buffer pointed to by +.Ar dst . +.Pp +The +.Fn strunvis +function +simply copies +.Ar src +to +.Ar dst , +decoding any escape sequences along the way, +and returns the number of characters placed into +.Ar dst , +or \-1 if an +invalid escape sequence was detected. The size of +.Ar dst +should be +equal to the size of +.Ar src +(that is, no expansion takes place during +decoding). +.Pp +The +.Fn strunvisx +function does the same as the +.Fn strunvis +function, +but it allows you to add a flag that specifies the style the string +.Ar src +is encoded with. +Currently, the only supported flag is +.Dv VIS_HTTPSTYLE . +.Pp +The +.Fn unvis +function +implements a state machine that can be used to decode an arbitrary +stream of bytes. All state associated with the bytes being decoded +is stored outside the +.Fn unvis +function (that is, a pointer to the state is passed in), so +calls decoding different streams can be freely intermixed. To +start decoding a stream of bytes, first initialize an integer +to zero. Call +.Fn unvis +with each successive byte, along with a pointer +to this integer, and a pointer to a destination character. +The +.Fn unvis +function +has several return codes that must be handled properly. They are: +.Bl -tag -width UNVIS_VALIDPUSH +.It Li \&0 (zero) +Another character is necessary; nothing has been recognized yet. +.It Dv UNVIS_VALID +A valid character has been recognized and is available at the location +pointed to by cp. +.It Dv UNVIS_VALIDPUSH +A valid character has been recognized and is available at the location +pointed to by cp; however, the character currently passed in should +be passed in again. +.It Dv UNVIS_NOCHAR +A valid sequence was detected, but no character was produced. This +return code is necessary to indicate a logical break between characters. +.It Dv UNVIS_SYNBAD +An invalid escape sequence was detected, or the decoder is in an +unknown state. The decoder is placed into the starting state. +.El +.Pp +When all bytes in the stream have been processed, call +.Fn unvis +one more time with +.Ar flag +set to +.Dv UNVIS_END +to extract any remaining character (the character passed in is ignored). +.Pp +The +.Ar flag +argument is also used to specify the encoding style of the source. +If set to +.Dv VIS_HTTPSTYLE , +.Fn unvis +will decode URI strings as specified in RFC 1808. +.Pp +The following code fragment illustrates a proper use of +.Fn unvis . +.Bd -literal -offset indent +int state = 0; +char out; + +while ((ch = getchar()) != EOF) { +again: + switch(unvis(&out, ch, &state, 0)) { + case 0: + case UNVIS_NOCHAR: + break; + case UNVIS_VALID: + (void) putchar(out); + break; + case UNVIS_VALIDPUSH: + (void) putchar(out); + goto again; + case UNVIS_SYNBAD: + (void)fprintf(stderr, "bad sequence!\en"); + exit(1); + } +} +if (unvis(&out, (char)0, &state, UNVIS_END) == UNVIS_VALID) + (void) putchar(out); +.Ed +.Sh SEE ALSO +.Xr vis 1 , +.Xr vis 3 +.Rs +.%A R. Fielding +.%T Relative Uniform Resource Locators +.%O RFC1808 +.Re +.Sh HISTORY +The +.Fn unvis +function +first appeared in +.Bx 4.4 . diff --git a/gen.subproj/unvis.c b/gen/unvis.c similarity index 100% rename from gen.subproj/unvis.c rename to gen/unvis.c diff --git a/gen/usleep.3 b/gen/usleep.3 new file mode 100644 index 0000000..058c7d5 --- /dev/null +++ b/gen/usleep.3 @@ -0,0 +1,84 @@ +.\" Copyright (c) 1986, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)usleep.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/usleep.3,v 1.10.2.7 2001/12/14 18:33:51 ru Exp $ +.\" +.Dd February 13, 1998 +.Dt USLEEP 3 +.Os +.Sh NAME +.Nm usleep +.Nd suspend process execution for an interval measured in microseconds +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft int +.Fn usleep "unsigned int microseconds" +.Sh DESCRIPTION +The +.Fn usleep +function suspends execution of the calling process until either +.Fa microseconds +microseconds have elapsed or a signal is delivered to the process and its +action is to invoke a signal-catching function or to terminate the +process. +System activity may lengthen the sleep by an indeterminate amount. +.Pp +This function is implemented using +.Xr nanosleep 2 +by pausing for +.Fa microseconds +microseconds or until a signal occurs. +Consequently, in this implementation, +sleeping has no effect on the state of process timers, +and there is no special handling for SIGALRM. +.Sh RETURN VALUES +.Rv -std usleep +.Sh ERRORS +The +.Fn usleep +function +will fail if: +.Bl -tag -width Er +.It Bq Er EINTR +A signal was delivered to the process and its +action was to invoke a signal-catching function. +.El +.Sh SEE ALSO +.Xr nanosleep 2 , +.Xr sleep 3 +.Sh HISTORY +The +.Fn usleep +function appeared in +.Bx 4.3 . diff --git a/gen/usleep.c b/gen/usleep.c new file mode 100644 index 0000000..15004e1 --- /dev/null +++ b/gen/usleep.c @@ -0,0 +1,54 @@ +/* + * Copyright (c) 1989, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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) +#if 0 +static char sccsid[] = "@(#)usleep.c 8.1 (Berkeley) 6/4/93"; +#endif +static char rcsid[] = + "$FreeBSD: src/lib/libc/gen/usleep.c,v 1.25 2000/01/27 23:06:22 jasone Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include + +int +usleep(useconds) + unsigned int useconds; +{ + struct timespec time_to_sleep; + + time_to_sleep.tv_nsec = (useconds % 1000000) * 1000; + time_to_sleep.tv_sec = useconds / 1000000; + return (nanosleep(&time_to_sleep, NULL)); +} diff --git a/gen/utime.3 b/gen/utime.3 new file mode 100644 index 0000000..deb5336 --- /dev/null +++ b/gen/utime.3 @@ -0,0 +1,91 @@ +.\" Copyright (c) 1980, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)utime.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/utime.3,v 1.10 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt UTIME 3 +.Os +.Sh NAME +.Nm utime +.Nd set file times +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In utime.h +.Ft int +.Fn utime "const char *file" "const struct utimbuf *timep" +.Sh DESCRIPTION +.Bf -symbolic +This interface is obsoleted by +.Xr utimes 2 . +.Ef +.Pp +The +.Fn utime +function sets the access and modification times of the named file from +the structures in the argument array +.Fa timep . +.Pp +If the times are specified (the +.Fa timep +argument is +.Pf non- Dv NULL ) +the caller must be the owner of the file or be the super-user. +.Pp +If the times are not specified (the +.Fa timep +argument is +.Dv NULL ) +the caller must be the owner of the file, have permission to write +the file, or be the super-user. +.Sh ERRORS +The +.Fn utime +function may fail and set +.Va errno +for any of the errors specified for the library function +.Xr utimes 2 . +.Sh SEE ALSO +.Xr stat 2 , +.Xr utimes 2 +.Sh HISTORY +A +.Fn utime +function appeared in +.At v7 . +.Sh STANDARDS +The +.Fn utime +function conforms to +.St -p1003.1-88 . diff --git a/gen.subproj/utime.c b/gen/utime.c similarity index 100% rename from gen.subproj/utime.c rename to gen/utime.c diff --git a/gen/valloc.3 b/gen/valloc.3 new file mode 100644 index 0000000..051922b --- /dev/null +++ b/gen/valloc.3 @@ -0,0 +1,74 @@ +.\" Copyright (c) 1980, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)valloc.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/gen/valloc.3,v 1.9 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt VALLOC 3 +.Os +.Sh NAME +.Nm valloc +.Nd aligned memory allocation function +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft void * +.Fn valloc "size_t size" +.Sh DESCRIPTION +.Bf -symbolic +The +.Fn valloc +function +allocates +.Fa size +bytes aligned on a page boundary. +It is implemented by calling +.Xr malloc 3 +with a slightly larger request, saving the true beginning of the block +allocated, and returning a properly aligned pointer. +.Sh RETURN VALUES +The +.Fn valloc +function returns +a pointer to the allocated space if successful; otherwise +a null pointer is returned +.Sh HISTORY +The +.Fn valloc +function appeared in +.Bx 3.0 . +.Sh BUGS +A +.Em vfree +function +has not been implemented. diff --git a/gen/vis.3 b/gen/vis.3 new file mode 100644 index 0000000..cd5f307 --- /dev/null +++ b/gen/vis.3 @@ -0,0 +1,277 @@ +.\" Copyright (c) 1989, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" From: @(#)vis.3 8.1 (Berkeley) 6/9/93 +.\" $FreeBSD: src/lib/libc/gen/vis.3,v 1.18 2001/10/01 16:08:51 ru Exp $ +.\" +.Dd July 25, 1996 +.Dt VIS 3 +.Os +.Sh NAME +.Nm vis +.Nd visually encode characters +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In vis.h +.Ft char * +.Fn vis "char *dst" "int c" "int flag" "int nextc" +.Ft int +.Fn strvis "char *dst" "const char *src" "int flag" +.Ft int +.Fn strvisx "char *dst" "const char *src" "size_t len" "int flag" +.Sh DESCRIPTION +The +.Fn vis +function +copies into +.Fa dst +a string which represents the character +.Fa c . +If +.Fa c +needs no encoding, it is copied in unaltered. The string is +null terminated, and a pointer to the end of the string is +returned. The maximum length of any encoding is four +characters (not including the trailing +.Dv NUL ) ; +thus, when +encoding a set of characters into a buffer, the size of the buffer should +be four times the number of characters encoded, plus one for the trailing +.Dv NUL . +The flag parameter is used for altering the default range of +characters considered for encoding and for altering the visual +representation. +The additional character, +.Fa nextc , +is only used when selecting the +.Dv VIS_CSTYLE +encoding format (explained below). +.Pp +The +.Fn strvis +and +.Fn strvisx +functions copy into +.Fa dst +a visual representation of +the string +.Fa src . +The +.Fn strvis +function encodes characters from +.Fa src +up to the +first +.Dv NUL . +The +.Fn strvisx +function encodes exactly +.Fa len +characters from +.Fa src +(this +is useful for encoding a block of data that may contain +.Dv NUL Ns 's ) . +Both forms +.Dv NUL +terminate +.Fa dst . +The size of +.Fa dst +must be four times the number +of characters encoded from +.Fa src +(plus one for the +.Dv NUL ) . +Both +forms return the number of characters in dst (not including +the trailing +.Dv NUL ) . +.Pp +The encoding is a unique, invertible representation composed entirely of +graphic characters; it can be decoded back into the original form using +the +.Xr unvis 3 +or +.Xr strunvis 3 +functions. +.Pp +There are two parameters that can be controlled: the range of +characters that are encoded, and the type +of representation used. +By default, all non-graphic characters +except space, tab, and newline are encoded. +(See +.Xr isgraph 3 . ) +The following flags +alter this: +.Bl -tag -width VIS_WHITEX +.It Dv VIS_SP +Also encode space. +.It Dv VIS_TAB +Also encode tab. +.It Dv VIS_NL +Also encode newline. +.It Dv VIS_WHITE +Synonym for +.Dv VIS_SP +\&| +.Dv VIS_TAB +\&| +.Dv VIS_NL . +.It Dv VIS_SAFE +Only encode "unsafe" characters. Unsafe means control +characters which may cause common terminals to perform +unexpected functions. Currently this form allows space, +tab, newline, backspace, bell, and return - in addition +to all graphic characters - unencoded. +.El +.Pp +There are four forms of encoding. +Most forms use the backslash character +.Ql \e +to introduce a special +sequence; two backslashes are used to represent a real backslash. +These are the visual formats: +.Bl -tag -width VIS_HTTPSTYLE +.It (default) +Use an +.Ql M +to represent meta characters (characters with the 8th +bit set), and use carat +.Ql ^ +to represent control characters see +.Pf ( Xr iscntrl 3 ) . +The following formats are used: +.Bl -tag -width xxxxx +.It Dv \e^C +Represents the control character +.Ql C . +Spans characters +.Ql \e000 +through +.Ql \e037 , +and +.Ql \e177 +(as +.Ql \e^? ) . +.It Dv \eM-C +Represents character +.Ql C +with the 8th bit set. +Spans characters +.Ql \e241 +through +.Ql \e376 . +.It Dv \eM^C +Represents control character +.Ql C +with the 8th bit set. +Spans characters +.Ql \e200 +through +.Ql \e237 , +and +.Ql \e377 +(as +.Ql \eM^? ) . +.It Dv \e040 +Represents +.Tn ASCII +space. +.It Dv \e240 +Represents Meta-space. +.El +.Pp +.It Dv VIS_CSTYLE +Use C-style backslash sequences to represent standard non-printable +characters. +The following sequences are used to represent the indicated characters: +.Bd -unfilled -offset indent +.Li \ea Tn - BEL No (007) +.Li \eb Tn - BS No (010) +.Li \ef Tn - NP No (014) +.Li \en Tn - NL No (012) +.Li \er Tn - CR No (015) +.Li \et Tn - HT No (011) +.Li \ev Tn - VT No (013) +.Li \e0 Tn - NUL No (000) +.Ed +.Pp +When using this format, the nextc parameter is looked at to determine +if a +.Dv NUL +character can be encoded as +.Ql \e0 +instead of +.Ql \e000 . +If +.Fa nextc +is an octal digit, the latter representation is used to +avoid ambiguity. +.It Dv VIS_HTTPSTYLE +Use URI encoding as described in RFC 1808. +The form is +.Ql %dd +where +.Em d +represents a hexadecimal digit. +.It Dv VIS_OCTAL +Use a three digit octal sequence. The form is +.Ql \eddd +where +.Em d +represents an octal digit. +.El +.Pp +There is one additional flag, +.Dv VIS_NOSLASH , +which inhibits the +doubling of backslashes and the backslash before the default +format (that is, control characters are represented by +.Ql ^C +and +meta characters as +.Ql M-C ) . +With this flag set, the encoding is +ambiguous and non-invertible. +.Sh SEE ALSO +.Xr unvis 1 , +.Xr unvis 3 +.Rs +.%A R. Fielding +.%T Relative Uniform Resource Locators +.%O RFC1808 +.Re +.Sh HISTORY +These functions first appeared in +.Bx 4.4 . diff --git a/gen.subproj/vis.c b/gen/vis.c similarity index 100% rename from gen.subproj/vis.c rename to gen/vis.c diff --git a/gen.subproj/wait.c b/gen/wait.c similarity index 100% rename from gen.subproj/wait.c rename to gen/wait.c diff --git a/gen.subproj/wait3.c b/gen/wait3.c similarity index 100% rename from gen.subproj/wait3.c rename to gen/wait3.c diff --git a/gen.subproj/waitpid.c b/gen/waitpid.c similarity index 100% rename from gen.subproj/waitpid.c rename to gen/waitpid.c diff --git a/gen.subproj/zone.c b/gen/zone.c similarity index 100% rename from gen.subproj/zone.c rename to gen/zone.c diff --git a/gmon/Makefile.inc b/gmon/Makefile.inc new file mode 100644 index 0000000..1e69c1d --- /dev/null +++ b/gmon/Makefile.inc @@ -0,0 +1,22 @@ +# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 +# $FreeBSD: src/lib/libc/gmon/Makefile.inc,v 1.8 2001/03/27 17:26:47 ru Exp $ + +# gmon sources +.PATH: ${.CURDIR}/gmon + +SRCS+= gmon.c + +#.if ${LIB} == "c" +#MAN+= moncontrol.3 +# +#MLINKS+=moncontrol.3 monstartup.3 +#.endif + +# mcount cannot be compiled with profiling +gmon.po: + ${CC} -O -pipe -arch ${MACHINE_ARCH} -Wmost -g -fno-common \ + -no-cpp-precomp -force_cpusubtype_ALL -I${.CURDIR}/include \ + -I${.CURDIR}/include/objc -c ${.CURDIR}/gmon/gmon.c -o gmon.po + +#gmon.po: gmon.o +# cp gmon.o gmon.po diff --git a/gen.subproj/gmon.c b/gmon/gmon.c similarity index 100% rename from gen.subproj/gmon.c rename to gmon/gmon.c diff --git a/headers.subproj/Makefile b/headers.subproj/Makefile deleted file mode 100644 index 4c2346e..0000000 --- a/headers.subproj/Makefile +++ /dev/null @@ -1,53 +0,0 @@ -# -# Generated by the Apple Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = headers - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -HFILES = asm.h crt_externs.h libc.h monitor.h NSSystemDirectories.h\ - standards.h - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -NEXTSTEP_INSTALLDIR = /Local/Developer/System -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - -PUBLIC_HEADERS = crt_externs.h libc.h monitor.h NSSystemDirectories.h\ - standards.h - - - -NEXTSTEP_BUILD_OUTPUT_DIR = /Local/Public/SandBox/$(USER)/BUILD/$(NAME) - -NEXTSTEP_PUBLIC_HEADERS_DIR = /usr/include - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/headers.subproj/Makefile.postamble b/headers.subproj/Makefile.postamble deleted file mode 100644 index df76c31..0000000 --- a/headers.subproj/Makefile.postamble +++ /dev/null @@ -1,5 +0,0 @@ -$(DSTROOT)$(PRIVATE_HDR_INSTALLDIR)$(MY_PRIVATE_HEADER_DIR_SUFFIX): - $(MKDIRS) $@ - -my_installhdrs: $(DSTROOT)$(PRIVATE_HDR_INSTALLDIR)$(MY_PRIVATE_HEADER_DIR_SUFFIX) - $(SILENT) $(FASTCP) $(MY_PRIVATE_HEADERS) $(DSTROOT)$(PRIVATE_HDR_INSTALLDIR)$(MY_PRIVATE_HEADER_DIR_SUFFIX) diff --git a/headers.subproj/Makefile.preamble b/headers.subproj/Makefile.preamble deleted file mode 100644 index 1a55329..0000000 --- a/headers.subproj/Makefile.preamble +++ /dev/null @@ -1,4 +0,0 @@ -MY_PRIVATE_HEADERS = asm.h -PUBLIC_HEADER_DIR_SUFFIX = -MY_PRIVATE_HEADER_DIR_SUFFIX = /machine -AFTER_INSTALLHDRS += my_installhdrs diff --git a/headers.subproj/PB.project b/headers.subproj/PB.project deleted file mode 100644 index c329ba0..0000000 --- a/headers.subproj/PB.project +++ /dev/null @@ -1,41 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - H_FILES = ( - asm.h, - crt_externs.h, - libc.h, - monitor.h, - NSSystemDirectories.h, - standards.h - ); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble); - PRECOMPILED_HEADERS = (); - PROJECT_HEADERS = (); - PUBLIC_HEADERS = ( - crt_externs.h, - libc.h, - monitor.h, - NSSystemDirectories.h, - standards.h - ); - SUBPROJECTS = (); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDDIR = "/Local/Public/SandBox/$(USER)/BUILD/$(NAME)"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_INSTALLDIR = /Local/Developer/System; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - NEXTSTEP_PUBLICHEADERSDIR = /usr/include; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = headers; - PROJECTTYPE = Component; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/i386/gen/Makefile.inc b/i386/gen/Makefile.inc new file mode 100644 index 0000000..ed150c0 --- /dev/null +++ b/i386/gen/Makefile.inc @@ -0,0 +1,5 @@ +SRCS+= abs.c ecvt.c memcpy.s strcat.c strncat.c \ + bcmp.c ffs.c memmove.s strcmp.c strncmp.c \ + bcopy.s insque.c remque.c strcpy.c strncpy.c \ + bzero.s isinf.c setjmperr.c strlen.c mcount.s \ + bcopy_init.c diff --git a/gen.subproj/i386.subproj/abs.c b/i386/gen/abs.c similarity index 100% rename from gen.subproj/i386.subproj/abs.c rename to i386/gen/abs.c diff --git a/gen.subproj/i386.subproj/bcmp.c b/i386/gen/bcmp.c similarity index 100% rename from gen.subproj/i386.subproj/bcmp.c rename to i386/gen/bcmp.c diff --git a/i386/gen/bcopy.s b/i386/gen/bcopy.s new file mode 100644 index 0000000..bcf63b2 --- /dev/null +++ b/i386/gen/bcopy.s @@ -0,0 +1,123 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from locore.s. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + */ + +#include + + /* + * (ov)bcopy (src,dst,cnt) + * ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800 + */ + +TEXT +#ifdef MEMCOPY +LEAF(_memcpy,0) +#else +#ifdef MEMMOVE +LEAF(_memmove,0) +#else +LEAF(_bcopy,0) +#endif +#endif + pushl %esi + pushl %edi +#if defined(MEMCOPY) || defined(MEMMOVE) + movl 12(%esp),%edi + movl 16(%esp),%esi +#else + movl 12(%esp),%esi + movl 16(%esp),%edi +#endif + movl 20(%esp),%ecx + movl %edi,%eax + subl %esi,%eax + cmpl %ecx,%eax /* overlapping? */ + jb 1f + cld /* nope, copy forwards. */ + shrl $2,%ecx /* copy by words */ + rep + movsl + movl 20(%esp),%ecx + andl $3,%ecx /* any bytes left? */ + rep + movsb +#if defined(MEMCOPY) || defined(MEMMOVE) + movl 12(%esp),%eax +#endif + popl %edi + popl %esi + ret +1: + addl %ecx,%edi /* copy backwards. */ + addl %ecx,%esi + std + andl $3,%ecx /* any fractional bytes? */ + decl %edi + decl %esi + rep + movsb + movl 20(%esp),%ecx /* copy remainder by words */ + shrl $2,%ecx + subl $3,%esi + subl $3,%edi + rep + movsl +#if defined(MEMCOPY) || defined(MEMMOVE) + movl 12(%esp),%eax +#endif + popl %edi + popl %esi + cld +END(bcopy) diff --git a/i386/gen/bcopy_init.c b/i386/gen/bcopy_init.c new file mode 100644 index 0000000..d10eadc --- /dev/null +++ b/i386/gen/bcopy_init.c @@ -0,0 +1,9 @@ +/* Null function. This actually does something on ppc, and this is needed + * for the i386 version to link. + */ +int _cpu_capabilities; + +void _bcopy_initialize() +{ + return; +} diff --git a/i386/gen/bzero.s b/i386/gen/bzero.s new file mode 100644 index 0000000..473e991 --- /dev/null +++ b/i386/gen/bzero.s @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2002 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1993 Winning Strategies, Inc. + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Winning Strategies, Inc. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software withough specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include + +/* + * bzero (void *b, size_t len) + * write len zero bytes to the string b. + * + * Written by: + * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. + */ + +TEXT +LEAF(_bzero,0) + pushl %edi + pushl %ebx + movl 12(%esp),%edi + movl 16(%esp),%ecx + + cld /* set fill direction forward */ + xorl %eax,%eax /* set fill data to 0 */ + + /* + * if the string is too short, it's really not worth the overhead + * of aligning to word boundries, etc. So we jump to a plain + * unaligned set. + */ + cmpl $0x0f,%ecx + jle L1 + + movl %edi,%edx /* compute misalignment */ + negl %edx + andl $3,%edx + movl %ecx,%ebx + subl %edx,%ebx + + movl %edx,%ecx /* zero until word aligned */ + rep + stosb + + movl %ebx,%ecx /* zero by words */ + shrl $2,%ecx + rep + stosl + + movl %ebx,%ecx + andl $3,%ecx /* zero remainder by bytes */ +L1: rep + stosb + + popl %ebx + popl %edi +END(_bzero) diff --git a/gen.subproj/i386.subproj/ecvt.c b/i386/gen/ecvt.c similarity index 100% rename from gen.subproj/i386.subproj/ecvt.c rename to i386/gen/ecvt.c diff --git a/gen.subproj/i386.subproj/ffs.c b/i386/gen/ffs.c similarity index 100% rename from gen.subproj/i386.subproj/ffs.c rename to i386/gen/ffs.c diff --git a/gen.subproj/i386.subproj/insque.c b/i386/gen/insque.c similarity index 100% rename from gen.subproj/i386.subproj/insque.c rename to i386/gen/insque.c diff --git a/gen.subproj/i386.subproj/isinf.c b/i386/gen/isinf.c similarity index 72% rename from gen.subproj/i386.subproj/isinf.c rename to i386/gen/isinf.c index 838b17b..cbc81ee 100644 --- a/gen.subproj/i386.subproj/isinf.c +++ b/i386/gen/isinf.c @@ -23,6 +23,21 @@ * Copyright (c) 1987 NeXT, INC. */ +struct words { +#if defined(__BIG_ENDIAN__) + unsigned int hi; + unsigned int lo; +#else + unsigned int lo; + unsigned int hi; +#endif +}; + +union double_words { + double d; + struct words w; +}; + /* * isinf -- returns 1 if positive IEEE infinity, -1 if negative * IEEE infinity, 0 otherwise. @@ -31,12 +46,11 @@ int isinf(d) double d; { - int i; - - i = *((int *)&d + 1); - if (i == 0x7ff00000) - return(1); - if (i == 0xfff00000) - return(-1); - return(0); + union double_words dw; + dw.d = d; + if (dw.w.hi == 0x7ff00000) + return(1); + if (dw.w.hi == 0xfff00000) + return(-1); + return(0); } diff --git a/gen.subproj/i386.subproj/mcount.s b/i386/gen/mcount.s similarity index 100% rename from gen.subproj/i386.subproj/mcount.s rename to i386/gen/mcount.s diff --git a/gen.subproj/i386.subproj/memcpy.c b/i386/gen/memcpy.s similarity index 98% rename from gen.subproj/i386.subproj/memcpy.c rename to i386/gen/memcpy.s index 6b5774f..b6c5f3e 100644 --- a/gen.subproj/i386.subproj/memcpy.c +++ b/i386/gen/memcpy.s @@ -29,4 +29,4 @@ * Created for m98k. */ #define MEMCOPY -#include "bcopy.c" +#include "bcopy.s" diff --git a/gen.subproj/i386.subproj/memmove.c b/i386/gen/memmove.s similarity index 98% rename from gen.subproj/i386.subproj/memmove.c rename to i386/gen/memmove.s index c907093..277f6e7 100644 --- a/gen.subproj/i386.subproj/memmove.c +++ b/i386/gen/memmove.s @@ -29,4 +29,4 @@ * Created for m98k. */ #define MEMMOVE -#include "bcopy.c" +#include "bcopy.s" diff --git a/gen.subproj/i386.subproj/remque.c b/i386/gen/remque.c similarity index 100% rename from gen.subproj/i386.subproj/remque.c rename to i386/gen/remque.c diff --git a/gen.subproj/i386.subproj/setjmperr.c b/i386/gen/setjmperr.c similarity index 100% rename from gen.subproj/i386.subproj/setjmperr.c rename to i386/gen/setjmperr.c diff --git a/gen.subproj/i386.subproj/strcat.c b/i386/gen/strcat.c similarity index 100% rename from gen.subproj/i386.subproj/strcat.c rename to i386/gen/strcat.c diff --git a/stdio.subproj/fvwrite.h b/i386/gen/strcmp.c similarity index 84% rename from stdio.subproj/fvwrite.h rename to i386/gen/strcmp.c index 7b021ce..edb6235 100644 --- a/stdio.subproj/fvwrite.h +++ b/i386/gen/strcmp.c @@ -55,21 +55,28 @@ * SUCH DAMAGE. */ +#if !defined(hppa) && !defined(ppc) + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)strcmp.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include + /* - * I/O descriptors for __sfvwrite(). + * Compare strings. */ -struct __siov { - void *iov_base; - size_t iov_len; -}; -struct __suio { - struct __siov *uio_iov; - int uio_iovcnt; - int uio_resid; -}; +int +strcmp(s1, s2) + register const char *s1, *s2; +{ + while (*s1 == *s2++) + if (*s1++ == 0) + return (0); + return (*(unsigned char *)s1 - *(unsigned char *)--s2); +} -#if __STDC__ || c_plusplus -extern int __sfvwrite(FILE *, struct __suio *); #else -extern int __sfvwrite(); -#endif +#warning ----------- Check for implementation of strcmp() ----------- ! +#endif /* !defined(hppa) */ diff --git a/gen.subproj/i386.subproj/strcpy.c b/i386/gen/strcpy.c similarity index 100% rename from gen.subproj/i386.subproj/strcpy.c rename to i386/gen/strcpy.c diff --git a/gen.subproj/i386.subproj/strlen.c b/i386/gen/strlen.c similarity index 100% rename from gen.subproj/i386.subproj/strlen.c rename to i386/gen/strlen.c diff --git a/gen.subproj/i386.subproj/strncat.c b/i386/gen/strncat.c similarity index 100% rename from gen.subproj/i386.subproj/strncat.c rename to i386/gen/strncat.c diff --git a/gen.subproj/i386.subproj/strncmp.c b/i386/gen/strncmp.c similarity index 100% rename from gen.subproj/i386.subproj/strncmp.c rename to i386/gen/strncmp.c diff --git a/gen.subproj/i386.subproj/strncpy.c b/i386/gen/strncpy.c similarity index 100% rename from gen.subproj/i386.subproj/strncpy.c rename to i386/gen/strncpy.c diff --git a/i386/mach/Makefile.inc b/i386/mach/Makefile.inc new file mode 100644 index 0000000..bf4f67b --- /dev/null +++ b/i386/mach/Makefile.inc @@ -0,0 +1 @@ +SRCS += mach_absolute_time.c diff --git a/i386/mach/mach_absolute_time.c b/i386/mach/mach_absolute_time.c new file mode 100644 index 0000000..86257b0 --- /dev/null +++ b/i386/mach/mach_absolute_time.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +#if !defined(__ppc__) +#include +#include + +extern mach_port_t clock_port; + +uint64_t mach_absolute_time(void) { + mach_timespec_t now; + (void)clock_get_time(clock_port, &now); + return (uint64_t)now.tv_sec * NSEC_PER_SEC + now.tv_nsec; +} +#endif diff --git a/sys.subproj/i386.subproj/ATPgetreq.s b/i386/sys/ATPgetreq.s similarity index 100% rename from sys.subproj/i386.subproj/ATPgetreq.s rename to i386/sys/ATPgetreq.s diff --git a/sys.subproj/i386.subproj/ATPgetrsp.s b/i386/sys/ATPgetrsp.s similarity index 100% rename from sys.subproj/i386.subproj/ATPgetrsp.s rename to i386/sys/ATPgetrsp.s diff --git a/sys.subproj/i386.subproj/ATPsndreq.s b/i386/sys/ATPsndreq.s similarity index 100% rename from sys.subproj/i386.subproj/ATPsndreq.s rename to i386/sys/ATPsndreq.s diff --git a/sys.subproj/i386.subproj/ATPsndrsp.s b/i386/sys/ATPsndrsp.s similarity index 100% rename from sys.subproj/i386.subproj/ATPsndrsp.s rename to i386/sys/ATPsndrsp.s diff --git a/sys.subproj/i386.subproj/ATgetmsg.s b/i386/sys/ATgetmsg.s similarity index 100% rename from sys.subproj/i386.subproj/ATgetmsg.s rename to i386/sys/ATgetmsg.s diff --git a/sys.subproj/i386.subproj/ATputmsg.s b/i386/sys/ATputmsg.s similarity index 100% rename from sys.subproj/i386.subproj/ATputmsg.s rename to i386/sys/ATputmsg.s diff --git a/sys.subproj/i386.subproj/ATsocket.s b/i386/sys/ATsocket.s similarity index 100% rename from sys.subproj/i386.subproj/ATsocket.s rename to i386/sys/ATsocket.s diff --git a/i386/sys/Makefile.inc b/i386/sys/Makefile.inc new file mode 100644 index 0000000..1d046d1 --- /dev/null +++ b/i386/sys/Makefile.inc @@ -0,0 +1,189 @@ +SRCS+= ATPgetreq.s \ + ATPgetrsp.s \ + ATPsndreq.s \ + ATPsndrsp.s \ + ATgetmsg.s \ + ATputmsg.s \ + ATsocket.s \ + _exit.s \ + _getlogin.s \ + _pthread_kill.s \ + _setjmp.s \ + _setlogin.s \ + _sysctl.s \ + accept.s \ + access.s \ + acct.s \ + add_profil.s \ + adjtime.s \ + bind.s \ + cerror.s \ + chdir.s \ + checkuseraccess.s \ + chflags.s \ + chmod.s \ + chown.s \ + chroot.s \ + close.s \ + connect.s \ + dup.s \ + dup2.s \ + exchangedata.s \ + execve.s \ + fchdir.s \ + fchflags.s \ + fchmod.s \ + fchown.s \ + fcntl.s \ + flock.s \ + fork.s \ + fpathconf.s \ + fstat.s \ + fstatfs.s \ + fstatv.s \ + fsync.s \ + ftruncate.s \ + futimes.s \ + getattrlist.s \ + getdirentries.s \ + getdirentriesattr.s \ + getegid.s \ + geteuid.s \ + getfh.s \ + getfsstat.s \ + getgid.s \ + getgroups.s \ + getitimer.s \ + getpeername.s \ + getpgrp.s \ + getpid.s \ + getppid.s \ + getpriority.s \ + getrlimit.s \ + getrusage.s \ + getpgid.s \ + getsid.s \ + getsockname.s \ + getsockopt.s \ + getuid.s \ + ioctl.s \ + issetugid.s \ + kill.s \ + ktrace.s \ + link.s \ + listen.s \ + load_shared_file.s \ + lseek.s \ + lstat.s \ + lstatv.s \ + madvise.s \ + mincore.s \ + minherit.s \ + mkcomplex.s \ + mkdir.s \ + mkfifo.s \ + mknod.s \ + mlock.s \ + mlockall.s \ + mmap.s \ + mount.s \ + mprotect.s \ + msgctl.s \ + msgget.s \ + msgrcv.s \ + msgsnd.s \ + msgsys.s \ + msync.s \ + munlock.s \ + munlockall.s \ + munmap.s \ + new_system_shared_regions.s \ + nfssvc.s \ + open.s \ + pathconf.s \ + pipe.s \ + pread.s \ + posix_madvise.s \ + profil.s \ + pwrite.s \ + ptrace.s \ + pthread_sigmask.s \ + quota.s \ + quotactl.s \ + read.s \ + readlink.s \ + readv.s \ + reboot.s \ + recvfrom.s \ + recvmsg.s \ + rename.s \ + reset_shared_file.s \ + revoke.s \ + rmdir.s \ + searchfs.s \ + select.s \ + sem_close.s \ + sem_destroy.s \ + sem_getvalue.s \ + sem_init.s \ + sem_open.s \ + sem_post.s \ + sem_trywait.s \ + sem_unlink.s \ + sem_wait.s \ + semconfig.s \ + semctl.s \ + semget.s \ + semop.s \ + semsys.s \ + sendmsg.s \ + sendto.s \ + setattrlist.s \ + setegid.s \ + seteuid.s \ + setgid.s \ + setgroups.s \ + setitimer.s \ + setjmp.s \ + setpgid.s \ + setpriority.s \ + setprivexec.s \ + setquota.s \ + setrlimit.s \ + setsid.s \ + setsockopt.s \ + settimeofday.s \ + setuid.s \ + shm_open.s \ + shm_unlink.s \ + shmat.s \ + shmctl.s \ + shmdt.s \ + shmget.s \ + shmsys.s \ + shutdown.s \ + sigaltstack.s \ + sigpending.s \ + sigprocmask.s \ + sigreturn.s \ + sigwait.s \ + socket.s \ + socketpair.s \ + stat.s \ + statfs.s \ + statv.s \ + swapon.s \ + symlink.s \ + sync.s \ + syscall.s \ + systable.s \ + truncate.s \ + umask.s \ + undelete.s \ + unlink.s \ + unmount.s \ + utimes.s \ + vfork.s \ + wait4.s \ + write.s \ + writev.s diff --git a/sys.subproj/i386.subproj/SYS.h b/i386/sys/SYS.h similarity index 97% rename from sys.subproj/i386.subproj/SYS.h rename to i386/sys/SYS.h index c35bf0c..7da1969 100644 --- a/sys.subproj/i386.subproj/SYS.h +++ b/i386/sys/SYS.h @@ -48,7 +48,7 @@ #define UNIX_SYSCALL(name, nargs) \ .globl cerror ;\ LEAF(_##name, 0) ;\ - movl $SYS_##name, %eax ;\ + movl $ SYS_##name, %eax ;\ UNIX_SYSCALL_TRAP ;\ jnb 2f ;\ BRANCH_EXTERN(cerror) ;\ @@ -56,7 +56,7 @@ LEAF(_##name, 0) ;\ #define UNIX_SYSCALL_NONAME(name, nargs) \ .globl cerror ;\ - movl $SYS_##name, %eax ;\ + movl $ SYS_##name, %eax ;\ UNIX_SYSCALL_TRAP ;\ jnb 2f ;\ BRANCH_EXTERN(cerror) ;\ diff --git a/sys.subproj/i386.subproj/_exit.s b/i386/sys/_exit.s similarity index 100% rename from sys.subproj/i386.subproj/_exit.s rename to i386/sys/_exit.s diff --git a/sys.subproj/i386.subproj/_getlogin.s b/i386/sys/_getlogin.s similarity index 100% rename from sys.subproj/i386.subproj/_getlogin.s rename to i386/sys/_getlogin.s diff --git a/i386/sys/_pthread_kill.s b/i386/sys/_pthread_kill.s new file mode 100644 index 0000000..c45b088 --- /dev/null +++ b/i386/sys/_pthread_kill.s @@ -0,0 +1,28 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved + */ +#include "SYS.h" + +UNIX_SYSCALL(__pthread_kill, 2) + ret diff --git a/sys.subproj/i386.subproj/_setjmp.s b/i386/sys/_setjmp.s similarity index 100% rename from sys.subproj/i386.subproj/_setjmp.s rename to i386/sys/_setjmp.s diff --git a/sys.subproj/i386.subproj/_setlogin.s b/i386/sys/_setlogin.s similarity index 100% rename from sys.subproj/i386.subproj/_setlogin.s rename to i386/sys/_setlogin.s diff --git a/sys.subproj/i386.subproj/_sysctl.s b/i386/sys/_sysctl.s similarity index 100% rename from sys.subproj/i386.subproj/_sysctl.s rename to i386/sys/_sysctl.s diff --git a/sys.subproj/i386.subproj/accept.s b/i386/sys/accept.s similarity index 100% rename from sys.subproj/i386.subproj/accept.s rename to i386/sys/accept.s diff --git a/sys.subproj/i386.subproj/access.s b/i386/sys/access.s similarity index 100% rename from sys.subproj/i386.subproj/access.s rename to i386/sys/access.s diff --git a/sys.subproj/i386.subproj/acct.s b/i386/sys/acct.s similarity index 100% rename from sys.subproj/i386.subproj/acct.s rename to i386/sys/acct.s diff --git a/sys.subproj/i386.subproj/add_profil.s b/i386/sys/add_profil.s similarity index 100% rename from sys.subproj/i386.subproj/add_profil.s rename to i386/sys/add_profil.s diff --git a/sys.subproj/i386.subproj/adjtime.s b/i386/sys/adjtime.s similarity index 100% rename from sys.subproj/i386.subproj/adjtime.s rename to i386/sys/adjtime.s diff --git a/sys.subproj/i386.subproj/bind.s b/i386/sys/bind.s similarity index 100% rename from sys.subproj/i386.subproj/bind.s rename to i386/sys/bind.s diff --git a/sys.subproj/i386.subproj/cerror.s b/i386/sys/cerror.s similarity index 100% rename from sys.subproj/i386.subproj/cerror.s rename to i386/sys/cerror.s diff --git a/sys.subproj/i386.subproj/chdir.s b/i386/sys/chdir.s similarity index 100% rename from sys.subproj/i386.subproj/chdir.s rename to i386/sys/chdir.s diff --git a/sys.subproj/i386.subproj/checkuseraccess.s b/i386/sys/checkuseraccess.s similarity index 100% rename from sys.subproj/i386.subproj/checkuseraccess.s rename to i386/sys/checkuseraccess.s diff --git a/sys.subproj/i386.subproj/chflags.s b/i386/sys/chflags.s similarity index 100% rename from sys.subproj/i386.subproj/chflags.s rename to i386/sys/chflags.s diff --git a/sys.subproj/i386.subproj/chmod.s b/i386/sys/chmod.s similarity index 100% rename from sys.subproj/i386.subproj/chmod.s rename to i386/sys/chmod.s diff --git a/sys.subproj/i386.subproj/chown.s b/i386/sys/chown.s similarity index 100% rename from sys.subproj/i386.subproj/chown.s rename to i386/sys/chown.s diff --git a/sys.subproj/i386.subproj/chroot.s b/i386/sys/chroot.s similarity index 100% rename from sys.subproj/i386.subproj/chroot.s rename to i386/sys/chroot.s diff --git a/sys.subproj/i386.subproj/close.s b/i386/sys/close.s similarity index 100% rename from sys.subproj/i386.subproj/close.s rename to i386/sys/close.s diff --git a/sys.subproj/i386.subproj/connect.s b/i386/sys/connect.s similarity index 100% rename from sys.subproj/i386.subproj/connect.s rename to i386/sys/connect.s diff --git a/sys.subproj/i386.subproj/dup.s b/i386/sys/dup.s similarity index 100% rename from sys.subproj/i386.subproj/dup.s rename to i386/sys/dup.s diff --git a/sys.subproj/i386.subproj/dup2.s b/i386/sys/dup2.s similarity index 100% rename from sys.subproj/i386.subproj/dup2.s rename to i386/sys/dup2.s diff --git a/sys.subproj/i386.subproj/exchangedata.s b/i386/sys/exchangedata.s similarity index 100% rename from sys.subproj/i386.subproj/exchangedata.s rename to i386/sys/exchangedata.s diff --git a/sys.subproj/i386.subproj/execve.s b/i386/sys/execve.s similarity index 100% rename from sys.subproj/i386.subproj/execve.s rename to i386/sys/execve.s diff --git a/sys.subproj/i386.subproj/fchdir.s b/i386/sys/fchdir.s similarity index 100% rename from sys.subproj/i386.subproj/fchdir.s rename to i386/sys/fchdir.s diff --git a/sys.subproj/i386.subproj/fchflags.s b/i386/sys/fchflags.s similarity index 100% rename from sys.subproj/i386.subproj/fchflags.s rename to i386/sys/fchflags.s diff --git a/sys.subproj/i386.subproj/fchmod.s b/i386/sys/fchmod.s similarity index 100% rename from sys.subproj/i386.subproj/fchmod.s rename to i386/sys/fchmod.s diff --git a/sys.subproj/i386.subproj/fchown.s b/i386/sys/fchown.s similarity index 100% rename from sys.subproj/i386.subproj/fchown.s rename to i386/sys/fchown.s diff --git a/sys.subproj/i386.subproj/fcntl.s b/i386/sys/fcntl.s similarity index 100% rename from sys.subproj/i386.subproj/fcntl.s rename to i386/sys/fcntl.s diff --git a/sys.subproj/i386.subproj/flock.s b/i386/sys/flock.s similarity index 100% rename from sys.subproj/i386.subproj/flock.s rename to i386/sys/flock.s diff --git a/sys.subproj/i386.subproj/fork.s b/i386/sys/fork.s similarity index 99% rename from sys.subproj/i386.subproj/fork.s rename to i386/sys/fork.s index 74b278d..88dbda1 100644 --- a/sys.subproj/i386.subproj/fork.s +++ b/i386/sys/fork.s @@ -49,7 +49,7 @@ LC1: call *%eax // call __dyld_fork_prepare indirectly #endif - movl $SYS_fork,%eax; // code for fork -> eax + movl $ SYS_fork,%eax; // code for fork -> eax UNIX_SYSCALL_TRAP; // do the system call jnc L1 // jump if CF==0 diff --git a/sys.subproj/i386.subproj/fpathconf.s b/i386/sys/fpathconf.s similarity index 100% rename from sys.subproj/i386.subproj/fpathconf.s rename to i386/sys/fpathconf.s diff --git a/sys.subproj/i386.subproj/fstat.s b/i386/sys/fstat.s similarity index 100% rename from sys.subproj/i386.subproj/fstat.s rename to i386/sys/fstat.s diff --git a/sys.subproj/i386.subproj/fstatfs.s b/i386/sys/fstatfs.s similarity index 100% rename from sys.subproj/i386.subproj/fstatfs.s rename to i386/sys/fstatfs.s diff --git a/sys.subproj/i386.subproj/fstatv.s b/i386/sys/fstatv.s similarity index 100% rename from sys.subproj/i386.subproj/fstatv.s rename to i386/sys/fstatv.s diff --git a/sys.subproj/i386.subproj/fsync.s b/i386/sys/fsync.s similarity index 100% rename from sys.subproj/i386.subproj/fsync.s rename to i386/sys/fsync.s diff --git a/sys.subproj/i386.subproj/ftruncate.s b/i386/sys/ftruncate.s similarity index 100% rename from sys.subproj/i386.subproj/ftruncate.s rename to i386/sys/ftruncate.s diff --git a/sys.subproj/i386.subproj/lfs_bmapv.s b/i386/sys/futimes.s similarity index 97% rename from sys.subproj/i386.subproj/lfs_bmapv.s rename to i386/sys/futimes.s index 5bfe288..fc90f1d 100644 --- a/sys.subproj/i386.subproj/lfs_bmapv.s +++ b/i386/sys/futimes.s @@ -24,5 +24,5 @@ */ #include "SYS.h" -UNIX_SYSCALL(lfs_bmapv, 2) +UNIX_SYSCALL(futimes, 2) ret diff --git a/sys.subproj/i386.subproj/getattrlist.s b/i386/sys/getattrlist.s similarity index 100% rename from sys.subproj/i386.subproj/getattrlist.s rename to i386/sys/getattrlist.s diff --git a/sys.subproj/i386.subproj/getdirentries.s b/i386/sys/getdirentries.s similarity index 100% rename from sys.subproj/i386.subproj/getdirentries.s rename to i386/sys/getdirentries.s diff --git a/sys.subproj/i386.subproj/getdirentriesattr.s b/i386/sys/getdirentriesattr.s similarity index 100% rename from sys.subproj/i386.subproj/getdirentriesattr.s rename to i386/sys/getdirentriesattr.s diff --git a/sys.subproj/i386.subproj/getegid.s b/i386/sys/getegid.s similarity index 100% rename from sys.subproj/i386.subproj/getegid.s rename to i386/sys/getegid.s diff --git a/sys.subproj/i386.subproj/geteuid.s b/i386/sys/geteuid.s similarity index 100% rename from sys.subproj/i386.subproj/geteuid.s rename to i386/sys/geteuid.s diff --git a/sys.subproj/i386.subproj/getfh.s b/i386/sys/getfh.s similarity index 100% rename from sys.subproj/i386.subproj/getfh.s rename to i386/sys/getfh.s diff --git a/sys.subproj/i386.subproj/getfsstat.s b/i386/sys/getfsstat.s similarity index 100% rename from sys.subproj/i386.subproj/getfsstat.s rename to i386/sys/getfsstat.s diff --git a/sys.subproj/i386.subproj/getgid.s b/i386/sys/getgid.s similarity index 100% rename from sys.subproj/i386.subproj/getgid.s rename to i386/sys/getgid.s diff --git a/sys.subproj/i386.subproj/getgroups.s b/i386/sys/getgroups.s similarity index 100% rename from sys.subproj/i386.subproj/getgroups.s rename to i386/sys/getgroups.s diff --git a/sys.subproj/i386.subproj/getitimer.s b/i386/sys/getitimer.s similarity index 100% rename from sys.subproj/i386.subproj/getitimer.s rename to i386/sys/getitimer.s diff --git a/sys.subproj/i386.subproj/getpeername.s b/i386/sys/getpeername.s similarity index 100% rename from sys.subproj/i386.subproj/getpeername.s rename to i386/sys/getpeername.s diff --git a/sys.subproj/i386.subproj/lfs_markv.s b/i386/sys/getpgid.s similarity index 97% rename from sys.subproj/i386.subproj/lfs_markv.s rename to i386/sys/getpgid.s index b43267c..f2dbba9 100644 --- a/sys.subproj/i386.subproj/lfs_markv.s +++ b/i386/sys/getpgid.s @@ -24,5 +24,5 @@ */ #include "SYS.h" -UNIX_SYSCALL(lfs_markv, 2) +UNIX_SYSCALL(getpgid, 1) ret diff --git a/sys.subproj/i386.subproj/getpgrp.s b/i386/sys/getpgrp.s similarity index 100% rename from sys.subproj/i386.subproj/getpgrp.s rename to i386/sys/getpgrp.s diff --git a/sys.subproj/i386.subproj/getpid.s b/i386/sys/getpid.s similarity index 100% rename from sys.subproj/i386.subproj/getpid.s rename to i386/sys/getpid.s diff --git a/sys.subproj/i386.subproj/getppid.s b/i386/sys/getppid.s similarity index 100% rename from sys.subproj/i386.subproj/getppid.s rename to i386/sys/getppid.s diff --git a/sys.subproj/i386.subproj/getpriority.s b/i386/sys/getpriority.s similarity index 100% rename from sys.subproj/i386.subproj/getpriority.s rename to i386/sys/getpriority.s diff --git a/sys.subproj/i386.subproj/getrlimit.s b/i386/sys/getrlimit.s similarity index 100% rename from sys.subproj/i386.subproj/getrlimit.s rename to i386/sys/getrlimit.s diff --git a/sys.subproj/i386.subproj/getrusage.s b/i386/sys/getrusage.s similarity index 100% rename from sys.subproj/i386.subproj/getrusage.s rename to i386/sys/getrusage.s diff --git a/sys.subproj/i386.subproj/lfs_segwait.s b/i386/sys/getsid.s similarity index 97% rename from sys.subproj/i386.subproj/lfs_segwait.s rename to i386/sys/getsid.s index 96c60f6..9af639f 100644 --- a/sys.subproj/i386.subproj/lfs_segwait.s +++ b/i386/sys/getsid.s @@ -24,5 +24,5 @@ */ #include "SYS.h" -UNIX_SYSCALL(lfs_segwait, 2) +UNIX_SYSCALL(getsid, 1) ret diff --git a/sys.subproj/i386.subproj/getsockname.s b/i386/sys/getsockname.s similarity index 100% rename from sys.subproj/i386.subproj/getsockname.s rename to i386/sys/getsockname.s diff --git a/sys.subproj/i386.subproj/getsockopt.s b/i386/sys/getsockopt.s similarity index 100% rename from sys.subproj/i386.subproj/getsockopt.s rename to i386/sys/getsockopt.s diff --git a/sys.subproj/i386.subproj/getuid.s b/i386/sys/getuid.s similarity index 100% rename from sys.subproj/i386.subproj/getuid.s rename to i386/sys/getuid.s diff --git a/sys.subproj/i386.subproj/ioctl.s b/i386/sys/ioctl.s similarity index 100% rename from sys.subproj/i386.subproj/ioctl.s rename to i386/sys/ioctl.s diff --git a/i386/sys/issetugid.s b/i386/sys/issetugid.s new file mode 100644 index 0000000..054d7ad --- /dev/null +++ b/i386/sys/issetugid.s @@ -0,0 +1,28 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved + */ +#include "SYS.h" + +UNIX_SYSCALL(issetugid, 0) + ret diff --git a/sys.subproj/i386.subproj/kill.s b/i386/sys/kill.s similarity index 100% rename from sys.subproj/i386.subproj/kill.s rename to i386/sys/kill.s diff --git a/sys.subproj/i386.subproj/ktrace.s b/i386/sys/ktrace.s similarity index 100% rename from sys.subproj/i386.subproj/ktrace.s rename to i386/sys/ktrace.s diff --git a/sys.subproj/i386.subproj/link.s b/i386/sys/link.s similarity index 100% rename from sys.subproj/i386.subproj/link.s rename to i386/sys/link.s diff --git a/sys.subproj/i386.subproj/listen.s b/i386/sys/listen.s similarity index 100% rename from sys.subproj/i386.subproj/listen.s rename to i386/sys/listen.s diff --git a/sys.subproj/i386.subproj/load_shared_file.s b/i386/sys/load_shared_file.s similarity index 100% rename from sys.subproj/i386.subproj/load_shared_file.s rename to i386/sys/load_shared_file.s diff --git a/sys.subproj/i386.subproj/lseek.s b/i386/sys/lseek.s similarity index 100% rename from sys.subproj/i386.subproj/lseek.s rename to i386/sys/lseek.s diff --git a/sys.subproj/i386.subproj/lstat.s b/i386/sys/lstat.s similarity index 100% rename from sys.subproj/i386.subproj/lstat.s rename to i386/sys/lstat.s diff --git a/sys.subproj/i386.subproj/lstatv.s b/i386/sys/lstatv.s similarity index 100% rename from sys.subproj/i386.subproj/lstatv.s rename to i386/sys/lstatv.s diff --git a/sys.subproj/i386.subproj/madvise.s b/i386/sys/madvise.s similarity index 100% rename from sys.subproj/i386.subproj/madvise.s rename to i386/sys/madvise.s diff --git a/sys.subproj/i386.subproj/mincore.s b/i386/sys/mincore.s similarity index 100% rename from sys.subproj/i386.subproj/mincore.s rename to i386/sys/mincore.s diff --git a/sys.subproj/i386.subproj/minherit.s b/i386/sys/minherit.s similarity index 100% rename from sys.subproj/i386.subproj/minherit.s rename to i386/sys/minherit.s diff --git a/sys.subproj/i386.subproj/mkcomplex.s b/i386/sys/mkcomplex.s similarity index 100% rename from sys.subproj/i386.subproj/mkcomplex.s rename to i386/sys/mkcomplex.s diff --git a/sys.subproj/i386.subproj/mkdir.s b/i386/sys/mkdir.s similarity index 100% rename from sys.subproj/i386.subproj/mkdir.s rename to i386/sys/mkdir.s diff --git a/sys.subproj/i386.subproj/mkfifo.s b/i386/sys/mkfifo.s similarity index 100% rename from sys.subproj/i386.subproj/mkfifo.s rename to i386/sys/mkfifo.s diff --git a/sys.subproj/i386.subproj/mknod.s b/i386/sys/mknod.s similarity index 100% rename from sys.subproj/i386.subproj/mknod.s rename to i386/sys/mknod.s diff --git a/sys.subproj/i386.subproj/mlock.s b/i386/sys/mlock.s similarity index 100% rename from sys.subproj/i386.subproj/mlock.s rename to i386/sys/mlock.s diff --git a/sys.subproj/i386.subproj/mlockall.s b/i386/sys/mlockall.s similarity index 100% rename from sys.subproj/i386.subproj/mlockall.s rename to i386/sys/mlockall.s diff --git a/sys.subproj/i386.subproj/mmap.s b/i386/sys/mmap.s similarity index 100% rename from sys.subproj/i386.subproj/mmap.s rename to i386/sys/mmap.s diff --git a/sys.subproj/i386.subproj/mount.s b/i386/sys/mount.s similarity index 100% rename from sys.subproj/i386.subproj/mount.s rename to i386/sys/mount.s diff --git a/sys.subproj/i386.subproj/mprotect.s b/i386/sys/mprotect.s similarity index 100% rename from sys.subproj/i386.subproj/mprotect.s rename to i386/sys/mprotect.s diff --git a/sys.subproj/i386.subproj/msgctl.s b/i386/sys/msgctl.s similarity index 100% rename from sys.subproj/i386.subproj/msgctl.s rename to i386/sys/msgctl.s diff --git a/sys.subproj/i386.subproj/msgget.s b/i386/sys/msgget.s similarity index 100% rename from sys.subproj/i386.subproj/msgget.s rename to i386/sys/msgget.s diff --git a/sys.subproj/i386.subproj/msgrcv.s b/i386/sys/msgrcv.s similarity index 100% rename from sys.subproj/i386.subproj/msgrcv.s rename to i386/sys/msgrcv.s diff --git a/sys.subproj/i386.subproj/msgsnd.s b/i386/sys/msgsnd.s similarity index 100% rename from sys.subproj/i386.subproj/msgsnd.s rename to i386/sys/msgsnd.s diff --git a/sys.subproj/i386.subproj/msgsys.s b/i386/sys/msgsys.s similarity index 100% rename from sys.subproj/i386.subproj/msgsys.s rename to i386/sys/msgsys.s diff --git a/sys.subproj/i386.subproj/msync.s b/i386/sys/msync.s similarity index 100% rename from sys.subproj/i386.subproj/msync.s rename to i386/sys/msync.s diff --git a/sys.subproj/i386.subproj/munlock.s b/i386/sys/munlock.s similarity index 100% rename from sys.subproj/i386.subproj/munlock.s rename to i386/sys/munlock.s diff --git a/sys.subproj/i386.subproj/munlockall.s b/i386/sys/munlockall.s similarity index 100% rename from sys.subproj/i386.subproj/munlockall.s rename to i386/sys/munlockall.s diff --git a/sys.subproj/i386.subproj/munmap.s b/i386/sys/munmap.s similarity index 100% rename from sys.subproj/i386.subproj/munmap.s rename to i386/sys/munmap.s diff --git a/i386/sys/new_system_shared_regions.s b/i386/sys/new_system_shared_regions.s new file mode 100644 index 0000000..1a9b1bf --- /dev/null +++ b/i386/sys/new_system_shared_regions.s @@ -0,0 +1,28 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved + */ +#include "SYS.h" + +UNIX_SYSCALL(new_system_shared_regions, 0) + ret diff --git a/sys.subproj/i386.subproj/nfssvc.s b/i386/sys/nfssvc.s similarity index 100% rename from sys.subproj/i386.subproj/nfssvc.s rename to i386/sys/nfssvc.s diff --git a/sys.subproj/i386.subproj/open.s b/i386/sys/open.s similarity index 100% rename from sys.subproj/i386.subproj/open.s rename to i386/sys/open.s diff --git a/sys.subproj/i386.subproj/pathconf.s b/i386/sys/pathconf.s similarity index 100% rename from sys.subproj/i386.subproj/pathconf.s rename to i386/sys/pathconf.s diff --git a/sys.subproj/i386.subproj/pipe.s b/i386/sys/pipe.s similarity index 100% rename from sys.subproj/i386.subproj/pipe.s rename to i386/sys/pipe.s diff --git a/i386/sys/posix_madvise.s b/i386/sys/posix_madvise.s new file mode 100644 index 0000000..bfa2567 --- /dev/null +++ b/i386/sys/posix_madvise.s @@ -0,0 +1,27 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* Copyright 1998 Apple Computer, Inc. */ + +#include "SYS.h" + +PSEUDO(posix_madvise, madvise, 3) + ret diff --git a/sys.subproj/i386.subproj/lfs_segclean.s b/i386/sys/pread.s similarity index 97% rename from sys.subproj/i386.subproj/lfs_segclean.s rename to i386/sys/pread.s index 3463892..3fb9c27 100644 --- a/sys.subproj/i386.subproj/lfs_segclean.s +++ b/i386/sys/pread.s @@ -24,5 +24,5 @@ */ #include "SYS.h" -UNIX_SYSCALL(lfs_segclean, 2) +UNIX_SYSCALL(pread, 4) ret diff --git a/sys.subproj/i386.subproj/profil.s b/i386/sys/profil.s similarity index 100% rename from sys.subproj/i386.subproj/profil.s rename to i386/sys/profil.s diff --git a/i386/sys/pthread_sigmask.s b/i386/sys/pthread_sigmask.s new file mode 100644 index 0000000..629a6c2 --- /dev/null +++ b/i386/sys/pthread_sigmask.s @@ -0,0 +1,28 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved + */ +#include "SYS.h" + +UNIX_SYSCALL(pthread_sigmask, 3) + ret diff --git a/sys.subproj/i386.subproj/ptrace.s b/i386/sys/ptrace.s similarity index 100% rename from sys.subproj/i386.subproj/ptrace.s rename to i386/sys/ptrace.s diff --git a/i386/sys/pwrite.s b/i386/sys/pwrite.s new file mode 100644 index 0000000..165c202 --- /dev/null +++ b/i386/sys/pwrite.s @@ -0,0 +1,28 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved + */ +#include "SYS.h" + +UNIX_SYSCALL(pwrite, 4) + ret diff --git a/sys.subproj/i386.subproj/quota.s b/i386/sys/quota.s similarity index 100% rename from sys.subproj/i386.subproj/quota.s rename to i386/sys/quota.s diff --git a/sys.subproj/i386.subproj/quotactl.s b/i386/sys/quotactl.s similarity index 100% rename from sys.subproj/i386.subproj/quotactl.s rename to i386/sys/quotactl.s diff --git a/sys.subproj/i386.subproj/read.s b/i386/sys/read.s similarity index 100% rename from sys.subproj/i386.subproj/read.s rename to i386/sys/read.s diff --git a/sys.subproj/i386.subproj/readlink.s b/i386/sys/readlink.s similarity index 100% rename from sys.subproj/i386.subproj/readlink.s rename to i386/sys/readlink.s diff --git a/sys.subproj/i386.subproj/readv.s b/i386/sys/readv.s similarity index 100% rename from sys.subproj/i386.subproj/readv.s rename to i386/sys/readv.s diff --git a/sys.subproj/i386.subproj/reboot.s b/i386/sys/reboot.s similarity index 100% rename from sys.subproj/i386.subproj/reboot.s rename to i386/sys/reboot.s diff --git a/sys.subproj/i386.subproj/recvfrom.s b/i386/sys/recvfrom.s similarity index 100% rename from sys.subproj/i386.subproj/recvfrom.s rename to i386/sys/recvfrom.s diff --git a/sys.subproj/i386.subproj/recvmsg.s b/i386/sys/recvmsg.s similarity index 100% rename from sys.subproj/i386.subproj/recvmsg.s rename to i386/sys/recvmsg.s diff --git a/sys.subproj/i386.subproj/rename.s b/i386/sys/rename.s similarity index 100% rename from sys.subproj/i386.subproj/rename.s rename to i386/sys/rename.s diff --git a/sys.subproj/i386.subproj/reset_shared_file.s b/i386/sys/reset_shared_file.s similarity index 100% rename from sys.subproj/i386.subproj/reset_shared_file.s rename to i386/sys/reset_shared_file.s diff --git a/sys.subproj/i386.subproj/revoke.s b/i386/sys/revoke.s similarity index 100% rename from sys.subproj/i386.subproj/revoke.s rename to i386/sys/revoke.s diff --git a/sys.subproj/i386.subproj/rmdir.s b/i386/sys/rmdir.s similarity index 100% rename from sys.subproj/i386.subproj/rmdir.s rename to i386/sys/rmdir.s diff --git a/i386/sys/s.template b/i386/sys/s.template new file mode 100644 index 0000000..d42f280 --- /dev/null +++ b/i386/sys/s.template @@ -0,0 +1,7 @@ +/* + * Copyright (c) 1998 Apple Computer, Inc. All Rights Reserved + */ +#include "SYS.h" + +UNIX_SYSCALL($FILENAMESANSEXTENSION$, 0) + ret diff --git a/sys.subproj/i386.subproj/searchfs.s b/i386/sys/searchfs.s similarity index 100% rename from sys.subproj/i386.subproj/searchfs.s rename to i386/sys/searchfs.s diff --git a/sys.subproj/i386.subproj/select.s b/i386/sys/select.s similarity index 100% rename from sys.subproj/i386.subproj/select.s rename to i386/sys/select.s diff --git a/sys.subproj/i386.subproj/sem_close.s b/i386/sys/sem_close.s similarity index 100% rename from sys.subproj/i386.subproj/sem_close.s rename to i386/sys/sem_close.s diff --git a/sys.subproj/i386.subproj/sem_destroy.s b/i386/sys/sem_destroy.s similarity index 100% rename from sys.subproj/i386.subproj/sem_destroy.s rename to i386/sys/sem_destroy.s diff --git a/sys.subproj/i386.subproj/sem_getvalue.s b/i386/sys/sem_getvalue.s similarity index 100% rename from sys.subproj/i386.subproj/sem_getvalue.s rename to i386/sys/sem_getvalue.s diff --git a/sys.subproj/i386.subproj/sem_init.s b/i386/sys/sem_init.s similarity index 100% rename from sys.subproj/i386.subproj/sem_init.s rename to i386/sys/sem_init.s diff --git a/sys.subproj/i386.subproj/sem_open.s b/i386/sys/sem_open.s similarity index 100% rename from sys.subproj/i386.subproj/sem_open.s rename to i386/sys/sem_open.s diff --git a/sys.subproj/i386.subproj/sem_post.s b/i386/sys/sem_post.s similarity index 100% rename from sys.subproj/i386.subproj/sem_post.s rename to i386/sys/sem_post.s diff --git a/sys.subproj/i386.subproj/sem_trywait.s b/i386/sys/sem_trywait.s similarity index 100% rename from sys.subproj/i386.subproj/sem_trywait.s rename to i386/sys/sem_trywait.s diff --git a/sys.subproj/i386.subproj/sem_unlink.s b/i386/sys/sem_unlink.s similarity index 100% rename from sys.subproj/i386.subproj/sem_unlink.s rename to i386/sys/sem_unlink.s diff --git a/sys.subproj/i386.subproj/sem_wait.s b/i386/sys/sem_wait.s similarity index 100% rename from sys.subproj/i386.subproj/sem_wait.s rename to i386/sys/sem_wait.s diff --git a/sys.subproj/i386.subproj/semconfig.s b/i386/sys/semconfig.s similarity index 100% rename from sys.subproj/i386.subproj/semconfig.s rename to i386/sys/semconfig.s diff --git a/sys.subproj/i386.subproj/semctl.s b/i386/sys/semctl.s similarity index 100% rename from sys.subproj/i386.subproj/semctl.s rename to i386/sys/semctl.s diff --git a/sys.subproj/i386.subproj/semget.s b/i386/sys/semget.s similarity index 100% rename from sys.subproj/i386.subproj/semget.s rename to i386/sys/semget.s diff --git a/sys.subproj/i386.subproj/semop.s b/i386/sys/semop.s similarity index 100% rename from sys.subproj/i386.subproj/semop.s rename to i386/sys/semop.s diff --git a/sys.subproj/i386.subproj/semsys.s b/i386/sys/semsys.s similarity index 100% rename from sys.subproj/i386.subproj/semsys.s rename to i386/sys/semsys.s diff --git a/sys.subproj/i386.subproj/sendmsg.s b/i386/sys/sendmsg.s similarity index 100% rename from sys.subproj/i386.subproj/sendmsg.s rename to i386/sys/sendmsg.s diff --git a/sys.subproj/i386.subproj/sendto.s b/i386/sys/sendto.s similarity index 100% rename from sys.subproj/i386.subproj/sendto.s rename to i386/sys/sendto.s diff --git a/sys.subproj/i386.subproj/setattrlist.s b/i386/sys/setattrlist.s similarity index 100% rename from sys.subproj/i386.subproj/setattrlist.s rename to i386/sys/setattrlist.s diff --git a/sys.subproj/i386.subproj/setegid.s b/i386/sys/setegid.s similarity index 100% rename from sys.subproj/i386.subproj/setegid.s rename to i386/sys/setegid.s diff --git a/sys.subproj/i386.subproj/seteuid.s b/i386/sys/seteuid.s similarity index 100% rename from sys.subproj/i386.subproj/seteuid.s rename to i386/sys/seteuid.s diff --git a/sys.subproj/i386.subproj/setgid.s b/i386/sys/setgid.s similarity index 100% rename from sys.subproj/i386.subproj/setgid.s rename to i386/sys/setgid.s diff --git a/sys.subproj/i386.subproj/setgroups.s b/i386/sys/setgroups.s similarity index 100% rename from sys.subproj/i386.subproj/setgroups.s rename to i386/sys/setgroups.s diff --git a/sys.subproj/i386.subproj/setitimer.s b/i386/sys/setitimer.s similarity index 100% rename from sys.subproj/i386.subproj/setitimer.s rename to i386/sys/setitimer.s diff --git a/sys.subproj/i386.subproj/setjmp.s b/i386/sys/setjmp.s similarity index 98% rename from sys.subproj/i386.subproj/setjmp.s rename to i386/sys/setjmp.s index bc5108d..3461c66 100644 --- a/sys.subproj/i386.subproj/setjmp.s +++ b/i386/sys/setjmp.s @@ -146,7 +146,7 @@ LEAF(_longjmp, 0) movl 4(%esp), %eax // address of jmp_buf (saved context) movl 8(%esp), %edx // return value movl %edx, JB_EAX(%eax) // return value into saved context - movl $SYS_sigreturn, %eax // sigreturn system call + movl $ SYS_sigreturn, %eax // sigreturn system call UNIX_SYSCALL_TRAP addl $8, %esp CALL_EXTERN(_longjmperror) diff --git a/sys.subproj/i386.subproj/setpgid.s b/i386/sys/setpgid.s similarity index 100% rename from sys.subproj/i386.subproj/setpgid.s rename to i386/sys/setpgid.s diff --git a/sys.subproj/i386.subproj/setpriority.s b/i386/sys/setpriority.s similarity index 100% rename from sys.subproj/i386.subproj/setpriority.s rename to i386/sys/setpriority.s diff --git a/sys.subproj/i386.subproj/setprivexec.s b/i386/sys/setprivexec.s similarity index 100% rename from sys.subproj/i386.subproj/setprivexec.s rename to i386/sys/setprivexec.s diff --git a/sys.subproj/i386.subproj/setquota.s b/i386/sys/setquota.s similarity index 100% rename from sys.subproj/i386.subproj/setquota.s rename to i386/sys/setquota.s diff --git a/sys.subproj/i386.subproj/setrlimit.s b/i386/sys/setrlimit.s similarity index 100% rename from sys.subproj/i386.subproj/setrlimit.s rename to i386/sys/setrlimit.s diff --git a/sys.subproj/i386.subproj/setsid.s b/i386/sys/setsid.s similarity index 100% rename from sys.subproj/i386.subproj/setsid.s rename to i386/sys/setsid.s diff --git a/sys.subproj/i386.subproj/setsockopt.s b/i386/sys/setsockopt.s similarity index 100% rename from sys.subproj/i386.subproj/setsockopt.s rename to i386/sys/setsockopt.s diff --git a/sys.subproj/i386.subproj/settimeofday.s b/i386/sys/settimeofday.s similarity index 100% rename from sys.subproj/i386.subproj/settimeofday.s rename to i386/sys/settimeofday.s diff --git a/sys.subproj/i386.subproj/setuid.s b/i386/sys/setuid.s similarity index 100% rename from sys.subproj/i386.subproj/setuid.s rename to i386/sys/setuid.s diff --git a/sys.subproj/i386.subproj/shm_open.s b/i386/sys/shm_open.s similarity index 100% rename from sys.subproj/i386.subproj/shm_open.s rename to i386/sys/shm_open.s diff --git a/sys.subproj/i386.subproj/shm_unlink.s b/i386/sys/shm_unlink.s similarity index 100% rename from sys.subproj/i386.subproj/shm_unlink.s rename to i386/sys/shm_unlink.s diff --git a/sys.subproj/i386.subproj/shmat.s b/i386/sys/shmat.s similarity index 100% rename from sys.subproj/i386.subproj/shmat.s rename to i386/sys/shmat.s diff --git a/sys.subproj/i386.subproj/shmctl.s b/i386/sys/shmctl.s similarity index 100% rename from sys.subproj/i386.subproj/shmctl.s rename to i386/sys/shmctl.s diff --git a/sys.subproj/i386.subproj/shmdt.s b/i386/sys/shmdt.s similarity index 100% rename from sys.subproj/i386.subproj/shmdt.s rename to i386/sys/shmdt.s diff --git a/sys.subproj/i386.subproj/shmget.s b/i386/sys/shmget.s similarity index 100% rename from sys.subproj/i386.subproj/shmget.s rename to i386/sys/shmget.s diff --git a/sys.subproj/i386.subproj/shmsys.s b/i386/sys/shmsys.s similarity index 100% rename from sys.subproj/i386.subproj/shmsys.s rename to i386/sys/shmsys.s diff --git a/sys.subproj/i386.subproj/shutdown.s b/i386/sys/shutdown.s similarity index 100% rename from sys.subproj/i386.subproj/shutdown.s rename to i386/sys/shutdown.s diff --git a/sys.subproj/i386.subproj/sigaltstack.s b/i386/sys/sigaltstack.s similarity index 100% rename from sys.subproj/i386.subproj/sigaltstack.s rename to i386/sys/sigaltstack.s diff --git a/sys.subproj/i386.subproj/sigpending.s b/i386/sys/sigpending.s similarity index 100% rename from sys.subproj/i386.subproj/sigpending.s rename to i386/sys/sigpending.s diff --git a/i386/sys/sigprocmask.s b/i386/sys/sigprocmask.s new file mode 100644 index 0000000..92b0432 --- /dev/null +++ b/i386/sys/sigprocmask.s @@ -0,0 +1,28 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved + */ +#include "SYS.h" + +UNIX_SYSCALL(sigprocmask, 3) + ret diff --git a/sys.subproj/i386.subproj/sigreturn.s b/i386/sys/sigreturn.s similarity index 100% rename from sys.subproj/i386.subproj/sigreturn.s rename to i386/sys/sigreturn.s diff --git a/i386/sys/sigwait.s b/i386/sys/sigwait.s new file mode 100644 index 0000000..0674fb8 --- /dev/null +++ b/i386/sys/sigwait.s @@ -0,0 +1,28 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved + */ +#include "SYS.h" + +UNIX_SYSCALL(sigwait, 2) + ret diff --git a/sys.subproj/i386.subproj/socket.s b/i386/sys/socket.s similarity index 100% rename from sys.subproj/i386.subproj/socket.s rename to i386/sys/socket.s diff --git a/sys.subproj/i386.subproj/socketpair.s b/i386/sys/socketpair.s similarity index 100% rename from sys.subproj/i386.subproj/socketpair.s rename to i386/sys/socketpair.s diff --git a/sys.subproj/i386.subproj/stat.s b/i386/sys/stat.s similarity index 100% rename from sys.subproj/i386.subproj/stat.s rename to i386/sys/stat.s diff --git a/sys.subproj/i386.subproj/statfs.s b/i386/sys/statfs.s similarity index 100% rename from sys.subproj/i386.subproj/statfs.s rename to i386/sys/statfs.s diff --git a/sys.subproj/i386.subproj/statv.s b/i386/sys/statv.s similarity index 100% rename from sys.subproj/i386.subproj/statv.s rename to i386/sys/statv.s diff --git a/sys.subproj/i386.subproj/swapon.s b/i386/sys/swapon.s similarity index 100% rename from sys.subproj/i386.subproj/swapon.s rename to i386/sys/swapon.s diff --git a/sys.subproj/i386.subproj/symlink.s b/i386/sys/symlink.s similarity index 100% rename from sys.subproj/i386.subproj/symlink.s rename to i386/sys/symlink.s diff --git a/sys.subproj/i386.subproj/sync.s b/i386/sys/sync.s similarity index 100% rename from sys.subproj/i386.subproj/sync.s rename to i386/sys/sync.s diff --git a/sys.subproj/i386.subproj/syscall.s b/i386/sys/syscall.s similarity index 100% rename from sys.subproj/i386.subproj/syscall.s rename to i386/sys/syscall.s diff --git a/sys.subproj/i386.subproj/table.s b/i386/sys/systable.s similarity index 100% rename from sys.subproj/i386.subproj/table.s rename to i386/sys/systable.s diff --git a/sys.subproj/i386.subproj/truncate.s b/i386/sys/truncate.s similarity index 100% rename from sys.subproj/i386.subproj/truncate.s rename to i386/sys/truncate.s diff --git a/sys.subproj/i386.subproj/umask.s b/i386/sys/umask.s similarity index 100% rename from sys.subproj/i386.subproj/umask.s rename to i386/sys/umask.s diff --git a/sys.subproj/i386.subproj/undelete.s b/i386/sys/undelete.s similarity index 100% rename from sys.subproj/i386.subproj/undelete.s rename to i386/sys/undelete.s diff --git a/sys.subproj/i386.subproj/unlink.s b/i386/sys/unlink.s similarity index 100% rename from sys.subproj/i386.subproj/unlink.s rename to i386/sys/unlink.s diff --git a/sys.subproj/i386.subproj/unmount.s b/i386/sys/unmount.s similarity index 100% rename from sys.subproj/i386.subproj/unmount.s rename to i386/sys/unmount.s diff --git a/sys.subproj/i386.subproj/utimes.s b/i386/sys/utimes.s similarity index 100% rename from sys.subproj/i386.subproj/utimes.s rename to i386/sys/utimes.s diff --git a/sys.subproj/i386.subproj/vfork.s b/i386/sys/vfork.s similarity index 98% rename from sys.subproj/i386.subproj/vfork.s rename to i386/sys/vfork.s index edd5f4f..7bf2402 100644 --- a/sys.subproj/i386.subproj/vfork.s +++ b/i386/sys/vfork.s @@ -50,7 +50,7 @@ LC1: call *%eax // call __dyld_fork_prepare indirectly #endif - movl $SYS_vfork,%eax; // code for vfork -> eax + movl $ SYS_vfork,%eax; // code for vfork -> eax UNIX_SYSCALL_TRAP; // do the system call jnc L1 // jump if CF==0 @@ -166,7 +166,7 @@ L2: LEAF(_vfork, 0) popl %ecx - movl $SYS_vfork,%eax; // code for vfork -> eax + movl $ SYS_vfork,%eax; // code for vfork -> eax UNIX_SYSCALL_TRAP; // do the system call jnb L1 // jump if CF==0 pushl %ecx diff --git a/sys.subproj/i386.subproj/wait4.s b/i386/sys/wait4.s similarity index 100% rename from sys.subproj/i386.subproj/wait4.s rename to i386/sys/wait4.s diff --git a/sys.subproj/i386.subproj/write.s b/i386/sys/write.s similarity index 100% rename from sys.subproj/i386.subproj/write.s rename to i386/sys/write.s diff --git a/sys.subproj/i386.subproj/writev.s b/i386/sys/writev.s similarity index 100% rename from sys.subproj/i386.subproj/writev.s rename to i386/sys/writev.s diff --git a/i386/threads/Makefile.inc b/i386/threads/Makefile.inc new file mode 100644 index 0000000..b0e854d --- /dev/null +++ b/i386/threads/Makefile.inc @@ -0,0 +1,2 @@ +CFLAGS+= -I${.CURDIR}/threads +SRCS+= thread.c diff --git a/threads.subproj/i386.subproj/thread.c b/i386/threads/thread.c similarity index 98% rename from threads.subproj/i386.subproj/thread.c rename to i386/threads/thread.c index 64595c3..a79fb2f 100644 --- a/threads.subproj/i386.subproj/thread.c +++ b/i386/threads/thread.c @@ -45,6 +45,7 @@ _pthread_set_self(p) asm("pushl $0"); // fake the kernel out asm("movl $1, %%eax" : : : "ax"); asm("lcall $0x3b, $0"); + asm("addl $0x8, %%esp" ::); } void * diff --git a/include/Makefile.inc b/include/Makefile.inc new file mode 100644 index 0000000..f6eb88b --- /dev/null +++ b/include/Makefile.inc @@ -0,0 +1,70 @@ +.include "${.CURDIR}/include/arpa/Makefile.inc" +.include "${.CURDIR}/include/protocols/Makefile.inc" +.include "${.CURDIR}/include/objc/Makefile.inc" + +INC_INSTHDRS += NSSystemDirectories.h \ + ar.h \ + asm.h \ + bitstring.h \ + c.h \ + crt_externs.h \ + ctype.h \ + db.h \ + dirent.h \ + disktab.h \ + err.h \ + errno.h \ + fcntl.h \ + fnmatch.h \ + fsproperties.h \ + fstab.h \ + fts.h \ + glob.h \ + grp.h \ + kvm.h \ + libc.h \ + libgen.h \ + limits.h \ + locale.h \ + memory.h \ + monitor.h \ + mpool.h \ + ndbm.h \ + netdb.h \ + nlist.h \ + paths.h \ + pwd.h \ + ranlib.h \ + regex.h \ + regexp.h \ + rune.h \ + runetype.h \ + semaphore.h \ + setjmp.h \ + sgtty.h \ + signal.h \ + stab.h \ + standards.h \ + stddef.h \ + stdio.h \ + stdlib.h \ + string.h \ + strings.h \ + struct.h \ + sysexits.h \ + syslog.h \ + tar.h \ + termios.h \ + time.h \ + ttyent.h \ + tzfile.h \ + ucontext.h \ + ulimit.h \ + unistd.h \ + util.h \ + utime.h \ + utmp.h \ + vis.h \ + +INC_INSTHDRS := ${INC_INSTHDRS:S/^/${.CURDIR}\/include\//} +INSTHDRS += ${INC_INSTHDRS} diff --git a/headers.subproj/NSSystemDirectories.h b/include/NSSystemDirectories.h similarity index 96% rename from headers.subproj/NSSystemDirectories.h rename to include/NSSystemDirectories.h index 75782d6..5dfd37a 100644 --- a/headers.subproj/NSSystemDirectories.h +++ b/include/NSSystemDirectories.h @@ -60,6 +60,8 @@ typedef enum { NSDeveloperDirectory, // developer resources (Developer) NSUserDirectory, // user home directories (Users) NSDocumentationDirectory, // documentation (Library/Documentation) + NSDocumentDirectory, // documents (Documents) + NSCoreServiceDirectory, // location of core services (System/Library/CoreServices) NSAllApplicationsDirectory = 100, // all directories where applications can occur (Applications, Applications/Utilities, Developer/Applications, Applications/GrabBag) NSAllLibrariesDirectory = 101 // all directories where resources can occur (Library, Developer) } NSSearchPathDirectory; diff --git a/include/ar.h b/include/ar.h new file mode 100644 index 0000000..def1c43 --- /dev/null +++ b/include/ar.h @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * This code is derived from software contributed to Berkeley by + * Hugh Smith at The University of Guelph. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)ar.h 8.2 (Berkeley) 1/21/94 + */ + +#ifndef _AR_H_ +#define _AR_H_ + +/* Pre-4BSD archives had these magic numbers in them. */ +#define OARMAG1 0177555 +#define OARMAG2 0177545 + +#define ARMAG "!\n" /* ar "magic number" */ +#define SARMAG 8 /* strlen(ARMAG); */ + +#define AR_EFMT1 "#1/" /* extended format #1 */ + +struct ar_hdr { + char ar_name[16]; /* name */ + char ar_date[12]; /* modification time */ + char ar_uid[6]; /* user id */ + char ar_gid[6]; /* group id */ + char ar_mode[8]; /* octal file permissions */ + char ar_size[10]; /* size in bytes */ +#define ARFMAG "`\n" + char ar_fmag[2]; /* consistency check */ +}; + +#endif /* !_AR_H_ */ diff --git a/include/arpa/Makefile.inc b/include/arpa/Makefile.inc new file mode 100644 index 0000000..a4fb7b4 --- /dev/null +++ b/include/arpa/Makefile.inc @@ -0,0 +1,5 @@ +ARPA_INSTHDRS += ftp.h \ + nameser_compat.h \ + telnet.h \ + tftp.h +ARPA_INSTHDRS := ${ARPA_INSTHDRS:S/^/${.CURDIR}\/include\/arpa\//} diff --git a/include/arpa/ftp.h b/include/arpa/ftp.h new file mode 100644 index 0000000..90b425b --- /dev/null +++ b/include/arpa/ftp.h @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1983, 1989, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)ftp.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _FTP_H_ +#define _FTP_H_ + +/* Definitions for FTP; see RFC-765. */ + +/* + * Reply codes. + */ +#define PRELIM 1 /* positive preliminary */ +#define COMPLETE 2 /* positive completion */ +#define CONTINUE 3 /* positive intermediate */ +#define TRANSIENT 4 /* transient negative completion */ +#define ERROR 5 /* permanent negative completion */ + +/* + * Type codes + */ +#define TYPE_A 1 /* ASCII */ +#define TYPE_E 2 /* EBCDIC */ +#define TYPE_I 3 /* image */ +#define TYPE_L 4 /* local byte size */ + +#ifdef FTP_NAMES +char *typenames[] = {"0", "ASCII", "EBCDIC", "Image", "Local" }; +#endif + +/* + * Form codes + */ +#define FORM_N 1 /* non-print */ +#define FORM_T 2 /* telnet format effectors */ +#define FORM_C 3 /* carriage control (ASA) */ +#ifdef FTP_NAMES +char *formnames[] = {"0", "Nonprint", "Telnet", "Carriage-control" }; +#endif + +/* + * Structure codes + */ +#define STRU_F 1 /* file (no record structure) */ +#define STRU_R 2 /* record structure */ +#define STRU_P 3 /* page structure */ +#ifdef FTP_NAMES +char *strunames[] = {"0", "File", "Record", "Page" }; +#endif + +/* + * Mode types + */ +#define MODE_S 1 /* stream */ +#define MODE_B 2 /* block */ +#define MODE_C 3 /* compressed */ +#ifdef FTP_NAMES +char *modenames[] = {"0", "Stream", "Block", "Compressed" }; +#endif + +/* + * Record Tokens + */ +#define REC_ESC '\377' /* Record-mode Escape */ +#define REC_EOR '\001' /* Record-mode End-of-Record */ +#define REC_EOF '\002' /* Record-mode End-of-File */ + +/* + * Block Header + */ +#define BLK_EOR 0x80 /* Block is End-of-Record */ +#define BLK_EOF 0x40 /* Block is End-of-File */ +#define BLK_ERRORS 0x20 /* Block is suspected of containing errors */ +#define BLK_RESTART 0x10 /* Block is Restart Marker */ + +#define BLK_BYTECOUNT 2 /* Bytes in this block */ + +#endif /* !_FTP_H_ */ diff --git a/include/arpa/nameser_compat.h b/include/arpa/nameser_compat.h new file mode 100644 index 0000000..33c96ac --- /dev/null +++ b/include/arpa/nameser_compat.h @@ -0,0 +1,194 @@ +/* Copyright (c) 1983, 1989 + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + */ + +/* + * from nameser.h 8.1 (Berkeley) 6/2/93 + * From: Id: nameser_compat.h,v 8.9 1998/03/20 23:25:10 halley Exp + * $FreeBSD: src/include/arpa/nameser_compat.h,v 1.1.2.1 1999/08/29 14:39:01 peter Exp $ + */ + +#ifndef _ARPA_NAMESER_COMPAT_ +#define _ARPA_NAMESER_COMPAT_ + +#define __BIND 19950621 /* (DEAD) interface version stamp. */ + +#include + +#if !defined(BYTE_ORDER) || \ + (BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN && \ + BYTE_ORDER != PDP_ENDIAN) + /* you must determine what the correct bit order is for + * your compiler - the next line is an intentional error + * which will force your compiles to bomb until you fix + * the above macros. + */ + error "Undefined or invalid BYTE_ORDER"; +#endif + +/* + * Structure for query header. The order of the fields is machine- and + * compiler-dependent, depending on the byte/bit order and the layout + * of bit fields. We use bit fields only in int variables, as this + * is all ANSI requires. This requires a somewhat confusing rearrangement. + */ + +typedef struct { + unsigned id :16; /* query identification number */ +#if BYTE_ORDER == BIG_ENDIAN + /* fields in third byte */ + unsigned qr: 1; /* response flag */ + unsigned opcode: 4; /* purpose of message */ + unsigned aa: 1; /* authoritive answer */ + unsigned tc: 1; /* truncated message */ + unsigned rd: 1; /* recursion desired */ + /* fields in fourth byte */ + unsigned ra: 1; /* recursion available */ + unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */ + unsigned ad: 1; /* authentic data from named */ + unsigned cd: 1; /* checking disabled by resolver */ + unsigned rcode :4; /* response code */ +#endif +#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN + /* fields in third byte */ + unsigned rd :1; /* recursion desired */ + unsigned tc :1; /* truncated message */ + unsigned aa :1; /* authoritive answer */ + unsigned opcode :4; /* purpose of message */ + unsigned qr :1; /* response flag */ + /* fields in fourth byte */ + unsigned rcode :4; /* response code */ + unsigned cd: 1; /* checking disabled by resolver */ + unsigned ad: 1; /* authentic data from named */ + unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */ + unsigned ra :1; /* recursion available */ +#endif + /* remaining bytes */ + unsigned qdcount :16; /* number of question entries */ + unsigned ancount :16; /* number of answer entries */ + unsigned nscount :16; /* number of authority entries */ + unsigned arcount :16; /* number of resource entries */ +} HEADER; + +#define PACKETSZ NS_PACKETSZ +#define MAXDNAME NS_MAXDNAME +#define MAXCDNAME NS_MAXCDNAME +#define MAXLABEL NS_MAXLABEL +#define HFIXEDSZ NS_HFIXEDSZ +#define QFIXEDSZ NS_QFIXEDSZ +#define RRFIXEDSZ NS_RRFIXEDSZ +#define INT32SZ NS_INT32SZ +#define INT16SZ NS_INT16SZ +#define INADDRSZ NS_INADDRSZ +#define IN6ADDRSZ NS_IN6ADDRSZ +#define INDIR_MASK NS_CMPRSFLGS +#define NAMESERVER_PORT NS_DEFAULTPORT + +#define S_ZONE ns_s_zn +#define S_PREREQ ns_s_pr +#define S_UPDATE ns_s_ud +#define S_ADDT ns_s_ar + +#define QUERY ns_o_query +#define IQUERY ns_o_iquery +#define STATUS ns_o_status +#define NS_NOTIFY_OP ns_o_notify +#define NS_UPDATE_OP ns_o_update + +#define NOERROR ns_r_noerror +#define FORMERR ns_r_formerr +#define SERVFAIL ns_r_servfail +#define NXDOMAIN ns_r_nxdomain +#define NOTIMP ns_r_notimpl +#define REFUSED ns_r_refused +#define YXDOMAIN ns_r_yxdomain +#define YXRRSET ns_r_yxrrset +#define NXRRSET ns_r_nxrrset +#define NOTAUTH ns_r_notauth +#define NOTZONE ns_r_notzone + +#define DELETE ns_uop_delete +#define ADD ns_uop_add + +#define T_A ns_t_a +#define T_NS ns_t_ns +#define T_MD ns_t_md +#define T_MF ns_t_mf +#define T_CNAME ns_t_cname +#define T_SOA ns_t_soa +#define T_MB ns_t_mb +#define T_MG ns_t_mg +#define T_MR ns_t_mr +#define T_NULL ns_t_null +#define T_WKS ns_t_wks +#define T_PTR ns_t_ptr +#define T_HINFO ns_t_hinfo +#define T_MINFO ns_t_minfo +#define T_MX ns_t_mx +#define T_TXT ns_t_txt +#define T_RP ns_t_rp +#define T_AFSDB ns_t_afsdb +#define T_X25 ns_t_x25 +#define T_ISDN ns_t_isdn +#define T_RT ns_t_rt +#define T_NSAP ns_t_nsap +#define T_NSAP_PTR ns_t_nsap_ptr +#define T_SIG ns_t_sig +#define T_KEY ns_t_key +#define T_PX ns_t_px +#define T_GPOS ns_t_gpos +#define T_AAAA ns_t_aaaa +#define T_LOC ns_t_loc +#define T_NXT ns_t_nxt +#define T_EID ns_t_eid +#define T_NIMLOC ns_t_nimloc +#define T_SRV ns_t_srv +#define T_ATMA ns_t_atma +#define T_NAPTR ns_t_naptr +#define T_IXFR ns_t_ixfr +#define T_AXFR ns_t_axfr +#define T_MAILB ns_t_mailb +#define T_MAILA ns_t_maila +#define T_ANY ns_t_any + +#define C_IN ns_c_in +#define C_CHAOS ns_c_chaos +#define C_HS ns_c_hs +/* BIND_UPDATE */ +#define C_NONE ns_c_none +#define C_ANY ns_c_any + +#define GETSHORT NS_GET16 +#define GETLONG NS_GET32 +#define PUTSHORT NS_PUT16 +#define PUTLONG NS_PUT32 + +#endif /* _ARPA_NAMESER_COMPAT_ */ diff --git a/include/arpa/telnet.h b/include/arpa/telnet.h new file mode 100644 index 0000000..8126ce9 --- /dev/null +++ b/include/arpa/telnet.h @@ -0,0 +1,341 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1983, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)telnet.h 8.2 (Berkeley) 12/15/93 + */ + +#ifndef _TELNET_H_ +#define _TELNET_H_ + +/* + * Definitions for the TELNET protocol. + */ +#define IAC 255 /* interpret as command: */ +#define DONT 254 /* you are not to use option */ +#define DO 253 /* please, you use option */ +#define WONT 252 /* I won't use option */ +#define WILL 251 /* I will use option */ +#define SB 250 /* interpret as subnegotiation */ +#define GA 249 /* you may reverse the line */ +#define EL 248 /* erase the current line */ +#define EC 247 /* erase the current character */ +#define AYT 246 /* are you there */ +#define AO 245 /* abort output--but let prog finish */ +#define IP 244 /* interrupt process--permanently */ +#define BREAK 243 /* break */ +#define DM 242 /* data mark--for connect. cleaning */ +#define NOP 241 /* nop */ +#define SE 240 /* end sub negotiation */ +#define EOR 239 /* end of record (transparent mode) */ +#define ABORT 238 /* Abort process */ +#define SUSP 237 /* Suspend process */ +#define xEOF 236 /* End of file: EOF is already used... */ + +#define SYNCH 242 /* for telfunc calls */ + +#ifdef TELCMDS +char *telcmds[] = { + "EOF", "SUSP", "ABORT", "EOR", + "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC", + "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0, +}; +#else +extern char *telcmds[]; +#endif + +#define TELCMD_FIRST xEOF +#define TELCMD_LAST IAC +#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \ + (unsigned int)(x) >= TELCMD_FIRST) +#define TELCMD(x) telcmds[(x)-TELCMD_FIRST] + +/* telnet options */ +#define TELOPT_BINARY 0 /* 8-bit data path */ +#define TELOPT_ECHO 1 /* echo */ +#define TELOPT_RCP 2 /* prepare to reconnect */ +#define TELOPT_SGA 3 /* suppress go ahead */ +#define TELOPT_NAMS 4 /* approximate message size */ +#define TELOPT_STATUS 5 /* give status */ +#define TELOPT_TM 6 /* timing mark */ +#define TELOPT_RCTE 7 /* remote controlled transmission and echo */ +#define TELOPT_NAOL 8 /* negotiate about output line width */ +#define TELOPT_NAOP 9 /* negotiate about output page size */ +#define TELOPT_NAOCRD 10 /* negotiate about CR disposition */ +#define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */ +#define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */ +#define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */ +#define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */ +#define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */ +#define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */ +#define TELOPT_XASCII 17 /* extended ascic character set */ +#define TELOPT_LOGOUT 18 /* force logout */ +#define TELOPT_BM 19 /* byte macro */ +#define TELOPT_DET 20 /* data entry terminal */ +#define TELOPT_SUPDUP 21 /* supdup protocol */ +#define TELOPT_SUPDUPOUTPUT 22 /* supdup output */ +#define TELOPT_SNDLOC 23 /* send location */ +#define TELOPT_TTYPE 24 /* terminal type */ +#define TELOPT_EOR 25 /* end or record */ +#define TELOPT_TUID 26 /* TACACS user identification */ +#define TELOPT_OUTMRK 27 /* output marking */ +#define TELOPT_TTYLOC 28 /* terminal location number */ +#define TELOPT_3270REGIME 29 /* 3270 regime */ +#define TELOPT_X3PAD 30 /* X.3 PAD */ +#define TELOPT_NAWS 31 /* window size */ +#define TELOPT_TSPEED 32 /* terminal speed */ +#define TELOPT_LFLOW 33 /* remote flow control */ +#define TELOPT_LINEMODE 34 /* Linemode option */ +#define TELOPT_XDISPLOC 35 /* X Display Location */ +#define TELOPT_OLD_ENVIRON 36 /* Old - Environment variables */ +#define TELOPT_AUTHENTICATION 37/* Authenticate */ +#define TELOPT_ENCRYPT 38 /* Encryption option */ +#define TELOPT_NEW_ENVIRON 39 /* New - Environment variables */ +#define TELOPT_EXOPL 255 /* extended-options-list */ + + +#define NTELOPTS (1+TELOPT_NEW_ENVIRON) +#ifdef TELOPTS +char *telopts[NTELOPTS+1] = { + "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME", + "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP", + "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS", + "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO", + "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT", + "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD", + "TACACS UID", "OUTPUT MARKING", "TTYLOC", + "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW", + "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION", + "ENCRYPT", "NEW-ENVIRON", + 0, +}; +#define TELOPT_FIRST TELOPT_BINARY +#define TELOPT_LAST TELOPT_NEW_ENVIRON +#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST) +#define TELOPT(x) telopts[(x)-TELOPT_FIRST] +#endif + +/* sub-option qualifiers */ +#define TELQUAL_IS 0 /* option is... */ +#define TELQUAL_SEND 1 /* send option */ +#define TELQUAL_INFO 2 /* ENVIRON: informational version of IS */ +#define TELQUAL_REPLY 2 /* AUTHENTICATION: client version of IS */ +#define TELQUAL_NAME 3 /* AUTHENTICATION: client version of IS */ + +#define LFLOW_OFF 0 /* Disable remote flow control */ +#define LFLOW_ON 1 /* Enable remote flow control */ +#define LFLOW_RESTART_ANY 2 /* Restart output on any char */ +#define LFLOW_RESTART_XON 3 /* Restart output only on XON */ + +/* + * LINEMODE suboptions + */ + +#define LM_MODE 1 +#define LM_FORWARDMASK 2 +#define LM_SLC 3 + +#define MODE_EDIT 0x01 +#define MODE_TRAPSIG 0x02 +#define MODE_ACK 0x04 +#define MODE_SOFT_TAB 0x08 +#define MODE_LIT_ECHO 0x10 + +#define MODE_MASK 0x1f + +/* Not part of protocol, but needed to simplify things... */ +#define MODE_FLOW 0x0100 +#define MODE_ECHO 0x0200 +#define MODE_INBIN 0x0400 +#define MODE_OUTBIN 0x0800 +#define MODE_FORCE 0x1000 + +#define SLC_SYNCH 1 +#define SLC_BRK 2 +#define SLC_IP 3 +#define SLC_AO 4 +#define SLC_AYT 5 +#define SLC_EOR 6 +#define SLC_ABORT 7 +#define SLC_EOF 8 +#define SLC_SUSP 9 +#define SLC_EC 10 +#define SLC_EL 11 +#define SLC_EW 12 +#define SLC_RP 13 +#define SLC_LNEXT 14 +#define SLC_XON 15 +#define SLC_XOFF 16 +#define SLC_FORW1 17 +#define SLC_FORW2 18 + +#define NSLC 18 + +/* + * For backwards compatability, we define SLC_NAMES to be the + * list of names if SLC_NAMES is not defined. + */ +#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \ + "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \ + "LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0, +#ifdef SLC_NAMES +char *slc_names[] = { + SLC_NAMELIST +}; +#else +extern char *slc_names[]; +#define SLC_NAMES SLC_NAMELIST +#endif + +#define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC) +#define SLC_NAME(x) slc_names[x] + +#define SLC_NOSUPPORT 0 +#define SLC_CANTCHANGE 1 +#define SLC_VARIABLE 2 +#define SLC_DEFAULT 3 +#define SLC_LEVELBITS 0x03 + +#define SLC_FUNC 0 +#define SLC_FLAGS 1 +#define SLC_VALUE 2 + +#define SLC_ACK 0x80 +#define SLC_FLUSHIN 0x40 +#define SLC_FLUSHOUT 0x20 + +#define OLD_ENV_VAR 1 +#define OLD_ENV_VALUE 0 +#define NEW_ENV_VAR 0 +#define NEW_ENV_VALUE 1 +#define ENV_ESC 2 +#define ENV_USERVAR 3 + +/* + * AUTHENTICATION suboptions + */ + +/* + * Who is authenticating who ... + */ +#define AUTH_WHO_CLIENT 0 /* Client authenticating server */ +#define AUTH_WHO_SERVER 1 /* Server authenticating client */ +#define AUTH_WHO_MASK 1 + +/* + * amount of authentication done + */ +#define AUTH_HOW_ONE_WAY 0 +#define AUTH_HOW_MUTUAL 2 +#define AUTH_HOW_MASK 2 + +#define AUTHTYPE_NULL 0 +#define AUTHTYPE_KERBEROS_V4 1 +#define AUTHTYPE_KERBEROS_V5 2 +#define AUTHTYPE_SPX 3 +#define AUTHTYPE_MINK 4 +#define AUTHTYPE_CNT 5 + +#define AUTHTYPE_TEST 99 + +#ifdef AUTH_NAMES +char *authtype_names[] = { + "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0, +}; +#else +extern char *authtype_names[]; +#endif + +#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT) +#define AUTHTYPE_NAME(x) authtype_names[x] + +/* + * ENCRYPTion suboptions + */ +#define ENCRYPT_IS 0 /* I pick encryption type ... */ +#define ENCRYPT_SUPPORT 1 /* I support encryption types ... */ +#define ENCRYPT_REPLY 2 /* Initial setup response */ +#define ENCRYPT_START 3 /* Am starting to send encrypted */ +#define ENCRYPT_END 4 /* Am ending encrypted */ +#define ENCRYPT_REQSTART 5 /* Request you start encrypting */ +#define ENCRYPT_REQEND 6 /* Request you send encrypting */ +#define ENCRYPT_ENC_KEYID 7 +#define ENCRYPT_DEC_KEYID 8 +#define ENCRYPT_CNT 9 + +#define ENCTYPE_ANY 0 +#define ENCTYPE_DES_CFB64 1 +#define ENCTYPE_DES_OFB64 2 +#define ENCTYPE_CNT 3 + +#ifdef ENCRYPT_NAMES +char *encrypt_names[] = { + "IS", "SUPPORT", "REPLY", "START", "END", + "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID", + 0, +}; +char *enctype_names[] = { + "ANY", "DES_CFB64", "DES_OFB64", 0, +}; +#else +extern char *encrypt_names[]; +extern char *enctype_names[]; +#endif + + +#define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT) +#define ENCRYPT_NAME(x) encrypt_names[x] + +#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT) +#define ENCTYPE_NAME(x) enctype_names[x] + +#endif /* !_TELNET_H_ */ diff --git a/include/arpa/tftp.h b/include/arpa/tftp.h new file mode 100644 index 0000000..1e7324f --- /dev/null +++ b/include/arpa/tftp.h @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1983, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)tftp.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _TFTP_H_ +#define _TFTP_H_ + +/* + * Trivial File Transfer Protocol (IEN-133) + */ +#define SEGSIZE 512 /* data segment size */ + +/* + * Packet types. + */ +#define RRQ 01 /* read request */ +#define WRQ 02 /* write request */ +#define DATA 03 /* data packet */ +#define ACK 04 /* acknowledgement */ +#define ERROR 05 /* error code */ + +struct tftphdr { + short th_opcode; /* packet type */ + union { + short tu_block; /* block # */ + short tu_code; /* error code */ + char tu_stuff[1]; /* request packet stuff */ + } th_u; + char th_data[1]; /* data or error string */ +}; + +#define th_block th_u.tu_block +#define th_code th_u.tu_code +#define th_stuff th_u.tu_stuff +#define th_msg th_data + +/* + * Error codes. + */ +#define EUNDEF 0 /* not defined */ +#define ENOTFOUND 1 /* file not found */ +#define EACCESS 2 /* access violation */ +#define ENOSPACE 3 /* disk full or allocation exceeded */ +#define EBADOP 4 /* illegal TFTP operation */ +#define EBADID 5 /* unknown transfer ID */ +#define EEXISTS 6 /* file already exists */ +#define ENOUSER 7 /* no such user */ + +#endif /* !_TFTP_H_ */ diff --git a/headers.subproj/asm.h b/include/asm.h similarity index 100% rename from headers.subproj/asm.h rename to include/asm.h diff --git a/include/authentication.h b/include/authentication.h new file mode 100644 index 0000000..4fcd000 --- /dev/null +++ b/include/authentication.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#ifndef __AUTHENTICATION_H__ +#define __AUTHENTICATION_H__ + +extern char *groupNameForTask(int taskNum); +extern int isAuthenticatedAsAdministrator(void); +extern int isAuthenticatedAsAdministratorForTask(int taskNum); +extern int isAuthenticatedAsRoot(void); + +#endif /* __AUTHENTICATION_H__ */ diff --git a/include/bitstring.h b/include/bitstring.h new file mode 100644 index 0000000..d275de0 --- /dev/null +++ b/include/bitstring.h @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Paul Vixie. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)bitstring.h 8.1 (Berkeley) 7/19/93 + */ + +#ifndef _BITSTRING_H_ +#define _BITSTRING_H_ + +typedef unsigned char bitstr_t; + +/* internal macros */ + /* byte of the bitstring bit is in */ +#define _bit_byte(bit) \ + ((bit) >> 3) + + /* mask for the bit within its byte */ +#define _bit_mask(bit) \ + (1 << ((bit)&0x7)) + +/* external macros */ + /* bytes in a bitstring of nbits bits */ +#define bitstr_size(nbits) \ + ((((nbits) - 1) >> 3) + 1) + + /* allocate a bitstring */ +#define bit_alloc(nbits) \ + (bitstr_t *)calloc(1, \ + (unsigned int)bitstr_size(nbits) * sizeof(bitstr_t)) + + /* allocate a bitstring on the stack */ +#define bit_decl(name, nbits) \ + (name)[bitstr_size(nbits)] + + /* is bit N of bitstring name set? */ +#define bit_test(name, bit) \ + ((name)[_bit_byte(bit)] & _bit_mask(bit)) + + /* set bit N of bitstring name */ +#define bit_set(name, bit) \ + (name)[_bit_byte(bit)] |= _bit_mask(bit) + + /* clear bit N of bitstring name */ +#define bit_clear(name, bit) \ + (name)[_bit_byte(bit)] &= ~_bit_mask(bit) + + /* clear bits start ... stop in bitstring */ +#define bit_nclear(name, start, stop) { \ + register bitstr_t *_name = name; \ + register int _start = start, _stop = stop; \ + register int _startbyte = _bit_byte(_start); \ + register int _stopbyte = _bit_byte(_stop); \ + if (_startbyte == _stopbyte) { \ + _name[_startbyte] &= ((0xff >> (8 - (_start&0x7))) | \ + (0xff << ((_stop&0x7) + 1))); \ + } else { \ + _name[_startbyte] &= 0xff >> (8 - (_start&0x7)); \ + while (++_startbyte < _stopbyte) \ + _name[_startbyte] = 0; \ + _name[_stopbyte] &= 0xff << ((_stop&0x7) + 1); \ + } \ +} + + /* set bits start ... stop in bitstring */ +#define bit_nset(name, start, stop) { \ + register bitstr_t *_name = name; \ + register int _start = start, _stop = stop; \ + register int _startbyte = _bit_byte(_start); \ + register int _stopbyte = _bit_byte(_stop); \ + if (_startbyte == _stopbyte) { \ + _name[_startbyte] |= ((0xff << (_start&0x7)) & \ + (0xff >> (7 - (_stop&0x7)))); \ + } else { \ + _name[_startbyte] |= 0xff << ((_start)&0x7); \ + while (++_startbyte < _stopbyte) \ + _name[_startbyte] = 0xff; \ + _name[_stopbyte] |= 0xff >> (7 - (_stop&0x7)); \ + } \ +} + + /* find first bit clear in name */ +#define bit_ffc(name, nbits, value) { \ + register bitstr_t *_name = name; \ + register int _byte, _nbits = nbits; \ + register int _stopbyte = _bit_byte(_nbits), _value = -1; \ + for (_byte = 0; _byte < _stopbyte; ++_byte) \ + if (_name[_byte] != 0xff) { \ + _value = _byte << 3; \ + for (_stopbyte = _name[_byte]; (_stopbyte&0x1); \ + ++_value, _stopbyte >>= 1); \ + break; \ + } \ + *(value) = _value; \ +} + + /* find first bit set in name */ +#define bit_ffs(name, nbits, value) { \ + register bitstr_t *_name = name; \ + register int _byte, _nbits = nbits; \ + register int _stopbyte = _bit_byte(_nbits), _value = -1; \ + for (_byte = 0; _byte < _stopbyte; ++_byte) \ + if (_name[_byte]) { \ + _value = _byte << 3; \ + for (_stopbyte = _name[_byte]; !(_stopbyte&0x1); \ + ++_value, _stopbyte >>= 1); \ + break; \ + } \ + *(value) = _value; \ +} + +#endif /* !_BITSTRING_H_ */ diff --git a/include/c.h b/include/c.h new file mode 100644 index 0000000..905d271 --- /dev/null +++ b/include/c.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Standard C macros + * + ********************************************************************** + * HISTORY + * 02-Feb-86 Glenn Marcy (gm0w) at Carnegie-Mellon University + * Added check to allow multiple or recursive inclusion of this + * file. Added bool enum from machine/types.h for regular users + * that want a real boolean type. + * + * 29-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University + * Also change spacing of MAX and MIN to coincide with that of + * sys/param.h. + * + * 19-Nov-85 Glenn Marcy (gm0w) at Carnegie-Mellon University + * Changed the number of tabs between TRUE, FALSE and their + * respective values to match those in sys/types.h. + * + * 17-Dec-84 Glenn Marcy (gm0w) at Carnegie-Mellon University + * Only define TRUE and FALSE if not defined. Added caseE macro + * for using enumerated types in switch statements. + * + * 23-Apr-81 Mike Accetta (mja) at Carnegie-Mellon University + * Added "sizeofS" and "sizeofA" macros which expand to the size + * of a string constant and array respectively. + * + ********************************************************************** + */ + +#ifndef _C_INCLUDE_ +#define _C_INCLUDE_ + +#ifndef ABS +#define ABS(x) ((x)>=0?(x):-(x)) +#endif /* ABS */ +#ifndef MIN +#define MIN(a,b) (((a)<(b))?(a):(b)) +#endif /* MIN */ +#ifndef MAX +#define MAX(a,b) (((a)>(b))?(a):(b)) +#endif /* MAX */ + +#ifndef FALSE +#define FALSE 0 +#endif /* FALSE */ +#ifndef TRUE +#define TRUE 1 +#endif /* TRUE */ + +#define CERROR (-1) + +#ifndef bool +typedef enum { false = 0, true = 1 } bool; +#endif /* bool */ + +#define sizeofS(string) (sizeof(string) - 1) +#define sizeofA(array) (sizeof(array)/sizeof(array[0])) + +#define caseE(enum_type) case (int)(enum_type) + +#endif /* _C_INCLUDE_ */ diff --git a/headers.subproj/crt_externs.h b/include/crt_externs.h similarity index 97% rename from headers.subproj/crt_externs.h rename to include/crt_externs.h index 9434878..94fc666 100644 --- a/headers.subproj/crt_externs.h +++ b/include/crt_externs.h @@ -33,4 +33,5 @@ extern char ***_NSGetArgv(void); extern int *_NSGetArgc(void); extern char ***_NSGetEnviron(void); +extern char **_NSGetProgname(void); extern struct mach_header *_NSGetMachExecuteHeader(void); diff --git a/include/ctype.h b/include/ctype.h new file mode 100644 index 0000000..244ae10 --- /dev/null +++ b/include/ctype.h @@ -0,0 +1,225 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * This code is derived from software contributed to Berkeley by + * Paul Borman at Krystal Technologies. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)ctype.h 8.4 (Berkeley) 1/21/94 + */ + +#ifndef _CTYPE_H_ +#define _CTYPE_H_ + +#include + +#define _A 0x00000100L /* Alpha */ +#define _C 0x00000200L /* Control */ +#define _D 0x00000400L /* Digit */ +#define _G 0x00000800L /* Graph */ +#define _L 0x00001000L /* Lower */ +#define _P 0x00002000L /* Punct */ +#define _S 0x00004000L /* Space */ +#define _U 0x00008000L /* Upper */ +#define _X 0x00010000L /* X digit */ +#define _B 0x00020000L /* Blank */ +#define _R 0x00040000L /* Print */ +#define _I 0x00080000L /* Ideogram */ +#define _T 0x00100000L /* Special */ +#define _Q 0x00200000L /* Phonogram */ + +#define _CTYPE_A _A +#define _CTYPE_C _C +#define _CTYPE_D _D +#define _CTYPE_G _G +#define _CTYPE_L _L +#define _CTYPE_P _P +#define _CTYPE_S _S +#define _CTYPE_U _U +#define _CTYPE_X _X +#define _CTYPE_B _B +#define _CTYPE_R _R +#define _CTYPE_I _I +#define _CTYPE_T _T +#define _CTYPE_Q _Q + +__BEGIN_DECLS +int isalnum __P((int)); +int isalpha __P((int)); +int iscntrl __P((int)); +int isdigit __P((int)); +int isgraph __P((int)); +int islower __P((int)); +int isprint __P((int)); +int ispunct __P((int)); +int isspace __P((int)); +int isupper __P((int)); +int isxdigit __P((int)); +int tolower __P((int)); +int toupper __P((int)); + +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) +int digittoint __P((int)); +int isascii __P((int)); +int isblank __P((int)); +int ishexnumber __P((int)); +int isideogram __P((int)); +int isnumber __P((int)); +int isphonogram __P((int)); +int isrune __P((int)); +int isspecial __P((int)); +int toascii __P((int)); +#endif +__END_DECLS + + +#define isalnum(c) __istype((c), (_A|_D)) +#define isalpha(c) __istype((c), _A) +#define iscntrl(c) __istype((c), _C) +#define isdigit(c) __isctype((c), _D) /* ANSI -- locale independent */ +#define isgraph(c) __istype((c), _G) +#define islower(c) __istype((c), _L) +#define isprint(c) __istype((c), _R) +#define ispunct(c) __istype((c), _P) +#define isspace(c) __istype((c), _S) +#define isupper(c) __istype((c), _U) +#define isxdigit(c) __isctype((c), _X) /* ANSI -- locale independent */ +#define tolower(c) __tolower(c) +#define toupper(c) __toupper(c) + +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) +#define digittoint(c) __maskrune((c), 0xFF) +#define isascii(c) ((c & ~0x7F) == 0) +#define isblank(c) __istype((c), _B) +#define ishexnumber(c) __istype((c), _X) +#define isideogram(c) __istype((c), _I) +#define isnumber(c) __istype((c), _D) +#define isphonogram(c) __istype((c), _T) +#define isrune(c) __istype((c), 0xFFFFFF00L) +#define isspecial(c) __istype((c), _Q) +#define toascii(c) ((c) & 0x7F) +#endif + +/* See comments in about _BSD_RUNE_T_. */ +__BEGIN_DECLS +unsigned long ___runetype __P((_BSD_CT_RUNE_T_)); +_BSD_CT_RUNE_T_ ___tolower __P((_BSD_CT_RUNE_T_)); +_BSD_CT_RUNE_T_ ___toupper __P((_BSD_CT_RUNE_T_)); +__END_DECLS + +/* + * _EXTERNALIZE_CTYPE_INLINES_ is defined in locale/nomacros.c to tell us + * to generate code for extern versions of all our inline functions. + */ +#ifdef _EXTERNALIZE_CTYPE_INLINES_ +#define _USE_CTYPE_INLINE_ +#define static +#define __inline +#endif + +/* + * Use inline functions if we are allowed to and the compiler supports them. + */ +#if !defined(_DONT_USE_CTYPE_INLINE_) && \ + (defined(_USE_CTYPE_INLINE_) || defined(__GNUC__) || defined(__cplusplus)) + +static __inline int +__maskrune(_BSD_CT_RUNE_T_ _c, unsigned long _f) +{ + return ((_c < 0 || _c >= _CACHED_RUNES) ? ___runetype(_c) : + _CurrentRuneLocale->runetype[_c]) & _f; +} + +static __inline int +__istype(_BSD_CT_RUNE_T_ c, unsigned long f) +{ + return !!(__maskrune(c, f)); +} + +static __inline _BSD_CT_RUNE_T_ +__isctype(_BSD_CT_RUNE_T_ _c, unsigned long _f) +{ + return (_c < 0 || _c >= _CACHED_RUNES) ? 0 : + !!(_DefaultRuneLocale.runetype[_c] & _f); +} + +static __inline _BSD_CT_RUNE_T_ +__toupper(_BSD_CT_RUNE_T_ _c) +{ + return (_c < 0 || _c >= _CACHED_RUNES) ? ___toupper(_c) : + _CurrentRuneLocale->mapupper[_c]; +} + +static __inline _BSD_CT_RUNE_T_ +__tolower(_BSD_CT_RUNE_T_ _c) +{ + return (_c < 0 || _c >= _CACHED_RUNES) ? ___tolower(_c) : + _CurrentRuneLocale->maplower[_c]; +} + +#else /* not using inlines */ + +__BEGIN_DECLS +int __maskrune __P((_BSD_CT_RUNE_T_, unsigned long)); +int __istype __P((_BSD_CT_RUNE_T_, unsigned long)); +int __isctype __P((_BSD_CT_RUNE_T_, unsigned long)); +_BSD_CT_RUNE_T_ __toupper __P((_BSD_CT_RUNE_T_)); +_BSD_CT_RUNE_T_ __tolower __P((_BSD_CT_RUNE_T_)); +__END_DECLS +#endif /* using inlines */ + +#endif /* !_CTYPE_H_ */ diff --git a/include/db.h b/include/db.h new file mode 100644 index 0000000..1e4cce8 --- /dev/null +++ b/include/db.h @@ -0,0 +1,239 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/*- + * Copyright (c) 1990, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)db.h 8.4 (Berkeley) 2/21/94 + */ + +#ifndef _DB_H_ +#define _DB_H_ + +#include +#include + +#include + +#define RET_ERROR -1 /* Return values. */ +#define RET_SUCCESS 0 +#define RET_SPECIAL 1 + +#define MAX_PAGE_NUMBER 0xffffffff /* >= # of pages in a file */ +typedef u_int32_t pgno_t; +#define MAX_PAGE_OFFSET 65535 /* >= # of bytes in a page */ +typedef u_int16_t indx_t; +#define MAX_REC_NUMBER 0xffffffff /* >= # of records in a tree */ +typedef u_int32_t recno_t; + +/* Key/data structure -- a Data-Base Thang. */ +typedef struct { + void *data; /* data */ + size_t size; /* data length */ +} DBT; + +/* Routine flags. */ +#define R_CURSOR 1 /* del, put, seq */ +#define __R_UNUSED 2 /* UNUSED */ +#define R_FIRST 3 /* seq */ +#define R_IAFTER 4 /* put (RECNO) */ +#define R_IBEFORE 5 /* put (RECNO) */ +#define R_LAST 6 /* seq (BTREE, RECNO) */ +#define R_NEXT 7 /* seq */ +#define R_NOOVERWRITE 8 /* put */ +#define R_PREV 9 /* seq (BTREE, RECNO) */ +#define R_SETCURSOR 10 /* put (RECNO) */ +#define R_RECNOSYNC 11 /* sync (RECNO) */ + +typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE; + +/* + * !!! + * The following flags are included in the dbopen(3) call as part of the + * open(2) flags. In order to avoid conflicts with the open flags, start + * at the top of the 16 or 32-bit number space and work our way down. If + * the open flags were significantly expanded in the future, it could be + * a problem. Wish I'd left another flags word in the dbopen call. + * + * !!! + * None of this stuff is implemented yet. The only reason that it's here + * is so that the access methods can skip copying the key/data pair when + * the DB_LOCK flag isn't set. + */ +#if UINT_MAX > 65535 +#define DB_LOCK 0x20000000 /* Do locking. */ +#define DB_SHMEM 0x40000000 /* Use shared memory. */ +#define DB_TXN 0x80000000 /* Do transactions. */ +#else +#define DB_LOCK 0x2000 /* Do locking. */ +#define DB_SHMEM 0x4000 /* Use shared memory. */ +#define DB_TXN 0x8000 /* Do transactions. */ +#endif + +/* Access method description structure. */ +typedef struct __db { + DBTYPE type; /* Underlying db type. */ + int (*close) __P((struct __db *)); + int (*del) __P((const struct __db *, const DBT *, u_int)); + int (*get) __P((const struct __db *, const DBT *, DBT *, u_int)); + int (*put) __P((const struct __db *, DBT *, const DBT *, u_int)); + int (*seq) __P((const struct __db *, DBT *, DBT *, u_int)); + int (*sync) __P((const struct __db *, u_int)); + void *internal; /* Access method private. */ + int (*fd) __P((const struct __db *)); +} DB; + +#define BTREEMAGIC 0x053162 +#define BTREEVERSION 3 + +/* Structure used to pass parameters to the btree routines. */ +typedef struct { +#define R_DUP 0x01 /* duplicate keys */ + u_long flags; + u_int cachesize; /* bytes to cache */ + int maxkeypage; /* maximum keys per page */ + int minkeypage; /* minimum keys per page */ + u_int psize; /* page size */ + int (*compare) /* comparison function */ + __P((const DBT *, const DBT *)); + size_t (*prefix) /* prefix function */ + __P((const DBT *, const DBT *)); + int lorder; /* byte order */ +} BTREEINFO; + +#define HASHMAGIC 0x061561 +#define HASHVERSION 2 + +/* Structure used to pass parameters to the hashing routines. */ +typedef struct { + u_int bsize; /* bucket size */ + u_int ffactor; /* fill factor */ + u_int nelem; /* number of elements */ + u_int cachesize; /* bytes to cache */ + u_int32_t /* hash function */ + (*hash) __P((const void *, size_t)); + int lorder; /* byte order */ +} HASHINFO; + +/* Structure used to pass parameters to the record routines. */ +typedef struct { +#define R_FIXEDLEN 0x01 /* fixed-length records */ +#define R_NOKEY 0x02 /* key not required */ +#define R_SNAPSHOT 0x04 /* snapshot the input */ + u_long flags; + u_int cachesize; /* bytes to cache */ + u_int psize; /* page size */ + int lorder; /* byte order */ + size_t reclen; /* record length (fixed-length records) */ + u_char bval; /* delimiting byte (variable-length records */ + char *bfname; /* btree file name */ +} RECNOINFO; + +#ifdef __DBINTERFACE_PRIVATE +/* + * Little endian <==> big endian 32-bit swap macros. + * M_32_SWAP swap a memory location + * P_32_SWAP swap a referenced memory location + * P_32_COPY swap from one location to another + */ +#define M_32_SWAP(a) { \ + u_int32_t _tmp = a; \ + ((char *)&a)[0] = ((char *)&_tmp)[3]; \ + ((char *)&a)[1] = ((char *)&_tmp)[2]; \ + ((char *)&a)[2] = ((char *)&_tmp)[1]; \ + ((char *)&a)[3] = ((char *)&_tmp)[0]; \ +} +#define P_32_SWAP(a) { \ + u_int32_t _tmp = *(u_int32_t *)a; \ + ((char *)a)[0] = ((char *)&_tmp)[3]; \ + ((char *)a)[1] = ((char *)&_tmp)[2]; \ + ((char *)a)[2] = ((char *)&_tmp)[1]; \ + ((char *)a)[3] = ((char *)&_tmp)[0]; \ +} +#define P_32_COPY(a, b) { \ + ((char *)&(b))[0] = ((char *)&(a))[3]; \ + ((char *)&(b))[1] = ((char *)&(a))[2]; \ + ((char *)&(b))[2] = ((char *)&(a))[1]; \ + ((char *)&(b))[3] = ((char *)&(a))[0]; \ +} + +/* + * Little endian <==> big endian 16-bit swap macros. + * M_16_SWAP swap a memory location + * P_16_SWAP swap a referenced memory location + * P_16_COPY swap from one location to another + */ +#define M_16_SWAP(a) { \ + u_int16_t _tmp = a; \ + ((char *)&a)[0] = ((char *)&_tmp)[1]; \ + ((char *)&a)[1] = ((char *)&_tmp)[0]; \ +} +#define P_16_SWAP(a) { \ + u_int16_t _tmp = *(u_int16_t *)a; \ + ((char *)a)[0] = ((char *)&_tmp)[1]; \ + ((char *)a)[1] = ((char *)&_tmp)[0]; \ +} +#define P_16_COPY(a, b) { \ + ((char *)&(b))[0] = ((char *)&(a))[1]; \ + ((char *)&(b))[1] = ((char *)&(a))[0]; \ +} +#endif + +__BEGIN_DECLS +DB *dbopen __P((const char *, int, int, DBTYPE, const void *)); + +#ifdef __DBINTERFACE_PRIVATE +DB *__bt_open __P((const char *, int, int, const BTREEINFO *, int)); +DB *__hash_open __P((const char *, int, int, const HASHINFO *, int)); +DB *__rec_open __P((const char *, int, int, const RECNOINFO *, int)); +void __dbpanic __P((DB *dbp)); +#endif +__END_DECLS +#endif /* !_DB_H_ */ diff --git a/include/dirent.h b/include/dirent.h new file mode 100644 index 0000000..1a67741 --- /dev/null +++ b/include/dirent.h @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/*- + * Copyright (c) 1989, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)dirent.h 8.2 (Berkeley) 7/28/94 + */ + +#ifndef _DIRENT_H_ +#define _DIRENT_H_ + +/* + * The kernel defines the format of directory entries returned by + * the getdirentries(2) system call. + */ +#include + +#ifdef _POSIX_SOURCE +typedef void * DIR; +#else + +#define d_ino d_fileno /* backward compatibility */ + +/* definitions for library routines operating on directories. */ +#define DIRBLKSIZ 1024 + +/* structure describing an open directory. */ +typedef struct _dirdesc { + int dd_fd; /* file descriptor associated with directory */ + long dd_loc; /* offset in current buffer */ + long dd_size; /* amount of data returned by getdirentries */ + char *dd_buf; /* data buffer */ + int dd_len; /* size of data buffer */ + long dd_seek; /* magic cookie returned by getdirentries */ + long dd_rewind; /* magic cookie for rewinding */ + int dd_flags; /* flags for readdir */ +} DIR; + +#define dirfd(dirp) ((dirp)->dd_fd) + +/* flags for opendir2 */ +#define DTF_HIDEW 0x0001 /* hide whiteout entries */ +#define DTF_NODUP 0x0002 /* don't return duplicate names */ +#define DTF_REWIND 0x0004 /* rewind after reading union stack */ +#define __DTF_READALL 0x0008 /* everything has been read */ + +#ifndef NULL +#define NULL 0 +#endif + +#endif /* _POSIX_SOURCE */ + +#ifndef KERNEL + +#include + +__BEGIN_DECLS +DIR *opendir __P((const char *)); +struct dirent *readdir __P((DIR *)); +void rewinddir __P((DIR *)); +int closedir __P((DIR *)); +#ifndef _POSIX_SOURCE +DIR *__opendir2 __P((const char *, int)); +long telldir __P((const DIR *)); +void seekdir __P((DIR *, long)); +int scandir __P((const char *, struct dirent ***, + int (*)(struct dirent *), int (*)(const void *, const void *))); +int alphasort __P((const void *, const void *)); +int getdirentries __P((int, char *, int, long *)); +int readdir_r __P((DIR *, struct dirent *, struct dirent **)); +#endif /* not POSIX */ +__END_DECLS + +#endif /* !KERNEL */ + +#endif /* !_DIRENT_H_ */ diff --git a/include/disktab.h b/include/disktab.h new file mode 100644 index 0000000..386cb64 --- /dev/null +++ b/include/disktab.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1983, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)disktab.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _DISKTAB_H_ +#define _DISKTAB_H_ + +/* + * Disk description table, see disktab(5) + */ +#define DISKTAB "/etc/disktab" + +struct disktab { + char *d_name; /* drive name */ + char *d_type; /* drive type */ + int d_secsize; /* sector size in bytes */ + int d_ntracks; /* # tracks/cylinder */ + int d_nsectors; /* # sectors/track */ + int d_ncylinders; /* # cylinders */ + int d_rpm; /* revolutions/minute */ + int d_badsectforw; /* supports DEC bad144 std */ + int d_sectoffset; /* use sect rather than cyl offsets */ + struct partition { + int p_size; /* #sectors in partition */ + short p_bsize; /* block size in bytes */ + short p_fsize; /* frag size in bytes */ + } d_partitions[8]; +}; + +#endif /* !_DISKTAB_H_ */ diff --git a/include/err.h b/include/err.h new file mode 100644 index 0000000..59e6d22 --- /dev/null +++ b/include/err.h @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/*- + * Copyright (c) 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)err.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _ERR_H_ +#define _ERR_H_ + +/* + * Don't use va_list in the err/warn prototypes. Va_list is typedef'd in two + * places ( and ), so if we include one + * of them here we may collide with the utility's includes. It's unreasonable + * for utilities to have to include one of them to include err.h, so we get + * _BSD_VA_LIST_ from and use it. + */ +#include +#include + +__BEGIN_DECLS +__dead void err __P((int, const char *, ...)) __attribute__((__noreturn__)); +__dead void verr __P((int, const char *, _BSD_VA_LIST_)) __attribute__((__noreturn__)); +__dead void errx __P((int, const char *, ...)) __attribute__((__noreturn__)); +__dead void verrx __P((int, const char *, _BSD_VA_LIST_)) __attribute__((__noreturn__)); +void warn __P((const char *, ...)); +void vwarn __P((const char *, _BSD_VA_LIST_)); +void warnx __P((const char *, ...)); +void vwarnx __P((const char *, _BSD_VA_LIST_)); +__END_DECLS + +#endif /* !_ERR_H_ */ diff --git a/mach.subproj/bootstrap.defs b/include/errno.h similarity index 90% rename from mach.subproj/bootstrap.defs rename to include/errno.h index 8f57322..57f2f7b 100644 --- a/mach.subproj/bootstrap.defs +++ b/include/errno.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -19,4 +19,5 @@ * * @APPLE_LICENSE_HEADER_END@ */ -#include +#include + diff --git a/include/fcntl.h b/include/fcntl.h new file mode 100644 index 0000000..d936d70 --- /dev/null +++ b/include/fcntl.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +#include diff --git a/include/fnmatch.h b/include/fnmatch.h new file mode 100644 index 0000000..ae89fc0 --- /dev/null +++ b/include/fnmatch.h @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/*- + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)fnmatch.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _FNMATCH_H_ +#define _FNMATCH_H_ + +#define FNM_NOMATCH 1 /* Match failed. */ + +#define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */ +#define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */ +#define FNM_PERIOD 0x04 /* Period must be matched by period. */ + +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) +#define FNM_LEADING_DIR 0x08 /* Ignore / after Imatch. */ +#define FNM_CASEFOLD 0x10 /* Case insensitive search. */ +#define FNM_IGNORECASE FNM_CASEFOLD +#define FNM_FILE_NAME FNM_PATHNAME +#endif + +#include + +__BEGIN_DECLS +#ifndef _POSIX_SOURCE +int fnmatch __P((const char *, const char *, int)); +#endif +__END_DECLS + +#endif /* !_FNMATCH_H_ */ diff --git a/include/fsproperties.h b/include/fsproperties.h new file mode 100644 index 0000000..15db660 --- /dev/null +++ b/include/fsproperties.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#ifndef _FSPROPERTIES_H_ +#define _FSPROPERTIES_H_ + +/* Info plist keys */ +#define kFSMediaTypesKey "FSMediaTypes" +#define kFSPersonalitiesKey "FSPersonalities" + +/* Sub-keys for FSMediaTypes dictionaries */ +#define kFSMediaPropertiesKey "FSMediaProperties" +#define kFSProbeArgumentsKey "FSProbeArguments" +#define kFSProbeExecutableKey "FSProbeExecutable" +#define kFSProbeOrderKey "FSProbeOrder" + +/* Sub-keys for FSPersonalities dictionaries */ +#define kFSFormatArgumentsKey "FSFormatArguments" +#define kFSFormatContentMaskKey "FSFormatContentMask" +#define kFSFormatExecutableKey "FSFormatExecutable" +#define kFSFormatMinimumSizeKey "FSFormatMinimumSize" +#define kFSMountArgumentsKey "FSMountArguments" +#define kFSMountExecutableKey "FSMountExecutable" +#define kFSNameKey "FSName" +#define kFSRepairArgumentsKey "FSRepairArguments" +#define kFSRepairExecutableKey "FSRepairExecutable" +#define kFSVerificationArgumentsKey "FSVerificationArguments" +#define kFSVerificationExecutableKey "FSVerificationExecutable" + +#endif /* _FSPROPERTIES_H_ */ diff --git a/include/fstab.h b/include/fstab.h new file mode 100644 index 0000000..5427d34 --- /dev/null +++ b/include/fstab.h @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1980, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)fstab.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _FSTAB_H_ +#define _FSTAB_H_ + +/* + * File system table, see fstab(5). + * + * Used by dump, mount, umount, swapon, fsck, df, ... + * + * For ufs fs_spec field is the block special name. Programs that want to + * use the character special name must create that name by prepending a 'r' + * after the right most slash. Quota files are always named "quotas", so + * if type is "rq", then use concatenation of fs_file and "quotas" to locate + * quota file. + */ +#define _PATH_FSTAB "/etc/fstab" +#define FSTAB "/etc/fstab" /* deprecated */ + +#define FSTAB_RW "rw" /* read/write device */ +#define FSTAB_RQ "rq" /* read/write with quotas */ +#define FSTAB_RO "ro" /* read-only device */ +#define FSTAB_SW "sw" /* swap device */ +#define FSTAB_XX "xx" /* ignore totally */ + +struct fstab { + char *fs_spec; /* block special device name */ + char *fs_file; /* file system path prefix */ + char *fs_vfstype; /* File system type, ufs, nfs */ + char *fs_mntops; /* Mount options ala -o */ + char *fs_type; /* FSTAB_* from fs_mntops */ + int fs_freq; /* dump frequency, in days */ + int fs_passno; /* pass number on parallel dump */ +}; + +#include + +__BEGIN_DECLS +struct fstab *getfsent __P((void)); +struct fstab *getfsspec __P((const char *)); +struct fstab *getfsfile __P((const char *)); +int setfsent __P((void)); +void endfsent __P((void)); +__END_DECLS + +#endif /* !_FSTAB_H_ */ diff --git a/include/fts.h b/include/fts.h new file mode 100644 index 0000000..3311bd3 --- /dev/null +++ b/include/fts.h @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1989, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)fts.h 8.3 (Berkeley) 8/14/94 + */ + +#ifndef _FTS_H_ +#define _FTS_H_ + +typedef struct { + struct _ftsent *fts_cur; /* current node */ + struct _ftsent *fts_child; /* linked list of children */ + struct _ftsent **fts_array; /* sort array */ + dev_t fts_dev; /* starting device # */ + char *fts_path; /* path for this descent */ + int fts_rfd; /* fd for root */ + int fts_pathlen; /* sizeof(path) */ + int fts_nitems; /* elements in the sort array */ + int (*fts_compar)(); /* compare function */ + +#define FTS_COMFOLLOW 0x001 /* follow command line symlinks */ +#define FTS_LOGICAL 0x002 /* logical walk */ +#define FTS_NOCHDIR 0x004 /* don't change directories */ +#define FTS_NOSTAT 0x008 /* don't get stat info */ +#define FTS_PHYSICAL 0x010 /* physical walk */ +#define FTS_SEEDOT 0x020 /* return dot and dot-dot */ +#define FTS_XDEV 0x040 /* don't cross devices */ +#define FTS_WHITEOUT 0x080 /* return whiteout information */ +#define FTS_OPTIONMASK 0x0ff /* valid user option mask */ + +#define FTS_NAMEONLY 0x100 /* (private) child names only */ +#define FTS_STOP 0x200 /* (private) unrecoverable error */ + int fts_options; /* fts_open options, global flags */ +} FTS; + +typedef struct _ftsent { + struct _ftsent *fts_cycle; /* cycle node */ + struct _ftsent *fts_parent; /* parent directory */ + struct _ftsent *fts_link; /* next file in directory */ + long fts_number; /* local numeric value */ + void *fts_pointer; /* local address value */ + char *fts_accpath; /* access path */ + char *fts_path; /* root path */ + int fts_errno; /* errno for this node */ + int fts_symfd; /* fd for symlink */ + u_short fts_pathlen; /* strlen(fts_path) */ + u_short fts_namelen; /* strlen(fts_name) */ + + ino_t fts_ino; /* inode */ + dev_t fts_dev; /* device */ + nlink_t fts_nlink; /* link count */ + +#define FTS_ROOTPARENTLEVEL -1 +#define FTS_ROOTLEVEL 0 + short fts_level; /* depth (-1 to N) */ + +#define FTS_D 1 /* preorder directory */ +#define FTS_DC 2 /* directory that causes cycles */ +#define FTS_DEFAULT 3 /* none of the above */ +#define FTS_DNR 4 /* unreadable directory */ +#define FTS_DOT 5 /* dot or dot-dot */ +#define FTS_DP 6 /* postorder directory */ +#define FTS_ERR 7 /* error; errno is set */ +#define FTS_F 8 /* regular file */ +#define FTS_INIT 9 /* initialized only */ +#define FTS_NS 10 /* stat(2) failed */ +#define FTS_NSOK 11 /* no stat(2) requested */ +#define FTS_SL 12 /* symbolic link */ +#define FTS_SLNONE 13 /* symbolic link without target */ +#define FTS_W 14 /* whiteout object */ + u_short fts_info; /* user flags for FTSENT structure */ + +#define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */ +#define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */ +#define FTS_ISW 0x04 /* this is a whiteout object */ + u_short fts_flags; /* private flags for FTSENT structure */ + +#define FTS_AGAIN 1 /* read node again */ +#define FTS_FOLLOW 2 /* follow symbolic link */ +#define FTS_NOINSTR 3 /* no instructions */ +#define FTS_SKIP 4 /* discard node */ + u_short fts_instr; /* fts_set() instructions */ + + struct stat *fts_statp; /* stat(2) information */ + char fts_name[1]; /* file name */ +} FTSENT; + +#include + +__BEGIN_DECLS +FTSENT *fts_children __P((FTS *, int)); +int fts_close __P((FTS *)); +FTS *fts_open __P((char * const *, int, + int (*)(const FTSENT **, const FTSENT **))); +FTSENT *fts_read __P((FTS *)); +int fts_set __P((FTS *, FTSENT *, int)); +__END_DECLS + +#endif /* !_FTS_H_ */ diff --git a/include/glob.h b/include/glob.h new file mode 100644 index 0000000..9a6d1f0 --- /dev/null +++ b/include/glob.h @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Guido van Rossum. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)glob.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _GLOB_H_ +#define _GLOB_H_ + +#include + +struct stat; +typedef struct { + int gl_pathc; /* Count of total paths so far. */ + int gl_matchc; /* Count of paths matching pattern. */ + int gl_offs; /* Reserved at beginning of gl_pathv. */ + int gl_flags; /* Copy of flags parameter to glob. */ + char **gl_pathv; /* List of paths matching pattern. */ + /* Copy of errfunc parameter to glob. */ + int (*gl_errfunc) __P((const char *, int)); + + /* + * Alternate filesystem access methods for glob; replacement + * versions of closedir(3), readdir(3), opendir(3), stat(2) + * and lstat(2). + */ + void (*gl_closedir) __P((void *)); + struct dirent *(*gl_readdir) __P((void *)); + void *(*gl_opendir) __P((const char *)); + int (*gl_lstat) __P((const char *, struct stat *)); + int (*gl_stat) __P((const char *, struct stat *)); +} glob_t; + +#define GLOB_APPEND 0x0001 /* Append to output from previous call. */ +#define GLOB_DOOFFS 0x0002 /* Use gl_offs. */ +#define GLOB_ERR 0x0004 /* Return on error. */ +#define GLOB_MARK 0x0008 /* Append / to matching directories. */ +#define GLOB_NOCHECK 0x0010 /* Return pattern itself if nothing matches. */ +#define GLOB_NOSORT 0x0020 /* Don't sort. */ + +#ifndef _POSIX_SOURCE +#define GLOB_ALTDIRFUNC 0x0040 /* Use alternately specified directory funcs. */ +#define GLOB_BRACE 0x0080 /* Expand braces ala csh. */ +#define GLOB_MAGCHAR 0x0100 /* Pattern had globbing characters. */ +#define GLOB_NOMAGIC 0x0200 /* GLOB_NOCHECK without magic chars (csh). */ +#define GLOB_QUOTE 0x0400 /* Quote special chars with \. */ +#define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */ +#endif + +#define GLOB_NOSPACE (-1) /* Malloc call failed. */ +#define GLOB_ABEND (-2) /* Unignored error. */ + +__BEGIN_DECLS +int glob __P((const char *, int, int (*)(const char *, int), glob_t *)); +void globfree __P((glob_t *)); +__END_DECLS + +#endif /* !_GLOB_H_ */ diff --git a/locale.subproj/ctype.c b/include/grp.h similarity index 77% rename from locale.subproj/ctype.c rename to include/grp.h index 7dec737..6861981 100644 --- a/locale.subproj/ctype.c +++ b/include/grp.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -19,7 +19,7 @@ * * @APPLE_LICENSE_HEADER_END@ */ -/* +/*- * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. @@ -55,36 +55,38 @@ * 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. + * + * @(#)grp.h 8.2 (Berkeley) 1/21/94 */ +#ifndef _GRP_H_ +#define _GRP_H_ -#define _U 0x01 -#define _L 0x02 -#define _N 0x04 -#define _S 0x08 -#define _P 0x10 -#define _C 0x20 -#define _X 0x40 -#define _B 0x80 +#ifndef _POSIX_SOURCE +#define _PATH_GROUP "/etc/group" +#endif -const char __ctype[1 + 256] = { - 0, - _C, _C, _C, _C, _C, _C, _C, _C, - _C, _C|_S, _C|_S, _C|_S, _C|_S, _C|_S, _C, _C, - _C, _C, _C, _C, _C, _C, _C, _C, - _C, _C, _C, _C, _C, _C, _C, _C, - _S|_B, _P, _P, _P, _P, _P, _P, _P, - _P, _P, _P, _P, _P, _P, _P, _P, - _N, _N, _N, _N, _N, _N, _N, _N, - _N, _N, _P, _P, _P, _P, _P, _P, - _P, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U, - _U, _U, _U, _U, _U, _U, _U, _U, - _U, _U, _U, _U, _U, _U, _U, _U, - _U, _U, _U, _P, _P, _P, _P, _P, - _P, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L, - _L, _L, _L, _L, _L, _L, _L, _L, - _L, _L, _L, _L, _L, _L, _L, _L, - _L, _L, _L, _P, _P, _P, _P, _C +struct group { + char *gr_name; /* group name */ + char *gr_passwd; /* group password */ + gid_t gr_gid; /* group id */ + char **gr_mem; /* group members */ }; -char *_ctype_ = __ctype; /* Backward compatibility. */ +#include + +__BEGIN_DECLS +struct group *getgrgid __P((gid_t)); +struct group *getgrnam __P((const char *)); +int getgrgid_r __P((gid_t, struct group *, char *, size_t, struct group **)); +int getgrnam_r __P((const char *, struct group *, char *, size_t, struct group **)); +#ifndef _POSIX_SOURCE +struct group *getgrent __P((void)); +int setgrent __P((void)); +void endgrent __P((void)); +void setgrfile __P((const char *)); +int setgroupent __P((int)); +#endif +__END_DECLS + +#endif /* !_GRP_H_ */ diff --git a/include/kvm.h b/include/kvm.h new file mode 100644 index 0000000..f513cb6 --- /dev/null +++ b/include/kvm.h @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/*- + * Copyright (c) 1989, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)kvm.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _KVM_H_ +#define _KVM_H_ + +/* Default version symbol. */ +#define VRS_SYM "_version" +#define VRS_KEY "VERSION" + +#include +#include + +__BEGIN_DECLS + +typedef struct __kvm kvm_t; + +struct kinfo_proc; +int kvm_close __P((kvm_t *)); +char **kvm_getargv __P((kvm_t *, const struct kinfo_proc *, int)); +char **kvm_getenvv __P((kvm_t *, const struct kinfo_proc *, int)); +char *kvm_geterr __P((kvm_t *)); +int kvm_getloadavg __P((kvm_t *, double [], int)); +char *kvm_getfiles __P((kvm_t *, int, int, int *)); +struct kinfo_proc * + kvm_getprocs __P((kvm_t *, int, int, int *)); +int kvm_nlist __P((kvm_t *, struct nlist *)); +kvm_t *kvm_open + __P((const char *, const char *, const char *, int, const char *)); +kvm_t *kvm_openfiles + __P((const char *, const char *, const char *, int, char *)); +int kvm_read __P((kvm_t *, unsigned long, void *, unsigned int)); +int kvm_write __P((kvm_t *, unsigned long, const void *, unsigned int)); + +__END_DECLS + +#endif /* !_KVM_H_ */ diff --git a/headers.subproj/libc.h b/include/libc.h similarity index 100% rename from headers.subproj/libc.h rename to include/libc.h diff --git a/include/libgen.h b/include/libgen.h new file mode 100644 index 0000000..a679433 --- /dev/null +++ b/include/libgen.h @@ -0,0 +1,49 @@ +/* $OpenBSD: libgen.h,v 1.4 1999/05/28 22:00:22 espie Exp $ */ +/* $FreeBSD: src/include/libgen.h,v 1.1.2.1 2000/11/12 18:01:51 adrian Exp $ */ + +/* + * Copyright (c) 1997 Todd C. Miller + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _LIBGEN_H_ +#define _LIBGEN_H_ + +#include + +__BEGIN_DECLS + +char *basename __P((const char *)); +char *dirname __P((const char *)); +#if 0 +char *regcmp __P((const char *, ...)); +char *regex __P((const char *, const char *, ...)); + +extern char *__loc1; +#endif + +__END_DECLS + +#endif /* _LIBGEN_H_ */ diff --git a/include/limits.h b/include/limits.h new file mode 100644 index 0000000..d2879c3 --- /dev/null +++ b/include/limits.h @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* $NetBSD: limits.h,v 1.8 1996/10/21 05:10:50 jtc Exp $ */ + +/* + * Copyright (c) 1988, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)limits.h 8.2 (Berkeley) 1/4/94 + */ + +#ifndef _LIMITS_H_ +#define _LIMITS_H_ + +#include +#include + +#if !defined(_ANSI_SOURCE) +#define _POSIX_ARG_MAX 4096 +#define _POSIX_CHILD_MAX 6 +#define _POSIX_LINK_MAX 8 +#define _POSIX_MAX_CANON 255 +#define _POSIX_MAX_INPUT 255 +#define _POSIX_NAME_MAX 14 +#define _POSIX_NGROUPS_MAX 0 +#define _POSIX_OPEN_MAX 16 +#define _POSIX_PATH_MAX 255 +#define _POSIX_PIPE_BUF 512 +#define _POSIX_SSIZE_MAX 32767 +#define _POSIX_STREAM_MAX 8 +#define _POSIX_TZNAME_MAX 3 + +#define _POSIX2_BC_BASE_MAX 99 +#define _POSIX2_BC_DIM_MAX 2048 +#define _POSIX2_BC_SCALE_MAX 99 +#define _POSIX2_BC_STRING_MAX 1000 +#define _POSIX2_COLL_WEIGHTS_MAX 2 +#define _POSIX2_EQUIV_CLASS_MAX 2 +#define _POSIX2_EXPR_NEST_MAX 32 +#define _POSIX2_LINE_MAX 2048 +#define _POSIX2_RE_DUP_MAX 255 + +#define PTHREAD_STACK_MIN 8192 +#define PTHREAD_DESTRUCTOR_ITERATIONS 4 +#define PTHREAD_KEYS_MAX 128 + +#endif /* !_ANSI_SOURCE */ + +#if ( !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) ) || defined(_XOPEN_SOURCE) +#define PASS_MAX 128 + +#define NL_ARGMAX 9 +#define NL_LANGMAX 14 +#define NL_MSGMAX 32767 +#define NL_NMAX 1 +#define NL_SETMAX 255 +#define NL_TEXTMAX 255 +#endif + + +#endif /* !_LIMITS_H_ */ diff --git a/include/locale.h b/include/locale.h new file mode 100644 index 0000000..0c1a6bc --- /dev/null +++ b/include/locale.h @@ -0,0 +1,81 @@ +/* + * Copyright (c) 1991, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)locale.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _LOCALE_H_ +#define _LOCALE_H_ + +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; +}; + +#ifndef NULL +#define NULL 0 +#endif + +#define LC_ALL 0 +#define LC_COLLATE 1 +#define LC_CTYPE 2 +#define LC_MONETARY 3 +#define LC_NUMERIC 4 +#define LC_TIME 5 +#define LC_MESSAGES 6 + +#define _LC_LAST 7 /* marks end */ + +#include + +__BEGIN_DECLS +struct lconv *localeconv __P((void)); +char *setlocale __P((int, const char *)); +__END_DECLS + +#endif /* _LOCALE_H_ */ diff --git a/locale.subproj/localeconv.c b/include/memory.h similarity index 91% rename from locale.subproj/localeconv.c rename to include/memory.h index 4393c9c..49f8bd0 100644 --- a/locale.subproj/localeconv.c +++ b/include/memory.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -20,7 +20,7 @@ * @APPLE_LICENSE_HEADER_END@ */ /* - * Copyright (c) 1991, 1993 + * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -50,18 +50,8 @@ * 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. + * + * @(#)memory.h 8.1 (Berkeley) 6/2/93 */ - -#include - -/* - * Return the current locale conversion. - */ -struct lconv * -localeconv() -{ - extern struct lconv *__lconv; - - return (__lconv); -} +#include diff --git a/headers.subproj/monitor.h b/include/monitor.h similarity index 100% rename from headers.subproj/monitor.h rename to include/monitor.h diff --git a/include/mpool.h b/include/mpool.h new file mode 100644 index 0000000..13f9551 --- /dev/null +++ b/include/mpool.h @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/*- + * Copyright (c) 1991, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)mpool.h 8.1 (Berkeley) 6/2/93 + */ + +/* + * The memory pool scheme is a simple one. Each in memory page is referenced + * by a bucket which is threaded in three ways. All active pages are threaded + * on a hash chain (hashed by the page number) and an lru chain. Inactive + * pages are threaded on a free chain. Each reference to a memory pool is + * handed an MPOOL which is the opaque cookie passed to all of the memory + * routines. + */ +#define HASHSIZE 128 +#define HASHKEY(pgno) ((pgno - 1) % HASHSIZE) + +/* The BKT structures are the elements of the lists. */ +typedef struct BKT { + struct BKT *hnext; /* next hash bucket */ + struct BKT *hprev; /* previous hash bucket */ + struct BKT *cnext; /* next free/lru bucket */ + struct BKT *cprev; /* previous free/lru bucket */ + void *page; /* page */ + pgno_t pgno; /* page number */ + +#define MPOOL_DIRTY 0x01 /* page needs to be written */ +#define MPOOL_PINNED 0x02 /* page is pinned into memory */ + unsigned long flags; /* flags */ +} BKT; + +/* The BKTHDR structures are the heads of the lists. */ +typedef struct BKTHDR { + struct BKT *hnext; /* next hash bucket */ + struct BKT *hprev; /* previous hash bucket */ + struct BKT *cnext; /* next free/lru bucket */ + struct BKT *cprev; /* previous free/lru bucket */ +} BKTHDR; + +typedef struct MPOOL { + BKTHDR free; /* The free list. */ + BKTHDR lru; /* The LRU list. */ + BKTHDR hashtable[HASHSIZE]; /* Hashed list by page number. */ + pgno_t curcache; /* Current number of cached pages. */ + pgno_t maxcache; /* Max number of cached pages. */ + pgno_t npages; /* Number of pages in the file. */ + u_long pagesize; /* File page size. */ + int fd; /* File descriptor. */ + /* Page in conversion routine. */ + void (*pgin) __P((void *, pgno_t, void *)); + /* Page out conversion routine. */ + void (*pgout) __P((void *, pgno_t, void *)); + void *pgcookie; /* Cookie for page in/out routines. */ +#ifdef STATISTICS + unsigned long cachehit; + unsigned long cachemiss; + unsigned long pagealloc; + unsigned long pageflush; + unsigned long pageget; + unsigned long pagenew; + unsigned long pageput; + unsigned long pageread; + unsigned long pagewrite; +#endif +} MPOOL; + +#ifdef __MPOOLINTERFACE_PRIVATE +/* Macros to insert/delete into/from hash chain. */ +#define rmhash(bp) { \ + (bp)->hprev->hnext = (bp)->hnext; \ + (bp)->hnext->hprev = (bp)->hprev; \ +} +#define inshash(bp, pg) { \ + hp = &mp->hashtable[HASHKEY(pg)]; \ + (bp)->hnext = hp->hnext; \ + (bp)->hprev = (struct BKT *)hp; \ + hp->hnext->hprev = (bp); \ + hp->hnext = (bp); \ +} + +/* Macros to insert/delete into/from lru and free chains. */ +#define rmchain(bp) { \ + (bp)->cprev->cnext = (bp)->cnext; \ + (bp)->cnext->cprev = (bp)->cprev; \ +} +#define inschain(bp, dp) { \ + (bp)->cnext = (dp)->cnext; \ + (bp)->cprev = (struct BKT *)(dp); \ + (dp)->cnext->cprev = (bp); \ + (dp)->cnext = (bp); \ +} +#endif + +__BEGIN_DECLS +MPOOL *mpool_open __P((DBT *, int, pgno_t, pgno_t)); +void mpool_filter __P((MPOOL *, void (*)(void *, pgno_t, void *), + void (*)(void *, pgno_t, void *), void *)); +void *mpool_new __P((MPOOL *, pgno_t *)); +void *mpool_get __P((MPOOL *, pgno_t, u_int)); +int mpool_put __P((MPOOL *, void *, u_int)); +int mpool_sync __P((MPOOL *)); +int mpool_close __P((MPOOL *)); +#ifdef STATISTICS +void mpool_stat __P((MPOOL *)); +#endif +__END_DECLS diff --git a/include/ndbm.h b/include/ndbm.h new file mode 100644 index 0000000..033a6ea --- /dev/null +++ b/include/ndbm.h @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Margo Seltzer. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)ndbm.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _NDBM_H_ +#define _NDBM_H_ + +#include + +/* Map dbm interface onto db(3). */ +#define DBM_RDONLY O_RDONLY + +/* Flags to dbm_store(). */ +#define DBM_INSERT 0 +#define DBM_REPLACE 1 + +/* + * The db(3) support for ndbm(3) always appends this suffix to the + * file name to avoid overwriting the user's original database. + */ +#define DBM_SUFFIX ".db" + +typedef struct { + char *dptr; + int dsize; +} datum; + +typedef DB DBM; +#define dbm_pagfno(a) DBM_PAGFNO_NOT_AVAILABLE + +__BEGIN_DECLS +void dbm_close __P((DBM *)); +int dbm_delete __P((DBM *, datum)); +datum dbm_fetch __P((DBM *, datum)); +datum dbm_firstkey __P((DBM *)); +long dbm_forder __P((DBM *, datum)); +datum dbm_nextkey __P((DBM *)); +DBM *dbm_open __P((const char *, int, int)); +int dbm_store __P((DBM *, datum, datum, int)); +int dbm_dirfno __P((DBM *)); +__END_DECLS + +#endif /* !_NDBM_H_ */ diff --git a/include/netdb.h b/include/netdb.h new file mode 100644 index 0000000..34102f2 --- /dev/null +++ b/include/netdb.h @@ -0,0 +1,259 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * ++Copyright++ 1980, 1983, 1988, 1993 + * - + * Copyright (c) 1980, 1983, 1988, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * - + * Portions Copyright (c) 1993 by Digital Equipment Corporation. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies, and that + * the name of Digital Equipment Corporation not be used in advertising or + * publicity pertaining to distribution of the document or software without + * specific, written prior permission. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT + * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * - + * --Copyright-- + */ + +/* + * @(#)netdb.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _NETDB_H_ +#define _NETDB_H_ + +#include +#include + +#define _PATH_HEQUIV "/etc/hosts.equiv" +#define _PATH_HOSTS "/etc/hosts" +#define _PATH_NETWORKS "/etc/networks" +#define _PATH_PROTOCOLS "/etc/protocols" +#define _PATH_SERVICES "/etc/services" + +extern int h_errno; + +/* + * Structures returned by network data base library. All addresses are + * supplied in host order, and returned in network order (suitable for + * use in system calls). + */ +struct hostent { + char *h_name; /* official name of host */ + char **h_aliases; /* alias list */ + int h_addrtype; /* host address type */ + int h_length; /* length of address */ + char **h_addr_list; /* list of addresses from name server */ +#define h_addr h_addr_list[0] /* address, for backward compatiblity */ +}; + +/* + * Assumption here is that a network number + * fits in an unsigned long -- probably a poor one. + */ +struct netent { + char *n_name; /* official name of net */ + char **n_aliases; /* alias list */ + int n_addrtype; /* net address type */ + unsigned long n_net; /* network # */ +}; + +struct servent { + char *s_name; /* official service name */ + char **s_aliases; /* alias list */ + int s_port; /* port # */ + char *s_proto; /* protocol to use */ +}; + +struct protoent { + char *p_name; /* official protocol name */ + char **p_aliases; /* alias list */ + int p_proto; /* protocol # */ +}; + +struct addrinfo { + int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */ + int ai_family; /* PF_xxx */ + int ai_socktype; /* SOCK_xxx */ + int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ + size_t ai_addrlen; /* length of ai_addr */ + char *ai_canonname; /* canonical name for hostname */ + struct sockaddr *ai_addr; /* binary address */ + struct addrinfo *ai_next; /* next structure in linked list */ +}; + +struct rpcent { + char *r_name; /* name of server for this rpc program */ + char **r_aliases; /* alias list */ + int r_number; /* rpc program number */ +}; + +/* + * Error return codes from gethostbyname() and gethostbyaddr() + * (left in extern int h_errno). + */ + +#define NETDB_INTERNAL -1 /* see errno */ +#define NETDB_SUCCESS 0 /* no problem */ +#define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */ +#define TRY_AGAIN 2 /* Non-Authoritative Host not found, or SERVERFAIL */ +#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ +#define NO_DATA 4 /* Valid name, no data record of requested type */ +#define NO_ADDRESS NO_DATA /* no address, look for MX record */ + +/* + * Error return codes from getaddrinfo() + */ +#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */ +#define EAI_AGAIN 2 /* temporary failure in name resolution */ +#define EAI_BADFLAGS 3 /* invalid value for ai_flags */ +#define EAI_FAIL 4 /* non-recoverable failure in name resolution */ +#define EAI_FAMILY 5 /* ai_family not supported */ +#define EAI_MEMORY 6 /* memory allocation failure */ +#define EAI_NODATA 7 /* no address associated with hostname */ +#define EAI_NONAME 8 /* hostname nor servname provided, or not known */ +#define EAI_SERVICE 9 /* servname not supported for ai_socktype */ +#define EAI_SOCKTYPE 10 /* ai_socktype not supported */ +#define EAI_SYSTEM 11 /* system error returned in errno */ +#define EAI_BADHINTS 12 +#define EAI_PROTOCOL 13 +#define EAI_MAX 14 + +/* + * Flag values for getaddrinfo() + */ +#define AI_PASSIVE 0x00000001 /* get address to use bind() */ +#define AI_CANONNAME 0x00000002 /* fill ai_canonname */ +#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */ +/* valid flags for addrinfo */ +#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST) + +#define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */ +#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */ +#define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */ +#define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */ +/* special recommended flags for getipnodebyname */ +#define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG) + +/* + * Constants for getnameinfo() + */ +#define NI_MAXHOST 1025 +#define NI_MAXSERV 32 + +/* + * Flag values for getnameinfo() + */ +#define NI_NOFQDN 0x00000001 +#define NI_NUMERICHOST 0x00000002 +#define NI_NAMEREQD 0x00000004 +#define NI_NUMERICSERV 0x00000008 +#define NI_DGRAM 0x00000010 +#define NI_WITHSCOPEID 0x00000020 + +/* + * Scope delimit character + */ +#define SCOPE_DELIMITER '%' + +__BEGIN_DECLS +void endhostent __P((void)); +void endnetent __P((void)); +void endprotoent __P((void)); +void endservent __P((void)); +void freehostent __P((struct hostent *)); +struct hostent *gethostbyaddr __P((const char *, int, int)); +struct hostent *gethostbyname __P((const char *)); +struct hostent *gethostbyname2 __P((const char *, int)); +struct hostent *gethostent __P((void)); +struct hostent *getipnodebyaddr __P((const void *, size_t, int, int *)); +struct hostent *getipnodebyname __P((const char *, int, int, int *)); +struct netent *getnetbyaddr __P((long, int)); +struct netent *getnetbyname __P((const char *)); +struct netent *getnetent __P((void)); +struct protoent *getprotobyname __P((const char *)); +struct protoent *getprotobynumber __P((int)); +struct protoent *getprotoent __P((void)); +struct servent *getservbyname __P((const char *, const char *)); +struct servent *getservbyport __P((int, const char *)); +struct servent *getservent __P((void)); +struct rpcent *getrpcbyname __P((const char *name)); +struct rpcent *getrpcbynumber __P((long number)); +struct rpcent *getrpcent __P((void)); +void setrpcent __P((int stayopen)); +void endrpcent __P((void)); + +void herror __P((const char *)); +char *hstrerror __P((int)); +void sethostent __P((int)); +/* void sethostfile __P((const char *)); */ +void setnetent __P((int)); +void setprotoent __P((int)); +void setservent __P((int)); + +char *gai_strerror __P((int)); +void freeaddrinfo __P((struct addrinfo *)); +int getaddrinfo __P((const char *, const char *, const struct addrinfo *, struct addrinfo **)); +int getnameinfo __P((const struct sockaddr *, size_t, char *, size_t, char *, size_t, int)); +__END_DECLS + +#endif /* !_NETDB_H_ */ diff --git a/locale.subproj/isctype.c b/include/nlist.h similarity index 66% rename from locale.subproj/isctype.c rename to include/nlist.h index 593b8ed..828b4a7 100644 --- a/locale.subproj/isctype.c +++ b/include/nlist.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -19,8 +19,8 @@ * * @APPLE_LICENSE_HEADER_END@ */ -/* - * Copyright (c) 1989, 1993 +/*- + * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. * All or some portions of this file are derived from material licensed @@ -28,9 +28,6 @@ * Co. or Unix System Laboratories, Inc. and are reproduced herein with * the permission of UNIX System Laboratories, Inc. * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -58,136 +55,52 @@ * 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. + * + * @(#)nlist.h 8.2 (Berkeley) 1/21/94 */ +#ifndef _NLIST_H_ +#define _NLIST_H_ -#define _ANSI_LIBRARY -#include - -#undef isalnum -int -isalnum(c) - int c; -{ - return(__istype((c), (_A|_D))); -} - -#undef isalpha -int -isalpha(c) - int c; -{ - return (__istype((c), _A)); -} - -#undef isascii -int -isascii(c) - int c; -{ - return((c & ~0x7F) == 0); -} - -#undef isblank -int -isblank(c) - int c; -{ - return (__istype((c), _B)); -} - -#undef iscntrl -int -iscntrl(c) - int c; -{ - return (__istype((c), _C)); -} - -#undef isdigit -int -isdigit(c) - int c; -{ - return (__isctype((c), _D)); -} - -#undef isgraph -int -isgraph(c) - int c; -{ - return (__istype((c), _G)); -} - -#undef islower -int -islower(c) - int c; -{ - return (__istype((c), _L)); -} - -#undef isprint -int -isprint(c) - int c; -{ - return (__istype((c), _R)); -} - -#undef ispunct -int -ispunct(c) - int c; -{ - return (__istype((c), _P)); -} - -#undef isspace -int -isspace(c) - int c; -{ - return (__istype((c), _S)); -} - -#undef isupper -int -isupper(c) - int c; -{ - return (__istype((c), _U)); -} - -#undef isxdigit -int -isxdigit(c) - int c; -{ - return (__isctype((c), _X)); -} - -#undef toascii -int -toascii(c) - int c; -{ - return (c & 0177); -} - -#undef tolower -int -tolower(c) - int c; -{ - return((c & _CRMASK) ? ___tolower(c) : _CurrentRuneLocale->maplower[c]); -} - -#undef toupper -int -toupper(c) - int c; -{ - return((c & _CRMASK) ? ___toupper(c) : _CurrentRuneLocale->mapupper[c]); -} +/* + * Symbol table entry format. The #ifdef's are so that programs including + * nlist.h can initialize nlist structures statically. + */ +struct nlist { +#ifdef _AOUT_INCLUDE_ + union { + char *n_name; /* symbol name (in memory) */ + long n_strx; /* file string table offset (on disk) */ + } n_un; +#else + char *n_name; /* symbol name (in memory) */ +#endif + +#define N_UNDF 0x00 /* undefined */ +#define N_ABS 0x02 /* absolute address */ +#define N_TEXT 0x04 /* text segment */ +#define N_DATA 0x06 /* data segment */ +#define N_BSS 0x08 /* bss segment */ +#define N_COMM 0x12 /* common reference */ +#define N_FN 0x1e /* file name */ + +#define N_EXT 0x01 /* external (global) bit, OR'ed in */ +#define N_TYPE 0x1e /* mask for all the type bits */ + unsigned char n_type; /* type defines */ + + char n_other; /* spare */ +#define n_hash n_desc /* used internally by ld(1); XXX */ + short n_desc; /* used by stab entries */ + unsigned long n_value; /* address/value of the symbol */ +}; + +#define N_FORMAT "%08x" /* namelist value format; XXX */ +#define N_STAB 0x0e0 /* mask for debugger symbols -- stab(5) */ + +#include + +__BEGIN_DECLS +int nlist __P((const char *, struct nlist *)); +__END_DECLS + +#endif /* !_NLIST_H_ */ diff --git a/include/objc/Makefile.inc b/include/objc/Makefile.inc new file mode 100644 index 0000000..a4f8fad --- /dev/null +++ b/include/objc/Makefile.inc @@ -0,0 +1,2 @@ +OBJC_INSTHDRS += malloc.h zone.h +OBJC_INSTHDRS := ${OBJC_INSTHDRS:S/^/${.CURDIR}\/include\/objc\//} diff --git a/gen.subproj/malloc.h b/include/objc/malloc.h similarity index 100% rename from gen.subproj/malloc.h rename to include/objc/malloc.h diff --git a/gen.subproj/zone.h b/include/objc/zone.h similarity index 100% rename from gen.subproj/zone.h rename to include/objc/zone.h diff --git a/include/paths.h b/include/paths.h new file mode 100644 index 0000000..45a47aa --- /dev/null +++ b/include/paths.h @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* $OpenBSD: paths.h,v 1.10 1997/11/09 00:29:02 bri Exp $ */ +/* $NetBSD: paths.h,v 1.10 1997/04/23 09:41:38 lukem Exp $ */ + +/* + * Copyright (c) 1989, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)paths.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _PATHS_H_ +#define _PATHS_H_ + +/* Default search path. */ +#define _PATH_DEFPATH "/usr/bin:/bin" +/* All standard utilities path. */ +#define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin" + +#define _PATH_BSHELL "/bin/sh" +#define _PATH_CONSOLE "/dev/console" +#define _PATH_CSHELL "/bin/csh" +#define _PATH_DEFTAPE "/dev/nrst0" +#define _PATH_DEVDB "/var/run/dev.db" +#define _PATH_DEVNULL "/dev/null" +#define _PATH_DRUM "/dev/drum" +#define _PATH_FSIRAND "/sbin/fsirand" +#define _PATH_KMEM "/dev/kmem" +#define _PATH_KVMDB "/var/db/kvm.db" +#define _PATH_LOCALE "/usr/share/locale" +#define _PATH_MAILDIR "/var/mail" +#define _PATH_MAN "/usr/share/man" +#define _PATH_MEM "/dev/mem" +#define _PATH_NOLOGIN "/etc/nologin" +#define _PATH_RSH "/usr/bin/rsh" +#define _PATH_SENDMAIL "/usr/sbin/sendmail" +#define _PATH_SHELLS "/etc/shells" +#define _PATH_TTY "/dev/tty" +#define _PATH_UNIX "/mach" +#define _PATH_VI "/usr/bin/vi" + +/* Provide trailing slash, since mostly used for building pathnames. */ +#define _PATH_DEV "/dev/" +#define _PATH_TMP "/tmp/" +#define _PATH_UUCPLOCK "/var/spool/lock/" +#define _PATH_VARDB "/var/db/" +#define _PATH_VARRUN "/var/run/" +#define _PATH_VARTMP "/var/tmp/" + +#include + +#endif /* !_PATHS_H_ */ diff --git a/include/protocols/Makefile.inc b/include/protocols/Makefile.inc new file mode 100644 index 0000000..b7ea0cb --- /dev/null +++ b/include/protocols/Makefile.inc @@ -0,0 +1,6 @@ +PROTO_INSTHDRS += dumprestore.h \ + routed.h \ + rwhod.h \ + talkd.h \ + timed.h +PROTO_INSTHDRS := ${PROTO_INSTHDRS:S/^/${.CURDIR}\/include\/protocols\//} diff --git a/include/protocols/dumprestore.h b/include/protocols/dumprestore.h new file mode 100644 index 0000000..0912e7d --- /dev/null +++ b/include/protocols/dumprestore.h @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1980, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)dumprestore.h 8.2 (Berkeley) 1/21/94 + */ + +#ifndef _DUMPRESTORE_H_ +#define _DUMPRESTORE_H_ + +/* + * TP_BSIZE is the size of file blocks on the dump tapes. + * Note that TP_BSIZE must be a multiple of DEV_BSIZE. + * + * NTREC is the number of TP_BSIZE blocks that are written + * in each tape record. HIGHDENSITYTREC is the number of + * TP_BSIZE blocks that are written in each tape record on + * 6250 BPI or higher density tapes. + * + * TP_NINDIR is the number of indirect pointers in a TS_INODE + * or TS_ADDR record. Note that it must be a power of two. + */ +#define TP_BSIZE 1024 +#define NTREC 10 +#define HIGHDENSITYTREC 32 +#define TP_NINDIR (TP_BSIZE/2) +#define LBLSIZE 16 +#define NAMELEN 64 + +#define OFS_MAGIC (int)60011 +#define NFS_MAGIC (int)60012 +#define CHECKSUM (int)84446 + +union u_spcl { + char dummy[TP_BSIZE]; + struct s_spcl { + long c_type; /* record type (see below) */ + time_t c_date; /* date of this dump */ + time_t c_ddate; /* date of previous dump */ + long c_volume; /* dump volume number */ + daddr_t c_tapea; /* logical block of this record */ + ino_t c_inumber; /* number of inode */ + long c_magic; /* magic number (see above) */ + long c_checksum; /* record checksum */ + struct dinode c_dinode; /* ownership and mode of inode */ + long c_count; /* number of valid c_addr entries */ + char c_addr[TP_NINDIR]; /* 1 => data; 0 => hole in inode */ + char c_label[LBLSIZE]; /* dump label */ + long c_level; /* level of this dump */ + char c_filesys[NAMELEN]; /* name of dumpped file system */ + char c_dev[NAMELEN]; /* name of dumpped device */ + char c_host[NAMELEN]; /* name of dumpped host */ + long c_flags; /* additional information */ + long c_firstrec; /* first record on volume */ + long c_spare[32]; /* reserved for future uses */ + } s_spcl; +}; + +/* + * special record types + */ +#define TS_TAPE 1 /* dump tape header */ +#define TS_INODE 2 /* beginning of file record */ +#define TS_ADDR 4 /* continuation of file record */ +#define TS_BITS 3 /* map of inodes on tape */ +#define TS_CLRI 6 /* map of inodes deleted since last dump */ +#define TS_END 5 /* end of volume marker */ + +/* + * flag values + */ +#define DR_NEWHEADER 0x0001 /* new format tape header */ +#define DR_NEWINODEFMT 0x0002 /* new format inodes on tape */ + +#define DUMPOUTFMT "%-16s %c %s" /* for printf */ + /* name, level, ctime(date) */ +#define DUMPINFMT "%16s %c %[^\n]\n" /* inverse for scanf */ + +#endif /* !_DUMPRESTORE_H_ */ diff --git a/include/protocols/routed.h b/include/protocols/routed.h new file mode 100644 index 0000000..95533f3 --- /dev/null +++ b/include/protocols/routed.h @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/*- + * Copyright (c) 1983, 1989, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)routed.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _ROUTED_H_ +#define _ROUTED_H_ + +/* + * Routing Information Protocol + * + * Derived from Xerox NS Routing Information Protocol + * by changing 32-bit net numbers to sockaddr's and + * padding stuff to 32-bit boundaries. + */ +#define RIPVERSION 1 + +struct netinfo { + struct sockaddr rip_dst; /* destination net/host */ + int rip_metric; /* cost of route */ +}; + +struct rip { + u_char rip_cmd; /* request/response */ + u_char rip_vers; /* protocol version # */ + u_char rip_res1[2]; /* pad to 32-bit boundary */ + union { + struct netinfo ru_nets[1]; /* variable length... */ + char ru_tracefile[1]; /* ditto ... */ + } ripun; +#define rip_nets ripun.ru_nets +#define rip_tracefile ripun.ru_tracefile +}; + +/* + * Packet types. + */ +#define RIPCMD_REQUEST 1 /* want info */ +#define RIPCMD_RESPONSE 2 /* responding to request */ +#define RIPCMD_TRACEON 3 /* turn tracing on */ +#define RIPCMD_TRACEOFF 4 /* turn it off */ + +#define RIPCMD_MAX 5 +#ifdef RIPCMDS +char *ripcmds[RIPCMD_MAX] = + { "#0", "REQUEST", "RESPONSE", "TRACEON", "TRACEOFF" }; +#endif + +#define HOPCNT_INFINITY 16 /* per Xerox NS */ +#define MAXPACKETSIZE 512 /* max broadcast size */ + +/* + * Timer values used in managing the routing table. + * Complete tables are broadcast every SUPPLY_INTERVAL seconds. + * If changes occur between updates, dynamic updates containing only changes + * may be sent. When these are sent, a timer is set for a random value + * between MIN_WAITTIME and MAX_WAITTIME, and no additional dynamic updates + * are sent until the timer expires. + * + * Every update of a routing entry forces an entry's timer to be reset. + * After EXPIRE_TIME without updates, the entry is marked invalid, + * but held onto until GARBAGE_TIME so that others may + * see it "be deleted". + */ +#define TIMER_RATE 30 /* alarm clocks every 30 seconds */ + +#define SUPPLY_INTERVAL 30 /* time to supply tables */ +#define MIN_WAITTIME 2 /* min. interval to broadcast changes */ +#define MAX_WAITTIME 5 /* max. time to delay changes */ + +#define EXPIRE_TIME 180 /* time to mark entry invalid */ +#define GARBAGE_TIME 240 /* time to garbage collect */ + +#endif /* !_ROUTED_H_ */ diff --git a/include/protocols/rwhod.h b/include/protocols/rwhod.h new file mode 100644 index 0000000..c054e63 --- /dev/null +++ b/include/protocols/rwhod.h @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1983, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)rwhod.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _RWHOD_H_ +#define _RWHOD_H_ + +/* + * rwho protocol packet format. + */ +struct outmp { + char out_line[8]; /* tty name */ + char out_name[8]; /* user id */ + long out_time; /* time on */ +}; + +struct whod { + char wd_vers; /* protocol version # */ + char wd_type; /* packet type, see below */ + char wd_pad[2]; + int wd_sendtime; /* time stamp by sender */ + int wd_recvtime; /* time stamp applied by receiver */ + char wd_hostname[32]; /* hosts's name */ + int wd_loadav[3]; /* load average as in uptime */ + int wd_boottime; /* time system booted */ + struct whoent { + struct outmp we_utmp; /* active tty info */ + int we_idle; /* tty idle time */ + } wd_we[1024 / sizeof (struct whoent)]; +}; + +#define WHODVERSION 1 +#define WHODTYPE_STATUS 1 /* host status */ + +#define _PATH_RWHODIR "/var/rwho" + +#endif /* !_RWHOD_H_ */ diff --git a/include/protocols/talkd.h b/include/protocols/talkd.h new file mode 100644 index 0000000..b8a2b97 --- /dev/null +++ b/include/protocols/talkd.h @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1983, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)talkd.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _TALKD_H_ +#define _TALKD_H_ + +/* + * This describes the protocol used by the talk server and clients. + * + * The talk server acts a repository of invitations, responding to + * requests by clients wishing to rendezvous for the purpose of + * holding a conversation. In normal operation, a client, the caller, + * initiates a rendezvous by sending a CTL_MSG to the server of + * type LOOK_UP. This causes the server to search its invitation + * tables to check if an invitation currently exists for the caller + * (to speak to the callee specified in the message). If the lookup + * fails, the caller then sends an ANNOUNCE message causing the server + * to broadcast an announcement on the callee's login ports requesting + * contact. When the callee responds, the local server uses the + * recorded invitation to respond with the appropriate rendezvous + * address and the caller and callee client programs establish a + * stream connection through which the conversation takes place. + */ + +/* + * Client->server request message format. + */ +typedef struct { + u_char vers; /* protocol version */ + u_char type; /* request type, see below */ + u_char answer; /* not used */ + u_char pad; + u_long id_num; /* message id */ + struct osockaddr addr; /* old (4.3) style */ + struct osockaddr ctl_addr; /* old (4.3) style */ + long pid; /* caller's process id */ +#define NAME_SIZE 12 + char l_name[NAME_SIZE];/* caller's name */ + char r_name[NAME_SIZE];/* callee's name */ +#define TTY_SIZE 16 + char r_tty[TTY_SIZE];/* callee's tty name */ +} CTL_MSG; + +/* + * Server->client response message format. + */ +typedef struct { + u_char vers; /* protocol version */ + u_char type; /* type of request message, see below */ + u_char answer; /* respose to request message, see below */ + u_char pad; + u_long id_num; /* message id */ + struct osockaddr addr; /* address for establishing conversation */ +} CTL_RESPONSE; + +#define TALK_VERSION 1 /* protocol version */ + +/* message type values */ +#define LEAVE_INVITE 0 /* leave invitation with server */ +#define LOOK_UP 1 /* check for invitation by callee */ +#define DELETE 2 /* delete invitation by caller */ +#define ANNOUNCE 3 /* announce invitation by caller */ + +/* answer values */ +#define SUCCESS 0 /* operation completed properly */ +#define NOT_HERE 1 /* callee not logged in */ +#define FAILED 2 /* operation failed for unexplained reason */ +#define MACHINE_UNKNOWN 3 /* caller's machine name unknown */ +#define PERMISSION_DENIED 4 /* callee's tty doesn't permit announce */ +#define UNKNOWN_REQUEST 5 /* request has invalid type value */ +#define BADVERSION 6 /* request has invalid protocol version */ +#define BADADDR 7 /* request has invalid addr value */ +#define BADCTLADDR 8 /* request has invalid ctl_addr value */ + +/* + * Operational parameters. + */ +#define MAX_LIFE 60 /* max time daemon saves invitations */ +/* RING_WAIT should be 10's of seconds less than MAX_LIFE */ +#define RING_WAIT 30 /* time to wait before resending invitation */ + +#endif /* !_TALKD_H_ */ diff --git a/include/protocols/timed.h b/include/protocols/timed.h new file mode 100644 index 0000000..e3e6263 --- /dev/null +++ b/include/protocols/timed.h @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1983, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)timed.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _TIMED_H_ +#define _TIMED_H_ + +/* + * Time Synchronization Protocol + */ + +#define TSPVERSION 1 +#define ANYADDR NULL + +struct tsp { + u_char tsp_type; + u_char tsp_vers; + u_short tsp_seq; + union { + struct timeval tspu_time; + char tspu_hopcnt; + } tsp_u; + char tsp_name[MAXHOSTNAMELEN]; +}; + +#define tsp_time tsp_u.tspu_time +#define tsp_hopcnt tsp_u.tspu_hopcnt + +/* + * Command types. + */ +#define TSP_ANY 0 /* match any types */ +#define TSP_ADJTIME 1 /* send adjtime */ +#define TSP_ACK 2 /* generic acknowledgement */ +#define TSP_MASTERREQ 3 /* ask for master's name */ +#define TSP_MASTERACK 4 /* acknowledge master request */ +#define TSP_SETTIME 5 /* send network time */ +#define TSP_MASTERUP 6 /* inform slaves that master is up */ +#define TSP_SLAVEUP 7 /* slave is up but not polled */ +#define TSP_ELECTION 8 /* advance candidature for master */ +#define TSP_ACCEPT 9 /* support candidature of master */ +#define TSP_REFUSE 10 /* reject candidature of master */ +#define TSP_CONFLICT 11 /* two or more masters present */ +#define TSP_RESOLVE 12 /* masters' conflict resolution */ +#define TSP_QUIT 13 /* reject candidature if master is up */ +#define TSP_DATE 14 /* reset the time (date command) */ +#define TSP_DATEREQ 15 /* remote request to reset the time */ +#define TSP_DATEACK 16 /* acknowledge time setting */ +#define TSP_TRACEON 17 /* turn tracing on */ +#define TSP_TRACEOFF 18 /* turn tracing off */ +#define TSP_MSITE 19 /* find out master's site */ +#define TSP_MSITEREQ 20 /* remote master's site request */ +#define TSP_TEST 21 /* for testing election algo */ +#define TSP_SETDATE 22 /* New from date command */ +#define TSP_SETDATEREQ 23 /* New remote for above */ +#define TSP_LOOP 24 /* loop detection packet */ + +#define TSPTYPENUMBER 25 + +#ifdef TSPTYPES +char *tsptype[TSPTYPENUMBER] = + { "ANY", "ADJTIME", "ACK", "MASTERREQ", "MASTERACK", "SETTIME", "MASTERUP", + "SLAVEUP", "ELECTION", "ACCEPT", "REFUSE", "CONFLICT", "RESOLVE", "QUIT", + "DATE", "DATEREQ", "DATEACK", "TRACEON", "TRACEOFF", "MSITE", "MSITEREQ", + "TEST", "SETDATE", "SETDATEREQ", "LOOP" }; +#endif + +#endif /* !_TIMED_H_ */ diff --git a/gen.subproj/i386.subproj/bcopy.c b/include/pwd.h similarity index 52% rename from gen.subproj/i386.subproj/bcopy.c rename to include/pwd.h index 6bfae93..91f6d91 100644 --- a/gen.subproj/i386.subproj/bcopy.c +++ b/include/pwd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -19,12 +19,17 @@ * * @APPLE_LICENSE_HEADER_END@ */ -/* - * Copyright (c) 1990, 1993 +/* $NetBSD: pwd.h,v 1.11 1997/08/16 13:47:21 lukem Exp $ */ + +/*- + * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * Portions Copyright(C) 1995, Jason Downs. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -53,109 +58,71 @@ * 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. + * + * @(#)pwd.h 8.2 (Berkeley) 1/21/94 */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bcopy.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ +#ifndef _PWD_H_ +#define _PWD_H_ -#include -#include +#include -/* - * sizeof(word) MUST BE A POWER OF TWO - * SO THAT wmask BELOW IS ALL ONES - */ -typedef int word; /* "word" used for optimal copy speed */ +#ifndef _POSIX_SOURCE +#define _PATH_PASSWD "/etc/passwd" +#define _PATH_MASTERPASSWD "/etc/master.passwd" +#define _PATH_MASTERPASSWD_LOCK "/etc/ptmp" -#define wsize sizeof(word) -#define wmask (wsize - 1) +#define _PATH_MP_DB "/etc/pwd.db" +#define _PATH_SMP_DB "/etc/spwd.db" -/* - * Copy a block of memory, handling overlap. - * This is the routine that actually implements - * (the portable versions of) bcopy, memcpy, and memmove. - */ -#ifdef MEMCOPY -void * -memcpy(dst0, src0, length) -#else -#ifdef MEMMOVE -void * -memmove(dst0, src0, length) -#else -void -bcopy(src0, dst0, length) -#endif +#define _PATH_PWD_MKDB "/usr/sbin/pwd_mkdb" + +#define _PW_KEYBYNAME '1' /* stored by name */ +#define _PW_KEYBYNUM '2' /* stored by entry in the "file" */ +#define _PW_KEYBYUID '3' /* stored by uid */ + +#define _PASSWORD_EFMT1 '_' /* extended encryption format */ + +#define _PASSWORD_LEN 128 /* max length, not counting NULL */ + +#define _PASSWORD_NOUID 0x01 /* flag for no specified uid. */ +#define _PASSWORD_NOGID 0x02 /* flag for no specified gid. */ +#define _PASSWORD_NOCHG 0x04 /* flag for no specified change. */ +#define _PASSWORD_NOEXP 0x08 /* flag for no specified expire. */ + +#define _PASSWORD_WARNDAYS 14 /* days to warn about expiry */ +#define _PASSWORD_CHGNOW -1 /* special day to force password + * change at next login */ #endif - void *dst0; - const void *src0; - register size_t length; -{ - register char *dst = dst0; - register const char *src = src0; - register size_t t; - if (length == 0 || dst == src) /* nothing to do */ - goto done; +struct passwd { + char *pw_name; /* user name */ + char *pw_passwd; /* encrypted password */ + uid_t pw_uid; /* user uid */ + gid_t pw_gid; /* user gid */ + time_t pw_change; /* password change time */ + char *pw_class; /* user access class */ + char *pw_gecos; /* Honeywell login info */ + char *pw_dir; /* home directory */ + char *pw_shell; /* default shell */ + time_t pw_expire; /* account expiration */ +}; - /* - * Macros: loop-t-times; and loop-t-times, t>0 - */ -#define TLOOP(s) if (t) TLOOP1(s) -#define TLOOP1(s) do { s; } while (--t) +#include - if (((unsigned long)dst < (unsigned long)src) || ((unsigned long)dst >= ((unsigned long)src + length))) { - /* - * Copy forward. - */ - t = (int)src; /* only need low bits */ - if ((t | (int)dst) & wmask) { - /* - * Try to align operands. This cannot be done - * unless the low bits match. - */ - if ((t ^ (int)dst) & wmask || length < wsize) - t = length; - else - t = wsize - (t & wmask); - length -= t; - TLOOP1(*dst++ = *src++); - } - /* - * Copy whole words, then mop up any trailing bytes. - */ - t = length / wsize; - TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize); - t = length & wmask; - TLOOP(*dst++ = *src++); - } else { - /* - * Copy backwards. Otherwise essentially the same. - * Alignment works as before, except that it takes - * (t&wmask) bytes to align, not wsize-(t&wmask). - */ - src += length; - dst += length; - t = (int)src; - if ((t | (int)dst) & wmask) { - if ((t ^ (int)dst) & wmask || length <= wsize) - t = length; - else - t &= wmask; - length -= t; - TLOOP1(*--dst = *--src); - } - t = length / wsize; - TLOOP(src -= wsize; dst -= wsize; *(word *)dst = *(word *)src); - t = length & wmask; - TLOOP(*--dst = *--src); - } -done: -#if defined(MEMCOPY) || defined(MEMMOVE) - return (dst0); -#else - return; +__BEGIN_DECLS +struct passwd *getpwuid __P((uid_t)); +struct passwd *getpwnam __P((const char *)); +int getpwuid_r __P((uid_t, struct passwd *, char *, size_t, struct passwd **)); +int getpwnam_r __P((const char *, struct passwd *, char *, size_t, struct passwd **)); +#ifndef _POSIX_SOURCE +struct passwd *getpwent __P((void)); +#ifndef _XOPEN_SOURCE +int setpassent __P((int)); +#endif +int setpwent __P((void)); +void endpwent __P((void)); #endif -} +__END_DECLS +#endif /* !_PWD_H_ */ diff --git a/include/ranlib.h b/include/ranlib.h new file mode 100644 index 0000000..543b89a --- /dev/null +++ b/include/ranlib.h @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ +/* + * Copyright (c) 1990, 1982, 1985, 1986, 1988, 1993, 1994 + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)ranlib.h 8.1 (Berkeley) 6/2/93 + */ +#ifndef _RANLIB_H_ +#define _RANLIB_H_ + +#include /* off_t */ + +/* + * There are two known orders of table of contents for archives. The first is + * the order ranlib(1) originally produced and still produces without any + * options. This table of contents has the archive member name "__.SYMDEF" + * This order has the ranlib structures in the order the objects appear in the + * archive and the symbol names of those objects in the order of symbol table. + * The second know order is sorted by symbol name and is produced with the -s + * option to ranlib(1). This table of contents has the archive member name + * "__.SYMDEF SORTED" and many programs (notably the 1.0 version of ld(1) can't + * tell the difference between names because of the imbedded blank in the name + * and works with either table of contents). This second order is used by the + * post 1.0 link editor to produce faster linking. The original 1.0 version of + * ranlib(1) gets confused when it is run on a archive with the second type of + * table of contents because it and ar(1) which it uses use different ways to + * determined the member name (ar(1) treats all blanks in the name as + * significant and ranlib(1) only checks for the first one). + */ +#define SYMDEF "__.SYMDEF" +#define SYMDEF_SORTED "__.SYMDEF SORTED" + +#define RANLIBMAG "__.SYMDEF" /* archive file name */ +#define RANLIBSKEW 3 /* creation time offset */ + +/* + * Structure of the __.SYMDEF table of contents for an archive. + * __.SYMDEF begins with a long giving the size in bytes of the ranlib + * structures which immediately follow, and then continues with a string + * table consisting of a long giving the number of bytes of strings which + * follow and then the strings themselves. The ran_strx fields index the + * string table whose first byte is numbered 0. + */ +struct ranlib { + union { + off_t ran_strx; /* string table index of */ + char *ran_name; /* symbol defined by */ + } ran_un; + off_t ran_off; /* library member at this offset */ +}; +#endif /* ! _RANLIB_H_ */ diff --git a/include/regex.h b/include/regex.h new file mode 100644 index 0000000..ad48247 --- /dev/null +++ b/include/regex.h @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/*- + * Copyright (c) 1992 Henry Spencer. + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Henry Spencer of the University of Toronto. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)regex.h 8.2 (Berkeley) 1/3/94 + */ + +#ifndef _REGEX_H_ +#define _REGEX_H_ + +#include + +/* types */ +typedef off_t regoff_t; + +typedef struct { + int re_magic; + size_t re_nsub; /* number of parenthesized subexpressions */ + __const char *re_endp; /* end pointer for REG_PEND */ + struct re_guts *re_g; /* none of your business :-) */ +} regex_t; + +typedef struct { + regoff_t rm_so; /* start of match */ + regoff_t rm_eo; /* end of match */ +} regmatch_t; + +/* regcomp() flags */ +#define REG_BASIC 0000 +#define REG_EXTENDED 0001 +#define REG_ICASE 0002 +#define REG_NOSUB 0004 +#define REG_NEWLINE 0010 +#define REG_NOSPEC 0020 +#define REG_PEND 0040 +#define REG_DUMP 0200 + +/* regerror() flags */ +#define REG_NOMATCH 1 +#define REG_BADPAT 2 +#define REG_ECOLLATE 3 +#define REG_ECTYPE 4 +#define REG_EESCAPE 5 +#define REG_ESUBREG 6 +#define REG_EBRACK 7 +#define REG_EPAREN 8 +#define REG_EBRACE 9 +#define REG_BADBR 10 +#define REG_ERANGE 11 +#define REG_ESPACE 12 +#define REG_BADRPT 13 +#define REG_EMPTY 14 +#define REG_ASSERT 15 +#define REG_INVARG 16 +#define REG_ATOI 255 /* convert name to number (!) */ +#define REG_ITOA 0400 /* convert number to name (!) */ + +/* regexec() flags */ +#define REG_NOTBOL 00001 +#define REG_NOTEOL 00002 +#define REG_STARTEND 00004 +#define REG_TRACE 00400 /* tracing of execution */ +#define REG_LARGE 01000 /* force large representation */ +#define REG_BACKR 02000 /* force use of backref code */ + +__BEGIN_DECLS +int regcomp __P((regex_t *, const char *, int)); +size_t regerror __P((int, const regex_t *, char *, size_t)); +int regexec __P((const regex_t *, + const char *, size_t, regmatch_t [], int)); +void regfree __P((regex_t *)); +__END_DECLS + +#endif /* !_REGEX_H_ */ diff --git a/include/regexp.h b/include/regexp.h new file mode 100644 index 0000000..97ce7e4 --- /dev/null +++ b/include/regexp.h @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1986 by University of Toronto. + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley + * by Henry Spencer. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)regexp.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _REGEXP_H_ +#define _REGEXP_H_ + +/* + * Definitions etc. for regexp(3) routines. + * + * Caveat: this is V8 regexp(3) [actually, a reimplementation thereof], + * not the System V one. + */ +#define NSUBEXP 10 +typedef struct regexp { + char *startp[NSUBEXP]; + char *endp[NSUBEXP]; + char regstart; /* Internal use only. */ + char reganch; /* Internal use only. */ + char *regmust; /* Internal use only. */ + int regmlen; /* Internal use only. */ + char program[1]; /* Unwarranted chumminess with compiler. */ +} regexp; + +#include + +__BEGIN_DECLS +regexp *regcomp __P((const char *)); +int regexec __P((const regexp *, const char *)); +void regsub __P((const regexp *, const char *, char *)); +void regerror __P((const char *)); +__END_DECLS + +#endif /* !_REGEXP_H_ */ diff --git a/include/rune.h b/include/rune.h new file mode 100644 index 0000000..c1e2b88 --- /dev/null +++ b/include/rune.h @@ -0,0 +1,66 @@ +/*- + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Paul Borman at Krystal Technologies. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)rune.h 8.1 (Berkeley) 6/27/93 + */ + +#ifndef _RUNE_H_ +#define _RUNE_H_ + +#include +#include + +#define _PATH_LOCALE "/usr/share/locale" + +#define _INVALID_RUNE _CurrentRuneLocale->invalid_rune + +#define __sgetrune _CurrentRuneLocale->sgetrune +#define __sputrune _CurrentRuneLocale->sputrune + +#define sgetrune(s, n, r) (*__sgetrune)((s), (n), (r)) +#define sputrune(c, s, n, r) (*__sputrune)((c), (s), (n), (r)) + +__BEGIN_DECLS +char *mbrune __P((const char *, rune_t)); +char *mbrrune __P((const char *, rune_t)); +char *mbmb __P((const char *, char *)); +long fgetrune __P((FILE *)); +int fputrune __P((rune_t, FILE *)); +int fungetrune __P((rune_t, FILE *)); +int setrunelocale __P((char *)); +void setinvalidrune __P((rune_t)); +__END_DECLS + +#endif /*! _RUNE_H_ */ diff --git a/include/runetype.h b/include/runetype.h new file mode 100644 index 0000000..84ce83f --- /dev/null +++ b/include/runetype.h @@ -0,0 +1,110 @@ +/*- + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Paul Borman at Krystal Technologies. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)runetype.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _RUNETYPE_H_ +#define _RUNETYPE_H_ + +#include +#include + +#ifndef _BSD_RUNE_T_DEFINED_ +#define _BSD_RUNE_T_DEFINED_ +typedef _BSD_RUNE_T_ rune_t; +#endif + +#ifndef _BSD_SIZE_T_DEFINED_ +#define _BSD_SIZE_T_DEFINED_ +typedef _BSD_SIZE_T_ size_t; +#endif + +#ifndef _BSD_WCHAR_T_DEFINED_ +#define _BSD_WCHAR_T_DEFINED_ +typedef _BSD_WCHAR_T_ wchar_t; +#endif + +#define _CACHED_RUNES (1 <<8 ) /* Must be a power of 2 */ +#define _CRMASK (~(_CACHED_RUNES - 1)) + +/* + * The lower 8 bits of runetype[] contain the digit value of the rune. + */ +typedef struct { + rune_t min; /* First rune of the range */ + rune_t max; /* Last rune (inclusive) of the range */ + rune_t map; /* What first maps to in maps */ + unsigned long *types; /* Array of types in range */ +} _RuneEntry; + +typedef struct { + int nranges; /* Number of ranges stored */ + _RuneEntry *ranges; /* Pointer to the ranges */ +} _RuneRange; + +typedef struct { + char magic[8]; /* Magic saying what version we are */ + char encoding[32]; /* ASCII name of this encoding */ + + rune_t (*sgetrune) + __P((const char *, size_t, char const **)); + int (*sputrune) + __P((rune_t, char *, size_t, char **)); + rune_t invalid_rune; + + unsigned long runetype[_CACHED_RUNES]; + rune_t maplower[_CACHED_RUNES]; + rune_t mapupper[_CACHED_RUNES]; + + /* + * The following are to deal with Runes larger than _CACHED_RUNES - 1. + * Their data is actually contiguous with this structure so as to make + * it easier to read/write from/to disk. + */ + _RuneRange runetype_ext; + _RuneRange maplower_ext; + _RuneRange mapupper_ext; + + void *variable; /* Data which depends on the encoding */ + int variable_len; /* how long that data is */ +} _RuneLocale; + +#define _RUNE_MAGIC_1 "RuneMagi" /* Indicates version 0 of RuneLocale */ + +extern _RuneLocale _DefaultRuneLocale; +extern _RuneLocale *_CurrentRuneLocale; + +#endif /* !_RUNETYPE_H_ */ diff --git a/include/semaphore.h b/include/semaphore.h new file mode 100644 index 0000000..bde387f --- /dev/null +++ b/include/semaphore.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +#ifndef _BSD_SEMAPHORE_H +#define _BSD_SEMAPHORE_H + +#include +#include + +#include + +#endif /* _BSD_SEMAPHORE_H */ diff --git a/include/setjmp.h b/include/setjmp.h new file mode 100644 index 0000000..51c8fd8 --- /dev/null +++ b/include/setjmp.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +#ifndef _BSD_SETJMP_H +#define _BSD_SETJMP_H + +#include + +#endif /* _BSD_SETJMP_H */ diff --git a/gen.subproj/usleep.c b/include/sgtty.h similarity index 89% rename from gen.subproj/usleep.c rename to include/sgtty.h index 96e7432..59081aa 100644 --- a/gen.subproj/usleep.c +++ b/include/sgtty.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -20,7 +20,7 @@ * @APPLE_LICENSE_HEADER_END@ */ /* - * Copyright (c) 1989, 1993 + * 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 @@ -50,16 +50,11 @@ * 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. + * + * @(#)sgtty.h 8.1 (Berkeley) 6/2/93 */ - -#include -#include -#include - -void -usleep(useconds) - unsigned int useconds; -{ - (void)syscall_thread_switch(THREAD_NULL, SWITCH_OPTION_WAIT, useconds / 1000); -} +#ifndef USE_OLD_TTY +#define USE_OLD_TTY +#endif +#include diff --git a/stdio.subproj/mktemp.c b/include/signal.h similarity index 61% rename from stdio.subproj/mktemp.c rename to include/signal.h index e6e29eb..704547b 100644 --- a/stdio.subproj/mktemp.c +++ b/include/signal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -19,8 +19,8 @@ * * @APPLE_LICENSE_HEADER_END@ */ -/* - * Copyright (c) 1987, 1993 +/*- + * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -50,96 +50,55 @@ * 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. + * + * @(#)signal.h 8.3 (Berkeley) 3/30/94 */ +#ifndef _USER_SIGNAL_H +#define _USER_SIGNAL_H #include -#include -#include -#include -#include -#include -#include - -static int _gettemp(); - -int -mkstemp(path) - char *path; -{ - int fd; - - return (_gettemp(path, &fd) ? fd : -1); -} - -char * -mktemp(path) - char *path; -{ - return(_gettemp(path, (int *)NULL) ? path : (char *)NULL); -} - -static int -_gettemp(path, doopen) - char *path; - register int *doopen; -{ - register char *start, *trv; - struct stat sbuf; - u_int pid; +#include +#include - pid = getpid(); - for (trv = path; *trv; ++trv); /* extra X's get set to 0's */ - while (*--trv == 'X') { - *trv = (pid % 10) + '0'; - pid /= 10; - } +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) +extern __const char *__const sys_signame[NSIG]; +extern __const char *__const sys_siglist[NSIG]; +#endif - /* - * check the target directory; if you have six X's and it - * doesn't exist this runs for a *very* long time. - */ - for (start = trv + 1;; --trv) { - if (trv <= path) - break; - if (*trv == '/') { - *trv = '\0'; - if (stat(path, &sbuf)) - return(0); - if (!S_ISDIR(sbuf.st_mode)) { - errno = ENOTDIR; - return(0); - } - *trv = '/'; - break; - } - } +__BEGIN_DECLS +int raise __P((int)); +#ifndef _ANSI_SOURCE +int kill __P((pid_t, int)); +int sigaction __P((int, const struct sigaction *, struct sigaction *)); +int sigaddset __P((sigset_t *, int)); +int sigdelset __P((sigset_t *, int)); +int sigemptyset __P((sigset_t *)); +int sigfillset __P((sigset_t *)); +int sigismember __P((const sigset_t *, int)); +int sigpending __P((sigset_t *)); +int sigprocmask __P((int, const sigset_t *, sigset_t *)); +int sigsuspend __P((const sigset_t *)); +#ifndef _POSIX_SOURCE +int killpg __P((pid_t, int)); +int sigblock __P((int)); +int siginterrupt __P((int, int)); +int sighold __P((int)); +int sigrelse __P((int)); +int sigpause __P((int)); +int sigreturn __P((struct sigcontext *)); +int sigsetmask __P((int)); +int sigvec __P((int, struct sigvec *, struct sigvec *)); +void psignal __P((unsigned int, const char *)); +#endif /* !_POSIX_SOURCE */ +#endif /* !_ANSI_SOURCE */ +__END_DECLS - for (;;) { - if (doopen) { - if ((*doopen = - open(path, O_CREAT|O_EXCL|O_RDWR, 0600)) >= 0) - return(1); - if (errno != EEXIST) - return(0); - } - else if (stat(path, &sbuf)) - return(errno == ENOENT ? 1 : 0); +/* List definitions after function declarations, or Reiser cpp gets upset. */ +#define sigaddset(set, signo) (*(set) |= 1 << ((signo) - 1), 0) +#define sigdelset(set, signo) (*(set) &= ~(1 << ((signo) - 1)), 0) +#define sigemptyset(set) (*(set) = 0, 0) +#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) +#define sigismember(set, signo) ((*(set) & (1 << ((signo) - 1))) != 0) - /* tricky little algorithm for backward compatibility */ - for (trv = start;;) { - if (!*trv) - return(0); - if (*trv == 'z') - *trv++ = 'a'; - else { - if (isdigit(*trv)) - *trv = 'a'; - else - ++*trv; - break; - } - } - } - /*NOTREACHED*/ -} +#endif /* !_USER_SIGNAL_H */ diff --git a/include/stab.h b/include/stab.h new file mode 100644 index 0000000..e4ee83e --- /dev/null +++ b/include/stab.h @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/*- + * Copyright (c) 1991, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)stab.h 8.1 (Berkeley) 6/2/93 + */ + +/* + * The following are symbols used by various debuggers and by the Pascal + * compiler. Each of them must have one (or more) of the bits defined by + * the N_STAB mask set. + */ + +#define N_GSYM 0x20 /* global symbol */ +#define N_FNAME 0x22 /* F77 function name */ +#define N_FUN 0x24 /* procedure name */ +#define N_STSYM 0x26 /* data segment variable */ +#define N_LCSYM 0x28 /* bss segment variable */ +#define N_MAIN 0x2a /* main function name */ +#define N_PC 0x30 /* global Pascal symbol */ +#define N_RSYM 0x40 /* register variable */ +#define N_SLINE 0x44 /* text segment line number */ +#define N_DSLINE 0x46 /* data segment line number */ +#define N_BSLINE 0x48 /* bss segment line number */ +#define N_SSYM 0x60 /* structure/union element */ +#define N_SO 0x64 /* main source file name */ +#define N_LSYM 0x80 /* stack variable */ +#define N_BINCL 0x82 /* include file beginning */ +#define N_SOL 0x84 /* included source file name */ +#define N_PSYM 0xa0 /* parameter variable */ +#define N_EINCL 0xa2 /* include file end */ +#define N_ENTRY 0xa4 /* alternate entry point */ +#define N_LBRAC 0xc0 /* left bracket */ +#define N_EXCL 0xc2 /* deleted include file */ +#define N_RBRAC 0xe0 /* right bracket */ +#define N_BCOMM 0xe2 /* begin common */ +#define N_ECOMM 0xe4 /* end common */ +#define N_ECOML 0xe8 /* end common (local name) */ +#define N_LENG 0xfe /* length of preceding entry */ diff --git a/headers.subproj/standards.h b/include/standards.h similarity index 100% rename from headers.subproj/standards.h rename to include/standards.h diff --git a/include/stddef.h b/include/stddef.h new file mode 100644 index 0000000..6835ac5 --- /dev/null +++ b/include/stddef.h @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* $OpenBSD: stddef.h,v 1.2 1997/09/21 10:45:52 niklas Exp $ */ +/* $NetBSD: stddef.h,v 1.4 1994/10/26 00:56:26 cgd Exp $ */ + +/*- + * Copyright (c) 1990 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)stddef.h 5.5 (Berkeley) 4/3/91 + */ + +#ifndef __STDDEF_H__ +#define __STDDEF_H__ + +#include +#include + +typedef _BSD_PTRDIFF_T_ ptrdiff_t; + +#ifndef _BSD_SIZE_T_DEFINED_ +#define _BSD_SIZE_T_DEFINED_ +typedef _BSD_SIZE_T_ size_t; +#endif + +#if !defined(_ANSI_SOURCE) +#ifndef _BSD_RUNE_T_DEFINED_ +#define _BSD_RUNE_T_DEFINED_ +typedef _BSD_RUNE_T_ rune_t; +#endif +#endif + +#ifndef _BSD_WCHAR_T_DEFINED_ +#define _BSD_WCHAR_T_DEFINED_ +typedef _BSD_WCHAR_T_ wchar_t; +#endif + +#ifndef NULL +#define NULL 0 +#endif + +#define offsetof(type, member) __offsetof(type, member) + +#endif /* __STDDEF_H__ */ diff --git a/include/stdio.h b/include/stdio.h new file mode 100644 index 0000000..e87d94a --- /dev/null +++ b/include/stdio.h @@ -0,0 +1,404 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)stdio.h 8.5 (Berkeley) 4/29/95 + */ + +#ifndef _STDIO_H_ +#define _STDIO_H_ + +#if !defined(_ANSI_SOURCE) && !defined(__STRICT_ANSI__) +#include +#endif + +#include + +#include +#ifndef _BSD_SIZE_T_DEFINED_ +#define _BSD_SIZE_T_DEFINED_ +typedef _BSD_SIZE_T_ size_t; +#endif + +#ifndef NULL +#define NULL 0 +#endif + +/* + * This is fairly grotesque, but pure ANSI code must not inspect the + * innards of an fpos_t anyway. The library internally uses off_t, + * which we assume is exactly as big as eight chars. (When we switch + * to gcc 2.4 we will use __attribute__ here.) + * + * WARNING: the alignment constraints on an off_t and the struct below + * differ on (e.g.) the SPARC. Hence, the placement of an fpos_t object + * in a structure will change if fpos_t's are not aligned on 8-byte + * boundaries. THIS IS A CROCK, but for now there is no way around it. + */ +#if !defined(_ANSI_SOURCE) && !defined(__STRICT_ANSI__) +typedef off_t fpos_t; +#else +typedef struct __sfpos { + char _pos[8]; +} fpos_t; +#endif + +#define _FSTDIO /* Define for new stdio with functions. */ + +/* + * NB: to fit things in six character monocase externals, the stdio + * code uses the prefix `__s' for stdio objects, typically followed + * by a three-character attempt at a mnemonic. + */ + +/* stdio buffers */ +struct __sbuf { + unsigned char *_base; + int _size; +}; + +/* + * stdio state variables. + * + * The following always hold: + * + * if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR), + * _lbfsize is -_bf._size, else _lbfsize is 0 + * if _flags&__SRD, _w is 0 + * if _flags&__SWR, _r is 0 + * + * This ensures that the getc and putc macros (or inline functions) never + * try to write or read from a file that is in `read' or `write' mode. + * (Moreover, they can, and do, automatically switch from read mode to + * write mode, and back, on "r+" and "w+" files.) + * + * _lbfsize is used only to make the inline line-buffered output stream + * code as compact as possible. + * + * _ub, _up, and _ur are used when ungetc() pushes back more characters + * than fit in the current _bf, or when ungetc() pushes back a character + * that does not match the previous one in _bf. When this happens, + * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff + * _ub._base!=NULL) and _up and _ur save the current values of _p and _r. + * + * NB: see WARNING above before changing the layout of this structure! + */ +typedef struct __sFILE { + unsigned char *_p; /* current position in (some) buffer */ + int _r; /* read space left for getc() */ + int _w; /* write space left for putc() */ + short _flags; /* flags, below; this FILE is free if 0 */ + short _file; /* fileno, if Unix descriptor, else -1 */ + struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */ + int _lbfsize; /* 0 or -_bf._size, for inline putc */ + + /* operations */ + void *_cookie; /* cookie passed to io functions */ + int (*_close) __P((void *)); + int (*_read) __P((void *, char *, int)); + fpos_t (*_seek) __P((void *, fpos_t, int)); + int (*_write) __P((void *, const char *, int)); + + /* separate buffer for long sequences of ungetc() */ + struct __sbuf _ub; /* ungetc buffer */ + unsigned char *_up; /* saved _p when _p is doing ungetc data */ + int _ur; /* saved _r when _r is counting ungetc data */ + + /* tricks to meet minimum requirements even when malloc() fails */ + unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */ + unsigned char _nbuf[1]; /* guarantee a getc() buffer */ + + /* separate buffer for fgetln() when line crosses buffer boundary */ + struct __sbuf _lb; /* buffer for fgetln() */ + + /* Unix stdio files get aligned to block boundaries on fseek() */ + int _blksize; /* stat.st_blksize (may be != _bf._size) */ + fpos_t _offset; /* current lseek offset (see WARNING) */ +} FILE; + +__BEGIN_DECLS +extern FILE __sF[]; +__END_DECLS + +#define __SLBF 0x0001 /* line buffered */ +#define __SNBF 0x0002 /* unbuffered */ +#define __SRD 0x0004 /* OK to read */ +#define __SWR 0x0008 /* OK to write */ + /* RD and WR are never simultaneously asserted */ +#define __SRW 0x0010 /* open for reading & writing */ +#define __SEOF 0x0020 /* found EOF */ +#define __SERR 0x0040 /* found error */ +#define __SMBF 0x0080 /* _buf is from malloc */ +#define __SAPP 0x0100 /* fdopen()ed in append mode */ +#define __SSTR 0x0200 /* this is an sprintf/snprintf string */ +#define __SOPT 0x0400 /* do fseek() optimisation */ +#define __SNPT 0x0800 /* do not do fseek() optimisation */ +#define __SOFF 0x1000 /* set iff _offset is in fact correct */ +#define __SMOD 0x2000 /* true => fgetln modified _p text */ +#define __SALC 0x4000 /* allocate string space dynamically */ + +/* + * The following three definitions are for ANSI C, which took them + * from System V, which brilliantly took internal interface macros and + * made them official arguments to setvbuf(), without renaming them. + * Hence, these ugly _IOxxx names are *supposed* to appear in user code. + * + * Although numbered as their counterparts above, the implementation + * does not rely on this. + */ +#define _IOFBF 0 /* setvbuf should set fully buffered */ +#define _IOLBF 1 /* setvbuf should set line buffered */ +#define _IONBF 2 /* setvbuf should set unbuffered */ + +#define BUFSIZ 1024 /* size of buffer used by setbuf */ +#define EOF (-1) + +/* + * FOPEN_MAX is a minimum maximum, and is the number of streams that + * stdio can provide without attempting to allocate further resources + * (which could fail). Do not use this for anything. + */ + /* must be == _POSIX_STREAM_MAX */ +#define FOPEN_MAX 20 /* must be <= OPEN_MAX */ +#define FILENAME_MAX 1024 /* must be <= PATH_MAX */ + +/* System V/ANSI C; this is the wrong way to do this, do *not* use these. */ +#ifndef _ANSI_SOURCE +#define P_tmpdir "/var/tmp/" +#endif +#define L_tmpnam 1024 /* XXX must be == PATH_MAX */ +#define TMP_MAX 308915776 + +#ifndef SEEK_SET +#define SEEK_SET 0 /* set file offset to offset */ +#endif +#ifndef SEEK_CUR +#define SEEK_CUR 1 /* set file offset to current plus offset */ +#endif +#ifndef SEEK_END +#define SEEK_END 2 /* set file offset to EOF plus offset */ +#endif + +#define stdin (&__sF[0]) +#define stdout (&__sF[1]) +#define stderr (&__sF[2]) + +/* + * Functions defined in ANSI C standard. + */ +__BEGIN_DECLS +void clearerr __P((FILE *)); +int fclose __P((FILE *)); +int feof __P((FILE *)); +int ferror __P((FILE *)); +int fflush __P((FILE *)); +int fgetc __P((FILE *)); +int fgetpos __P((FILE *, fpos_t *)); +char *fgets __P((char *, int, FILE *)); +FILE *fopen __P((const char *, const char *)); +int fprintf __P((FILE *, const char *, ...)); +int fputc __P((int, FILE *)); +int fputs __P((const char *, FILE *)); +size_t fread __P((void *, size_t, size_t, FILE *)); +FILE *freopen __P((const char *, const char *, FILE *)); +int fscanf __P((FILE *, const char *, ...)); +int fseek __P((FILE *, long, int)); +int fsetpos __P((FILE *, const fpos_t *)); +long ftell __P((FILE *)); +size_t fwrite __P((const void *, size_t, size_t, FILE *)); +int getc __P((FILE *)); +int getchar __P((void)); +char *gets __P((char *)); +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) +extern __const int sys_nerr; /* perror(3) external variables */ +extern __const char *__const sys_errlist[]; +#endif +void perror __P((const char *)); +int printf __P((const char *, ...)); +int putc __P((int, FILE *)); +int putchar __P((int)); +int puts __P((const char *)); +int remove __P((const char *)); +int rename __P((const char *, const char *)); +void rewind __P((FILE *)); +int scanf __P((const char *, ...)); +void setbuf __P((FILE *, char *)); +int setvbuf __P((FILE *, char *, int, size_t)); +int sprintf __P((char *, const char *, ...)); +int sscanf __P((const char *, const char *, ...)); +FILE *tmpfile __P((void)); +char *tmpnam __P((char *)); +int ungetc __P((int, FILE *)); +int vfprintf __P((FILE *, const char *, _BSD_VA_LIST_)); +int vprintf __P((const char *, _BSD_VA_LIST_)); +int vsprintf __P((char *, const char *, _BSD_VA_LIST_)); +int asprintf __P((char **, const char *, ...)); +int vasprintf __P((char **, const char *, _BSD_VA_LIST_)); +__END_DECLS + +/* + * Functions defined in POSIX 1003.1. + */ +#ifndef _ANSI_SOURCE +#define L_cuserid 9 /* size for cuserid(); UT_NAMESIZE + 1 */ +#define L_ctermid 1024 /* size for ctermid(); PATH_MAX */ + +__BEGIN_DECLS +char *ctermid __P((char *)); +FILE *fdopen __P((int, const char *)); +int fileno __P((FILE *)); +__END_DECLS +#endif /* not ANSI */ + +/* + * Routines that are purely local. + */ +#if !defined (_ANSI_SOURCE) && !defined(_POSIX_SOURCE) +__BEGIN_DECLS +char *fgetln __P((FILE *, size_t *)); +int fpurge __P((FILE *)); +int fseeko __P((FILE *, fpos_t, int)); +fpos_t ftello __P((FILE *)); +int getw __P((FILE *)); +int pclose __P((FILE *)); +FILE *popen __P((const char *, const char *)); +int putw __P((int, FILE *)); +void setbuffer __P((FILE *, char *, int)); +int setlinebuf __P((FILE *)); +char *tempnam __P((const char *, const char *)); +int snprintf __P((char *, size_t, const char *, ...)); +int vsnprintf __P((char *, size_t, const char *, _BSD_VA_LIST_)); +int vscanf __P((const char *, _BSD_VA_LIST_)); +int vsscanf __P((const char *, const char *, _BSD_VA_LIST_)); +FILE *zopen __P((const char *, const char *, int)); +__END_DECLS + +/* + * This is a #define because the function is used internally and + * (unlike vfscanf) the name __svfscanf is guaranteed not to collide + * with a user function when _ANSI_SOURCE or _POSIX_SOURCE is defined. + */ +#define vfscanf __svfscanf + +/* + * Stdio function-access interface. + */ +__BEGIN_DECLS +FILE *funopen __P((const void *, + int (*)(void *, char *, int), + int (*)(void *, const char *, int), + fpos_t (*)(void *, fpos_t, int), + int (*)(void *))); +__END_DECLS +#define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0) +#define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0) +#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */ + +/* + * Functions internal to the implementation. + */ +__BEGIN_DECLS +int __srget __P((FILE *)); +int __svfscanf __P((FILE *, const char *, _BSD_VA_LIST_)); +int __swbuf __P((int, FILE *)); +__END_DECLS + +/* + * The __sfoo macros are here so that we can + * define function versions in the C library. + */ +#define __sgetc(p) (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++)) +#if defined(__GNUC__) && defined(__STDC__) +static __inline int __sputc(int _c, FILE *_p) { + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf(_c, _p)); +} +#else +/* + * This has been tuned to generate reasonable code on the vax using pcc. + */ +#define __sputc(c, p) \ + (--(p)->_w < 0 ? \ + (p)->_w >= (p)->_lbfsize ? \ + (*(p)->_p = (c)), *(p)->_p != '\n' ? \ + (int)*(p)->_p++ : \ + __swbuf('\n', p) : \ + __swbuf((int)(c), p) : \ + (*(p)->_p = (c), (int)*(p)->_p++)) +#endif + +#define __sfeof(p) (((p)->_flags & __SEOF) != 0) +#define __sferror(p) (((p)->_flags & __SERR) != 0) +#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF))) +#define __sfileno(p) ((p)->_file) + +#define feof(p) __sfeof(p) +#define ferror(p) __sferror(p) +#define clearerr(p) __sclearerr(p) + +#ifndef _ANSI_SOURCE +#define fileno(p) __sfileno(p) +#endif + +#ifndef lint +#define getc(fp) __sgetc(fp) +#define putc(x, fp) __sputc(x, fp) +#endif /* lint */ + +#define getchar() getc(stdin) +#define putchar(x) putc(x, stdout) +#endif /* _STDIO_H_ */ diff --git a/include/stdlib.h b/include/stdlib.h new file mode 100644 index 0000000..4e79128 --- /dev/null +++ b/include/stdlib.h @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/*- + * Copyright (c) 1990, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)stdlib.h 8.5 (Berkeley) 5/19/95 + */ + +#ifndef _STDLIB_H_ +#define _STDLIB_H_ + +#include +#include + +#ifndef _BSD_SIZE_T_DEFINED_ +#define _BSD_SIZE_T_DEFINED_ +typedef _BSD_SIZE_T_ size_t; +#endif + +#if !defined(_ANSI_SOURCE) +#ifndef _BSD_RUNE_T_DEFINED_ +#define _BSD_RUNE_T_DEFINED_ +typedef _BSD_WCHAR_T_ rune_t; +#endif +#endif + +#ifndef _BSD_WCHAR_T_DEFINED_ +#define _BSD_WCHAR_T_DEFINED_ +typedef _BSD_WCHAR_T_ wchar_t; +#endif + +typedef struct { + int quot; /* quotient */ + int rem; /* remainder */ +} div_t; + +typedef struct { + long quot; /* quotient */ + long rem; /* remainder */ +} ldiv_t; + +#ifndef NULL +#define NULL 0 +#endif + +#define EXIT_FAILURE 1 +#define EXIT_SUCCESS 0 + +#define RAND_MAX 0x7fffffff + +extern int __mb_cur_max; +#define MB_CUR_MAX __mb_cur_max + +#include + +__BEGIN_DECLS +__dead void + abort __P((void)); +__pure int + abs __P((int)); +int atexit __P((void (*)(void))); +double atof __P((const char *)); +int atoi __P((const char *)); +long atol __P((const char *)); +void *bsearch __P((const void *, const void *, size_t, + size_t, int (*)(const void *, const void *))); +void *calloc __P((size_t, size_t)); +__pure div_t + div __P((int, int)); +__dead void + exit __P((int)); +void free __P((void *)); +char *getenv __P((const char *)); +__pure long + labs __P((long)); +__pure ldiv_t + ldiv __P((long, long)); +void *malloc __P((size_t)); +void qsort __P((void *, size_t, size_t, + int (*)(const void *, const void *))); +int rand __P((void)); +void *realloc __P((void *, size_t)); +void srand __P((unsigned)); +double strtod __P((const char *, char **)); +long strtol __P((const char *, char **, int)); +unsigned long + strtoul __P((const char *, char **, int)); +int system __P((const char *)); + +/* These are currently just stubs. */ +int mblen __P((const char *, size_t)); +size_t mbstowcs __P((wchar_t *, const char *, size_t)); +int wctomb __P((char *, wchar_t)); +int mbtowc __P((wchar_t *, const char *, size_t)); +size_t wcstombs __P((char *, const wchar_t *, size_t)); + +#ifndef _ANSI_SOURCE +int putenv __P((const char *)); +int setenv __P((const char *, const char *, int)); +#endif + +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) +double drand48 __P((void)); +double erand48 __P((unsigned short[3])); +long jrand48 __P((unsigned short[3])); +void lcong48 __P((unsigned short[7])); +long lrand48 __P((void)); +long mrand48 __P((void)); +long nrand48 __P((unsigned short[3])); +unsigned short + *seed48 __P((unsigned short[3])); +void srand48 __P((long)); + +void *alloca __P((size_t)); /* built-in for gcc */ + /* getcap(3) functions */ +u_int32_t + arc4random __P((void)); +void arc4random_addrandom __P((unsigned char *dat, int datlen)); +void arc4random_stir __P((void)); +char *getbsize __P((int *, long *)); +char *cgetcap __P((char *, char *, int)); +int cgetclose __P((void)); +int cgetent __P((char **, char **, char *)); +int cgetfirst __P((char **, char **)); +int cgetmatch __P((char *, char *)); +int cgetnext __P((char **, char **)); +int cgetnum __P((char *, char *, long *)); +int cgetset __P((char *)); +int cgetstr __P((char *, char *, char **)); +int cgetustr __P((char *, char *, char **)); + +int daemon __P((int, int)); +char *devname __P((int, int)); +int getloadavg __P((double [], int)); + +long a64l __P((const char *)); +char *l64a __P((long)); + +char *group_from_gid __P((unsigned long, int)); +int heapsort __P((void *, size_t, size_t, + int (*)(const void *, const void *))); +char *initstate __P((unsigned long, char *, long)); +int mergesort __P((void *, size_t, size_t, + int (*)(const void *, const void *))); +int radixsort __P((const unsigned char **, int, const unsigned char *, + unsigned)); +int sradixsort __P((const unsigned char **, int, const unsigned char *, + unsigned)); +int rand_r __P((unsigned *)); +long random __P((void)); +void *reallocf __P((void *, size_t)); +char *realpath __P((const char *, char resolved_path[])); +char *setstate __P((char *)); +void srandom __P((unsigned long)); +char *user_from_uid __P((unsigned long, int)); +#ifndef __STRICT_ANSI__ +long long + strtoll(const char *, char **, int); +unsigned long long + strtoull(const char *, char **, int); +long long + strtoq __P((const char *, char **, int)); +unsigned long long + strtouq __P((const char *, char **, int)); +#endif +void unsetenv __P((const char *)); +#endif +__END_DECLS + +#endif /* _STDLIB_H_ */ diff --git a/include/string.h b/include/string.h new file mode 100644 index 0000000..7c63b12 --- /dev/null +++ b/include/string.h @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/*- + * Copyright (c) 1990, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)string.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _STRING_H_ +#define _STRING_H_ +#include + +#ifndef _BSD_SIZE_T_DEFINED_ +#define _BSD_SIZE_T_DEFINED_ +typedef _BSD_SIZE_T_ size_t; +#endif + +#ifndef NULL +#define NULL 0 +#endif + +#include + +__BEGIN_DECLS +void *memchr __P((const void *, int, size_t)); +int memcmp __P((const void *, const void *, size_t)); +void *memcpy __P((void *, const void *, size_t)); +void *memmove __P((void *, const void *, size_t)); +void *memset __P((void *, int, size_t)); +char *strcat __P((char *, const char *)); +char *strchr __P((const char *, int)); +int strcmp __P((const char *, const char *)); +int strcoll __P((const char *, const char *)); +char *strcpy __P((char *, const char *)); +size_t strcspn __P((const char *, const char *)); +char *strerror __P((int)); +size_t strlen __P((const char *)); +char *strncat __P((char *, const char *, size_t)); +int strncmp __P((const char *, const char *, size_t)); +char *strncpy __P((char *, const char *, size_t)); +char *strpbrk __P((const char *, const char *)); +char *strrchr __P((const char *, int)); +size_t strspn __P((const char *, const char *)); +char *strstr __P((const char *, const char *)); +char *strtok __P((char *, const char *)); +size_t strxfrm __P((char *, const char *, size_t)); + +/* Nonstandard routines */ +#ifndef _ANSI_SOURCE +int bcmp __P((const void *, const void *, size_t)); +void bcopy __P((const void *, void *, size_t)); +void bzero __P((void *, size_t)); +int ffs __P((int)); +char *index __P((const char *, int)); +void *memccpy __P((void *, const void *, int, size_t)); +char *rindex __P((const char *, int)); +int strcasecmp __P((const char *, const char *)); +char *strdup __P((const char *)); +size_t strlcat __P((char *, const char *, size_t)); +size_t strlcpy __P((char *, const char *, size_t)); +void strmode __P((int, char *)); +int strncasecmp __P((const char *, const char *, size_t)); +char *strsep __P((char **, const char *)); +char *strtok_r __P((char *, const char *, char **)); +void swab __P((const void *, void *, size_t)); +#endif +__END_DECLS + +#endif /* _STRING_H_ */ diff --git a/stdlib.subproj/rand.c b/include/strings.h similarity index 90% rename from stdlib.subproj/rand.c rename to include/strings.h index 0379c8f..56c3ae4 100644 --- a/stdlib.subproj/rand.c +++ b/include/strings.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -19,7 +19,7 @@ * * @APPLE_LICENSE_HEADER_END@ */ -/* +/*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * @@ -50,23 +50,8 @@ * 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. + * + * @(#)strings.h 8.1 (Berkeley) 6/2/93 */ - -#include -#include - -static u_long next = 1; - -int -rand() -{ - return ((next = next * 1103515245 + 12345) % ((u_long)RAND_MAX + 1)); -} - -void -srand(seed) -u_int seed; -{ - next = seed; -} +#include diff --git a/include/struct.h b/include/struct.h new file mode 100644 index 0000000..ba8ac59 --- /dev/null +++ b/include/struct.h @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/*- + * Copyright (c) 1983, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)struct.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _STRUCT_H_ +#define _STRUCT_H_ + +/* Offset of the field in the structure. */ +#define fldoff(name, field) \ + ((int)&(((struct name *)0)->field)) + +/* Size of the field in the structure. */ +#define fldsiz(name, field) \ + (sizeof(((struct name *)0)->field)) + +/* Address of the structure from a field. */ +#define strbase(name, addr, field) \ + ((struct name *)((char *)(addr) - fldoff(name, field))) + +#endif /* !_STRUCT_H_ */ diff --git a/include/sysexits.h b/include/sysexits.h new file mode 100644 index 0000000..0a960a0 --- /dev/null +++ b/include/sysexits.h @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1987, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)sysexits.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _SYSEXITS_H_ +#define _SYSEXITS_H_ + +/* + * SYSEXITS.H -- Exit status codes for system programs. + * + * This include file attempts to categorize possible error + * exit statuses for system programs, notably delivermail + * and the Berkeley network. + * + * Error numbers begin at EX__BASE to reduce the possibility of + * clashing with other exit statuses that random programs may + * already return. The meaning of the codes is approximately + * as follows: + * + * EX_USAGE -- The command was used incorrectly, e.g., with + * the wrong number of arguments, a bad flag, a bad + * syntax in a parameter, or whatever. + * EX_DATAERR -- The input data was incorrect in some way. + * This should only be used for user's data & not + * system files. + * EX_NOINPUT -- An input file (not a system file) did not + * exist or was not readable. This could also include + * errors like "No message" to a mailer (if it cared + * to catch it). + * EX_NOUSER -- The user specified did not exist. This might + * be used for mail addresses or remote logins. + * EX_NOHOST -- The host specified did not exist. This is used + * in mail addresses or network requests. + * EX_UNAVAILABLE -- A service is unavailable. This can occur + * if a support program or file does not exist. This + * can also be used as a catchall message when something + * you wanted to do doesn't work, but you don't know + * why. + * EX_SOFTWARE -- An internal software error has been detected. + * This should be limited to non-operating system related + * errors as possible. + * EX_OSERR -- An operating system error has been detected. + * This is intended to be used for such things as "cannot + * fork", "cannot create pipe", or the like. It includes + * things like getuid returning a user that does not + * exist in the passwd file. + * EX_OSFILE -- Some system file (e.g., /etc/passwd, /etc/utmp, + * etc.) does not exist, cannot be opened, or has some + * sort of error (e.g., syntax error). + * EX_CANTCREAT -- A (user specified) output file cannot be + * created. + * EX_IOERR -- An error occurred while doing I/O on some file. + * EX_TEMPFAIL -- temporary failure, indicating something that + * is not really an error. In sendmail, this means + * that a mailer (e.g.) could not create a connection, + * and the request should be reattempted later. + * EX_PROTOCOL -- the remote system returned something that + * was "not possible" during a protocol exchange. + * EX_NOPERM -- You did not have sufficient permission to + * perform the operation. This is not intended for + * file system problems, which should use NOINPUT or + * CANTCREAT, but rather for higher level permissions. + */ + +#define EX_OK 0 /* successful termination */ + +#define EX__BASE 64 /* base value for error messages */ + +#define EX_USAGE 64 /* command line usage error */ +#define EX_DATAERR 65 /* data format error */ +#define EX_NOINPUT 66 /* cannot open input */ +#define EX_NOUSER 67 /* addressee unknown */ +#define EX_NOHOST 68 /* host name unknown */ +#define EX_UNAVAILABLE 69 /* service unavailable */ +#define EX_SOFTWARE 70 /* internal software error */ +#define EX_OSERR 71 /* system error (e.g., can't fork) */ +#define EX_OSFILE 72 /* critical OS file missing */ +#define EX_CANTCREAT 73 /* can't create (user) output file */ +#define EX_IOERR 74 /* input/output error */ +#define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */ +#define EX_PROTOCOL 76 /* remote error in protocol */ +#define EX_NOPERM 77 /* permission denied */ +#define EX_CONFIG 78 /* configuration error */ + +#define EX__MAX 78 /* maximum listed value */ + +#endif /* !_SYSEXITS_H_ */ diff --git a/include/syslog.h b/include/syslog.h new file mode 100644 index 0000000..455fe67 --- /dev/null +++ b/include/syslog.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +#include + diff --git a/net.subproj/ns_ntoa.c b/include/tar.h similarity index 65% rename from net.subproj/ns_ntoa.c rename to include/tar.h index e038815..37d0edc 100644 --- a/net.subproj/ns_ntoa.c +++ b/include/tar.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -19,10 +19,13 @@ * * @APPLE_LICENSE_HEADER_END@ */ -/* - * Copyright (c) 1986, 1993 +/*- + * Copyright (c) 1994 * The Regents of the University of California. All rights reserved. * + * This code is derived from software contributed to Berkeley by + * Chuck Karish of Mindcraft, Inc. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -50,69 +53,42 @@ * 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. + * + * @(#)tar.h 8.2 (Berkeley) 1/4/94 */ +#ifndef _TAR_H +#define _TAR_H -#include -#include -#include - -char * -ns_ntoa(addr) - struct ns_addr addr; -{ - static char obuf[40]; - union { union ns_net net_e; u_long long_e; } net; - u_short port = htons(addr.x_port); - register char *cp; - char *cp2; - register u_char *up = addr.x_host.c_host; - u_char *uplim = up + 6; - static char *spectHex(); +#define TMAGIC "ustar" /* ustar and a null */ +#define TMAGLEN 6 +#define TVERSION "00" /* 00 and no null */ +#define TVERSLEN 2 - net.net_e = addr.x_net; - sprintf(obuf, "%lx", ntohl(net.long_e)); - cp = spectHex(obuf); - cp2 = cp + 1; - while (*up==0 && up < uplim) up++; - if (up == uplim) { - if (port) { - sprintf(cp, ".0"); - cp += 2; - } - } else { - sprintf(cp, ".%x", *up++); - while (up < uplim) { - while (*cp) cp++; - sprintf(cp, "%02x", *up++); - } - cp = spectHex(cp2); - } - if (port) { - sprintf(cp, ".%x", port); - spectHex(cp + 1); - } - return (obuf); -} +/* Values used in typeflag field */ +#define REGTYPE '0' /* Regular file */ +#define AREGTYPE '\0' /* Regular file */ +#define LNKTYPE '1' /* Link */ +#define SYMTYPE '2' /* Reserved */ +#define CHRTYPE '3' /* Character special */ +#define BLKTYPE '4' /* Block special */ +#define DIRTYPE '5' /* Directory */ +#define FIFOTYPE '6' /* FIFO special */ +#define CONTTYPE '7' /* Reserved */ -static char * -spectHex(p0) - char *p0; -{ - int ok = 0; - int nonzero = 0; - register char *p = p0; - for (; *p; p++) switch (*p) { +/* Bits used in the mode field - values in octal */ +#define TSUID 04000 /* Set UID on execution */ +#define TSGID 02000 /* Set GID on execution */ +#define TSVTX 01000 /* Reserved */ + /* File permissions */ +#define TUREAD 00400 /* Read by owner */ +#define TUWRITE 00200 /* Write by owner */ +#define TUEXEC 00100 /* Execute/Search by owner */ +#define TGREAD 00040 /* Read by group */ +#define TGWRITE 00020 /* Write by group */ +#define TGEXEC 00010 /* Execute/Search by group */ +#define TOREAD 00004 /* Read by other */ +#define TOWRITE 00002 /* Write by other */ +#define TOEXEC 00001 /* Execute/Search by other */ - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - *p += ('A' - 'a'); - /* fall into . . . */ - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - ok = 1; - case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - nonzero = 1; - } - if (nonzero && !ok) { *p++ = 'H'; *p = 0; } - return (p); -} +#endif diff --git a/include/termios.h b/include/termios.h new file mode 100644 index 0000000..7ab55fe --- /dev/null +++ b/include/termios.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +#include + diff --git a/include/time.h b/include/time.h new file mode 100644 index 0000000..f2e35f5 --- /dev/null +++ b/include/time.h @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)time.h 8.3 (Berkeley) 1/21/94 + */ + +#ifndef _TIME_H_ +#define _TIME_H_ + +#include + +#ifndef NULL +#define NULL 0 +#endif + +#ifndef _BSD_CLOCK_T_DEFINED_ +#define _BSD_CLOCK_T_DEFINED_ +typedef _BSD_CLOCK_T_ clock_t; +#endif + +#ifndef _BSD_TIME_T_DEFINED_ +#define _BSD_TIME_T_DEFINED_ +typedef _BSD_TIME_T_ time_t; +#endif + +#ifndef _BSD_SIZE_T_DEFINED_ +#define _BSD_SIZE_T_DEFINED_ +typedef _BSD_SIZE_T_ size_t; +#endif + +#ifndef _TIMESPEC_DECLARED +#define _TIMESPEC_DECLARED +struct timespec { + time_t tv_sec; /* seconds */ + long tv_nsec; /* and nanoseconds */ +}; +#endif + +struct tm { + int tm_sec; /* seconds after the minute [0-60] */ + int tm_min; /* minutes after the hour [0-59] */ + int tm_hour; /* hours since midnight [0-23] */ + int tm_mday; /* day of the month [1-31] */ + int tm_mon; /* months since January [0-11] */ + int tm_year; /* years since 1900 */ + int tm_wday; /* days since Sunday [0-6] */ + int tm_yday; /* days since January 1 [0-365] */ + int tm_isdst; /* Daylight Savings Time flag */ + long tm_gmtoff; /* offset from CUT in seconds */ + char *tm_zone; /* timezone abbreviation */ +}; + +#include /* Include file containing CLK_TCK. */ + +#define CLOCKS_PER_SEC (CLK_TCK) + +#include + +#ifndef _ANSI_SOURCE +extern char *tzname[]; +#endif + +__BEGIN_DECLS +char *asctime __P((const struct tm *)); +clock_t clock __P((void)); +char *ctime __P((const time_t *)); +double difftime __P((time_t, time_t)); +struct tm *gmtime __P((const time_t *)); +struct tm *localtime __P((const time_t *)); +time_t mktime __P((struct tm *)); +size_t strftime __P((char *, size_t, const char *, const struct tm *)); +time_t time __P((time_t *)); + +#ifndef _ANSI_SOURCE +void tzset __P((void)); +#endif /* not ANSI */ + +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) +char *asctime_r __P((const struct tm *, char *)); +char *ctime_r __P((const time_t *, char *)); +struct tm *gmtime_r __P((const time_t *, struct tm *)); +struct tm *localtime_r __P((const time_t *, struct tm *)); +char *strptime __P((const char *, const char *, struct tm *)); +char *timezone __P((int, int)); +void tzsetwall __P((void)); +time_t timelocal __P((struct tm * const)); +time_t timegm __P((struct tm * const)); +#endif /* neither ANSI nor POSIX */ + +#if !defined(_ANSI_SOURCE) +int nanosleep __P((const struct timespec *, struct timespec *)); +#endif +__END_DECLS + +#endif /* !_TIME_H_ */ diff --git a/include/ttyent.h b/include/ttyent.h new file mode 100644 index 0000000..25ace7f --- /dev/null +++ b/include/ttyent.h @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1989, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)ttyent.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _TTYENT_H_ +#define _TTYENT_H_ + +#define _PATH_TTYS "/etc/ttys" + +#define _TTYS_OFF "off" +#define _TTYS_ON "on" +#define _TTYS_SECURE "secure" +#define _TTYS_WINDOW "window" +#define _TTYS_ONERROR "onerror" +#define _TTYS_ONOPTION "onoption" + +struct ttyent { + char *ty_name; /* terminal device name */ + char *ty_getty; /* command to execute, usually getty */ + char *ty_type; /* terminal type for termcap */ +#define TTY_ON 0x01 /* enable logins (start ty_getty program) */ +#define TTY_SECURE 0x02 /* allow uid of 0 to login */ + int ty_status; /* status flags */ + char *ty_window; /* command to start up window manager */ + char *ty_onerror; /* command to execute after getty failure */ + char *ty_onoption; /* command to execute after console login */ + char *ty_comment; /* comment field */ +}; + +#include + +__BEGIN_DECLS +struct ttyent *getttyent __P((void)); +struct ttyent *getttynam __P((const char *)); +int setttyent __P((void)); +int endttyent __P((void)); +__END_DECLS + +#endif /* !_TTYENT_H_ */ diff --git a/include/tzfile.h b/include/tzfile.h new file mode 100644 index 0000000..53bc180 --- /dev/null +++ b/include/tzfile.h @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Arthur David Olson of the National Cancer Institute. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)tzfile.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _TZFILE_H_ +#define _TZFILE_H_ + +/* + * Information about time zone files. + */ + /* Time zone object file directory */ +#define TZDIR "/usr/share/zoneinfo" +#define TZDEFAULT "/etc/localtime" +#define TZDEFRULES "posixrules" + +/* +** Each file begins with. . . +*/ + +struct tzhead { + char tzh_reserved[24]; /* reserved for future use */ + char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */ + char tzh_leapcnt[4]; /* coded number of leap seconds */ + char tzh_timecnt[4]; /* coded number of transition times */ + char tzh_typecnt[4]; /* coded number of local time types */ + char tzh_charcnt[4]; /* coded number of abbr. chars */ +}; + +/* +** . . .followed by. . . +** +** tzh_timecnt (char [4])s coded transition times a la time(2) +** tzh_timecnt (unsigned char)s types of local time starting at above +** tzh_typecnt repetitions of +** one (char [4]) coded GMT offset in seconds +** one (unsigned char) used to set tm_isdst +** one (unsigned char) that's an abbreviation list index +** tzh_charcnt (char)s '\0'-terminated zone abbreviations +** tzh_leapcnt repetitions of +** one (char [4]) coded leap second transition times +** one (char [4]) total correction after above +** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition +** time is standard time, if FALSE, +** transition time is wall clock time +** if absent, transition times are +** assumed to be wall clock time +*/ + +/* +** In the current implementation, "tzset()" refuses to deal with files that +** exceed any of the limits below. +*/ + +/* +** The TZ_MAX_TIMES value below is enough to handle a bit more than a +** year's worth of solar time (corrected daily to the nearest second) or +** 138 years of Pacific Presidential Election time +** (where there are three time zone transitions every fourth year). +*/ +#define TZ_MAX_TIMES 370 + +#define NOSOLAR /* 4BSD doesn't currently handle solar time */ + +#ifndef NOSOLAR +#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */ +#else +#define TZ_MAX_TYPES 20 /* Maximum number of local time types */ +#endif + +#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */ + +#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */ + +#define SECSPERMIN 60 +#define MINSPERHOUR 60 +#define HOURSPERDAY 24 +#define DAYSPERWEEK 7 +#define DAYSPERNYEAR 365 +#define DAYSPERLYEAR 366 +#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR) +#define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY) +#define MONSPERYEAR 12 + +#define TM_SUNDAY 0 +#define TM_MONDAY 1 +#define TM_TUESDAY 2 +#define TM_WEDNESDAY 3 +#define TM_THURSDAY 4 +#define TM_FRIDAY 5 +#define TM_SATURDAY 6 + +#define TM_JANUARY 0 +#define TM_FEBRUARY 1 +#define TM_MARCH 2 +#define TM_APRIL 3 +#define TM_MAY 4 +#define TM_JUNE 5 +#define TM_JULY 6 +#define TM_AUGUST 7 +#define TM_SEPTEMBER 8 +#define TM_OCTOBER 9 +#define TM_NOVEMBER 10 +#define TM_DECEMBER 11 + +#define TM_YEAR_BASE 1900 + +#define EPOCH_YEAR 1970 +#define EPOCH_WDAY TM_THURSDAY + +/* +** Accurate only for the past couple of centuries; +** that will probably do. +*/ + +#define isleap(y) (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0) + +#endif /* !_TZFILE_H_ */ diff --git a/include/ucontext.h b/include/ucontext.h new file mode 100644 index 0000000..f658425 --- /dev/null +++ b/include/ucontext.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2002 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#ifndef _UCONTEXT_H_ +#define _UCONTEXT_H_ + +#include + +#endif /* _UCONTEXT_H_ */ diff --git a/include/ulimit.h b/include/ulimit.h new file mode 100644 index 0000000..55bb1a2 --- /dev/null +++ b/include/ulimit.h @@ -0,0 +1,9 @@ +#ifndef _ULIMIT_H +#define _ULIMIT_H + +#define UL_GETFSIZE 1 +#define UL_SETFSIZE 2 + +long int ulimit(int, ...); + +#endif /* _ULIMIT_H */ diff --git a/include/unistd.h b/include/unistd.h new file mode 100644 index 0000000..32f1c74 --- /dev/null +++ b/include/unistd.h @@ -0,0 +1,249 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/*- + * Copyright (c) 1998-1999 Apple Computer, Inc. All Rights Reserved + * Copyright (c) 1991, 1993, 1994 + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)unistd.h 8.12 (Berkeley) 4/27/95 + * + * Copyright (c) 1998 Apple Compter, Inc. + * All Rights Reserved + */ + +/* History: + 7/14/99 EKN at Apple fixed getdirentriesattr from getdirentryattr + 3/26/98 CHW at Apple added real interface to searchfs call + 3/5/98 CHW at Apple added hfs semantic system calls headers +*/ + +#ifndef _UNISTD_H_ +#define _UNISTD_H_ + +#include +#include +#include + +#define STDIN_FILENO 0 /* standard input file descriptor */ +#define STDOUT_FILENO 1 /* standard output file descriptor */ +#define STDERR_FILENO 2 /* standard error file descriptor */ + +#ifndef NULL +#define NULL 0 /* null pointer constant */ +#endif + +#define _POSIX_THREADS /* We support pthreads */ + +#ifndef _POSIX_SOURCE +#define F_ULOCK 0 /* unlock locked section */ +#define F_LOCK 1 /* lock a section for exclusive use */ +#define F_TLOCK 2 /* test and lock a section for exclusive use */ +#define F_TEST 3 /* test a section for locks by other procs */ +#endif + +__BEGIN_DECLS +__dead void + _exit __P((int)); +int access __P((const char *, int)); +unsigned int alarm __P((unsigned int)); +int chdir __P((const char *)); +int chown __P((const char *, uid_t, gid_t)); +int close __P((int)); +size_t confstr __P((int, char *, size_t)); +int dup __P((int)); +int dup2 __P((int, int)); +int execl __P((const char *, const char *, ...)); +int execle __P((const char *, const char *, ...)); +int execlp __P((const char *, const char *, ...)); +int execv __P((const char *, char * const *)); +int execve __P((const char *, char * const *, char * const *)); +int execvp __P((const char *, char * const *)); +pid_t fork __P((void)); +long fpathconf __P((int, int)); +char *getcwd __P((char *, size_t)); +gid_t getegid __P((void)); +uid_t geteuid __P((void)); +gid_t getgid __P((void)); +int getgroups __P((int, gid_t [])); +char *getlogin __P((void)); +pid_t getpgrp __P((void)); +pid_t getpid __P((void)); +pid_t getppid __P((void)); +uid_t getuid __P((void)); +int isatty __P((int)); +int link __P((const char *, const char *)); +off_t lseek __P((int, off_t, int)); +long pathconf __P((const char *, int)); +int pause __P((void)); +int pipe __P((int *)); +ssize_t read __P((int, void *, size_t)); +int rmdir __P((const char *)); +int setgid __P((gid_t)); +int setpgid __P((pid_t, pid_t)); +pid_t setsid __P((void)); +int setuid __P((uid_t)); +unsigned int sleep __P((unsigned int)); +long sysconf __P((int)); +pid_t tcgetpgrp __P((int)); +int tcsetpgrp __P((int, pid_t)); +char *ttyname __P((int)); +int unlink __P((const char *)); +ssize_t write __P((int, const void *, size_t)); + +extern char *optarg; /* getopt(3) external variables */ +extern int optind, opterr, optopt, optreset; +int getopt __P((int, char * const [], const char *)); + +#ifndef _POSIX_SOURCE +#ifdef __STDC__ +struct timeval; /* select(2) */ +#endif +int acct __P((const char *)); +int async_daemon __P((void)); +char *brk __P((const char *)); +int chroot __P((const char *)); +char *crypt __P((const char *, const char *)); +int des_cipher __P((const char *, char *, long, int)); +int des_setkey __P((const char *key)); +int encrypt __P((char *, int)); +void endusershell __P((void)); +int exect __P((const char *, char * const *, char * const *)); +int fchdir __P((int)); +int fchown __P((int, int, int)); +char *fflagstostr __P((u_long)); +int fsync __P((int)); +int ftruncate __P((int, off_t)); +int getdtablesize __P((void)); +int getgrouplist __P((const char *, int, int *, int *)); +long gethostid __P((void)); +int gethostname __P((char *, int)); +mode_t getmode __P((const void *, mode_t)); +__pure int + getpagesize __P((void)); +char *getpass __P((const char *)); +int getpgid __P((pid_t _pid)); +int getsid __P((pid_t _pid)); +char *getusershell __P((void)); +char *getwd __P((char *)); /* obsoleted by getcwd() */ +int initgroups __P((const char *, int)); +int iruserok __P((unsigned long, int, const char *, const char *)); +int issetugid __P((void)); +char *mkdtemp __P((char *)); +int mknod __P((const char *, mode_t, dev_t)); +int mkstemp __P((char *)); +int mkstemps __P((char *, int)); +char *mktemp __P((char *)); +int nfssvc __P((int, void *)); +int nice __P((int)); +ssize_t pread __P((int, void *, size_t, off_t)); +#if 0 +void psignal __P((unsigned int, const char *)); +extern __const char *__const sys_siglist[]; +#else +#include +#endif +int profil __P((char *, int, int, int)); +ssize_t pwrite __P((int, const void *, size_t, off_t)); +int rcmd __P((char **, int, const char *, + const char *, const char *, int *)); +char *re_comp __P((const char *)); +int re_exec __P((const char *)); +int readlink __P((const char *, char *, int)); +int reboot __P((int)); +int revoke __P((const char *)); +int rresvport __P((int *)); +int ruserok __P((const char *, int, const char *, const char *)); +char *sbrk __P((int)); +int select __P((int, fd_set *, fd_set *, fd_set *, struct timeval *)); +int setegid __P((gid_t)); +int seteuid __P((uid_t)); +int setgroups __P((int, const gid_t *)); +void sethostid __P((long)); +int sethostname __P((const char *, int)); +int setkey __P((const char *)); +int setlogin __P((const char *)); +void *setmode __P((const char *)); +int setpgrp __P((pid_t pid, pid_t pgrp)); /* obsoleted by setpgid() */ +int setregid __P((gid_t, gid_t)); +int setreuid __P((uid_t, uid_t)); +int setrgid __P((gid_t)); +int setruid __P((uid_t)); +void setusershell __P((void)); +int strtofflags __P((char **, u_long *, u_long *)); +int swapon __P((const char *)); +int symlink __P((const char *, const char *)); +void sync __P((void)); +int syscall __P((int, ...)); +int truncate __P((const char *, off_t)); +int ttyslot __P((void)); +unsigned int ualarm __P((unsigned int, unsigned int)); +int unwhiteout __P((const char *)); +int usleep __P((unsigned int)); +void *valloc __P((size_t)); +pid_t vfork __P((void)); + +extern char *suboptarg; /* getsubopt(3) external variable */ +int getsubopt __P((char **, char * const *, char **)); + +/* HFS & HFS Plus semantics system calls go here */ +int getattrlist __P((const char*,void*,void*,size_t,unsigned long)); +int setattrlist __P((const char*,void*,void*,size_t,unsigned long)); +int exchangedata __P((const char*,const char*,unsigned long)); +int checkuseraccess __P((const char*,uid_t,gid_t*,int,int,unsigned long)); +int getdirentriesattr __P((int,void*,void*,size_t,unsigned long*,unsigned long*,unsigned long*,unsigned long)); +int searchfs __P((const char*,void*,void*,unsigned long,unsigned long,void*)); + +int fsctl __P((const char *,unsigned long,void*,unsigned long)); + + +#endif /* !_POSIX_SOURCE */ +__END_DECLS + +#endif /* !_UNISTD_H_ */ diff --git a/include/util.h b/include/util.h new file mode 100644 index 0000000..42dbdab --- /dev/null +++ b/include/util.h @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* $NetBSD: util.h,v 1.10 1997/12/01 02:25:46 lukem Exp $ */ + +/*- + * Copyright (c) 1995 + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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 _UTIL_H_ +#define _UTIL_H_ + +#include +#include +#include +#include +#include +#include +#include + +#define PIDLOCK_NONBLOCK 1 +#define PIDLOCK_USEHOSTNAME 2 + +#define FPARSELN_UNESCESC 0x01 +#define FPARSELN_UNESCCONT 0x02 +#define FPARSELN_UNESCCOMM 0x04 +#define FPARSELN_UNESCREST 0x08 +#define FPARSELN_UNESCALL 0x0f + +__BEGIN_DECLS +void login __P((struct utmp *)); +int login_tty __P((int)); +int logout __P((const char *)); +void logwtmp __P((const char *, const char *, const char *)); +int pw_lock __P((int retries)); +int pw_mkdb __P((void)); +int pw_abort __P((void)); +void pw_init __P((void)); +void pw_edit __P((int notsetuid, const char *filename)); +void pw_prompt __P((void)); +void pw_copy __P((int ffd, int tfd, struct passwd *pw, + struct passwd *old_pw)); +int pw_scan __P((char *bp, struct passwd *pw, int *flags)); +void pw_error __P((const char *name, int err, int eval)); +int openpty __P((int *, int *, char *, struct termios *, + struct winsize *)); +char *fparseln __P((FILE *, size_t *, size_t *, const char[3], int)); +pid_t forkpty __P((int *, char *, struct termios *, struct winsize *)); +int getmaxpartitions __P((void)); +int getrawpartition __P((void)); +int opendisk __P((const char *, int, char *, size_t, int)); +int pidlock __P((const char *, int, pid_t *, const char *)); +int ttylock __P((const char *, int, pid_t *)); +int ttyunlock __P((const char *)); +int ttyaction __P((char *tty, char *act, char *user)); +struct iovec; +char *ttymsg __P((struct iovec *, int, const char *, int)); +__END_DECLS + +#endif /* !_UTIL_H_ */ diff --git a/stdio.subproj/remove.c b/include/utime.h similarity index 87% rename from stdio.subproj/remove.c rename to include/utime.h index f20237e..2326c06 100644 --- a/stdio.subproj/remove.c +++ b/include/utime.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -19,13 +19,10 @@ * * @APPLE_LICENSE_HEADER_END@ */ -/* +/*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -53,18 +50,22 @@ * 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. + * + * @(#)utime.h 8.1 (Berkeley) 6/2/93 */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)remove.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ +#ifndef _UTIME_H_ +#define _UTIME_H_ + +struct utimbuf { + time_t actime; /* Access time */ + time_t modtime; /* Modification time */ +}; + +#include -#include -#include +__BEGIN_DECLS +int utime __P((const char *, const struct utimbuf *)); +__END_DECLS -int -remove(file) - const char *file; -{ - return (unlink(file)); -} +#endif /* !_UTIME_H_ */ diff --git a/locale.subproj/lconv.c b/include/utmp.h similarity index 75% rename from locale.subproj/lconv.c rename to include/utmp.h index 786ca4a..0778052 100644 --- a/locale.subproj/lconv.c +++ b/include/utmp.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -20,8 +20,13 @@ * @APPLE_LICENSE_HEADER_END@ */ /* - * Copyright (c) 1991, 1993 + * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -50,39 +55,32 @@ * 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. + * + * @(#)utmp.h 8.2 (Berkeley) 1/21/94 */ +#ifndef _UTMP_H_ +#define _UTMP_H_ -#include -#include +#define _PATH_UTMP "/var/run/utmp" +#define _PATH_WTMP "/var/log/wtmp" +#define _PATH_LASTLOG "/var/log/lastlog" -static char empty[] = ""; +#define UT_NAMESIZE 8 +#define UT_LINESIZE 8 +#define UT_HOSTSIZE 16 -/* - * Default (C) locale conversion. - */ -static struct lconv C_lconv = { - ".", /* decimal_point */ - empty, /* thousands_sep */ - empty, /* grouping */ - empty, /* int_curr_symbol */ - empty, /* currency_symbol */ - empty, /* mon_decimal_point */ - empty, /* mon_thousands_sep */ - empty, /* mon_grouping */ - empty, /* positive_sign */ - empty, /* negative_sign */ - CHAR_MAX, /* int_frac_digits */ - CHAR_MAX, /* frac_digits */ - CHAR_MAX, /* p_cs_precedes */ - CHAR_MAX, /* p_sep_by_space */ - CHAR_MAX, /* n_cs_precedes */ - CHAR_MAX, /* n_sep_by_space */ - CHAR_MAX, /* p_sign_posn */ - CHAR_MAX, /* n_sign_posn */ +struct lastlog { + time_t ll_time; + char ll_line[UT_LINESIZE]; + char ll_host[UT_HOSTSIZE]; }; -/* - * Current locale conversion. - */ -struct lconv *__lconv = &C_lconv; +struct utmp { + char ut_line[UT_LINESIZE]; + char ut_name[UT_NAMESIZE]; + char ut_host[UT_HOSTSIZE]; + long ut_time; +}; + +#endif /* !_UTMP_H_ */ diff --git a/include/vis.h b/include/vis.h new file mode 100644 index 0000000..b9debf7 --- /dev/null +++ b/include/vis.h @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/*- + * Copyright (c) 1990, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)vis.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _VIS_H_ +#define _VIS_H_ + +/* + * to select alternate encoding format + */ +#define VIS_OCTAL 0x01 /* use octal \ddd format */ +#define VIS_CSTYLE 0x02 /* use \[nrft0..] where appropiate */ + +/* + * to alter set of characters encoded (default is to encode all + * non-graphic except space, tab, and newline). + */ +#define VIS_SP 0x04 /* also encode space */ +#define VIS_TAB 0x08 /* also encode tab */ +#define VIS_NL 0x10 /* also encode newline */ +#define VIS_WHITE (VIS_SP | VIS_TAB | VIS_NL) +#define VIS_SAFE 0x20 /* only encode "unsafe" characters */ + +/* + * other + */ +#define VIS_NOSLASH 0x40 /* inhibit printing '\' */ + +/* + * unvis return codes + */ +#define UNVIS_VALID 1 /* character valid */ +#define UNVIS_VALIDPUSH 2 /* character valid, push back passed char */ +#define UNVIS_NOCHAR 3 /* valid sequence, no character produced */ +#define UNVIS_SYNBAD -1 /* unrecognized escape sequence */ +#define UNVIS_ERROR -2 /* decoder in unknown state (unrecoverable) */ + +/* + * unvis flags + */ +#define UNVIS_END 1 /* no more characters */ + +#include + +__BEGIN_DECLS +char *vis __P((char *, int, int, int)); +int strvis __P((char *, const char *, int)); +int strvisx __P((char *, const char *, size_t, int)); +int strunvis __P((char *, const char *)); +int unvis __P((char *, int, int *, int)); +__END_DECLS + +#endif /* !_VIS_H_ */ diff --git a/internat.subproj/Makefile b/internat.subproj/Makefile deleted file mode 100644 index e1ea59d..0000000 --- a/internat.subproj/Makefile +++ /dev/null @@ -1,50 +0,0 @@ -# -# Generated by the NeXT Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = internat - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -HFILES = NXCType.h - -CFILES = NXCType.c NXIsAlNum.c NXIsAlpha.c NXIsAscii.c NXIsCntrl.c\ - NXIsDigit.c NXIsGraph.c NXIsLower.c NXIsPrint.c NXIsPunct.c\ - NXIsSpace.c NXIsUpper.c NXIsXDigit.c NXToAscii.c NXToLower.c\ - _NXToLower.c NXToUpper.c _NXToUpper.c - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble - - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - - - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/internat.subproj/Makefile.postamble b/internat.subproj/Makefile.postamble deleted file mode 100644 index df76c31..0000000 --- a/internat.subproj/Makefile.postamble +++ /dev/null @@ -1,5 +0,0 @@ -$(DSTROOT)$(PRIVATE_HDR_INSTALLDIR)$(MY_PRIVATE_HEADER_DIR_SUFFIX): - $(MKDIRS) $@ - -my_installhdrs: $(DSTROOT)$(PRIVATE_HDR_INSTALLDIR)$(MY_PRIVATE_HEADER_DIR_SUFFIX) - $(SILENT) $(FASTCP) $(MY_PRIVATE_HEADERS) $(DSTROOT)$(PRIVATE_HDR_INSTALLDIR)$(MY_PRIVATE_HEADER_DIR_SUFFIX) diff --git a/internat.subproj/Makefile.preamble b/internat.subproj/Makefile.preamble deleted file mode 100644 index ab01f68..0000000 --- a/internat.subproj/Makefile.preamble +++ /dev/null @@ -1,3 +0,0 @@ -MY_PRIVATE_HEADERS = NXCType.h -MY_PRIVATE_HEADER_DIR_SUFFIX = /objc -AFTER_INSTALLHDRS += my_installhdrs diff --git a/internat.subproj/PB.project b/internat.subproj/PB.project deleted file mode 100644 index 67c5990..0000000 --- a/internat.subproj/PB.project +++ /dev/null @@ -1,42 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - H_FILES = (NXCType.h); - OTHER_LINKED = ( - NXCType.c, - NXIsAlNum.c, - NXIsAlpha.c, - NXIsAscii.c, - NXIsCntrl.c, - NXIsDigit.c, - NXIsGraph.c, - NXIsLower.c, - NXIsPrint.c, - NXIsPunct.c, - NXIsSpace.c, - NXIsUpper.c, - NXIsXDigit.c, - NXToAscii.c, - NXToLower.c, - _NXToLower.c, - NXToUpper.c, - _NXToUpper.c - ); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble); - SUBPROJECTS = (); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = internat; - PROJECTTYPE = Component; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/internat/Makefile.inc b/internat/Makefile.inc new file mode 100644 index 0000000..2f3fdcc --- /dev/null +++ b/internat/Makefile.inc @@ -0,0 +1,6 @@ +.PATH: ${.CURDIR}/${MACHINE_ARCH}/internat ${.CURDIR}/internat + +SRCS += NXCType.c NXIsCntrl.c NXIsPrint.c NXIsXDigit.c _NXToLower.c \ + NXIsAlNum.c NXIsDigit.c NXIsPunct.c NXToAscii.c _NXToUpper.c \ + NXIsAlpha.c NXIsGraph.c NXIsSpace.c NXToLower.c \ + NXIsAscii.c NXIsLower.c NXIsUpper.c NXToUpper.c \ diff --git a/internat.subproj/NXCType.c b/internat/NXCType.c similarity index 100% rename from internat.subproj/NXCType.c rename to internat/NXCType.c diff --git a/internat.subproj/NXCType.h b/internat/NXCType.h similarity index 100% rename from internat.subproj/NXCType.h rename to internat/NXCType.h diff --git a/internat.subproj/NXIsAlNum.c b/internat/NXIsAlNum.c similarity index 100% rename from internat.subproj/NXIsAlNum.c rename to internat/NXIsAlNum.c diff --git a/internat.subproj/NXIsAlpha.c b/internat/NXIsAlpha.c similarity index 100% rename from internat.subproj/NXIsAlpha.c rename to internat/NXIsAlpha.c diff --git a/internat.subproj/NXIsAscii.c b/internat/NXIsAscii.c similarity index 100% rename from internat.subproj/NXIsAscii.c rename to internat/NXIsAscii.c diff --git a/internat.subproj/NXIsCntrl.c b/internat/NXIsCntrl.c similarity index 100% rename from internat.subproj/NXIsCntrl.c rename to internat/NXIsCntrl.c diff --git a/internat.subproj/NXIsDigit.c b/internat/NXIsDigit.c similarity index 100% rename from internat.subproj/NXIsDigit.c rename to internat/NXIsDigit.c diff --git a/internat.subproj/NXIsGraph.c b/internat/NXIsGraph.c similarity index 100% rename from internat.subproj/NXIsGraph.c rename to internat/NXIsGraph.c diff --git a/internat.subproj/NXIsLower.c b/internat/NXIsLower.c similarity index 100% rename from internat.subproj/NXIsLower.c rename to internat/NXIsLower.c diff --git a/internat.subproj/NXIsPrint.c b/internat/NXIsPrint.c similarity index 100% rename from internat.subproj/NXIsPrint.c rename to internat/NXIsPrint.c diff --git a/internat.subproj/NXIsPunct.c b/internat/NXIsPunct.c similarity index 100% rename from internat.subproj/NXIsPunct.c rename to internat/NXIsPunct.c diff --git a/internat.subproj/NXIsSpace.c b/internat/NXIsSpace.c similarity index 100% rename from internat.subproj/NXIsSpace.c rename to internat/NXIsSpace.c diff --git a/internat.subproj/NXIsUpper.c b/internat/NXIsUpper.c similarity index 100% rename from internat.subproj/NXIsUpper.c rename to internat/NXIsUpper.c diff --git a/internat.subproj/NXIsXDigit.c b/internat/NXIsXDigit.c similarity index 100% rename from internat.subproj/NXIsXDigit.c rename to internat/NXIsXDigit.c diff --git a/internat.subproj/NXToAscii.c b/internat/NXToAscii.c similarity index 100% rename from internat.subproj/NXToAscii.c rename to internat/NXToAscii.c diff --git a/internat.subproj/NXToLower.c b/internat/NXToLower.c similarity index 100% rename from internat.subproj/NXToLower.c rename to internat/NXToLower.c diff --git a/internat.subproj/NXToUpper.c b/internat/NXToUpper.c similarity index 100% rename from internat.subproj/NXToUpper.c rename to internat/NXToUpper.c diff --git a/internat.subproj/_NXToLower.c b/internat/_NXToLower.c similarity index 100% rename from internat.subproj/_NXToLower.c rename to internat/_NXToLower.c diff --git a/internat.subproj/_NXToUpper.c b/internat/_NXToUpper.c similarity index 100% rename from internat.subproj/_NXToUpper.c rename to internat/_NXToUpper.c diff --git a/locale.subproj/Makefile b/locale.subproj/Makefile deleted file mode 100644 index f126176..0000000 --- a/locale.subproj/Makefile +++ /dev/null @@ -1,46 +0,0 @@ -# -# Generated by the NeXT Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = locale - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -CFILES = ansi.c ctype.c euc.c frune.c isctype.c lconv.c localeconv.c\ - mbrune.c none.c rune.c runetable.c setlocale.c utf2.c - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble - - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - - - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/locale.subproj/Makefile.postamble b/locale.subproj/Makefile.postamble deleted file mode 100644 index 411cde6..0000000 --- a/locale.subproj/Makefile.postamble +++ /dev/null @@ -1,100 +0,0 @@ -############################################################################### -# Makefile.postamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile, which is imported after all other makefiles, to -# override attributes for a project's Makefile environment. This allows you -# to take advantage of the environment set up by the other Makefiles. -# You can also define custom rules at the end of this file. -# -############################################################################### -# -# These variables are exported by the standard makefiles and can be -# used in any customizations you make. They are *outputs* of -# the Makefiles and should be used, not set. -# -# PRODUCTS: products to install. All of these products will be placed in -# the directory $(DSTROOT)$(INSTALLDIR) -# GLOBAL_RESOURCE_DIR: The directory to which resources are copied. -# LOCAL_RESOURCE_DIR: The directory to which localized resources are copied. -# OFILE_DIR: Directory into which .o object files are generated. -# DERIVED_SRC_DIR: Directory used for all other derived files -# -# ALL_CFLAGS: flags to pass when compiling .c files -# ALL_MFLAGS: flags to pass when compiling .m files -# ALL_CCFLAGS: flags to pass when compiling .cc, .cxx, and .C files -# ALL_MMFLAGS: flags to pass when compiling .mm, .mxx, and .M files -# ALL_PRECOMPFLAGS: flags to pass when precompiling .h files -# ALL_LDFLAGS: flags to pass when linking object files -# ALL_LIBTOOL_FLAGS: flags to pass when libtooling object files -# ALL_PSWFLAGS: flags to pass when processing .psw and .pswm (pswrap) files -# ALL_RPCFLAGS: flags to pass when processing .rpc (rpcgen) files -# ALL_YFLAGS: flags to pass when processing .y (yacc) files -# ALL_LFLAGS: flags to pass when processing .l (lex) files -# -# NAME: name of application, bundle, subproject, palette, etc. -# LANGUAGES: langages in which the project is written (default "English") -# English_RESOURCES: localized resources (e.g. nib's, images) of project -# GLOBAL_RESOURCES: non-localized resources of project -# -# SRCROOT: base directory in which to place the new source files -# SRCPATH: relative path from SRCROOT to present subdirectory -# -# INSTALLDIR: Directory the product will be installed into by 'install' target -# PUBLIC_HDR_INSTALLDIR: where to install public headers. Don't forget -# to prefix this with DSTROOT when you use it. -# PRIVATE_HDR_INSTALLDIR: where to install private headers. Don't forget -# to prefix this with DSTROOT when you use it. -# -# EXECUTABLE_EXT: Executable extension for the platform (i.e. .exe on Windows) -# -############################################################################### - -# Some compiler flags can be overridden here for certain build situations. -# -# WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost) -# DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults -# to -g) -# DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG) -# OPTIMIZE_BUILD_CFLAGS: flags passed during optimized builds (defaults -# to -O) -# PROFILE_BUILD_CFLAGS: flags passed during profile builds (defaults -# to -pg -DPROFILE) -# LOCAL_DIR_INCLUDE_DIRECTIVE: flag used to add current directory to -# the include path (defaults to -I.) -# DEBUG_BUILD_LDFLAGS, OPTIMIZE_BUILD_LDFLAGS, PROFILE_BUILD_LDFLAGS: flags -# passed to ld/libtool (defaults to nothing) - - -# Library and Framework projects only: -# INSTALL_NAME_DIRECTIVE: This directive ensures that executables linked -# against the framework will run against the correct version even if -# the current version of the framework changes. You may override this -# to "" as an alternative to using the DYLD_LIBRARY_PATH during your -# development cycle, but be sure to restore it before installing. - - -# Ownership and permissions of files installed by 'install' target - -#INSTALL_AS_USER = root - # User/group ownership -#INSTALL_AS_GROUP = wheel - # (probably want to set both of these) -#INSTALL_PERMISSIONS = - # If set, 'install' chmod's executable to this - - -# Options to strip. Note: -S strips debugging symbols (executables can be stripped -# down further with -x or, if they load no bundles, with no options at all). - -#STRIPFLAGS = -S - - -######################################################################### -# Put rules to extend the behavior of the standard Makefiles here. Include them in -# the dependency tree via cvariables like AFTER_INSTALL in the Makefile.preamble. -# -# You should avoid redefining things like "install" or "app", as they are -# owned by the top-level Makefile API and no context has been set up for where -# derived files should go. -# diff --git a/locale.subproj/Makefile.preamble b/locale.subproj/Makefile.preamble deleted file mode 100644 index c1624b4..0000000 --- a/locale.subproj/Makefile.preamble +++ /dev/null @@ -1,137 +0,0 @@ -############################################################################### -# Makefile.preamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile for configuring the standard application makefiles -# associated with ProjectBuilder. It is included before the main makefile. -# In Makefile.preamble you set attributes for a project, so they are available -# to the project's makefiles. In contrast, you typically write additional rules or -# override built-in behavior in the Makefile.postamble. -# -# Each directory in a project tree (main project plus subprojects) should -# have its own Makefile.preamble and Makefile.postamble. -############################################################################### -# -# Before the main makefile is included for this project, you may set: -# -# MAKEFILEDIR: Directory in which to find $(MAKEFILE) -# MAKEFILE: Top level mechanism Makefile (e.g., app.make, bundle.make) - -# Compiler/linker flags added to the defaults: The OTHER_* variables will be -# inherited by all nested sub-projects, but the LOCAL_ versions of the same -# variables will not. Put your -I, -D, -U, and -L flags in ProjectBuilder's -# Build Attributes inspector if at all possible. To override the default flags -# that get passed to ${CC} (e.g. change -O to -O2), see Makefile.postamble. The -# variables below are *inputs* to the build process and distinct from the override -# settings done (less often) in the Makefile.postamble. -# -# OTHER_CFLAGS, LOCAL_CFLAGS: additional flags to pass to the compiler -# Note that $(OTHER_CFLAGS) and $(LOCAL_CFLAGS) are used for .h, ...c, .m, -# .cc, .cxx, .C, and .M files. There is no need to respecify the -# flags in OTHER_MFLAGS, etc. -# OTHER_MFLAGS, LOCAL_MFLAGS: additional flags for .m files -# OTHER_CCFLAGS, LOCAL_CCFLAGS: additional flags for .cc, .cxx, and ...C files -# OTHER_MMFLAGS, LOCAL_MMFLAGS: additional flags for .mm and .M files -# OTHER_PRECOMPFLAGS, LOCAL_PRECOMPFLAGS: additional flags used when -# precompiling header files -# OTHER_LDFLAGS, LOCAL_LDFLAGS: additional flags passed to ld and libtool -# OTHER_PSWFLAGS, LOCAL_PSWFLAGS: additional flags passed to pswrap -# OTHER_RPCFLAGS, LOCAL_RPCFLAGS: additional flags passed to rpcgen -# OTHER_YFLAGS, LOCAL_YFLAGS: additional flags passed to yacc -# OTHER_LFLAGS, LOCAL_LFLAGS: additional flags passed to lex - -# These variables provide hooks enabling you to add behavior at almost every -# stage of the make: -# -# BEFORE_PREBUILD: targets to build before installing headers for a subproject -# AFTER_PREBUILD: targets to build after installing headers for a subproject -# BEFORE_BUILD_RECURSION: targets to make before building subprojects -# BEFORE_BUILD: targets to make before a build, but after subprojects -# AFTER_BUILD: targets to make after a build -# -# BEFORE_INSTALL: targets to build before installing the product -# AFTER_INSTALL: targets to build after installing the product -# BEFORE_POSTINSTALL: targets to build before postinstalling every subproject -# AFTER_POSTINSTALL: targts to build after postinstalling every subproject -# -# BEFORE_INSTALLHDRS: targets to build before installing headers for a -# subproject -# AFTER_INSTALLHDRS: targets to build after installing headers for a subproject -# BEFORE_INSTALLSRC: targets to build before installing source for a subproject -# AFTER_INSTALLSRC: targets to build after installing source for a subproject -# -# BEFORE_DEPEND: targets to build before building dependencies for a -# subproject -# AFTER_DEPEND: targets to build after building dependencies for a -# subproject -# -# AUTOMATIC_DEPENDENCY_INFO: if YES, then the dependency file is -# updated every time the project is built. If NO, the dependency -# file is only built when the depend target is invoked. - -# Framework-related variables: -# FRAMEWORK_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the framework's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables - -# Library-related variables: -# PUBLIC_HEADER_DIR: Determines where public exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. For library projects you should -# set this to something like /Developer/Headers/$(NAME). Do not set -# this variable for framework projects unless you do not want the -# header files included in the framework. -# PRIVATE_HEADER_DIR: Determines where private exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. -# LIBRARY_STYLE: This may be either STATIC or DYNAMIC, and determines -# whether the libraries produced are statically linked when they -# are used or if they are dynamically loadable. This defaults to -# DYNAMIC. -# LIBRARY_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the library's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables -# -# INSTALL_AS_USER: owner of the intalled products (default root) -# INSTALL_AS_GROUP: group of the installed products (default wheel) -# INSTALL_PERMISSIONS: permissions of the installed product (default o+rX) -# -# OTHER_RECURSIVE_VARIABLES: The names of variables which you want to be -# passed on the command line to recursive invocations of make. Note that -# the values in OTHER_*FLAGS are inherited by subprojects automatically -- -# you do not have to (and shouldn't) add OTHER_*FLAGS to -# OTHER_RECURSIVE_VARIABLES. - -# Additional headers to export beyond those in the PB.project: -# OTHER_PUBLIC_HEADERS -# OTHER_PROJECT_HEADERS -# OTHER_PRIVATE_HEADERS - -# Additional files for the project's product: <> -# OTHER_RESOURCES: (non-localized) resources for this project -# OTHER_OFILES: relocatables to be linked into this project -# OTHER_LIBS: more libraries to link against -# OTHER_PRODUCT_DEPENDS: other dependencies of this project -# OTHER_SOURCEFILES: other source files maintained by .pre/postamble -# OTHER_GARBAGE: additional files to be removed by `make clean' - -# Set this to YES if you don't want a final libtool call for a library/framework. -# BUILD_OFILES_LIST_ONLY - -# To include a version string, project source must exist in a directory named -# $(NAME).%d[.%d][.%d] and the following line must be uncommented. -# OTHER_GENERATED_OFILES = $(VERS_OFILE) - -# This definition will suppress stripping of debug symbols when an executable -# is installed. By default it is YES. -# STRIP_ON_INSTALL = NO - -# Uncomment to suppress generation of a KeyValueCoding index when installing -# frameworks (This index is used by WOB and IB to determine keys available -# for an object). Set to YES by default. -# PREINDEX_FRAMEWORK = NO - -# Change this definition to install projects somewhere other than the -# standard locations. NEXT_ROOT defaults to "C:/Apple" on Windows systems -# and "" on other systems. -DSTROOT = $(HOME) diff --git a/locale.subproj/PB.project b/locale.subproj/PB.project deleted file mode 100644 index 25515a8..0000000 --- a/locale.subproj/PB.project +++ /dev/null @@ -1,37 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - H_FILES = (); - OTHER_LINKED = ( - ansi.c, - ctype.c, - euc.c, - frune.c, - isctype.c, - lconv.c, - localeconv.c, - mbrune.c, - none.c, - rune.c, - runetable.c, - setlocale.c, - utf2.c - ); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble); - SUBPROJECTS = (); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = locale; - PROJECTTYPE = Component; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/locale.subproj/setlocale.c b/locale.subproj/setlocale.c deleted file mode 100644 index 7dc8b93..0000000 --- a/locale.subproj/setlocale.c +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ -/* - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. 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. - */ - - -#include -#include -#include -#include -#include - -/* - * Category names for getenv() - */ -static char *categories[_LC_LAST] = { - "LC_ALL", - "LC_COLLATE", - "LC_CTYPE", - "LC_MONETARY", - "LC_NUMERIC", - "LC_TIME", -}; - -/* - * Current locales for each category - */ -static char current_categories[_LC_LAST][32] = { - "C", - "C", - "C", - "C", - "C", - "C", -}; - -/* - * The locales we are going to try and load - */ -static char new_categories[_LC_LAST][32]; - -static char current_locale_string[_LC_LAST * 33]; -static char *PathLocale; - -static char *currentlocale __P((void)); -static char *loadlocale __P((int)); - -char * -setlocale(category, locale) - int category; - const char *locale; -{ - int found, i, len; - char *env, *r; - - if (!PathLocale) - PathLocale = _PATH_LOCALE; - - if (category < 0 || category >= _LC_LAST) - return (NULL); - - if (!locale) - return (category ? - current_categories[category] : currentlocale()); - - /* - * Default to the current locale for everything. - */ - for (i = 1; i < _LC_LAST; ++i) - (void)strcpy(new_categories[i], current_categories[i]); - - /* - * Now go fill up new_categories from the locale argument - */ - if (!*locale) { - env = getenv(categories[category]); - - if (!env) - env = getenv(categories[0]); - - if (!env) - env = getenv("LANG"); - - if (!env) - env = "C"; - - (void) strncpy(new_categories[category], env, 31); - new_categories[category][31] = 0; - if (!category) { - for (i = 1; i < _LC_LAST; ++i) { - if (!(env = getenv(categories[i]))) - env = new_categories[0]; - (void)strncpy(new_categories[i], env, 31); - new_categories[i][31] = 0; - } - } - } else if (category) { - (void)strncpy(new_categories[category], locale, 31); - new_categories[category][31] = 0; - } else { - if ((r = strchr(locale, '/')) == 0) { - for (i = 1; i < _LC_LAST; ++i) { - (void)strncpy(new_categories[i], locale, 31); - new_categories[i][31] = 0; - } - } else { - for (i = 1; r[1] == '/'; ++r); - if (!r[1]) - return (NULL); /* Hmm, just slashes... */ - do { - len = r - locale > 31 ? 31 : r - locale; - (void)strncpy(new_categories[i++], locale, len); - new_categories[i++][len] = 0; - locale = r; - while (*locale == '/') - ++locale; - while (*++r && *r != '/'); - } while (*locale); - while (i < _LC_LAST) - (void)strcpy(new_categories[i], - new_categories[i-1]); - } - } - - if (category) - return (loadlocale(category)); - - found = 0; - for (i = 1; i < _LC_LAST; ++i) - if (loadlocale(i) != NULL) - found = 1; - if (found) - return (currentlocale()); - return (NULL); -} - -static char * -currentlocale() -{ - int i; - - (void)strcpy(current_locale_string, current_categories[1]); - - for (i = 2; i < _LC_LAST; ++i) - if (strcmp(current_categories[1], current_categories[i])) { - (void)snprintf(current_locale_string, - sizeof(current_locale_string), "%s/%s/%s/%s/%s", - current_categories[1], current_categories[2], - current_categories[3], current_categories[4], - current_categories[5]); - break; - } - return (current_locale_string); -} - -static char * -loadlocale(category) - int category; -{ - char name[PATH_MAX]; - - if (strcmp(new_categories[category], - current_categories[category]) == 0) - return (current_categories[category]); - - if (category == LC_CTYPE) { - if (setrunelocale(new_categories[LC_CTYPE])) - return (NULL); - (void)strcpy(current_categories[LC_CTYPE], - new_categories[LC_CTYPE]); - return (current_categories[LC_CTYPE]); - } - - if (!strcmp(new_categories[category], "C") || - !strcmp(new_categories[category], "POSIX")) { - - /* - * Some day this will need to reset the locale to the default - * C locale. Since we have no way to change them as of yet, - * there is no need to reset them. - */ - (void)strcpy(current_categories[category], - new_categories[category]); - return (current_categories[category]); - } - - /* - * Some day we will actually look at this file. - */ - (void)snprintf(name, sizeof(name), "%s/%s/%s", - PathLocale, new_categories[category], categories[category]); - - switch (category) { - case LC_COLLATE: - case LC_MONETARY: - case LC_NUMERIC: - case LC_TIME: - return (NULL); - } -} diff --git a/locale/Makefile.inc b/locale/Makefile.inc new file mode 100644 index 0000000..f5c3b13 --- /dev/null +++ b/locale/Makefile.inc @@ -0,0 +1,26 @@ +# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 +# $FreeBSD: src/lib/libc/locale/Makefile.inc,v 1.20 2001/05/03 15:12:52 phantom Exp $ + +# locale sources +.PATH: ${.CURDIR}/${MACHINE_ARCH}/locale ${.CURDIR}/locale + +SRCS+= ansi.c big5.c collate.c collcmp.c euc.c frune.c isctype.c \ + lconv.c localeconv.c mbrune.c mskanji.c nomacros.c none.c rune.c \ + runetype.c setinvalidrune.c setlocale.c setrunelocale.c table.c \ + tolower.c toupper.c utf2.c + +.if ${LIB} == "c" +MAN3+= ctype.3 isalnum.3 isalpha.3 isascii.3 isblank.3 iscntrl.3 \ + isdigit.3 isgraph.3 islower.3 isprint.3 ispunct.3 isspace.3 \ + isupper.3 isxdigit.3 mbrune.3 multibyte.3 nl_langinfo.3 rune.3 \ + setlocale.3 toascii.3 tolower.3 toupper.3 +MAN4+= euc.4 utf2.4 + +MLINKS+=mbrune.3 mbmb.3 mbrune.3 mbrrune.3 +MLINKS+=multibyte.3 mblen.3 multibyte.3 mbstowcs.3 multibyte.3 mbtowc.3 \ + multibyte.3 wcstombs.3 multibyte.3 wctomb.3 +MLINKS+=rune.3 fgetrune.3 rune.3 fputrune.3 rune.3 fungetrune.3 \ + rune.3 setinvalidrune.3 rune.3 setrunelocale.3 rune.3 sgetrune.3 \ + rune.3 sputrune.3 +MLINKS+=setlocale.3 localeconv.3 +.endif diff --git a/locale.subproj/ansi.c b/locale/ansi.c similarity index 74% rename from locale.subproj/ansi.c rename to locale/ansi.c index cba06a3..c0871fe 100644 --- a/locale.subproj/ansi.c +++ b/locale/ansi.c @@ -1,25 +1,4 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ -/* +/*- * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * @@ -55,6 +34,9 @@ * SUCH DAMAGE. */ +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)ansi.c 8.1 (Berkeley) 6/27/93"; +#endif /* LIBC_SCCS and not lint */ #include #include @@ -71,7 +53,7 @@ mblen(s, n) if (s == 0 || *s == 0) return (0); /* No support for state dependent encodings. */ - if (sgetrune(s, (int)n, &e) == _INVALID_RUNE) + if (sgetrune(s, n, &e) == _INVALID_RUNE) return (s - e); return (e - s); } @@ -88,7 +70,7 @@ mbtowc(pwc, s, n) if (s == 0 || *s == 0) return (0); /* No support for state dependent encodings. */ - if ((r = sgetrune(s, (int)n, &e)) == _INVALID_RUNE) + if ((r = sgetrune(s, n, &e)) == _INVALID_RUNE) return (s - e); if (pwc) *pwc = r; @@ -145,21 +127,24 @@ wcstombs(s, pwcs, n) size_t n; { char *e; - int cnt = 0; + int cnt, nb; - if (!pwcs || !s) + if (!pwcs || !s || n > INT_MAX) return (-1); - while (n > 0) { + nb = n; + cnt = 0; + while (nb > 0) { if (*pwcs == 0) { *s = 0; break; } - if (!sputrune(*pwcs++, s, (int)n, &e)) + if (!sputrune(*pwcs++, s, nb, &e)) return (-1); /* encoding error */ if (!e) /* too long */ return (cnt); cnt += e - s; + nb -= e - s; s = e; } return (cnt); diff --git a/locale/big5.c b/locale/big5.c new file mode 100644 index 0000000..87e2fd8 --- /dev/null +++ b/locale/big5.c @@ -0,0 +1,119 @@ +/*- + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Paul Borman at Krystal Technologies. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * $FreeBSD: src/lib/libc/locale/big5.c,v 1.3.2.2 2001/03/05 10:02:54 obrien Exp $ + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)big5.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include +#include +#include + +rune_t _BIG5_sgetrune __P((const char *, size_t, char const **)); +int _BIG5_sputrune __P((rune_t, char *, size_t, char **)); + +int +_BIG5_init(rl) + _RuneLocale *rl; +{ + rl->sgetrune = _BIG5_sgetrune; + rl->sputrune = _BIG5_sputrune; + _CurrentRuneLocale = rl; + __mb_cur_max = 2; + return (0); +} + +static inline int +_big5_check(c) + u_int c; +{ + c &= 0xff; + return ((c >= 0xa1 && c <= 0xfe) ? 2 : 1); +} + +rune_t +_BIG5_sgetrune(string, n, result) + const char *string; + size_t n; + char const **result; +{ + rune_t rune = 0; + int len; + + if (n < 1 || (len = _big5_check(*string)) > n) { + if (result) + *result = string; + return (_INVALID_RUNE); + } + while (--len >= 0) + rune = (rune << 8) | ((u_int)(*string++) & 0xff); + if (result) + *result = string; + return rune; +} + +int +_BIG5_sputrune(c, string, n, result) + rune_t c; + char *string, **result; + size_t n; +{ + if (c & 0x8000) { + if (n >= 2) { + string[0] = (c >> 8) & 0xff; + string[1] = c & 0xff; + if (result) + *result = string + 2; + return (2); + } + } + else { + if (n >= 1) { + *string = c & 0xff; + if (result) + *result = string + 1; + return (1); + } + } + if (result) + *result = string; + return (0); + +} diff --git a/locale/collate.c b/locale/collate.c new file mode 100644 index 0000000..5ef2ebb --- /dev/null +++ b/locale/collate.c @@ -0,0 +1,212 @@ +/*- + * Copyright (c) 1995 Alex Tatmanjants + * at Electronni Visti IA, Kiev, Ukraine. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/lib/libc/locale/collate.c,v 1.21.2.1 2001/03/05 10:10:22 obrien Exp $ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "collate.h" +#include "setlocale.h" + +int __collate_load_error = 1; +int __collate_substitute_nontrivial; +char __collate_version[STR_LEN]; +u_char __collate_substitute_table[UCHAR_MAX + 1][STR_LEN]; +struct __collate_st_char_pri __collate_char_pri_table[UCHAR_MAX + 1]; +struct __collate_st_chain_pri __collate_chain_pri_table[TABLE_SIZE]; + +#define FREAD(a, b, c, d) \ + do { \ + if (fread(a, b, c, d) != c) { \ + fclose(d); \ + return -1; \ + } \ + } while(0) + +void __collate_err(int ex, const char *f) ; + +int +__collate_load_tables(encoding) + char *encoding; +{ + char buf[PATH_MAX]; + FILE *fp; + int i, save_load_error; + + save_load_error = __collate_load_error; + __collate_load_error = 1; + if (!encoding) { + __collate_load_error = save_load_error; + return -1; + } + if (!strcmp(encoding, "C") || !strcmp(encoding, "POSIX")) + return 0; + if (!_PathLocale) { + __collate_load_error = save_load_error; + return -1; + } + /* Range checking not needed, encoding has fixed size */ + (void) strcpy(buf, _PathLocale); + (void) strcat(buf, "/"); + (void) strcat(buf, encoding); + (void) strcat(buf, "/LC_COLLATE"); + if ((fp = fopen(buf, "r")) == NULL) { + __collate_load_error = save_load_error; + return -1; + } + FREAD(__collate_version, sizeof(__collate_version), 1, fp); + if (strcmp(__collate_version, COLLATE_VERSION) != 0) { + fclose(fp); + return -1; + } + FREAD(__collate_substitute_table, sizeof(__collate_substitute_table), + 1, fp); + FREAD(__collate_char_pri_table, sizeof(__collate_char_pri_table), 1, + fp); + FREAD(__collate_chain_pri_table, sizeof(__collate_chain_pri_table), 1, + fp); + fclose(fp); + __collate_load_error = 0; + + __collate_substitute_nontrivial = 0; + for (i = 0; i < UCHAR_MAX + 1; i++) { + if (__collate_substitute_table[i][0] != i || + __collate_substitute_table[i][1] != 0) { + __collate_substitute_nontrivial = 1; + break; + } + } + + return 0; +} + +u_char * +__collate_substitute(s) + const u_char *s; +{ + int dest_len, len, nlen; + int delta = strlen(s); + u_char *dest_str = NULL; + + if(s == NULL || *s == '\0') + return __collate_strdup(""); + delta += delta / 8; + dest_str = malloc(dest_len = delta); + if(dest_str == NULL) + __collate_err(EX_OSERR, __FUNCTION__); + len = 0; + while(*s) { + nlen = len + strlen(__collate_substitute_table[*s]); + if (dest_len <= nlen) { + dest_str = reallocf(dest_str, dest_len = nlen + delta); + if(dest_str == NULL) + __collate_err(EX_OSERR, __FUNCTION__); + } + strcpy(dest_str + len, __collate_substitute_table[*s++]); + len = nlen; + } + return dest_str; +} + +void +__collate_lookup(t, len, prim, sec) + const u_char *t; + int *len, *prim, *sec; +{ + struct __collate_st_chain_pri *p2; + + *len = 1; + *prim = *sec = 0; + for(p2 = __collate_chain_pri_table; p2->str[0]; p2++) { + if(strncmp(t, p2->str, strlen(p2->str)) == 0) { + *len = strlen(p2->str); + *prim = p2->prim; + *sec = p2->sec; + return; + } + } + *prim = __collate_char_pri_table[*t].prim; + *sec = __collate_char_pri_table[*t].sec; +} + +u_char * +__collate_strdup(s) + u_char *s; +{ + u_char *t = strdup(s); + + if (t == NULL) + __collate_err(EX_OSERR, __FUNCTION__); + return t; +} + +void +__collate_err(int ex, const char *f) +{ + char **__progname = _NSGetProgname(); + const char *s; + int serrno = errno; + + s = *__progname; + write(STDERR_FILENO, s, strlen(s)); + write(STDERR_FILENO, ": ", 2); + s = f; + write(STDERR_FILENO, s, strlen(s)); + write(STDERR_FILENO, ": ", 2); + s = strerror(serrno); + write(STDERR_FILENO, s, strlen(s)); + write(STDERR_FILENO, "\n", 1); + exit(ex); +} + +#ifdef COLLATE_DEBUG +void +__collate_print_tables() +{ + int i; + struct __collate_st_chain_pri *p2; + + printf("Substitute table:\n"); + for (i = 0; i < UCHAR_MAX + 1; i++) + if (i != *__collate_substitute_table[i]) + printf("\t'%c' --> \"%s\"\n", i, + __collate_substitute_table[i]); + printf("Chain priority table:\n"); + for (p2 = __collate_chain_pri_table; p2->str[0]; p2++) + printf("\t\"%s\" : %d %d\n\n", p2->str, p2->prim, p2->sec); + printf("Char priority table:\n"); + for (i = 0; i < UCHAR_MAX + 1; i++) + printf("\t'%c' : %d %d\n", i, __collate_char_pri_table[i].prim, + __collate_char_pri_table[i].sec); +} +#endif diff --git a/locale/collate.h b/locale/collate.h new file mode 100644 index 0000000..97d9c5b --- /dev/null +++ b/locale/collate.h @@ -0,0 +1,67 @@ +/*- + * Copyright (c) 1995 Alex Tatmanjants + * at Electronni Visti IA, Kiev, Ukraine. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/lib/libc/locale/collate.h,v 1.9 1999/09/12 21:15:14 dt Exp $ + */ + +#ifndef COLLATE_H_INCLUDED +#define COLLATE_H_INCLUDED + +#include +#include +#include + +#define STR_LEN 10 +#define TABLE_SIZE 100 +#define COLLATE_VERSION "1.0\n" + +struct __collate_st_char_pri { + int prim, sec; +}; +struct __collate_st_chain_pri { + u_char str[STR_LEN]; + int prim, sec; +}; + +extern int __collate_load_error; +extern int __collate_substitute_nontrivial; +extern char __collate_version[STR_LEN]; +extern u_char __collate_substitute_table[UCHAR_MAX + 1][STR_LEN]; +extern struct __collate_st_char_pri __collate_char_pri_table[UCHAR_MAX + 1]; +extern struct __collate_st_chain_pri __collate_chain_pri_table[TABLE_SIZE]; + +__BEGIN_DECLS +u_char *__collate_strdup __P((u_char *)); +u_char *__collate_substitute __P((const u_char *)); +int __collate_load_tables __P((char *)); +void __collate_lookup __P((const u_char *, int *, int *, int *)); +int __collate_range_cmp __P((int, int)); +#ifdef COLLATE_DEBUG +void __collate_print_tables __P((void)); +#endif +__END_DECLS + +#endif /* not COLLATE_H_INCLUDED */ diff --git a/locale/collcmp.c b/locale/collcmp.c new file mode 100644 index 0000000..b1e8e0a --- /dev/null +++ b/locale/collcmp.c @@ -0,0 +1,84 @@ +/* + * Copyright (C) 1996 by Andrey A. Chernov, Moscow, Russia. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE 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. + * + * $FreeBSD: src/lib/libc/locale/collcmp.c,v 1.12.2.1 2000/08/22 01:54:39 jhb Exp $ + */ + +#define ASCII_COMPATIBLE_COLLATE /* see share/colldef */ + +#include +#include "collate.h" +#ifndef ASCII_COMPATIBLE_COLLATE +#include +#endif + +/* + * Compare two characters converting collate information + * into ASCII-compatible range, it allows to handle + * "[a-z]"-type ranges with national characters. + */ + +int __collate_range_cmp (c1, c2) + int c1, c2; +{ + static char s1[2], s2[2]; + int ret; +#ifndef ASCII_COMPATIBLE_COLLATE + int as1, as2, al1, al2; +#endif + + c1 &= UCHAR_MAX; + c2 &= UCHAR_MAX; + if (c1 == c2) + return (0); + +#ifndef ASCII_COMPATIBLE_COLLATE + as1 = isascii(c1); + as2 = isascii(c2); + al1 = isalpha(c1); + al2 = isalpha(c2); + + if (as1 || as2 || al1 || al2) { + if ((as1 && as2) || (!al1 && !al2)) + return (c1 - c2); + if (al1 && !al2) { + if (isupper(c1)) + return ('A' - c2); + else + return ('a' - c2); + } else if (al2 && !al1) { + if (isupper(c2)) + return (c1 - 'A'); + else + return (c1 - 'a'); + } + } +#endif + s1[0] = c1; + s2[0] = c2; + if ((ret = strcoll(s1, s2)) != 0) + return (ret); + return (c1 - c2); +} diff --git a/locale/ctype.3 b/locale/ctype.3 new file mode 100644 index 0000000..f946e12 --- /dev/null +++ b/locale/ctype.3 @@ -0,0 +1,147 @@ +.\" Copyright (c) 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)ctype.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/locale/ctype.3,v 1.6.2.3 2001/12/14 18:33:54 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt CTYPE 3 +.Os +.Sh NAME +.Nm isalnum , +.Nm isalpha , +.Nm isascii , +.Nm isblank , +.Nm iscntrl , +.Nm isdigit , +.Nm isgraph , +.Nm ishexnumber , +.Nm isideogram , +.Nm islower , +.Nm isnumber , +.Nm isphonogram , +.Nm isprint , +.Nm ispunct , +.Nm isrune , +.Nm isspace , +.Nm isspecial , +.Nm isupper , +.Nm isxdigit , +.Nm toascii , +.Nm tolower , +.Nm toupper +.Nd character classification macros +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In ctype.h +.Ft int +.Fn isalnum "int c" +.Ft int +.Fn isalpha "int c" +.Ft int +.Fn isascii "int c" +.Ft int +.Fn iscntrl "int c" +.Ft int +.Fn isdigit "int c" +.Ft int +.Fn isgraph "int c" +.Ft int +.Fn ishexnumber "int c" +.Ft int +.Fn isideogram "int c" +.Ft int +.Fn islower "int c" +.Ft int +.Fn isnumber "int c" +.Ft int +.Fn isphonogram "int c" +.Ft int +.Fn isspecial "int c" +.Ft int +.Fn isprint "int c" +.Ft int +.Fn ispunct "int c" +.Ft int +.Fn isrune "int c" +.Ft int +.Fn isspace "int c" +.Ft int +.Fn isupper "int c" +.Ft int +.Fn isxdigit "int c" +.Ft int +.Fn toascii "int c" +.Ft int +.Fn tolower "int c" +.Ft int +.Fn toupper "int c" +.Sh DESCRIPTION +The above functions perform character tests and conversions on the integer +.Ar c . +They are available as macros, defined in the include file +.Aq Pa ctype.h , +or as true functions in the C library. +See the specific manual pages for more information. +.Sh SEE ALSO +.Xr isalnum 3 , +.Xr isalpha 3 , +.Xr isascii 3 , +.Xr isblank 3 , +.Xr iscntrl 3 , +.Xr isdigit 3 , +.Xr isgraph 3 , +.Xr islower 3 , +.Xr isprint 3 , +.Xr ispunct 3 , +.Xr isspace 3 , +.Xr isupper 3 , +.Xr isxdigit 3 , +.Xr toascii 3 , +.Xr tolower 3 , +.Xr toupper 3 , +.Xr ascii 7 +.Sh STANDARDS +These functions, except for +.Fn digittoint , +.Fn isascii , +.Fn isblank , +.Fn ishexnumber , +.Fn isideogram , +.Fn isnumber , +.Fn isphonogram , +.Fn isrune , +.Fn isspecial +and +.Fn toascii , +conform to +.St -isoC . diff --git a/locale/euc.4 b/locale/euc.4 new file mode 100644 index 0000000..e7c9c92 --- /dev/null +++ b/locale/euc.4 @@ -0,0 +1,242 @@ +.\" Copyright (c) 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Paul Borman at Krystal Technologies. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)euc.4 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/locale/euc.4,v 1.8.2.1 2001/07/22 12:06:40 dd Exp $ +.\" +.Dd June 4, 1993 +.Dt EUC 4 +.Os +.Sh NAME +.Nm euc +.Nd EUC encoding of runes +.Sh SYNOPSIS +.Nm ENCODING +.Qq EUC +.Pp +.Nm VARIABLE +.Ar len1 +.Ar mask1 +.Ar len2 +.Ar mask2 +.Ar len3 +.Ar mask3 +.Ar len4 +.Ar mask4 +.Ar mask +.Sh DESCRIPTION +The +.Nm EUC +encoding is provided for compatibility with +.Ux +based systems. +See +.Xr mklocale 1 +for a complete description of the +.Ev LC_CTYPE +source file format. +.Pp +.Nm EUC +implements a system of 4 multibyte codesets. +A multibyte character in the first codeset consists of +.Ar len1 +bytes starting with a byte in the range of 0x00 to 0x7f. +To allow use of ASCII, +.Ar len1 +is always 1. +A multibyte character in the second codeset consists of +.Ar len2 +bytes starting with a byte in the range of 0x80-0xff excluding 0x8e and 0x8f. +A multibyte character in the third codeset consists of +.Ar len3 +bytes starting with the byte 0x8e. +A multibyte character in the fourth codeset consists of +.Ar len4 +bytes starting with the byte 0x8f. +.Pp +The +.Ev rune_t +encoding of +.Nm EUC +multibyte characters is dependent on the +.Ar len +and +.Ar mask +arguments. +First, the bytes are moved into a +.Ev rune_t +as follows: +.Bd -literal +byte0 << ((\fIlen\fPN-1) * 8) | byte1 << ((\fIlen\fPN-2) * 8) | ... | byte\fIlen\fPN-1 +.Ed +.Pp +The result is then ANDed with +.Ar ~mask +and ORed with +.Ar maskN . +Codesets 2 and 3 are special in that the leading byte (0x8e or 0x8f) is +first removed and the +.Ar lenN +argument is reduced by 1. +.Pp +For example, the Japanese locale has the following +.Ev VARIABLE +line: +.Bd -literal +VARIABLE 1 0x0000 2 0x8080 2 0x0080 3 0x8000 0x8080 +.Ed +.Pp +Codeset 1 consists of the values 0x0000 - 0x007f. +.Pp +Codeset 2 consists of the values who have the bits 0x8080 set. +.Pp +Codeset 3 consists of the values 0x0080 - 0x00ff. +.Pp +Codeset 4 consists of the values 0x8000 - 0xff7f excluding the values +which have the 0x0080 bit set. +.Pp +Notice that the global +.Ar mask +is set to 0x8080, this implies that from those 2 bits the codeset can +be determined. +.Sh "EXAMPLE - Japanese Locale" +This is a complete example of an +.Ev LC_CTYPE +source file for the Japanese locale +.Bd -literal +/* + * Japanese LOCALE_CTYPE definitions using EUC of JIS character sets + */ + +ENCODING "EUC" + +/* JIS JIS JIS */ +/* X201 X208 X201 */ +/* 00-7f 84-fe */ + +VARIABLE 1 0x0000 2 0x8080 2 0x0080 3 0x8000 0x8080 + +/* + * Code Set 1 + */ +ALPHA 'A' - 'Z' 'a' - 'z' +CONTROL 0x00 - 0x1f 0x7f +DIGIT '0' - '9' +GRAPH 0x21 - 0x7e +LOWER 'a' - 'z' +PUNCT 0x21 - 0x2f 0x3a - 0x40 0x5b - 0x60 0x7b - 0x7e +SPACE 0x09 - 0x0d 0x20 +UPPER 'A' - 'Z' +XDIGIT 'a' - 'f' 'A' - 'F' +BLANK ' ' '\t' +PRINT 0x20 - 0x7e + +MAPLOWER < 'A' - 'Z' : 'a' > < 'a' - 'z' : 'a' > +MAPUPPER < 'A' - 'Z' : 'A' > < 'a' - 'z' : 'A' > +TODIGIT < '0' - '9' : 0 > +TODIGIT < 'A' - 'F' : 10 > < 'a' - 'f' : 10 > + +/* + * Code Set 2 + */ + +SPACE 0xa1a1 +PHONOGRAM 0xa1bc +SPECIAL 0xa1a2 - 0xa1fe +PUNCT 0xa1a2 - 0xa1f8 /* A few too many in here... */ + +SPECIAL 0xa2a1 - 0xa2ae 0xa2ba - 0xa2c1 0xa2ca - 0xa2d0 0xa2dc - 0xa2ea +SPECIAL 0xa2f2 - 0xa2f9 0xa2fe + +DIGIT 0xa3b0 - 0xa3b9 +UPPER 0xa3c1 - 0xa3da /* Romaji */ +LOWER 0xa3e1 - 0xa3fa /* Romaji */ +MAPLOWER < 0xa3c1 - 0xa3da : 0xa3e1 > /* English */ +MAPLOWER < 0xa3e1 - 0xa3fa : 0xa3e1 > /* English */ +MAPUPPER < 0xa3c1 - 0xa3da : 0xa3c1 > +MAPUPPER < 0xa3e1 - 0xa3fa : 0xa3c1 > + +XDIGIT 0xa3c1 - 0xa3c6 0xa3e1 - 0xa3e6 + +TODIGIT < 0xa3b0 - 0xa3b9 : 0 > +TODIGIT < 0xa3c1 - 0xa3c6 : 10 > < 0xa3e1 - 0xa3e6 : 10 > + +PHONOGRAM 0xa4a1 - 0xa4f3 +PHONOGRAM 0xa5a1 - 0xa5f6 + +UPPER 0xa6a1 - 0xa6b8 /* Greek */ +LOWER 0xa6c1 - 0xa6d8 /* Greek */ +MAPLOWER < 0xa6a1 - 0xa6b8 : 0xa6c1 > < 0xa6c1 - 0xa6d8 : 0xa6c1 > +MAPUPPER < 0xa6a1 - 0xa6b8 : 0xa6a1 > < 0xa6c1 - 0xa6d8 : 0xa6a1 > + +UPPER 0xa7a1 - 0xa7c1 /* Cyrillic */ +LOWER 0xa7d1 - 0xa7f1 /* Cyrillic */ +MAPLOWER < 0xa7a1 - 0xa7c1 : 0xa7d1 > < 0xa7d1 - 0xa7f1 : 0xa7d1 > +MAPUPPER < 0xa7a1 - 0xa7c1 : 0xa7a1 > < 0xa7d1 - 0xa7f1 : 0xa7a1 > + +SPECIAL 0xa8a1 - 0xa8c0 + +IDEOGRAM 0xb0a1 - 0xb0fe 0xb1a1 - 0xb1fe 0xb2a1 - 0xb2fe +IDEOGRAM 0xb3a1 - 0xb3fe 0xb4a1 - 0xb4fe 0xb5a1 - 0xb5fe +IDEOGRAM 0xb6a1 - 0xb6fe 0xb7a1 - 0xb7fe 0xb8a1 - 0xb8fe +IDEOGRAM 0xb9a1 - 0xb9fe 0xbaa1 - 0xbafe 0xbba1 - 0xbbfe +IDEOGRAM 0xbca1 - 0xbcfe 0xbda1 - 0xbdfe 0xbea1 - 0xbefe +IDEOGRAM 0xbfa1 - 0xbffe 0xc0a1 - 0xc0fe 0xc1a1 - 0xc1fe +IDEOGRAM 0xc2a1 - 0xc2fe 0xc3a1 - 0xc3fe 0xc4a1 - 0xc4fe +IDEOGRAM 0xc5a1 - 0xc5fe 0xc6a1 - 0xc6fe 0xc7a1 - 0xc7fe +IDEOGRAM 0xc8a1 - 0xc8fe 0xc9a1 - 0xc9fe 0xcaa1 - 0xcafe +IDEOGRAM 0xcba1 - 0xcbfe 0xcca1 - 0xccfe 0xcda1 - 0xcdfe +IDEOGRAM 0xcea1 - 0xcefe 0xcfa1 - 0xcfd3 0xd0a1 - 0xd0fe +IDEOGRAM 0xd1a1 - 0xd1fe 0xd2a1 - 0xd2fe 0xd3a1 - 0xd3fe +IDEOGRAM 0xd4a1 - 0xd4fe 0xd5a1 - 0xd5fe 0xd6a1 - 0xd6fe +IDEOGRAM 0xd7a1 - 0xd7fe 0xd8a1 - 0xd8fe 0xd9a1 - 0xd9fe +IDEOGRAM 0xdaa1 - 0xdafe 0xdba1 - 0xdbfe 0xdca1 - 0xdcfe +IDEOGRAM 0xdda1 - 0xddfe 0xdea1 - 0xdefe 0xdfa1 - 0xdffe +IDEOGRAM 0xe0a1 - 0xe0fe 0xe1a1 - 0xe1fe 0xe2a1 - 0xe2fe +IDEOGRAM 0xe3a1 - 0xe3fe 0xe4a1 - 0xe4fe 0xe5a1 - 0xe5fe +IDEOGRAM 0xe6a1 - 0xe6fe 0xe7a1 - 0xe7fe 0xe8a1 - 0xe8fe +IDEOGRAM 0xe9a1 - 0xe9fe 0xeaa1 - 0xeafe 0xeba1 - 0xebfe +IDEOGRAM 0xeca1 - 0xecfe 0xeda1 - 0xedfe 0xeea1 - 0xeefe +IDEOGRAM 0xefa1 - 0xeffe 0xf0a1 - 0xf0fe 0xf1a1 - 0xf1fe +IDEOGRAM 0xf2a1 - 0xf2fe 0xf3a1 - 0xf3fe 0xf4a1 - 0xf4a4 +/* + * This is for Code Set 3, half-width kana + */ +SPECIAL 0xa1 - 0xdf +PHONOGRAM 0xa1 - 0xdf +CONTROL 0x84 - 0x97 0x9b - 0x9f 0xe0 - 0xfe +.Ed +.Sh "SEE ALSO" +.Xr mklocale 1 , +.Xr setlocale 3 diff --git a/locale.subproj/euc.c b/locale/euc.c similarity index 84% rename from locale.subproj/euc.c rename to locale/euc.c index 41394b9..4b7d9eb 100644 --- a/locale.subproj/euc.c +++ b/locale/euc.c @@ -1,25 +1,4 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ -/* +/*- * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * @@ -53,8 +32,13 @@ * 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. + * + * $FreeBSD: src/lib/libc/locale/euc.c,v 1.3.6.1 2000/06/04 21:47:39 ache Exp $ */ +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)euc.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ #include @@ -63,6 +47,7 @@ #include #include #include +#include rune_t _EUC_sgetrune __P((const char *, size_t, char const **)); int _EUC_sputrune __P((rune_t, char *, size_t, char **)); diff --git a/locale.subproj/frune.c b/locale/frune.c similarity index 75% rename from locale.subproj/frune.c rename to locale/frune.c index a6adad9..443d3ba 100644 --- a/locale.subproj/frune.c +++ b/locale/frune.c @@ -1,25 +1,4 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ -/* +/*- * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * @@ -55,6 +34,9 @@ * SUCH DAMAGE. */ +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)frune.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ #include #include diff --git a/locale/isalnum.3 b/locale/isalnum.3 new file mode 100644 index 0000000..91d3112 --- /dev/null +++ b/locale/isalnum.3 @@ -0,0 +1,101 @@ +.\" Copyright (c) 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)isalnum.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/locale/isalnum.3,v 1.7.2.7 2001/12/14 18:33:54 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt ISALNUM 3 +.Os +.Sh NAME +.Nm isalnum +.Nd alphanumeric character test +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In ctype.h +.Ft int +.Fn isalnum "int c" +.Sh DESCRIPTION +The +.Fn isalnum +function tests for any character for which +.Xr isalpha 3 +or +.Xr isdigit 3 +is true. +For single C +.Va char Ns s +locales (see +.Xr multibyte 3 ) +the value of the argument is +representable as an +.Li unsigned char +or the value of +.Dv EOF . +In the ASCII character set, this includes the following characters +(with their numeric values shown in octal): +.Pp +.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ +.It "\&060\ ``0'' \t061\ ``1'' \t062\ ``2'' \t063\ ``3'' \t064\ ``4''" +.It "\&065\ ``5'' \t066\ ``6'' \t067\ ``7'' \t070\ ``8'' \t071\ ``9''" +.It "\&101\ ``A'' \t102\ ``B'' \t103\ ``C'' \t104\ ``D'' \t105\ ``E''" +.It "\&106\ ``F'' \t107\ ``G'' \t110\ ``H'' \t111\ ``I'' \t112\ ``J''" +.It "\&113\ ``K'' \t114\ ``L'' \t115\ ``M'' \t116\ ``N'' \t117\ ``O''" +.It "\&120\ ``P'' \t121\ ``Q'' \t122\ ``R'' \t123\ ``S'' \t124\ ``T''" +.It "\&125\ ``U'' \t126\ ``V'' \t127\ ``W'' \t130\ ``X'' \t131\ ``Y''" +.It "\&132\ ``Z'' \t141\ ``a'' \t142\ ``b'' \t143\ ``c'' \t144\ ``d''" +.It "\&145\ ``e'' \t146\ ``f'' \t147\ ``g'' \t150\ ``h'' \t151\ ``i''" +.It "\&152\ ``j'' \t153\ ``k'' \t154\ ``l'' \t155\ ``m'' \t156\ ``n''" +.It "\&157\ ``o'' \t160\ ``p'' \t161\ ``q'' \t162\ ``r'' \t163\ ``s''" +.It "\&164\ ``t'' \t165\ ``u'' \t166\ ``v'' \t167\ ``w'' \t170\ ``x''" +.It "\&171\ ``y'' \t172\ ``z''" +.El +.Sh RETURN VALUES +The +.Fn isalnum +function returns zero if the character tests false and +returns non-zero if the character tests true. +.Sh SEE ALSO +.Xr ctype 3 , +.Xr isalpha 3 , +.Xr isdigit 3 , +.Xr multibyte 3 , +.Xr ascii 7 +.Sh STANDARDS +The +.Fn isalnum +function conforms to +.St -isoC . diff --git a/locale/isalpha.3 b/locale/isalpha.3 new file mode 100644 index 0000000..ae00cf4 --- /dev/null +++ b/locale/isalpha.3 @@ -0,0 +1,99 @@ +.\" Copyright (c) 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)isalpha.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/locale/isalpha.3,v 1.7.2.6 2001/12/14 18:33:54 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt ISALPHA 3 +.Os +.Sh NAME +.Nm isalpha +.Nd alphabetic character test +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In ctype.h +.Ft int +.Fn isalpha "int c" +.Sh DESCRIPTION +The +.Fn isalpha +function tests for any character for which +.Xr isupper 3 +or +.Xr islower 3 +is true. +For single C +.Va char Ns s +locales (see +.Xr multibyte 3 ) +the value of the argument is +representable as an +.Li unsigned char +or the value of +.Dv EOF . +In the ASCII character set, this includes the following characters +(with their numeric values shown in octal): +.Pp +.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ +.It "\&101\ ``A'' \t102\ ``B'' \t103\ ``C'' \t104\ ``D'' \t105\ ``E''" +.It "\&106\ ``F'' \t107\ ``G'' \t110\ ``H'' \t111\ ``I'' \t112\ ``J''" +.It "\&113\ ``K'' \t114\ ``L'' \t115\ ``M'' \t116\ ``N'' \t117\ ``O''" +.It "\&120\ ``P'' \t121\ ``Q'' \t122\ ``R'' \t123\ ``S'' \t124\ ``T''" +.It "\&125\ ``U'' \t126\ ``V'' \t127\ ``W'' \t130\ ``X'' \t131\ ``Y''" +.It "\&132\ ``Z'' \t141\ ``a'' \t142\ ``b'' \t143\ ``c'' \t144\ ``d''" +.It "\&145\ ``e'' \t146\ ``f'' \t147\ ``g'' \t150\ ``h'' \t151\ ``i''" +.It "\&152\ ``j'' \t153\ ``k'' \t154\ ``l'' \t155\ ``m'' \t156\ ``n''" +.It "\&157\ ``o'' \t160\ ``p'' \t161\ ``q'' \t162\ ``r'' \t163\ ``s''" +.It "\&164\ ``t'' \t165\ ``u'' \t166\ ``v'' \t167\ ``w'' \t170\ ``x''" +.It "\&171\ ``y'' \t172\ ``z''" +.El +.Sh RETURN VALUES +The +.Fn isalpha +function returns zero if the character tests false and +returns non-zero if the character tests true. +.Sh SEE ALSO +.Xr ctype 3 , +.Xr islower 3 , +.Xr isupper 3 , +.Xr multibyte 3 , +.Xr ascii 7 +.Sh STANDARDS +The +.Fn isalpha +function conforms to +.St -isoC . diff --git a/locale/isascii.3 b/locale/isascii.3 new file mode 100644 index 0000000..071bb62 --- /dev/null +++ b/locale/isascii.3 @@ -0,0 +1,61 @@ +.\" Copyright (c) 1989, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)isascii.3 8.2 (Berkeley) 12/11/93 +.\" $FreeBSD: src/lib/libc/locale/isascii.3,v 1.5.2.5 2001/12/14 18:33:54 ru Exp $ +.\" +.Dd December 11, 1993 +.Dt ISASCII 3 +.Os +.Sh NAME +.Nm isascii +.Nd test for ASCII character +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In ctype.h +.Ft int +.Fn isascii "int c" +.Sh DESCRIPTION +The +.Fn isascii +function tests for an +.Tn ASCII +character, which is any character +between 0 and octal 0177 inclusive. +.Sh SEE ALSO +.Xr ctype 3 , +.Xr ascii 7 +.Sh STANDARDS +The +.Fn isascii +function conforms to +.St -isoC . diff --git a/locale/isblank.3 b/locale/isblank.3 new file mode 100644 index 0000000..82587dc --- /dev/null +++ b/locale/isblank.3 @@ -0,0 +1,68 @@ +.\" Copyright (c) 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)isblank.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/locale/isblank.3,v 1.4.2.3 2001/12/14 18:33:54 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt ISBLANK 3 +.Os +.Sh NAME +.Nm isblank +.Nd space or tab character test +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In ctype.h +.Ft int +.Fn isblank "int c" +.Sh DESCRIPTION +The +.Fn isblank +function tests for a space or tab character. +For single C +.Va char Ns s +locales (see +.Xr multibyte 3 ) +the value of the argument is +representable as an +.Li unsigned char +or the value of +.Dv EOF . +.Sh RETURN VALUES +The +.Fn isblank +function returns zero if the character tests false and +returns non-zero if the character tests true. +.Sh SEE ALSO +.Xr ctype 3 , +.Xr multibyte 3 , +.Xr ascii 7 diff --git a/locale/iscntrl.3 b/locale/iscntrl.3 new file mode 100644 index 0000000..be6dcc5 --- /dev/null +++ b/locale/iscntrl.3 @@ -0,0 +1,89 @@ +.\" Copyright (c) 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)iscntrl.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/locale/iscntrl.3,v 1.6.2.5 2001/12/14 18:33:54 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt ISCNTRL 3 +.Os +.Sh NAME +.Nm iscntrl +.Nd control character test +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In ctype.h +.Ft int +.Fn iscntrl "int c" +.Sh DESCRIPTION +The +.Fn iscntrl +function tests for any control character. +For single C +.Va char Ns s +locales (see +.Xr multibyte 3 ) +the value of the argument is +representable as an +.Li unsigned char +or the value of +.Dv EOF . +In the ASCII character set, this includes the following characters +(with their numeric values shown in octal): +.Pp +.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ +.It "\&000\ nul \t001\ soh \t002\ stx \t003\ etx \t004\ eot" +.It "\&005\ enq \t006\ ack \t007\ bel \t010\ bs \t011\ ht" +.It "\&012\ nl \t013\ vt \t014\ np \t015\ cr \t016\ so" +.It "\&017\ si \t020\ dle \t021\ dc1 \t022\ dc2 \t023\ dc3" +.It "\&024\ dc4 \t025\ nak \t026\ syn \t027\ etb \t030\ can" +.It "\&031\ em \t032\ sub \t033\ esc \t034\ fs \t035\ gs" +.It "\&036\ rs \t037\ us \t177\ del" +.El +.Sh RETURN VALUES +The +.Fn iscntrl +function returns zero if the character tests false and +returns non-zero if the character tests true. +.Sh SEE ALSO +.Xr ctype 3 , +.Xr multibyte 3 , +.Xr ascii 7 +.Sh STANDARDS +The +.Fn iscntrl +function conforms to +.St -isoC . diff --git a/locale/isctype.c b/locale/isctype.c new file mode 100644 index 0000000..7c718c7 --- /dev/null +++ b/locale/isctype.c @@ -0,0 +1,233 @@ +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * This code is derived from software contributed to Berkeley by + * Paul Borman at Krystal Technologies. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * $FreeBSD: src/lib/libc/locale/isctype.c,v 1.7 2000/02/08 07:43:24 obrien Exp $ + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)isctype.c 8.3 (Berkeley) 2/24/94"; +#endif /* LIBC_SCCS and not lint */ + +#include + +#undef digittoint +int +digittoint(c) + int c; +{ + return (__maskrune((c), 0xFF)); +} + +#undef isalnum +int +isalnum(c) + int c; +{ + return (__istype((c), _CTYPE_A|_CTYPE_D)); +} + +#undef isalpha +int +isalpha(c) + int c; +{ + return (__istype((c), _CTYPE_A)); +} + +#undef isascii +int +isascii(c) + int c; +{ + return (((c) & ~0x7F) == 0); +} + +#undef isblank +int +isblank(c) + int c; +{ + return (__istype((c), _CTYPE_B)); +} + +#undef iscntrl +int +iscntrl(c) + int c; +{ + return (__istype((c), _CTYPE_C)); +} + +#undef isdigit +int +isdigit(c) + int c; +{ + return (__isctype((c), _CTYPE_D)); +} + +#undef isgraph +int +isgraph(c) + int c; +{ + return (__istype((c), _CTYPE_G)); +} + +#undef ishexnumber +int +ishexnumber(c) + int c; +{ + return (__istype((c), _CTYPE_X)); +} + +#undef isideogram +int +isideogram(c) + int c; +{ + return (__istype((c), _CTYPE_I)); +} + +#undef islower +int +islower(c) + int c; +{ + return (__istype((c), _CTYPE_L)); +} + +#undef isnumber +int +isnumber(c) + int c; +{ + return (__istype((c), _CTYPE_D)); +} + +#undef isphonogram +int +isphonogram(c) + int c; +{ + return (__istype((c), _CTYPE_Q)); +} + +#undef isprint +int +isprint(c) + int c; +{ + return (__istype((c), _CTYPE_R)); +} + +#undef ispunct +int +ispunct(c) + int c; +{ + return (__istype((c), _CTYPE_P)); +} + +#undef isrune +int +isrune(c) + int c; +{ + return (__istype((c), 0xFFFFFF00L)); +} + +#undef isspace +int +isspace(c) + int c; +{ + return (__istype((c), _CTYPE_S)); +} + +#undef isspecial +int +isspecial(c) + int c; +{ + return (__istype((c), _CTYPE_T)); +} + +#undef isupper +int +isupper(c) + int c; +{ + return (__istype((c), _CTYPE_U)); +} + +#undef isxdigit +int +isxdigit(c) + int c; +{ + return (__isctype((c), _CTYPE_X)); +} + +#undef toascii +int +toascii(c) + int c; +{ + return ((c) & 0x7F); +} + +#undef tolower +int +tolower(c) + int c; +{ + return (__tolower(c)); +} + +#undef toupper +int +toupper(c) + int c; +{ + return (__toupper(c)); +} + diff --git a/locale/isdigit.3 b/locale/isdigit.3 new file mode 100644 index 0000000..9042f31 --- /dev/null +++ b/locale/isdigit.3 @@ -0,0 +1,84 @@ +.\" Copyright (c) 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)isdigit.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/locale/isdigit.3,v 1.6.2.5 2001/12/14 18:33:54 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt ISDIGIT 3 +.Os +.Sh NAME +.Nm isdigit +.Nd decimal-digit character test +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In ctype.h +.Ft int +.Fn isdigit "int c" +.Sh DESCRIPTION +The +.Fn isdigit +function tests for any decimal-digit character. +For single C +.Va char Ns s +locales (see +.Xr multibyte 3 ) +the value of the argument is +representable as an +.Li unsigned char +or the value of +.Dv EOF . +In the ASCII character set, this includes the following characters +(with their numeric values shown in octal): +.Pp +.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ +.It "\&060\ ``0'' \t061\ ``1'' \t062\ ``2'' \t063\ ``3'' \t064\ ``4''" +.It "\&065\ ``5'' \t066\ ``6'' \t067\ ``7'' \t070\ ``8'' \t071\ ``9''" +.El +.Sh RETURN VALUES +The +.Fn isdigit +function returns zero if the character tests false and +returns non-zero if the character tests true. +.Sh SEE ALSO +.Xr ctype 3 , +.Xr multibyte 3 , +.Xr ascii 7 +.Sh STANDARDS +The +.Fn isdigit +function conforms to +.St -isoC . diff --git a/locale/isgraph.3 b/locale/isgraph.3 new file mode 100644 index 0000000..02e7b13 --- /dev/null +++ b/locale/isgraph.3 @@ -0,0 +1,101 @@ +.\" Copyright (c) 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)isgraph.3 8.2 (Berkeley) 12/11/93 +.\" $FreeBSD: src/lib/libc/locale/isgraph.3,v 1.7.2.5 2001/12/14 18:33:54 ru Exp $ +.\" +.Dd December 11, 1993 +.Dt ISGRAPH 3 +.Os +.Sh NAME +.Nm isgraph +.Nd printing character test (space character exclusive) +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In ctype.h +.Ft int +.Fn isgraph "int c" +.Sh DESCRIPTION +The +.Fn isgraph +function tests for any printing character except space. +For single C +.Va char Ns s +locales (see +.Xr multibyte 3 ) +the value of the argument is +representable as an +.Li unsigned char +or the value of +.Dv EOF . +In the ASCII character set, this includes the following characters +(with their numeric values shown in octal): +.Pp +.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ +.It "\&041\ ``!'' \t042\ ``""'' \t043\ ``#'' \t044\ ``$'' \t045\ ``%''" +.It "\&046\ ``&'' \t047\ ``''' \t050\ ``('' \t051\ ``)'' \t052\ ``*''" +.It "\&053\ ``+'' \t054\ ``,'' \t055\ ``-'' \t056\ ``.'' \t057\ ``/''" +.It "\&060\ ``0'' \t061\ ``1'' \t062\ ``2'' \t063\ ``3'' \t064\ ``4''" +.It "\&065\ ``5'' \t066\ ``6'' \t067\ ``7'' \t070\ ``8'' \t071\ ``9''" +.It "\&072\ ``:'' \t073\ ``;'' \t074\ ``<'' \t075\ ``='' \t076\ ``>''" +.It "\&077\ ``?'' \t100\ ``@'' \t101\ ``A'' \t102\ ``B'' \t103\ ``C''" +.It "\&104\ ``D'' \t105\ ``E'' \t106\ ``F'' \t107\ ``G'' \t110\ ``H''" +.It "\&111\ ``I'' \t112\ ``J'' \t113\ ``K'' \t114\ ``L'' \t115\ ``M''" +.It "\&116\ ``N'' \t117\ ``O'' \t120\ ``P'' \t121\ ``Q'' \t122\ ``R''" +.It "\&123\ ``S'' \t124\ ``T'' \t125\ ``U'' \t126\ ``V'' \t127\ ``W''" +.It "\&130\ ``X'' \t131\ ``Y'' \t132\ ``Z'' \t133\ ``['' \t134\ ``\e\|''" +.It "\&135\ ``]'' \t136\ ``^'' \t137\ ``_'' \t140\ ```'' \t141\ ``a''" +.It "\&142\ ``b'' \t143\ ``c'' \t144\ ``d'' \t145\ ``e'' \t146\ ``f''" +.It "\&147\ ``g'' \t150\ ``h'' \t151\ ``i'' \t152\ ``j'' \t153\ ``k''" +.It "\&154\ ``l'' \t155\ ``m'' \t156\ ``n'' \t157\ ``o'' \t160\ ``p''" +.It "\&161\ ``q'' \t162\ ``r'' \t163\ ``s'' \t164\ ``t'' \t165\ ``u''" +.It "\&166\ ``v'' \t167\ ``w'' \t170\ ``x'' \t171\ ``y'' \t172\ ``z''" +.It "\&173\ ``{'' \t174\ ``|'' \t175\ ``}'' \t176\ ``~''" +.El +.Sh RETURN VALUES +The +.Fn isgraph +function returns zero if the character tests false and +returns non-zero if the character tests true. +.Sh SEE ALSO +.Xr ctype 3 , +.Xr multibyte 3 , +.Xr ascii 7 +.Sh STANDARDS +The +.Fn isgraph +function conforms to +.St -isoC . diff --git a/locale/islower.3 b/locale/islower.3 new file mode 100644 index 0000000..95358f7 --- /dev/null +++ b/locale/islower.3 @@ -0,0 +1,89 @@ +.\" Copyright (c) 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)islower.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/locale/islower.3,v 1.7.2.5 2001/12/14 18:33:54 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt ISLOWER 3 +.Os +.Sh NAME +.Nm islower +.Nd lower-case character test +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In ctype.h +.Ft int +.Fn islower "int c" +.Sh DESCRIPTION +The +.Fn islower +function tests for any lower-case letters. +For single C +.Va char Ns s +locales (see +.Xr multibyte 3 ) +the value of the argument is +representable as an +.Li unsigned char +or the value of +.Dv EOF . +In the ASCII character set, this includes the following characters +(with their numeric values shown in octal): +.Pp +.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ +.It "\&141\ ``a'' \t142\ ``b'' \t143\ ``c'' \t144\ ``d'' \t145\ ``e''" +.It "\&146\ ``f'' \t147\ ``g'' \t150\ ``h'' \t151\ ``i'' \t152\ ``j''" +.It "\&153\ ``k'' \t154\ ``l'' \t155\ ``m'' \t156\ ``n'' \t157\ ``o''" +.It "\&160\ ``p'' \t161\ ``q'' \t162\ ``r'' \t163\ ``s'' \t164\ ``t''" +.It "\&165\ ``u'' \t166\ ``v'' \t167\ ``w'' \t170\ ``x'' \t171\ ``y''" +.It "\&172\ ``z''" +.El +.Sh RETURN VALUES +The +.Fn islower +function returns zero if the character tests false and +returns non-zero if the character tests true. +.Sh SEE ALSO +.Xr ctype 3 , +.Xr multibyte 3 , +.Xr tolower 3 , +.Xr ascii 7 +.Sh STANDARDS +The +.Fn islower +function conforms to +.St -isoC . diff --git a/locale/isprint.3 b/locale/isprint.3 new file mode 100644 index 0000000..3f281fe --- /dev/null +++ b/locale/isprint.3 @@ -0,0 +1,101 @@ +.\" Copyright (c) 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)isprint.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/locale/isprint.3,v 1.7.2.5 2001/12/14 18:33:54 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt ISPRINT 3 +.Os +.Sh NAME +.Nm isprint +.Nd printing character test (space character inclusive) +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In ctype.h +.Ft int +.Fn isprint "int c" +.Sh DESCRIPTION +The +.Fn isprint +function tests for any printing character including space (' '). +For single C +.Va char Ns s +locales (see +.Xr multibyte 3 ) +the value of the argument is +representable as an +.Li unsigned char +or the value of +.Dv EOF . +In the ASCII character set, this includes the following characters +(with their numeric values shown in octal): +.Pp +.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ +.It "\&040\ sp \t041\ ``!'' \t042\ ``""'' \t043\ ``#'' \t044\ ``$''" +.It "\&045\ ``%'' \t046\ ``&'' \t047\ ``''' \t050\ ``('' \t051\ ``)''" +.It "\&052\ ``*'' \t053\ ``+'' \t054\ ``,'' \t055\ ``-'' \t056\ ``.''" +.It "\&057\ ``/'' \t060\ ``0'' \t061\ ``1'' \t062\ ``2'' \t063\ ``3''" +.It "\&064\ ``4'' \t065\ ``5'' \t066\ ``6'' \t067\ ``7'' \t070\ ``8''" +.It "\&071\ ``9'' \t072\ ``:'' \t073\ ``;'' \t074\ ``<'' \t075\ ``=''" +.It "\&076\ ``>'' \t077\ ``?'' \t100\ ``@'' \t101\ ``A'' \t102\ ``B''" +.It "\&103\ ``C'' \t104\ ``D'' \t105\ ``E'' \t106\ ``F'' \t107\ ``G''" +.It "\&110\ ``H'' \t111\ ``I'' \t112\ ``J'' \t113\ ``K'' \t114\ ``L''" +.It "\&115\ ``M'' \t116\ ``N'' \t117\ ``O'' \t120\ ``P'' \t121\ ``Q''" +.It "\&122\ ``R'' \t123\ ``S'' \t124\ ``T'' \t125\ ``U'' \t126\ ``V''" +.It "\&127\ ``W'' \t130\ ``X'' \t131\ ``Y'' \t132\ ``Z'' \t133\ ``[''" +.It "\&134\ ``\e\|'' \t135\ ``]'' \t136\ ``^'' \t137\ ``_'' \t140\ ```''" +.It "\&141\ ``a'' \t142\ ``b'' \t143\ ``c'' \t144\ ``d'' \t145\ ``e''" +.It "\&146\ ``f'' \t147\ ``g'' \t150\ ``h'' \t151\ ``i'' \t152\ ``j''" +.It "\&153\ ``k'' \t154\ ``l'' \t155\ ``m'' \t156\ ``n'' \t157\ ``o''" +.It "\&160\ ``p'' \t161\ ``q'' \t162\ ``r'' \t163\ ``s'' \t164\ ``t''" +.It "\&165\ ``u'' \t166\ ``v'' \t167\ ``w'' \t170\ ``x'' \t171\ ``y''" +.It "\&172\ ``z'' \t173\ ``{'' \t174\ ``|'' \t175\ ``}'' \t176\ ``~''" +.El +.Sh RETURN VALUES +The +.Fn isprint +function returns zero if the character tests false and +returns non-zero if the character tests true. +.Sh SEE ALSO +.Xr ctype 3 , +.Xr multibyte 3 , +.Xr ascii 7 +.Sh STANDARDS +The +.Fn isprint +function conforms to +.St -isoC . diff --git a/locale/ispunct.3 b/locale/ispunct.3 new file mode 100644 index 0000000..3d17042 --- /dev/null +++ b/locale/ispunct.3 @@ -0,0 +1,92 @@ +.\" Copyright (c) 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)ispunct.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/locale/ispunct.3,v 1.7.2.5 2001/12/14 18:33:54 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt ISPUNCT 3 +.Os +.Sh NAME +.Nm ispunct +.Nd punctuation character test +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In ctype.h +.Ft int +.Fn ispunct "int c" +.Sh DESCRIPTION +The +.Fn ispunct +function tests for any printing character except for space (' ') or a +character for which +.Xr isalnum 3 +is true. +For single C +.Va char Ns s +locales (see +.Xr multibyte 3 ) +the value of the argument is +representable as an +.Li unsigned char +or the value of +.Dv EOF . +In the ASCII character set, this includes the following characters +(with their numeric values shown in octal): +.Pp +.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ +.It "\&041\ ``!'' \t042\ ``""'' \t043\ ``#'' \t044\ ``$'' \t045\ ``%''" +.It "\&046\ ``&'' \t047\ ``''' \t050\ ``('' \t051\ ``)'' \t052\ ``*''" +.It "\&053\ ``+'' \t054\ ``,'' \t055\ ``-'' \t056\ ``.'' \t057\ ``/''" +.It "\&072\ ``:'' \t073\ ``;'' \t074\ ``<'' \t075\ ``='' \t076\ ``>''" +.It "\&077\ ``?'' \t100\ ``@'' \t133\ ``['' \t134\ ``\e\|'' \t135\ ``]''" +.It "\&136\ ``^'' \t137\ ``_'' \t140\ ```'' \t173\ ``{'' \t174\ ``|''" +.It "\&175\ ``}'' \t176\ ``~''" +.El +.Sh RETURN VALUES +The +.Fn ispunct +function returns zero if the character tests false and +returns non-zero if the character tests true. +.Sh SEE ALSO +.Xr ctype 3 , +.Xr multibyte 3 , +.Xr ascii 7 +.Sh STANDARDS +The +.Fn ispunct +function conforms to +.St -isoC . diff --git a/locale/isspace.3 b/locale/isspace.3 new file mode 100644 index 0000000..b53b3f9 --- /dev/null +++ b/locale/isspace.3 @@ -0,0 +1,84 @@ +.\" Copyright (c) 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)isspace.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/locale/isspace.3,v 1.6.2.5 2001/12/14 18:33:54 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt ISSPACE 3 +.Os +.Sh NAME +.Nm isspace +.Nd white-space character test +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In ctype.h +.Ft int +.Fn isspace "int c" +.Sh DESCRIPTION +The +.Fn isspace +function tests for the standard white-space characters. +For single C +.Va char Ns s +locales (see +.Xr multibyte 3 ) +the value of the argument is +representable as an +.Li unsigned char +or the value of +.Dv EOF . +In the ASCII character set, this includes the following characters +(with their numeric values shown in octal): +.Pp +.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ +.It "\&011\ ht \t012\ nl \t013\ vt \t014\ np \t015\ cr" +.It "\&040\ sp" +.El +.Sh RETURN VALUES +The +.Fn isspace +function returns zero if the character tests false and +returns non-zero if the character tests true. +.Sh SEE ALSO +.Xr ctype 3 , +.Xr multibyte 3 , +.Xr ascii 7 +.Sh STANDARDS +The +.Fn isspace +function conforms to +.St -isoC . diff --git a/locale/isupper.3 b/locale/isupper.3 new file mode 100644 index 0000000..af98c6b --- /dev/null +++ b/locale/isupper.3 @@ -0,0 +1,89 @@ +.\" Copyright (c) 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)isupper.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/locale/isupper.3,v 1.8.2.5 2001/12/14 18:33:54 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt ISUPPER 3 +.Os +.Sh NAME +.Nm isupper +.Nd upper-case character test +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In ctype.h +.Ft int +.Fn isupper "int c" +.Sh DESCRIPTION +The +.Fn isupper +function tests for any upper-case letter. +For single C +.Va char Ns s +locales (see +.Xr multibyte 3 ) +the value of the argument is +representable as an +.Li unsigned char +or the value of +.Dv EOF . +In the ASCII character set, this includes the following characters +(with their numeric values shown in octal): +.Pp +.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ +.It "\&101\ ``A'' \t102\ ``B'' \t103\ ``C'' \t104\ ``D'' \t105\ ``E''" +.It "\&106\ ``F'' \t107\ ``G'' \t110\ ``H'' \t111\ ``I'' \t112\ ``J''" +.It "\&113\ ``K'' \t114\ ``L'' \t115\ ``M'' \t116\ ``N'' \t117\ ``O''" +.It "\&120\ ``P'' \t121\ ``Q'' \t122\ ``R'' \t123\ ``S'' \t124\ ``T''" +.It "\&125\ ``U'' \t126\ ``V'' \t127\ ``W'' \t130\ ``X'' \t131\ ``Y''" +.It "\&132\ ``Z''" +.El +.Sh RETURN VALUES +The +.Fn isupper +function returns zero if the character tests false and +returns non-zero if the character tests true. +.Sh SEE ALSO +.Xr ctype 3 , +.Xr multibyte 3 , +.Xr toupper 3 , +.Xr ascii 7 +.Sh STANDARDS +The +.Fn isupper +function conforms to +.St -isoC . diff --git a/locale/isxdigit.3 b/locale/isxdigit.3 new file mode 100644 index 0000000..7fa9ceb --- /dev/null +++ b/locale/isxdigit.3 @@ -0,0 +1,87 @@ +.\" Copyright (c) 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)isxdigit.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/locale/isxdigit.3,v 1.6.2.5 2001/12/14 18:33:54 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt ISXDIGIT 3 +.Os +.Sh NAME +.Nm isxdigit +.Nd hexadecimal-digit character test +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In ctype.h +.Ft int +.Fn isxdigit "int c" +.Sh DESCRIPTION +The +.Fn isxdigit +function tests for any hexadecimal-digit character. +For single C +.Va char Ns s +locales (see +.Xr multibyte 3 ) +the value of the argument is +representable as an +.Li unsigned char +or the value of +.Dv EOF . +In the ASCII character set, this includes the following characters +(with their numeric values shown in octal): +.Pp +.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ +.It "\&060\ ``0'' \t061\ ``1'' \t062\ ``2'' \t063\ ``3'' \t064\ ``4''" +.It "\&065\ ``5'' \t066\ ``6'' \t067\ ``7'' \t070\ ``8'' \t071\ ``9''" +.It "\&101\ ``A'' \t102\ ``B'' \t103\ ``C'' \t104\ ``D'' \t105\ ``E''" +.It "\&106\ ``F'' \t141\ ``a'' \t142\ ``b'' \t143\ ``c'' \t144\ ``d''" +.It "\&145\ ``e'' \t146\ ``f''" +.El +.Sh RETURN VALUES +The +.Fn isxdigit +function returns zero if the character tests false and +returns non-zero if the character tests true. +.Sh SEE ALSO +.Xr ctype 3 , +.Xr multibyte 3 , +.Xr ascii 7 +.Sh STANDARDS +The +.Fn isxdigit +function conforms to +.St -isoC . diff --git a/locale/lconv.c b/locale/lconv.c new file mode 100644 index 0000000..f1212b0 --- /dev/null +++ b/locale/lconv.c @@ -0,0 +1,70 @@ +/* + * Copyright (c) 1991, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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[] = "@(#)lconv.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include + +static char empty[] = ""; + +/* + * Default (C) locale conversion. + */ +static struct lconv C_lconv = { + ".", /* decimal_point */ + empty, /* thousands_sep */ + empty, /* grouping */ + empty, /* int_curr_symbol */ + empty, /* currency_symbol */ + empty, /* mon_decimal_point */ + empty, /* mon_thousands_sep */ + empty, /* mon_grouping */ + empty, /* positive_sign */ + empty, /* negative_sign */ + CHAR_MAX, /* int_frac_digits */ + CHAR_MAX, /* frac_digits */ + CHAR_MAX, /* p_cs_precedes */ + CHAR_MAX, /* p_sep_by_space */ + CHAR_MAX, /* n_cs_precedes */ + CHAR_MAX, /* n_sep_by_space */ + CHAR_MAX, /* p_sign_posn */ + CHAR_MAX, /* n_sign_posn */ +}; + +/* + * Current locale conversion. + */ +struct lconv *__lconv = &C_lconv; diff --git a/locale/localeconv.c b/locale/localeconv.c new file mode 100644 index 0000000..825f52c --- /dev/null +++ b/locale/localeconv.c @@ -0,0 +1,51 @@ +/* + * Copyright (c) 1991, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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[] = "@(#)localeconv.c 8.1 (Berkeley) 6/4/93"; +static char rcsid[] = + "$FreeBSD: src/lib/libc/locale/localeconv.c,v 1.1.1.1.14.1 2001/03/05 10:21:18 obrien Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include + +/* + * Return the current locale conversion. + */ +struct lconv * +localeconv() +{ + extern struct lconv *__lconv; + + return (__lconv); +} diff --git a/locale/mbrune.3 b/locale/mbrune.3 new file mode 100644 index 0000000..e6b6432 --- /dev/null +++ b/locale/mbrune.3 @@ -0,0 +1,160 @@ +.\" Copyright (c) 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Paul Borman at Krystal Technologies. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)mbrune.3 8.2 (Berkeley) 4/19/94 +.\" $FreeBSD: src/lib/libc/locale/mbrune.3,v 1.6.2.4 2001/12/14 18:33:54 ru Exp $ +.\" +.Dd April 19, 1994 +.Dt MBRUNE 3 +.Os +.Sh NAME +.Nm mbrune , +.Nm mbrrune , +.Nm mbmb +.Nd multibyte rune support for C +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In rune.h +.Ft char * +.Fn mbrune "const char *string" "rune_t rune" +.Ft char * +.Fn mbrrune "const char *string" "rune_t rune" +.Ft char * +.Fn mbmb "const char *string" "char *pattern" +.Sh DESCRIPTION +These routines provide the corresponding functionality of +.Fn strchr , +.Fn strrchr +and +.Fn strstr +for multibyte strings. +.Pp +The +.Fn mbrune +function locates the first occurrence of +.Fn rune +in the string pointed to by +.Ar string . +The terminating +.Dv NUL +character is considered part of the string. +If +.Fa rune +is +.Ql \e0 , +.Fn mbrune +locates the terminating +.Ql \e0 . +.Pp +The +.Fn mbrrune +function +locates the last occurrence of +.Fa rune +in the string +.Fa string . +If +.Fa rune +is +.Ql \e0 , +.Fn mbrune +locates the terminating +.Ql \e0 . +.Pp +The +.Fn mbmb +function locates the first occurrence of the null-terminated string +.Fa pattern +in the null-terminated string +.Fa string . +If +.Fa pattern +is the empty string, +.Fn mbmb +returns +.Fa string ; +if +.Fa pattern +occurs nowhere in +.Fa string , +.Fn mbmb +returns +.Dv NULL ; +otherwise +.Fn mbmb +returns a pointer to the first character of the first occurrence of +.Fa pattern . +.Sh RETURN VALUES +The function +.Fn mbrune +returns a pointer to the located character, or +.Dv NULL +if the character does not appear in the string. +.Pp +The +.Fn mbrrune +function +returns a pointer to the character, or +.Dv NULL +if the character does not appear in the string. +.Pp +The +.Fn mbmb +function +returns a pointer to the +.Fa pattern , +or +.Dv NULL +if the +.Fa pattern +does not appear in the string. +.Sh "SEE ALSO +.Xr mbrune 3 , +.Xr rune 3 , +.Xr setlocale 3 , +.Xr euc 4 , +.Xr utf2 4 +.Sh HISTORY +The +.Fn mbrune , +.Fn mbrrune , +and +.Fn mbmb +functions +first appeared in Plan 9 from Bell Labs as +.Fn utfrune , +.Fn utfrrune , +and +.Fn utfutf . diff --git a/locale.subproj/mbrune.c b/locale/mbrune.c similarity index 77% rename from locale.subproj/mbrune.c rename to locale/mbrune.c index 105c4a7..92efe83 100644 --- a/locale.subproj/mbrune.c +++ b/locale/mbrune.c @@ -1,25 +1,4 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ -/* +/*- * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * @@ -55,6 +34,9 @@ * SUCH DAMAGE. */ +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)mbrune.c 8.1 (Berkeley) 6/27/93"; +#endif /* LIBC_SCCS and not lint */ #include #include diff --git a/locale/mskanji.c b/locale/mskanji.c new file mode 100644 index 0000000..16411f6 --- /dev/null +++ b/locale/mskanji.c @@ -0,0 +1,106 @@ +/* + * ja_JP.SJIS locale table for BSD4.4/rune + * version 1.0 + * (C) Sin'ichiro MIYATANI / Phase One, Inc + * May 12, 1995 + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Phase One, Inc. + * 4. The name of Phase One, Inc. 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. + * + * $FreeBSD: src/lib/libc/locale/mskanji.c,v 1.2.8.2 2001/03/05 10:22:45 obrien Exp $ + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)mskanji.c 1.0 (Phase One) 5/5/95"; +#endif /* LIBC_SCCS and not lint */ + +#include + +#include +#include +#include +#include + +rune_t _MSKanji_sgetrune __P((const char *, size_t, char const **)); +int _MSKanji_sputrune __P((rune_t, char *, size_t, char **)); + +int +_MSKanji_init(rl) + _RuneLocale *rl; +{ + rl->sgetrune = _MSKanji_sgetrune; + rl->sputrune = _MSKanji_sputrune; + + _CurrentRuneLocale = rl; + __mb_cur_max = 2; + return (0); +} + +rune_t +_MSKanji_sgetrune(string, n, result) + const char *string; + size_t n; + char const **result; +{ + rune_t rune = 0; + + if (n < 1 ) { + rune = _INVALID_RUNE; + } else { + rune = *( string++ ) & 0xff; + if ( ( rune > 0x80 && rune < 0xa0 ) + || ( rune >= 0xe0 && rune < 0xfa ) ) { + if ( n < 2 ) { + rune = (rune_t)_INVALID_RUNE; + --string; + } else { + rune = ( rune << 8 ) | ( *( string++ ) & 0xff ); + } + } + } + if (result) *result = string; + return rune; +} + +int +_MSKanji_sputrune(c, string, n, result) + rune_t c; + char *string, **result; + size_t n; +{ + int len, i; + + len = ( c > 0x100 ) ? 2 : 1; + if ( n < len ) { + if ( result ) *result = (char *) 0; + } else { + if ( result ) *result = string + len; + for ( i = len; i-- > 0; ) { + *( string++ ) = c >> ( i << 3 ); + } + } + return len; +} diff --git a/locale/multibyte.3 b/locale/multibyte.3 new file mode 100644 index 0000000..84a3d0e --- /dev/null +++ b/locale/multibyte.3 @@ -0,0 +1,245 @@ +.\" Copyright (c) 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Donn Seeley of BSDI. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)multibyte.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/locale/multibyte.3,v 1.6.2.5 2001/12/14 18:33:54 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt MULTIBYTE 3 +.Os +.Sh NAME +.Nm mblen , +.Nm mbstowcs , +.Nm mbtowc , +.Nm wcstombs , +.Nm wctomb +.Nd multibyte character support for C +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft int +.Fn mblen "const char *mbchar" "size_t nbytes" +.Ft size_t +.Fn mbstowcs "wchar_t *wcstring" "const char *mbstring" "size_t nwchars" +.Ft int +.Fn mbtowc "wchar_t *wcharp" "const char *mbchar" "size_t nbytes" +.Ft size_t +.Fn wcstombs "char *mbstring" "const wchar_t *wcstring" "size_t nbytes" +.Ft int +.Fn wctomb "char *mbchar" "wchar_t wchar" +.Sh DESCRIPTION +The basic elements of some written natural languages such as Chinese +cannot be represented uniquely with single C +.Va char Ns s . +The C standard supports two different ways of dealing with +extended natural language encodings, +.Em wide +characters and +.Em multibyte +characters. +Wide characters are an internal representation +which allows each basic element to map +to a single object of type +.Va wchar_t . +Multibyte characters are used for input and output +and code each basic element as a sequence of C +.Va char Ns s . +Individual basic elements may map into one or more +(up to +.Dv MB_CHAR_MAX ) +bytes in a multibyte character. +.Pp +The current locale +.Pq Xr setlocale 3 +governs the interpretation of wide and multibyte characters. +The locale category +.Dv LC_CTYPE +specifically controls this interpretation. +The +.Va wchar_t +type is wide enough to hold the largest value +in the wide character representations for all locales. +.Pp +Multibyte strings may contain +.Sq shift +indicators to switch to and from +particular modes within the given representation. +If explicit bytes are used to signal shifting, +these are not recognized as separate characters +but are lumped with a neighboring character. +There is always a distinguished +.Sq initial +shift state. +The +.Fn mbstowcs +and +.Fn wcstombs +functions assume that multibyte strings are interpreted +starting from the initial shift state. +The +.Fn mblen , +.Fn mbtowc +and +.Fn wctomb +functions maintain static shift state internally. +A call with a null +.Fa mbchar +pointer returns nonzero if the current locale requires shift states, +zero otherwise; +if shift states are required, the shift state is reset to the initial state. +The internal shift states are undefined after a call to +.Fn setlocale +with the +.Dv LC_CTYPE +or +.Dv LC_ALL +categories. +.Pp +For convenience in processing, +the wide character with value 0 +(the null wide character) +is recognized as the wide character string terminator, +and the character with value 0 +(the null byte) +is recognized as the multibyte character string terminator. +Null bytes are not permitted within multibyte characters. +.Pp +The +.Fn mblen +function computes the length in bytes +of a multibyte character +.Fa mbchar . +Up to +.Fa nbytes +bytes are examined. +.Pp +The +.Fn mbtowc +function converts a multibyte character +.Fa mbchar +into a wide character and stores the result +in the object pointed to by +.Fa wcharp . +Up to +.Fa nbytes +bytes are examined. +.Pp +The +.Fn wctomb +function converts a wide character +.Fa wchar +into a multibyte character and stores +the result in +.Fa mbchar . +The object pointed to by +.Fa mbchar +must be large enough to accommodate the multibyte character. +.Pp +The +.Fn mbstowcs +function converts a multibyte character string +.Fa mbstring +into a wide character string +.Fa wcstring . +No more than +.Fa nwchars +wide characters are stored. +A terminating null wide character is appended if there is room. +.Pp +The +.Fn wcstombs +function converts a wide character string +.Fa wcstring +into a multibyte character string +.Fa mbstring . +Up to +.Fa nbytes +bytes are stored in +.Fa mbstring . +Partial multibyte characters at the end of the string are not stored. +The multibyte character string is null terminated if there is room. +.Sh "RETURN VALUES +If multibyte characters are not supported in the current locale, +all of these functions will return \-1 if characters can be processed, +otherwise 0. +.Pp +If +.Fa mbchar +is +.Dv NULL , +the +.Fn mblen , +.Fn mbtowc +and +.Fn wctomb +functions return nonzero if shift states are supported, +zero otherwise. +If +.Fa mbchar +is valid, +then these functions return +the number of bytes processed in +.Fa mbchar , +or \-1 if no multibyte character +could be recognized or converted. +.Pp +The +.Fn mbstowcs +function returns the number of wide characters converted, +not counting any terminating null wide character. +The +.Fn wcstombs +function returns the number of bytes converted, +not counting any terminating null byte. +If any invalid multibyte characters are encountered, +both functions return \-1. +.Sh "SEE ALSO +.Xr mbrune 3 , +.Xr rune 3 , +.Xr setlocale 3 , +.Xr euc 4 , +.Xr utf2 4 +.Sh STANDARDS +The +.Fn mblen , +.Fn mbstowcs , +.Fn mbtowc , +.Fn wcstombs +and +.Fn wctomb +functions conform to +.St -isoC . +.Sh BUGS +The current implementation does not support shift states. diff --git a/locale/nl_langinfo.3 b/locale/nl_langinfo.3 new file mode 100644 index 0000000..a4ddf96 --- /dev/null +++ b/locale/nl_langinfo.3 @@ -0,0 +1,90 @@ +.\" Copyright (c) 2001 Alexey Zelkin +.\" 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. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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. +.\" +.\" $FreeBSD: src/lib/libc/locale/nl_langinfo.3,v 1.2 2001/09/17 08:18:45 ache Exp $ +.\" +.Dd May 3, 2001 +.Dt NL_LANGINFO 3 +.Os +.Sh NAME +.Nm nl_langinfo +.Nd language information +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In langinfo.h +.Ft char * +.Fn nl_langinfo "nl_item item" +.Sh DESCRIPTION +The +.Fn nl_langinfo +function returns a pointer to a string containing information relevant to +the particular language or cultural area defined in the program's locale. +The manifest constant names and values of +.Fa item +are defined in +.Aq Pa langinfo.h . +.Pp +Calls to +.Fn setlocale +with a category corresponding to the category of +.Fa item , +or to the +category +.Dv LC_ALL , +may overwrite buffer pointed by the return value. +.Sh EXAMPLES +For example: +.Pp +.Dl nl_langinfo(ABDAY_1) +.Pp +would return a pointer to the string +.Qq Li Dom +if the identified language was +Portuguese, and +.Qq Li Sun +if the identified language was English. +.Sh RETURN VALUES +In a locale where langinfo data is not defined, +.Fn nl_langinfo +returns a pointer to the corresponding string in the +.Tn POSIX +locale. +In all locales, +.Fn nl_langinfo +returns a pointer to an empty string if +.Fa item +contains an invalid setting. +.Sh SEE ALSO +.Xr setlocale 3 +.Sh STANDARDS +The +.Fn nl_langinfo +function conforms to +.St -susv2 . +.Sh HISTORY +The +.Fn nl_langinfo +function first appeared in +.Fx 5.0 . diff --git a/locale/nomacros.c b/locale/nomacros.c new file mode 100644 index 0000000..45c0db7 --- /dev/null +++ b/locale/nomacros.c @@ -0,0 +1,9 @@ +/* + * Tell to generate extern versions of all its inline + * functions. The extern versions get called if the system doesn't + * support inlines or the user defines _DONT_USE_CTYPE_INLINE_ + * before including . + */ +#define _EXTERNALIZE_CTYPE_INLINES_ + +#include diff --git a/locale.subproj/none.c b/locale/none.c similarity index 74% rename from locale.subproj/none.c rename to locale/none.c index 8c8c442..4fb7d7e 100644 --- a/locale.subproj/none.c +++ b/locale/none.c @@ -1,25 +1,4 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ -/* +/*- * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * @@ -53,13 +32,17 @@ * 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. + * + * $FreeBSD: src/lib/libc/locale/none.c,v 1.2.8.1 2001/03/05 10:25:03 obrien Exp $ */ +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)none.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ #include #include #include -#include #include rune_t _none_sgetrune __P((const char *, size_t, char const **)); @@ -82,8 +65,6 @@ _none_sgetrune(string, n, result) size_t n; char const **result; { - int c; - if (n < 1) { if (result) *result = string; diff --git a/locale/rune.3 b/locale/rune.3 new file mode 100644 index 0000000..570e73d --- /dev/null +++ b/locale/rune.3 @@ -0,0 +1,277 @@ +.\" Copyright (c) 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Paul Borman at Krystal Technologies. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)rune.3 8.2 (Berkeley) 12/11/93 +.\" $FreeBSD: src/lib/libc/locale/rune.3,v 1.10.2.6 2001/12/14 18:33:54 ru Exp $ +.\" +.Dd December 11, 1993 +.Dt RUNE 3 +.Os +.Sh NAME +.Nm setrunelocale , +.Nm setinvalidrune , +.Nm sgetrune , +.Nm sputrune , +.Nm fgetrune , +.Nm fungetrune , +.Nm fputrune +.Nd rune support for C +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In rune.h +.In errno.h +.Ft int +.Fn setrunelocale "char *locale" +.Ft void +.Fn setinvalidrune "rune_t rune" +.Ft rune_t +.Fn sgetrune "const char *string" "size_t n" "char const **result" +.Ft int +.Fn sputrune "rune_t rune" "char *string" "size_t n" "char **result" +.Pp +.In stdio.h +.Ft long +.Fn fgetrune "FILE *stream" +.Ft int +.Fn fungetrune "rune_t rune" "FILE *stream" +.Ft int +.Fn fputrune "rune_t rune" "FILE *stream" +.Sh DESCRIPTION +The +.Fn setrunelocale +controls the type of encoding used to represent runes as multibyte strings +as well as the properties of the runes as defined in +.Aq Pa ctype.h . +The +.Fa locale +argument indicates which locale to load. +If the locale is successfully loaded, +.Dv 0 +is returned, otherwise an errno value is returned to indicate the +type of error. +.Pp +The +.Fn setinvalidrune +function sets the value of the global value +.Dv _INVALID_RUNE +to be +.Fa rune . +.Pp +The +.Fn sgetrune +function tries to read a single multibyte character from +.Fa string , +which is at most +.Fa n +bytes long. +If +.Fn sgetrune +is successful, the rune is returned. +If +.Fa result +is not +.Dv NULL , +.Fa *result +will point to the first byte which was not converted in +.Fa string . +If the first +.Fa n +bytes of +.Fa string +do not describe a full multibyte character, +.Dv _INVALID_RUNE +is returned and +.Fa *result +will point to +.Fa string . +If there is an encoding error at the start of +.Fa string , +.Dv _INVALID_RUNE +is returned and +.Fa *result +will point to the second character of +.Fa string . +.Pp +the +.Fn sputrune +function tries to encode +.Fa rune +as a multibyte string and store it at +.Fa string , +but no more than +.Fa n +bytes will be stored. +If +.Fa result +is not +.Dv NULL , +.Fa *result +will be set to point to the first byte in string following the new +multibyte character. +If +.Fa string +is +.Dv NULL , +.Fa *result +will point to +.Dv "(char *)0 +" +.Fa x , +where +.Fa x +is the number of bytes that would be needed to store the multibyte value. +If the multibyte character would consist of more than +.Fa n +bytes and +.Fa result +is not +.Dv NULL , +.Fa *result +will be set to +.Dv NULL . +In all cases, +.Fn sputrune +will return the number of bytes which would be needed to store +.Fa rune +as a multibyte character. +.Pp +The +.Fn fgetrune +function operates the same as +.Fn sgetrune +with the exception that it attempts to read enough bytes from +.Fa stream +to decode a single rune. It returns either +.Dv EOF +on end of file, +.Dv _INVALID_RUNE +on an encoding error, or the rune decoded if all went well. +.Pp +The +.Fn fungetrune +function pushes the multibyte encoding, as provided by +.Fn sputrune , +of +.Fa rune +onto +.Fa stream +such that the next +.Fn fgetrune +call will return +.Fa rune . +It returns +.Dv EOF +if it fails and +.Dv 0 +on success. +.Pp +The +.Fn fputrune +function writes the multibyte encoding of +.Fa rune , +as provided by +.Fn sputrune , +onto +.Fa stream . +It returns +.Dv EOF +on failure and +.Dv 0 +on success. +.Sh RETURN VALUES +The +.Fn setrunelocale +function returns one of the following values: +.Bl -tag -width Er +.It Er 0 +.Fn setrunelocale +was successful. +.It Bq Er EFAULT +.Fa locale +was +.Dv NULL . +.It Bq Er ENOENT +The locale could not be found. +.It Bq Er EFTYPE +The file found was not a valid file. +.It Bq Er EINVAL +The encoding indicated by the locale was unknown. +.El +.Pp +The +.Fn sgetrune +function either returns the rune read or +.Dv _INVALID_RUNE . +The +.Fn sputrune +function returns the number of bytes needed to store +.Fa rune +as a multibyte string. +.Sh FILES +.Bl -tag -width /usr/share/locale/locale/LC_CTYPE -compact +.It Pa $PATH_LOCALE/ Ns Em locale Ns /LC_CTYPE +.It Pa /usr/share/locale/ Ns Em locale Ns /LC_CTYPE +binary LC_CTYPE file for the locale +.Em locale . +.El +.Sh SEE ALSO +.Xr mbrune 3 , +.Xr setlocale 3 , +.Xr euc 4 , +.Xr utf2 4 +.Sh NOTES +The ANSI C type +.Em wchar_t +is the same as +.Em rune_t . +.Em Rune_t +was chosen to accent the purposeful choice of not basing the +system with the ANSI C +primitives, which were, shall we say, less aesthetic. +.Sh HISTORY +These functions first appeared in +.Bx 4.4 . +.Pp +The +.Fn setrunelocale +function and the other non-ANSI rune functions were inspired by +.Sy "Plan 9 from Bell Labs" +as a much more sane alternative to the ANSI multibyte and +wide character support. +.\"They were conceived at the San Diego 1993 Summer USENIX conference by +.\"Paul Borman of Krystal Technologies, Keith Bostic of CSRG and Andrew Hume +.\"of Bell Labs. +.Pp +All of the ANSI multibyte and wide character +support functions are built using the rune functions. diff --git a/locale.subproj/rune.c b/locale/rune.c similarity index 56% rename from locale.subproj/rune.c rename to locale/rune.c index 631c815..5531c76 100644 --- a/locale.subproj/rune.c +++ b/locale/rune.c @@ -1,25 +1,4 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ -/* +/*- * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * @@ -53,81 +32,26 @@ * 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. + * + * $FreeBSD: src/lib/libc/locale/rune.c,v 1.5.8.1 2001/03/05 10:26:02 obrien Exp $ */ +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)rune.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ -#include -#include - -#include -#include -#include #include #include +#include #include +#include +#include -extern int _none_init __P((_RuneLocale *)); -extern int _UTF2_init __P((_RuneLocale *)); -extern int _EUC_init __P((_RuneLocale *)); -static _RuneLocale *_Read_RuneMagi __P((FILE *)); - -static char *PathLocale = 0; - -int -setrunelocale(encoding) - char *encoding; -{ - FILE *fp; - char name[PATH_MAX]; - _RuneLocale *rl; - - if (!encoding) - return(EFAULT); - - /* - * The "C" and "POSIX" locale are always here. - */ - if (!strcmp(encoding, "C") || !strcmp(encoding, "POSIX")) { - _CurrentRuneLocale = &_DefaultRuneLocale; - return(0); - } - - if (!PathLocale) - PathLocale = _PATH_LOCALE; - - sprintf(name, "%s/%s/LC_CTYPE", PathLocale, encoding); - - if ((fp = fopen(name, "r")) == NULL) - return(ENOENT); - - if ((rl = _Read_RuneMagi(fp)) == 0) { - fclose(fp); - return(EFTYPE); - } - - if (!rl->encoding[0] || !strcmp(rl->encoding, "UTF2")) { - return(_UTF2_init(rl)); - } else if (!strcmp(rl->encoding, "NONE")) { - return(_none_init(rl)); - } else if (!strcmp(rl->encoding, "EUC")) { - return(_EUC_init(rl)); - } else - return(EINVAL); -} - -void -setinvalidrune(ir) - rune_t ir; -{ - _INVALID_RUNE = ir; -} - -static _RuneLocale * +_RuneLocale * _Read_RuneMagi(fp) FILE *fp; { char *data; - void *np; void *lastp; _RuneLocale *rl; _RuneEntry *rr; @@ -246,107 +170,6 @@ _Read_RuneMagi(fp) if (!rl->mapupper_ext.nranges) rl->mapupper_ext.ranges = 0; - - return(rl); -} -unsigned long -___runetype(c) - _BSD_RUNE_T_ c; -{ - int x; - _RuneRange *rr = &_CurrentRuneLocale->runetype_ext; - _RuneEntry *re = rr->ranges; - - if (c == EOF) - return(0); - for (x = 0; x < rr->nranges; ++x, ++re) { - if (c < re->min) - return(0L); - if (c <= re->max) { - if (re->types) - return(re->types[c - re->min]); - else - return(re->map); - } - } - return(0L); -} - -_BSD_RUNE_T_ -___toupper(c) - _BSD_RUNE_T_ c; -{ - int x; - _RuneRange *rr = &_CurrentRuneLocale->mapupper_ext; - _RuneEntry *re = rr->ranges; - - if (c == EOF) - return(EOF); - for (x = 0; x < rr->nranges; ++x, ++re) { - if (c < re->min) - return(c); - if (c <= re->max) - return(re->map + c - re->min); - } - return(c); -} - -_BSD_RUNE_T_ -___tolower(c) - _BSD_RUNE_T_ c; -{ - int x; - _RuneRange *rr = &_CurrentRuneLocale->maplower_ext; - _RuneEntry *re = rr->ranges; - - if (c == EOF) - return(EOF); - for (x = 0; x < rr->nranges; ++x, ++re) { - if (c < re->min) - return(c); - if (c <= re->max) - return(re->map + c - re->min); - } - return(c); -} - - -#if !defined(_USE_CTYPE_INLINE_) && !defined(_USE_CTYPE_MACROS_) -/* - * See comments in - */ -int -__istype(c, f) - _BSD_RUNE_T_ c; - unsigned long f; -{ - return ((((c & _CRMASK) ? ___runetype(c) - : _CurrentRuneLocale->runetype[c]) & f) ? 1 : 0); -} - -int -__isctype(_BSD_RUNE_T_ c, unsigned long f) - _BSD_RUNE_T_ c; - unsigned long f; -{ - return ((((c & _CRMASK) ? 0 - : _DefaultRuneLocale.runetype[c]) & f) ? 1 : 0); -} - -_BSD_RUNE_T_ -toupper(c) - _BSD_RUNE_T_ c; -{ - return ((c & _CRMASK) ? - ___toupper(c) : _CurrentRuneLocale->mapupper[c]); -} - -_BSD_RUNE_T_ -tolower(c) - _BSD_RUNE_T_ c; -{ - return ((c & _CRMASK) ? - ___tolower(c) : _CurrentRuneLocale->maplower[c]); + return(rl); } -#endif diff --git a/locale/runetype.c b/locale/runetype.c new file mode 100644 index 0000000..9f5228c --- /dev/null +++ b/locale/runetype.c @@ -0,0 +1,65 @@ +/*- + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Paul Borman at Krystal Technologies. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * $FreeBSD: src/lib/libc/locale/runetype.c,v 1.5.8.1 2000/06/04 21:47:39 ache Exp $ + */ + +#include +#include + +unsigned long +___runetype(c) + _BSD_CT_RUNE_T_ c; +{ + int x; + _RuneRange *rr = &_CurrentRuneLocale->runetype_ext; + _RuneEntry *re = rr->ranges; + + if (c < 0 || c == EOF) + return(0L); + + for (x = 0; x < rr->nranges; ++x, ++re) { + if (c < re->min) + return(0L); + if (c <= re->max) { + if (re->types) + return(re->types[c - re->min]); + else + return(re->map); + } + } + + return(0L); +} diff --git a/locale/setinvalidrune.c b/locale/setinvalidrune.c new file mode 100644 index 0000000..45a2a47 --- /dev/null +++ b/locale/setinvalidrune.c @@ -0,0 +1,44 @@ +/*- + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Paul Borman at Krystal Technologies. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + */ + +#include + +void +setinvalidrune(ir) + rune_t ir; +{ + _INVALID_RUNE = ir; +} diff --git a/locale/setlocale.3 b/locale/setlocale.3 new file mode 100644 index 0000000..b0cdfb6 --- /dev/null +++ b/locale/setlocale.3 @@ -0,0 +1,338 @@ +.\" Copyright (c) 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Donn Seeley at BSDI. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)setlocale.3 8.1 (Berkeley) 6/9/93 +.\" $FreeBSD: src/lib/libc/locale/setlocale.3,v 1.15.2.5 2001/12/14 18:33:55 ru Exp $ +.\" +.Dd June 9, 1993 +.Dt SETLOCALE 3 +.Os +.Sh NAME +.Nm setlocale , +.Nm localeconv +.Nd natural language formatting for C +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In locale.h +.Ft char * +.Fn setlocale "int category" "const char *locale" +.Ft struct lconv * +.Fn localeconv "void" +.Sh DESCRIPTION +The +.Fn setlocale +function sets the C library's notion +of natural language formatting style +for particular sets of routines. +Each such style is called a +.Sq locale +and is invoked using an appropriate name passed as a C string. +The +.Fn localeconv +routine returns the current locale's parameters +for formatting numbers. +.Pp +The +.Fn setlocale +function recognizes several categories of routines. +These are the categories and the sets of routines they select: +.Pp +.Bl -tag -width LC_MONETARY +.It Dv LC_ALL +Set the entire locale generically. +.It Dv LC_COLLATE +Set a locale for string collation routines. +This controls alphabetic ordering in +.Fn strcoll +and +.Fn strxfrm . +.It Dv LC_CTYPE +Set a locale for the +.Xr ctype 3 , +.Xr mbrune 3 , +.Xr multibyte 3 +and +.Xr rune 3 +functions. +This controls recognition of upper and lower case, +alphabetic or non-alphabetic characters, +and so on. The real work is done by the +.Fn setrunelocale +function. +.It Dv LC_MESSAGES +Set a locale for message catalogs, see +.Xr catopen 3 +function. +.It Dv LC_MONETARY +Set a locale for formatting monetary values; +this affects the +.Fn localeconv +function. +.It Dv LC_NUMERIC +Set a locale for formatting numbers. +This controls the formatting of decimal points +in input and output of floating point numbers +in functions such as +.Fn printf +and +.Fn scanf , +as well as values returned by +.Fn localeconv . +.It Dv LC_TIME +Set a locale for formatting dates and times using the +.Fn strftime +function. +.El +.Pp +Only three locales are defined by default, +the empty string +.Li "\&""\|"" +which denotes the native environment, and the +.Li "\&""C"" +and +.Li "\&""POSIX"" +locales, which denote the C language environment. +A +.Fa locale +argument of +.Dv NULL +causes +.Fn setlocale +to return the current locale. +By default, C programs start in the +.Li "\&""C"" +locale. +The only function in the library that sets the locale is +.Fn setlocale ; +the locale is never changed as a side effect of some other routine. +.Pp +The +.Fn localeconv +function returns a pointer to a structure +which provides parameters for formatting numbers, +especially currency values: +.Bd -literal -offset indent +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; +}; +.Ed +.Pp +The individual fields have the following meanings: +.Pp +.Bl -tag -width mon_decimal_point +.It Fa decimal_point +The decimal point character, except for currency values. +.It Fa thousands_sep +The separator between groups of digits +before the decimal point, except for currency values. +.It Fa grouping +The sizes of the groups of digits, except for currency values. +This is a pointer to a vector of integers, each of size +.Va char , +representing group size from low order digit groups +to high order (right to left). +The list may be terminated with 0 or +.Dv CHAR_MAX . +If the list is terminated with 0, +the last group size before the 0 is repeated to account for all the digits. +If the list is terminated with +.Dv CHAR_MAX , +no more grouping is performed. +.It Fa int_curr_symbol +The standardized international currency symbol. +.It Fa currency_symbol +The local currency symbol. +.It Fa mon_decimal_point +The decimal point character for currency values. +.It Fa mon_thousands_sep +The separator for digit groups in currency values. +.It Fa mon_grouping +Like +.Fa grouping +but for currency values. +.It Fa positive_sign +The character used to denote nonnegative currency values, +usually the empty string. +.It Fa negative_sign +The character used to denote negative currency values, +usually a minus sign. +.It Fa int_frac_digits +The number of digits after the decimal point +in an international-style currency value. +.It Fa frac_digits +The number of digits after the decimal point +in the local style for currency values. +.It Fa p_cs_precedes +1 if the currency symbol precedes the currency value +for nonnegative values, 0 if it follows. +.It Fa p_sep_by_space +1 if a space is inserted between the currency symbol +and the currency value for nonnegative values, 0 otherwise. +.It Fa n_cs_precedes +Like +.Fa p_cs_precedes +but for negative values. +.It Fa n_sep_by_space +Like +.Fa p_sep_by_space +but for negative values. +.It Fa p_sign_posn +The location of the +.Fa positive_sign +with respect to a nonnegative quantity and the +.Fa currency_symbol , +coded as follows: +.Bl -tag -width 3n -compact +.It Li 0 +Parentheses around the entire string. +.It Li 1 +Before the string. +.It Li 2 +After the string. +.It Li 3 +Just before +.Fa currency_symbol . +.It Li 4 +Just after +.Fa currency_symbol . +.El +.It Fa n_sign_posn +Like +.Fa p_sign_posn +but for negative currency values. +.El +.Pp +Unless mentioned above, +an empty string as a value for a field +indicates a zero length result or +a value that is not in the current locale. +A +.Dv CHAR_MAX +result similarly denotes an unavailable value. +.Sh RETURN VALUES +The +.Fn setlocale +function returns +.Dv NULL +and fails to change the locale +if the given combination of +.Fa category +and +.Fa locale +makes no sense. +The +.Fn localeconv +function returns a pointer to a static object +which may be altered by later calls to +.Fn setlocale +or +.Fn localeconv . +.Sh FILES +.Bl -tag -width /usr/share/locale/locale/category -compact +.It Pa $PATH_LOCALE/ Ns Em locale/category +.It Pa /usr/share/locale/ Ns Em locale/category +locale file for the locale +.Em locale +and the category +.Em category . +.El +.Sh SEE ALSO +.Xr colldef 1 , +.Xr mklocale 1 , +.Xr catopen 3 , +.Xr ctype 3 , +.Xr mbrune 3 , +.Xr multibyte 3 , +.Xr rune 3 , +.Xr strcoll 3 , +.Xr strxfrm 3 , +.Xr euc 4 , +.Xr utf2 4 +.Sh STANDARDS +The +.Fn setlocale +and +.Fn localeconv +functions conform to +.St -isoC . +.Sh HISTORY +The +.Fn setlocale +and +.Fn localeconv +functions first appeared in +.Bx 4.4 . +.Sh BUGS +The current implementation supports only the +.Li "\&""C"" +and +.Li "\&""POSIX"" +locales for all but the +.Dv LC_COLLATE , +.Dv LC_CTYPE , +and +.Dv LC_TIME +categories. +.Pp +In spite of the gnarly currency support in +.Fn localeconv , +the standards don't include any functions +for generalized currency formatting. +.Pp +Use of +.Dv LC_MONETARY +could lead to misleading results until we have a real time currency +conversion function. +.Dv LC_NUMERIC +and +.Dv LC_TIME +are personal choices and should not be wrapped up with the other categories. diff --git a/locale/setlocale.c b/locale/setlocale.c new file mode 100644 index 0000000..3ec6fca --- /dev/null +++ b/locale/setlocale.c @@ -0,0 +1,307 @@ +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Paul Borman at Krystal Technologies. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + */ + +#ifdef LIBC_RCS +static const char rcsid[] = + "$FreeBSD: src/lib/libc/locale/setlocale.c,v 1.25.2.4 2001/03/05 13:08:42 ru Exp $"; +#endif + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)setlocale.c 8.1 (Berkeley) 7/4/93"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "collate.h" +#include "setlocale.h" + +/* + * Category names for getenv() + */ +static char *categories[_LC_LAST] = { + "LC_ALL", + "LC_COLLATE", + "LC_CTYPE", + "LC_MONETARY", + "LC_NUMERIC", + "LC_TIME", + "LC_MESSAGES" +}; + +/* + * Current locales for each category + */ +static char current_categories[_LC_LAST][ENCODING_LEN + 1] = { + "C", + "C", + "C", + "C", + "C", + "C", + "C" +}; + +/* + * The locales we are going to try and load + */ +static char new_categories[_LC_LAST][ENCODING_LEN + 1]; +static char saved_categories[_LC_LAST][ENCODING_LEN + 1]; + +static char current_locale_string[_LC_LAST * (ENCODING_LEN + 1/*"/"*/ + 1)]; + +static char *currentlocale __P((void)); +static char *loadlocale __P((int)); +static int stub_load_locale __P((const char *)); + +extern int __time_load_locale __P((const char *)); /* strftime.c */ + +char * +setlocale(category, locale) + int category; + const char *locale; +{ + int i, j, len; + char *env, *r; + + if (category < LC_ALL || category >= _LC_LAST) + return (NULL); + + if (!locale) + return (category != LC_ALL ? + current_categories[category] : currentlocale()); + + /* + * Default to the current locale for everything. + */ + for (i = 1; i < _LC_LAST; ++i) + (void)strcpy(new_categories[i], current_categories[i]); + + /* + * Now go fill up new_categories from the locale argument + */ + if (!*locale) { + env = getenv("LC_ALL"); + + if (category != LC_ALL && (!env || !*env)) + env = getenv(categories[category]); + + if (!env || !*env) + env = getenv("LANG"); + + if (!env || !*env || strchr(env, '/')) + env = "C"; + + (void) strncpy(new_categories[category], env, ENCODING_LEN); + new_categories[category][ENCODING_LEN] = '\0'; + if (category == LC_ALL) { + for (i = 1; i < _LC_LAST; ++i) { + if (!(env = getenv(categories[i])) || !*env) + env = new_categories[LC_ALL]; + (void)strncpy(new_categories[i], env, ENCODING_LEN); + new_categories[i][ENCODING_LEN] = '\0'; + } + } + } else if (category != LC_ALL) { + (void)strncpy(new_categories[category], locale, ENCODING_LEN); + new_categories[category][ENCODING_LEN] = '\0'; + } else { + if ((r = strchr(locale, '/')) == NULL) { + for (i = 1; i < _LC_LAST; ++i) { + (void)strncpy(new_categories[i], locale, ENCODING_LEN); + new_categories[i][ENCODING_LEN] = '\0'; + } + } else { + for (i = 1; r[1] == '/'; ++r); + if (!r[1]) + return (NULL); /* Hmm, just slashes... */ + do { + len = r - locale > ENCODING_LEN ? ENCODING_LEN : r - locale; + (void)strncpy(new_categories[i], locale, len); + new_categories[i][len] = '\0'; + i++; + locale = r; + while (*locale == '/') + ++locale; + while (*++r && *r != '/'); + } while (*locale); + while (i < _LC_LAST) { + (void)strcpy(new_categories[i], + new_categories[i-1]); + i++; + } + } + } + + if (category) + return (loadlocale(category)); + + for (i = 1; i < _LC_LAST; ++i) { + (void)strcpy(saved_categories[i], current_categories[i]); + if (loadlocale(i) == NULL) { + for (j = 1; j < i; j++) { + (void)strcpy(new_categories[j], + saved_categories[j]); + /* XXX can fail too */ + (void)loadlocale(j); + } + return (NULL); + } + } + return (currentlocale()); +} + +static char * +currentlocale() +{ + int i; + + (void)strcpy(current_locale_string, current_categories[1]); + + for (i = 2; i < _LC_LAST; ++i) + if (strcmp(current_categories[1], current_categories[i])) { + for (i = 2; i < _LC_LAST; ++i) { + (void) strcat(current_locale_string, "/"); + (void) strcat(current_locale_string, current_categories[i]); + } + break; + } + return (current_locale_string); +} + +static char * +loadlocale(category) + int category; +{ + char *ret; + char *new = new_categories[category]; + char *old = current_categories[category]; + + if (_PathLocale == NULL) { + char *p = getenv("PATH_LOCALE"); + + if (p != NULL +#ifndef __NETBSD_SYSCALLS + && !issetugid() +#endif + ) { + if (strlen(p) + 1/*"/"*/ + ENCODING_LEN + + 1/*"/"*/ + CATEGORY_LEN >= PATH_MAX) + return (NULL); + _PathLocale = strdup(p); + if (_PathLocale == NULL) + return (NULL); + } else + _PathLocale = _PATH_LOCALE; + } + + if (strcmp(new, old) == 0) + return (old); + + if (category == LC_CTYPE) { + ret = setrunelocale(new) ? NULL : new; + if (!ret) + (void)setrunelocale(old); + else + (void)strcpy(old, new); + return (ret); + } + + if (category == LC_COLLATE) { + ret = (__collate_load_tables(new) < 0) ? NULL : new; + if (!ret) + (void)__collate_load_tables(old); + else + (void)strcpy(old, new); + return (ret); + } + + if (category == LC_TIME) { + ret = (__time_load_locale(new) < 0) ? NULL : new; + if (!ret) + (void)__time_load_locale(old); + else + (void)strcpy(old, new); + return (ret); + } + + if (category == LC_MONETARY || + category == LC_MESSAGES || + category == LC_NUMERIC) { + ret = stub_load_locale(new) ? NULL : new; + if (!ret) + (void)stub_load_locale(old); + else + (void)strcpy(old, new); + return (ret); + } + + /* Just in case...*/ + return (NULL); +} + +static int +stub_load_locale(encoding) +const char *encoding; +{ + char name[PATH_MAX]; + struct stat st; + + if (!encoding) + return(1); + /* + * The "C" and "POSIX" locale are always here. + */ + if (!strcmp(encoding, "C") || !strcmp(encoding, "POSIX")) + return(0); + if (!_PathLocale) + return(1); + /* Range checking not needed, encoding has fixed size */ + strcpy(name, _PathLocale); + strcat(name, "/"); + strcat(name, encoding); +#if 0 + /* + * Some day we will actually look at this file. + */ +#endif + return (stat(name, &st) != 0 || !S_ISDIR(st.st_mode)); +} diff --git a/locale/setlocale.h b/locale/setlocale.h new file mode 100644 index 0000000..f3b2a22 --- /dev/null +++ b/locale/setlocale.h @@ -0,0 +1,34 @@ +#ifndef _SETLOCALE_H +#define _SETLOCALE_H +/* + * Copyright (C) 1997 by Andrey A. Chernov, Moscow, Russia. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE 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. + */ + +#define ENCODING_LEN 31 +#define CATEGORY_LEN 11 + +extern char *_PathLocale; + +#endif /* SETLOCALE_H */ diff --git a/locale/setrunelocale.c b/locale/setrunelocale.c new file mode 100644 index 0000000..509fac2 --- /dev/null +++ b/locale/setrunelocale.c @@ -0,0 +1,121 @@ +/*- + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Paul Borman at Krystal Technologies. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * $FreeBSD: src/lib/libc/locale/setrunelocale.c,v 1.14.6.1 2000/06/04 21:47:39 ache Exp $ + */ + +#include +#include +#include +#include +#include +#include +#include +#include "setlocale.h" + +extern int _none_init __P((_RuneLocale *)); +extern int _UTF2_init __P((_RuneLocale *)); +extern int _EUC_init __P((_RuneLocale *)); +extern int _BIG5_init __P((_RuneLocale *)); +extern int _MSKanji_init __P((_RuneLocale *)); +extern _RuneLocale *_Read_RuneMagi __P((FILE *)); + +int +setrunelocale(encoding) + char *encoding; +{ + FILE *fp; + char name[PATH_MAX]; + _RuneLocale *rl; + + if (!encoding || strlen(encoding) > ENCODING_LEN) + return(EFAULT); + + /* + * The "C" and "POSIX" locale are always here. + */ + if (!strcmp(encoding, "C") || !strcmp(encoding, "POSIX")) { + _CurrentRuneLocale = &_DefaultRuneLocale; + return(0); + } + + if (_PathLocale == NULL) { + char *p = getenv("PATH_LOCALE"); + + if (p != NULL +#ifndef __NETBSD_SYSCALLS + && !issetugid() +#endif + ) { + if (strlen(p) + 1/*"/"*/ + ENCODING_LEN + + 1/*"/"*/ + CATEGORY_LEN >= PATH_MAX) + return(EFAULT); + _PathLocale = strdup(p); + if (_PathLocale == NULL) + return (errno); + } else + _PathLocale = _PATH_LOCALE; + } + /* Range checking not needed, encoding length already checked above */ + (void) strcpy(name, _PathLocale); + (void) strcat(name, "/"); + (void) strcat(name, encoding); + (void) strcat(name, "/LC_CTYPE"); + + if ((fp = fopen(name, "r")) == NULL) + return(ENOENT); + + if ((rl = _Read_RuneMagi(fp)) == 0) { + fclose(fp); + return(EFTYPE); + } + fclose(fp); + + if (!rl->encoding[0]) + return(EINVAL); + else if (!strcmp(rl->encoding, "NONE")) + return(_none_init(rl)); + else if (!strcmp(rl->encoding, "UTF2")) + return(_UTF2_init(rl)); + else if (!strcmp(rl->encoding, "EUC")) + return(_EUC_init(rl)); + else if (!strcmp(rl->encoding, "BIG5")) + return(_BIG5_init(rl)); + else if (!strcmp(rl->encoding, "MSKanji")) + return(_MSKanji_init(rl)); + else + return(EINVAL); +} + diff --git a/locale.subproj/runetable.c b/locale/table.c similarity index 55% rename from locale.subproj/runetable.c rename to locale/table.c index 3d6df8a..4771c56 100644 --- a/locale.subproj/runetable.c +++ b/locale/table.c @@ -1,25 +1,4 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ -/* +/*- * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * @@ -53,10 +32,13 @@ * 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. + * + * $FreeBSD: src/lib/libc/locale/table.c,v 1.13.2.1 2000/06/04 21:47:39 ache Exp $ */ - -#include +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)table.c 8.1 (Berkeley) 6/27/93"; +#endif /* LIBC_SCCS and not lint */ #include #include @@ -65,45 +47,141 @@ extern rune_t _none_sgetrune __P((const char *, size_t, char const **)); extern int _none_sputrune __P((rune_t, char *, size_t, char **)); extern int _none_init __P((char *, char **)); -const _RuneLocale _DefaultRuneLocale = { +_RuneLocale _DefaultRuneLocale = { _RUNE_MAGIC_1, - "none", + "NONE", _none_sgetrune, _none_sputrune, 0xFFFD, - { /*00*/ _C, _C, _C, _C, - _C, _C, _C, _C, - /*08*/ _C, _C|_S|_B, _C|_S, _C|_S, - _C|_S, _C|_S, _C, _C, - /*10*/ _C, _C, _C, _C, - _C, _C, _C, _C, - /*18*/ _C, _C, _C, _C, - _C, _C, _C, _C, - /*20*/ _S|_B|_R, _P|_R|_G, _P|_R|_G, _P|_R|_G, - _P|_R|_G, _P|_R|_G, _P|_R|_G, _P|_R|_G, - /*28*/ _P|_R|_G, _P|_R|_G, _P|_R|_G, _P|_R|_G, - _P|_R|_G, _P|_R|_G, _P|_R|_G, _P|_R|_G, - /*30*/ _D|_R|_G|_X|0, _D|_R|_G|_X|1, _D|_R|_G|_X|2, _D|_R|_G|_X|3, - _D|_R|_G|_X|4, _D|_R|_G|_X|5, _D|_R|_G|_X|6, _D|_R|_G|_X|7, - /*38*/ _D|_R|_G|_X|8, _D|_R|_G|_X|9, _P|_R|_G, _P|_R|_G, - _P|_R|_G, _P|_R|_G, _P|_R|_G, _P|_R|_G, - /*40*/ _P|_R|_G, _U|_X|_R|_G|_A|10, _U|_X|_R|_G|_A|11, _U|_X|_R|_G|_A|12, - _U|_X|_R|_G|_A|13, _U|_X|_R|_G|_A|14, _U|_X|_R|_G|_A|15, _U|_R|_G|_A, - /*48*/ _U|_R|_G|_A, _U|_R|_G|_A, _U|_R|_G|_A, _U|_R|_G|_A, - _U|_R|_G|_A, _U|_R|_G|_A, _U|_R|_G|_A, _U|_R|_G|_A, - /*50*/ _U|_R|_G|_A, _U|_R|_G|_A, _U|_R|_G|_A, _U|_R|_G|_A, - _U|_R|_G|_A, _U|_R|_G|_A, _U|_R|_G|_A, _U|_R|_G|_A, - /*58*/ _U|_R|_G|_A, _U|_R|_G|_A, _U|_R|_G|_A, _P|_R|_G, - _P|_R|_G, _P|_R|_G, _P|_R|_G, _P|_R|_G, - /*60*/ _P|_R|_G, _L|_X|_R|_G|_A|10, _L|_X|_R|_G|_A|11, _L|_X|_R|_G|_A|12, - _L|_X|_R|_G|_A|13, _L|_X|_R|_G|_A|14, _L|_X|_R|_G|_A|15, _L|_R|_G|_A, - /*68*/ _L|_R|_G|_A, _L|_R|_G|_A, _L|_R|_G|_A, _L|_R|_G|_A, - _L|_R|_G|_A, _L|_R|_G|_A, _L|_R|_G|_A, _L|_R|_G|_A, - /*70*/ _L|_R|_G|_A, _L|_R|_G|_A, _L|_R|_G|_A, _L|_R|_G|_A, - _L|_R|_G|_A, _L|_R|_G|_A, _L|_R|_G|_A, _L|_R|_G|_A, - /*78*/ _L|_R|_G|_A, _L|_R|_G|_A, _L|_R|_G|_A, _P|_R|_G, - _P|_R|_G, _P|_R|_G, _P|_R|_G, _C, + { /*00*/ _CTYPE_C, + _CTYPE_C, + _CTYPE_C, + _CTYPE_C, + _CTYPE_C, + _CTYPE_C, + _CTYPE_C, + _CTYPE_C, + /*08*/ _CTYPE_C, + _CTYPE_C|_CTYPE_S|_CTYPE_B, + _CTYPE_C|_CTYPE_S, + _CTYPE_C|_CTYPE_S, + _CTYPE_C|_CTYPE_S, + _CTYPE_C|_CTYPE_S, + _CTYPE_C, + _CTYPE_C, + /*10*/ _CTYPE_C, + _CTYPE_C, + _CTYPE_C, + _CTYPE_C, + _CTYPE_C, + _CTYPE_C, + _CTYPE_C, + _CTYPE_C, + /*18*/ _CTYPE_C, + _CTYPE_C, + _CTYPE_C, + _CTYPE_C, + _CTYPE_C, + _CTYPE_C, + _CTYPE_C, + _CTYPE_C, + /*20*/ _CTYPE_S|_CTYPE_B|_CTYPE_R, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + /*28*/ _CTYPE_P|_CTYPE_R|_CTYPE_G, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + /*30*/ _CTYPE_D|_CTYPE_R|_CTYPE_G|_CTYPE_X|0, + _CTYPE_D|_CTYPE_R|_CTYPE_G|_CTYPE_X|1, + _CTYPE_D|_CTYPE_R|_CTYPE_G|_CTYPE_X|2, + _CTYPE_D|_CTYPE_R|_CTYPE_G|_CTYPE_X|3, + _CTYPE_D|_CTYPE_R|_CTYPE_G|_CTYPE_X|4, + _CTYPE_D|_CTYPE_R|_CTYPE_G|_CTYPE_X|5, + _CTYPE_D|_CTYPE_R|_CTYPE_G|_CTYPE_X|6, + _CTYPE_D|_CTYPE_R|_CTYPE_G|_CTYPE_X|7, + /*38*/ _CTYPE_D|_CTYPE_R|_CTYPE_G|_CTYPE_X|8, + _CTYPE_D|_CTYPE_R|_CTYPE_G|_CTYPE_X|9, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + /*40*/ _CTYPE_P|_CTYPE_R|_CTYPE_G, + _CTYPE_U|_CTYPE_X|_CTYPE_R|_CTYPE_G|_CTYPE_A|10, + _CTYPE_U|_CTYPE_X|_CTYPE_R|_CTYPE_G|_CTYPE_A|11, + _CTYPE_U|_CTYPE_X|_CTYPE_R|_CTYPE_G|_CTYPE_A|12, + _CTYPE_U|_CTYPE_X|_CTYPE_R|_CTYPE_G|_CTYPE_A|13, + _CTYPE_U|_CTYPE_X|_CTYPE_R|_CTYPE_G|_CTYPE_A|14, + _CTYPE_U|_CTYPE_X|_CTYPE_R|_CTYPE_G|_CTYPE_A|15, + _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, + /*48*/ _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, + /*50*/ _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, + /*58*/ _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_U|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + /*60*/ _CTYPE_P|_CTYPE_R|_CTYPE_G, + _CTYPE_L|_CTYPE_X|_CTYPE_R|_CTYPE_G|_CTYPE_A|10, + _CTYPE_L|_CTYPE_X|_CTYPE_R|_CTYPE_G|_CTYPE_A|11, + _CTYPE_L|_CTYPE_X|_CTYPE_R|_CTYPE_G|_CTYPE_A|12, + _CTYPE_L|_CTYPE_X|_CTYPE_R|_CTYPE_G|_CTYPE_A|13, + _CTYPE_L|_CTYPE_X|_CTYPE_R|_CTYPE_G|_CTYPE_A|14, + _CTYPE_L|_CTYPE_X|_CTYPE_R|_CTYPE_G|_CTYPE_A|15, + _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, + /*68*/ _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, + /*70*/ _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, + /*78*/ _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_L|_CTYPE_R|_CTYPE_G|_CTYPE_A, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + _CTYPE_P|_CTYPE_R|_CTYPE_G, + _CTYPE_C, }, { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, @@ -176,3 +254,5 @@ const _RuneLocale _DefaultRuneLocale = { _RuneLocale *_CurrentRuneLocale = &_DefaultRuneLocale; int __mb_cur_max = 1; + +char *_PathLocale; diff --git a/locale/toascii.3 b/locale/toascii.3 new file mode 100644 index 0000000..82099ef --- /dev/null +++ b/locale/toascii.3 @@ -0,0 +1,72 @@ +.\" Copyright (c) 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)toascii.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/locale/toascii.3,v 1.4.2.2 2001/12/14 18:33:55 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt TOASCII 3 +.Os +.Sh NAME +.Nm toascii +.Nd convert a byte to 7-bit ASCII +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In ctype.h +.Ft int +.Fn toascii "int c" +.Sh DESCRIPTION +The +.Fn toascii +function strips all but the low 7 bits from a letter, +including parity or other marker bits. +.Sh RETURN VALUES +The +.Fn toascii +function always returns a valid ASCII character. +.Sh SEE ALSO +.Xr isalnum 3 , +.Xr isalpha 3 , +.Xr isascii 3 , +.Xr iscntrl 3 , +.Xr isdigit 3 , +.Xr isgraph 3 , +.Xr islower 3 , +.Xr isprint 3 , +.Xr ispunct 3 , +.Xr isspace 3 , +.Xr isupper 3 , +.Xr isxdigit 3 , +.Xr stdio 3 , +.Xr tolower 3 , +.Xr toupper 3 , +.Xr ascii 7 diff --git a/locale/tolower.3 b/locale/tolower.3 new file mode 100644 index 0000000..761948c --- /dev/null +++ b/locale/tolower.3 @@ -0,0 +1,92 @@ +.\" Copyright (c) 1989, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)tolower.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/locale/tolower.3,v 1.6.2.4 2001/12/14 18:33:55 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt TOLOWER 3 +.Os +.Sh NAME +.Nm tolower +.Nd upper case to lower case letter conversion +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In ctype.h +.Ft int +.Fn tolower "int c" +.Sh DESCRIPTION +The +.Fn tolower +function converts an upper-case letter to the corresponding lower-case +letter. +For single C +.Va char Ns s +locales (see +.Xr multibyte 3 ) +the value of the argument is +representable as an +.Li unsigned char +or the value of +.Dv EOF . +.Sh RETURN VALUES +If the argument is an upper-case letter, the +.Fn tolower +function returns the corresponding lower-case letter if there is +one; otherwise the argument is returned unchanged. +.Sh SEE ALSO +.Xr isalnum 3 , +.Xr isalpha 3 , +.Xr isascii 3 , +.Xr iscntrl 3 , +.Xr isdigit 3 , +.Xr isgraph 3 , +.Xr islower 3 , +.Xr isprint 3 , +.Xr ispunct 3 , +.Xr isspace 3 , +.Xr isupper 3 , +.Xr isxdigit 3 , +.Xr multibyte 3 , +.Xr stdio 3 , +.Xr toascii 3 , +.Xr toupper 3 , +.Xr ascii 7 +.Sh STANDARDS +The +.Fn tolower +function conforms to +.St -isoC . diff --git a/locale/tolower.c b/locale/tolower.c new file mode 100644 index 0000000..3ed1840 --- /dev/null +++ b/locale/tolower.c @@ -0,0 +1,61 @@ +/*- + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Paul Borman at Krystal Technologies. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * $FreeBSD: src/lib/libc/locale/tolower.c,v 1.5.8.1 2000/06/04 21:47:39 ache Exp $ + */ + +#include +#include + +_BSD_CT_RUNE_T_ +___tolower(c) + _BSD_CT_RUNE_T_ c; +{ + int x; + _RuneRange *rr = &_CurrentRuneLocale->maplower_ext; + _RuneEntry *re = rr->ranges; + + if (c < 0 || c == EOF) + return(c); + + for (x = 0; x < rr->nranges; ++x, ++re) { + if (c < re->min) + return(c); + if (c <= re->max) + return(re->map + c - re->min); + } + + return(c); +} diff --git a/locale/toupper.3 b/locale/toupper.3 new file mode 100644 index 0000000..e4edd22 --- /dev/null +++ b/locale/toupper.3 @@ -0,0 +1,92 @@ +.\" Copyright (c) 1989, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)toupper.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/locale/toupper.3,v 1.5.2.5 2001/12/14 18:33:55 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt TOUPPER 3 +.Os +.Sh NAME +.Nm toupper +.Nd lower case to upper case letter conversion +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In ctype.h +.Ft int +.Fn toupper "int c" +.Sh DESCRIPTION +The +.Fn toupper +function converts a lower-case letter to the corresponding +upper-case letter. +For single C +.Va char Ns s +locales (see +.Xr multibyte 3 ) +the value of the argument is +representable as an +.Li unsigned char +or the value of +.Dv EOF . +.Sh RETURN VALUES +If the argument is a lower-case letter, the +.Fn toupper +function returns the corresponding upper-case letter if there is +one; otherwise the argument is returned unchanged. +.Sh SEE ALSO +.Xr isalnum 3 , +.Xr isalpha 3 , +.Xr isascii 3 , +.Xr iscntrl 3 , +.Xr isdigit 3 , +.Xr isgraph 3 , +.Xr islower 3 , +.Xr isprint 3 , +.Xr ispunct 3 , +.Xr isspace 3 , +.Xr isupper 3 , +.Xr isxdigit 3 , +.Xr multibyte 3 , +.Xr stdio 3 , +.Xr toascii 3 , +.Xr tolower 3 , +.Xr ascii 7 +.Sh STANDARDS +The +.Fn toupper +function conforms to +.St -isoC . diff --git a/locale/toupper.c b/locale/toupper.c new file mode 100644 index 0000000..9fbe9d7 --- /dev/null +++ b/locale/toupper.c @@ -0,0 +1,61 @@ +/*- + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Paul Borman at Krystal Technologies. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * $FreeBSD: src/lib/libc/locale/toupper.c,v 1.5.8.1 2000/06/04 21:47:39 ache Exp $ + */ + +#include +#include + +_BSD_CT_RUNE_T_ +___toupper(c) + _BSD_CT_RUNE_T_ c; +{ + int x; + _RuneRange *rr = &_CurrentRuneLocale->mapupper_ext; + _RuneEntry *re = rr->ranges; + + if (c < 0 || c == EOF) + return(c); + + for (x = 0; x < rr->nranges; ++x, ++re) { + if (c < re->min) + return(c); + if (c <= re->max) + return(re->map + c - re->min); + } + + return(c); +} diff --git a/locale/utf2.4 b/locale/utf2.4 new file mode 100644 index 0000000..3b81b9c --- /dev/null +++ b/locale/utf2.4 @@ -0,0 +1,88 @@ +.\" Copyright (c) 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Paul Borman at Krystal Technologies. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)utf2.4 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/locale/utf2.4,v 1.8.2.1 2001/03/06 16:45:58 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt UTF2 4 +.Os +.Sh NAME +.Nm utf2 +.Nd "Universal character set Transformation Format encoding of runes +.Sh SYNOPSIS +.Nm ENCODING +.Qq UTF2 +.Sh DESCRIPTION +The +.Nm UTF2 +encoding is based on a proposed X-Open multibyte +\s-1FSS-UCS-TF\s+1 (File System Safe Universal Character Set Transformation Format) encoding as used in +.Sy "Plan 9 from Bell Labs" . +Although it is capable of representing more than 16 bits, +the current implementation is limited to 16 bits as defined by the +Unicode Standard. +.Pp +.Nm UTF2 +representation is backwards compatible with ASCII, so 0x00-0x7f refer to the +ASCII character set. The multibyte encoding of runes between 0x0080 and 0xffff +consist entirely of bytes whose high order bit is set. The actual +encoding is represented by the following table: +.Bd -literal +[0x0000 - 0x007f] [00000000.0bbbbbbb] -> 0bbbbbbb +[0x0080 - 0x07ff] [00000bbb.bbbbbbbb] -> 110bbbbb, 10bbbbbb +[0x0800 - 0xffff] [bbbbbbbb.bbbbbbbb] -> 1110bbbb, 10bbbbbb, 10bbbbbb +.Ed +.Pp +If more than a single representation of a value exists (for example, +0x00; 0xC0 0x80; 0xE0 0x80 0x80) the shortest representation is always +used (but the longer ones will be correctly decoded). +.Pp +The final three encodings provided by X-Open: +.Bd -literal +[00000000.000bbbbb.bbbbbbbb.bbbbbbbb] -> + 11110bbb, 10bbbbbb, 10bbbbbb, 10bbbbbb + +[000000bb.bbbbbbbb.bbbbbbbb.bbbbbbbb] -> + 111110bb, 10bbbbbb, 10bbbbbb, 10bbbbbb, 10bbbbbb + +[0bbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb] -> + 1111110b, 10bbbbbb, 10bbbbbb, 10bbbbbb, 10bbbbbb, 10bbbbbb +.Ed +.Pp +which provides for the entire proposed ISO-10646 31 bit standard are currently +not implemented. +.Sh "SEE ALSO" +.Xr mklocale 1 , +.Xr setlocale 3 diff --git a/locale.subproj/utf2.c b/locale/utf2.c similarity index 80% rename from locale.subproj/utf2.c rename to locale/utf2.c index 1d4a69f..5219434 100644 --- a/locale.subproj/utf2.c +++ b/locale/utf2.c @@ -1,25 +1,4 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ -/* +/*- * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * @@ -53,10 +32,14 @@ * 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. + * + * $FreeBSD: src/lib/libc/locale/utf2.c,v 1.3.2.2 2001/03/05 10:27:18 obrien Exp $ */ +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)utf2.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ -#include #include #include #include @@ -65,7 +48,7 @@ rune_t _UTF2_sgetrune __P((const char *, size_t, char const **)); int _UTF2_sputrune __P((rune_t, char *, size_t, char **)); -static _utf_count[16] = { +static int _utf_count[16] = { 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 2, 2, 3, 0, }; diff --git a/mach.subproj/Makefile b/mach.subproj/Makefile deleted file mode 100644 index 68ed0b6..0000000 --- a/mach.subproj/Makefile +++ /dev/null @@ -1,65 +0,0 @@ -# -# Generated by the Apple Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = mach - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -HFILES = externs.h - -OTHERLINKED = mach_traps.s - -CFILES = clock_sleep.c error_codes.c exc_catcher.c exc_catcher_state.c\ - exc_catcher_state_identity.c fprintf_stderr.c mach_error.c\ - mach_error_string.c mach_init.c mach_init_ports.c mach_msg.c\ - mach_msg_destroy.c mach_msg_receive.c mach_msg_send.c\ - mach_msg_server.c mach_subsystem_join.c mig_allocate.c\ - mig_deallocate.c mig_reply_setup.c mig_strncpy.c\ - ms_thread_switch.c panic.c port_obj.c sbrk.c semaphore.c\ - slot_name.c mach_absolute_time.c - -SUBPROJECTS = headers.subproj servers.subproj - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble\ - bootstrap.defs clock.defs clock_reply.defs err_ipc.sub\ - err_kern.sub err_mach_ipc.sub err_server.sub err_us.sub\ - exc.defs ledger.defs mach_port.defs notify.defs\ - clock_priv.defs host_priv.defs host_security.defs\ - lock_set.defs processor.defs processor_set.defs task.defs\ - thread_act.defs vm_map.defs mach_host.defs - -OTHERLINKEDOFILES = mach_traps.o - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - - - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/mach.subproj/Makefile.postamble b/mach.subproj/Makefile.postamble deleted file mode 100644 index e69de29..0000000 diff --git a/mach.subproj/Makefile.preamble b/mach.subproj/Makefile.preamble deleted file mode 100644 index c8f3ba4..0000000 --- a/mach.subproj/Makefile.preamble +++ /dev/null @@ -1,37 +0,0 @@ -PUBLIC_HDR_INSTALL_DIR = /usr/include -PRIVATE_HDR_INSTALL_DIR = $(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/Versions/B/PrivateHeaders -PUBLIC_HEADER_DIR_SUFFIX = /mach -PRIVATE_HEADER_DIR_SUFFIX = /mach -OTHER_PUBLIC_HEADERS = bootstrap.h \ - clock.h \ - clock_priv.h \ - mach_host.h \ - host_priv.h \ - host_security.h \ - ledger.h \ - lock_set.h \ - processor.h \ - processor_set.h \ - task.h \ - thread_act.h \ - vm_map.h \ - mach_port.h -OTHER_PROJECT_HEADERS = lock_set.h vm_map.h -OTHER_OFILES = excUser.o \ - excServer.o \ - ledgerUser.o \ - notifyUser.o \ - processorUser.o \ - processor_setUser.o \ - taskUser.o \ - vm_mapUser.o \ - thread_actUser.o \ - bootstrapUser.o \ - lock_setUser.o \ - mach_portUser.o \ - clockUser.o \ - clock_privUser.o \ - mach_hostUser.o \ - host_privUser.o \ - host_securityUser.o - diff --git a/mach.subproj/PB.project b/mach.subproj/PB.project deleted file mode 100644 index 9a4126c..0000000 --- a/mach.subproj/PB.project +++ /dev/null @@ -1,78 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - H_FILES = (externs.h); - OTHER_LINKED = ( - clock_sleep.c, - error_codes.c, - exc_catcher.c, - exc_catcher_state.c, - exc_catcher_state_identity.c, - fprintf_stderr.c, - mach_error.c, - mach_error_string.c, - mach_init.c, - mach_init_ports.c, - mach_msg.c, - mach_msg_destroy.c, - mach_msg_receive.c, - mach_msg_send.c, - mach_msg_server.c, - mach_subsystem_join.c, - mach_traps.s, - mig_allocate.c, - mig_deallocate.c, - mig_reply_setup.c, - mig_strncpy.c, - ms_thread_switch.c, - panic.c, - port_obj.c, - sbrk.c, - semaphore.c, - slot_name.c, - mach_absolute_time.c - ); - OTHER_SOURCES = ( - Makefile.preamble, - Makefile, - Makefile.postamble, - bootstrap.defs, - clock.defs, - clock_reply.defs, - err_ipc.sub, - err_kern.sub, - err_mach_ipc.sub, - err_server.sub, - err_us.sub, - exc.defs, - ledger.defs, - mach_port.defs, - notify.defs, - clock_priv.defs, - host_priv.defs, - host_security.defs, - lock_set.defs, - processor.defs, - processor_set.defs, - task.defs, - thread_act.defs, - vm_map.defs, - mach_host.defs - ); - SUBPROJECTS = (headers.subproj, servers.subproj); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = mach; - PROJECTTYPE = Component; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/mach.subproj/headers.subproj/Makefile b/mach.subproj/headers.subproj/Makefile deleted file mode 100644 index f82584e..0000000 --- a/mach.subproj/headers.subproj/Makefile +++ /dev/null @@ -1,53 +0,0 @@ -# -# Generated by the Apple Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = headers - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -HFILES = errorlib.h mach.h mach_error.h mach_init.h mach_interface.h\ - mig_errors.h port_obj.h sync.h vm_task.h - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -NEXTSTEP_INSTALLDIR = /Local/Developer/System -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - -PUBLIC_HEADERS = errorlib.h mach.h mach_error.h mach_init.h\ - mig_errors.h port_obj.h mach_interface.h sync.h - - - -NEXTSTEP_BUILD_OUTPUT_DIR = /Local/Public/Sandbox/$(USER)/BUILD/$(NAME) - -NEXTSTEP_PUBLIC_HEADERS_DIR = /usr/include - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/mach.subproj/headers.subproj/Makefile.postamble b/mach.subproj/headers.subproj/Makefile.postamble deleted file mode 100644 index 411cde6..0000000 --- a/mach.subproj/headers.subproj/Makefile.postamble +++ /dev/null @@ -1,100 +0,0 @@ -############################################################################### -# Makefile.postamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile, which is imported after all other makefiles, to -# override attributes for a project's Makefile environment. This allows you -# to take advantage of the environment set up by the other Makefiles. -# You can also define custom rules at the end of this file. -# -############################################################################### -# -# These variables are exported by the standard makefiles and can be -# used in any customizations you make. They are *outputs* of -# the Makefiles and should be used, not set. -# -# PRODUCTS: products to install. All of these products will be placed in -# the directory $(DSTROOT)$(INSTALLDIR) -# GLOBAL_RESOURCE_DIR: The directory to which resources are copied. -# LOCAL_RESOURCE_DIR: The directory to which localized resources are copied. -# OFILE_DIR: Directory into which .o object files are generated. -# DERIVED_SRC_DIR: Directory used for all other derived files -# -# ALL_CFLAGS: flags to pass when compiling .c files -# ALL_MFLAGS: flags to pass when compiling .m files -# ALL_CCFLAGS: flags to pass when compiling .cc, .cxx, and .C files -# ALL_MMFLAGS: flags to pass when compiling .mm, .mxx, and .M files -# ALL_PRECOMPFLAGS: flags to pass when precompiling .h files -# ALL_LDFLAGS: flags to pass when linking object files -# ALL_LIBTOOL_FLAGS: flags to pass when libtooling object files -# ALL_PSWFLAGS: flags to pass when processing .psw and .pswm (pswrap) files -# ALL_RPCFLAGS: flags to pass when processing .rpc (rpcgen) files -# ALL_YFLAGS: flags to pass when processing .y (yacc) files -# ALL_LFLAGS: flags to pass when processing .l (lex) files -# -# NAME: name of application, bundle, subproject, palette, etc. -# LANGUAGES: langages in which the project is written (default "English") -# English_RESOURCES: localized resources (e.g. nib's, images) of project -# GLOBAL_RESOURCES: non-localized resources of project -# -# SRCROOT: base directory in which to place the new source files -# SRCPATH: relative path from SRCROOT to present subdirectory -# -# INSTALLDIR: Directory the product will be installed into by 'install' target -# PUBLIC_HDR_INSTALLDIR: where to install public headers. Don't forget -# to prefix this with DSTROOT when you use it. -# PRIVATE_HDR_INSTALLDIR: where to install private headers. Don't forget -# to prefix this with DSTROOT when you use it. -# -# EXECUTABLE_EXT: Executable extension for the platform (i.e. .exe on Windows) -# -############################################################################### - -# Some compiler flags can be overridden here for certain build situations. -# -# WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost) -# DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults -# to -g) -# DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG) -# OPTIMIZE_BUILD_CFLAGS: flags passed during optimized builds (defaults -# to -O) -# PROFILE_BUILD_CFLAGS: flags passed during profile builds (defaults -# to -pg -DPROFILE) -# LOCAL_DIR_INCLUDE_DIRECTIVE: flag used to add current directory to -# the include path (defaults to -I.) -# DEBUG_BUILD_LDFLAGS, OPTIMIZE_BUILD_LDFLAGS, PROFILE_BUILD_LDFLAGS: flags -# passed to ld/libtool (defaults to nothing) - - -# Library and Framework projects only: -# INSTALL_NAME_DIRECTIVE: This directive ensures that executables linked -# against the framework will run against the correct version even if -# the current version of the framework changes. You may override this -# to "" as an alternative to using the DYLD_LIBRARY_PATH during your -# development cycle, but be sure to restore it before installing. - - -# Ownership and permissions of files installed by 'install' target - -#INSTALL_AS_USER = root - # User/group ownership -#INSTALL_AS_GROUP = wheel - # (probably want to set both of these) -#INSTALL_PERMISSIONS = - # If set, 'install' chmod's executable to this - - -# Options to strip. Note: -S strips debugging symbols (executables can be stripped -# down further with -x or, if they load no bundles, with no options at all). - -#STRIPFLAGS = -S - - -######################################################################### -# Put rules to extend the behavior of the standard Makefiles here. Include them in -# the dependency tree via cvariables like AFTER_INSTALL in the Makefile.preamble. -# -# You should avoid redefining things like "install" or "app", as they are -# owned by the top-level Makefile API and no context has been set up for where -# derived files should go. -# diff --git a/mach.subproj/headers.subproj/Makefile.preamble b/mach.subproj/headers.subproj/Makefile.preamble deleted file mode 100644 index 817860a..0000000 --- a/mach.subproj/headers.subproj/Makefile.preamble +++ /dev/null @@ -1 +0,0 @@ -PUBLIC_HEADER_DIR_SUFFIX = /mach diff --git a/mach.subproj/headers.subproj/PB.project b/mach.subproj/headers.subproj/PB.project deleted file mode 100644 index 7448712..0000000 --- a/mach.subproj/headers.subproj/PB.project +++ /dev/null @@ -1,45 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - H_FILES = ( - errorlib.h, - mach.h, - mach_error.h, - mach_init.h, - mach_interface.h, - mig_errors.h, - port_obj.h, - sync.h, - vm_task.h - ); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble); - PUBLIC_HEADERS = ( - errorlib.h, - mach.h, - mach_error.h, - mach_init.h, - mig_errors.h, - port_obj.h, - mach_interface.h, - sync.h - ); - SUBPROJECTS = (); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDDIR = "/Local/Public/Sandbox/$(USER)/BUILD/$(NAME)"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_INSTALLDIR = /Local/Developer/System; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - NEXTSTEP_PUBLICHEADERSDIR = /usr/include; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = headers; - PROJECTTYPE = Component; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/mach.subproj/headers.subproj/mig_errors.h b/mach.subproj/headers.subproj/mig_errors.h deleted file mode 100644 index 2344e84..0000000 --- a/mach.subproj/headers.subproj/mig_errors.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 1996 1995 by Open Software Foundation, Inc. 1997 1996 1995 1994 1993 1992 1991 - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* - * MkLinux - */ - -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ - -/* - * Mach Interface Generator errors - * - */ - -#ifndef _MACH_MIG_ERRORS_H_ -#define _MACH_MIG_ERRORS_H_ - -#include -#include -#include -#include - -/* - * These error codes should be specified as system 4, subsytem 2. - * But alas backwards compatibility makes that impossible. - * The problem is old clients of new servers (eg, the kernel) - * which get strange large error codes when there is a Mig problem - * in the server. Unfortunately, the IPC system doesn't have - * the knowledge to convert the codes in this situation. - */ - -#define MIG_TYPE_ERROR -300 /* client type check failure */ -#define MIG_REPLY_MISMATCH -301 /* wrong reply message ID */ -#define MIG_REMOTE_ERROR -302 /* server detected error */ -#define MIG_BAD_ID -303 /* bad request message ID */ -#define MIG_BAD_ARGUMENTS -304 /* server type check failure */ -#define MIG_NO_REPLY -305 /* no reply should be send */ -#define MIG_EXCEPTION -306 /* server raised exception */ -#define MIG_ARRAY_TOO_LARGE -307 /* array not large enough */ -#define MIG_SERVER_DIED -308 /* server died */ -#define MIG_TRAILER_ERROR -309 /* trailer has an unknown format */ - -#include - -typedef struct { - mach_msg_header_t Head; - NDR_record_t NDR; - kern_return_t RetCode; -} mig_reply_error_t; - -typedef struct mig_symtab { - char *ms_routine_name; - int ms_routine_number; - void (*ms_routine)(void); /* Since the functions in the - * symbol table have unknown - * signatures, this is the best - * we can do... - */ -} mig_symtab_t; - -/* Client side reply port allocate */ -extern mach_port_t mig_get_reply_port(void); - -/* Client side reply port deallocate */ -extern void mig_dealloc_reply_port(mach_port_t reply_port); - -/* Client side reply port "deallocation" */ -extern void mig_put_reply_port(mach_port_t reply_port); - -/* Allocate memory for out-of-stack mig structures */ -extern char *mig_user_allocate(vm_size_t size); - -/* Deallocate memory used for out-of-stack mig structures */ -extern void mig_user_deallocate(char *data, vm_size_t size); - -/* Bounded string copy */ -extern int mig_strncpy( - char *dest, - char *src, - int len); - -#endif /* _MACH_MIG_ERRORS_H_ */ diff --git a/mach.subproj/mach_absolute_time.c b/mach.subproj/mach_absolute_time.c deleted file mode 100644 index 04491ef..0000000 --- a/mach.subproj/mach_absolute_time.c +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include - -extern mach_port_t clock_port; - -uint64_t mach_absolute_time(void) { -#if defined(__ppc__) - __asm__ volatile("0: mftbu r3"); - __asm__ volatile("mftb r4"); - __asm__ volatile("mftbu r0"); - __asm__ volatile("cmpw r0,r3"); - __asm__ volatile("bne- 0b"); -#else - mach_timespec_t now; - (void)clock_get_time(clock_port, &now); - return (uint64_t)now.tv_sec * NSEC_PER_SEC + now.tv_nsec; -#endif -} - diff --git a/mach.subproj/mach_msg.c b/mach.subproj/mach_msg.c deleted file mode 100644 index d7a1d92..0000000 --- a/mach.subproj/mach_msg.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ - -#include -#include - -#define LIBMACH_OPTIONS (MACH_SEND_INTERRUPT|MACH_RCV_INTERRUPT) - -mach_msg_return_t -mach_msg(msg, option, send_size, rcv_size, rcv_name, timeout, notify) - mach_msg_header_t *msg; - mach_msg_option_t option; - mach_msg_size_t send_size; - mach_msg_size_t rcv_size; - mach_port_t rcv_name; - mach_msg_timeout_t timeout; - mach_port_t notify; -{ - mach_msg_return_t mr; - - /* - * Consider the following cases: - * 1) Errors in pseudo-receive (eg, MACH_SEND_INTERRUPTED - * plus special bits). - * 2) Use of MACH_SEND_INTERRUPT/MACH_RCV_INTERRUPT options. - * 3) RPC calls with interruptions in one/both halves. - * - * We refrain from passing the option bits that we implement - * to the kernel. This prevents their presence from inhibiting - * the kernel's fast paths (when it checks the option value). - */ - - mr = mach_msg_overwrite_trap(msg, option &~ LIBMACH_OPTIONS, - send_size, rcv_size, rcv_name, - timeout, notify, MACH_MSG_NULL, 0); - if (mr == MACH_MSG_SUCCESS) - return MACH_MSG_SUCCESS; - - if ((option & MACH_SEND_INTERRUPT) == 0) - while (mr == MACH_SEND_INTERRUPTED) - mr = mach_msg_overwrite_trap(msg, - option &~ LIBMACH_OPTIONS, - send_size, rcv_size, rcv_name, - timeout, notify, MACH_MSG_NULL, 0); - - if ((option & MACH_RCV_INTERRUPT) == 0) - while (mr == MACH_RCV_INTERRUPTED) - mr = mach_msg_overwrite_trap(msg, - option &~ (LIBMACH_OPTIONS|MACH_SEND_MSG), - 0, rcv_size, rcv_name, - timeout, notify, MACH_MSG_NULL, 0); - - return mr; -} - -mach_msg_return_t -mach_msg_overwrite(msg, option, send_size, rcv_limit, rcv_name, timeout, - notify, rcv_msg, rcv_msg_size) - mach_msg_header_t *msg; - mach_msg_option_t option; - mach_msg_size_t send_size; - mach_msg_size_t rcv_limit; - mach_port_t rcv_name; - mach_msg_timeout_t timeout; - mach_port_t notify; - mach_msg_header_t *rcv_msg; - mach_msg_size_t rcv_msg_size; -{ - mach_msg_return_t mr; - - /* - * Consider the following cases: - * 1) Errors in pseudo-receive (eg, MACH_SEND_INTERRUPTED - * plus special bits). - * 2) Use of MACH_SEND_INTERRUPT/MACH_RCV_INTERRUPT options. - * 3) RPC calls with interruptions in one/both halves. - * - * We refrain from passing the option bits that we implement - * to the kernel. This prevents their presence from inhibiting - * the kernel's fast paths (when it checks the option value). - */ - - mr = mach_msg_overwrite_trap(msg, option &~ LIBMACH_OPTIONS, - send_size, rcv_limit, rcv_name, - timeout, notify, rcv_msg, rcv_msg_size); - if (mr == MACH_MSG_SUCCESS) - return MACH_MSG_SUCCESS; - - if ((option & MACH_SEND_INTERRUPT) == 0) - while (mr == MACH_SEND_INTERRUPTED) - mr = mach_msg_overwrite_trap(msg, - option &~ LIBMACH_OPTIONS, - send_size, rcv_limit, rcv_name, - timeout, notify, rcv_msg, rcv_msg_size); - - if ((option & MACH_RCV_INTERRUPT) == 0) - while (mr == MACH_RCV_INTERRUPTED) - mr = mach_msg_overwrite_trap(msg, - option &~ (LIBMACH_OPTIONS|MACH_SEND_MSG), - 0, rcv_limit, rcv_name, - timeout, notify, rcv_msg, rcv_msg_size); - - return mr; -} diff --git a/mach.subproj/mach_msg_destroy.c b/mach.subproj/mach_msg_destroy.c deleted file mode 100644 index 008ee99..0000000 --- a/mach.subproj/mach_msg_destroy.c +++ /dev/null @@ -1,169 +0,0 @@ -/* - * @OSF_COPYRIGHT@ - */ - -/* - * Mach Operating System - * Copyright (c) 1991,1990 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ - -#include -#include -#include - -static void mach_msg_destroy_port(mach_port_t, mach_msg_type_name_t); -static void mach_msg_destroy_memory(vm_offset_t, vm_size_t); - -/* - * Routine: mach_msg_destroy - * Purpose: - * mach_msg_destroy is useful in two contexts. - * - * First, it can deallocate all port rights and - * out-of-line memory in a received message. - * When a server receives a request it doesn't want, - * it needs this functionality. - * - * Second, it can mimic the side-effects of a msg-send - * operation. The effect is as if the message were sent - * and then destroyed inside the kernel. When a server - * can't send a reply (because the client died), - * it needs this functionality. - */ -void -mach_msg_destroy(mach_msg_header_t *msg) -{ - mach_msg_bits_t mbits = msg->msgh_bits; - - /* - * The msgh_local_port field doesn't hold a port right. - * The receive operation consumes the destination port right. - */ - - mach_msg_destroy_port(msg->msgh_remote_port, MACH_MSGH_BITS_REMOTE(mbits)); - - if (mbits & MACH_MSGH_BITS_COMPLEX) { - mach_msg_body_t *body; - mach_msg_descriptor_t *saddr, *eaddr; - - body = (mach_msg_body_t *) (msg + 1); - saddr = (mach_msg_descriptor_t *) - ((mach_msg_base_t *) msg + 1); - eaddr = saddr + body->msgh_descriptor_count; - - for ( ; saddr < eaddr; saddr++) { - switch (saddr->type.type) { - - case MACH_MSG_PORT_DESCRIPTOR: { - mach_msg_port_descriptor_t *dsc; - - /* - * Destroy port rights carried in the message - */ - dsc = &saddr->port; - mach_msg_destroy_port(dsc->name, dsc->disposition); - break; - } - - case MACH_MSG_OOL_DESCRIPTOR : { - mach_msg_ool_descriptor_t *dsc; - - /* - * Destroy memory carried in the message - */ - dsc = &saddr->out_of_line; - if (dsc->deallocate) { - mach_msg_destroy_memory((vm_offset_t)dsc->address, - dsc->size); - } - break; - } - - case MACH_MSG_OOL_PORTS_DESCRIPTOR : { - mach_port_t *ports; - mach_msg_ool_ports_descriptor_t *dsc; - mach_msg_type_number_t j; - - /* - * Destroy port rights carried in the message - */ - dsc = &saddr->ool_ports; - ports = (mach_port_t *) dsc->address; - for (j = 0; j < dsc->count; j++, ports++) { - mach_msg_destroy_port(*ports, dsc->disposition); - } - - /* - * Destroy memory carried in the message - */ - if (dsc->deallocate) { - mach_msg_destroy_memory((vm_offset_t)dsc->address, - dsc->count * sizeof(mach_port_t)); - } - break; - } - } - } - } -} - -static void -mach_msg_destroy_port(mach_port_t port, mach_msg_type_name_t type) -{ - if (MACH_PORT_VALID(port)) switch (type) { - case MACH_MSG_TYPE_MOVE_SEND: - case MACH_MSG_TYPE_MOVE_SEND_ONCE: - /* destroy the send/send-once right */ - (void) mach_port_deallocate(mach_task_self(), port); - break; - - case MACH_MSG_TYPE_MOVE_RECEIVE: - /* destroy the receive right */ - (void) mach_port_mod_refs(mach_task_self(), port, - MACH_PORT_RIGHT_RECEIVE, -1); - break; - - case MACH_MSG_TYPE_MAKE_SEND: - /* create a send right and then destroy it */ - (void) mach_port_insert_right(mach_task_self(), port, - port, MACH_MSG_TYPE_MAKE_SEND); - (void) mach_port_deallocate(mach_task_self(), port); - break; - - case MACH_MSG_TYPE_MAKE_SEND_ONCE: - /* create a send-once right and then destroy it */ - (void) mach_port_extract_right(mach_task_self(), port, - MACH_MSG_TYPE_MAKE_SEND_ONCE, - &port, &type); - (void) mach_port_deallocate(mach_task_self(), port); - break; - } -} - -static void -mach_msg_destroy_memory(vm_offset_t addr, vm_size_t size) -{ - if (size != 0) - (void) vm_deallocate(mach_task_self(), addr, size); -} diff --git a/mach.subproj/mach_msg_send.c b/mach.subproj/mach_msg_send.c deleted file mode 100644 index 80180dd..0000000 --- a/mach.subproj/mach_msg_send.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ -/* - * Mach Operating System - * Copyright (c) 1991,1990,1989 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ - -#include -#include - -mach_msg_return_t -mach_msg_send(mach_msg_header_t *msg) -{ - return mach_msg(msg, MACH_SEND_MSG, - msg->msgh_size, 0, MACH_PORT_NULL, - MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); -} diff --git a/mach.subproj/mach_msg_server.c b/mach.subproj/mach_msg_server.c deleted file mode 100644 index 4144c7a..0000000 --- a/mach.subproj/mach_msg_server.c +++ /dev/null @@ -1,265 +0,0 @@ -/* - * @OSF_COPYRIGHT@ - */ - -/* - * Mach Operating System - * Copyright (c) 1991,1990 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ - -#include -#include -#include -#include -#include -#include -#include - -/* - * Routine: mach_msg_server_once - * Purpose: - * A simple generic server function. It allows more flexibility - * than mach_msg_server by processing only one message request - * and then returning to the user. Note that more in the way - * of error codes are returned to the user; specifically, any - * failing error from mach_msg_overwrite_trap will be returned - * (though errors from the demux routine or the routine it calls - * will not be). - */ -mach_msg_return_t -mach_msg_server_once( - boolean_t (*demux)(mach_msg_header_t *, mach_msg_header_t *), - mach_msg_size_t max_size, - mach_port_t rcv_name, - mach_msg_options_t options) -{ - mig_reply_error_t *bufRequest = 0, *bufReply = 0, *bufTemp; - register mach_msg_return_t mr; - register kern_return_t kr; - - if ((kr = vm_allocate(mach_task_self(), - (vm_address_t *)&bufRequest, - max_size + MAX_TRAILER_SIZE, - VM_MAKE_TAG(VM_MEMORY_MACH_MSG)|TRUE)) != KERN_SUCCESS) - return kr; - if ((kr = vm_allocate(mach_task_self(), - (vm_address_t *)&bufReply, - max_size + MAX_TRAILER_SIZE, - VM_MAKE_TAG(VM_MEMORY_MACH_MSG)|TRUE)) != KERN_SUCCESS) - return kr; - - mr = mach_msg_overwrite_trap(&bufRequest->Head, MACH_RCV_MSG|options, - 0, max_size, rcv_name, - MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL, - (mach_msg_header_t *) 0, 0); - if (mr == MACH_MSG_SUCCESS) { - /* we have a request message */ - - (void) (*demux)(&bufRequest->Head, &bufReply->Head); - - if (!(bufReply->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) && - bufReply->RetCode != KERN_SUCCESS) { - if (bufReply->RetCode == MIG_NO_REPLY) - /* - * This return code is a little tricky-- - * it appears that the demux routine found an - * error of some sort, but since that error - * would not normally get returned either to - * the local user or the remote one, we pretend it's - * ok. - */ - return KERN_SUCCESS; - - /* don't destroy the reply port right, - so we can send an error message */ - bufRequest->Head.msgh_remote_port = MACH_PORT_NULL; - mach_msg_destroy(&bufRequest->Head); - } - - if (bufReply->Head.msgh_remote_port == MACH_PORT_NULL) { - /* no reply port, so destroy the reply */ - if (bufReply->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) - mach_msg_destroy(&bufReply->Head); - - return KERN_SUCCESS; - } - - /* send reply. */ - - bufTemp = bufRequest; - bufRequest = bufReply; - bufReply = bufTemp; - - /* - * We don't want to block indefinitely because the client - * isn't receiving messages from the reply port. - * If we have a send-once right for the reply port, then - * this isn't a concern because the send won't block. - * If we have a send right, we need to use MACH_SEND_TIMEOUT. - * To avoid falling off the kernel's fast RPC path unnecessarily, - * we only supply MACH_SEND_TIMEOUT when absolutely necessary. - */ - - mr = mach_msg_overwrite_trap(&bufRequest->Head, - (MACH_MSGH_BITS_REMOTE(bufRequest->Head.msgh_bits) == - MACH_MSG_TYPE_MOVE_SEND_ONCE) ? - MACH_SEND_MSG|options : - MACH_SEND_MSG|MACH_SEND_TIMEOUT|options, - bufRequest->Head.msgh_size, 0, MACH_PORT_NULL, - 0, MACH_PORT_NULL, (mach_msg_header_t *) 0, 0); - } - /* Has a message error occurred? */ - - switch (mr) { - case MACH_SEND_INVALID_DEST: - case MACH_SEND_TIMED_OUT: - /* the reply can't be delivered, so destroy it */ - mach_msg_destroy(&bufRequest->Head); - return KERN_SUCCESS; /* Matches error hiding behavior in - mach_msg_server. */ - - case MACH_RCV_TOO_LARGE: - return KERN_SUCCESS; /* Matches error hiding behavior in - mach_msg_server. */ - - default: - /* Includes success case. */ - (void)vm_deallocate(mach_task_self(), - (vm_address_t) bufRequest, - max_size + MAX_TRAILER_SIZE); - (void)vm_deallocate(mach_task_self(), - (vm_address_t) bufReply, - max_size + MAX_TRAILER_SIZE); - return mr; - } -} - -/* - * Routine: mach_msg_server - * Purpose: - * A simple generic server function. Note that changes here - * should be considered for duplication above. - */ -mach_msg_return_t -mach_msg_server( - boolean_t (*demux)(mach_msg_header_t *, mach_msg_header_t *), - mach_msg_size_t max_size, - mach_port_t rcv_name, - mach_msg_options_t options) -{ - mig_reply_error_t *bufRequest = 0, *bufReply = 0, *bufTemp; - register mach_msg_return_t mr; - register kern_return_t kr; - - if ((kr = vm_allocate(mach_task_self(), - (vm_address_t *)&bufRequest, - max_size + MAX_TRAILER_SIZE, - VM_MAKE_TAG(VM_MEMORY_MACH_MSG)|TRUE)) != KERN_SUCCESS) - return kr; - if ((kr = vm_allocate(mach_task_self(), - (vm_address_t *)&bufReply, - max_size + MAX_TRAILER_SIZE, - VM_MAKE_TAG(VM_MEMORY_MACH_MSG)|TRUE)) != KERN_SUCCESS) - return kr; - - for (;;) { - get_request: - mr = mach_msg_overwrite_trap(&bufRequest->Head, MACH_RCV_MSG|options, - 0, max_size, rcv_name, - MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL, - (mach_msg_header_t *) 0, 0); - while (mr == MACH_MSG_SUCCESS) { - /* we have a request message */ - - (void) (*demux)(&bufRequest->Head, &bufReply->Head); - - if (!(bufReply->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) && - bufReply->RetCode != KERN_SUCCESS) { - if (bufReply->RetCode == MIG_NO_REPLY) - goto get_request; - - /* don't destroy the reply port right, - so we can send an error message */ - bufRequest->Head.msgh_remote_port = MACH_PORT_NULL; - mach_msg_destroy(&bufRequest->Head); - } - - if (bufReply->Head.msgh_remote_port == MACH_PORT_NULL) { - /* no reply port, so destroy the reply */ - if (bufReply->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) - mach_msg_destroy(&bufReply->Head); - - goto get_request; - } - - /* send reply and get next request */ - - bufTemp = bufRequest; - bufRequest = bufReply; - bufReply = bufTemp; - - /* - * We don't want to block indefinitely because the client - * isn't receiving messages from the reply port. - * If we have a send-once right for the reply port, then - * this isn't a concern because the send won't block. - * If we have a send right, we need to use MACH_SEND_TIMEOUT. - * To avoid falling off the kernel's fast RPC path unnecessarily, - * we only supply MACH_SEND_TIMEOUT when absolutely necessary. - */ - - mr = mach_msg_overwrite_trap(&bufRequest->Head, - (MACH_MSGH_BITS_REMOTE(bufRequest->Head.msgh_bits) == - MACH_MSG_TYPE_MOVE_SEND_ONCE) ? - MACH_SEND_MSG|MACH_RCV_MSG|options : - MACH_SEND_MSG|MACH_SEND_TIMEOUT|MACH_RCV_MSG|options, - bufRequest->Head.msgh_size, max_size, rcv_name, - 0, MACH_PORT_NULL, (mach_msg_header_t *) 0, 0); - } - - /* a message error occurred */ - - switch (mr) { - case MACH_SEND_INVALID_DEST: - case MACH_SEND_TIMED_OUT: - /* the reply can't be delivered, so destroy it */ - mach_msg_destroy(&bufRequest->Head); - break; - - case MACH_RCV_TOO_LARGE: - /* the kernel destroyed the request */ - break; - - default: - /* should only happen if the server is buggy */ - (void)vm_deallocate(mach_task_self(), - (vm_address_t) bufRequest, - max_size + MAX_TRAILER_SIZE); - (void)vm_deallocate(mach_task_self(), - (vm_address_t) bufReply, - max_size + MAX_TRAILER_SIZE); - return mr; - } - } -} diff --git a/mach.subproj/mach_subsystem_join.c b/mach.subproj/mach_subsystem_join.c deleted file mode 100644 index a22504a..0000000 --- a/mach.subproj/mach_subsystem_join.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - * @OSF_COPYRIGHT@ - */ - -#include /* To get NULL */ -#include -#include -#include - -#if 0 -# include -# define debug(x) printf x -#else -# define debug(x) -#endif - -/* - * Routine: mach_subsystem_join - * Purpose: - * Create a new subsystem, suitable for registering with - * mach_subsystem_create, that consists of the union of - * the routines of subsys_1 and subsys_2. - * - * Warning: - * If there is a big gap between the routine numbers of - * the two subsystems, a correspondingly large amount of - * space will be wasted in the new subsystem. - */ -rpc_subsystem_t -mach_subsystem_join(rpc_subsystem_t subsys_1, /* First input subsystem */ - rpc_subsystem_t subsys_2, /* Second input subsystem */ - unsigned int *num_bytes_p, /* Size of output subsystem */ - void *(*malloc_func)(int) /* Allocation routine to use */ - ) -{ - rpc_subsystem_t sp, subsys_new; - int num_routines, num_args, num_bytes; - int i, j; - struct routine_arg_descriptor *ap; - struct routine_descriptor *rp; - - /* Make sure the two routine number ranges do not overlap: - */ - if (subsys_1->start <= subsys_2->start && subsys_1->end > subsys_2->start - || - subsys_2->start <= subsys_1->start && subsys_2->end > subsys_1->start) - return NULL; - - /* Arrange that subsys_1 is the subsystem with the lower numbered - * routines: - */ - if (subsys_2->start < subsys_1->start || - subsys_2->end < subsys_1->end) { - /* Exchange the two input subsystem pointers: */ - sp = subsys_2; subsys_2 = subsys_1; subsys_1 = sp; - } - - debug(("subys_join: Lower subsys: (%d, %d); Higher subsys: (%d, %d)\n", - subsys_1->start, subsys_1->end, subsys_2->start, subsys_2->end)); - - /* - * Calculate size needed for new subsystem and allocate it: - */ - num_args = 0; - sp = subsys_1; - do { - int nr; - - nr = sp->end - sp->start; - num_routines += nr; - - for (rp = &sp->routine[0]; rp < &sp->routine[nr]; rp++) { - /* Make sure this routine is non-null: */ - if (rp->impl_routine != NULL) - num_args += rp->descr_count; - } - if (sp == subsys_2) - break; - sp = subsys_2; - } while (1); - num_routines = subsys_2->end - subsys_1->start; - - /* A struct rpc_subsystem, which is just a template for a real - * subsystem descriptor, has one dummy routine descriptor in it - * and one arg descriptor, so we have to subtract these out, when - * calculating room for the routine and arg arrays: - */ - num_bytes = sizeof(struct rpc_subsystem) + - (num_routines - 1) * sizeof(struct routine_descriptor) + - (num_args - 1) * sizeof(struct routine_arg_descriptor); - - debug(("subys_new: %x; #routines: %d; #args: %d; #bytes: %d\n", - subsys_new, num_routines, num_args, num_bytes)); - - subsys_new = (rpc_subsystem_t) (*malloc_func)(num_bytes); - if (subsys_new == NULL) - return NULL; - - /* Initialize the new subsystem, then copy the lower-numbered - * subsystem into the new subsystem, then the higher-numbered one: - */ - - subsys_new->subsystem = NULL; /* Reserved for system use */ - subsys_new->start = subsys_1->start; - subsys_new->end = subsys_2->end; - subsys_new->maxsize = subsys_1->maxsize > subsys_2->maxsize ? - subsys_1->maxsize : subsys_2->maxsize; - subsys_new->base_addr = (vm_address_t)subsys_new; - - /* Point ap at the beginning of the arg_descriptors for the - * joined subystem, i.e. just after the end of the combined - * array of routine descriptors: - */ - ap = (struct routine_arg_descriptor *) - &(subsys_new->routine[num_routines]); - rp = &(subsys_new->routine[0]); - - /* Copy subsys_1 into subsys_new: */ - debug(("subys_join: Copying lower subsys: rp=%x, ap=%x\n", rp, ap)); - for (i = 0; i < subsys_1->end - subsys_1->start; i++, rp++) { - *rp = subsys_1->routine[i]; - if (rp->impl_routine != NULL) { - rp->arg_descr = ap; - for (j = 0; j < rp->descr_count; j++) - *ap++ = subsys_1->routine[i].arg_descr[j]; - } else - rp->arg_descr = NULL; - } - - /* Fill in the gap, if any, between subsys_1 routine numbers - * and subsys_2 routine numbers: - */ - for (i = subsys_1->end; i < subsys_2->start; i++, rp++) { - rp->impl_routine = NULL; - rp->arg_descr = NULL; - } - - /* Copy subsys_2 into subsys_new: */ - debug(("subys_join: Copying higher subsys: rp=%x, ap=%x\n", rp, ap)); - for (i = 0; i < subsys_2->end - subsys_2->start; i++, rp++) { - *rp = subsys_2->routine[i]; - if (rp->impl_routine != NULL) { - rp->arg_descr = ap; - for (j = 0; j < rp->descr_count; j++) - *ap++ = subsys_2->routine[i].arg_descr[j]; - } else - rp->arg_descr = NULL; - } - debug(("subys_join: Done: rp=%x, ap=%x\n", rp, ap)); - - *num_bytes_p = num_bytes; - return subsys_new; -} diff --git a/mach.subproj/servers.subproj/Makefile b/mach.subproj/servers.subproj/Makefile deleted file mode 100644 index e00ee97..0000000 --- a/mach.subproj/servers.subproj/Makefile +++ /dev/null @@ -1,49 +0,0 @@ -# -# Generated by the NeXT Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = servers - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -HFILES = bootstrap_defs.h key_defs.h ls_defs.h netname_defs.h\ - nm_defs.h - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble\ - bootstrap.defs netname.defs - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - -PUBLIC_HEADERS = bootstrap_defs.h key_defs.h ls_defs.h netname_defs.h\ - nm_defs.h - - - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/mach.subproj/servers.subproj/Makefile.postamble b/mach.subproj/servers.subproj/Makefile.postamble deleted file mode 100644 index 411cde6..0000000 --- a/mach.subproj/servers.subproj/Makefile.postamble +++ /dev/null @@ -1,100 +0,0 @@ -############################################################################### -# Makefile.postamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile, which is imported after all other makefiles, to -# override attributes for a project's Makefile environment. This allows you -# to take advantage of the environment set up by the other Makefiles. -# You can also define custom rules at the end of this file. -# -############################################################################### -# -# These variables are exported by the standard makefiles and can be -# used in any customizations you make. They are *outputs* of -# the Makefiles and should be used, not set. -# -# PRODUCTS: products to install. All of these products will be placed in -# the directory $(DSTROOT)$(INSTALLDIR) -# GLOBAL_RESOURCE_DIR: The directory to which resources are copied. -# LOCAL_RESOURCE_DIR: The directory to which localized resources are copied. -# OFILE_DIR: Directory into which .o object files are generated. -# DERIVED_SRC_DIR: Directory used for all other derived files -# -# ALL_CFLAGS: flags to pass when compiling .c files -# ALL_MFLAGS: flags to pass when compiling .m files -# ALL_CCFLAGS: flags to pass when compiling .cc, .cxx, and .C files -# ALL_MMFLAGS: flags to pass when compiling .mm, .mxx, and .M files -# ALL_PRECOMPFLAGS: flags to pass when precompiling .h files -# ALL_LDFLAGS: flags to pass when linking object files -# ALL_LIBTOOL_FLAGS: flags to pass when libtooling object files -# ALL_PSWFLAGS: flags to pass when processing .psw and .pswm (pswrap) files -# ALL_RPCFLAGS: flags to pass when processing .rpc (rpcgen) files -# ALL_YFLAGS: flags to pass when processing .y (yacc) files -# ALL_LFLAGS: flags to pass when processing .l (lex) files -# -# NAME: name of application, bundle, subproject, palette, etc. -# LANGUAGES: langages in which the project is written (default "English") -# English_RESOURCES: localized resources (e.g. nib's, images) of project -# GLOBAL_RESOURCES: non-localized resources of project -# -# SRCROOT: base directory in which to place the new source files -# SRCPATH: relative path from SRCROOT to present subdirectory -# -# INSTALLDIR: Directory the product will be installed into by 'install' target -# PUBLIC_HDR_INSTALLDIR: where to install public headers. Don't forget -# to prefix this with DSTROOT when you use it. -# PRIVATE_HDR_INSTALLDIR: where to install private headers. Don't forget -# to prefix this with DSTROOT when you use it. -# -# EXECUTABLE_EXT: Executable extension for the platform (i.e. .exe on Windows) -# -############################################################################### - -# Some compiler flags can be overridden here for certain build situations. -# -# WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost) -# DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults -# to -g) -# DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG) -# OPTIMIZE_BUILD_CFLAGS: flags passed during optimized builds (defaults -# to -O) -# PROFILE_BUILD_CFLAGS: flags passed during profile builds (defaults -# to -pg -DPROFILE) -# LOCAL_DIR_INCLUDE_DIRECTIVE: flag used to add current directory to -# the include path (defaults to -I.) -# DEBUG_BUILD_LDFLAGS, OPTIMIZE_BUILD_LDFLAGS, PROFILE_BUILD_LDFLAGS: flags -# passed to ld/libtool (defaults to nothing) - - -# Library and Framework projects only: -# INSTALL_NAME_DIRECTIVE: This directive ensures that executables linked -# against the framework will run against the correct version even if -# the current version of the framework changes. You may override this -# to "" as an alternative to using the DYLD_LIBRARY_PATH during your -# development cycle, but be sure to restore it before installing. - - -# Ownership and permissions of files installed by 'install' target - -#INSTALL_AS_USER = root - # User/group ownership -#INSTALL_AS_GROUP = wheel - # (probably want to set both of these) -#INSTALL_PERMISSIONS = - # If set, 'install' chmod's executable to this - - -# Options to strip. Note: -S strips debugging symbols (executables can be stripped -# down further with -x or, if they load no bundles, with no options at all). - -#STRIPFLAGS = -S - - -######################################################################### -# Put rules to extend the behavior of the standard Makefiles here. Include them in -# the dependency tree via cvariables like AFTER_INSTALL in the Makefile.preamble. -# -# You should avoid redefining things like "install" or "app", as they are -# owned by the top-level Makefile API and no context has been set up for where -# derived files should go. -# diff --git a/mach.subproj/servers.subproj/Makefile.preamble b/mach.subproj/servers.subproj/Makefile.preamble deleted file mode 100644 index 5cee34d..0000000 --- a/mach.subproj/servers.subproj/Makefile.preamble +++ /dev/null @@ -1,3 +0,0 @@ -OTHER_PUBLIC_HEADERS = bootstrap.h netname.h -OTHER_OFILES = bootstrapUser.o netnameUser.o -PUBLIC_HEADER_DIR_SUFFIX = /servers diff --git a/mach.subproj/servers.subproj/PB.project b/mach.subproj/servers.subproj/PB.project deleted file mode 100644 index d9b8447..0000000 --- a/mach.subproj/servers.subproj/PB.project +++ /dev/null @@ -1,23 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - H_FILES = (bootstrap_defs.h, key_defs.h, ls_defs.h, netname_defs.h, nm_defs.h); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble, bootstrap.defs, netname.defs); - PUBLIC_HEADERS = (bootstrap_defs.h, key_defs.h, ls_defs.h, netname_defs.h, nm_defs.h); - SUBPROJECTS = (); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = servers; - PROJECTTYPE = Component; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/mach/Makefile.inc b/mach/Makefile.inc new file mode 100644 index 0000000..10bda18 --- /dev/null +++ b/mach/Makefile.inc @@ -0,0 +1,103 @@ +.PATH: ${.CURDIR}/${MACHINE_ARCH}/mach ${.CURDIR}/mach + +.include "${.CURDIR}/mach/headers/Makefile.inc" +.include "${.CURDIR}/mach/servers/Makefile.inc" + +# machine-dependent mach sources +.if exists(${.CURDIR}/${MACHINE_ARCH}/mach/Makefile.inc) +.include "${.CURDIR}/${MACHINE_ARCH}/mach/Makefile.inc" +.endif + +MIGDEFS += \ + clock.defs \ + clock_priv.defs \ + host_priv.defs \ + host_security.defs \ + ledger.defs \ + lock_set.defs \ + mach_port.defs \ + mach_host.defs \ + processor.defs \ + processor_set.defs \ + task.defs \ + thread_act.defs \ + vm_map.defs + +#MIGHDRS = ${MIGDEFS:S/.defs$/.h/:S/^/${.CURDIR}\/mach\//} +MIGHDRS = ${MIGDEFS:S/.defs$/.h/} +MIGHDRS += clock_reply.h +MACH_INSTHDRS += ${MIGHDRS} + +# These files are generated from the .defs files +MIGSRCS = ${MIGDEFS:S/.defs$/User.c/} + +SRCS+= ${MIGDEFS:S/.defs$/User.defs/} \ + bootstrap_ports.c \ + clock_sleep.c \ + error_codes.c \ + excServer.c \ + excUser.c \ + exc_catcher.c \ + exc_catcher_state.c \ + exc_catcher_state_identity.c \ + fprintf_stderr.c \ + mig_allocate.c \ + mig_deallocate.c \ + mig_reply_setup.c \ + mig_strncpy.c \ + mach_error.c \ + mach_error_string.c \ + mach_init.c \ + mach_init_ports.c \ + mach_msg.c \ + mach_traps.s \ + ms_thread_switch.c \ + notifyUser.c \ + panic.c \ + port_obj.c \ + sbrk.c \ + semaphore.c \ + slot_name.c + +CLEANFILES += ${MIGHDRS} ${MIGHDRS:S/.h$/User.c/} \ + ${MIGHDRS:S/.h/Server.c/} exc.h excUser.c excServer.c \ + notify.h notifyUser.c notifyServer.c + +${MIGDEFS:S/.defs$/User.So/}: + mig -user ${.TARGET:S/.So$/.c/} \ + -server ${.TARGET:S/User.So$/Server.c/} \ + -header ${.TARGET:S/User.So$/.h/} \ + ${.CURDIR}/mach/${.TARGET:S/User.So$/.defs/} + ${CC} ${CFLAGS} -Os -c ${.TARGET:S/.So$/.c/}\ + -o ${.TARGET} +${MIGDEFS:S/.defs$/User.do/}: + mig -user ${.TARGET:S/.do$/.c/} \ + -server ${.TARGET:S/User.do$/Server.c/} \ + -header ${.TARGET:S/User.do$/.h/} \ + ${.CURDIR}/mach/${.TARGET:S/User.do$/.defs/} + ${CC} -g -DDEBUG ${CFLAGS} -c ${.TARGET:S/.do$/.c/}\ + -o ${.TARGET} +${MIGDEFS:S/.defs$/User.po/}: + mig -user ${.TARGET:S/.po$/.c/} \ + -server ${.TARGET:S/User.po$/Server.c/} \ + -header ${.TARGET:S/User.po$/.h/} \ + ${.CURDIR}/mach/${.TARGET:S/User.po$/.defs/} + ${CC} -pg -DPROFILE ${CFLAGS} -c ${.TARGET:S/.po$/.c/}\ + -o ${.TARGET} +${MIGDEFS:S/.defs$/User.o/}: + mig -user ${.TARGET:S/.o$/.c/} \ + -server ${.TARGET:S/User.o$/Server.c/} \ + -header ${.TARGET:S/User.o$/.h/} \ + ${.CURDIR}/mach/${.TARGET:S/User.o$/.defs/} + ${CC} -static ${CFLAGS} -c ${.TARGET:S/.o$/.c/}\ + -o ${.TARGET} + +excServer.c: ${.CURDIR}/mach/exc.defs + mig -user excUser.c -server excServer.c -header exc.h \ + ${.CURDIR}/mach/exc.defs +excUser.c: ${.CURDIR}/mach/exc.defs + mig -user excUser.c -server excServer.c -header exc.h \ + ${.CURDIR}/mach/exc.defs +notifyUser.c: ${.CURDIR}/mach/notify.defs + mig -user notifyUser.c -server notifyServer.c -header notify.h \ + ${.CURDIR}/mach/notify.defs diff --git a/mach.subproj/mach_msg_receive.c b/mach/bootstrap_ports.c similarity index 80% rename from mach.subproj/mach_msg_receive.c rename to mach/bootstrap_ports.c index 8d7f260..9cd19d2 100644 --- a/mach.subproj/mach_msg_receive.c +++ b/mach/bootstrap_ports.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2002 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -46,12 +46,21 @@ */ #include -#include -mach_msg_return_t -mach_msg_receive(mach_msg_header_t *msg) +/* + * Stub out the old bootstrap_ports() API, as some applications need + * it to exist. We do not publish a prototype for this, and the stub + * WILL disappear in a future release. + */ +kern_return_t +bootstrap_ports( + mach_port_t bootstrap, + mach_port_t *priv_host, + mach_port_t *device_master, + mach_port_t *wired_ledger, + mach_port_t *paged_ledger, + mach_port_t *host_security) { - return mach_msg(msg, MACH_RCV_MSG, - 0, msg->msgh_size, msg->msgh_local_port, - MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + return KERN_FAILURE; } + diff --git a/mach.subproj/clock.defs b/mach/clock.defs similarity index 100% rename from mach.subproj/clock.defs rename to mach/clock.defs diff --git a/mach.subproj/clock_priv.defs b/mach/clock_priv.defs similarity index 100% rename from mach.subproj/clock_priv.defs rename to mach/clock_priv.defs diff --git a/mach.subproj/clock_reply.defs b/mach/clock_reply.defs similarity index 100% rename from mach.subproj/clock_reply.defs rename to mach/clock_reply.defs diff --git a/mach.subproj/clock_sleep.c b/mach/clock_sleep.c similarity index 100% rename from mach.subproj/clock_sleep.c rename to mach/clock_sleep.c diff --git a/mach.subproj/err_ipc.sub b/mach/err_ipc.sub similarity index 100% rename from mach.subproj/err_ipc.sub rename to mach/err_ipc.sub diff --git a/mach.subproj/err_kern.sub b/mach/err_kern.sub similarity index 100% rename from mach.subproj/err_kern.sub rename to mach/err_kern.sub diff --git a/mach.subproj/err_mach_ipc.sub b/mach/err_mach_ipc.sub similarity index 100% rename from mach.subproj/err_mach_ipc.sub rename to mach/err_mach_ipc.sub diff --git a/mach.subproj/err_server.sub b/mach/err_server.sub similarity index 100% rename from mach.subproj/err_server.sub rename to mach/err_server.sub diff --git a/mach.subproj/err_us.sub b/mach/err_us.sub similarity index 100% rename from mach.subproj/err_us.sub rename to mach/err_us.sub diff --git a/mach.subproj/error_codes.c b/mach/error_codes.c similarity index 92% rename from mach.subproj/error_codes.c rename to mach/error_codes.c index b46cd61..184969d 100644 --- a/mach.subproj/error_codes.c +++ b/mach/error_codes.c @@ -36,14 +36,14 @@ */ #include -#include +#include "errorlib.h" #include "err_kern.sub" #include "err_us.sub" #include "err_server.sub" #include "err_ipc.sub" #include "err_mach_ipc.sub" -struct error_system errors[err_max_system+1] = { +__private_extern__ struct error_system _mach_errors[err_max_system+1] = { /* 0; err_kern */ { errlib_count(err_os_sub), @@ -76,4 +76,4 @@ struct error_system errors[err_max_system+1] = { }, }; -int error_system_count = errlib_count(errors); +int error_system_count = errlib_count(_mach_errors); diff --git a/mach/errorlib.h b/mach/errorlib.h new file mode 100644 index 0000000..df06289 --- /dev/null +++ b/mach/errorlib.h @@ -0,0 +1,73 @@ +/* + * @OSF_COPYRIGHT@ + */ + +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +/* + * File: errorlib.h + * Author: Douglas Orr, Carnegie Mellon University + * Date: Mar. 1988 + * + * Error bases for subsytems errors. + */ + +#include +#include + +#define MACH_IPC_SEND_MOD (err_mach_ipc|err_sub(0)) +#define MACH_IPC_RCV_MOD (err_mach_ipc|err_sub(1)) +#define MACH_IPC_MIG_MOD (err_mach_ipc|err_sub(2)) + +#define IPC_SEND_MOD (err_ipc|err_sub(0)) +#define IPC_RCV_MOD (err_ipc|err_sub(1)) +#define IPC_MIG_MOD (err_ipc|err_sub(2)) + +#define SERV_NETNAME_MOD (err_server|err_sub(0)) +#define SERV_ENV_MOD (err_server|err_sub(1)) +#define SERV_EXECD_MOD (err_server|err_sub(2)) + + +#define NO_SUCH_ERROR "unknown error code" + +struct error_subsystem { + char * subsys_name; + int max_code; + char * * codes; +}; + +struct error_system { + int max_sub; + char * bad_sub; + struct error_subsystem * subsystem; +}; + +__private_extern__ struct error_system _mach_errors[err_max_system+1]; + +__private_extern__ char *mach_error_string_int(mach_error_t, boolean_t *); + +#define errlib_count(s) (sizeof(s)/sizeof(s[0])) diff --git a/mach.subproj/exc.defs b/mach/exc.defs similarity index 100% rename from mach.subproj/exc.defs rename to mach/exc.defs diff --git a/mach.subproj/exc_catcher.c b/mach/exc_catcher.c similarity index 100% rename from mach.subproj/exc_catcher.c rename to mach/exc_catcher.c diff --git a/mach.subproj/exc_catcher_state.c b/mach/exc_catcher_state.c similarity index 100% rename from mach.subproj/exc_catcher_state.c rename to mach/exc_catcher_state.c diff --git a/mach.subproj/exc_catcher_state_identity.c b/mach/exc_catcher_state_identity.c similarity index 100% rename from mach.subproj/exc_catcher_state_identity.c rename to mach/exc_catcher_state_identity.c diff --git a/mach.subproj/externs.h b/mach/externs.h similarity index 82% rename from mach.subproj/externs.h rename to mach/externs.h index 0110179..515646f 100644 --- a/mach.subproj/externs.h +++ b/mach/externs.h @@ -12,4 +12,3 @@ extern void mach_init_ports(void); extern void mig_allocate(vm_address_t *, vm_size_t); extern void mig_deallocate(vm_address_t, vm_size_t); -extern char *mach_error_string_int(mach_error_t, boolean_t *); diff --git a/mach.subproj/fprintf_stderr.c b/mach/fprintf_stderr.c similarity index 100% rename from mach.subproj/fprintf_stderr.c rename to mach/fprintf_stderr.c diff --git a/mach/headers/Makefile.inc b/mach/headers/Makefile.inc new file mode 100644 index 0000000..a01b9f7 --- /dev/null +++ b/mach/headers/Makefile.inc @@ -0,0 +1,8 @@ +MACH_INSTHDRS += mach.h \ + mach_error.h \ + mach_init.h \ + mach_interface.h \ + port_obj.h \ + sync.h \ + vm_task.h +MACH_INSTHDRS := ${MACH_INSTHDRS:S/^/${.CURDIR}\/mach\/headers\//} diff --git a/mach.subproj/headers.subproj/errorlib.h b/mach/headers/errorlib.h similarity index 100% rename from mach.subproj/headers.subproj/errorlib.h rename to mach/headers/errorlib.h diff --git a/mach.subproj/headers.subproj/mach.h b/mach/headers/mach.h similarity index 96% rename from mach.subproj/headers.subproj/mach.h rename to mach/headers/mach.h index 9fa02f3..d37344e 100644 --- a/mach.subproj/headers.subproj/mach.h +++ b/mach/headers/mach.h @@ -56,12 +56,18 @@ #define __MACH30__ #define MACH_IPC_FLAVOR UNTYPED +#include #include #include #include #include #include #include + +#include /* for compatibility only */ +#include +#include + /* * Standard prototypes */ diff --git a/mach.subproj/headers.subproj/mach_error.h b/mach/headers/mach_error.h similarity index 100% rename from mach.subproj/headers.subproj/mach_error.h rename to mach/headers/mach_error.h diff --git a/mach.subproj/headers.subproj/mach_init.h b/mach/headers/mach_init.h similarity index 100% rename from mach.subproj/headers.subproj/mach_init.h rename to mach/headers/mach_init.h diff --git a/mach.subproj/headers.subproj/mach_interface.h b/mach/headers/mach_interface.h similarity index 100% rename from mach.subproj/headers.subproj/mach_interface.h rename to mach/headers/mach_interface.h diff --git a/mach.subproj/headers.subproj/port_obj.h b/mach/headers/port_obj.h similarity index 100% rename from mach.subproj/headers.subproj/port_obj.h rename to mach/headers/port_obj.h diff --git a/mach.subproj/headers.subproj/sync.h b/mach/headers/sync.h similarity index 100% rename from mach.subproj/headers.subproj/sync.h rename to mach/headers/sync.h diff --git a/mach.subproj/headers.subproj/vm_task.h b/mach/headers/vm_task.h similarity index 100% rename from mach.subproj/headers.subproj/vm_task.h rename to mach/headers/vm_task.h diff --git a/mach.subproj/host_priv.defs b/mach/host_priv.defs similarity index 100% rename from mach.subproj/host_priv.defs rename to mach/host_priv.defs diff --git a/mach.subproj/host_security.defs b/mach/host_security.defs similarity index 100% rename from mach.subproj/host_security.defs rename to mach/host_security.defs diff --git a/mach.subproj/ledger.defs b/mach/ledger.defs similarity index 100% rename from mach.subproj/ledger.defs rename to mach/ledger.defs diff --git a/mach.subproj/lock_set.defs b/mach/lock_set.defs similarity index 100% rename from mach.subproj/lock_set.defs rename to mach/lock_set.defs diff --git a/mach.subproj/mach_error.c b/mach/mach_error.c similarity index 99% rename from mach.subproj/mach_error.c rename to mach/mach_error.c index df35b48..5d95954 100644 --- a/mach.subproj/mach_error.c +++ b/mach/mach_error.c @@ -57,7 +57,7 @@ #include #include #include -#include "externs.h" +#include "errorlib.h" void mach_error( str, err ) diff --git a/mach.subproj/mach_error_string.c b/mach/mach_error_string.c similarity index 86% rename from mach.subproj/mach_error_string.c rename to mach/mach_error_string.c index 846d2b8..5934f1c 100644 --- a/mach.subproj/mach_error_string.c +++ b/mach/mach_error_string.c @@ -30,7 +30,8 @@ #include #include #include -#include + +#include "errorlib.h" #include "externs.h" static void do_compat(mach_error_t *); @@ -71,14 +72,14 @@ mach_error_type(mach_error_t err) sub = err_get_sub(err); system = err_get_system(err); - if (system > err_max_system || sub >= errors[system].max_sub) + if (system > err_max_system || sub >= _mach_errors[system].max_sub) return((char *)"(?/?)"); - return(errors[system].subsystem[sub].subsys_name); + return(_mach_errors[system].subsystem[sub].subsys_name); } boolean_t mach_error_full_diag = FALSE; -char * +__private_extern__ char * mach_error_string_int(mach_error_t err, boolean_t *diag) { int sub, system, code; @@ -93,13 +94,13 @@ mach_error_string_int(mach_error_t err, boolean_t *diag) if (system > err_max_system) return((char *)"(?/?) unknown error system"); - if (sub >= errors[system].max_sub) - return(errors[system].bad_sub); - if (code >= errors[system].subsystem[sub].max_code) + if (sub >= _mach_errors[system].max_sub) + return(_mach_errors[system].bad_sub); + if (code >= _mach_errors[system].subsystem[sub].max_code) return ((char *)NO_SUCH_ERROR); *diag = mach_error_full_diag; - return( errors[system].subsystem[sub].codes[code] ); + return( _mach_errors[system].subsystem[sub].codes[code] ); } char * diff --git a/mach.subproj/mach_host.defs b/mach/mach_host.defs similarity index 100% rename from mach.subproj/mach_host.defs rename to mach/mach_host.defs diff --git a/mach.subproj/mach_init.c b/mach/mach_init.c similarity index 93% rename from mach.subproj/mach_init.c rename to mach/mach_init.c index 2d3bd9c..8bb2f53 100644 --- a/mach.subproj/mach_init.c +++ b/mach/mach_init.c @@ -55,7 +55,8 @@ mach_port_t mach_task_self_ = MACH_PORT_NULL; mach_port_t mach_host_self_ = MACH_PORT_NULL; -kern_return_t _host_semaphore_traps_return_ = KERN_SUCCESS; + +__private_extern__ kern_return_t _host_mach_msg_trap_return_; vm_size_t vm_page_size; @@ -99,7 +100,8 @@ mach_host_self() int mach_init_doit(int forkchild) { - mach_msg_type_number_t host_info_size = 0; + mach_msg_type_number_t host_info_size; + host_t host; /* * Get the important ports into the cached values, @@ -107,7 +109,7 @@ int mach_init_doit(int forkchild) */ mach_task_self_ = task_self_trap(); - mach_host_self_ = host_self_trap(); + host = host_self_trap(); if (!forkchild) { @@ -134,12 +136,18 @@ int mach_init_doit(int forkchild) /* * Cache some other valuable system constants */ - _host_semaphore_traps_return_ = host_info(mach_host_self_, - HOST_SEMAPHORE_TRAPS, + +#ifdef HOST_MACH_MSG_TRAP + host_info_size = 0; + _host_mach_msg_trap_return_ = host_info(host, + HOST_MACH_MSG_TRAP, 0, &host_info_size); +#endif + + (void)host_page_size(host, &vm_page_size); - (void)host_page_size(mach_host_self_, &vm_page_size); + mach_port_deallocate(mach_task_self_, host); mach_init_ports(); diff --git a/mach.subproj/mach_init_ports.c b/mach/mach_init_ports.c similarity index 91% rename from mach.subproj/mach_init_ports.c rename to mach/mach_init_ports.c index 8853ef7..b178e57 100644 --- a/mach.subproj/mach_init_ports.c +++ b/mach/mach_init_ports.c @@ -44,6 +44,7 @@ mach_init_ports(void) mach_port_array_t ports; mach_msg_type_number_t ports_count; kern_return_t kr; + host_t host; /* * Find those ports important to every task. @@ -71,18 +72,16 @@ mach_init_ports(void) (vm_size_t) (ports_count * sizeof *ports)); /* Get the clock service port for nanosleep */ - kr = host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &clock_port); + host = mach_host_self(); + kr = host_get_clock_service(host, SYSTEM_CLOCK, &clock_port); if (kr != KERN_SUCCESS) { abort(); } + mach_port_deallocate(mach_task_self(), host); kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &thread_recycle_port); if (kr != KERN_SUCCESS) { abort(); } - kr = mach_port_insert_right(mach_task_self(), thread_recycle_port, thread_recycle_port, MACH_MSG_TYPE_MAKE_SEND); - if (kr != KERN_SUCCESS) { - abort(); - } } #ifdef notdef diff --git a/mach/mach_msg.c b/mach/mach_msg.c new file mode 100644 index 0000000..ac5b433 --- /dev/null +++ b/mach/mach_msg.c @@ -0,0 +1,626 @@ +/* + * Copyright (c) 1999-2002 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ + +#include +#include +#include +#include +#include +#include +#include + +#ifdef HOST_MACH_MSG_TRAP +__private_extern__ kern_return_t _host_mach_msg_trap_return_ = KERN_FAILURE; + +#define MACH_MSG_TRAP(msg, opt, ssize, rsize, rname, to, not) \ + ((_host_mach_msg_trap_return_ == KERN_SUCCESS) ? \ + mach_msg_trap((msg), (opt), (ssize), (rsize), (rname), (to), (not)) : \ + mach_msg_overwrite_trap((msg), (opt), (ssize), (rsize), (rname), \ + (to), (not), MACH_MSG_NULL, 0)) + +#else + +#define MACH_MSG_TRAP(msg, opt, ssize, rsize, rname, to, not) \ + mach_msg_overwrite_trap((msg), (opt), (ssize), (rsize), (rname), \ + (to), (not), MACH_MSG_NULL, 0)) +#endif + +#define LIBMACH_OPTIONS (MACH_SEND_INTERRUPT|MACH_RCV_INTERRUPT) + +/* + * Routine: mach_msg + * Purpose: + * Send and/or receive a message. If the message operation + * is interrupted, and the user did not request an indication + * of that fact, then restart the appropriate parts of the + * operation. + */ +mach_msg_return_t +mach_msg(msg, option, send_size, rcv_size, rcv_name, timeout, notify) + mach_msg_header_t *msg; + mach_msg_option_t option; + mach_msg_size_t send_size; + mach_msg_size_t rcv_size; + mach_port_t rcv_name; + mach_msg_timeout_t timeout; + mach_port_t notify; +{ + mach_msg_return_t mr; + + /* + * Consider the following cases: + * 1) Errors in pseudo-receive (eg, MACH_SEND_INTERRUPTED + * plus special bits). + * 2) Use of MACH_SEND_INTERRUPT/MACH_RCV_INTERRUPT options. + * 3) RPC calls with interruptions in one/both halves. + * + * We refrain from passing the option bits that we implement + * to the kernel. This prevents their presence from inhibiting + * the kernel's fast paths (when it checks the option value). + */ + + mr = MACH_MSG_TRAP(msg, option &~ LIBMACH_OPTIONS, + send_size, rcv_size, rcv_name, + timeout, notify); + if (mr == MACH_MSG_SUCCESS) + return MACH_MSG_SUCCESS; + + if ((option & MACH_SEND_INTERRUPT) == 0) + while (mr == MACH_SEND_INTERRUPTED) + mr = MACH_MSG_TRAP(msg, + option &~ LIBMACH_OPTIONS, + send_size, rcv_size, rcv_name, + timeout, notify); + + if ((option & MACH_RCV_INTERRUPT) == 0) + while (mr == MACH_RCV_INTERRUPTED) + mr = MACH_MSG_TRAP(msg, + option &~ (LIBMACH_OPTIONS|MACH_SEND_MSG), + 0, rcv_size, rcv_name, + timeout, notify); + + return mr; +} + +/* + * Routine: mach_msg_overwrite + * Purpose: + * Send and/or receive a message. If the message operation + * is interrupted, and the user did not request an indication + * of that fact, then restart the appropriate parts of the + * operation. + * + * Distinct send and receive buffers may be specified. If + * no separate receive buffer is specified, the msg parameter + * will be used for both send and receive operations. + * + * In addition to a distinct receive buffer, that buffer may + * already contain scatter control information to direct the + * receiving of the message. + */ +mach_msg_return_t +mach_msg_overwrite(msg, option, send_size, rcv_limit, rcv_name, timeout, + notify, rcv_msg, rcv_scatter_size) + mach_msg_header_t *msg; + mach_msg_option_t option; + mach_msg_size_t send_size; + mach_msg_size_t rcv_limit; + mach_port_t rcv_name; + mach_msg_timeout_t timeout; + mach_port_t notify; + mach_msg_header_t *rcv_msg; + mach_msg_size_t rcv_scatter_size; +{ + mach_msg_return_t mr; + + /* + * Consider the following cases: + * 1) Errors in pseudo-receive (eg, MACH_SEND_INTERRUPTED + * plus special bits). + * 2) Use of MACH_SEND_INTERRUPT/MACH_RCV_INTERRUPT options. + * 3) RPC calls with interruptions in one/both halves. + * + * We refrain from passing the option bits that we implement + * to the kernel. This prevents their presence from inhibiting + * the kernel's fast paths (when it checks the option value). + */ + + mr = mach_msg_overwrite_trap(msg, option &~ LIBMACH_OPTIONS, + send_size, rcv_limit, rcv_name, + timeout, notify, rcv_msg, rcv_scatter_size); + if (mr == MACH_MSG_SUCCESS) + return MACH_MSG_SUCCESS; + + if ((option & MACH_SEND_INTERRUPT) == 0) + while (mr == MACH_SEND_INTERRUPTED) + mr = mach_msg_overwrite_trap(msg, + option &~ LIBMACH_OPTIONS, + send_size, rcv_limit, rcv_name, + timeout, notify, rcv_msg, rcv_scatter_size); + + if ((option & MACH_RCV_INTERRUPT) == 0) + while (mr == MACH_RCV_INTERRUPTED) + mr = mach_msg_overwrite_trap(msg, + option &~ (LIBMACH_OPTIONS|MACH_SEND_MSG), + 0, rcv_limit, rcv_name, + timeout, notify, rcv_msg, rcv_scatter_size); + + return mr; +} + + +mach_msg_return_t +mach_msg_send(mach_msg_header_t *msg) +{ + return mach_msg(msg, MACH_SEND_MSG, + msg->msgh_size, 0, MACH_PORT_NULL, + MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + +mach_msg_return_t +mach_msg_receive(mach_msg_header_t *msg) +{ + return mach_msg(msg, MACH_RCV_MSG, + 0, msg->msgh_size, msg->msgh_local_port, + MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); +} + + +static void +mach_msg_destroy_port(mach_port_t port, mach_msg_type_name_t type) +{ + if (MACH_PORT_VALID(port)) switch (type) { + case MACH_MSG_TYPE_MOVE_SEND: + case MACH_MSG_TYPE_MOVE_SEND_ONCE: + /* destroy the send/send-once right */ + (void) mach_port_deallocate(mach_task_self(), port); + break; + + case MACH_MSG_TYPE_MOVE_RECEIVE: + /* destroy the receive right */ + (void) mach_port_mod_refs(mach_task_self(), port, + MACH_PORT_RIGHT_RECEIVE, -1); + break; + + case MACH_MSG_TYPE_MAKE_SEND: + /* create a send right and then destroy it */ + (void) mach_port_insert_right(mach_task_self(), port, + port, MACH_MSG_TYPE_MAKE_SEND); + (void) mach_port_deallocate(mach_task_self(), port); + break; + + case MACH_MSG_TYPE_MAKE_SEND_ONCE: + /* create a send-once right and then destroy it */ + (void) mach_port_extract_right(mach_task_self(), port, + MACH_MSG_TYPE_MAKE_SEND_ONCE, + &port, &type); + (void) mach_port_deallocate(mach_task_self(), port); + break; + } +} + +static void +mach_msg_destroy_memory(vm_offset_t addr, vm_size_t size) +{ + if (size != 0) + (void) vm_deallocate(mach_task_self(), addr, size); +} + + +/* + * Routine: mach_msg_destroy + * Purpose: + * mach_msg_destroy is useful in two contexts. + * + * First, it can deallocate all port rights and + * out-of-line memory in a received message. + * When a server receives a request it doesn't want, + * it needs this functionality. + * + * Second, it can mimic the side-effects of a msg-send + * operation. The effect is as if the message were sent + * and then destroyed inside the kernel. When a server + * can't send a reply (because the client died), + * it needs this functionality. + */ +void +mach_msg_destroy(mach_msg_header_t *msg) +{ + mach_msg_bits_t mbits = msg->msgh_bits; + + /* + * The msgh_local_port field doesn't hold a port right. + * The receive operation consumes the destination port right. + */ + + mach_msg_destroy_port(msg->msgh_remote_port, MACH_MSGH_BITS_REMOTE(mbits)); + + if (mbits & MACH_MSGH_BITS_COMPLEX) { + mach_msg_body_t *body; + mach_msg_descriptor_t *saddr, *eaddr; + + body = (mach_msg_body_t *) (msg + 1); + saddr = (mach_msg_descriptor_t *) + ((mach_msg_base_t *) msg + 1); + eaddr = saddr + body->msgh_descriptor_count; + + for ( ; saddr < eaddr; saddr++) { + switch (saddr->type.type) { + + case MACH_MSG_PORT_DESCRIPTOR: { + mach_msg_port_descriptor_t *dsc; + + /* + * Destroy port rights carried in the message + */ + dsc = &saddr->port; + mach_msg_destroy_port(dsc->name, dsc->disposition); + break; + } + + case MACH_MSG_OOL_DESCRIPTOR : { + mach_msg_ool_descriptor_t *dsc; + + /* + * Destroy memory carried in the message + */ + dsc = &saddr->out_of_line; + if (dsc->deallocate) { + mach_msg_destroy_memory((vm_offset_t)dsc->address, + dsc->size); + } + break; + } + + case MACH_MSG_OOL_PORTS_DESCRIPTOR : { + mach_port_t *ports; + mach_msg_ool_ports_descriptor_t *dsc; + mach_msg_type_number_t j; + + /* + * Destroy port rights carried in the message + */ + dsc = &saddr->ool_ports; + ports = (mach_port_t *) dsc->address; + for (j = 0; j < dsc->count; j++, ports++) { + mach_msg_destroy_port(*ports, dsc->disposition); + } + + /* + * Destroy memory carried in the message + */ + if (dsc->deallocate) { + mach_msg_destroy_memory((vm_offset_t)dsc->address, + dsc->count * sizeof(mach_port_t)); + } + break; + } + } + } + } +} + +/* + * Routine: mach_msg_server_once + * Purpose: + * A simple generic server function. It allows more flexibility + * than mach_msg_server by processing only one message request + * and then returning to the user. Note that more in the way + * of error codes are returned to the user; specifically, any + * failing error from mach_msg calls will be returned + * (though errors from the demux routine or the routine it + * calls will not be). + */ +mach_msg_return_t +mach_msg_server_once( + boolean_t (*demux)(mach_msg_header_t *, mach_msg_header_t *), + mach_msg_size_t max_size, + mach_port_t rcv_name, + mach_msg_options_t options) +{ + mig_reply_error_t *bufRequest, *bufReply; + mach_msg_size_t request_size; + mach_msg_size_t request_alloc; + mach_msg_size_t trailer_alloc; + mach_msg_size_t reply_alloc; + mach_msg_return_t mr; + kern_return_t kr; + mach_port_t self = mach_task_self(); + + options &= ~(MACH_SEND_MSG|MACH_RCV_MSG); + + trailer_alloc = REQUESTED_TRAILER_SIZE(options); + request_alloc = round_page(max_size + trailer_alloc); + + request_size = (options & MACH_RCV_LARGE) ? + request_alloc : max_size + trailer_alloc; + + reply_alloc = round_page((options & MACH_SEND_TRAILER) ? + (max_size + MAX_TRAILER_SIZE) : + max_size); + + kr = vm_allocate(self, + (vm_address_t *)&bufReply, + reply_alloc, + VM_MAKE_TAG(VM_MEMORY_MACH_MSG)|TRUE); + if (kr != KERN_SUCCESS) + return kr; + + for (;;) { + mach_msg_size_t new_request_alloc; + + kr = vm_allocate(self, + (vm_address_t *)&bufRequest, + request_alloc, + VM_MAKE_TAG(VM_MEMORY_MACH_MSG)|TRUE); + if (kr != KERN_SUCCESS) { + vm_deallocate(self, + (vm_address_t)bufReply, + reply_alloc); + return kr; + } + + mr = mach_msg(&bufRequest->Head, MACH_RCV_MSG|options, + 0, request_size, rcv_name, + MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + + if (!((mr == MACH_RCV_TOO_LARGE) && (options & MACH_RCV_LARGE))) + break; + + new_request_alloc = round_page(bufRequest->Head.msgh_size + + trailer_alloc); + vm_deallocate(self, + (vm_address_t) bufRequest, + request_alloc); + request_size = request_alloc = new_request_alloc; + } + + if (mr == MACH_MSG_SUCCESS) { + /* we have a request message */ + + (void) (*demux)(&bufRequest->Head, &bufReply->Head); + + if (!(bufReply->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) { + if (bufReply->RetCode == MIG_NO_REPLY) + bufReply->Head.msgh_remote_port = MACH_PORT_NULL; + else if ((bufReply->RetCode != KERN_SUCCESS) && + (bufRequest->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) { + /* destroy the request - but not the reply port */ + bufRequest->Head.msgh_remote_port = MACH_PORT_NULL; + mach_msg_destroy(&bufRequest->Head); + } + } + + /* + * We don't want to block indefinitely because the client + * isn't receiving messages from the reply port. + * If we have a send-once right for the reply port, then + * this isn't a concern because the send won't block. + * If we have a send right, we need to use MACH_SEND_TIMEOUT. + * To avoid falling off the kernel's fast RPC path unnecessarily, + * we only supply MACH_SEND_TIMEOUT when absolutely necessary. + */ + if (bufReply->Head.msgh_remote_port != MACH_PORT_NULL) { + + mr = mach_msg(&bufReply->Head, + (MACH_MSGH_BITS_REMOTE(bufReply->Head.msgh_bits) == + MACH_MSG_TYPE_MOVE_SEND_ONCE) ? + MACH_SEND_MSG|options : + MACH_SEND_MSG|MACH_SEND_TIMEOUT|options, + bufReply->Head.msgh_size, 0, MACH_PORT_NULL, + MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + + if ((mr != MACH_SEND_INVALID_DEST) && + (mr != MACH_SEND_TIMED_OUT)) + goto done_once; + mr = MACH_MSG_SUCCESS; + } + if (bufReply->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) + mach_msg_destroy(&bufReply->Head); + } + + done_once: + (void)vm_deallocate(self, + (vm_address_t) bufRequest, + request_alloc); + (void)vm_deallocate(self, + (vm_address_t) bufReply, + reply_alloc); + return mr; +} + +/* + * Routine: mach_msg_server + * Purpose: + * A simple generic server function. Note that changes here + * should be considered for duplication above. + */ +mach_msg_return_t +mach_msg_server( + boolean_t (*demux)(mach_msg_header_t *, mach_msg_header_t *), + mach_msg_size_t max_size, + mach_port_t rcv_name, + mach_msg_options_t options) +{ + mig_reply_error_t *bufRequest, *bufReply; + mach_msg_size_t request_size; + mach_msg_size_t new_request_alloc; + mach_msg_size_t request_alloc; + mach_msg_size_t trailer_alloc; + mach_msg_size_t reply_alloc; + mach_msg_return_t mr; + kern_return_t kr; + mach_port_t self = mach_task_self(); + + options &= ~(MACH_SEND_MSG|MACH_RCV_MSG); + + reply_alloc = round_page((options & MACH_SEND_TRAILER) ? + (max_size + MAX_TRAILER_SIZE) : max_size); + + kr = vm_allocate(self, + (vm_address_t *)&bufReply, + reply_alloc, + VM_MAKE_TAG(VM_MEMORY_MACH_MSG)|TRUE); + if (kr != KERN_SUCCESS) + return kr; + + request_alloc = 0; + trailer_alloc = REQUESTED_TRAILER_SIZE(options); + new_request_alloc = round_page(max_size + trailer_alloc); + + request_size = (options & MACH_RCV_LARGE) ? + new_request_alloc : max_size + trailer_alloc; + + for (;;) { + if (request_alloc < new_request_alloc) { + request_alloc = new_request_alloc; + kr = vm_allocate(self, + (vm_address_t *)&bufRequest, + request_alloc, + VM_MAKE_TAG(VM_MEMORY_MACH_MSG)|TRUE); + if (kr != KERN_SUCCESS) { + vm_deallocate(self, + (vm_address_t)bufReply, + reply_alloc); + return kr; + } + } + + mr = mach_msg(&bufRequest->Head, MACH_RCV_MSG|options, + 0, request_size, rcv_name, + MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + + while (mr == MACH_MSG_SUCCESS) { + /* we have another request message */ + + (void) (*demux)(&bufRequest->Head, &bufReply->Head); + + if (!(bufReply->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) { + if (bufReply->RetCode == MIG_NO_REPLY) + bufReply->Head.msgh_remote_port = MACH_PORT_NULL; + else if ((bufReply->RetCode != KERN_SUCCESS) && + (bufRequest->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) { + /* destroy the request - but not the reply port */ + bufRequest->Head.msgh_remote_port = MACH_PORT_NULL; + mach_msg_destroy(&bufRequest->Head); + } + } + + /* + * We don't want to block indefinitely because the client + * isn't receiving messages from the reply port. + * If we have a send-once right for the reply port, then + * this isn't a concern because the send won't block. + * If we have a send right, we need to use MACH_SEND_TIMEOUT. + * To avoid falling off the kernel's fast RPC path, + * we only supply MACH_SEND_TIMEOUT when absolutely necessary. + */ + if (bufReply->Head.msgh_remote_port != MACH_PORT_NULL) { + if (request_alloc == reply_alloc) { + mig_reply_error_t *bufTemp; + + mr = mach_msg( + &bufReply->Head, + (MACH_MSGH_BITS_REMOTE(bufReply->Head.msgh_bits) == + MACH_MSG_TYPE_MOVE_SEND_ONCE) ? + MACH_SEND_MSG|MACH_RCV_MSG|options : + MACH_SEND_MSG|MACH_RCV_MSG|MACH_SEND_TIMEOUT|options, + bufReply->Head.msgh_size, request_size, rcv_name, + MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + + /* swap request and reply */ + bufTemp = bufRequest; + bufRequest = bufReply; + bufReply = bufTemp; + + } else { + mr = mach_msg_overwrite( + &bufReply->Head, + (MACH_MSGH_BITS_REMOTE(bufReply->Head.msgh_bits) == + MACH_MSG_TYPE_MOVE_SEND_ONCE) ? + MACH_SEND_MSG|MACH_RCV_MSG|options : + MACH_SEND_MSG|MACH_RCV_MSG|MACH_SEND_TIMEOUT|options, + bufReply->Head.msgh_size, request_size, rcv_name, + MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL, + &bufRequest->Head, request_size); + } + + if ((mr != MACH_SEND_INVALID_DEST) && + (mr != MACH_SEND_TIMED_OUT)) + continue; + } + if (bufReply->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) + mach_msg_destroy(&bufReply->Head); + + mr = mach_msg(&bufRequest->Head, MACH_RCV_MSG|options, + 0, request_size, rcv_name, + MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + + } /* while (mr == MACH_MSG_SUCCESS) */ + + if ((mr == MACH_RCV_TOO_LARGE) && (options & MACH_RCV_LARGE)) { + new_request_alloc = round_page(bufRequest->Head.msgh_size + + trailer_alloc); + request_size = new_request_alloc; + vm_deallocate(self, + (vm_address_t) bufRequest, + request_alloc); + continue; + } + + break; + + } /* for(;;) */ + + (void)vm_deallocate(self, + (vm_address_t) bufRequest, + request_alloc); + (void)vm_deallocate(self, + (vm_address_t) bufReply, + reply_alloc); + return mr; +} diff --git a/mach.subproj/mach_port.defs b/mach/mach_port.defs similarity index 100% rename from mach.subproj/mach_port.defs rename to mach/mach_port.defs diff --git a/mach.subproj/mach_traps.s b/mach/mach_traps.s similarity index 100% rename from mach.subproj/mach_traps.s rename to mach/mach_traps.s diff --git a/mach.subproj/mig_allocate.c b/mach/mig_allocate.c similarity index 100% rename from mach.subproj/mig_allocate.c rename to mach/mig_allocate.c diff --git a/mach.subproj/mig_deallocate.c b/mach/mig_deallocate.c similarity index 100% rename from mach.subproj/mig_deallocate.c rename to mach/mig_deallocate.c diff --git a/mach.subproj/mig_reply_setup.c b/mach/mig_reply_setup.c similarity index 100% rename from mach.subproj/mig_reply_setup.c rename to mach/mig_reply_setup.c diff --git a/mach.subproj/mig_strncpy.c b/mach/mig_strncpy.c similarity index 98% rename from mach.subproj/mig_strncpy.c rename to mach/mig_strncpy.c index fe2a314..662cc4f 100644 --- a/mach.subproj/mig_strncpy.c +++ b/mach/mig_strncpy.c @@ -68,7 +68,7 @@ int mig_strncpy( register char *dest, - register char *src, + register const char *src, register int len) { register int i; diff --git a/mach.subproj/ms_thread_switch.c b/mach/ms_thread_switch.c similarity index 100% rename from mach.subproj/ms_thread_switch.c rename to mach/ms_thread_switch.c diff --git a/mach.subproj/notify.defs b/mach/notify.defs similarity index 100% rename from mach.subproj/notify.defs rename to mach/notify.defs diff --git a/mach.subproj/panic.c b/mach/panic.c similarity index 100% rename from mach.subproj/panic.c rename to mach/panic.c diff --git a/mach.subproj/port_obj.c b/mach/port_obj.c similarity index 100% rename from mach.subproj/port_obj.c rename to mach/port_obj.c diff --git a/mach.subproj/processor.defs b/mach/processor.defs similarity index 100% rename from mach.subproj/processor.defs rename to mach/processor.defs diff --git a/mach.subproj/processor_set.defs b/mach/processor_set.defs similarity index 100% rename from mach.subproj/processor_set.defs rename to mach/processor_set.defs diff --git a/mach.subproj/sbrk.c b/mach/sbrk.c similarity index 100% rename from mach.subproj/sbrk.c rename to mach/sbrk.c diff --git a/mach.subproj/semaphore.c b/mach/semaphore.c similarity index 91% rename from mach.subproj/semaphore.c rename to mach/semaphore.c index e0ac63b..3b94c46 100644 --- a/mach.subproj/semaphore.c +++ b/mach/semaphore.c @@ -19,11 +19,6 @@ * * @APPLE_LICENSE_HEADER_END@ */ -/* - * catch_exception_raise will be implemented by user programs - * This implementation is provided to resolve the reference in - * exc_server(). - */ #include #include @@ -32,8 +27,6 @@ #include #include -extern kern_return_t _host_semaphore_traps_return_; - kern_return_t semaphore_signal( mach_port_t signal_semaphore) { diff --git a/mach/servers/Makefile.inc b/mach/servers/Makefile.inc new file mode 100644 index 0000000..d0ff159 --- /dev/null +++ b/mach/servers/Makefile.inc @@ -0,0 +1,45 @@ +.PATH: ${.CURDIR}/${MACHINE_ARCH}/mach/servers ${.CURDIR}/mach/servers + +SRVMIGDEFS += srvbootstrap.defs netname.defs + +SRVMIGHDRS = ${SRVMIGDEFS:S/.defs$/.h/} +#SRVMIGHDRS = ${SRVMIGDEFS:S/.defs$/.h/:S/^/${.CURDIR}\/mach\/servers\//} +SRVMIGSRCS = ${SRVMIGDEFS:S/.defs$/User.c/} + +SRVHDRS = bootstrap_defs.h netname_defs.h key_defs.h nm_defs.h ls_defs.h +SRVHDRS := ${SRVHDRS:S/^/${.CURDIR}\/mach\/servers\//} +SRVHDRS += ${SRVMIGHDRS} + +SRCS+= ${SRVMIGDEFS:S/.defs$/User.defs/} + +CLEANFILES += ${SRVMIGHDRS} ${SRVMIGHDRS:S/.h$/User.c/} \ + ${SRVMIGHDRS:S/.h$/Server.c/} + +${SRVMIGDEFS:S/.defs$/User.So/}: + mig -user ${.TARGET:S/.So$/.c/} \ + -server ${.TARGET:S/User.So$/Server.c/} \ + -header ${.TARGET:S/User.So$/.h/} \ + ${.CURDIR}/mach/servers/${.TARGET:S/User.So$/.defs/} + ${CC} ${CFLAGS} -Os -c ${.TARGET:S/.So$/.c/}\ + -o ${.TARGET} +${SRVMIGDEFS:S/.defs$/User.do/}: + mig -user ${.TARGET:S/.do$/.c/} \ + -server ${.TARGET:S/User.do$/Server.c/} \ + -header ${.TARGET:S/User.do$/.h/} \ + ${.CURDIR}/mach/servers/${.TARGET:S/User.do$/.defs/} + ${CC} -g -DDEBUG ${CFLAGS} -c ${.TARGET:S/.do$/.c/}\ + -o ${.TARGET} +${SRVMIGDEFS:S/.defs$/User.po/}: + mig -user ${.TARGET:S/.po$/.c/} \ + -server ${.TARGET:S/User.po$/Server.c/} \ + -header ${.TARGET:S/User.po$/.h/} \ + ${.CURDIR}/mach/servers/${.TARGET:S/User.po$/.defs/} + ${CC} -pg -DPROFILE ${CFLAGS} -c ${.TARGET:S/.po$/.c/}\ + -o ${.TARGET} +${SRVMIGDEFS:S/.defs$/User.o/}: + mig -user ${.TARGET:S/.o$/.c/} \ + -server ${.TARGET:S/User.o$/Server.c/} \ + -header ${.TARGET:S/User.o$/.h/} \ + ${.CURDIR}/mach/servers/${.TARGET:S/User.o$/.defs/} + ${CC} -static ${CFLAGS} -c ${.TARGET:S/.o$/.c/}\ + -o ${.TARGET} diff --git a/mach.subproj/servers.subproj/bootstrap_defs.h b/mach/servers/bootstrap_defs.h similarity index 79% rename from mach.subproj/servers.subproj/bootstrap_defs.h rename to mach/servers/bootstrap_defs.h index 18a8ca8..1bcd27d 100644 --- a/mach.subproj/servers.subproj/bootstrap_defs.h +++ b/mach/servers/bootstrap_defs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2002 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -38,16 +38,23 @@ typedef char name_t[BOOTSTRAP_MAX_NAME_LEN]; typedef char cmd_t[BOOTSTRAP_MAX_CMD_LEN]; typedef name_t *name_array_t; +typedef int bootstrap_status_t; +typedef bootstrap_status_t *bootstrap_status_array_t; + typedef boolean_t *bool_array_t; #define BOOTSTRAP_MAX_LOOKUP_COUNT 20 #define BOOTSTRAP_SUCCESS 0 -#define BOOTSTRAP_NOT_PRIVILEGED 1100 -#define BOOTSTRAP_NAME_IN_USE 1101 -#define BOOTSTRAP_UNKNOWN_SERVICE 1102 -#define BOOTSTRAP_SERVICE_ACTIVE 1103 +#define BOOTSTRAP_NOT_PRIVILEGED 1100 +#define BOOTSTRAP_NAME_IN_USE 1101 +#define BOOTSTRAP_UNKNOWN_SERVICE 1102 +#define BOOTSTRAP_SERVICE_ACTIVE 1103 #define BOOTSTRAP_BAD_COUNT 1104 #define BOOTSTRAP_NO_MEMORY 1105 +#define BOOTSTRAP_STATUS_INACTIVE 0 +#define BOOTSTRAP_STATUS_ACTIVE 1 +#define BOOTSTRAP_STATUS_ON_DEMAND 2 + #endif /* _BOOTSTRAP_DEFS_ */ diff --git a/mach.subproj/servers.subproj/key_defs.h b/mach/servers/key_defs.h similarity index 100% rename from mach.subproj/servers.subproj/key_defs.h rename to mach/servers/key_defs.h diff --git a/mach.subproj/servers.subproj/ls_defs.h b/mach/servers/ls_defs.h similarity index 100% rename from mach.subproj/servers.subproj/ls_defs.h rename to mach/servers/ls_defs.h diff --git a/mach.subproj/servers.subproj/netname.defs b/mach/servers/netname.defs similarity index 100% rename from mach.subproj/servers.subproj/netname.defs rename to mach/servers/netname.defs diff --git a/mach.subproj/servers.subproj/netname_defs.h b/mach/servers/netname_defs.h similarity index 100% rename from mach.subproj/servers.subproj/netname_defs.h rename to mach/servers/netname_defs.h diff --git a/mach.subproj/servers.subproj/nm_defs.h b/mach/servers/nm_defs.h similarity index 100% rename from mach.subproj/servers.subproj/nm_defs.h rename to mach/servers/nm_defs.h diff --git a/mach.subproj/servers.subproj/bootstrap.defs b/mach/servers/srvbootstrap.defs similarity index 52% rename from mach.subproj/servers.subproj/bootstrap.defs rename to mach/servers/srvbootstrap.defs index 0daa753..43a0b60 100644 --- a/mach.subproj/servers.subproj/bootstrap.defs +++ b/mach/servers/srvbootstrap.defs @@ -1,3 +1,26 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." + * + * @APPLE_LICENSE_HEADER_END@ + */ /* * bootstrap -- fundamental service initiator and port server * Mike DeMoney, NeXT, Inc. @@ -14,19 +37,15 @@ subsystem bootstrap 400; * The bootstrap server is the first user-mode task initiated by the Mach * kernel at system boot time. The bootstrap server provides two services, * it initiates other system tasks, and manages a table of name-port bindings - * for fundamental system services (e.g. the NetMsgServer, and the Unix - * emulation service). - * - * The file /etc/bootstrap.conf is read by bootstrap to determine other system - * services to initiate at system boot time. The format of this file is - * described later. + * for fundamental system services (e.g. lookupd, Window Manager, etc...). * * Name-port bindings can be established with the bootstrap server by either * of two mechanisms: * - * 1. The binding can be indicated in the file /etc/bootstrap.conf. In this - * case, bootstrap will immediately create a port and bind the indicated name - * with that port. At a later time, a service may "checkin" for the name-port + * 1. The binding can be indicated, in advance of the service that backs it + * being available, via a "service create" request. In this case, bootstrap + * will immediately create a port and bind the indicated name with that port. + * At a later time, a service may "checkin" for the name-port * binding and will be returned receive rights for the bound port. Lookup's * on bindings created by this mechanism will return send rights to the port, * even if no service has "checked-in". In this case, requests sent to the @@ -50,98 +69,112 @@ subsystem bootstrap 400; * it is marked available for check-out again. This allows crashed servers to * resume service to previous clients. Lookup's on this named port will * continue to be serviced by bootstrap while holding receive rights for the - * bound port. A client may detect that the service is inactive via the. - * bootstrap status request. If the service re-registers rather than - * "checking-in" the original bound port is destroyed. + * bound port. A client may detect that the service is inactive via the + * bootstrap status request. If an inactive service re-registers rather + * than "checking-in" the original bound port is destroyed. * * The status of a named service may be obtained via the "status" request. * A service is "active" if a name-port binding exists and receive rights * to the bound port are held by a task other than bootstrap. * - * Bootstrap initiates server tasks and creates initial name-port bindings as - * directed by the configuration file /etc/bootstrap.conf. This file has - * entries with the following formats: - * - * services [ SERVICE_NAME ]+ ; - * - * E.g: - * services OldService=1 SomeService; - * - * Creates a port and binds the name "OldService" to it. - * For compatability, assigns the port via mach_ports_register to - * slot 1. Also creates a port and binds the name "SomeService". - * - * self [ SERVICE_NAME ]+ ; - * - * E.g: - * self BootStrapService; - * - * Provides a binding to bootstrap's own service port named - * "BootStrapService". - * - * [restartable] server SERVER_FILE_AND_ARGS [ services ... ] ; - * - * E.g: - * server "/usr/etc/sigserver -i" services UnixSignalService; - * - * Initiates the server task "/usr/etc/sigserver" with - * command-line argument "-i", and also creates a name-port - * binding for the name UnixSignalService. Checkin requests for - * UnixSignalService are only accepted via the bootstrap service - * port passed to/usr/etc/sigserver. If the "restartable" option - * had been specified, bootstrap will reinitiate the server task - * if it receives notification that all of the server's service - * ports have been destroyed or deallocated. The server command - * may be specified without surrounding quotes if it does not - * include blanks. - * - * init SERVER_FILE_AND_ARGS [ services ... ] ; - * - * E.g: - * init /etc/init services NetMsgService=0 PSWindowService=4; - * - * Functions like "server" request above, except process is - * started as pid 1. Illegal if bootstrap itself was not - * initiated as pid 1. - * - * forward; - * - * If present, bootstrap will forward unknown lookup requests to - * its bootstrap service port (if not PORT_NULL), and forward any - * reply to the original requester. - * - * # Comment string up to end of line. - * - * A line terminated comment starts with a sharp sign (#). - * - * Lexical notes: Strings are either enclosed in double quotes ("), or must - * start with a letter or underscore (_) and followed by a string of - * alphanumerics and underscores; backslash (\) escapes the following - * character. Strings are limited to a (large) length. Numbers must be - * decimal. Blanks and newlines may be freely used outside of strings. + * The bootstrap server may also (re)start server processes associated with + * with a set of services. The definition of the server process is done + * through the "create server" request. The server will be launched in the + * same bootstrap context in which it was registered. */ #include +#include import ; -type name_t = c_string[128]; -type name_array_t = ^array [] of name_t; -type bool_array_t = ^array [] of boolean_t; +type cmd_t = c_string[512]; +type name_t = c_string[128]; +type cmd_array_t = ^array [] of cmd_t; +type name_array_t = ^array [] of name_t; +type bootstrap_status_t = integer_t; +type bootstrap_status_array_t = ^array [] of bootstrap_status_t; serverprefix x_; -/* old service_checkin */ -skip; -/* old service_status */ -skip; +/* + * kern_return_t + * bootstrap_create_server(mach_port_t bootstrap_port, + * cmd_t server_command, + * integer_t server_uid, + * boolean_t on_demand, + * mach_port_t *server_port) + * + * Declares a server that mach_init will re-spawn within the specified + * bootstrap context. The server is considered already "active" + * (i.e. will not be re-spawned) until the returned server_port is + * deallocated. + * + * In the meantime, services can be declared against the server, + * by using the server_port as the privileged bootstrap target of + * subsequent bootstrap_create_service() calls. + * + * When mach_init re-spawns the server, its task bootstrap port + * is set to the privileged sever_port. Through this special + * bootstrap port, it can access all of parent bootstrap's context + * (and all services are created in the parent's namespace). But + * all additional service declarations (and declaration removals) + * will be associated with this particular server. + * + * Only a holder of the server_port privilege bootstrap port can + * check in or register over those services. + * + * When all services associated with a server are deleted, and the server + * exits, it will automatically be deleted itself. + * + * If the server is declared "on_demand," then a non-running server + * will be re-launched on first use of one of the service ports + * registered against it. Otherwise, it will be re-launched + * immediately upon exiting (whether any client is actively using + * any of the service ports or not). + * + * Errors: Returns appropriate kernel errors on rpc failure. + * Returns BOOTSTRAP_NOT_PRIVILEGED, bootstrap or uid invalid. + */ +routine bootstrap_create_server( + bootstrap_port : mach_port_t; + server_cmd : cmd_t; + server_uid : integer_t; + on_demand : boolean_t; + ServerSecToken token : security_token_t; + out server_port : mach_port_make_send_t); + +/* + * kern_return_t + * bootstrap_unprivileged(mach_port_t bootstrap_port, + * mach_port_t *unpriv_port) + * + * Given a bootstrap port, return its unprivileged equivalent. If + * the port is already unprivileged, another reference to the same + * port is returned. + * + * This is most often used by servers, which are launched with their + * bootstrap port set to the privileged port for the server, to get + * an unprivileged version of the same port for use by its unprivileged + * children (or any offspring that it does not want to count as part + * of the "server" for mach_init registration and re-launch purposes). + */ +routine bootstrap_unprivileged( + bootstrap_port : mach_port_t; + out unpriv_port : mach_port_t); /* * kern_return_t * bootstrap_check_in(mach_port_t bootstrap_port, * name_t service_name, - * port_all_t *service_port) + * mach_port_t *service_port) + * + * Returns the receive right for the service named by service_name. The + * service must have previously been declared in this bootstrap context via + * a call to bootstrap_create_service(). Attempts to check_in a service + * which is already active are not allowed. * - * Returns all rights to service_port of service named by service_name. + * If the service was declared as being associated with a server, the + * check_in must come from the server's privileged port (server_port). * * Errors: Returns appropriate kernel errors on rpc failure. * Returns BOOTSTRAP_UNKNOWN_SERVICE, if service does not exist. @@ -161,14 +194,15 @@ routine bootstrap_check_in( * name_t service_name, * mach_port_t service_port) * - * Registers send rights for the port service_port for the service named by - * service_name. Attempts to registering a service where an active binding - * already exists are rejected. On the otherhand, registering a service where - * and inactive binding exists (i.e. bootstrap currently holds receive rights - * for the service port) is allowed; in this case the previous service port - * will be deallocated. Restarting services wishing to resume service for - * previous clients must first attempt to checkin to the service in order to - * recover the previous service port. + * Registers a send right for service_port with the service identified by + * service_name. Attempts to register a service where an active binding + * already exists are rejected. + * + * If the service was previously declared with bootstrap_create_service(), + * but is not currently active, this call can be used to undeclare the + * service. The bootstrap port used must have sufficient privilege to + * do so. (Registering MACH_PORT_NULL is especially useful for shutting + * down declared services). * * Errors: Returns appropriate kernel errors on rpc failure. * Returns BOOTSTRAP_NOT_PRIVILEGED, if request directed to @@ -187,8 +221,9 @@ routine bootstrap_register( * name_t service_name, * mach_port_t *service_port) * - * Returns send rights for the service port of the service named by - * service_name in service_port. Service is not guaranteed to be active. + * Returns a send right for the service port declared/registered under the + * name service_name. The service is not guaranteed to be active. Use the + * bootstrap_status call to determine the status of the service. * * Errors: Returns appropriate kernel errors on rpc failure. * Returns BOOTSTRAP_UNKNOWN_SERVICE, if service does not exist. @@ -226,16 +261,33 @@ routine bootstrap_look_up_array( out service_ports : mach_port_array_t; out all_services_known: boolean_t); -/* old bootstrap_get_unpriv_port */ -skip; +/* + * kern_return_t + * bootstrap_parent(mach_port_t bootstrap_port, + * mach_port_t *parent_port); + * + * Given a bootstrap subset port, return the parent bootstrap port. + * If the specified bootstrap port is already the root subset, + * MACH_PORT_NULL will be returned. + * + * Errors: + * Returns BOOTSTRAP_NOT_PRIVILEGED if the caller is not running + * with an effective user id of root (as determined by the security + * token in the message trailer). + */ +routine bootstrap_parent( + bootstrap_port : mach_port_t; + ServerSecToken token : security_token_t; + out parent_port : mach_port_t); /* * kern_return_t * bootstrap_status(mach_port_t bootstrap_port, * name_t service_name, - * boolean_t *service_active); + * bootstrap_status_t *service_active); * - * Returns: service_active is true if service is available. + * Returns: service_active indicates if service is active, inactive, or + * associated with a launch-on-demand server. * * Errors: Returns appropriate kernel errors on rpc failure. * Returns BOOTSTRAP_UNKNOWN_SERVICE, if service does not exist. @@ -243,7 +295,7 @@ skip; routine bootstrap_status( bootstrap_port : mach_port_t; service_name : name_t; - out service_active : boolean_t); + out service_active : bootstrap_status_t); /* * kern_return_t @@ -261,7 +313,7 @@ routine bootstrap_info( bootstrap_port : mach_port_t; out service_names : name_array_t, dealloc; out server_names : name_array_t, dealloc; - out service_active : bool_array_t, dealloc); + out service_active : bootstrap_status_array_t, dealloc); /* * kern_return_t @@ -278,7 +330,7 @@ routine bootstrap_info( * registered with an ancestor port may be registered with the subset port * are allowed. Services already advertised may then be effectively removed * by registering PORT_NULL for the service. - * When it is detected that the requestor_port is destroied the subset + * When it is detected that the requestor_port is destroyed the subset * port and all services advertized by it are destroied as well. * * Errors: Returns appropriate kernel errors on rpc failure. @@ -305,3 +357,4 @@ routine bootstrap_create_service( bootstrap_port : mach_port_t; service_name : name_t; out service_port : mach_port_t); + diff --git a/mach.subproj/slot_name.c b/mach/slot_name.c similarity index 100% rename from mach.subproj/slot_name.c rename to mach/slot_name.c diff --git a/mach.subproj/task.defs b/mach/task.defs similarity index 100% rename from mach.subproj/task.defs rename to mach/task.defs diff --git a/mach.subproj/thread_act.defs b/mach/thread_act.defs similarity index 100% rename from mach.subproj/thread_act.defs rename to mach/thread_act.defs diff --git a/mach.subproj/vm_map.defs b/mach/vm_map.defs similarity index 100% rename from mach.subproj/vm_map.defs rename to mach/vm_map.defs diff --git a/net.subproj/Makefile b/net.subproj/Makefile deleted file mode 100644 index 7417017..0000000 --- a/net.subproj/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -# -# Generated by the NeXT Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = net - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -CFILES = inet_addr.c inet_lnaof.c inet_makeaddr.c inet_netof.c\ - inet_network.c inet_ntoa.c iso_addr.c linkaddr.c ns_addr.c\ - ns_ntoa.c nsap_addr.c recv.c - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble - - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - - - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/net.subproj/Makefile.postamble b/net.subproj/Makefile.postamble deleted file mode 100644 index 411cde6..0000000 --- a/net.subproj/Makefile.postamble +++ /dev/null @@ -1,100 +0,0 @@ -############################################################################### -# Makefile.postamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile, which is imported after all other makefiles, to -# override attributes for a project's Makefile environment. This allows you -# to take advantage of the environment set up by the other Makefiles. -# You can also define custom rules at the end of this file. -# -############################################################################### -# -# These variables are exported by the standard makefiles and can be -# used in any customizations you make. They are *outputs* of -# the Makefiles and should be used, not set. -# -# PRODUCTS: products to install. All of these products will be placed in -# the directory $(DSTROOT)$(INSTALLDIR) -# GLOBAL_RESOURCE_DIR: The directory to which resources are copied. -# LOCAL_RESOURCE_DIR: The directory to which localized resources are copied. -# OFILE_DIR: Directory into which .o object files are generated. -# DERIVED_SRC_DIR: Directory used for all other derived files -# -# ALL_CFLAGS: flags to pass when compiling .c files -# ALL_MFLAGS: flags to pass when compiling .m files -# ALL_CCFLAGS: flags to pass when compiling .cc, .cxx, and .C files -# ALL_MMFLAGS: flags to pass when compiling .mm, .mxx, and .M files -# ALL_PRECOMPFLAGS: flags to pass when precompiling .h files -# ALL_LDFLAGS: flags to pass when linking object files -# ALL_LIBTOOL_FLAGS: flags to pass when libtooling object files -# ALL_PSWFLAGS: flags to pass when processing .psw and .pswm (pswrap) files -# ALL_RPCFLAGS: flags to pass when processing .rpc (rpcgen) files -# ALL_YFLAGS: flags to pass when processing .y (yacc) files -# ALL_LFLAGS: flags to pass when processing .l (lex) files -# -# NAME: name of application, bundle, subproject, palette, etc. -# LANGUAGES: langages in which the project is written (default "English") -# English_RESOURCES: localized resources (e.g. nib's, images) of project -# GLOBAL_RESOURCES: non-localized resources of project -# -# SRCROOT: base directory in which to place the new source files -# SRCPATH: relative path from SRCROOT to present subdirectory -# -# INSTALLDIR: Directory the product will be installed into by 'install' target -# PUBLIC_HDR_INSTALLDIR: where to install public headers. Don't forget -# to prefix this with DSTROOT when you use it. -# PRIVATE_HDR_INSTALLDIR: where to install private headers. Don't forget -# to prefix this with DSTROOT when you use it. -# -# EXECUTABLE_EXT: Executable extension for the platform (i.e. .exe on Windows) -# -############################################################################### - -# Some compiler flags can be overridden here for certain build situations. -# -# WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost) -# DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults -# to -g) -# DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG) -# OPTIMIZE_BUILD_CFLAGS: flags passed during optimized builds (defaults -# to -O) -# PROFILE_BUILD_CFLAGS: flags passed during profile builds (defaults -# to -pg -DPROFILE) -# LOCAL_DIR_INCLUDE_DIRECTIVE: flag used to add current directory to -# the include path (defaults to -I.) -# DEBUG_BUILD_LDFLAGS, OPTIMIZE_BUILD_LDFLAGS, PROFILE_BUILD_LDFLAGS: flags -# passed to ld/libtool (defaults to nothing) - - -# Library and Framework projects only: -# INSTALL_NAME_DIRECTIVE: This directive ensures that executables linked -# against the framework will run against the correct version even if -# the current version of the framework changes. You may override this -# to "" as an alternative to using the DYLD_LIBRARY_PATH during your -# development cycle, but be sure to restore it before installing. - - -# Ownership and permissions of files installed by 'install' target - -#INSTALL_AS_USER = root - # User/group ownership -#INSTALL_AS_GROUP = wheel - # (probably want to set both of these) -#INSTALL_PERMISSIONS = - # If set, 'install' chmod's executable to this - - -# Options to strip. Note: -S strips debugging symbols (executables can be stripped -# down further with -x or, if they load no bundles, with no options at all). - -#STRIPFLAGS = -S - - -######################################################################### -# Put rules to extend the behavior of the standard Makefiles here. Include them in -# the dependency tree via cvariables like AFTER_INSTALL in the Makefile.preamble. -# -# You should avoid redefining things like "install" or "app", as they are -# owned by the top-level Makefile API and no context has been set up for where -# derived files should go. -# diff --git a/net.subproj/Makefile.preamble b/net.subproj/Makefile.preamble deleted file mode 100644 index c1624b4..0000000 --- a/net.subproj/Makefile.preamble +++ /dev/null @@ -1,137 +0,0 @@ -############################################################################### -# Makefile.preamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile for configuring the standard application makefiles -# associated with ProjectBuilder. It is included before the main makefile. -# In Makefile.preamble you set attributes for a project, so they are available -# to the project's makefiles. In contrast, you typically write additional rules or -# override built-in behavior in the Makefile.postamble. -# -# Each directory in a project tree (main project plus subprojects) should -# have its own Makefile.preamble and Makefile.postamble. -############################################################################### -# -# Before the main makefile is included for this project, you may set: -# -# MAKEFILEDIR: Directory in which to find $(MAKEFILE) -# MAKEFILE: Top level mechanism Makefile (e.g., app.make, bundle.make) - -# Compiler/linker flags added to the defaults: The OTHER_* variables will be -# inherited by all nested sub-projects, but the LOCAL_ versions of the same -# variables will not. Put your -I, -D, -U, and -L flags in ProjectBuilder's -# Build Attributes inspector if at all possible. To override the default flags -# that get passed to ${CC} (e.g. change -O to -O2), see Makefile.postamble. The -# variables below are *inputs* to the build process and distinct from the override -# settings done (less often) in the Makefile.postamble. -# -# OTHER_CFLAGS, LOCAL_CFLAGS: additional flags to pass to the compiler -# Note that $(OTHER_CFLAGS) and $(LOCAL_CFLAGS) are used for .h, ...c, .m, -# .cc, .cxx, .C, and .M files. There is no need to respecify the -# flags in OTHER_MFLAGS, etc. -# OTHER_MFLAGS, LOCAL_MFLAGS: additional flags for .m files -# OTHER_CCFLAGS, LOCAL_CCFLAGS: additional flags for .cc, .cxx, and ...C files -# OTHER_MMFLAGS, LOCAL_MMFLAGS: additional flags for .mm and .M files -# OTHER_PRECOMPFLAGS, LOCAL_PRECOMPFLAGS: additional flags used when -# precompiling header files -# OTHER_LDFLAGS, LOCAL_LDFLAGS: additional flags passed to ld and libtool -# OTHER_PSWFLAGS, LOCAL_PSWFLAGS: additional flags passed to pswrap -# OTHER_RPCFLAGS, LOCAL_RPCFLAGS: additional flags passed to rpcgen -# OTHER_YFLAGS, LOCAL_YFLAGS: additional flags passed to yacc -# OTHER_LFLAGS, LOCAL_LFLAGS: additional flags passed to lex - -# These variables provide hooks enabling you to add behavior at almost every -# stage of the make: -# -# BEFORE_PREBUILD: targets to build before installing headers for a subproject -# AFTER_PREBUILD: targets to build after installing headers for a subproject -# BEFORE_BUILD_RECURSION: targets to make before building subprojects -# BEFORE_BUILD: targets to make before a build, but after subprojects -# AFTER_BUILD: targets to make after a build -# -# BEFORE_INSTALL: targets to build before installing the product -# AFTER_INSTALL: targets to build after installing the product -# BEFORE_POSTINSTALL: targets to build before postinstalling every subproject -# AFTER_POSTINSTALL: targts to build after postinstalling every subproject -# -# BEFORE_INSTALLHDRS: targets to build before installing headers for a -# subproject -# AFTER_INSTALLHDRS: targets to build after installing headers for a subproject -# BEFORE_INSTALLSRC: targets to build before installing source for a subproject -# AFTER_INSTALLSRC: targets to build after installing source for a subproject -# -# BEFORE_DEPEND: targets to build before building dependencies for a -# subproject -# AFTER_DEPEND: targets to build after building dependencies for a -# subproject -# -# AUTOMATIC_DEPENDENCY_INFO: if YES, then the dependency file is -# updated every time the project is built. If NO, the dependency -# file is only built when the depend target is invoked. - -# Framework-related variables: -# FRAMEWORK_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the framework's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables - -# Library-related variables: -# PUBLIC_HEADER_DIR: Determines where public exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. For library projects you should -# set this to something like /Developer/Headers/$(NAME). Do not set -# this variable for framework projects unless you do not want the -# header files included in the framework. -# PRIVATE_HEADER_DIR: Determines where private exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. -# LIBRARY_STYLE: This may be either STATIC or DYNAMIC, and determines -# whether the libraries produced are statically linked when they -# are used or if they are dynamically loadable. This defaults to -# DYNAMIC. -# LIBRARY_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the library's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables -# -# INSTALL_AS_USER: owner of the intalled products (default root) -# INSTALL_AS_GROUP: group of the installed products (default wheel) -# INSTALL_PERMISSIONS: permissions of the installed product (default o+rX) -# -# OTHER_RECURSIVE_VARIABLES: The names of variables which you want to be -# passed on the command line to recursive invocations of make. Note that -# the values in OTHER_*FLAGS are inherited by subprojects automatically -- -# you do not have to (and shouldn't) add OTHER_*FLAGS to -# OTHER_RECURSIVE_VARIABLES. - -# Additional headers to export beyond those in the PB.project: -# OTHER_PUBLIC_HEADERS -# OTHER_PROJECT_HEADERS -# OTHER_PRIVATE_HEADERS - -# Additional files for the project's product: <> -# OTHER_RESOURCES: (non-localized) resources for this project -# OTHER_OFILES: relocatables to be linked into this project -# OTHER_LIBS: more libraries to link against -# OTHER_PRODUCT_DEPENDS: other dependencies of this project -# OTHER_SOURCEFILES: other source files maintained by .pre/postamble -# OTHER_GARBAGE: additional files to be removed by `make clean' - -# Set this to YES if you don't want a final libtool call for a library/framework. -# BUILD_OFILES_LIST_ONLY - -# To include a version string, project source must exist in a directory named -# $(NAME).%d[.%d][.%d] and the following line must be uncommented. -# OTHER_GENERATED_OFILES = $(VERS_OFILE) - -# This definition will suppress stripping of debug symbols when an executable -# is installed. By default it is YES. -# STRIP_ON_INSTALL = NO - -# Uncomment to suppress generation of a KeyValueCoding index when installing -# frameworks (This index is used by WOB and IB to determine keys available -# for an object). Set to YES by default. -# PREINDEX_FRAMEWORK = NO - -# Change this definition to install projects somewhere other than the -# standard locations. NEXT_ROOT defaults to "C:/Apple" on Windows systems -# and "" on other systems. -DSTROOT = $(HOME) diff --git a/net.subproj/PB.project b/net.subproj/PB.project deleted file mode 100644 index 172eb9c..0000000 --- a/net.subproj/PB.project +++ /dev/null @@ -1,36 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - H_FILES = (); - OTHER_LINKED = ( - inet_addr.c, - inet_lnaof.c, - inet_makeaddr.c, - inet_netof.c, - inet_network.c, - inet_ntoa.c, - iso_addr.c, - linkaddr.c, - ns_addr.c, - ns_ntoa.c, - nsap_addr.c, - recv.c - ); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble); - SUBPROJECTS = (); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = net; - PROJECTTYPE = Component; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/net.subproj/ns_addr.c b/net.subproj/ns_addr.c deleted file mode 100644 index 7e98719..0000000 --- a/net.subproj/ns_addr.c +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ -/* - * Copyright (c) 1986, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * J.Q. Johnson. - * - * 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. 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. - */ - - -#include -#include -#include -#include - -static struct ns_addr addr, zero_addr; - -static void Field(), cvtbase(); - -struct ns_addr -ns_addr(name) - const char *name; -{ - char separator; - char *hostname, *socketname, *cp; - char buf[50]; - - (void)strncpy(buf, name, sizeof(buf) - 1); - buf[sizeof(buf) - 1] = '\0'; - - /* - * First, figure out what he intends as a field separtor. - * Despite the way this routine is written, the prefered - * form 2-272.AA001234H.01777, i.e. XDE standard. - * Great efforts are made to insure backward compatability. - */ - if (hostname = strchr(buf, '#')) - separator = '#'; - else { - hostname = strchr(buf, '.'); - if ((cp = strchr(buf, ':')) && - ((hostname && cp < hostname) || (hostname == 0))) { - hostname = cp; - separator = ':'; - } else - separator = '.'; - } - if (hostname) - *hostname++ = 0; - - addr = zero_addr; - Field(buf, addr.x_net.c_net, 4); - if (hostname == 0) - return (addr); /* No separator means net only */ - - socketname = strchr(hostname, separator); - if (socketname) { - *socketname++ = 0; - Field(socketname, (u_char *)&addr.x_port, 2); - } - - Field(hostname, addr.x_host.c_host, 6); - - return (addr); -} - -static void -Field(buf, out, len) - char *buf; - u_char *out; - int len; -{ - register char *bp = buf; - int i, ibase, base16 = 0, base10 = 0, clen = 0; - int hb[6], *hp; - char *fmt; - - /* - * first try 2-273#2-852-151-014#socket - */ - if ((*buf != '-') && - (1 < (i = sscanf(buf, "%d-%d-%d-%d-%d", - &hb[0], &hb[1], &hb[2], &hb[3], &hb[4])))) { - cvtbase(1000L, 256, hb, i, out, len); - return; - } - /* - * try form 8E1#0.0.AA.0.5E.E6#socket - */ - if (1 < (i = sscanf(buf,"%x.%x.%x.%x.%x.%x", - &hb[0], &hb[1], &hb[2], &hb[3], &hb[4], &hb[5]))) { - cvtbase(256L, 256, hb, i, out, len); - return; - } - /* - * try form 8E1#0:0:AA:0:5E:E6#socket - */ - if (1 < (i = sscanf(buf,"%x:%x:%x:%x:%x:%x", - &hb[0], &hb[1], &hb[2], &hb[3], &hb[4], &hb[5]))) { - cvtbase(256L, 256, hb, i, out, len); - return; - } - /* - * This is REALLY stretching it but there was a - * comma notation separting shorts -- definitely non standard - */ - if (1 < (i = sscanf(buf,"%x,%x,%x", - &hb[0], &hb[1], &hb[2]))) { - hb[0] = htons(hb[0]); hb[1] = htons(hb[1]); - hb[2] = htons(hb[2]); - cvtbase(65536L, 256, hb, i, out, len); - return; - } - - /* Need to decide if base 10, 16 or 8 */ - while (*bp) switch (*bp++) { - - case '0': case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '-': - break; - - case '8': case '9': - base10 = 1; - break; - - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - base16 = 1; - break; - - case 'x': case 'X': - *--bp = '0'; - base16 = 1; - break; - - case 'h': case 'H': - base16 = 1; - /* fall into */ - - default: - *--bp = 0; /* Ends Loop */ - } - if (base16) { - fmt = "%3x"; - ibase = 4096; - } else if (base10 == 0 && *buf == '0') { - fmt = "%3o"; - ibase = 512; - } else { - fmt = "%3d"; - ibase = 1000; - } - - for (bp = buf; *bp++; ) clen++; - if (clen == 0) clen++; - if (clen > 18) clen = 18; - i = ((clen - 1) / 3) + 1; - bp = clen + buf - 3; - hp = hb + i - 1; - - while (hp > hb) { - (void)sscanf(bp, fmt, hp); - bp[0] = 0; - hp--; - bp -= 3; - } - (void)sscanf(buf, fmt, hp); - cvtbase((long)ibase, 256, hb, i, out, len); -} - -static void -cvtbase(oldbase,newbase,input,inlen,result,reslen) - long oldbase; - int newbase; - int input[]; - int inlen; - unsigned char result[]; - int reslen; -{ - int d, e; - long sum; - - e = 1; - while (e > 0 && reslen > 0) { - d = 0; e = 0; sum = 0; - /* long division: input=input/newbase */ - while (d < inlen) { - sum = sum*oldbase + (long) input[d]; - e += (sum > 0); - input[d++] = sum / newbase; - sum %= newbase; - } - result[--reslen] = sum; /* accumulate remainder */ - } - for (d=0; d < reslen; d++) - result[d] = 0; -} diff --git a/net/Makefile.inc b/net/Makefile.inc new file mode 100644 index 0000000..7fe1474 --- /dev/null +++ b/net/Makefile.inc @@ -0,0 +1,54 @@ +# from @(#)Makefile.inc 8.2 (Berkeley) 9/5/93 +# $FreeBSD: src/lib/libc/net/Makefile.inc,v 1.43 2001/10/23 06:22:14 imp Exp $ + +# machine-independent net sources +.PATH: ${.CURDIR}/${MACHINE_ARCH}/net ${.CURDIR}/net + +SRCS+= inet_addr.c inet_netof.c \ + inet_lnaof.c inet_network.c linkaddr.c nsap_addr.c \ + inet_makeaddr.c inet_ntoa.c recv.c + + +CFLAGS+=-DINET6 -I${.OBJDIR} + +YFLAGS+=-p_nsyy +LFLAGS+=-P_nsyy + +CLEANFILES+=nsparser.c nslexer.c nsparser.h + +nsparser.h: nsparser.c + mv y.tab.h ${.TARGET} + +nslexer.c: nslexer.l nsparser.h + ${LEX} ${LFLAGS} -o/dev/stdout ${.IMPSRC} | \ + sed -e '/YY_BUF_SIZE/s/16384/1024/' >${.TARGET} + +# machine-dependent net sources +.if exists(${.CURDIR}/${MACHINE_ARCH}/net/Makefile.inc) +.include "${.CURDIR}/${MACHINE_ARCH}/net/Makefile.inc" +.endif + +.if ${LIB} == "c" +MAN3+= addr2ascii.3 byteorder.3 ethers.3 hesiod.3 \ + inet.3 inet_net.3 \ + nsdispatch.3 rcmdsh.3 resolver.3 +# not installed: iso_addr.3 ns.3 + +MLINKS+=addr2ascii.3 ascii2addr.3 +MLINKS+=byteorder.3 htonl.3 byteorder.3 htons.3 byteorder.3 ntohl.3 \ + byteorder.3 ntohs.3 +MLINKS+=ethers.3 ether_aton.3 ethers.3 ether_hostton.3 ethers.3 ether_line.3 \ + ethers.3 ether_ntoa.3 ethers.3 ether_ntohost.3 +MLINKS+=inet.3 addr.3 inet.3 inet_addr.3 inet.3 inet_aton.3 \ + inet.3 inet_lnaof.3 inet.3 inet_makeaddr.3 inet.3 inet_netof.3 \ + inet.3 inet_network.3 inet.3 inet_ntoa.3 \ + inet.3 inet_ntop.3 inet.3 inet_pton.3 \ + inet.3 network.3 inet.3 ntoa.3 +MLINKS+=inet_net.3 inet_net_ntop.3 inet_net.3 inet_net_pton.3 +#MLINKS+=ns.3 ns_addr.3 ns.3 ns_ntoa.3 +MLINKS+=resolver.3 dn_comp.3 resolver.3 dn_expand.3 resolver.3 res_init.3 \ + resolver.3 res_mkquery.3 resolver.3 res_query.3 \ + resolver.3 res_search.3 resolver.3 res_send.3 resolver.3 dn_skipname.3 \ + resolver.3 ns_get16.3 resolver.3 ns_get32.3 \ + resolver.3 ns_put16.3 resolver.3 ns_put32.3 +.endif diff --git a/net/addr2ascii.3 b/net/addr2ascii.3 new file mode 100644 index 0000000..10b1ac7 --- /dev/null +++ b/net/addr2ascii.3 @@ -0,0 +1,222 @@ +.\" +.\" Copyright 1996 Massachusetts Institute of Technology +.\" +.\" Permission to use, copy, modify, and distribute this software and +.\" its documentation for any purpose and without fee is hereby +.\" granted, provided that both the above copyright notice and this +.\" permission notice appear in all copies, that both the above +.\" copyright notice and this permission notice appear in all +.\" supporting documentation, and that the name of M.I.T. not be used +.\" in advertising or publicity pertaining to distribution of the +.\" software without specific, written prior permission. M.I.T. makes +.\" no representations about the suitability of this software for any +.\" purpose. It is provided "as is" without express or implied +.\" warranty. +.\" +.\" THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS +.\" ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, +.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT +.\" SHALL M.I.T. 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. +.\" +.\" $ANA: addr2ascii.3,v 1.1 1996/06/13 18:41:46 wollman Exp $ +.\" $FreeBSD: src/lib/libc/net/addr2ascii.3,v 1.12 2001/10/01 16:08:55 ru Exp $ +.\" +.Dd June 13, 1996 +.Dt ADDR2ASCII 3 +.Os +.Sh NAME +.Nm addr2ascii , +.Nm ascii2addr +.Nd Generic address formatting routines +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In netinet/in.h +.In arpa/inet.h +.Ft "char *" +.Fn addr2ascii "int af" "const void *addrp" "int len" "char *buf" +.Ft int +.Fn ascii2addr "int af" "const char *ascii" "void *result" +.Sh DESCRIPTION +The routines +.Fn addr2ascii +and +.Fn ascii2addr +are used to convert network addresses between binary form and a +printable form appropriate to the address family. Both functions take +an +.Fa af +argument, specifying the address family to be used in the conversion +process. +(Currently, only the +.Dv AF_INET +and +.Dv AF_LINK +address families are supported.) +.Pp +The +.Fn addr2ascii +function +is used to convert binary, network-format addresses into printable +form. In addition to +.Fa af , +there are three other arguments. The +.Fa addrp +argument is a pointer to the network address to be converted. +The +.Fa len +argument is the length of the address. The +.Fa buf +argument is an optional pointer to a caller-allocated buffer to hold +the result; if a null pointer is passed, +.Fn addr2ascii +uses a statically-allocated buffer. +.Pp +The +.Fn ascii2addr +function performs the inverse operation to +.Fn addr2ascii . +In addition to +.Fa af , +it takes two parameters, +.Fa ascii +and +.Fa result . +The +.Fa ascii +parameter is a pointer to the string which is to be converted into +binary. The +.Fa result +parameter is a pointer to an appropriate network address structure for +the specified family. +.Pp +The following gives the appropriate structure to use for binary +addresses in the specified family: +.Pp +.Bl -tag -width AF_INETxxxx -compact +.It Dv AF_INET +.Li struct in_addr +(in +.Aq Pa netinet/in.h ) +.It Dv AF_LINK +.Li struct sockaddr_dl +(in +.Aq Pa net/if_dl.h ) +.\" .It Dv AF_INET6 +.\" .Li struct in6_addr +.\" (in +.\" .Aq Pa netinet6/in6.h ) +.El +.Sh RETURN VALUES +The +.Fn addr2ascii +function returns the address of the buffer it was passed, or a static +buffer if the a null pointer was passed; on failure, it returns a null +pointer. +The +.Fn ascii2addr +function returns the length of the binary address in bytes, or -1 on +failure. +.Sh EXAMPLES +The +.Xr inet 3 +functions +.Fn inet_ntoa +and +.Fn inet_aton +could be implemented thusly: +.Bd -literal -offset indent +#include +#include +#include +#include + +char * +inet_ntoa(struct in_addr addr) +{ + return addr2ascii(AF_INET, &addr, sizeof addr, 0); +} + +int +inet_aton(const char *ascii, struct in_addr *addr) +{ + return (ascii2addr(AF_INET, ascii, addr) + == sizeof(*addr)); +} +.Ed +.Pp +In actuality, this cannot be done because +.Fn addr2ascii +and +.Fn ascii2addr +are implemented in terms of the +.Xr inet 3 +functions, rather than the other way around. +.Sh ERRORS +When a failure is returned, +.Li errno +is set to one of the following values: +.Bl -tag -width Er +.It Bq Er ENAMETOOLONG +The +.Fn addr2ascii +routine was passed a +.Fa len +parameter which was inappropriate for the address family given by +.Fa af . +.It Bq Er EPROTONOSUPPORT +Either routine was passed an +.Fa af +parameter other than +.Dv AF_INET +or +.Dv AF_LINK . +.It Bq Er EINVAL +The string passed to +.Fn ascii2addr +was improperly formatted for address family +.Fa af . +.El +.Sh SEE ALSO +.Xr inet 3 , +.Xr linkaddr 3 , +.Xr inet 4 +.Sh HISTORY +An interface close to this one was originally suggested by Craig +Partridge. This particular interface originally appeared in the +.Tn INRIA +.Tn IPv6 +implementation. +.Sh AUTHORS +Code and documentation by +.An Garrett A. Wollman , +MIT Laboratory for Computer Science. +.Sh BUGS +The original implementations supported IPv6. This support should +eventually be resurrected. The +.Tn NRL +implementation also included support for the +.Dv AF_ISO +and +.Dv AF_NS +address families. +.Pp +The genericity of this interface is somewhat questionable. A truly +generic interface would provide a means for determining the length of +the buffer to be used so that it could be dynamically allocated, and +would always require a +.Dq Li "struct sockaddr" +to hold the binary address. Unfortunately, this is incompatible with existing +practice. This limitation means that a routine for printing network +addresses from arbitrary address families must still have internal +knowledge of the maximum buffer length needed and the appropriate part +of the address to use as the binary address. diff --git a/net/byteorder.3 b/net/byteorder.3 new file mode 100644 index 0000000..527bae4 --- /dev/null +++ b/net/byteorder.3 @@ -0,0 +1,84 @@ +.\" Copyright (c) 1983, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)byteorder.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/net/byteorder.3,v 1.8 2001/10/01 16:08:55 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt BYTEORDER 3 +.Os +.Sh NAME +.Nm htonl , +.Nm htons , +.Nm ntohl , +.Nm ntohs +.Nd convert values between host and network byte order +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In arpa/inet.h +.Ft uint32_t +.Fn htonl "uint32_t hostlong" +.Ft uint16_t +.Fn htons "uint16_t hostshort" +.Ft uint32_t +.Fn ntohl "uint32_t netlong" +.Ft uint16_t +.Fn ntohs "uint16_t netshort" +.Sh DESCRIPTION +These routines convert 16 and 32 bit quantities between network +byte order and host byte order. +On machines which have a byte order which is the same as the network +order, routines are defined as null macros. +.Pp +These routines are most often used in conjunction with Internet +addresses and ports as returned by +.Xr gethostbyname 3 +and +.Xr getservent 3 . +.Sh SEE ALSO +.Xr gethostbyname 3 , +.Xr getservent 3 +.Sh STANDARDS +The +.Nm byteorder +functions are expected to conform with IEEE Std POSIX.1-200x +.Pq Dq POSIX.1 . +.Sh HISTORY +The +.Nm byteorder +functions appeared in +.Bx 4.2 . +.Sh BUGS +On the +.Tn VAX +bytes are handled backwards from most everyone else in +the world. This is not expected to be fixed in the near future. diff --git a/net/ethers.3 b/net/ethers.3 new file mode 100644 index 0000000..36a8268 --- /dev/null +++ b/net/ethers.3 @@ -0,0 +1,197 @@ +.\" Copyright (c) 1995 +.\" Bill Paul . 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by Bill Paul. +.\" 4. Neither the name of the author nor the names of any co-contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY Bill Paul 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. +.\" +.\" $FreeBSD: src/lib/libc/net/ethers.3,v 1.18 2001/10/01 16:08:55 ru Exp $ +.\" +.Dd April 12, 1995 +.Dt ETHERS 3 +.Os +.Sh NAME +.Nm ethers , +.Nm ether_line , +.Nm ether_aton , +.Nm ether_ntoa , +.Nm ether_ntohost , +.Nm ether_hostton +.Nd Ethernet address conversion and lookup routines +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In sys/socket.h +.In net/ethernet.h +.Ft int +.Fn ether_line "const char *l" "struct ether_addr *e" "char *hostname" +.Ft struct ether_addr * +.Fn ether_aton "const char *a" +.Ft char * +.Fn ether_ntoa "const struct ether_addr *n" +.Ft int +.Fn ether_ntohost "char *hostname" "const struct ether_addr *e" +.Ft int +.Fn ether_hostton "const char *hostname" "struct ether_addr *e" +.Sh DESCRIPTION +These functions operate on ethernet addresses using an +.Ar ether_addr +structure, which is defined in the header file +.Aq Pa netinet/if_ether.h : +.Bd -literal -offset indent +/* + * The number of bytes in an ethernet (MAC) address. + */ +#define ETHER_ADDR_LEN 6 + +/* + * Structure of a 48-bit Ethernet address. + */ +struct ether_addr { + u_char octet[ETHER_ADDR_LEN]; +}; +.Ed +.Pp +The function +.Fn ether_line +scans +.Ar l , +an +.Tn ASCII +string in +.Xr ethers 5 +format and sets +.Ar e +to the ethernet address specified in the string and +.Ar h +to the hostname. +This function is used to parse lines from +.Pa /etc/ethers +into their component parts. +.Pp +The +.Fn ether_aton +function converts an +.Tn ASCII +representation of an ethernet address into an +.Ar ether_addr +structure. +Likewise, +.Fn ether_ntoa +converts an ethernet address specified as an +.Ar ether_addr +structure into an +.Tn ASCII +string. +.Pp +The +.Fn ether_ntohost +and +.Fn ether_hostton +functions map ethernet addresses to their corresponding hostnames +as specified in the +.Pa /etc/ethers +database. +.Fn ether_ntohost +converts from ethernet address to hostname, and +.Fn ether_hostton +converts from hostname to ethernet address. +.Sh RETURN VALUES +.Fn ether_line +returns zero on success and non-zero if it was unable to parse +any part of the supplied line +.Ar l . +It returns the extracted ethernet address in the supplied +.Ar ether_addr +structure +.Ar e +and the hostname in the supplied string +.Ar h . +.Pp +On success, +.Fn ether_ntoa +returns a pointer to a string containing an +.Tn ASCII +representation of an ethernet address. +If it is unable to convert +the supplied +.Ar ether_addr +structure, it returns a +.Dv NULL +pointer. +Likewise, +.Fn ether_aton +returns a pointer to an +.Ar ether_addr +structure on success and a +.Dv NULL +pointer on failure. +.Pp +The +.Fn ether_ntohost +and +.Fn ether_hostton +functions both return zero on success or non-zero if they were +unable to find a match in the +.Pa /etc/ethers +database. +.Sh NOTES +The user must insure that the hostname strings passed to the +.Fn ether_line , +.Fn ether_ntohost +and +.Fn ether_hostton +functions are large enough to contain the returned hostnames. +.Sh NIS INTERACTION +If the +.Pa /etc/ethers +contains a line with a single + in it, the +.Fn ether_ntohost +and +.Fn ether_hostton +functions will attempt to consult the NIS +.Pa ethers.byname +and +.Pa ethers.byaddr +maps in addition to the data in the +.Pa /etc/ethers +file. +.Sh SEE ALSO +.Xr yp 4 , +.Xr ethers 5 +.Sh BUGS +The +.Fn ether_aton +and +.Fn ether_ntoa +functions returns values that are stored in static memory areas +which may be overwritten the next time they are called. +.Sh HISTORY +This particular implementation of the +.Nm +library functions were written for and first appeared in +.Fx 2.1 . diff --git a/net/getaddrinfo.3 b/net/getaddrinfo.3 new file mode 100644 index 0000000..1ae9e9a --- /dev/null +++ b/net/getaddrinfo.3 @@ -0,0 +1,619 @@ +.\" $FreeBSD: src/lib/libc/net/getaddrinfo.3,v 1.17 2001/10/01 16:08:55 ru Exp $ +.\" $KAME: getaddrinfo.3,v 1.22 2000/08/09 21:16:17 itojun Exp $ +.\" +.\" Copyright (c) 1983, 1987, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95 +.\" +.Dd May 25, 1995 +.Dt GETADDRINFO 3 +.Os +.\" +.Sh NAME +.Nm getaddrinfo , +.Nm freeaddrinfo , +.Nm gai_strerror +.Nd nodename-to-address translation in protocol-independent manner +.\" +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In sys/socket.h +.In netdb.h +.Ft int +.Fn getaddrinfo "const char *nodename" "const char *servname" \ +"const struct addrinfo *hints" "struct addrinfo **res" +.Ft void +.Fn freeaddrinfo "struct addrinfo *ai" +.Ft "char *" +.Fn gai_strerror "int ecode" +.\" +.Sh DESCRIPTION +The +.Fn getaddrinfo +function is defined for protocol-independent nodename-to-address translation. +It performs the functionality of +.Xr gethostbyname 3 +and +.Xr getservbyname 3 , +but in a more sophisticated manner. +.Pp +The +.Li addrinfo +structure is defined as a result of including the +.Aq Pa netdb.h +header: +.Bd -literal -offset +struct addrinfo { + int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */ + int ai_family; /* PF_xxx */ + int ai_socktype; /* SOCK_xxx */ + int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ + size_t ai_addrlen; /* length of ai_addr */ + char *ai_canonname; /* canonical name for nodename */ + struct sockaddr *ai_addr; /* binary address */ + struct addrinfo *ai_next; /* next structure in linked list */ +}; +.Ed +.Pp +The +.Fa nodename +and +.Fa servname +arguments are pointers to null-terminated strings or +.Dv NULL . +One or both of these two arguments must be a +.Pf non Dv -NULL +pointer. +In the normal client scenario, both the +.Fa nodename +and +.Fa servname +are specified. +In the normal server scenario, only the +.Fa servname +is specified. +A +.Pf non Dv -NULL +.Fa nodename +string can be either a node name or a numeric host address string +(i.e., a dotted-decimal IPv4 address or an IPv6 hex address). +A +.Pf non Dv -NULL +.Fa servname +string can be either a service name or a decimal port number. +.Pp +The caller can optionally pass an +.Li addrinfo +structure, pointed to by the third argument, +to provide hints concerning the type of socket that the caller supports. +In this +.Fa hints +structure all members other than +.Fa ai_flags , +.Fa ai_family , +.Fa ai_socktype , +and +.Fa ai_protocol +must be zero or a +.Dv NULL +pointer. +A value of +.Dv PF_UNSPEC +for +.Fa ai_family +means the caller will accept any protocol family. +A value of 0 for +.Fa ai_socktype +means the caller will accept any socket type. +A value of 0 for +.Fa ai_protocol +means the caller will accept any protocol. +For example, if the caller handles only TCP and not UDP, then the +.Fa ai_socktype +member of the hints structure should be set to +.Dv SOCK_STREAM +when +.Fn getaddrinfo +is called. +If the caller handles only IPv4 and not IPv6, then the +.Fa ai_family +member of the +.Fa hints +structure should be set to +.Dv PF_INET +when +.Fn getaddrinfo +is called. +If the third argument to +.Fn getaddrinfo +is a +.Dv NULL +pointer, this is the same as if the caller had filled in an +.Li addrinfo +structure initialized to zero with +.Fa ai_family +set to +.Dv PF_UNSPEC . +.Pp +Upon successful return a pointer to a linked list of one or more +.Li addrinfo +structures is returned through the final argument. +The caller can process each +.Li addrinfo +structure in this list by following the +.Fa ai_next +pointer, until a +.Dv NULL +pointer is encountered. +In each returned +.Li addrinfo +structure the three members +.Fa ai_family , +.Fa ai_socktype , +and +.Fa ai_protocol +are the corresponding arguments for a call to the +.Fn socket +function. +In each +.Li addrinfo +structure the +.Fa ai_addr +member points to a filled-in socket address structure whose length is +specified by the +.Fa ai_addrlen +member. +.Pp +If the +.Dv AI_PASSIVE +bit is set in the +.Fa ai_flags +member of the +.Fa hints +structure, then the caller plans to use the returned socket address +structure in a call to +.Fn bind . +In this case, if the +.Fa nodename +argument is a +.Dv NULL +pointer, then the IP address portion of the socket +address structure will be set to +.Dv INADDR_ANY +for an IPv4 address or +.Dv IN6ADDR_ANY_INIT +for an IPv6 address. +.Pp +If the +.Dv AI_PASSIVE +bit is not set in the +.Fa ai_flags +member of the +.Fa hints +structure, then the returned socket address structure will be ready for a +call to +.Fn connect +(for a connection-oriented protocol) +or either +.Fn connect , +.Fn sendto , +or +.Fn sendmsg +(for a connectionless protocol). +In this case, if the +.Fa nodename +argument is a +.Dv NULL +pointer, then the IP address portion of the +socket address structure will be set to the loopback address. +.Pp +If the +.Dv AI_CANONNAME +bit is set in the +.Fa ai_flags +member of the +.Fa hints +structure, then upon successful return the +.Fa ai_canonname +member of the first +.Li addrinfo +structure in the linked list will point to a null-terminated string +containing the canonical name of the specified +.Fa nodename . +.Pp +If the +.Dv AI_NUMERICHOST +bit is set in the +.Fa ai_flags +member of the +.Fa hints +structure, then a +.Pf non Dv -NULL +.Fa nodename +string must be a numeric host address string. +Otherwise an error of +.Dv EAI_NONAME +is returned. +This flag prevents any type of name resolution service (e.g., the DNS) +from being called. +.Pp +The arguments to +.Fn getaddrinfo +must be sufficiently consistent and unambiguous. +Here are some problem cases you may encounter: +.Bl -bullet +.It +.Fn getaddrinfo +will fail if the members in the +.Fa hints +structure are not consistent. +For example, for internet address families, +.Fn getaddrinfo +will fail if you specify +.Dv SOCK_STREAM +to +.Fa ai_socktype +while you specify +.Dv IPPROTO_UDP +to +.Fa ai_protocol . +.It +If you specify a +.Fa servname +which is defined only for certain +.Fa ai_socktype , +.Fn getaddrinfo +will fail because the arguments are not consistent. +For example, +.Fn getaddrinfo +will return an error if you ask for +.Dq Li tftp +service on +.Dv SOCK_STREAM . +.It +For internet address families, if you specify +.Fa servname +while you set +.Fa ai_socktype +to +.Dv SOCK_RAW , +.Fn getaddrinfo +will fail, because service names are not defined for the internet +.Dv SOCK_RAW +space. +.It +If you specify numeric +.Fa servname , +while leaving +.Fa ai_socktype +and +.Fa ai_protocol +unspecified, +.Fn getaddrinfo +will fail. +This is because the numeric +.Fa servname +does not identify any socket type, and +.Fn getaddrinfo +is not allowed to glob the argument in such case. +.El +.Pp +All of the information returned by +.Fn getaddrinfo +is dynamically allocated: +the +.Li addrinfo +structures, the socket address structures, and canonical node name +strings pointed to by the addrinfo structures. +To return this information to the system the function +.Fn freeaddrinfo +is called. +The +.Fa addrinfo +structure pointed to by the +.Fa ai argument +is freed, along with any dynamic storage pointed to by the structure. +This operation is repeated until a +.Dv NULL +.Fa ai_next +pointer is encountered. +.Pp +To aid applications in printing error messages based on the +.Dv EAI_xxx +codes returned by +.Fn getaddrinfo , +.Fn gai_strerror +is defined. +The argument is one of the +.Dv EAI_xxx +values defined earlier and the return value points to a string describing +the error. +If the argument is not one of the +.Dv EAI_xxx +values, the function still returns a pointer to a string whose contents +indicate an unknown error. +.\" +.Sh EXTENSIONS +This implementation supports numeric IPv6 address notation with the +experimental scope identifier. +By appending a percent sign and scope identifier to the address, you +can specify the value of the +.Li sin6_scope_id +field of the socket address. +This makes management of scoped address easier, +and allows cut-and-paste input of scoped addresses. +.Pp +At the moment the code supports only link-local addresses in this format. +The scope identifier is hardcoded to name of hardware interface associated +with the link, +(such as +.Li ne0 ) . +For example, +.Dq Li fe80::1%ne0 , +which means +.Do +.Li fe80::1 +on the link associated with the +.Li ne0 +interface +.Dc . +.Pp +This implementation is still very experimental and non-standard. +The current implementation assumes a one-to-one relationship between +interfaces and links, which is not necessarily true according to the +specification. +.\" +.Sh EXAMPLES +The following code tries to connect to +.Dq Li www.kame.net +service +.Dq Li http . +via stream socket. +It loops through all the addresses available, regardless of the address family. +If the destination resolves to an IPv4 address, it will use an +.Dv AF_INET +socket. +Similarly, if it resolves to IPv6, an +.Dv AF_INET6 +socket is used. +Observe that there is no hardcoded reference to particular address family. +The code works even if +.Fn getaddrinfo +returns addresses that are not IPv4/v6. +.Bd -literal -offset indent +struct addrinfo hints, *res, *res0; +int error; +int s; +const char *cause = NULL; + +memset(&hints, 0, sizeof(hints)); +hints.ai_family = PF_UNSPEC; +hints.ai_socktype = SOCK_STREAM; +error = getaddrinfo("www.kame.net", "http", &hints, &res0); +if (error) { + errx(1, "%s", gai_strerror(error)); + /*NOTREACHED*/ +} +s = -1; +cause = "no addresses"; +errno = EADDRNOTAVAIL; +for (res = res0; res; res = res->ai_next) { + s = socket(res->ai_family, res->ai_socktype, + res->ai_protocol); + if (s < 0) { + cause = "socket"; + continue; + } + + if (connect(s, res->ai_addr, res->ai_addrlen) < 0) { + cause = "connect"; + close(s); + s = -1; + continue; + } + + break; /* okay we got one */ +} +if (s < 0) { + err(1, cause); + /*NOTREACHED*/ +} +freeaddrinfo(res0); +.Ed +.Pp +The following example tries to open a wildcard listening socket onto service +.Dq Li http , +for all the address families available. +.Bd -literal -offset indent +struct addrinfo hints, *res, *res0; +int error; +int s[MAXSOCK]; +int nsock; +const char *cause = NULL; + +memset(&hints, 0, sizeof(hints)); +hints.ai_family = PF_UNSPEC; +hints.ai_socktype = SOCK_STREAM; +hints.ai_flags = AI_PASSIVE; +error = getaddrinfo(NULL, "http", &hints, &res0); +if (error) { + errx(1, "%s", gai_strerror(error)); + /*NOTREACHED*/ +} +nsock = 0; +for (res = res0; res && nsock < MAXSOCK; res = res->ai_next) { + s[nsock] = socket(res->ai_family, res->ai_socktype, + res->ai_protocol); + if (s[nsock] < 0) { + cause = "socket"; + continue; + } + + if (bind(s[nsock], res->ai_addr, res->ai_addrlen) < 0) { + cause = "bind"; + close(s[nsock]); + continue; + } + + if (listen(s[nsock], SOMAXCONN) < 0) { + cause = "listen"; + close(s[nsock]); + continue; + } + + nsock++; +} +if (nsock == 0) { + err(1, cause); + /*NOTREACHED*/ +} +freeaddrinfo(res0); +.Ed +.\" +.Sh FILES +.Bl -tag -width /etc/nsswitch.conf -compact +.It Pa /etc/hosts +.It Pa /etc/nsswitch.conf +.It Pa /etc/resolv.conf +.El +.\" +.Sh DIAGNOSTICS +Error return status from +.Fn getaddrinfo +is zero on success and non-zero on errors. +Non-zero error codes are defined in +.Aq Pa netdb.h , +and as follows: +.Pp +.Bl -tag -width EAI_ADDRFAMILY -compact +.It Dv EAI_ADDRFAMILY +Address family for +.Fa nodename +not supported. +.It Dv EAI_AGAIN +Temporary failure in name resolution. +.It Dv EAI_BADFLAGS +Invalid value for +.Fa ai_flags . +.It Dv EAI_FAIL +Non-recoverable failure in name resolution. +.It Dv EAI_FAMILY +.Fa ai_family +not supported. +.It Dv EAI_MEMORY +Memory allocation failure. +.It Dv EAI_NODATA +No address associated with +.Fa nodename . +.It Dv EAI_NONAME +.Fa nodename +nor +.Fa servname +provided, or not known. +.It Dv EAI_SERVICE +.Fa servname +not supported for +.Fa ai_socktype . +.It Dv EAI_SOCKTYPE +.Fa ai_socktype +not supported. +.It Dv EAI_SYSTEM +System error returned in +.Va errno . +.It Dv EAI_BADHINTS +Invalid value for +.Fa hints . +.It Dv EAI_PROTOCOL +Resolved protocol is unknown. +.It Dv EAI_MAX +Unknown error. +.El +.Pp +If called with an appropriate argument, +.Fn gai_strerror +returns a pointer to a string describing the given error code. +If the argument is not one of the +.Dv EAI_xxx +values, the function still returns a pointer to a string whose contents +indicate an unknown error. +.\" +.Sh SEE ALSO +.Xr gethostbyname 3 , +.Xr getnameinfo 3 , +.Xr getservbyname 3 , +.Xr hosts 5 , +.Xr services 5 , +.Xr hostname 7 , +.Xr named 8 +.Pp +.Rs +.%A R. Gilligan +.%A S. Thomson +.%A J. Bound +.%A W. Stevens +.%T Basic Socket Interface Extensions for IPv6 +.%R RFC2553 +.%D March 1999 +.Re +.Rs +.%A Tatsuya Jinmei +.%A Atsushi Onoe +.%T "An Extension of Format for IPv6 Scoped Addresses" +.%R internet draft +.%N draft-ietf-ipngwg-scopedaddr-format-02.txt +.%O work in progress material +.Re +.Rs +.%A Craig Metz +.%T Protocol Independence Using the Sockets API +.%B "Proceedings of the freenix track: 2000 USENIX annual technical conference" +.%D June 2000 +.Re +.\" +.Sh HISTORY +The implementation first appeared in WIDE Hydrangea IPv6 protocol stack kit. +.\" +.Sh STANDARDS +The +.Fn getaddrinfo +function is defined in +.St -p1003.1g-2000 , +and documented in +.Dq Basic Socket Interface Extensions for IPv6 +(RFC2553). +.\" +.Sh BUGS +The current implementation is not thread-safe. +.Pp +The text was shamelessly copied from RFC2553. diff --git a/net/gethostbyname.3 b/net/gethostbyname.3 new file mode 100644 index 0000000..8efba37 --- /dev/null +++ b/net/gethostbyname.3 @@ -0,0 +1,380 @@ +.\" Copyright (c) 1983, 1987, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95 +.\" $FreeBSD: src/lib/libc/net/gethostbyname.3,v 1.25 2001/10/01 16:08:55 ru Exp $ +.\" +.Dd May 25, 1995 +.Dt GETHOSTBYNAME 3 +.Os +.Sh NAME +.Nm gethostbyname , +.Nm gethostbyname2 , +.Nm gethostbyaddr , +.Nm gethostent , +.Nm sethostent , +.Nm endhostent , +.Nm herror , +.Nm hstrerror +.Nd get network host entry +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In netdb.h +.Vt extern int h_errno ; +.Ft struct hostent * +.Fn gethostbyname "const char *name" +.Ft struct hostent * +.Fn gethostbyname2 "const char *name" "int af" +.Ft struct hostent * +.Fn gethostbyaddr "const char *addr" "int len" "int type" +.Ft struct hostent * +.Fn gethostent void +.Ft void +.Fn sethostent "int stayopen" +.Ft void +.Fn endhostent void +.Ft void +.Fn herror "const char *string" +.Ft const char * +.Fn hstrerror "int err" +.Sh DESCRIPTION +.Bf -symbolic +The +.Xr getaddrinfo 3 +and +.Xr getnameinfo 3 +functions are preferred over the +.Fn gethostbyname , +.Fn gethostbyname2 , +and +.Fn gethostbyaddr +functions. +.Ef +.Pp +The +.Fn gethostbyname , +.Fn gethostbyname2 +and +.Fn gethostbyaddr +functions +each return a pointer to an object with the +following structure describing an internet host +referenced by name or by address, respectively. +.Pp +The +.Fa name +parameter passed to +.Fn gethostbyname +or +.Fn gethostbyname2 +should point to a +.Dv NUL Ns -terminated +hostname. +The +.Fa addr +parameter passed to +.Fn gethostbyaddr +should point to an address which is +.Fa len +bytes long, +in binary form +(i.e. not an IP address in human readable +.Tn ASCII +form). +The +.Fa type +parameter specifies the address family +(e.g.\& +.Dv AF_INET , AF_INET6 , +etc.) of this address. +.Pp +The structure returned contains either the information obtained from the name +server, +.Xr named 8 , +broken-out fields from a line in +.Pa /etc/hosts , +or database entries supplied by the +.Xr yp 4 +system. +The order of the lookups is controlled by the +.Sq hosts +entry in +.Xr nsswitch.conf 5 . +.Bd -literal +struct hostent { + char *h_name; /* official name of host */ + char **h_aliases; /* alias list */ + int h_addrtype; /* host address type */ + int h_length; /* length of address */ + char **h_addr_list; /* list of addresses from name server */ +}; +#define h_addr h_addr_list[0] /* address, for backward compatibility */ +.Ed +.Pp +The members of this structure are: +.Bl -tag -width h_addr_list +.It Va h_name +Official name of the host. +.It Va h_aliases +A +.Dv NULL Ns -terminated +array of alternate names for the host. +.It Va h_addrtype +The type of address being returned; usually +.Dv AF_INET . +.It Va h_length +The length, in bytes, of the address. +.It Va h_addr_list +A +.Dv NULL Ns -terminated +array of network addresses for the host. +Host addresses are returned in network byte order. +.It Va h_addr +The first address in +.Va h_addr_list ; +this is for backward compatibility. +.El +.Pp +When using the nameserver, +.Fn gethostbyname +and +.Fn gethostbyname2 +will search for the named host in the current domain and its parents +unless the name ends in a dot. +If the name contains no dot, and if the environment variable +.Dq Ev HOSTALIASES +contains the name of an alias file, the alias file will first be searched +for an alias matching the input name. +See +.Xr hostname 7 +for the domain search procedure and the alias file format. +.Pp +The +.Fn gethostbyname2 +function is an evolution of +.Fn gethostbyname +which is intended to allow lookups in address families other than +.Dv AF_INET , +for example +.Dv AF_INET6 . +.Pp +The +.Fn sethostent +function +may be used to request the use of a connected +.Tn TCP +socket for queries. +If the +.Fa stayopen +flag is non-zero, +this sets the option to send all queries to the name server using +.Tn TCP +and to retain the connection after each call to +.Fn gethostbyname , +.Fn gethostbyname2 +or +.Fn gethostbyaddr . +Otherwise, queries are performed using +.Tn UDP +datagrams. +.Pp +The +.Fn endhostent +function +closes the +.Tn TCP +connection. +.Pp +The +.Fn herror +function writes a message to the diagnostic output consisting of the +string parameter +.Fa s , +the constant string +.Qq Li ":\ " , +and a message corresponding to the value of +.Va h_errno . +.Pp +The +.Fn hstrerror +function returns a string which is the message text corresponding to the +value of the +.Fa err +parameter. +.Sh FILES +.Bl -tag -width /etc/nsswitch.conf -compact +.It Pa /etc/hosts +.It Pa /etc/nsswitch.conf +.It Pa /etc/resolv.conf +.El +.Sh EXAMPLES +Print out the hostname associated with a specific IP address: +.Bd -literal -offset indent +const char *ipstr = "127.0.0.1"; +struct in_addr ip; +struct hostent *hp; + +if (!inet_aton(ipstr, &ip)) + errx(1, "can't parse IP address %s", ipstr); + +if ((hp = gethostbyaddr((const char *)&ip, + sizeof ip, AF_INET)) == NULL) + errx(1, "no name associated with %s", ipstr); + +printf("name associated with %s is %s\en", ipstr, hp->h_name); +.Ed +.Sh DIAGNOSTICS +Error return status from +.Fn gethostbyname , +.Fn gethostbyname2 +and +.Fn gethostbyaddr +is indicated by return of a +.Dv NULL +pointer. +The external integer +.Va h_errno +may then be checked to see whether this is a temporary failure +or an invalid or unknown host. +The routine +.Fn herror +can be used to print an error message describing the failure. +If its argument +.Fa string +is +.Pf non- Dv NULL , +it is printed, followed by a colon and a space. +The error message is printed with a trailing newline. +.Pp +The variable +.Va h_errno +can have the following values: +.Bl -tag -width HOST_NOT_FOUND +.It Dv HOST_NOT_FOUND +No such host is known. +.It Dv TRY_AGAIN +This is usually a temporary error +and means that the local server did not receive +a response from an authoritative server. +A retry at some later time may succeed. +.It Dv NO_RECOVERY +Some unexpected server failure was encountered. +This is a non-recoverable error. +.It Dv NO_DATA +The requested name is valid but does not have an IP address; +this is not a temporary error. +This means that the name is known to the name server but there is no address +associated with this name. +Another type of request to the name server using this domain name +will result in an answer; +for example, a mail-forwarder may be registered for this domain. +.El +.Sh SEE ALSO +.Xr getaddrinfo 3 , +.Xr getnameinfo 3 , +.Xr inet_aton 3 , +.Xr resolver 3 , +.Xr hosts 5 , +.Xr hostname 7 , +.Xr named 8 +.Sh CAVEAT +The +.Fn gethostent +function +is defined, and +.Fn sethostent +and +.Fn endhostent +are redefined, +when +.Xr libc 3 +is built to use only the routines to lookup in +.Pa /etc/hosts +and not the name server. +.Pp +The +.Fn gethostent +function +reads the next line of +.Pa /etc/hosts , +opening the file if necessary. +.Pp +The +.Fn sethostent +function +opens and/or rewinds the file +.Pa /etc/hosts . +If the +.Fa stayopen +argument is non-zero, +the file will not be closed after each call to +.Fn gethostbyname , +.Fn gethostbyname2 +or +.Fn gethostbyaddr . +.Pp +The +.Fn endhostent +function +closes the file. +.Sh HISTORY +The +.Fn herror +function appeared in +.Bx 4.3 . +The +.Fn endhostent , +.Fn gethostbyaddr , +.Fn gethostbyname , +.Fn gethostent , +and +.Fn sethostent +functions appeared in +.Bx 4.2 . +The +.Fn gethostbyname2 +function first appeared in +.Tn BIND +version 4.9.4. +.Sh BUGS +These functions use static data storage; +if the data is needed for future use, it should be +copied before any subsequent calls overwrite it. +Only the Internet +address format is currently understood. +.Pp +.Fn gethostbyname2 +cannot perform +.Dv AF_INET6 +lookups over NIS. +.Xr getaddrinfo 3 +must be used instead. diff --git a/net/getifaddrs.3 b/net/getifaddrs.3 new file mode 100644 index 0000000..47e5004 --- /dev/null +++ b/net/getifaddrs.3 @@ -0,0 +1,164 @@ +.\" $FreeBSD: src/lib/libc/net/getifaddrs.3,v 1.6 2001/10/01 16:08:55 ru Exp $ +.\" $KAME: getifaddrs.3,v 1.4 2000/05/17 14:13:14 itojun Exp $ +.\" BSDI getifaddrs.3,v 2.5 2000/02/23 14:51:59 dab Exp +.\" +.\" Copyright (c) 1995, 1999 +.\" Berkeley Software Design, Inc. 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. +.\" +.\" THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``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 Berkeley Software Design, Inc. 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. +.Dd October 12, 1995 +.Dt GETIFADDRS 3 +.Os +.Sh NAME +.Nm getifaddrs +.Nd get interface addresses +.Sh SYNOPSIS +.In sys/types.h +.In sys/socket.h +.In ifaddrs.h +.Ft int +.Fn getifaddrs "struct ifaddrs **ifap" +.Ft void +.Fn freeifaddrs "struct ifaddrs *ifp" +.Sh DESCRIPTION +The +.Fn getifaddrs +function stores a reference to a linked list of the network interfaces +on the local machine in the memory referenced by +.Fa ifap . +The list consists of +.Nm ifaddrs +structures, as defined in the include file +.Aq Pa ifaddrs.h . +The +.Nm ifaddrs +structure contains at least the following entries: +.Bd -literal + struct ifaddrs *ifa_next; /* Pointer to next struct */ + char *ifa_name; /* Interface name */ + u_int ifa_flags; /* Interface flags */ + struct sockaddr *ifa_addr; /* Interface address */ + struct sockaddr *ifa_netmask; /* Interface netmask */ + struct sockaddr *ifa_broadaddr; /* Interface broadcast address */ + struct sockaddr *ifa_dstaddr; /* P2P interface destination */ + void *ifa_data; /* Address specific data */ +.Ed +.Pp +The +.Li ifa_next +field contains a pointer to the next structure on the list. +This field is +.Dv NULL +in last structure on the list. +.Pp +The +.Li ifa_name +field contains the interface name. +.Pp +The +.Li ifa_flags +field contains the interface flags, as set by +.Xr ifconfig 8 +utility. +.Pp +The +.Li ifa_addr +field references either the address of the interface or the link level +address of the interface, if one exists, otherwise it is NULL. +(The +.Li sa_family +field of the +.Li ifa_addr +field should be consulted to determine the format of the +.Li ifa_addr +address.) +.Pp +The +.Li ifa_netmask +field references the netmask associated with +.Li ifa_addr , +if one is set, otherwise it is NULL. +.Pp +The +.Li ifa_broadaddr +field, +which should only be referenced for non-P2P interfaces, +references the broadcast address associated with +.Li ifa_addr , +if one exists, otherwise it is NULL. +.Pp +The +.Li ifa_dstaddr +field references the destination address on a P2P interface, +if one exists, otherwise it is NULL. +.Pp +The +.Li ifa_data +field references address family specific data. For +.Dv AF_LINK +addresses it contains a pointer to the +.Fa struct if_data +(as defined in include file +.Aq Pa net/if.h ) +which contains various interface attributes and statistics. +For all other address families, it contains a pointer to the +.Fa struct ifa_data +(as defined in include file +.Aq Pa net/if.h ) +which contains per-address interface statistics. +.Pp +The data returned by +.Fn getifaddrs +is dynamically allocated and should be freed using +.Fn freeifaddrs +when no longer needed. +.Sh RETURN VALUES +.Rv -std getifaddrs +.Sh ERRORS +The +.Fn getifaddrs +may fail and set +.Va errno +for any of the errors specified for the library routines +.Xr ioctl 2 , +.Xr socket 2 , +.Xr malloc 3 +or +.Xr sysctl 3 . +.Sh BUGS +If both +.Aq Pa net/if.h +and +.Aq Pa ifaddrs.h +are being included, +.Aq Pa net/if.h +.Em must +be included before +.Aq Pa ifaddrs.h . +.Sh SEE ALSO +.Xr ioctl 2 , +.Xr socket 2 , +.Xr sysctl 3 , +.Xr networking 4 , +.Xr ifconfig 8 +.Sh HISTORY +The +.Nm +implementation first appeared in BSDi +.Bsx . diff --git a/net/getipnodebyname.3 b/net/getipnodebyname.3 new file mode 100644 index 0000000..5b8ea1e --- /dev/null +++ b/net/getipnodebyname.3 @@ -0,0 +1,461 @@ +.\" $FreeBSD: src/lib/libc/net/getipnodebyname.3,v 1.8 2001/10/01 16:08:55 ru Exp $ +.\" $KAME: getipnodebyname.3,v 1.6 2000/08/09 21:16:17 itojun Exp $ +.\" +.\" Copyright (c) 1983, 1987, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95 +.\" +.Dd May 25, 1995 +.Dt GETIPNODEBYNAME 3 +.Os +.\" +.Sh NAME +.Nm getipnodebyname , +.Nm getipnodebyaddr , +.Nm freehostent +.Nd nodename-to-address and address-to-nodename translation +.\" +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In sys/socket.h +.In netdb.h +.Ft "struct hostent *" +.Fn getipnodebyname "const char *name" "int af" "int flags" "int *error_num" +.Ft "struct hostent *" +.Fn getipnodebyaddr "const void *src" "size_t len" "int af" "int *error_num" +.Ft void +.Fn freehostent "struct hostent *ptr" +.\" +.Sh DESCRIPTION +.Fn getipnodebyname +and +.Fn getipnodebyaddr +functions are very similar to +.Xr gethostbyname 3 , +.Xr gethostbyname2 3 +and +.Xr gethostbyaddr 3 . +The functions cover all the functionalities provided by the older ones, +and provide better interface to programmers. +The functions require additional arguments, +.Ar af , +and +.Ar flags , +for specifying address family and operation mode. +The additional arguments allow programmer to get address for a nodename, +for specific address family +(such as +.Dv AF_INET +or +.Dv AF_INET6 ) . +The functions also require an additional pointer argument, +.Ar error_num +to return the appropriate error code, +to support thread safe error code returns. +.Pp +The type and usage of the return value, +.Li "struct hostent" +is described in +.Xr gethostbyname 3 . +.Pp +For +.Fn getipnodebyname , +the +.Ar name +argument can be either a node name or a numeric address +string +(i.e., a dotted-decimal IPv4 address or an IPv6 hex address). +The +.Ar af +argument specifies the address family, either +.Dv AF_INET +or +.Dv AF_INET6 . +The +.Ar flags +argument specifies the types of addresses that are searched for, +and the types of addresses that are returned. +We note that a special flags value of +.Dv AI_DEFAULT +(defined below) +should handle most applications. +That is, porting simple applications to use IPv6 replaces the call +.Bd -literal -offset + hptr = gethostbyname(name); +.Ed +.Pp +with +.Bd -literal -offset + hptr = getipnodebyname(name, AF_INET6, AI_DEFAULT, &error_num); +.Ed +.Pp +Applications desiring finer control over the types of addresses +searched for and returned, can specify other combinations of the +.Ar flags +argument. +.Pp +A +.Ar flags +of +.Li 0 +implies a strict interpretation of the +.Ar af +argument: +.Bl -bullet +.It +If +.Ar flags +is 0 and +.Ar af +is +.Dv AF_INET , +then the caller wants only IPv4 addresses. +A query is made for +.Li A +records. +If successful, the IPv4 addresses are returned and the +.Li h_length +member of the +.Li hostent +structure will be 4, else the function returns a +.Dv NULL +pointer. +.It +If +.Ar flags +is 0 and if +.Ar af +is +.Li AF_INET6 , +then the caller wants only IPv6 addresses. +A query is made for +.Li AAAA +records. +If successful, the IPv6 addresses are returned and the +.Li h_length +member of the +.Li hostent +structure will be 16, else the function returns a +.Dv NULL +pointer. +.El +.Pp +Other constants can be logically-ORed into the +.Ar flags +argument, to modify the behavior of the function. +.Bl -bullet +.It +If the +.Dv AI_V4MAPPED +flag is specified along with an +.Ar af +of +.Dv AF_INET6 , +then the caller will accept IPv4-mapped IPv6 addresses. +That is, if no +.Li AAAA +records are found then a query is made for +.Li A +records and any found are returned as IPv4-mapped IPv6 addresses +.Li ( h_length +will be 16). +The +.Dv AI_V4MAPPED +flag is ignored unless +.Ar af +equals +.Dv AF_INET6 . +.It +The +.Dv AI_V4MAPPED_CFG +flag is exact same as the +.Dv AI_V4MAPPED +flag only if the kernel supports IPv4-mapped IPv6 address. +.It +If the +.Dv AI_ALL +flag is used in conjunction with the +.Dv AI_V4MAPPED +flag, and only used with the IPv6 address family. +When +.Dv AI_ALL +is logically or'd with +.Dv AI_V4MAPPED +flag then the caller wants all addresses: IPv6 and IPv4-mapped IPv6. +A query is first made for +.Li AAAA +records and if successful, the +IPv6 addresses are returned. Another query is then made for +.Li A +records and any found are returned as IPv4-mapped IPv6 addresses. +.Li h_length +will be 16. Only if both queries fail does the function +return a +.Dv NULL +pointer. This flag is ignored unless af equals +AF_INET6. If both +.Dv AI_ALL +and +.Dv AI_V4MAPPED +are specified, +.Dv AI_ALL +takes precedence. +.It +The +.Dv AI_ADDRCONFIG +flag specifies that a query for +.Li AAAA +records +should occur only if the node has at least one IPv6 source +address configured and a query for +.Li A +records should occur only if the node has at least one IPv4 source address +configured. +.Pp +For example, if the node has no IPv6 source addresses configured, +and +.Ar af +equals AF_INET6, and the node name being looked up has both +.Li AAAA +and +.Li A +records, then: +(a) if only +.Dv AI_ADDRCONFIG +is +specified, the function returns a +.Dv NULL +pointer; +(b) if +.Dv AI_ADDRCONFIG +| +.Dv AI_V4MAPPED +is specified, the +.Li A +records are returned as IPv4-mapped IPv6 addresses; +.El +.Pp +The special flags value of +.Dv AI_DEFAULT +is defined as +.Bd -literal -offset + #define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG) +.Ed +.Pp +We noted that the +.Fn getipnodebyname +function must allow the +.Ar name +argument to be either a node name or a literal address string +(i.e., a dotted-decimal IPv4 address or an IPv6 hex address). +This saves applications from having to call +.Xr inet_pton 3 +to handle literal address strings. +When the +.Ar name +argument is a literal address string, +the +.Ar flags +argument is always ignored. +.Pp +There are four scenarios based on the type of literal address string +and the value of the +.Ar af +argument. +The two simple cases are when +.Ar name +is a dotted-decimal IPv4 address and +.Ar af +equals +.Dv AF_INET , +or when +.Ar name +is an IPv6 hex address and +.Ar af +equals +.Dv AF_INET6 . +The members of the +returned hostent structure are: +.Li h_name +points to a copy of the +.Ar name +argument, +.Li h_aliases +is a +.Dv NULL +pointer, +.Li h_addrtype +is a copy of the +.Ar af +argument, +.Li h_length +is either 4 +(for +.Dv AF_INET ) +or 16 +(for +.Dv AF_INET6 ) , +.Li h_addr_list[0] +is a pointer to the 4-byte or 16-byte binary address, +and +.Li h_addr_list[1] +is a +.Dv NULL +pointer. +.Pp +When +.Ar name +is a dotted-decimal IPv4 address and +.Ar af +equals +.Dv AF_INET6 , +and +.Dv AI_V4MAPPED +is specified, +an IPv4-mapped IPv6 address is returned: +.Li h_name +points to an IPv6 hex address containing the IPv4-mapped IPv6 address, +.Li h_aliases +is a +.Dv NULL +pointer, +.Li h_addrtype +is +.Dv AF_INET6 , +.Li h_length +is 16, +.Li h_addr_list[0] +is a pointer to the 16-byte binary address, and +.Li h_addr_list[1] +is a +.Dv NULL +pointer. +.Pp +It is an error when +.Ar name +is an IPv6 hex address and +.Ar af +equals +.Dv AF_INET . +The function's return value is a +.Dv NULL +pointer and the value pointed to by +.Ar error_num +equals +.Dv HOST_NOT_FOUND . +.Pp +.Fn getipnodebyaddr +takes almost the same argument as +.Xr gethostbyaddr 3 , +but adds a pointer to return an error number. +Additionally it takes care of IPv4-mapped IPv6 addresses, +and IPv4-compatible IPv6 addresses. +.Pp +.Fn getipnodebyname +and +.Fn getipnodebyaddr +dynamically allocate the structure to be returned to the caller. +.Fn freehostent +reclaims memory region allocated and returned by +.Fn getipnodebyname +or +.Fn getipnodebyaddr . +.\" +.Sh FILES +.Bl -tag -width /etc/nsswitch.conf -compact +.It Pa /etc/hosts +.It Pa /etc/nsswitch.conf +.It Pa /etc/resolv.conf +.El +.\" +.Sh DIAGNOSTICS +.Fn getipnodebyname +and +.Fn getipnodebyaddr +returns +.Dv NULL +on errors. +The integer values pointed to by +.Ar error_num +may then be checked to see whether this is a temporary failure +or an invalid or unknown host. +The meanings of each error code are described in +.Xr gethostbyname 3 . +.\" +.Sh SEE ALSO +.Xr gethostbyaddr 3 , +.Xr gethostbyname 3 , +.Xr hosts 5 , +.Xr nsswitch.conf 5 , +.Xr services 5 , +.Xr hostname 7 , +.Xr named 8 +.Pp +.Rs +.%A R. Gilligan +.%A S. Thomson +.%A J. Bound +.%A W. Stevens +.%T Basic Socket Interface Extensions for IPv6 +.%R RFC2553 +.%D March 1999 +.Re +.\" +.Sh HISTORY +The implementation first appeared in KAME advanced networking kit. +.\" +.Sh STANDARDS +.Fn getipnodebyname +and +.Fn getipnodebyaddr +are documented in +.Dq Basic Socket Interface Extensions for IPv6 +(RFC2553). +.\" +.Sh BUGS +.Fn getipnodebyname +and +.Fn getipnodebyaddr +do not handle scoped IPv6 address properly. +If you use these functions, +your program will not be able to handle scoped IPv6 addresses. +For IPv6 address manipulation, +.Fn getaddrinfo 3 +and +.Fn getnameinfo 3 +are recommended. +.Pp +The current implementation is not thread-safe. +.Pp +The text was shamelessly copied from RFC2553. diff --git a/net/getnameinfo.3 b/net/getnameinfo.3 new file mode 100644 index 0000000..d7afa2f --- /dev/null +++ b/net/getnameinfo.3 @@ -0,0 +1,311 @@ +.\" $FreeBSD: src/lib/libc/net/getnameinfo.3,v 1.11 2001/10/01 16:08:55 ru Exp $ +.\" $KAME: getnameinfo.3,v 1.17 2000/08/09 21:16:17 itojun Exp $ +.\" +.\" Copyright (c) 1983, 1987, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95 +.\" +.Dd May 25, 1995 +.Dt GETNAMEINFO 3 +.Os +.\" +.Sh NAME +.Nm getnameinfo +.Nd address-to-nodename translation in protocol-independent manner +.\" +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In sys/socket.h +.In netdb.h +.Ft int +.Fn getnameinfo "const struct sockaddr *sa" "socklen_t salen" \ +"char *host" "size_t hostlen" "char *serv" "size_t servlen" "int flags" +.\" +.Sh DESCRIPTION +The +.Fn getnameinfo +function is defined for protocol-independent address-to-nodename translation. +Its functionality is a reverse conversion of +.Xr getaddrinfo 3 , +and implements similar functionality with +.Xr gethostbyaddr 3 +and +.Xr getservbyport 3 +in more sophisticated manner. +.Pp +This function looks up an IP address and port number provided by the +caller in the DNS and system-specific database, and returns text +strings for both in buffers provided by the caller. +The function indicates successful completion by a zero return value; +a non-zero return value indicates failure. +.Pp +The first argument, +.Fa sa , +points to either a +.Li sockaddr_in +structure (for IPv4) or a +.Li sockaddr_in6 +structure (for IPv6) that holds the IP address and port number. +The +.Fa salen +argument gives the length of the +.Li sockaddr_in +or +.Li sockaddr_in6 +structure. +.Pp +The function returns the nodename associated with the IP address in +the buffer pointed to by the +.Fa host +argument. +The caller provides the size of this buffer via the +.Fa hostlen +argument. +The service name associated with the port number is returned in the buffer +pointed to by +.Fa serv , +and the +.Fa servlen +argument gives the length of this buffer. +The caller specifies not to return either string by providing a zero +value for the +.Fa hostlen +or +.Fa servlen +arguments. +Otherwise, the caller must provide buffers large enough to hold the +nodename and the service name, including the terminating null characters. +.Pp +Unfortunately most systems do not provide constants that specify the +maximum size of either a fully-qualified domain name or a service name. +Therefore to aid the application in allocating buffers for these two +returned strings the following constants are defined in +.Aq Pa netdb.h : +.Bd -literal -offset +#define NI_MAXHOST 1025 +#define NI_MAXSERV 32 +.Ed +.Pp +The first value is actually defined as the constant +.Dv MAXDNAME +in recent versions of BIND's +.Aq Pa arpa/nameser.h +header +(older versions of BIND define this constant to be 256) +and the second is a guess based on the services listed in the current +Assigned Numbers RFC. +.Pp +The final argument is a +.Fa flag +that changes the default actions of this function. +By default the fully-qualified domain name (FQDN) for the host is +looked up in the DNS and returned. +If the flag bit +.Dv NI_NOFQDN +is set, only the nodename portion of the FQDN is returned for local hosts. +.Pp +If the +.Fa flag +bit +.Dv NI_NUMERICHOST +is set, or if the host's name cannot be located in the DNS, +the numeric form of the host's address is returned instead of its name +(e.g., by calling +.Fn inet_ntop +instead of +.Fn getnodebyaddr ) . +If the +.Fa flag +bit +.Dv NI_NAMEREQD +is set, an error is returned if the host's name cannot be located in the DNS. +.Pp +If the flag bit +.Dv NI_NUMERICSERV +is set, the numeric form of the service address is returned +(e.g., its port number) +instead of its name. +The two +.Dv NI_NUMERICxxx +flags are required to support the +.Fl n +flag that many commands provide. +.Pp +A fifth flag bit, +.Dv NI_DGRAM , +specifies that the service is a datagram service, and causes +.Fn getservbyport +to be called with a second argument of +.Dq udp +instead of its default of +.Dq tcp . +This is required for the few ports (512-514) +that have different services for UDP and TCP. +.Pp +These +.Dv NI_xxx +flags are defined in +.Aq Pa netdb.h . +.\" +.Sh EXTENSION +The implementation allows experimental numeric IPv6 address notation with +scope identifier. +IPv6 link-local address will appear as string like +.Dq Li fe80::1%ne0 , +if +.Dv NI_WITHSCOPEID +bit is enabled in +.Ar flags +argument. +Refer to +.Xr getaddrinfo 3 +for the notation. +.\" +.Sh EXAMPLES +The following code tries to get numeric hostname, and service name, +for given socket address. +Observe that there is no hardcoded reference to particular address family. +.Bd -literal -offset indent +struct sockaddr *sa; /* input */ +char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV]; + +if (getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf), sbuf, + sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV)) { + errx(1, "could not get numeric hostname"); + /*NOTREACHED*/ +} +printf("host=%s, serv=%s\\n", hbuf, sbuf); +.Ed +.Pp +The following version checks if the socket address has reverse address mapping. +.Bd -literal -offset indent +struct sockaddr *sa; /* input */ +char hbuf[NI_MAXHOST]; + +if (getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf), NULL, 0, + NI_NAMEREQD)) { + errx(1, "could not resolve hostname"); + /*NOTREACHED*/ +} +printf("host=%s\\n", hbuf); +.Ed +.\" +.Sh FILES +.Bl -tag -width /etc/nsswitch.conf -compact +.It Pa /etc/hosts +.It Pa /etc/nsswitch.conf +.It Pa /etc/resolv.conf +.El +.\" +.Sh DIAGNOSTICS +The function indicates successful completion by a zero return value; +a non-zero return value indicates failure. +Error codes are as below: +.Bl -tag -width Er +.It Bq Er EAI_AGAIN +The name could not be resolved at this time. +Future attempts may succeed. +.It Bq Er EAI_BADFLAGS +The flags had an invalid value. +.It Bq Er EAI_FAIL +A non-recoverable error occurred. +.It Bq Er EAI_FAMILY +The address family was not recognized or the address length was invalid +for the specified family. +.It Bq Er EAI_MEMORY +There was a memory allocation failure. +.It Bq Er EAI_NONAME +The name does not resolve for the supplied parameters. +.Dv NI_NAMEREQD +is set and the host's name cannot be located, +or both nodename and servname were null. +.It Bq Er EAI_SYSTEM +A system error occurred. +The error code can be found in errno. +.El +.\" +.Sh SEE ALSO +.Xr getaddrinfo 3 , +.Xr gethostbyaddr 3 , +.Xr getservbyport 3 , +.Xr hosts 5 , +.Xr services 5 , +.Xr hostname 7 , +.Xr named 8 +.Pp +.Rs +.%A R. Gilligan +.%A S. Thomson +.%A J. Bound +.%A W. Stevens +.%T Basic Socket Interface Extensions for IPv6 +.%R RFC2553 +.%D March 1999 +.Re +.Rs +.%A Tatsuya Jinmei +.%A Atsushi Onoe +.%T "An Extension of Format for IPv6 Scoped Addresses" +.%R internet draft +.%N draft-ietf-ipngwg-scopedaddr-format-02.txt +.%O work in progress material +.Re +.Rs +.%A Craig Metz +.%T Protocol Independence Using the Sockets API +.%B "Proceedings of the freenix track: 2000 USENIX annual technical conference" +.%D June 2000 +.Re +.\" +.Sh HISTORY +The implementation first appeared in WIDE Hydrangea IPv6 protocol stack kit. +.\" +.Sh STANDARDS +The +.Fn getaddrinfo +function is defined in +.St -p1003.1g-2000 , +and documented in +.Dq Basic Socket Interface Extensions for IPv6 +(RFC2553). +.\" +.Sh BUGS +The current implementation is not thread-safe. +.Pp +The text was shamelessly copied from RFC2553. +.Pp +The type of the 2nd argument should be +.Li socklen_t +for RFC2553 conformance. +The current code is based on pre-RFC2553 specification. diff --git a/net/getnetent.3 b/net/getnetent.3 new file mode 100644 index 0000000..7a60a67 --- /dev/null +++ b/net/getnetent.3 @@ -0,0 +1,172 @@ +.\" Copyright (c) 1983, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)getnetent.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/net/getnetent.3,v 1.16 2001/10/01 16:08:55 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt GETNETENT 3 +.Os +.Sh NAME +.Nm getnetent , +.Nm getnetbyaddr , +.Nm getnetbyname , +.Nm setnetent , +.Nm endnetent +.Nd get network entry +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In netdb.h +.Ft struct netent * +.Fn getnetent void +.Ft struct netent * +.Fn getnetbyname "const char *name" +.Ft struct netent * +.Fn getnetbyaddr "unsigned long net" "int type" +.Ft void +.Fn setnetent "int stayopen" +.Ft void +.Fn endnetent void +.Sh DESCRIPTION +The +.Fn getnetent , +.Fn getnetbyname , +and +.Fn getnetbyaddr +functions +each return a pointer to an object with the +following structure describing an internet network. +This structure contains either the information obtained +from the nameserver, +.Xr named 8 , +broken-out fields of a line in the network data base +.Pa /etc/networks , +or entries supplied by the +.Xr yp 4 +system. The order of the lookups is controlled by the +`networks' entry in +.Xr nsswitch.conf 5 . +.Pp +.Bd -literal -offset indent +struct netent { + char *n_name; /* official name of net */ + char **n_aliases; /* alias list */ + int n_addrtype; /* net number type */ + unsigned long n_net; /* net number */ +}; +.Ed +.Pp +The members of this structure are: +.Bl -tag -width n_addrtype +.It Fa n_name +The official name of the network. +.It Fa n_aliases +A zero terminated list of alternate names for the network. +.It Fa n_addrtype +The type of the network number returned; currently only AF_INET. +.It Fa n_net +The network number. Network numbers are returned in machine byte +order. +.El +.Pp +The +.Fn getnetent +function +reads the next line of the file, opening the file if necessary. +.Pp +The +.Fn setnetent +function +opens and rewinds the file. If the +.Fa stayopen +flag is non-zero, +the net data base will not be closed after each call to +.Fn getnetbyname +or +.Fn getnetbyaddr . +.Pp +The +.Fn endnetent +function +closes the file. +.Pp +The +.Fn getnetbyname +function +and +.Fn getnetbyaddr +sequentially search from the beginning +of the file until a matching +net name or +net address and type is found, +or until +.Dv EOF +is encountered. +The +.Fa type +must be +.Dv AF_INET . +Network numbers are supplied in host order. +.Sh FILES +.Bl -tag -width /etc/nsswitch.conf -compact +.It Pa /etc/networks +.It Pa /etc/nsswitch.conf +.It Pa /etc/resolv.conf +.El +.Sh DIAGNOSTICS +Null pointer +(0) returned on +.Dv EOF +or error. +.Sh SEE ALSO +.Xr networks 5 +.Pp +.%T RFC 1101 +.Sh HISTORY +The +.Fn getnetent , +.Fn getnetbyaddr , +.Fn getnetbyname , +.Fn setnetent , +and +.Fn endnetent +functions appeared in +.Bx 4.2 . +.Sh BUGS +The data space used by +these functions is static; if future use requires the data, it should be +copied before any subsequent calls to these functions overwrite it. +Only Internet network +numbers are currently understood. +Expecting network numbers to fit +in no more than 32 bits is probably +naive. diff --git a/net/getprotoent.3 b/net/getprotoent.3 new file mode 100644 index 0000000..18b5654 --- /dev/null +++ b/net/getprotoent.3 @@ -0,0 +1,149 @@ +.\" Copyright (c) 1983, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)getprotoent.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/net/getprotoent.3,v 1.8 2001/10/01 16:08:55 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt GETPROTOENT 3 +.Os +.Sh NAME +.Nm getprotoent , +.Nm getprotobynumber , +.Nm getprotobyname , +.Nm setprotoent , +.Nm endprotoent +.Nd get protocol entry +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In netdb.h +.Ft struct protoent * +.Fn getprotoent void +.Ft struct protoent * +.Fn getprotobyname "const char *name" +.Ft struct protoent * +.Fn getprotobynumber "int proto" +.Ft void +.Fn setprotoent "int stayopen" +.Ft void +.Fn endprotoent void +.Sh DESCRIPTION +The +.Fn getprotoent , +.Fn getprotobyname , +and +.Fn getprotobynumber +functions +each return a pointer to an object with the +following structure +containing the broken-out +fields of a line in the network protocol data base, +.Pa /etc/protocols . +.Bd -literal -offset indent +.Pp +struct protoent { + char *p_name; /* official name of protocol */ + char **p_aliases; /* alias list */ + int p_proto; /* protocol number */ +}; +.Ed +.Pp +The members of this structure are: +.Bl -tag -width p_aliases +.It Fa p_name +The official name of the protocol. +.It Fa p_aliases +A zero terminated list of alternate names for the protocol. +.It Fa p_proto +The protocol number. +.El +.Pp +The +.Fn getprotoent +function +reads the next line of the file, opening the file if necessary. +.Pp +The +.Fn setprotoent +function +opens and rewinds the file. If the +.Fa stayopen +flag is non-zero, +the net data base will not be closed after each call to +.Fn getprotobyname +or +.Fn getprotobynumber . +.Pp +The +.Fn endprotoent +function +closes the file. +.Pp +The +.Fn getprotobyname +function +and +.Fn getprotobynumber +sequentially search from the beginning +of the file until a matching +protocol name or +protocol number is found, +or until +.Dv EOF +is encountered. +.Sh RETURN VALUES +Null pointer +(0) returned on +.Dv EOF +or error. +.Sh FILES +.Bl -tag -width /etc/protocols -compact +.It Pa /etc/protocols +.El +.Sh SEE ALSO +.Xr protocols 5 +.Sh HISTORY +The +.Fn getprotoent , +.Fn getprotobynumber , +.Fn getprotobyname , +.Fn setprotoent , +and +.Fn endprotoent +functions appeared in +.Bx 4.2 . +.Sh BUGS +These functions use a static data space; +if the data is needed for future use, it should be +copied before any subsequent calls overwrite it. +Only the Internet +protocols are currently understood. diff --git a/net/getservent.3 b/net/getservent.3 new file mode 100644 index 0000000..3d398bd --- /dev/null +++ b/net/getservent.3 @@ -0,0 +1,158 @@ +.\" Copyright (c) 1983, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" From: @(#)getservent.3 8.3 (Berkeley) 1/12/94 +.\" $FreeBSD: src/lib/libc/net/getservent.3,v 1.12 2001/10/01 16:08:55 ru Exp $ +.\" +.Dd July 9, 1995 +.Dt GETSERVENT 3 +.Os +.Sh NAME +.Nm getservent , +.Nm getservbyport , +.Nm getservbyname , +.Nm setservent , +.Nm endservent +.Nd get service entry +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In netdb.h +.Ft struct servent * +.Fn getservent +.Ft struct servent * +.Fn getservbyname "const char *name" "const char *proto" +.Ft struct servent * +.Fn getservbyport "int port" "const char *proto" +.Ft void +.Fn setservent "int stayopen" +.Ft void +.Fn endservent void +.Sh DESCRIPTION +The +.Fn getservent , +.Fn getservbyname , +and +.Fn getservbyport +functions +each return a pointer to an object with the +following structure +containing the broken-out +fields of a line in the network services data base, +.Pa /etc/services . +.Bd -literal -offset indent +struct servent { + char *s_name; /* official name of service */ + char **s_aliases; /* alias list */ + int s_port; /* port service resides at */ + char *s_proto; /* protocol to use */ +}; +.Ed +.Pp +The members of this structure are: +.Bl -tag -width s_aliases +.It Fa s_name +The official name of the service. +.It Fa s_aliases +A zero terminated list of alternate names for the service. +.It Fa s_port +The port number at which the service resides. +Port numbers are returned in network byte order. +.It Fa s_proto +The name of the protocol to use when contacting the +service. +.El +.Pp +The +.Fn getservent +function +reads the next line of the file, opening the file if necessary. +.Pp +The +.Fn setservent +function +opens and rewinds the file. If the +.Fa stayopen +flag is non-zero, +the net data base will not be closed after each call to +.Fn getservbyname +or +.Fn getservbyport . +.Pp +The +.Fn endservent +function +closes the file. +.Pp +The +.Fn getservbyname +and +.Fn getservbyport +functions +sequentially search from the beginning +of the file until a matching +protocol name or +port number (which must be specified in +network byte order) is found, +or until +.Dv EOF +is encountered. +If a protocol name is also supplied (non- +.Dv NULL ) , +searches must also match the protocol. +.Sh FILES +.Bl -tag -width /etc/services -compact +.It Pa /etc/services +.El +.Sh DIAGNOSTICS +Null pointer +(0) returned on +.Dv EOF +or error. +.Sh SEE ALSO +.Xr getprotoent 3 , +.Xr services 5 +.Sh HISTORY +The +.Fn getservent , +.Fn getservbyport , +.Fn getservbyname , +.Fn setservent , +and +.Fn endservent +functions appeared in +.Bx 4.2 . +.Sh BUGS +These functions use static data storage; +if the data is needed for future use, it should be +copied before any subsequent calls overwrite it. +Expecting port numbers to fit in a 32 bit +quantity is probably naive. diff --git a/net/hesiod.3 b/net/hesiod.3 new file mode 100644 index 0000000..8de1f92 --- /dev/null +++ b/net/hesiod.3 @@ -0,0 +1,159 @@ +.\" $NetBSD: hesiod.3,v 1.1 1999/01/25 03:43:04 lukem Exp $ +.\" $FreeBSD: src/lib/libc/net/hesiod.3,v 1.3 2001/10/01 16:08:55 ru Exp $ +.\" +.\" from: #Id: hesiod.3,v 1.9.2.1 1997/01/03 21:02:23 ghudson Exp # +.\" +.\" Copyright 1988, 1996 by the Massachusetts Institute of Technology. +.\" +.\" Permission to use, copy, modify, and distribute this +.\" software and its documentation for any purpose and without +.\" fee is hereby granted, provided that the above copyright +.\" notice appear in all copies and that both that copyright +.\" notice and this permission notice appear in supporting +.\" documentation, and that the name of M.I.T. not be used in +.\" advertising or publicity pertaining to distribution of the +.\" software without specific, written prior permission. +.\" M.I.T. makes no representations about the suitability of +.\" this software for any purpose. It is provided "as is" +.\" without express or implied warranty. +.\" +.Dd November 30, 1996 +.Dt HESIOD 3 +.Os +.Sh NAME +.Nm hesiod , +.Nm hesiod_init , +.Nm hesiod_resolve , +.Nm hesiod_free_list , +.Nm hesiod_to_bind , +.Nm hesiod_end +.Nd Hesiod name server interface library +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In hesiod.h +.Ft int +.Fn hesiod_init "void **context" +.Ft char ** +.Fn hesiod_resolve "void *context" "const char *name" "const char *type" +.Ft void +.Fn hesiod_free_list "void *context" "char **list" +.Ft char * +.Fn hesiod_to_bind "void *context" "const char *name" "const char *type" +.Ft void +.Fn hesiod_end "void *context" +.Sh DESCRIPTION +This family of functions allows you to perform lookups of Hesiod +information, which is stored as text records in the Domain Name +Service. +To perform lookups, you must first initialize a +.Fa context , +an opaque object which stores information used internally by the +library between calls. +.Fn hesiod_init +initializes a context, storing a pointer to the context in the +location pointed to by the +.Fa context +argument. +.Fn hesiod_end +frees the resources used by a context. +.Pp +.Fn hesiod_resolve +is the primary interface to the library. +If successful, it returns a +list of one or more strings giving the records matching +.Fa name +and +.Fa type . +The last element of the list is followed by a +.Dv NULL +pointer. +It is the +caller's responsibility to call +.Fn hesiod_free_list +to free the resources used by the returned list. +.Pp +.Fn hesiod_to_bind +converts +.Fa name +and +.Fa type +into the DNS name used by +.Fn hesiod_resolve . +It is the caller's responsibility to free the returned string using +.Fn free . +.Sh RETURN VALUES +.Rv -std hesiod_init +On failure, +.Fn hesiod_resolve +and +.Fn hesiod_to_bind +return +.Dv NULL +and set the global variable +.Va errno +to indicate the error. +.Sh ENVIRONMENT +.Bl -tag -width HESIOD_CONFIG +.It Ev HES_DOMAIN +If the environment variable +.Ev HES_DOMAIN +is set, it will override the domain in the Hesiod configuration file. +.It Ev HESIOD_CONFIG +If the environment variable +.Ev HESIOD_CONFIG +is set, it specifies the location of the Hesiod configuration file. +.El +.Sh SEE ALSO +.Xr hesiod.conf 5 , +.Xr named 8 +.Rs +.%T "Hesiod - Project Athena Technical Plan -- Name Service" +.Re +.Sh ERRORS +Hesiod calls may fail because of: +.Bl -tag -width Er +.It Bq Er ENOMEM +Insufficient memory was available to carry out the requested +operation. +.It Bq Er ENOEXEC +.Fn hesiod_init +failed because the Hesiod configuration file was invalid. +.It Bq Er ECONNREFUSED +.Fn hesiod_resolve +failed because no name server could be contacted to answer the query. +.It Bq Er EMSGSIZE +.Fn hesiod_resolve +or +.Fn hesiod_to_bind +failed because the query or response was too big to fit into the +packet buffers. +.It Bq Er ENOENT +.Fn hesiod_resolve +failed because the name server had no text records matching +.Fa name +and +.Fa type , +or +.Fn hesiod_to_bind +failed because the +.Fa name +argument had a domain extension which could not be resolved with type +.Dq rhs\-extension +in the local Hesiod domain. +.El +.Sh AUTHORS +.An Steve Dyer , +IBM/Project Athena +.An Greg Hudson , +MIT Team Athena +.Pp +Copyright 1987, 1988, 1995, 1996 by the Massachusetts Institute of Technology. +.Sh BUGS +The strings corresponding to the +.Va errno +values set by the Hesiod functions are not particularly indicative of +what went wrong, especially for +.Er ENOEXEC +and +.Er ENOENT . diff --git a/net/if_indextoname.3 b/net/if_indextoname.3 new file mode 100644 index 0000000..4b5bff5 --- /dev/null +++ b/net/if_indextoname.3 @@ -0,0 +1,142 @@ +.\" Copyright (c) 1983, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" From: @(#)rcmd.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/net/if_indextoname.3,v 1.7 2001/10/01 16:08:55 ru Exp $ +.\" +.Dd May 21, 1998 +.Dt IF_NAMETOINDEX 3 +.Os +.Sh NAME +.Nm if_nametoindex , +.Nm if_indextoname , +.Nm if_nameindex , +.Nm if_freenameindex +.Nd convert interface index to name, and vice versa +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In sys/socket.h +.In net/if.h +.Ft "unsigned int" +.Fn if_nametoindex "const char *ifname" +.Ft "char *" +.Fn if_indextoname "unsigned int ifindex" "char *ifname" +.Ft "struct if_nameindex *" +.Fn if_nameindex "void" +.Ft "void" +.Fn if_freenameindex "struct if_nameindex *ptr" +.Sh DESCRIPTION +The functions map interface index to readable interface name +(such as +.Dq Li lo0 ) , +and vice versa. +.Pp +.Fn if_nametoindex +converts readable interface name to interface index +.Pp positive integer value . +If the specified interface does not exist, 0 will be returned. +.Pp +.Fn if_indextoname +converts interface index to readable interface name. +The +.Fa ifname +argument must point to a buffer of at least +.Dv IF_NAMESIZE +bytes into which the interface name corresponding to the specified index is +returned. +.Dv ( IF_NAMESIZE +is also defined in +.Aq Pa net/if.h +and its value includes a terminating null byte at the end of the +interface name.) +This pointer is also the return value of the function. +If there is no interface corresponding to the specified index, +.Dv NULL +is returned. +.Pp +.Fn if_nameindex +returns an array of +.Fa if_nameindex +structures. +.Fa if_nametoindex +is also defined in +.Aq Pa net/if.h , +and is as follows: +.Bd -literal -offset +struct if_nameindex { + unsigned int if_index; /* 1, 2, ... */ + char *if_name; /* null terminated name: "le0", ... */ +}; +.Ed +.Pp +The end of the array of structures is indicated by a structure with +an +.Fa if_index +of 0 and an +.Fa if_name +of +.Dv NULL . +The function returns a +.Dv NULL +pointer upon an error. +The memory used for this array of structures along with the interface +names pointed to by the +.Fa if_name +members is obtained dynamically. +This memory is freed by the +.Fn if_freenameindex +function. +.Pp +.Fn if_freenameindex +takes a pointer that was returned by +.Fn if_nameindex +as argument +.Pq Fa ptr , +and it reclaims the region allocated. +.Sh DIAGNOSTICS +.Fn if_nametoindex +returns 0 on error, positive integer on success. +.Fn if_indextoname +and +.Fn if_nameindex +return +.Dv NULL +on errors. +.Sh SEE ALSO +R. Gilligan, S. Thomson, J. Bound, and W. Stevens, +``Basic Socket Interface Extensions for IPv6,'' RFC2553, March 1999. +.Sh HISTORY +The implementation first appeared in WIDE Hydrangea IPv6 protocol stack kit. +.Sh STANDARDS +These functions are defined in ``Basic Socket Interface Extensions for IPv6'' +(RFC2533). diff --git a/net/inet.3 b/net/inet.3 new file mode 100644 index 0000000..c65d1dc --- /dev/null +++ b/net/inet.3 @@ -0,0 +1,271 @@ +.\" Copyright (c) 1983, 1990, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" From: @(#)inet.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/net/inet.3,v 1.19 2001/10/01 16:08:55 ru Exp $ +.\" +.Dd June 17, 1996 +.Dt INET 3 +.Os +.Sh NAME +.Nm inet_aton , +.Nm inet_addr , +.Nm inet_network , +.Nm inet_ntoa , +.Nm inet_ntop , +.Nm inet_pton , +.Nm inet_makeaddr , +.Nm inet_lnaof , +.Nm inet_netof +.Nd Internet address manipulation routines +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In sys/socket.h +.In netinet/in.h +.In arpa/inet.h +.Ft int +.Fn inet_aton "const char *cp" "struct in_addr *pin" +.Ft in_addr_t +.Fn inet_addr "const char *cp" +.Ft in_addr_t +.Fn inet_network "const char *cp" +.Ft char * +.Fn inet_ntoa "struct in_addr in" +.Ft const char * +.Fn inet_ntop "int af" "const void *src" "char *dst" "size_t size" +.Ft int +.Fn inet_pton "int af" "const char *src" "void *dst" +.Ft struct in_addr +.Fn inet_makeaddr "in_addr_t net" "in_addr_t lna" +.Ft in_addr_t +.Fn inet_lnaof "struct in_addr in" +.Ft in_addr_t +.Fn inet_netof "struct in_addr in" +.Sh DESCRIPTION +The routines +.Fn inet_aton , +.Fn inet_addr +and +.Fn inet_network +interpret character strings representing +numbers expressed in the Internet standard +.Ql .\& +notation. +.Pp +The +.Fn inet_pton +function converts a presentation format address (that is, printable form +as held in a character string) to network format (usually a +.Ft struct in_addr +or some other internal binary representation, in network byte order). +It returns 1 if the address was valid for the specified address family, or +0 if the address wasn't parseable in the specified address family, or -1 +if some system error occurred (in which case +.Va errno +will have been set). +This function is presently valid for +.Dv AF_INET +and +.Dv AF_INET6 . +.Pp +The +.Fn inet_aton +routine interprets the specified character string as an Internet address, +placing the address into the structure provided. +It returns 1 if the string was successfully interpreted, +or 0 if the string is invalid. +The +.Fn inet_addr +and +.Fn inet_network +functions return numbers suitable for use +as Internet addresses and Internet network +numbers, respectively. +.Pp +The function +.Fn inet_ntop +converts an address from network format (usually a +.Ft struct in_addr +or some other binary form, in network byte order) to presentation format +(suitable for external display purposes). +It returns NULL if a system error occurs (in which case, +.Va errno +will have been set), or it returns a pointer to the destination string. +This function is presently valid for +.Dv AF_INET +and +.Dv AF_INET6 . +.Pp +The routine +.Fn inet_ntoa +takes an Internet address and returns an +.Tn ASCII +string representing the address in +.Ql .\& +notation. The routine +.Fn inet_makeaddr +takes an Internet network number and a local +network address and constructs an Internet address +from it. The routines +.Fn inet_netof +and +.Fn inet_lnaof +break apart Internet host addresses, returning +the network number and local network address part, +respectively. +.Pp +All Internet addresses are returned in network +order (bytes ordered from left to right). +All network numbers and local address parts are +returned as machine byte order integer values. +.Sh INTERNET ADDRESSES +Values specified using the +.Ql .\& +notation take one +of the following forms: +.Bd -literal -offset indent +a.b.c.d +a.b.c +a.b +a +.Ed +.Pp +When four parts are specified, each is interpreted +as a byte of data and assigned, from left to right, +to the four bytes of an Internet address. Note +that when an Internet address is viewed as a 32-bit +integer quantity on the +.Tn VAX +the bytes referred to +above appear as +.Dq Li d.c.b.a . +That is, +.Tn VAX +bytes are +ordered from right to left. +.Pp +When a three part address is specified, the last +part is interpreted as a 16-bit quantity and placed +in the right-most two bytes of the network address. +This makes the three part address format convenient +for specifying Class B network addresses as +.Dq Li 128.net.host . +.Pp +When a two part address is supplied, the last part +is interpreted as a 24-bit quantity and placed in +the right most three bytes of the network address. +This makes the two part address format convenient +for specifying Class A network addresses as +.Dq Li net.host . +.Pp +When only one part is given, the value is stored +directly in the network address without any byte +rearrangement. +.Pp +All numbers supplied as +.Dq parts +in a +.Ql .\& +notation +may be decimal, octal, or hexadecimal, as specified +in the C language (i.e., a leading 0x or 0X implies +hexadecimal; otherwise, a leading 0 implies octal; +otherwise, the number is interpreted as decimal). +.Pp +The +.Fn inet_aton +and +.Fn inet_ntoa +functions are semi-deprecated in favor of the +.Xr addr2ascii 3 +family. However, since those functions are not yet widely implemented, +portable programs cannot rely on their presence and will continue +to use the +.Xr inet 3 +functions for some time. +.Sh DIAGNOSTICS +The constant +.Dv INADDR_NONE +is returned by +.Fn inet_addr +and +.Fn inet_network +for malformed requests. +.Sh SEE ALSO +.Xr addr2ascii 3 , +.Xr byteorder 3 , +.Xr gethostbyname 3 , +.Xr getnetent 3 , +.Xr inet_net 3 , +.Xr hosts 5 , +.Xr networks 5 +.Rs +.%R RFC +.%N 2373 +.%D July 1998 +.%T "IP Version 6 Addressing Architecture" +.Re +.Sh STANDARDS +The +.Fn inet_ntop +and +.Fn inet_pton +functions conform to +.St -xns5.2 . +Note that +.Fn inet_pton +does not accept 1-, 2-, or 3-part dotted addresses; all four parts +must be specified. +This is a narrower input set than that accepted by +.Fn inet_aton . +.Sh HISTORY +These +functions appeared in +.Bx 4.2 . +.Sh BUGS +The value +.Dv INADDR_NONE +(0xffffffff) is a valid broadcast address, but +.Fn inet_addr +cannot return that value without indicating failure. +The newer +.Fn inet_aton +function does not share this problem. +The problem of host byte ordering versus network byte ordering is +confusing. +The string returned by +.Fn inet_ntoa +resides in a static memory area. +.Pp +Inet_addr should return a +.Fa struct in_addr . diff --git a/net/inet6_option_space.3 b/net/inet6_option_space.3 new file mode 100644 index 0000000..4ef8047 --- /dev/null +++ b/net/inet6_option_space.3 @@ -0,0 +1,445 @@ +.\" Copyright (c) 1983, 1987, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" $Id: inet6_option_space.3,v 1.1 2001/12/18 01:21:21 bbraun Exp $ +.\" $FreeBSD: src/lib/libc/net/inet6_option_space.3,v 1.8 2001/10/01 16:08:55 ru Exp $ +.\" +.Dd December 10, 1999 +.Dt INET6_OPTION_SPACE 3 +.Os +.\" +.Sh NAME +.Nm inet6_option_space , +.Nm inet6_option_init , +.Nm inet6_option_append , +.Nm inet6_option_alloc , +.Nm inet6_option_next , +.Nm inet6_option_find +.Nd IPv6 Hop-by-Hop and Destination Options manipulation +.\" +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In netinet/in.h +.Ft "int" +.Fn inet6_option_space "int nbytes" +.Ft "int" +.Fn inet6_option_init "void *bp" "struct cmsghdr **cmsgp" "int type" +.Ft "int" +.Fn inet6_option_append "struct cmsghdr *cmsg" "const u_int8_t *typep" "int multx" "int plusy" +.Ft "u_int8_t *" +.Fn inet6_option_alloc "struct cmsghdr *cmsg" "int datalen" "int multx" "int plusy" +.Ft "int" +.Fn inet6_option_next "const struct cmsghdr *cmsg" "u_int8_t **tptrp" +.Ft "int" +.Fn inet6_option_find "const struct cmsghdr *cmsg" "u_int8_t **tptrp" "int type" +.\" +.Sh DESCRIPTION +.\" +Building and parsing the Hop-by-Hop and Destination options is +complicated due to alignment constranints, padding and +ancillary data manipulation. +RFC2292 defines a set of functions to help the application. +The function prototypes for +these functions are all in the +.Aq Li netinet/in.h +header. +.\" +.Ss inet6_option_space +.Fn inet6_option_space +returns the number of bytes required to hold an option when it is stored as +ancillary data, including the +.Li cmsghdr +structure at the beginning, +and any padding at the end +(to make its size a multiple of 8 bytes). +The argument is the size of the structure defining the option, +which must include any pad bytes at the beginning +(the value +.Li y +in the alignment term +.Dq Li "xn + y" ) , +the type byte, the length byte, and the option data. +.Pp +Note: If multiple options are stored in a single ancillary data +object, which is the recommended technique, this function +overestimates the amount of space required by the size of +.Li N-1 +.Li cmsghdr +structures, +where +.Li N +is the number of options to be stored in the object. +This is of little consequence, since it is assumed that most +Hop-by-Hop option headers and Destination option headers carry only +one option +(appendix B of [RFC-2460]). +.\" +.Ss inet6_option_init +.Fn inet6_option_init +is called once per ancillary data object that will +contain either Hop-by-Hop or Destination options. +It returns +.Li 0 +on success or +.Li -1 +on an error. +.Pp +.Fa bp +is a pointer to previously allocated space that will contain the +ancillary data object. +It must be large enough to contain all the +individual options to be added by later calls to +.Fn inet6_option_append +and +.Fn inet6_option_alloc . +.Pp +.Fa cmsgp +is a pointer to a pointer to a +.Li cmsghdr +structure. +.Fa *cmsgp +is initialized by this function to point to the +.Li cmsghdr +structure constructed by this function in the buffer pointed to by +.Fa bp . +.Pp +.Fa type +is either +.Dv IPV6_HOPOPTS +or +.Dv IPV6_DSTOPTS . +This +.Fa type +is stored in the +.Li cmsg_type +member of the +.Li cmsghdr +structure pointed to by +.Fa *cmsgp . +.\" +.Ss inet6_option_append +This function appends a Hop-by-Hop option or a Destination option +into an ancillary data object that has been initialized by +.Fn inet6_option_init . +This function returns +.Li 0 +if it succeeds or +.Li -1 +on an error. +.Pp +.Fa cmsg +is a pointer to the +.Li cmsghdr +structure that must have been +initialized by +.Fn inet6_option_init . +.Pp +.Fa typep +is a pointer to the 8-bit option type. +It is assumed that this +field is immediately followed by the 8-bit option data length field, +which is then followed immediately by the option data. +The caller +initializes these three fields +(the type-length-value, or TLV) +before calling this function. +.Pp +The option type must have a value from +.Li 2 +to +.Li 255 , +inclusive. +.Li ( 0 +and +.Li 1 +are reserved for the +.Li Pad1 +and +.Li PadN +options, respectively.) +.Pp +The option data length must have a value between +.Li 0 +and +.Li 255 , +inclusive, and is the length of the option data that follows. +.Pp +.Fa multx +is the value +.Li x +in the alignment term +.Dq Li xn + y . +It must have a value of +.Li 1 , +.Li 2 , +.Li 4 , +or +.Li 8 . +.Pp +.Fa plusy +is the value +.Li y +in the alignment term +.Dq Li xn + y . +It must have a value between +.Li 0 +and +.Li 7 , +inclusive. +.\" +.Ss inet6_option_alloc +This function appends a Hop-by-Hop option or a Destination option +into an ancillary data object that has been initialized by +.Fn inet6_option_init . +This function returns a pointer to the 8-bit +option type field that starts the option on success, or +.Dv NULL +on an error. +.Pp +The difference between this function and +.Fn inet6_option_append +is that the latter copies the contents of a previously built option into +the ancillary data object while the current function returns a +pointer to the space in the data object where the option's TLV must +then be built by the caller. +.Pp +.Fa cmsg +is a pointer to the +.Li cmsghdr +structure that must have been +initialized by +.Fn inet6_option_init . +.Pp +.Fa datalen +is the value of the option data length byte for this option. +This value is required as an argument to allow the function to +determine if padding must be appended at the end of the option. +(The +.Fn inet6_option_append +function does not need a data length argument +since the option data length must already be stored by the caller.) +.Pp +.Fa multx +is the value +.Li x +in the alignment term +.Dq Li xn + y . +It must have a value of +.Li 1 , +.Li 2 , +.Li 4 , +or +.Li 8 . +.Pp +.Fa plusy +is the value +.Li y +in the alignment term +.Dq Li xn + y . +It must have a value between +.Li 0 +and +.Li 7 , +inclusive. +.\" +.Ss inet6_option_next +This function processes the next Hop-by-Hop option or Destination +option in an ancillary data object. +If another option remains to be +processed, the return value of the function is +.Li 0 +and +.Fa *tptrp +points to +the 8-bit option type field +(which is followed by the 8-bit option +data length, followed by the option data). +If no more options remain +to be processed, the return value is +.Li -1 +and +.Fa *tptrp +is +.Dv NULL . +If an error occurs, the return value is +.Li -1 +and +.Fa *tptrp +is not +.Dv NULL . +.Pp +.Fa cmsg +is a pointer to +.Li cmsghdr +structure of which +.Li cmsg_level +equals +.Dv IPPROTO_IPV6 +and +.Li cmsg_type +equals either +.Dv IPV6_HOPOPTS +or +.Dv IPV6_DSTOPTS . +.Pp +.Fa tptrp +is a pointer to a pointer to an 8-bit byte and +.Fa *tptrp +is used +by the function to remember its place in the ancillary data object +each time the function is called. +The first time this function is +called for a given ancillary data object, +.Fa *tptrp +must be set to +.Dv NULL . +.Pp +Each time this function returns success, +.Fa *tptrp +points to the 8-bit +option type field for the next option to be processed. +.\" +.Ss inet6_option_find +This function is similar to the previously described +.Fn inet6_option_next +function, except this function lets the caller +specify the option type to be searched for, instead of always +returning the next option in the ancillary data object. +.Fa cmsg +is a +pointer to +.Li cmsghdr +structure of which +.Li cmsg_level +equals +.Dv IPPROTO_IPV6 +and +.Li cmsg_type +equals either +.Dv IPV6_HOPOPTS +or +.Dv IPV6_DSTOPTS . +.Pp +.Fa tptrp +is a pointer to a pointer to an 8-bit byte and +.Fa *tptrp +is used +by the function to remember its place in the ancillary data object +each time the function is called. +The first time this function is +called for a given ancillary data object, +.Fa *tptrp +must be set to +.Dv NULL . +.Pa +This function starts searching for an option of the specified type +beginning after the value of +.Fa *tptrp . +If an option of the specified +type is located, this function returns +.Li 0 +and +.Fa *tptrp +points to the 8- +bit option type field for the option of the specified type. +If an +option of the specified type is not located, the return value is +.Li -1 +and +.Fa *tptrp +is +.Dv NULL . +If an error occurs, the return value is +.Li -1 +and +.Fa *tptrp +is not +.Dv NULL . +.\" +.Sh DIAGNOSTICS +.Fn inet6_option_init +and +.Fn inet6_option_append +return +.Li 0 +on success or +.Li -1 +on an error. +.Pp +.Fn inet6_option_alloc +returns +.Dv NULL +on an error. +.Pp +On errors, +.Fn inet6_option_next +and +.Fn inet6_option_find +return +.Li -1 +setting +.Fa *tptrp +to non +.Dv NULL +value. +.\" +.Sh EXAMPLES +RFC2292 gives comprehensive examples in chapter 6. +.\" +.Sh SEE ALSO +.Rs +.%A W. Stevens +.%A M. Thomas +.%T "Advanced Sockets API for IPv6" +.%N RFC2292 +.%D February 1998 +.Re +.Rs +.%A S. Deering +.%A R. Hinden +.%T "Internet Protocol, Version 6 (IPv6) Specification" +.%N RFC2460 +.%D December 1998 +.Re +.\" +.Sh HISTORY +The implementation first appeared in KAME advanced networking kit. +.\" +.Sh STANDARDS +The functions +are documented in +.Dq Advanced Sockets API for IPv6 +(RFC2292). +.\" +.Sh BUGS +The text was shamelessly copied from RFC2292. diff --git a/net/inet6_rthdr_space.3 b/net/inet6_rthdr_space.3 new file mode 100644 index 0000000..42a4662 --- /dev/null +++ b/net/inet6_rthdr_space.3 @@ -0,0 +1,323 @@ +.\" Copyright (c) 1983, 1987, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" $Id: inet6_rthdr_space.3,v 1.1 2001/12/18 01:21:22 bbraun Exp $ +.\" $FreeBSD: src/lib/libc/net/inet6_rthdr_space.3,v 1.8 2001/10/01 16:08:55 ru Exp $ +.\" +.Dd December 10, 1999 +.Dt INET6_RTHDR_SPACE 3 +.Os +.\" +.Sh NAME +.Nm inet6_rthdr_space , +.Nm inet6_rthdr_init , +.Nm inet6_rthdr_add , +.Nm inet6_rthdr_lasthop , +.Nm inet6_rthdr_reverse , +.Nm inet6_rthdr_segments , +.Nm inet6_rthdr_getaddr , +.Nm inet6_rthdr_getflags +.Nd IPv6 Routing Header Options manipulation +.\" +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In netinet/in.h +.Ft size_t +.Fn inet6_rthdr_space "int type" "int segments" +.Ft "struct cmsghdr *" +.Fn inet6_rthdr_init "void *bp" "int type" +.Ft int +.Fn inet6_rthdr_add "struct cmsghdr *cmsg" "const struct in6_addr *addr" "unsigned int flags" +.Ft int +.Fn inet6_rthdr_lasthop "struct cmsghdr *cmsg" "unsigned int flags" +.Ft int +.Fn inet6_rthdr_reverse "const struct cmsghdr *in" "struct cmsghdr *out" +.Ft int +.Fn inet6_rthdr_segments "const struct cmsghdr *cmsg" +.Ft "struct in6_addr *" +.Fn inet6_rthdr_getaddr "struct cmsghdr *cmsg" "int index" +.Ft int +.Fn inet6_rthdr_getflags "const struct cmsghdr *cmsg" "int index" +.\" +.Sh DESCRIPTION +RFC2292 IPv6 advanced API defines eight +functions that the application calls to build and examine a Routing +header. Four functions build a Routing header: +.Bl -hang +.It Fn inet6_rthdr_space +return #bytes required for ancillary data +.It Fn inet6_rthdr_init +initialize ancillary data for Routing header +.It Fn inet6_rthdr_add +add IPv6 address & flags to Routing header +.It Fn inet6_rthdr_lasthop +specify the flags for the final hop +.El +.Pp +Four functions deal with a returned Routing header: +.Bl -hang +.It Fn inet6_rthdr_reverse +reverse a Routing header +.It Fn inet6_rthdr_segments +return #segments in a Routing header +.It Fn inet6_rthdr_getaddr +fetch one address from a Routing header +.It Fn inet6_rthdr_getflags +fetch one flag from a Routing header +.El +.Pp +The function prototypes for these functions are all in the +.Aq Li netinet/in.h +header. +.\" +.Ss inet6_rthdr_space +This function returns the number of bytes required to hold a Routing +header of the specified +.Fa type +containing the specified number of +.Fa segments +(addresses). +For an IPv6 Type 0 Routing header, the number +of segments must be between 1 and 23, inclusive. The return value +includes the size of the cmsghdr structure that precedes the Routing +header, and any required padding. +.Pp +If the return value is 0, then either the type of the Routing header +is not supported by this implementation or the number of segments is +invalid for this type of Routing header. +.Pp +Note: This function returns the size but does not allocate the space +required for the ancillary data. +This allows an application to +allocate a larger buffer, if other ancillary data objects are +desired, since all the ancillary data objects must be specified to +.Xr sendmsg 2 +as a single +.Li msg_control +buffer. +.\" +.Ss inet6_rthdr_init +This function initializes the buffer pointed to by +.Fa bp +to contain a +.Li cmsghdr +structure followed by a Routing header of the specified +.Fa type . +The +.Li cmsg_len +member of the +.Li cmsghdr +structure is initialized to the +size of the structure plus the amount of space required by the +Routing header. +The +.Li cmsg_level +and +.Li cmsg_type +members are also initialized as required. +.Pp +The caller must allocate the buffer and its size can be determined by +calling +.Fn inet6_rthdr_space . +.Pp +Upon success the return value is the pointer to the +.Li cmsghdr +structure, and this is then used as the first argument to the next +two functions. +Upon an error the return value is +.Dv NULL . +.\" +.Ss inet6_rthdr_add +This function adds the address pointed to by +.Fa addr +to the end of the +Routing header being constructed and sets the type of this hop to the +value of +.Fa flags . +For an IPv6 Type 0 Routing header, +.Fa flags +must be +either +.Dv IPV6_RTHDR_LOOSE +or +.Dv IPV6_RTHDR_STRICT . +.Pp +If successful, the +.Li cmsg_len +member of the +.Li cmsghdr +structure is +updated to account for the new address in the Routing header and the +return value of the function is 0. +Upon an error the return value of +the function is -1. +.\" +.Ss inet6_rthdr_lasthop +This function specifies the Strict/Loose flag for the final hop of a +Routing header. +For an IPv6 Type 0 Routing header, +.Fa flags +must be either +.Dv IPV6_RTHDR_LOOSE +or +.Dv IPV6_RTHDR_STRICT . +.Pp +The return value of the function is 0 upon success, or -1 upon an error. +.Pp +Notice that a Routing header specifying +.Li N +intermediate nodes requires +.Li N+1 +Strict/Loose flags. +This requires +.Li N +calls to +.Fn inet6_rthdr_add +followed by one call to +.Fn inet6_rthdr_lasthop . +.\" +.Ss inet6_rthdr_reverse +This function is not yet implemented. +When implemented, this should behave as follows. +.Pp +This function takes a Routing header that was received as ancillary +data +(pointed to by the first argument, +.Fa in ) +and writes a new Routing +header that sends datagrams along the reverse of that route. +Both +arguments are allowed to point to the same buffer +(that is, the reversal can occur in place). +.Pp +The return value of the function is 0 on success, or -1 upon an +error. +.\" +.Ss inet6_rthdr_segments +This function returns the number of segments +(addresses) +contained in +the Routing header described by +.Fa cmsg . +On success the return value is +between 1 and 23, inclusive. +The return value of the function is -1 upon an error. +.\" +.Ss inet6_rthdr_getaddr +This function returns a pointer to the IPv6 address specified by +.Fa index +(which must have a value between 1 and the value returned by +.Fn inet6_rthdr_segments ) +in the Routing header described by +.Fa cmsg . +An +application should first call +.Fn inet6_rthdr_segments +to obtain the number of segments in the Routing header. +.Pp +Upon an error the return value of the function is +.Dv NULL . +.\" +.Ss inet6_rthdr_getflags +This function returns the flags value specified by +.Fa index +(which must +have a value between 0 and the value returned by +.Fn inet6_rthdr_segments ) +in the Routing header described by +.Fa cmsg . +For an IPv6 Type 0 Routing header the return value will be either +.Dv IPV6_RTHDR_LOOSE +or +.Dv IPV6_RTHDR_STRICT . +.Pp +Upon an error the return value of the function is -1. +.Pp +Note: Addresses are indexed starting at 1, and flags starting at 0, +to maintain consistency with the terminology and figures in RFC2460. +.\" +.Sh DIAGNOSTICS +.Fn inet6_rthdr_space +returns 0 on errors. +.Pp +.Fn inet6_rthdr_add , +.Fn inet6_rthdr_lasthop +and +.Fn inet6_rthdr_reverse +return 0 on success, and returns -1 on error. +.Pp +.Fn inet6_rthdr_init +and +.Fn inet6_rthdr_getaddr +return +.Dv NULL +on error. +.Pp +.Fn inet6_rthdr_segments +and +.Fn inet6_rthdr_getflags +return -1 on error. +.\" +.Sh EXAMPLES +RFC2292 gives comprehensive examples in chapter 8. +.\" +.Sh SEE ALSO +.Rs +.%A W. Stevens +.%A M. Thomas +.%T "Advanced Sockets API for IPv6" +.%N RFC2292 +.%D February 1998 +.Re +.Rs +.%A S. Deering +.%A R. Hinden +.%T "Internet Protocol, Version 6 (IPv6) Specification" +.%N RFC2460 +.%D December 1998 +.Re +.\" +.Sh HISTORY +The implementation first appeared in KAME advanced networking kit. +.\" +.Sh STANDARDS +The functions +are documented in +.Dq Advanced Sockets API for IPv6 +(RFC2292). +.\" +.Sh BUGS +The text was shamelessly copied from RFC2292. +.Pp +.Fn inet6_rthdr_reverse +is not implemented yet. diff --git a/net.subproj/inet_addr.c b/net/inet_addr.c similarity index 73% rename from net.subproj/inet_addr.c rename to net/inet_addr.c index 646a95d..305bec1 100644 --- a/net.subproj/inet_addr.c +++ b/net/inet_addr.c @@ -57,6 +57,7 @@ #include #include #include +#include /* * Ascii internet address interpretation routine. @@ -85,86 +86,94 @@ inet_aton(cp, addr) register const char *cp; struct in_addr *addr; { - register u_long val; - register int base, n; - register char c; - u_int parts[4]; - register u_int *pp = parts; + u_long parts[4]; + u_int32_t val; + char *c; + char *endptr; + int gotend, n; - for (;;) { - /* - * Collect number up to ``.''. - * Values are specified as for C: - * 0x=hex, 0=octal, other=decimal. + c = (char *)cp; + n = 0; + /* + * Run through the string, grabbing numbers until + * the end of the string, or some error + */ + gotend = 0; + while (!gotend) { + errno = 0; + val = strtoul(c, &endptr, 0); + + if (errno == ERANGE) /* Fail completely if it overflowed. */ + return (0); + + /* + * If the whole string is invalid, endptr will equal + * c.. this way we can make sure someone hasn't + * gone '.12' or something which would get past + * the next check. */ - val = 0; base = 10; - if (*cp == '0') { - if (*++cp == 'x' || *cp == 'X') - base = 16, cp++; - else - base = 8; - } - while ((c = *cp) != '\0') { - if (isascii(c) && isdigit(c)) { - val = (val * base) + (c - '0'); - cp++; - continue; - } - if (base == 16 && isascii(c) && isxdigit(c)) { - val = (val << 4) + - (c + 10 - (islower(c) ? 'a' : 'A')); - cp++; - continue; - } - break; - } - if (*cp == '.') { - /* - * Internet format: - * a.b.c.d - * a.b.c (with c treated as 16-bits) - * a.b (with b treated as 24 bits) - */ - if (pp >= parts + 3 || val > 0xff) + if (endptr == c) + return (0); + parts[n] = val; + c = endptr; + + /* Check the next character past the previous number's end */ + switch (*c) { + case '.' : + /* Make sure we only do 3 dots .. */ + if (n == 3) /* Whoops. Quit. */ return (0); - *pp++ = val, cp++; - } else + n++; + c++; + break; + + case '\0': + gotend = 1; break; + + default: + if (isspace((unsigned char)*c)) { + gotend = 1; + break; + } else + return (0); /* Invalid character, so fail */ + } + } - /* - * Check for trailing characters. - */ - if (*cp && (!isascii(*cp) || !isspace(*cp))) - return (0); + /* * Concoct the address according to * the number of parts specified. */ - n = pp - parts + 1; - switch (n) { - case 1: /* a -- 32 bits */ + switch (n) { + case 0: /* a -- 32 bits */ + /* + * Nothing is necessary here. Overflow checking was + * already done in strtoul(). + */ break; - - case 2: /* a.b -- 8.24 bits */ - if (val > 0xffffff) + case 1: /* a.b -- 8.24 bits */ + if (val > 0xffffff || parts[0] > 0xff) return (0); val |= parts[0] << 24; break; - case 3: /* a.b.c -- 8.8.16 bits */ - if (val > 0xffff) + case 2: /* a.b.c -- 8.8.16 bits */ + if (val > 0xffff || parts[0] > 0xff || parts[1] > 0xff) return (0); val |= (parts[0] << 24) | (parts[1] << 16); break; - case 4: /* a.b.c.d -- 8.8.8.8 bits */ - if (val > 0xff) + case 3: /* a.b.c.d -- 8.8.8.8 bits */ + if (val > 0xff || parts[0] > 0xff || parts[1] > 0xff || + parts[2] > 0xff) return (0); val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8); break; } - if (addr) + + if (addr != NULL) addr->s_addr = htonl(val); return (1); } diff --git a/net.subproj/inet_lnaof.c b/net/inet_lnaof.c similarity index 100% rename from net.subproj/inet_lnaof.c rename to net/inet_lnaof.c diff --git a/net.subproj/inet_makeaddr.c b/net/inet_makeaddr.c similarity index 100% rename from net.subproj/inet_makeaddr.c rename to net/inet_makeaddr.c diff --git a/net/inet_net.3 b/net/inet_net.3 new file mode 100644 index 0000000..1d43bcc --- /dev/null +++ b/net/inet_net.3 @@ -0,0 +1,157 @@ +.\" $NetBSD: inet_net.3,v 1.4 1999/03/22 19:44:52 garbled Exp $ +.\" +.\" Copyright (c) 1997 The NetBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to The NetBSD Foundation +.\" by Luke Mewburn. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the NetBSD +.\" Foundation, Inc. and its contributors. +.\" 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +.\" +.\" $FreeBSD: src/lib/libc/net/inet_net.3,v 1.1 2001/08/31 10:54:44 ru Exp $ +.\" +.Dd June 18, 1997 +.Dt INET_NET 3 +.Os +.Sh NAME +.Nm inet_net_ntop , +.Nm inet_net_pton +.Nd Internet network number manipulation routines +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In sys/socket.h +.In netinet/in.h +.In arpa/inet.h +.Ft char * +.Fn inet_net_ntop "int af" "const void *src" "int bits" "char *dst" "size_t size" +.Ft int +.Fn inet_net_pton "int af" "const char *src" "void *dst" "size_t size" +.Sh DESCRIPTION +The +.Fn inet_net_ntop +function converts an Internet network number from network format (usually a +.Vt "struct in_addr" +or some other binary form, in network byte order) to CIDR presentation format +(suitable for external display purposes). +.Fa bits +is the number of bits in +.Fa src +that are the network number. +It returns +.Dv NULL +if a system error occurs (in which case, +.Va errno +will have been set), or it returns a pointer to the destination string. +.Pp +The +.Fn inet_net_pton +function converts a presentation format Internet network number (that is, +printable form as held in a character string) to network format (usually a +.Vt "struct in_addr" +or some other internal binary representation, in network byte order). +It returns the number of bits (either computed based on the class, or +specified with /CIDR), or \-1 if a failure occurred +(in which case +.Va errno +will have been set. +It will be set to +.Er ENOENT +if the Internet network number was not valid). +.Pp +The only value for +.Fa af +currently supported is +.Dv AF_INET . +.Fa size +is the size of the result buffer +.Fa dst . +.Pp +.Sh NETWORK NUMBERS (IP VERSION 4) +Internet network numbers may be specified in one of the following forms: +.Bd -literal -offset indent +a.b.c.d/bits +a.b.c.d +a.b.c +a.b +a +.Ed +.Pp +When four parts are specified, each is interpreted +as a byte of data and assigned, from left to right, +to the four bytes of an Internet network number. +Note +that when an Internet network number is viewed as a 32-bit +integer quantity on a system that uses little-endian +byte order (such as the +.Tn Intel 386 , 486 , +and +.Tn Pentium +processors) the bytes referred to above appear as +.Dq Li d.c.b.a . +That is, little-endian bytes are ordered from right to left. +.Pp +When a three part number is specified, the last +part is interpreted as a 16-bit quantity and placed +in the rightmost two bytes of the Internet network number. +This makes the three part number format convenient +for specifying Class B network numbers as +.Dq Li 128.net.host . +.Pp +When a two part number is supplied, the last part +is interpreted as a 24-bit quantity and placed in +the rightmost three bytes of the Internet network number. +This makes the two part number format convenient +for specifying Class A network numbers as +.Dq Li net.host . +.Pp +When only one part is given, the value is stored +directly in the Internet network number without any byte +rearrangement. +.Pp +All numbers supplied as +.Dq parts +in a +.Ql \&. +notation +may be decimal, octal, or hexadecimal, as specified +in the C language (i.e., a leading 0x or 0X implies +hexadecimal; otherwise, a leading 0 implies octal; +otherwise, the number is interpreted as decimal). +.Sh SEE ALSO +.Xr byteorder 3 , +.Xr inet 3 , +.Xr networks 5 +.Sh HISTORY +The +.Fn inet_net_ntop +and +.Fn inet_net_pton +functions appeared in BIND 4.9.4. diff --git a/net.subproj/inet_netof.c b/net/inet_netof.c similarity index 100% rename from net.subproj/inet_netof.c rename to net/inet_netof.c diff --git a/net.subproj/inet_network.c b/net/inet_network.c similarity index 100% rename from net.subproj/inet_network.c rename to net/inet_network.c diff --git a/net.subproj/inet_ntoa.c b/net/inet_ntoa.c similarity index 100% rename from net.subproj/inet_ntoa.c rename to net/inet_ntoa.c diff --git a/net/linkaddr.3 b/net/linkaddr.3 new file mode 100644 index 0000000..1d66463 --- /dev/null +++ b/net/linkaddr.3 @@ -0,0 +1,140 @@ +.\" Copyright (c) 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Donn Seeley at BSDI. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" From: @(#)linkaddr.3 8.1 (Berkeley) 7/28/93 +.\" $FreeBSD: src/lib/libc/net/linkaddr.3,v 1.12 2001/10/01 16:08:56 ru Exp $ +.\" +.Dd June 17, 1996 +.Dt LINK_ADDR 3 +.Os +.Sh NAME +.Nm link_addr , +.Nm link_ntoa +.Nd elementary address specification routines for link level access +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In sys/socket.h +.In net/if_dl.h +.Ft void +.Fn link_addr "const char *addr" "struct sockaddr_dl *sdl" +.Ft char * +.Fn link_ntoa "const struct sockaddr_dl *sdl" +.Sh DESCRIPTION +The routine +.Fn link_addr +interprets character strings representing +link-level addresses, returning binary information suitable +for use in system calls. +The routine +.Fn link_ntoa +takes +a link-level +address and returns an +.Tn ASCII +string representing some of the information present, +including the link level address itself, and the interface name +or number, if present. +This facility is experimental and is +still subject to change. +.Pp +For +.Fn link_addr , +the string +.Fa addr +may contain +an optional network interface identifier of the form +.Dq "name unit-number" , +suitable for the first argument to +.Xr ifconfig 8 , +followed in all cases by a colon and +an interface address in the form of +groups of hexadecimal digits +separated by periods. +Each group represents a byte of address; +address bytes are filled left to right from +low order bytes through high order bytes. +.Pp +.\" A regular expression may make this format clearer: +.\" .Bd -literal -offset indent +.\" ([a-z]+[0-9]+:)?[0-9a-f]+(\e.[0-9a-f]+)* +.\" .Ed +.\" .Pp +Thus +.Li le0:8.0.9.13.d.30 +represents an ethernet address +to be transmitted on the first Lance ethernet interface. +.Pp +The direct use of these functions is deprecated in favor of the +.Xr addr2ascii 3 +interface; however, portable programs cannot rely on the latter as it is +not yet widely implemented. +.Sh RETURN VALUES +.Fn link_ntoa +always returns a null terminated string. +.Fn link_addr +has no return value. +(See +.Sx BUGS . ) +.Sh SEE ALSO +.Xr addr2ascii 3 +.\" .Xr iso 4 +.Sh HISTORY +The +.Fn link_addr +and +.Fn link_ntoa +functions appeared in +.Bx 4.3 Reno . +.Sh BUGS +The returned values for link_ntoa +reside in a static memory area. +.Pp +The function +.Fn link_addr +should diagnose improperly formed input, and there should be an unambiguous +way to recognize this. +.Pp +If the +.Va sdl_len +field of the link socket address +.Fa sdl +is 0, +.Fn link_ntoa +will not insert a colon before the interface address bytes. +If this translated address is given to +.Fn link_addr +without inserting an initial colon, +the latter will not interpret it correctly. diff --git a/net.subproj/linkaddr.c b/net/linkaddr.c similarity index 100% rename from net.subproj/linkaddr.c rename to net/linkaddr.c diff --git a/net/ns.3 b/net/ns.3 new file mode 100644 index 0000000..be8d155 --- /dev/null +++ b/net/ns.3 @@ -0,0 +1,133 @@ +.\" Copyright (c) 1986, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)ns.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/net/ns.3,v 1.10 2001/10/01 16:08:56 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt NS 3 +.Os +.Sh NAME +.Nm ns_addr , +.Nm ns_ntoa +.Nd Xerox +.Tn NS Ns (tm) +address conversion routines +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In netns/ns.h +.Ft struct ns_addr +.Fn ns_addr "char *cp" +.Ft char * +.Fn ns_ntoa "struct ns_addr ns" +.Sh DESCRIPTION +The routine +.Fn ns_addr +interprets character strings representing +.Tn XNS +addresses, returning binary information suitable +for use in system calls. +The routine +.Fn ns_ntoa +takes +.Tn XNS +addresses and returns +.Tn ASCII +strings representing the address in a +notation in common use in the Xerox Development Environment: +.Bd -ragged -offset indent +.. +.Ed +.Pp +Trailing zero fields are suppressed, and each number is printed in hexadecimal, +in a format suitable for input to +.Fn ns_addr . +Any fields lacking super-decimal digits will have a +trailing +.Ql H +appended. +.Pp +Unfortunately, no universal standard exists for representing +.Tn XNS +addresses. +An effort has been made to insure that +.Fn ns_addr +be compatible with most formats in common use. +It will first separate an address into 1 to 3 fields using a single delimiter +chosen from +period +.Ql \&. , +colon +.Ql \&: +or pound-sign +.Ql \&# . +Each field is then examined for byte separators (colon or period). +If there are byte separators, each subfield separated is taken to be +a small hexadecimal number, and the entirety is taken as a network-byte-ordered +quantity to be zero extended in the high-network-order bytes. +Next, the field is inspected for hyphens, in which case +the field is assumed to be a number in decimal notation +with hyphens separating the millenia. +Next, the field is assumed to be a number: +It is interpreted +as hexadecimal if there is a leading +.Ql 0x +(as in C), +a trailing +.Ql H +(as in Mesa), or there are any super-decimal digits present. +It is interpreted as octal is there is a leading +.Ql 0 +and there are no super-octal digits. +Otherwise, it is converted as a decimal number. +.Sh RETURN VALUES +None. (See +.Sx BUGS . ) +.Sh SEE ALSO +.Xr hosts 5 , +.Xr networks 5 +.Sh HISTORY +The +.Fn ns_addr +and +.Fn ns_toa +functions appeared in +.Bx 4.3 . +.Sh BUGS +The string returned by +.Fn ns_ntoa +resides in a static memory area. +The function +.Fn ns_addr +should diagnose improperly formed input, and there should be an unambiguous +way to recognize this. diff --git a/net.subproj/nsap_addr.c b/net/nsap_addr.c similarity index 91% rename from net.subproj/nsap_addr.c rename to net/nsap_addr.c index 2c5ebaa..fd3cc99 100644 --- a/net.subproj/nsap_addr.c +++ b/net/nsap_addr.c @@ -20,7 +20,7 @@ * @APPLE_LICENSE_HEADER_END@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$Id: nsap_addr.c,v 1.3 2000/06/09 04:01:52 wsanchez Exp $"; +static char rcsid[] = "$Id: nsap_addr.c,v 1.4 2002/05/17 21:00:31 bbraun Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -29,6 +29,7 @@ static char rcsid[] = "$Id: nsap_addr.c,v 1.3 2000/06/09 04:01:52 wsanchez Exp $ #include #include #include +#include #if !defined(isxdigit) /* XXX - could be a function */ static int @@ -89,9 +90,15 @@ inet_nsap_ntoa(binlen, binary, ascii) { register int nib; int i; - static char tmpbuf[255*3]; + static char *tmpbuf = NULL; char *start; + if( tmpbuf == NULL ) { + tmpbuf = malloc(255*3); + if( tmpbuf == NULL ) + return NULL; + } + if (ascii) start = ascii; else { diff --git a/net/nsdispatch.3 b/net/nsdispatch.3 new file mode 100644 index 0000000..708f97c --- /dev/null +++ b/net/nsdispatch.3 @@ -0,0 +1,231 @@ +.\" $NetBSD: nsdispatch.3,v 1.8 1999/03/22 19:44:53 garbled Exp $ +.\" $FreeBSD: src/lib/libc/net/nsdispatch.3,v 1.5 2001/10/01 16:08:56 ru Exp $ +.\" +.\" Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to The NetBSD Foundation +.\" by Luke Mewburn. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the NetBSD +.\" Foundation, Inc. and its contributors. +.\" 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +.\" +.Dd January 19, 1999 +.Dt NSDISPATCH 3 +.Os +.Sh NAME +.Nm nsdispatch +.Nd name-service switch dispatcher routine +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In nsswitch.h +.Ft int +.Fo nsdispatch +.Fa "void *retval" +.Fa "const ns_dtab dtab[]" +.Fa "const char *database" +.Fa "const char *method" +.Fa "const ns_src defaults[]" +.Fa "..." +.Fc +.Sh DESCRIPTION +The +.Fn nsdispatch +function invokes the callback functions specified in +.Va dtab +in the order given in +.Pa /etc/nsswitch.conf +for the database +.Va database +until a successful entry is found. +.Pp +.Va retval +is passed to each callback function to modify as necessary +(to pass back to the caller of +.Fn nsdispatch ) +.Pp +.Va dtab +is an array of +.Va ns_dtab +structures, which have the following format: +.Bd -literal -offset indent +typedef struct { + const char *src; + int (*cb)(void *retval, void *cb_data, va_list ap); + void *cb_data; +} ns_dtab; +.Ed +.Pp +.Bd -ragged -offset indent +For each source type that is implemented, an entry with +.Va src +set to the name of the source, +.Va cb +defined as a function which handles that source, and +.Va cb_data +is used to pass arbritrary data to the callback function. +The last entry in +.Va dtab +should contain +.Dv NULL +values for +.Va src , +.Va cb , +and +.Va cb_data . +.Ed +.Pp +.Va method +is usually the name of the function calling +.Fn nsdispatch . +When dynamic loading is supported, a symbol constructed from +.Va database , +the current source, and +.Va method +will be used as the name to invoke the dynamically loaded function. +.Pp +.Va defaults +contains a list of default sources to try in the case of +a missing or corrupt +.Xr nsswitch.conf 5 , +or if there isn't a relevant entry for +.Va database . +It is an array of +.Va ns_src +structures, which have the following format: +.Bd -literal -offset indent +typedef struct { + const char *src; + u_int32_t flags; +} ns_src; +.Ed +.Pp +.Bd -ragged -offset indent +For each default source type, an entry with +.Va src +set to the name of the source, and +.Va flags +set to the relevant flags +(usually +.Dv NS_SUCCESS ; +refer to +.Sx Callback return values +for more information). +The last entry in +.Va defaults +should have +.Va src +set to +.Dv NULL +and +.Va flags +set to 0. +.Pp +For convenience, a global variable defined as: +.Dl extern const ns_src __nsdefaultsrc[]; +exists which contains a single default entry for +.Sq files +for use by callers which don't require complicated default rules. +.Ed +.Pp +.Sq Va ... +are optional extra arguments, which +are passed to the appropriate callback function as a variable argument +list of the type +.Va va_list . +.Ss Valid source types +Whilst there is support for arbitrary sources, the following +#defines for commonly implementated sources are available: +.Bl -column NS_COMPAT COMPAT -offset indent +.It Sy "#define value" +.It "NSSRC_FILES ""files""" +.It "NSSRC_DNS ""dns""" +.It "NSSRC_NIS ""nis""" +.It "NSSRC_COMPAT ""compat""" +.El +.Pp +Refer to +.Xr nsswitch.conf 5 +for a complete description of what each source type is. +.Pp +.Ss Callback return values +The callback functions should return one of the following values +depending upon status of the lookup: +.Bl -column NS_NOTFOUND -offset indent +.It Sy "Return value Status code" +.It "NS_SUCCESS success" +.It "NS_NOTFOUND notfound" +.It "NS_UNAVAIL unavail" +.It "NS_TRYAGAIN tryagain" +.El +.Pp +Refer to +.Xr nsswitch.conf 5 +for a complete description of what each status code is. +.Pp +.Nm +returns the value of the callback that caused the dispatcher to finish, +or NS_NOTFOUND otherwise. +.Sh SEE ALSO +.Xr hesiod 3 , +.Xr stdarg 3 , +.Xr ypclnt 3 , +.Xr nsswitch.conf 5 +.Sh HISTORY +The +.Nm +routines first appeared in +.Fx 4.1 . +They were imported from the +.Nx +Project, +where they appeared first in +.Nx 1.4 . +.Sh AUTHORS +Luke Mewburn +.Aq lukem@netbsd.org +wrote this freely distributable name-service switch implementation, +using ideas from the +.Tn ULTRIX +.Xr svc.conf 5 +and +.Tn Solaris +.Xr nsswitch.conf 4 +manual pages. +.Sh BUGS +The +.Nm +routines are not thread safe. +This will be rectified in the future. +.Pp +Currently there is no support for dynamically loadable dispatcher callback +functions. +It is anticipated that this will be added in the future in the back-end +without requiring changes to code that invokes +.Fn nsdispatch . diff --git a/net/rcmd.3 b/net/rcmd.3 new file mode 100644 index 0000000..9479a23 --- /dev/null +++ b/net/rcmd.3 @@ -0,0 +1,298 @@ +.\" Copyright (c) 1983, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" From: @(#)rcmd.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/net/rcmd.3,v 1.20 2001/10/01 16:08:56 ru Exp $ +.\" +.Dd March 3, 2000 +.Dt RCMD 3 +.Os +.Sh NAME +.Nm rcmd , +.Nm rresvport , +.Nm iruserok , +.Nm ruserok , +.Nm rcmd_af , +.Nm rresvport_af , +.Nm iruserok_sa +.Nd routines for returning a stream to a remote command +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft int +.Fn rcmd "char **ahost" "int inport" "const char *locuser" "const char *remuser" "const char *cmd" "int *fd2p" +.Ft int +.Fn rresvport "int *port" +.Ft int +.Fn iruserok "u_long raddr" "int superuser" "const char *ruser" "const char *luser" +.Ft int +.Fn ruserok "const char *rhost" "int superuser" "const char *ruser" "const char *luser" +.Ft int +.Fn rcmd_af "char **ahost" "int inport" "const char *locuser" "const char *remuser" "const char *cmd" "int *fd2p" "int af" +.Ft int +.Fn rresvport_af "int *port" "int af" +.Ft int +.Fn iruserok_sa "const void *addr" "int addrlen" "int superuser" "const char *ruser" "const char *luser" +.Sh DESCRIPTION +The +.Fn rcmd +function +is used by the super-user to execute a command on +a remote machine using an authentication scheme based +on reserved port numbers. +The +.Fn rresvport +function +returns a descriptor to a socket +with an address in the privileged port space. +The +.Fn ruserok +function +is used by servers +to authenticate clients requesting service with +.Fn rcmd . +All three functions are present in the same file and are used +by the +.Xr rshd 8 +server (among others). +.Pp +The +.Fn rcmd +function +looks up the host +.Fa *ahost +using +.Xr gethostbyname 3 , +returning -1 if the host does not exist. +Otherwise +.Fa *ahost +is set to the standard name of the host +and a connection is established to a server +residing at the well-known Internet port +.Fa inport . +.Pp +If the connection succeeds, +a socket in the Internet domain of type +.Dv SOCK_STREAM +is returned to the caller, and given to the remote +command as +.Em stdin +and +.Em stdout . +If +.Fa fd2p +is non-zero, then an auxiliary channel to a control +process will be set up, and a descriptor for it will be placed +in +.Fa *fd2p . +The control process will return diagnostic +output from the command (unit 2) on this channel, and will also +accept bytes on this channel as being +.Tn UNIX +signal numbers, to be +forwarded to the process group of the command. +If +.Fa fd2p +is 0, then the +.Em stderr +(unit 2 of the remote +command) will be made the same as the +.Em stdout +and no +provision is made for sending arbitrary signals to the remote process, +although you may be able to get its attention by using out-of-band data. +.Pp +The protocol is described in detail in +.Xr rshd 8 . +.Pp +The +.Fn rresvport +function is used to obtain a socket to which an address with a Privileged +Internet port is bound. +This socket is suitable for use by +.Fn rcmd +and several other functions. +Privileged Internet ports are those in the range 0 to 1023. +Only the super-user is allowed to bind an address of this sort +to a socket. +.Pp +The +.Fn iruserok +and +.Fn ruserok +functions take a remote host's IP address or name, as returned by the +.Xr gethostbyname 3 +routines, two user names and a flag indicating whether the local user's +name is that of the super-user. +Then, if the user is +.Em NOT +the super-user, it checks the +.Pa /etc/hosts.equiv +file. +If that lookup is not done, or is unsuccessful, the +.Pa .rhosts +in the local user's home directory is checked to see if the request for +service is allowed. +.Pp +If this file does not exist, is not a regular file, is owned by anyone +other than the user or the super-user, or is writable by anyone other +than the owner, the check automatically fails. +Zero is returned if the machine name is listed in the +.Dq Pa hosts.equiv +file, or the host and remote user name are found in the +.Dq Pa .rhosts +file; otherwise +.Fn iruserok +and +.Fn ruserok +return -1. +If the local domain (as obtained from +.Xr gethostname 3 ) +is the same as the remote domain, only the machine name need be specified. +.Pp +The +.Fn iruserok +function is strongly preferred for security reasons. +It requires trusting the local DNS at most, while the +.Fn ruserok +function requires trusting the entire DNS, which can be spoofed. +.Pp +The functions with an +.Dq Li _af +or +.Dq Li _sa +suffix, i.e., +.Fn rcmd_af , +.Fn rresvport_af +and +.Fn iruserok_sa , +work the same as the corresponding functions without a +suffix, except that they are capable of handling both IPv6 and IPv4 ports. +.Pp +The +.Dq Li _af +suffix means that the function has an additional +.Fa af +argument which is used to specify the address family, +(see below). +The +.Fa af +argument extension is implemented for functions +that have no binary address argument. +Instead, the +.Fa af +argument specifies which address family is desired. +.Pp +The +.Dq Li _sa +suffix means that the function has general socket address and +length arguments. +As the socket address is a protocol independent data structure, +IPv4 and IPv6 socket address can be passed as desired. +The +.Fa sa +argument extension is implemented for functions +that pass a protocol dependent binary address argument. +The argument needs to be replaced with a more general address structure +to support multiple address families in a general way. +.Pp +The functions with neither an +.Dq Li _af +suffix nor an +.Dq Li _sa +suffix work for IPv4 only, except for +.Fn ruserok +which can handle both IPv6 and IPv4. +To switch the address family, the +.Fa af +argument must be filled with +.Dv AF_INET , +or +.Dv AF_INET6 . +For +.Fn rcmd_af , +.Dv PF_UNSPEC +is also allowed. +.Sh DIAGNOSTICS +The +.Fn rcmd +function +returns a valid socket descriptor on success. +It returns -1 on error and prints a diagnostic message +on the standard error. +.Pp +The +.Fn rresvport +function +returns a valid, bound socket descriptor on success. +It returns -1 on error with the global value +.Va errno +set according to the reason for failure. +The error code +.Er EAGAIN +is overloaded to mean ``All network ports in use.'' +.Sh SEE ALSO +.Xr rlogin 1 , +.Xr rsh 1 , +.Xr intro 2 , +.Xr rexec 3 , +.Xr rexecd 8 , +.Xr rlogind 8 , +.Xr rshd 8 +.Pp +.Rs +.%A W. Stevens +.%A M. Thomas +.%T "Advanced Socket API for IPv6" +.%O RFC2292 +.Re +.Rs +.%A W. Stevens +.%A M. Thomas +.%A E. Nordmark +.%T "Advanced Socket API for IPv6" +.%O draft-ietf-ipngwg-rfc2292bis-01.txt +.Re +.Sh HISTORY +Most of these +functions appeared in +.Bx 4.2 . +.Fn rresvport_af +appeared in RFC2292, and was implemented by the WIDE project +for the Hydrangea IPv6 protocol stack kit. +.Fn rcmd_af +appeared in draft-ietf-ipngwg-rfc2292bis-01.txt, +and was implemented in the WIDE/KAME IPv6 protocol stack kit. +.Fn iruserok_sa +appeared in discussion on the IETF ipngwg mailing list, +and was implemented in +.Fx 4.0 . diff --git a/net/rcmdsh.3 b/net/rcmdsh.3 new file mode 100644 index 0000000..43e6a8d --- /dev/null +++ b/net/rcmdsh.3 @@ -0,0 +1,116 @@ +.\" $OpenBSD: rcmdsh.3,v 1.6 1999/07/05 04:41:00 aaron Exp $ +.\" +.\" Copyright (c) 1983, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" $FreeBSD: src/lib/libc/net/rcmdsh.3,v 1.2 2001/11/09 15:19:25 ru Exp $ +.\" +.Dd September 1, 1996 +.Dt RCMDSH 3 +.Os +.Sh NAME +.Nm rcmdsh +.Nd return a stream to a remote command without superuser +.Sh SYNOPSIS +.In unistd.h +.Ft int +.Fo rcmdsh +.Fa "char **ahost" +.Fa "int inport" +.Fa "const char *locuser" +.Fa "const char *remuser" +.Fa "const char *cmd" +.Fa "const char *rshprog" +.Fc +.Sh DESCRIPTION +The +.Fn rcmdsh +function +is used by normal users to execute a command on +a remote machine using an authentication scheme based +on reserved port numbers using +.Xr rshd 8 +or the value of +.Fa rshprog +(if +.No non- Ns Dv NULL ) . +.Pp +The +.Fn rcmdsh +function +looks up the host +.Fa *ahost +using +.Xr gethostbyname 3 , +returning \-1 if the host does not exist. +Otherwise +.Fa *ahost +is set to the standard name of the host +and a connection is established to a server +residing at the well-known Internet port +.Dq Li shell/tcp +(or whatever port is used by +.Fa rshprog ) . +The parameter +.Fa inport +is ignored; it is only included to provide an interface similar to +.Xr rcmd 3 . +.Pp +If the connection succeeds, +a socket in the +.Ux +domain of type +.Dv SOCK_STREAM +is returned to the caller, and given to the remote +command as stdin, stdout, and stderr. +.Sh RETURN VALUES +The +.Fn rcmdsh +function +returns a valid socket descriptor on success. +Otherwise, \-1 is returned +and a diagnostic message is printed on the standard error. +.Sh SEE ALSO +.Xr rsh 1 , +.Xr socketpair 2 , +.Xr rcmd 3 , +.Xr rshd 8 +.Sh BUGS +If +.Xr rsh 1 +encounters an error, a file descriptor is still returned instead of \-1. +.Sh HISTORY +The +.Fn rcmdsh +function first appeared in +.Ox 2.0 , +and made its way into +.Fx 5.0 . diff --git a/net.subproj/recv.c b/net/recv.c similarity index 100% rename from net.subproj/recv.c rename to net/recv.c diff --git a/net/resolver.3 b/net/resolver.3 new file mode 100644 index 0000000..1417598 --- /dev/null +++ b/net/resolver.3 @@ -0,0 +1,422 @@ +.\" Copyright (c) 1985, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)resolver.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/net/resolver.3,v 1.21 2001/10/01 16:08:56 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt RESOLVER 3 +.Os +.Sh NAME +.Nm res_query , +.Nm res_search , +.Nm res_mkquery , +.Nm res_send , +.Nm res_init , +.Nm dn_comp , +.Nm dn_expand , +.Nm dn_skipname , +.Nm ns_get16 , +.Nm ns_get32 , +.Nm ns_put16 , +.Nm ns_put32 +.Nd resolver routines +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In netinet/in.h +.In arpa/nameser.h +.In resolv.h +.Ft int +.Fo res_query +.Fa "const char *dname" +.Fa "int class" +.Fa "int type" +.Fa "u_char *answer" +.Fa "int anslen" +.Fc +.Ft int +.Fo res_search +.Fa "const char *dname" +.Fa "int class" +.Fa "int type" +.Fa "u_char *answer" +.Fa "int anslen" +.Fc +.Ft int +.Fo res_mkquery +.Fa "int op" +.Fa "const char *dname" +.Fa "int class" +.Fa "int type" +.Fa "const u_char *data" +.Fa "int datalen" +.Fa "const u_char *newrr_in" +.Fa "u_char *buf" +.Fa "int buflen" +.Fc +.Ft int +.Fo res_send +.Fa "const u_char *msg" +.Fa "int msglen" +.Fa "u_char *answer" +.Fa "int anslen" +.Fc +.Ft int +.Fn res_init +.Ft int +.Fo dn_comp +.Fa "const char *exp_dn" +.Fa "u_char *comp_dn" +.Fa "int length" +.Fa "u_char **dnptrs" +.Fa "u_char **lastdnptr" +.Fc +.Ft int +.Fo dn_expand +.Fa "const u_char *msg" +.Fa "const u_char *eomorig" +.Fa "const u_char *comp_dn" +.Fa "char *exp_dn" +.Fa "int length" +.Fc +.Ft int +.Fn dn_skipname "const u_char *comp_dn" "const u_char *eom" +.Ft u_int +.Fn ns_get16 "const u_char *src" +.Ft u_long +.Fn ns_get32 "const u_char *src" +.Ft void +.Fn ns_put16 "u_int src" "u_char *dst" +.Ft void +.Fn ns_put32 "u_long src" "u_char *dst" +.Sh DESCRIPTION +These routines are used for making, sending and interpreting +query and reply messages with Internet domain name servers. +.Pp +Global configuration and state information that is used by the +resolver routines is kept in the structure +.Em _res . +Most of the values have reasonable defaults and can be ignored. +Options +stored in +.Em _res.options +are defined in +.Pa resolv.h +and are as follows. +Options are stored as a simple bit mask containing the bitwise ``or'' +of the options enabled. +.Bl -tag -width RES_USE_INET6 +.It Dv RES_INIT +True if the initial name server address and default domain name are +initialized (i.e., +.Fn res_init +has been called). +.It Dv RES_DEBUG +Print debugging messages. +.It Dv RES_AAONLY +Accept authoritative answers only. +With this option, +.Fn res_send +should continue until it finds an authoritative answer or finds an error. +Currently this is not implemented. +.It Dv RES_USEVC +Use +.Tn TCP +connections for queries instead of +.Tn UDP +datagrams. +.It Dv RES_STAYOPEN +Used with +.Dv RES_USEVC +to keep the +.Tn TCP +connection open between +queries. +This is useful only in programs that regularly do many queries. +.Tn UDP +should be the normal mode used. +.It Dv RES_IGNTC +Unused currently (ignore truncation errors, i.e., don't retry with +.Tn TCP ) . +.It Dv RES_RECURSE +Set the recursion-desired bit in queries. +This is the default. +.Pf ( Fn res_send +does not do iterative queries and expects the name server +to handle recursion.) +.It Dv RES_DEFNAMES +If set, +.Fn res_search +will append the default domain name to single-component names +(those that do not contain a dot). +This option is enabled by default. +.It Dv RES_DNSRCH +If this option is set, +.Fn res_search +will search for host names in the current domain and in parent domains; see +.Xr hostname 7 . +This is used by the standard host lookup routine +.Xr gethostbyname 3 . +This option is enabled by default. +.It Dv RES_NOALIASES +This option turns off the user level aliasing feature controlled by the +.Dq Ev HOSTALIASES +environment variable. Network daemons should set this option. +.It Dv RES_USE_INET6 +Enables support for IPv6-only applications. +This causes IPv4 addresses to be returned as an IPv4 mapped address. +For example, +.Li 10.1.1.1 +will be returned as +.Li ::ffff:10.1.1.1 . +The option is meaningful with certain kernel configuration only. +.It Dv RES_USE_EDNS0 +Enables support for OPT pseudo-RR for EDNS0 extension. +With the option, resolver code will attach OPT pseudo-RR into DNS queries, +to inform of our receive buffer size. +The option will allow DNS servers to take advantage of non-default receive +buffer size, and to send larger replies. +DNS query packets with EDNS0 extension is not compatible with +non-EDNS0 DNS servers. +.El +.Pp +The +.Fn res_init +routine +reads the configuration file (if any; see +.Xr resolver 5 ) +to get the default domain name, +search list and +the Internet address of the local name server(s). +If no server is configured, the host running +the resolver is tried. +The current domain name is defined by the hostname +if not specified in the configuration file; +it can be overridden by the environment variable +.Ev LOCALDOMAIN . +This environment variable may contain several blank-separated +tokens if you wish to override the +.Em "search list" +on a per-process basis. This is similar to the +.Em search +command in the configuration file. +Another environment variable +.Dq Ev RES_OPTIONS +can be set to +override certain internal resolver options which are otherwise +set by changing fields in the +.Em _res +structure or are inherited from the configuration file's +.Em options +command. The syntax of the +.Dq Ev RES_OPTIONS +environment variable is explained in +.Xr resolver 5 . +Initialization normally occurs on the first call +to one of the following routines. +.Pp +The +.Fn res_query +function provides an interface to the server query mechanism. +It constructs a query, sends it to the local server, +awaits a response, and makes preliminary checks on the reply. +The query requests information of the specified +.Fa type +and +.Fa class +for the specified fully-qualified domain name +.Fa dname . +The reply message is left in the +.Fa answer +buffer with length +.Fa anslen +supplied by the caller. +.Pp +The +.Fn res_search +routine makes a query and awaits a response like +.Fn res_query , +but in addition, it implements the default and search rules +controlled by the +.Dv RES_DEFNAMES +and +.Dv RES_DNSRCH +options. +It returns the first successful reply. +.Pp +The remaining routines are lower-level routines used by +.Fn res_query . +The +.Fn res_mkquery +function +constructs a standard query message and places it in +.Fa buf . +It returns the size of the query, or \-1 if the query is +larger than +.Fa buflen . +The query type +.Fa op +is usually +.Dv QUERY , +but can be any of the query types defined in +.Aq Pa arpa/nameser.h . +The domain name for the query is given by +.Fa dname . +.Fa Newrr +is currently unused but is intended for making update messages. +.Pp +The +.Fn res_send +routine +sends a pre-formatted query and returns an answer. +It will call +.Fn res_init +if +.Dv RES_INIT +is not set, send the query to the local name server, and +handle timeouts and retries. +The length of the reply message is returned, or +\-1 if there were errors. +.Pp +The +.Fn dn_comp +function +compresses the domain name +.Fa exp_dn +and stores it in +.Fa comp_dn . +The size of the compressed name is returned or \-1 if there were errors. +The size of the array pointed to by +.Fa comp_dn +is given by +.Fa length . +The compression uses +an array of pointers +.Fa dnptrs +to previously-compressed names in the current message. +The first pointer points to +the beginning of the message and the list ends with +.Dv NULL . +The limit to the array is specified by +.Fa lastdnptr . +A side effect of +.Fn dn_comp +is to update the list of pointers for +labels inserted into the message +as the name is compressed. +If +.Em dnptr +is +.Dv NULL , +names are not compressed. +If +.Fa lastdnptr +is +.Dv NULL , +the list of labels is not updated. +.Pp +The +.Fn dn_expand +entry +expands the compressed domain name +.Fa comp_dn +to a full domain name +The compressed name is contained in a query or reply message; +.Fa msg +is a pointer to the beginning of the message. +The uncompressed name is placed in the buffer indicated by +.Fa exp_dn +which is of size +.Fa length . +The size of compressed name is returned or \-1 if there was an error. +.Pp +The +.Fn dn_skipname +function skips over a compressed domain name, which starts at a location +pointed to by +.Fa comp_dn . +The compressed name is contained in a query or reply message; +.Fa eom +is a pointer to the end of the message. +The size of compressed name is returned or \-1 if there was +an error. +.Pp +The +.Fn ns_get16 +function gets a 16-bit quantity from a buffer pointed to by +.Fa src . +.Pp +The +.Fn ns_get32 +function gets a 32-bit quantity from a buffer pointed to by +.Fa src . +.Pp +The +.Fn ns_put16 +function puts a 16-bit quantity +.Fa src +to a buffer pointed to by +.Fa dst . +.Pp +The +.Fn ns_put32 +function puts a 32-bit quantity +.Fa src +to a buffer pointed to by +.Fa dst . +.Sh FILES +.Bl -tag -width /etc/resolv.conf +.It Pa /etc/resolv.conf +The configuration file, +see +.Xr resolver 5 . +.El +.Sh SEE ALSO +.Xr gethostbyname 3 , +.Xr resolver 5 , +.Xr hostname 7 , +.Xr named 8 +.Pp +.%T RFC1032 , +.%T RFC1033 , +.%T RFC1034 , +.%T RFC1035 , +.%T RFC974 +.Rs +.%T "Name Server Operations Guide for BIND" +.Re +.Sh HISTORY +The +.Nm +function appeared in +.Bx 4.3 . diff --git a/nls/Makefile.inc b/nls/Makefile.inc new file mode 100644 index 0000000..66329a2 --- /dev/null +++ b/nls/Makefile.inc @@ -0,0 +1,10 @@ +# from $NetBSD: Makefile.inc,v 1.7 1995/02/27 13:06:20 cgd Exp $ +# $FreeBSD: src/lib/libc/nls/Makefile.inc,v 1.7 2001/03/27 17:26:48 ru Exp $ + +.PATH: ${.CURDIR}/../libc/nls + +SRCS+= msgcat.c + +.if ${LIB} == "c" +MAN+= catclose.3 catgets.3 catopen.3 +.endif diff --git a/posix1e/Makefile.inc b/posix1e/Makefile.inc new file mode 100644 index 0000000..42b2aa6 --- /dev/null +++ b/posix1e/Makefile.inc @@ -0,0 +1,92 @@ +# $FreeBSD: src/lib/libc/posix1e/Makefile.inc,v 1.6 2001/09/01 00:00:50 rwatson Exp $ + +MAINTAINER= rwatson@FreeBSD.org + +.PATH: ${.CURDIR}/../libc/posix1e + +SRCS+= acl_calc_mask.c \ + acl_copy.c \ + acl_delete.c \ + acl_delete_entry.c \ + acl_entry.c \ + acl_free.c \ + acl_from_text.c \ + acl_get.c \ + acl_init.c \ + acl_perm.c \ + acl_set.c \ + acl_support.c \ + acl_to_text.c \ + acl_valid.c \ + cap_clear.c \ + cap_cmp.c \ + cap_copy.c \ + cap_dup.c \ + cap_free.c \ + cap_get_fd.c \ + cap_get_file.c \ + cap_get_flag.c \ + cap_get_proc.c \ + cap_init.c \ + cap_set_fd.c \ + cap_set_file.c \ + cap_set_flag.c \ + cap_set_proc.c \ + cap_text.c + +.if ${LIB} == "c" + +MAN+= acl.3 \ + acl_add_perm.3 \ + acl_calc_mask.3 \ + acl_clear_perms.3 \ + acl_copy_entry.3 \ + acl_create_entry.3 \ + acl_delete.3 \ + acl_delete_entry.3 \ + acl_delete_perm.3 \ + acl_dup.3 \ + acl_free.3 \ + acl_from_text.3 \ + acl_get.3 \ + acl_get_entry.3 \ + acl_get_permset.3 \ + acl_get_perm_np.3 \ + acl_get_qualifier.3 \ + acl_get_tag_type.3 \ + acl_init.3 \ + acl_set.3 \ + acl_set_permset.3 \ + acl_set_qualifier.3 \ + acl_set_tag_type.3 \ + acl_to_text.3 \ + acl_valid.3 \ + cap.3 \ + cap_clear.3 \ + cap_copy_ext.3 \ + cap_copy_int.3 \ + cap_dup.3 \ + cap_free.3 \ + cap_from_text.3 \ + cap_get_flag.3 \ + cap_get_proc.3 \ + cap_init.3 \ + cap_set_flag.3 \ + cap_set_proc.3 \ + cap_to_text.3 \ + posix1e.3 + +MLINKS+=acl_delete.3 acl_delete_def_file.3 \ + acl_delete.3 acl_delete_file_np.3 \ + acl_delete.3 acl_delete_fd_np.3 \ + acl_get.3 acl_get_file.3 \ + acl_get.3 acl_get_fd.3 \ + acl_get.3 acl_get_fd_np.3 \ + acl_set.3 acl_set_file.3 \ + acl_set.3 acl_set_fd.3 \ + acl_set.3 acl_set_fd_np.3 \ + acl_valid.3 acl_valid_file_np.3 \ + acl_valid.3 acl_valid_fd_np.3 \ + cap_copy_ext.3 cap_size.3 + +.endif diff --git a/ppc/gen/Makefile.inc b/ppc/gen/Makefile.inc new file mode 100644 index 0000000..6344540 --- /dev/null +++ b/ppc/gen/Makefile.inc @@ -0,0 +1,6 @@ +SRCS += abs.s bzero.s mcount.s strcmp.c strncmp.c \ + ecvt.c remque.c strcpy.c strncpy.c \ + bcmp.c ffs.s insque.c setjmperr.c strlen.s \ + bcopy.s fp.h isinf.c strcat.c strncat.c \ + mcount.s + diff --git a/gen.subproj/ppc.subproj/abs.s b/ppc/gen/abs.s similarity index 100% rename from gen.subproj/ppc.subproj/abs.s rename to ppc/gen/abs.s diff --git a/ppc/gen/assymdefs.c b/ppc/gen/assymdefs.c new file mode 100644 index 0000000..80ecae8 --- /dev/null +++ b/ppc/gen/assymdefs.c @@ -0,0 +1,87 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * assymdefs.c -- list of symbols to #define in assym.h + */ +#import +#define __TARGET_ARCHITECTURE__ "ppc" +#import +#import +#import +#import "genassym.h" + +void +assymdefs(void) +{ + /* This is required for `setjmp' to work. */ + assert(offsetof(struct _jmp_buf, csr[18]) + == offsetof(struct _jmp_buf, fp)); + + comment(MAJOR, "Structure Offsets"); + comment(MINOR, "jmpbuf_t offsets and constants"); + + PRINT_OFFSET(struct _jmp_buf *, magic); + PRINT_OFFSET(struct _jmp_buf *, sp); + PRINT_OFFSET(struct _jmp_buf *, csr[0]); + PRINT_OFFSET(struct _jmp_buf *, csr[17]); + PRINT_OFFSET(struct _jmp_buf *, fp); + PRINT_OFFSET(struct _jmp_buf *, toc); + PRINT_OFFSET(struct _jmp_buf *, cr); + PRINT_OFFSET(struct _jmp_buf *, lr); + PRINT_OFFSET(struct _jmp_buf *, fpr[0]); + PRINT_OFFSET(struct _jmp_buf *, fpr[1]); + PRINT_OFFSET(struct _jmp_buf *, fpr[2]); + PRINT_OFFSET(struct _jmp_buf *, fpr[3]); + PRINT_OFFSET(struct _jmp_buf *, fpr[4]); + PRINT_OFFSET(struct _jmp_buf *, fpr[5]); + PRINT_OFFSET(struct _jmp_buf *, fpr[6]); + PRINT_OFFSET(struct _jmp_buf *, fpr[7]); + PRINT_OFFSET(struct _jmp_buf *, fpr[8]); + PRINT_OFFSET(struct _jmp_buf *, fpr[9]); + PRINT_OFFSET(struct _jmp_buf *, fpr[10]); + PRINT_OFFSET(struct _jmp_buf *, fpr[11]); + PRINT_OFFSET(struct _jmp_buf *, fpr[12]); + PRINT_OFFSET(struct _jmp_buf *, fpr[13]); + PRINT_OFFSET(struct _jmp_buf *, fpr[14]); + PRINT_OFFSET(struct _jmp_buf *, fpr[15]); + PRINT_OFFSET(struct _jmp_buf *, fpr[16]); + PRINT_OFFSET(struct _jmp_buf *, fpr[17]); + PRINT_OFFSET(struct _jmp_buf *, fpscr); + PRINT_OFFSET(struct _jmp_buf *, sig_onstack); + PRINT_OFFSET(struct _jmp_buf *, sig_mask); + PRINT_CONSTANT(_JMP_BUF_MAGICNUM); + + comment(MINOR, "sigcontext offsets, sizes, and constants"); + PRINT_SIZEOF(struct sigcontext); + PRINT_OFFSET(struct sigcontext *, sc_onstack); + PRINT_OFFSET(struct sigcontext *, sc_mask); + PRINT_OFFSET(struct sigcontext *, sc_sp); + PRINT_OFFSET(struct sigcontext *, sc_cia); + PRINT_OFFSET(struct sigcontext *, sc_regs_saved); + PRINT_OFFSET(struct sigcontext *, sc_a0); + PRINT_ENUM(REGS_SAVED_NONE); + + comment(MINOR, "struct sigstack offsets and sizes"); + PRINT_SIZEOF(struct sigstack); + PRINT_OFFSET(struct sigstack *, ss_sp); + PRINT_OFFSET(struct sigstack *, ss_onstack); +} diff --git a/gen.subproj/ppc.subproj/bcmp.c b/ppc/gen/bcmp.c similarity index 100% rename from gen.subproj/ppc.subproj/bcmp.c rename to ppc/gen/bcmp.c diff --git a/ppc/gen/bcopy.s b/ppc/gen/bcopy.s new file mode 100644 index 0000000..2020f15 --- /dev/null +++ b/ppc/gen/bcopy.s @@ -0,0 +1,1159 @@ +/* + * Copyright (c) 2002 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* ======================================= + * BCOPY, MEMCPY, and MEMMOVE for Mac OS X + * ======================================= + * + * Version of 6/17/2002, for G3, G4, and G4+. + * + * There are many paths through this code, depending on length, reverse/forward, + * processor type, and alignment. We use reverse paths only when the operands + * overlap and the destination is higher than the source. They are not quite as + * fast as the forward paths. + * + * Judicious use of DCBTs, just far enough ahead to minimize waiting, is critical in + * the inner loops for long operands. DST is less effective than DCBT, because it + * can get out of sync with the inner loop. DCBTST is usually not a win, so we + * don't use it except during initialization when we're not using the LSU. + * We don't DCBT on G3, which only handles one load miss at a time. + * + * We don't use DCBZ, because it takes an alignment exception on uncached memory + * like frame buffers. Bcopy to frame buffers must work. This hurts G3 in the + * cold-cache case, but G4 can use DCBA (which does not take alignment exceptions.) + * + * Using DCBA on G4 is a tradeoff. For the cold-cache case it can be a big win, + * since it avoids the read of destination cache lines. But for the hot-cache case + * it is always slower, because of the cycles spent needlessly zeroing data. Some + * machines store-gather and can cancel the read if all bytes of a line are stored, + * others cannot. Unless explicitly told which is better, we time loops with and + * without DCBA and use the fastest. Note that we never DCBA in reverse loops, + * since by definition they are overlapped so dest lines will be in the cache. + * + * For longer operands we use an 8-element branch table, based on the CPU type, + * to select the appropriate inner loop. The branch table is indexed as follows: + * + * bit 10000 set if a Reverse move is required + * bits 01100 set on the relative operand alignment: 0=unaligned, 1=word, + * 2=doubleword, and 3=quadword. + * + * By "relatively" n-byte aligned, we mean the source and destination are a multiple + * of n bytes apart (they need not be absolutely aligned.) + * + * The branch table for the running CPU type is pointed to by LBranchTablePtr. + * Initially, LBranchtablePtr points to G3's table, since that is the lowest + * common denominator that will run on any CPU. Later, pthread initialization + * sets up the _cpu_capabilities vector and calls _bcopy_initialize, which sets + * up the correct pointer for the running CPU. + * + * We distinguish between "short", "medium", and "long" operands: + * short (<= 32 bytes) most common case, minimum path length is important + * medium (> 32, < kLong) too short for Altivec or use of cache ops like DCBA + * long (>= kLong) long enough for cache ops and to amortize use of Altivec + * + * WARNING: kLong must be >=96, due to implicit assumptions about operand length. + */ +#define kLong 96 + +/* Register usage. Note we use R2, so this code will not run in a PEF/CFM + * environment. Note also the rather delicate way we assign multiple uses + * to the same register. Beware. + * + * r0 = "w7" or "r0" (NB: cannot use r0 for any constant such as "c16") + * r2 = "w8" or VRSave ("rv") + * r3 = not used, as memcpy and memmove return 1st parameter as a value + * r4 = source ptr ("rs") + * r5 = count of bytes to move ("rc") + * r6 = "w1", "c16", or "cm17" + * r7 = "w2", "c32", or "cm33" + * r8 = "w3", "c48", or "cm49" + * r9 = "w4", "c64", or "cm1" + * r10 = "w5", "c96", or "cm97" + * r11 = "w6", "c128", "cm129", or return address ("ra") + * r12 = destination ptr ("rd") + * f0-f8 = used for moving 8-byte aligned data + * v0 = permute vector ("vp") + * v1-v4 = qw's loaded from source ("v1", "v2", "v3", and "v4") + * v5-v7 = permuted qw's ("vx", "vy", and "vz") + */ +#define rs r4 +#define rd r12 +#define rc r5 +#define ra r11 +#define rv r2 + +#define w1 r6 +#define w2 r7 +#define w3 r8 +#define w4 r9 +#define w5 r10 +#define w6 r11 +#define w7 r0 +#define w8 r2 + +#define c16 r6 +#define cm17 r6 +#define c32 r7 +#define cm33 r7 +#define c48 r8 +#define cm49 r8 +#define c64 r9 +#define cm1 r9 +#define c96 r10 +#define cm97 r10 +#define c128 r11 +#define cm129 r11 + +#define vp v0 +#define vx v5 +#define vy v6 +#define vz v7 + +#define VRSave 256 + +#include + +// The branch tables, 8 entries per CPU type. +// NB: we depend on 5 low-order 0s in the address of branch tables. + + .data + .align 5 // must be 32-byte aligned + + // G3 (the default CPU type) + +LG3: + .long LForwardWord // 000: forward, unaligned + .long LForwardFloat // 001: forward, 4-byte aligned + .long LForwardFloat // 010: forward, 8-byte aligned + .long LForwardFloat // 011: forward, 16-byte aligned + .long LReverseWord // 100: reverse, unaligned + .long LReverseFloat // 101: reverse, 4-byte aligned + .long LReverseFloat // 110: reverse, 8-byte aligned + .long LReverseFloat // 111: reverse, 16-byte aligned + + // G4s that benefit from DCBA. + +LG4UseDcba: + .long LForwardVecUnal32Dcba // 000: forward, unaligned + .long LForwardVecUnal32Dcba // 001: forward, 4-byte aligned + .long LForwardVecUnal32Dcba // 010: forward, 8-byte aligned + .long LForwardVecAlig32Dcba // 011: forward, 16-byte aligned + .long LReverseVectorUnal32 // 100: reverse, unaligned + .long LReverseVectorUnal32 // 101: reverse, 4-byte aligned + .long LReverseVectorUnal32 // 110: reverse, 8-byte aligned + .long LReverseVectorAligned32 // 111: reverse, 16-byte aligned + + // G4s that should not use DCBA. + +LG4NoDcba: + .long LForwardVecUnal32NoDcba // 000: forward, unaligned + .long LForwardVecUnal32NoDcba // 001: forward, 4-byte aligned + .long LForwardVecUnal32NoDcba // 010: forward, 8-byte aligned + .long LForwardVecAlig32NoDcba // 011: forward, 16-byte aligned + .long LReverseVectorUnal32 // 100: reverse, unaligned + .long LReverseVectorUnal32 // 101: reverse, 4-byte aligned + .long LReverseVectorUnal32 // 110: reverse, 8-byte aligned + .long LReverseVectorAligned32 // 111: reverse, 16-byte aligned + + +// Pointer to the 8-element branch table for running CPU type: + +LBranchTablePtr: + .long LG3 // default to G3 until "bcopy_initialize" called + + +// The CPU capability vector, initialized in pthread_init(). +// "_bcopy_initialize" uses this to set up LBranchTablePtr: + + .globl __cpu_capabilities +__cpu_capabilities: + .long 0 + +// Bit definitions for _cpu_capabilities: + +#define kHasAltivec 0x01 +#define k64Bit 0x02 +#define kCache32 0x04 +#define kCache64 0x08 +#define kCache128 0x10 +#define kUseDcba 0x20 +#define kNoDcba 0x40 + + +.text +.globl _bcopy +.globl _memcpy +.globl _memmove +.globl __bcopy_initialize + + +// Main entry points. + + .align 5 +_bcopy: // void bcopy(const void *src, void *dst, size_t len) + mr r10,r3 // reverse source and dest ptrs, to be like memcpy + mr r3,r4 + mr r4,r10 +_memcpy: // void* memcpy(void *dst, void *src, size_t len) +_memmove: // void* memmove(void *dst, const void *src, size_t len) + cmplwi cr7,rc,32 // length <= 32 bytes? + sub. w1,r3,rs // must move in reverse if (rd-rs)=1) + mtctr w4 // prepare loop count + beq+ 2f // source already aligned + + lwzx w2,w3,rs // get 1st aligned word (which we might partially overwrite) + add rs,rs,w3 // word-align source ptr + stw w1,0(rd) // store all (w3) bytes at once to avoid a loop + add rd,rd,w3 + mr w1,w2 // first aligned word to w1 + b 2f + + .align 4 // align inner loops +1: // loop over 16-byte chunks + lwz w1,0(rs) +2: + lwz w2,4(rs) + lwz w3,8(rs) + lwz w4,12(rs) + addi rs,rs,16 + stw w1,0(rd) + stw w2,4(rd) + stw w3,8(rd) + stw w4,12(rd) + addi rd,rd,16 + bdnz 1b + + b LShort16 + + +// Medium, doubleword aligned. We use floating point. Note that G4+ has bigger latencies +// and reduced throughput for floating pt loads and stores; future processors will probably +// have even worse lfd/stfd performance. We use it here because it is so important for G3, +// and not slower for G4+. But we only do so for doubleword aligned operands, whereas the +// G3-only long operand loops use floating pt even for word-aligned operands. +// w2 = neg(rs) +// w1 = first 4 bytes of source + +LMediumAligned: + andi. w3,w2,7 // already aligned? + sub rc,rc,w3 // adjust count by 0-7 bytes + lfdx f0,rs,w3 // pre-fetch first aligned source doubleword + srwi w4,rc,5 // get count of 32-byte chunks (might be 0 if unaligned) + mtctr w4 + beq- LForwardFloatLoop1 // already aligned + + cmpwi w4,0 // are there any 32-byte chunks to xfer? + lwz w2,4(rs) // get 2nd (unaligned) source word + add rs,rs,w3 // doubleword align source pointer + stw w1,0(rd) // store first 8 bytes of source to align... + stw w2,4(rd) // ...which could overwrite source + add rd,rd,w3 // doubleword align destination + bne+ LForwardFloatLoop1 // at least 1 chunk, so enter loop + + subi rc,rc,8 // unfortunate degenerate case: no chunks to xfer + stfd f0,0(rd) // must store f1 since source might have been overwriten + addi rs,rs,8 + addi rd,rd,8 + b LShort + + +// Medium reverse moves. This loop runs on all processors. + +LMediumReverse: + add rs,rs,rc // point to other end of operands when in reverse + add rd,rd,rc + andi. w3,rs,3 // w3 <- #bytes to word align source + lwz w1,-4(rs) // pre-fetch 1st 4 bytes of source + sub rc,rc,w3 // adjust count + srwi w4,rc,4 // get count of 16-byte chunks (>=1) + mtcrf 0x01,rc // remaining byte count (0-15) to cr7 for LShortReverse16 + mtctr w4 // prepare loop count + beq+ 2f // source already aligned + + sub rs,rs,w3 // word-align source ptr + lwz w2,-4(rs) // get 1st aligned word which we may overwrite + stw w1,-4(rd) // store all 4 bytes to align without a loop + sub rd,rd,w3 + mr w1,w2 // shift 1st aligned source word to w1 + b 2f + +1: + lwz w1,-4(rs) +2: + lwz w2,-8(rs) + lwz w3,-12(rs) + lwzu w4,-16(rs) + stw w1,-4(rd) + stw w2,-8(rd) + stw w3,-12(rd) + stwu w4,-16(rd) + bdnz 1b + + b LShortReverse16 + + +// Long operands. Use branch table to decide which loop to use. +// w1 = (rd-rs), used to determine alignment + +LLong: + xor w4,w1,rc // we must move reverse if (rd-rs)=1) + mtctr r0 // prepare loop count + beq+ 1f // dest already aligned + + lwz w2,0(rs) // get first 4 bytes of source + lwzx w1,w3,rs // get source bytes we might overwrite + add rs,rs,w3 // adjust source ptr + stw w2,0(rd) // store all 4 bytes to avoid a loop + add rd,rd,w3 // word-align destination + b 2f +1: + lwz w1,0(rs) +2: + lwz w2,4(rs) + lwz w3,8(rs) + lwz w4,12(rs) + lwz w5,16(rs) + lwz w6,20(rs) + lwz w7,24(rs) + lwz w8,28(rs) + addi rs,rs,32 + stw w1,0(rd) + stw w2,4(rd) + stw w3,8(rd) + stw w4,12(rd) + stw w5,16(rd) + stw w6,20(rd) + stw w7,24(rd) + stw w8,28(rd) + addi rd,rd,32 + bdnz 1b + + b LShort + + +// G3, forward, long, word aligned. We use floating pt even when only word aligned. +// w1 = neg(rd) + +LForwardFloat: + andi. w3,w1,7 // W3 <- #bytes to doubleword-align destination + mtlr ra // restore return address + sub rc,rc,w3 // adjust count for alignment + srwi r0,rc,5 // number of 32-byte chunks to xfer (>=1) + mtctr r0 // prepare loop count + beq LForwardFloatLoop // dest already aligned + + lwz w1,0(rs) // get first 8 bytes of source + lwz w2,4(rs) + lfdx f0,w3,rs // get source bytes we might overwrite + add rs,rs,w3 // word-align source ptr + stw w1,0(rd) // store all 8 bytes to avoid a loop + stw w2,4(rd) + add rd,rd,w3 + b LForwardFloatLoop1 + + .align 4 // align since this loop is executed by G4s too +LForwardFloatLoop: + lfd f0,0(rs) +LForwardFloatLoop1: // enter here from LMediumAligned and above + lfd f1,8(rs) + lfd f2,16(rs) + lfd f3,24(rs) + addi rs,rs,32 + stfd f0,0(rd) + stfd f1,8(rd) + stfd f2,16(rd) + stfd f3,24(rd) + addi rd,rd,32 + bdnz LForwardFloatLoop + + b LShort + + +// G4 Forward, long, 16-byte aligned, 32-byte cache ops, use DCBA and DCBT. +// r0/cr0 = #bytes to 32-byte align + +LForwardVecAlig32Dcba: + bnel+ LAlign32 // align destination iff necessary + bl LPrepareForwardVectors + mtlr ra // restore return address before loading c128 + li c128,128 + b 1f // enter aligned loop + + .align 5 // long loop heads should be at least 16-byte aligned +1: // loop over aligned 64-byte chunks + dcbt c96,rs // pre-fetch three cache lines ahead + dcbt c128,rs // and four + lvx v1,0,rs + lvx v2,c16,rs + lvx v3,c32,rs + lvx v4,c48,rs + addi rs,rs,64 + dcba 0,rd // avoid read of destination cache lines + stvx v1,0,rd + stvx v2,c16,rd + dcba c32,rd + stvx v3,c32,rd + stvx v4,c48,rd + addi rd,rd,64 + bdnz 1b + +LForwardVectorAlignedEnd: // r0/cr0=#quadwords, rv=VRSave, cr7=low 4 bits of rc, cr6 set on cr7 + beq- 3f // no leftover quadwords + mtctr r0 +2: // loop over remaining quadwords (1-7) + lvx v1,0,rs + addi rs,rs,16 + stvx v1,0,rd + addi rd,rd,16 + bdnz 2b +3: + mtspr VRSave,rv // restore bitmap of live vr's + bne cr6,LShort16 // handle last 0-15 bytes if any + blr + + +// G4 Forward, long, 16-byte aligned, 32-byte cache, use DCBT but not DCBA. +// r0/cr0 = #bytes to 32-byte align + +LForwardVecAlig32NoDcba: + bnel+ LAlign32 // align destination iff necessary + bl LPrepareForwardVectors + mtlr ra // restore return address before loading c128 + li c128,128 + b 1f // enter aligned loop + + .align 4 // balance 13-word loop between QWs... + nop // ...which improves performance 5% +/- + nop +1: // loop over aligned 64-byte chunks + dcbt c96,rs // pre-fetch three cache lines ahead + dcbt c128,rs // and four + lvx v1,0,rs + lvx v2,c16,rs + lvx v3,c32,rs + lvx v4,c48,rs + addi rs,rs,64 + stvx v1,0,rd + stvx v2,c16,rd + stvx v3,c32,rd + stvx v4,c48,rd + addi rd,rd,64 + bdnz 1b + + b LForwardVectorAlignedEnd + + +// G4 Forward, long, unaligned, 32-byte cache ops, use DCBT and DCBA. At least on +// some CPUs, this routine is no slower than the simpler aligned version that does +// not use permutes. But it cannot be used with aligned operands, because of the +// way it prefetches source QWs. +// r0/cr0 = #bytes to 32-byte align + +LForwardVecUnal32Dcba: + bnel+ LAlign32 // align destination iff necessary + bl LPrepareForwardVectors + lvx v1,0,rs // prime loop + mtlr ra // restore return address before loading c128 + lvsl vp,0,rs // get permute vector to shift left + li c128,128 + b 1f // enter aligned loop + + .align 4 // long loop heads should be at least 16-byte aligned +1: // loop over aligned 64-byte destination chunks + lvx v2,c16,rs + dcbt c96,rs // touch 3rd cache line ahead + lvx v3,c32,rs + dcbt c128,rs // touch 4th cache line ahead + lvx v4,c48,rs + addi rs,rs,64 + vperm vx,v1,v2,vp + lvx v1,0,rs + vperm vy,v2,v3,vp + dcba 0,rd // avoid read of destination lines + stvx vx,0,rd + vperm vz,v3,v4,vp + stvx vy,c16,rd + dcba c32,rd + vperm vx,v4,v1,vp + stvx vz,c32,rd + stvx vx,c48,rd + addi rd,rd,64 + bdnz 1b + +LForwardVectorUnalignedEnd: // r0/cr0=#QWs, rv=VRSave, v1=next QW, cr7=(rc & F), cr6 set on cr7 + beq- 3f // no leftover quadwords + mtctr r0 +2: // loop over remaining quadwords + lvx v2,c16,rs + addi rs,rs,16 + vperm vx,v1,v2,vp + vor v1,v2,v2 // v1 <- v2 + stvx vx,0,rd + addi rd,rd,16 + bdnz 2b +3: + mtspr VRSave,rv // restore bitmap of live vr's + bne cr6,LShort16 // handle last 0-15 bytes if any + blr + + +// G4 Forward, long, unaligned, 32-byte cache ops, use DCBT but not DCBA. +// r0/cr0 = #bytes to 32-byte align + +LForwardVecUnal32NoDcba: + bnel+ LAlign32 // align destination iff necessary + bl LPrepareForwardVectors + lvx v1,0,rs // prime loop + mtlr ra // restore return address before loading c128 + lvsl vp,0,rs // get permute vector to shift left + li c128,128 + b 1f // enter aligned loop + + .align 4 + nop // balance 17-word loop between QWs + nop +1: // loop over aligned 64-byte destination chunks + lvx v2,c16,rs + dcbt c96,rs // touch 3rd cache line ahead + lvx v3,c32,rs + dcbt c128,rs // touch 4th cache line ahead + lvx v4,c48,rs + addi rs,rs,64 + vperm vx,v1,v2,vp + lvx v1,0,rs + vperm vy,v2,v3,vp + stvx vx,0,rd + vperm vz,v3,v4,vp + stvx vy,c16,rd + vperm vx,v4,v1,vp + stvx vz,c32,rd + stvx vx,c48,rd + addi rd,rd,64 + bdnz 1b + + b LForwardVectorUnalignedEnd + + +// G3 Reverse, long, unaligned. + +LReverseWord: + bl LAlign8Reverse // 8-byte align destination + mtlr ra // restore return address + srwi r0,rc,5 // get count of 32-byte chunks to xfer (> 1) + mtctr r0 +1: + lwz w1,-4(rs) + lwz w2,-8(rs) + lwz w3,-12(rs) + lwz w4,-16(rs) + stw w1,-4(rd) + lwz w5,-20(rs) + stw w2,-8(rd) + lwz w6,-24(rs) + stw w3,-12(rd) + lwz w7,-28(rs) + stw w4,-16(rd) + lwzu w8,-32(rs) + stw w5,-20(rd) + stw w6,-24(rd) + stw w7,-28(rd) + stwu w8,-32(rd) + bdnz 1b + + b LShortReverse + + +// G3 Reverse, long, word aligned. + +LReverseFloat: + bl LAlign8Reverse // 8-byte align + mtlr ra // restore return address + srwi r0,rc,5 // get count of 32-byte chunks to xfer (> 1) + mtctr r0 +1: + lfd f0,-8(rs) + lfd f1,-16(rs) + lfd f2,-24(rs) + lfdu f3,-32(rs) + stfd f0,-8(rd) + stfd f1,-16(rd) + stfd f2,-24(rd) + stfdu f3,-32(rd) + bdnz 1b + + b LShortReverse + + +// G4 Reverse, long, 16-byte aligned, 32-byte DCBT but no DCBA. + +LReverseVectorAligned32: + bl LAlign32Reverse // 32-byte align destination iff necessary + bl LPrepareReverseVectors + mtlr ra // restore return address before loading cm129 + li cm129,-129 + b 1f // enter aligned loop + + .align 4 + nop // must start in 3rd word of QW... + nop // ...to keep balanced +1: // loop over aligned 64-byte chunks + dcbt cm97,rs // pre-fetch three cache lines ahead + dcbt cm129,rs // and four + lvx v1,cm1,rs + lvx v2,cm17,rs + lvx v3,cm33,rs + lvx v4,cm49,rs + subi rs,rs,64 + stvx v1,cm1,rd + stvx v2,cm17,rd + stvx v3,cm33,rd + stvx v4,cm49,rd + subi rd,rd,64 + bdnz 1b + +LReverseVectorAlignedEnd: // cr0/r0=#quadwords, rv=VRSave, cr7=low 4 bits of rc, cr6 set on cr7 + beq 3f // no leftover quadwords + mtctr r0 +2: // loop over 1-3 quadwords + lvx v1,cm1,rs + subi rs,rs,16 + stvx v1,cm1,rd + subi rd,rd,16 + bdnz 2b +3: + mtspr VRSave,rv // restore bitmap of live vr's + bne cr6,LShortReverse16 // handle last 0-15 bytes iff any + blr + + +// G4 Reverse, long, unaligned, 32-byte DCBT. + +LReverseVectorUnal32: + bl LAlign32Reverse // align destination iff necessary + bl LPrepareReverseVectors + lvx v1,cm1,rs // prime loop + mtlr ra // restore return address before loading cm129 + lvsl vp,0,rs // get permute vector to shift left + li cm129,-129 + b 1f // enter aligned loop + + .align 4 + nop // start loop in 3rd word on QW to balance + nop +1: // loop over aligned 64-byte destination chunks + lvx v2,cm17,rs + dcbt cm97,rs // touch in 3rd source block + lvx v3,cm33,rs + dcbt cm129,rs // touch in 4th + lvx v4,cm49,rs + subi rs,rs,64 + vperm vx,v2,v1,vp + lvx v1,cm1,rs + vperm vy,v3,v2,vp + stvx vx,cm1,rd + vperm vz,v4,v3,vp + stvx vy,cm17,rd + vperm vx,v1,v4,vp + stvx vz,cm33,rd + stvx vx,cm49,rd + subi rd,rd,64 + bdnz 1b + +LReverseVectorUnalignedEnd: // r0/cr0=#QWs, rv=VRSave, v1=source QW, cr7=low 4 bits of rc, cr6 set on cr7 + beq 3f // no leftover quadwords + mtctr r0 +2: // loop over 1-3 quadwords + lvx v2,cm17,rs + subi rs,rs,16 + vperm vx,v2,v1,vp + vor v1,v2,v2 // v1 <- v2 + stvx vx,cm1,rd + subi rd,rd,16 + bdnz 2b +3: + mtspr VRSave,rv // restore bitmap of live vr's + bne cr6,LShortReverse16 // handle last 0-15 bytes iff any + blr + + +// Subroutine to prepare for 64-byte forward vector loops. +// Returns many things: +// ctr = number of 64-byte chunks to move +// r0/cr0 = leftover QWs to move +// cr7 = low 4 bits of rc (ie, leftover byte count 0-15) +// cr6 = beq if leftover byte count is 0 +// c16..c96 loaded +// rv = original value of VRSave +// NB: c128 not set (if needed), since it is still "ra" + +LPrepareForwardVectors: + mfspr rv,VRSave // get bitmap of live vector registers + srwi r0,rc,6 // get count of 64-byte chunks to move (>=1) + oris w1,rv,0xFF00 // we use v0-v7 + mtcrf 0x01,rc // prepare for moving last 0-15 bytes in LShort16 + rlwinm w3,rc,0,28,31 // move last 0-15 byte count to w3 too + mtspr VRSave,w1 // update mask + li c16,16 // get constants used in ldvx/stvx + li c32,32 + mtctr r0 // set up loop count + cmpwi cr6,w3,0 // set cr6 on leftover byte count + li c48,48 + li c96,96 + rlwinm. r0,rc,28,30,31 // get number of quadword leftovers (0-3) and set cr0 + blr + + +// Subroutine to prepare for 64-byte reverse vector loops. +// Returns many things: +// ctr = number of 64-byte chunks to move +// r0/cr0 = leftover QWs to move +// cr7 = low 4 bits of rc (ie, leftover byte count 0-15) +// cr6 = beq if leftover byte count is 0 +// cm1..cm97 loaded +// rv = original value of VRSave +// NB: cm129 not set (if needed), since it is still "ra" + +LPrepareReverseVectors: + mfspr rv,VRSave // get bitmap of live vector registers + srwi r0,rc,6 // get count of 64-byte chunks to move (>=1) + oris w1,rv,0xFF00 // we use v0-v7 + mtcrf 0x01,rc // prepare for moving last 0-15 bytes in LShortReverse16 + rlwinm w3,rc,0,28,31 // move last 0-15 byte count to w3 too + mtspr VRSave,w1 // update mask + li cm1,-1 // get constants used in ldvx/stvx + li cm17,-17 + mtctr r0 // set up loop count + cmpwi cr6,w3,0 // set cr6 on leftover byte count + li cm33,-33 + li cm49,-49 + rlwinm. r0,rc,28,30,31 // get number of quadword leftovers (0-3) and set cr0 + li cm97,-97 + blr + + +// Subroutine to align destination on a 32-byte boundary. +// r0 = number of bytes to xfer (0-31) + +LAlign32: + mtcrf 0x01,r0 // length to cr (faster to change 1 CR at a time) + mtcrf 0x02,r0 + sub rc,rc,r0 // adjust length + bf 31,1f // skip if no odd bit + lbz w1,0(rs) + addi rs,rs,1 + stb w1,0(rd) + addi rd,rd,1 +1: + bf 30,2f // halfword to move? + lhz w1,0(rs) + addi rs,rs,2 + sth w1,0(rd) + addi rd,rd,2 +2: + bf 29,3f // word? + lwz w1,0(rs) + addi rs,rs,4 + stw w1,0(rd) + addi rd,rd,4 +3: + bf 28,4f // doubleword? + lwz w1,0(rs) + lwz w2,4(rs) + addi rs,rs,8 + stw w1,0(rd) + stw w2,4(rd) + addi rd,rd,8 +4: + bflr 27 // done if no quadword to move + lwz w1,0(rs) + lwz w2,4(rs) + lwz w3,8(rs) + lwz w4,12(rs) + addi rs,rs,16 + stw w1,0(rd) + stw w2,4(rd) + stw w3,8(rd) + stw w4,12(rd) + addi rd,rd,16 + blr + +// Subroutine to align destination if necessary on a 32-byte boundary for reverse moves. +// rs and rd still point to low end of operands +// we adjust rs and rd to point to last byte moved + +LAlign32Reverse: + add rd,rd,rc // point to last byte moved (ie, 1 past end of operands) + add rs,rs,rc + andi. r0,rd,0x1F // r0 <- #bytes that must be moved to align destination + mtcrf 0x01,r0 // length to cr (faster to change 1 CR at a time) + mtcrf 0x02,r0 + sub rc,rc,r0 // update length + beqlr- // destination already 32-byte aligned + + bf 31,1f // odd byte? + lbzu w1,-1(rs) + stbu w1,-1(rd) +1: + bf 30,2f // halfword to move? + lhzu w1,-2(rs) + sthu w1,-2(rd) +2: + bf 29,3f // word? + lwzu w1,-4(rs) + stwu w1,-4(rd) +3: + bf 28,4f // doubleword? + lwz w1,-4(rs) + lwzu w2,-8(rs) + stw w1,-4(rd) + stwu w2,-8(rd +4: + bflr 27 // done if no quadwords + lwz w1,-4(rs) + lwz w2,-8(rs) + lwz w3,-12(rs) + lwzu w4,-16(rs) + stw w1,-4(rd) + stw w2,-8(rd) + stw w3,-12(rd) + stwu w4,-16(rd) + blr + + +// Subroutine to align destination on an 8-byte boundary for reverse moves. +// rs and rd still point to low end of operands +// we adjust rs and rd to point to last byte moved + +LAlign8Reverse: + add rd,rd,rc // point to last byte moved (ie, 1 past end of operands) + add rs,rs,rc + andi. r0,rd,0x7 // r0 <- #bytes that must be moved to align destination + beqlr- // destination already 8-byte aligned + mtctr r0 // set up for loop + sub rc,rc,r0 // update length +1: + lbzu w1,-1(rs) + stbu w1,-1(rd) + bdnz 1b + + blr + + +// Called by pthread initialization to set up the branch table pointer based on +// the CPU capability vector. This routine may be called more than once (for +// example, during testing.) + +// Size of the buffer we use to do DCBA timing on G4: +#define kBufSiz 1024 + +// Stack frame size, which contains the 128-byte-aligned buffer: +#define kSFSize (kBufSiz+128+16) + +// Iterations of the timing loop: +#define kLoopCnt 5 + +// Bit in cr5 used as a flag in timing loop: +#define kDCBA 22 + +__bcopy_initialize: // int _bcopy_initialize(void) + mflr ra // get return + stw ra,8(r1) // save + stwu r1,-kSFSize(r1) // carve our temp buffer from the stack + addi w6,r1,127+16 // get base address... + rlwinm w6,w6,0,0,24 // ...of our buffer, 128-byte aligned + bcl 20,31,1f // get our PIC base +1: + mflr w1 + addis w2,w1,ha16(__cpu_capabilities - 1b) + lwz w3,lo16(__cpu_capabilities - 1b)(w2) + andi. r0,w3,kUseDcba+kNoDcba+kCache32+k64Bit+kHasAltivec + cmpwi r0,kCache32+kHasAltivec // untyped G4? + li w8,0 // assume no need to test + bne 2f // not an untyped G4, so do not test + + // G4, but neither kUseDcba or kNoDcba are set. Time and select fastest. + + crset kDCBA // first, use DCBA + bl LTest32 // time it + mr w8,w4 // w8 <- best time using DCBA + srwi r0,w8,3 // bias 12 pct in favor of not using DCBA... + add w8,w8,r0 // ...because DCBA is always slower with warm cache + crclr kDCBA + bl LTest32 // w4 <- best time without DCBA + cmplw w8,w4 // which is better? + li w8,kUseDcba // assume using DCBA is faster + blt 2f + li w8,kNoDcba // no DCBA is faster + + // What branch table to use? + +2: // here with w8 = 0, kUseDcba, or kNoDcba + bcl 20,31,4f // get our PIC base again +4: + mflr w1 + addis w2,w1,ha16(__cpu_capabilities - 4b) + lwz w3,lo16(__cpu_capabilities - 4b)(w2) + or w3,w3,w8 // add in kUseDcba or kNoDcba if untyped G4 + mr r3,w8 // return dynamic selection, if any (used in testing) + + andi. r0,w3,kHasAltivec+k64Bit+kCache128+kCache64+kCache32+kUseDcba+kNoDcba + cmpwi r0,kHasAltivec+kCache32+kUseDcba // G4 with DCBA? + addis w4,w1,ha16(LG4UseDcba - 4b) + addi w4,w4,lo16(LG4UseDcba - 4b) + beq 5f + + andi. r0,w3,kHasAltivec+k64Bit+kCache128+kCache64+kCache32+kUseDcba+kNoDcba + cmpwi r0,kHasAltivec+kCache32+kNoDcba // G4 without DCBA? + addis w4,w1,ha16(LG4NoDcba - 4b) + addi w4,w4,lo16(LG4NoDcba - 4b) + beq 5f + + andi. r0,w3,kHasAltivec+k64Bit+kCache128+kCache64+kCache32 + cmpwi r0,kCache32 // G3? + addis w4,w1,ha16(LG3 - 4b) + addi w4,w4,lo16(LG3 - 4b) + beq 5f + + // Map unrecognized CPU types to G3 (lowest common denominator) + +5: // w4 <- branch table pointer + addis w5,w1,ha16(LBranchTablePtr - 4b) + stw w4,lo16(LBranchTablePtr - 4b)(w5) + lwz ra,kSFSize+8(r1) // recover return address + mtlr ra // restore it + lwz r1,0(r1) // pop off our stack frame + blr // return dynamic selection (or 0) in r3 + + +// Subroutine to time a 32-byte cache. +// kDCBA = set if we should use DCBA +// w6 = base of buffer to use for test (kBufSiz bytes) +// w4 = we return time of fastest loop in w4 + +LTest32: + li w1,kLoopCnt // number of times to loop + li w4,-1 // initialize fastest time +1: + mr rd,w6 // initialize buffer ptr + li r0,kBufSiz/32 // r0 <- cache blocks to test + mtctr r0 +2: + dcbf 0,rd // first, force the blocks out of the cache + addi rd,rd,32 + bdnz 2b + sync // make sure all the flushes take + mr rd,w6 // re-initialize buffer ptr + mtctr r0 // reset cache-block count + mftbu w5 // remember upper half so we can check for carry + mftb w2 // start the timer +3: // loop over cache blocks + bf kDCBA,4f // should we DCBA? + dcba 0,rd +4: + stfd f1,0(rd) // store the entire cache block + stfd f1,8(rd) + stfd f1,16(rd) + stfd f1,24(rd) + addi rd,rd,32 + bdnz 3b + mftb w3 + mftbu r0 + cmpw r0,w5 // did timebase carry? + bne 1b // yes, retest rather than fuss + sub w3,w3,w2 // w3 <- time for this loop + cmplw w3,w4 // faster than current best? + bge 5f // no + mr w4,w3 // remember fastest time through loop +5: + subi w1,w1,1 // decrement outer loop count + cmpwi w1,0 // more to go? + bne 1b // loop if so + blr + \ No newline at end of file diff --git a/ppc/gen/bzero.s b/ppc/gen/bzero.s new file mode 100644 index 0000000..bb313e9 --- /dev/null +++ b/ppc/gen/bzero.s @@ -0,0 +1,202 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +// +// ============================= +// BZERO and MEMSET FOR Mac OS X +// ============================= +// +// We use DCBZ, and therefore are dependent on the cache block size (32.) +// Bzero and memset need to be in the same file since they are tightly +// coupled, so we can use bzero for memset of 0 without incurring extra +// overhead. (The issue is that bzero must preserve r3 for memset.) +// +// Registers we use: +// r3 = original ptr, not changed since memset returns it +// r4 = count of bytes to set ("rc") +// r11 = working operand ptr ("rp") +// r10 = value to set ("rv") + +#define rc r4 +#define rp r11 +#define rv r10 + +#include + + .text + .align 5 + .globl _bzero + .globl _memset + +// ************* +// * B Z E R O * +// ************* + +_bzero: // void bzero(void *b, size_t len); + cmplwi cr1,rc,32 // too short for DCBZ? + li rv,0 // get a 0 +Lbzero1: // enter from memset with cr1 and rv set up + neg r5,r3 // start to compute bytes to align + mr rp,r3 // make copy of operand ptr + andi. r6,r5,0x1F // r6 <- bytes to align on cache block + blt- cr1,Ltail // <32, so skip DCBZs + beq- cr0,Ldcbz // already aligned + + // align on 32-byte boundary + + mtcrf 0x01,r6 // move length to cr7 (faster if only 1 cr) + andi. r7,r6,16 // test bit 27 by hand + sub rc,rc,r6 // adjust length + bf 31,1f // test bits of count + stb rv,0(rp) + addi rp,rp,1 +1: + bf 30,2f + sth rv,0(rp) + addi rp,rp,2 +2: + bf 29,3f + stw rv,0(rp) + addi rp,rp,4 +3: + bf 28,4f + stw rv,0(rp) + stw rv,4(rp) + addi rp,rp,8 +4: + beq Ldcbz + stw rv,0(rp) + stw rv,4(rp) + stw rv,8(rp) + stw rv,12(rp) + addi rp,rp,16 + + // DCBZ 32-byte cache blocks +Ldcbz: + srwi. r5,rc,5 // r5 <- number of cache blocks to zero + beq Ltail // none + mtctr r5 // set up loop count + andi. rc,rc,0x1F // will there be leftovers? +1: + dcbz 0,rp // zero 32 bytes + addi rp,rp,32 + bdnz 1b + beqlr // no leftovers so done + + // store up to 31 trailing bytes + // rv = value to store (in all 4 bytes) + // rc = #bytes to store (0..31) +Ltail: + andi. r5,rc,16 // bit 27 set in length? + mtcrf 0x01,rc // low 4 bits of length to cr7 + beq 1f // test bits of length + stw rv,0(rp) + stw rv,4(rp) + stw rv,8(rp) + stw rv,12(rp) + addi rp,rp,16 +1: + bf 28,2f + stw rv,0(rp) + stw rv,4(rp) + addi rp,rp,8 +2: + bf 29,3f + stw rv,0(rp) + addi rp,rp,4 +3: + bf 30,4f + sth rv,0(rp) + addi rp,rp,2 +4: + bflr 31 + stb rv,0(rp) + blr + + +// *************** +// * M E M S E T * +// *************** + + .align 5 +_memset: // void * memset(void *b, int c, size_t len); + andi. rv,r4,0xFF // copy value to working register, test for 0 + mr rc,r5 // move length to working register + cmplwi cr1,r5,32 // length < 32 ? + beq Lbzero1 // memset of 0 is just a bzero + rlwimi rv,rv,8,16,23 // replicate value to low 2 bytes + mr rp,r3 // make working copy of operand ptr + rlwimi rv,rv,16,0,15 // value now in all 4 bytes + blt cr1,Ltail // length<32, so use common tail routine + neg r5,rp // start to compute #bytes to align + andi. r6,r5,0x7 // r6 <- #bytes to align on dw + beq- Lmemset1 // already aligned + + ; align on 8-byte boundary + + mtcrf 0x01,r6 // move count to cr7 (faster if only 1 cr) + sub rc,rc,r6 // adjust length + bf 31,1f + stb rv,0(rp) + addi rp,rp,1 +1: + bf 30,2f + sth rv,0(rp) + addi rp,rp,2 +2: + bf 29,Lmemset1 + stw rv,0(rp) + addi rp,rp,4 + + // loop on 16-byte blocks +Lmemset1: + stw rv,0(rp) // store first 8 bytes from rv + stw rv,4(rp) + srwi r5,rc,4 // r5 <- #blocks (>=1) + mtcrf 0x01,rc // leftover length to cr7 + mtctr r5 // set up loop count + lfd f0,0(rp) // pick up in a fp register + b 2f // enter loop in middle + .align 4 +1: // loop on 16-byte blocks + stfd f0,0(rp) +2: + stfd f0,8(rp) + addi rp,rp,16 + bdnz 1b + + // store up to 16 trailing bytes (count in cr7) + + bf 28,3f + stfd f0,0(rp) + addi rp,rp,8 +3: + bf 29,4f + stw rv,0(rp) + addi rp,rp,4 +4: + bf 30,5f + sth rv,0(rp) + addi rp,rp,2 +5: + bflr 31 + stb rv,0(rp) + blr diff --git a/gen.subproj/ppc.subproj/ecvt.c b/ppc/gen/ecvt.c old mode 100755 new mode 100644 similarity index 100% rename from gen.subproj/ppc.subproj/ecvt.c rename to ppc/gen/ecvt.c diff --git a/gen.subproj/ppc.subproj/ffs.s b/ppc/gen/ffs.s similarity index 100% rename from gen.subproj/ppc.subproj/ffs.s rename to ppc/gen/ffs.s diff --git a/gen.subproj/ppc.subproj/fp.h b/ppc/gen/fp.h old mode 100755 new mode 100644 similarity index 100% rename from gen.subproj/ppc.subproj/fp.h rename to ppc/gen/fp.h diff --git a/ppc/gen/genassym.c b/ppc/gen/genassym.c new file mode 100644 index 0000000..ca608b1 --- /dev/null +++ b/ppc/gen/genassym.c @@ -0,0 +1,205 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +#import +#import +#import +#import + +#import "genassym.h" + +#define NAME_LEN 30 + +char *progname; + +unsigned bit_num(char *reg_type, char *field, unsigned bits) +{ + unsigned bit; + unsigned mask; + + for (bit = 0, mask = 0x1; + (mask & bits) == 0 && mask; + mask <<= 1, bit += 1) + continue; + if (mask) + return bit; + fprintf(stderr, "%s: Bad BIT_POS for %s.%s\n", progname, + reg_type, field); + exit(1); +} + +unsigned field_width(char *reg_type, char *field, unsigned bits) +{ + unsigned width; + + while (bits && (bits & 0x1) == 0) + bits >>= 1; + for (width = 0; (bits & 0x1) == 1; bits >>= 1, width += 1) + continue; + if (bits == 0 && width) + return width; + fprintf(stderr, "%s: Bad BIT_FIELD for %s.%s\n", progname, + reg_type, field); + exit(1); +} + +unsigned log2(unsigned val, char *type) +{ + unsigned l2 = 0; + + if (val == 0) { + fprintf(stderr, "log2: sizeof(%s) is zero!\n", type); + exit(1); + } + while ((val & 0x1) == 0) { + l2 += 1; + val >>= 1; + } + if (val != 0x1) { + fprintf(stderr, "log2: sizeof(%s) is not power of two!\n", + type); + exit(1); + } + return l2; +} + +const char *skip_white(const char *cp) +{ + while (*cp && isspace(*cp)) + cp += 1; + return cp; +} + +const char *strip_prefix(const char *cp, const char *prefix) +{ + int len; + + cp = skip_white(cp); + len = strlen(prefix); + if (strncmp(cp, prefix, len) == 0 && isspace(*(cp+len))) + cp += len; + return cp; +} + +void +print_define(const char *prefix, const char *type_name, const char *field) +{ + const char *cp; + int col = 0; + + printf("#define\t"); + if (prefix != NULL && *prefix != '\0') { + printf("%s", prefix); + col += strlen(prefix); + } + if (type_name != NULL && *type_name != '\0') { + cp = strip_prefix(type_name, "struct"); + cp = strip_prefix(cp, "enum"); + cp = skip_white(cp); + if (*cp != '\0' && col != 0) { + putchar('_'); + col += 1; + } + for (; *cp != '\0'; cp++) { + if (isspace(*cp)) + break; + if (*cp == '*') + break; + if (strncmp(cp, "_t", 2) == 0 && !isalnum(cp[2])) + break; + putchar(isalpha(*cp) ? toupper(*cp) : *cp); + col += 1; + + } + } + if (field != NULL && *field != '\0') { + if (col != 0) { + putchar('_'); + col++; + } + for (cp = field; *cp != 0; cp++) { + if (*cp == '.') + putchar('_'); + else if (*cp == '[') + putchar('_'); + else if (*cp == ']') + continue; + else if (!isspace(*cp)) + putchar(isalpha(*cp) ? toupper(*cp) : *cp); + col++; + } + } + if (col == 0) { + fprintf(stderr, "%s: Bad call to print_define\n", progname); + exit(1); + } + do { + putchar(' '); + col += 1; + } while (col < NAME_LEN); +} + +void print_dec(int val) +{ + printf("%d\n", val); +} + +void print_hex(unsigned val) +{ + printf("%#010x\n", val); +} + +void print_str(const char *str) +{ + printf("%s\n", str); +} + +void comment(cmt_level_t level, const char *cmt) +{ + switch (level) { + case MAJOR: + printf("\n\n"); + printf("/*\n"); + printf(" * %s\n", cmt); + printf(" */\n"); + break; + case MINOR: + printf("\n"); + printf("/* %s */\n", cmt); + printf("\n"); + break; + default: + fprintf(stderr, "%s: Bad comment level\n", progname); + exit(1); + } +} + +void main(int argc, char **argv) +{ + progname = argv[0]; + + printf("/* assym.h -- generated by genassym */\n"); + printf("/* DON'T EDIT THIS -- change assymdefs.c */\n"); + + assymdefs(); + + exit(0); +} diff --git a/gen.subproj/ppc.subproj/genassym.h b/ppc/gen/genassym.h similarity index 100% rename from gen.subproj/ppc.subproj/genassym.h rename to ppc/gen/genassym.h diff --git a/gen.subproj/ppc.subproj/insque.c b/ppc/gen/insque.c similarity index 100% rename from gen.subproj/ppc.subproj/insque.c rename to ppc/gen/insque.c diff --git a/gen.subproj/ppc.subproj/isinf.c b/ppc/gen/isinf.c similarity index 100% rename from gen.subproj/ppc.subproj/isinf.c rename to ppc/gen/isinf.c diff --git a/gen.subproj/ppc.subproj/mcount.s b/ppc/gen/mcount.s similarity index 100% rename from gen.subproj/ppc.subproj/mcount.s rename to ppc/gen/mcount.s diff --git a/gen.subproj/ppc.subproj/remque.c b/ppc/gen/remque.c similarity index 100% rename from gen.subproj/ppc.subproj/remque.c rename to ppc/gen/remque.c diff --git a/gen.subproj/ppc.subproj/setjmperr.c b/ppc/gen/setjmperr.c old mode 100755 new mode 100644 similarity index 100% rename from gen.subproj/ppc.subproj/setjmperr.c rename to ppc/gen/setjmperr.c diff --git a/gen.subproj/ppc.subproj/strcat.c b/ppc/gen/strcat.c similarity index 100% rename from gen.subproj/ppc.subproj/strcat.c rename to ppc/gen/strcat.c diff --git a/ppc/gen/strcmp.c b/ppc/gen/strcmp.c new file mode 100644 index 0000000..b51e8a5 --- /dev/null +++ b/ppc/gen/strcmp.c @@ -0,0 +1,53 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* Copyright (c) 1992, 1997 NeXT Software, Inc. All rights reserved. + * + * File: libc/gen/ppc/strcmp.c + * + * This file contains machine dependent code for string comparison + * on NeXT 88K-based products. + * + * HISTORY + * 24-Jan-1997 Umesh Vaishampayan (umeshv@NeXT.com) + * Ported to PPC. + * 24-Nov-92 Derek B Clegg (dclegg@next.com) + * Created. + */ +#import + +/* This routine should be optimized. */ + +/* ANSI sez: + * The `strcmp' function compares the string pointed to by `s1' to the + * string pointed to by `s2'. + * The `strcmp' function returns an integer greater than, equal to, or less + * than zero, according as the string pointed to by `s1' is greater than, + * equal to, or less than the string pointed to by `s2'. [4.11.4.2] + */ +int +strcmp(const char *s1, const char *s2) +{ + for ( ; *s1 == *s2; s1++, s2++) + if (*s1 == '\0') + return 0; + return ((*(unsigned char *)s1 < *(unsigned char *)s2) ? -1 : +1); +} diff --git a/gen.subproj/ppc.subproj/strcpy.c b/ppc/gen/strcpy.c similarity index 100% rename from gen.subproj/ppc.subproj/strcpy.c rename to ppc/gen/strcpy.c diff --git a/ppc/gen/strlen.s b/ppc/gen/strlen.s new file mode 100644 index 0000000..a633cf7 --- /dev/null +++ b/ppc/gen/strlen.s @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2000-2001 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +; +; +; Strlen, optimized for PPC. The routine we use is 2-3x faster +; then the simple loop which checks each byte for zero. +; For 0- and 1-byte strings, the simple routine is faster, but +; only by a few cycles. The algorithm used was adapted from the +; Mac OS 9 stdCLib strcopy routine, which was originally +; written by Gary Davidian. It relies on the following rather +; inobvious but very efficient test: +; +; y = dataWord + 0xFEFEFEFF +; z = ~dataWord & 0x80808080 +; if ( y & z ) = 0 then all bytes in dataWord are non-zero +; +; The test maps any non-zero byte to zeros and any zero byte to 0x80, +; with one exception: 0x01 bytes preceeding the first zero are also +; mapped to 0x80. +; +#include +; +; int strlen(ptr) +; +; + + .align 5 + .globl EXT(strlen) +LEXT(strlen) + + andi. r4,r3,0x03 ; test alignment first + mr r9,r3 ; store the original address for later use.... + bne LalignSource ; align the source addr if not already aligned +Llentry: + lis r5,hi16(0xFEFEFEFF) + lis r6,hi16(0x80808080) + subi r3,r3,0x04 ; pre-decrement r3 for the lwzu + ori r5,r5,lo16(0xFEFEFEFF) ; r5=0xFEFEFEFF + ori r6,r6,lo16(0x80808080) ; r6=0x80808080 + +LLoop: + lwzu r8,4(r3) ; get the first 4 bytes and increment address + add r4,r5,r8 ; r4= data + 0xFEFEFEFF + andc r7,r6,r8 ; r7= ~data & 0x80808080 + and. r4,r4,r7 ; r4= r4 & r7 + beq LLoop ; if r4 is zero, then all bytes are non-zero + +; Now we know one of the bytes in r8 is zero, +; we just have to figure out which one. +; We have mapped 0 bytes to 0x80, and nonzero bytes to 0x00, +; with one exception: +; 0x01 bytes preceeding the first zero are also mapped to 0x80. +; So we have to mask out the 0x80s caused by 0x01s before +; counting leading zeroes to get the bytes in last word. + + rlwinm r5,r8,7,0,31 ; move 0x01 bits to 0x80 position + subf r3,r9,r3 ; start to compute string length + andc r4,r4,r5 ; turn off false hits from 0x0100 worst case + cntlzw r7,r4 ; now we can count leading 0s + srwi r7,r7,3 ; convert 0,8,16,24 to 0,1,2,3 + add r3,r3,r7 ; add in nonzero bytes in last word + blr + +; We must align the source address for two reasons: to avoid spurious page +; faults, and for speed. +; r4 = low 2 bits of address (1,2, or 3) +; r3 = address +; r9 = original address (still same as r3) + +LalignSource: + lbz r5,0(r3) ; get the first byte... + subic. r4,r4,2 ; test for 1, 2 or 3 bytes + addi r3,r3,1 ; increment address + addi r6,r9,1 ; now r6==r3 + cmpwi cr1,r5,0 ; zero? + beq cr1,Lreturn ; if its zero return zero + bgt Llentry ; address is aligned now if low bits were 3 + + lbz r5,0(r3) ; get the next byte... + addi r3,r3,1 ; increment address + cmpwi cr1,r5,0 ; zero? + beq cr1,Lreturn ; if its zero return one + beq Llentry ; addr is aligned now if low bits were 2 + + lbz r5,0(r3) ; get the next byte... + addi r3,r3,1 ; increment address + cmpwi cr1,r5,0 ; zero? + bne cr1,Llentry ; not zero, continue check (now aligned) +Lreturn: + sub r3,r3,r6 ; get string length (0, 1, or 2) + blr + diff --git a/gen.subproj/ppc.subproj/strncat.c b/ppc/gen/strncat.c similarity index 100% rename from gen.subproj/ppc.subproj/strncat.c rename to ppc/gen/strncat.c diff --git a/gen.subproj/ppc.subproj/strncmp.c b/ppc/gen/strncmp.c similarity index 100% rename from gen.subproj/ppc.subproj/strncmp.c rename to ppc/gen/strncmp.c diff --git a/gen.subproj/ppc.subproj/strncpy.c b/ppc/gen/strncpy.c similarity index 100% rename from gen.subproj/ppc.subproj/strncpy.c rename to ppc/gen/strncpy.c diff --git a/ppc/mach/Makefile.inc b/ppc/mach/Makefile.inc new file mode 100644 index 0000000..e35f6ab --- /dev/null +++ b/ppc/mach/Makefile.inc @@ -0,0 +1 @@ +SRCS += mach_absolute_time.s diff --git a/ppc/mach/mach_absolute_time.s b/ppc/mach/mach_absolute_time.s new file mode 100644 index 0000000..7ed2293 --- /dev/null +++ b/ppc/mach/mach_absolute_time.s @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2002 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#if defined(__ppc__) +.text +.align 2 +.globl _mach_absolute_time +_mach_absolute_time: +1: mftbu r3 + mftb r4 + mftbu r0 + cmpw r0,r3 + bne- 1b + blr +#endif diff --git a/sys.subproj/ppc.subproj/ATPgetreq.s b/ppc/sys/ATPgetreq.s similarity index 100% rename from sys.subproj/ppc.subproj/ATPgetreq.s rename to ppc/sys/ATPgetreq.s diff --git a/sys.subproj/ppc.subproj/ATPgetrsp.s b/ppc/sys/ATPgetrsp.s similarity index 100% rename from sys.subproj/ppc.subproj/ATPgetrsp.s rename to ppc/sys/ATPgetrsp.s diff --git a/sys.subproj/ppc.subproj/ATPsndreq.s b/ppc/sys/ATPsndreq.s similarity index 100% rename from sys.subproj/ppc.subproj/ATPsndreq.s rename to ppc/sys/ATPsndreq.s diff --git a/sys.subproj/ppc.subproj/ATPsndrsp.s b/ppc/sys/ATPsndrsp.s similarity index 100% rename from sys.subproj/ppc.subproj/ATPsndrsp.s rename to ppc/sys/ATPsndrsp.s diff --git a/sys.subproj/ppc.subproj/ATgetmsg.s b/ppc/sys/ATgetmsg.s similarity index 100% rename from sys.subproj/ppc.subproj/ATgetmsg.s rename to ppc/sys/ATgetmsg.s diff --git a/sys.subproj/ppc.subproj/ATputmsg.s b/ppc/sys/ATputmsg.s similarity index 100% rename from sys.subproj/ppc.subproj/ATputmsg.s rename to ppc/sys/ATputmsg.s diff --git a/sys.subproj/ppc.subproj/ATsocket.s b/ppc/sys/ATsocket.s similarity index 100% rename from sys.subproj/ppc.subproj/ATsocket.s rename to ppc/sys/ATsocket.s diff --git a/ppc/sys/Makefile.inc b/ppc/sys/Makefile.inc new file mode 100644 index 0000000..1338cea --- /dev/null +++ b/ppc/sys/Makefile.inc @@ -0,0 +1,195 @@ +SRCS+= ATPgetreq.s \ + ATPgetrsp.s \ + ATPsndreq.s \ + ATPsndrsp.s \ + ATgetmsg.s \ + ATputmsg.s \ + ATsocket.s \ + _exit.s \ + _getlogin.s \ + _longjmp.s \ + _pthread_kill.s \ + _setjmp.s \ + _setlogin.s \ + _sysctl.s \ + accept.s \ + access.s \ + acct.s \ + add_profil.s \ + adjtime.s \ + bind.s \ + cerror.s \ + chdir.s \ + checkuseraccess.s \ + chflags.s \ + chmod.s \ + chown.s \ + chroot.s \ + close.s \ + connect.s \ + cthread.s \ + dup.s \ + dup2.s \ + exchangedata.s \ + execve.s \ + fchdir.s \ + fchflags.s \ + fchmod.s \ + fchown.s \ + fcntl.s \ + flock.s \ + fork.s \ + fpathconf.s \ + fstat.s \ + fstatfs.s \ + fstatv.s \ + fsync.s \ + ftruncate.s \ + futimes.s \ + getattrlist.s \ + getdirentries.s \ + getdirentriesattr.s \ + getegid.s \ + geteuid.s \ + getfh.s \ + getfsstat.s \ + getgid.s \ + getgroups.s \ + getitimer.s \ + getpeername.s \ + getpgrp.s \ + getpgid.s \ + getpid.s \ + getppid.s \ + getpriority.s \ + getrlimit.s \ + getrusage.s \ + getsid.s \ + getsockname.s \ + getsockopt.s \ + ppc_gettimeofday.s \ + getuid.s \ + ioctl.s \ + issetugid.s \ + kill.s \ + ktrace.s \ + link.s \ + listen.s \ + load_shared_file.s \ + longjmp.s \ + lseek.s \ + lstat.s \ + lstatv.s \ + madvise.s \ + mincore.s \ + minherit.s \ + mkcomplex.s \ + mkdir.s \ + mkfifo.s \ + mknod.s \ + mlock.s \ + mlockall.s \ + mmap.s \ + mount.s \ + mprotect.s \ + msgctl.s \ + msgget.s \ + msgrcv.s \ + msgsnd.s \ + msgsys.s \ + msync.s \ + munlock.s \ + munlockall.s \ + munmap.s \ + new_system_shared_regions.s \ + nfssvc.s \ + open.s \ + pathconf.s \ + pipe.s \ + posix_madvise.s \ + processor_facilities.s \ + pread.s \ + profil.s \ + pwrite.s \ + ptrace.s \ + pthread_sigmask.s \ + quota.s \ + quotactl.s \ + read.s \ + readlink.s \ + readv.s \ + reboot.s \ + recvfrom.s \ + recvmsg.s \ + rename.s \ + reset_shared_file.s \ + revoke.s \ + rmdir.s \ + searchfs.s \ + select.s \ + sem_close.s \ + sem_destroy.s \ + sem_getvalue.s \ + sem_init.s \ + sem_open.s \ + sem_post.s \ + sem_trywait.s \ + sem_unlink.s \ + sem_wait.s \ + semconfig.s \ + semctl.s \ + semget.s \ + semop.s \ + semsys.s \ + sendmsg.s \ + sendto.s \ + setattrlist.s \ + setegid.s \ + seteuid.s \ + setgid.s \ + setgroups.s \ + setitimer.s \ + setjmp.s \ + setpgid.s \ + setpriority.s \ + setprivexec.s \ + setquota.s \ + setrlimit.s \ + setsid.s \ + setsockopt.s \ + settimeofday.s \ + setuid.s \ + shm_open.s \ + shm_unlink.s \ + shmat.s \ + shmctl.s \ + shmdt.s \ + shmget.s \ + shmsys.s \ + shutdown.s \ + sigaltstack.s \ + sigpending.s \ + sigprocmask.s \ + sigreturn.s \ + sigwait.s \ + socket.s \ + socketpair.s \ + stat.s \ + statfs.s \ + statv.s \ + swapon.s \ + symlink.s \ + sync.s \ + syscall.s \ + systable.s \ + truncate.s \ + umask.s \ + undelete.s \ + unlink.s \ + unmount.s \ + ur_cthread.s \ + utimes.s \ + vfork.s \ + wait4.s \ + write.s \ + writev.s diff --git a/sys.subproj/ppc.subproj/SYS.h b/ppc/sys/SYS.h similarity index 100% rename from sys.subproj/ppc.subproj/SYS.h rename to ppc/sys/SYS.h diff --git a/sys.subproj/ppc.subproj/_exit.s b/ppc/sys/_exit.s similarity index 100% rename from sys.subproj/ppc.subproj/_exit.s rename to ppc/sys/_exit.s diff --git a/sys.subproj/ppc.subproj/_getlogin.s b/ppc/sys/_getlogin.s similarity index 100% rename from sys.subproj/ppc.subproj/_getlogin.s rename to ppc/sys/_getlogin.s diff --git a/sys.subproj/ppc.subproj/_longjmp.s b/ppc/sys/_longjmp.s similarity index 100% rename from sys.subproj/ppc.subproj/_longjmp.s rename to ppc/sys/_longjmp.s diff --git a/ppc/sys/_pthread_kill.s b/ppc/sys/_pthread_kill.s new file mode 100644 index 0000000..22a9562 --- /dev/null +++ b/ppc/sys/_pthread_kill.s @@ -0,0 +1,26 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +#include "SYS.h" + +SYSCALL(__pthread_kill, 2) + blr + diff --git a/sys.subproj/ppc.subproj/_setjmp.h b/ppc/sys/_setjmp.h similarity index 100% rename from sys.subproj/ppc.subproj/_setjmp.h rename to ppc/sys/_setjmp.h diff --git a/sys.subproj/ppc.subproj/_setjmp.s b/ppc/sys/_setjmp.s similarity index 100% rename from sys.subproj/ppc.subproj/_setjmp.s rename to ppc/sys/_setjmp.s diff --git a/sys.subproj/ppc.subproj/_setlogin.s b/ppc/sys/_setlogin.s similarity index 100% rename from sys.subproj/ppc.subproj/_setlogin.s rename to ppc/sys/_setlogin.s diff --git a/sys.subproj/ppc.subproj/_sysctl.s b/ppc/sys/_sysctl.s similarity index 100% rename from sys.subproj/ppc.subproj/_sysctl.s rename to ppc/sys/_sysctl.s diff --git a/sys.subproj/ppc.subproj/accept.s b/ppc/sys/accept.s similarity index 100% rename from sys.subproj/ppc.subproj/accept.s rename to ppc/sys/accept.s diff --git a/sys.subproj/ppc.subproj/access.s b/ppc/sys/access.s similarity index 100% rename from sys.subproj/ppc.subproj/access.s rename to ppc/sys/access.s diff --git a/sys.subproj/ppc.subproj/acct.s b/ppc/sys/acct.s similarity index 100% rename from sys.subproj/ppc.subproj/acct.s rename to ppc/sys/acct.s diff --git a/sys.subproj/ppc.subproj/add_profil.s b/ppc/sys/add_profil.s similarity index 100% rename from sys.subproj/ppc.subproj/add_profil.s rename to ppc/sys/add_profil.s diff --git a/sys.subproj/ppc.subproj/adjtime.s b/ppc/sys/adjtime.s similarity index 100% rename from sys.subproj/ppc.subproj/adjtime.s rename to ppc/sys/adjtime.s diff --git a/sys.subproj/ppc.subproj/assym.h b/ppc/sys/assym.h similarity index 100% rename from sys.subproj/ppc.subproj/assym.h rename to ppc/sys/assym.h diff --git a/ppc/sys/assymdefs.c b/ppc/sys/assymdefs.c new file mode 100644 index 0000000..685b750 --- /dev/null +++ b/ppc/sys/assymdefs.c @@ -0,0 +1,128 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * assymdefs.c -- list of symbols to #define in assym.h + */ + +#import +#import + +#define __TARGET_ARCHITECTURE__ "ppc" +#import +#import "sigcatch.h" + +#import "genassym.h" + +void +assymdefs(void) +{ + comment(MAJOR, "Structure Offsets"); + + comment(MINOR, "struct sigcontext offsets and sizes"); + PRINT_SIZEOF(struct sigcontext); + PRINT_OFFSET(struct sigcontext *, sc_regs_saved); + PRINT_OFFSET(struct sigcontext *, sc_sp); + PRINT_OFFSET(struct sigcontext *, sc_cia); + PRINT_OFFSET(struct sigcontext *, sc_a0); + PRINT_OFFSET(struct sigcontext *, sc_a1); + PRINT_OFFSET(struct sigcontext *, sc_a2); + PRINT_OFFSET(struct sigcontext *, sc_ep); + PRINT_OFFSET(struct sigcontext *, sc_mq); + PRINT_OFFSET(struct sigcontext *, sc_lr); + PRINT_OFFSET(struct sigcontext *, sc_cr); + PRINT_OFFSET(struct sigcontext *, sc_ctr); + PRINT_OFFSET(struct sigcontext *, sc_xer); + PRINT_OFFSET(struct sigcontext *, sc_fpscr); + PRINT_OFFSET(struct sigcontext *, sc_zt); + PRINT_OFFSET(struct sigcontext *, sc_a3); + PRINT_OFFSET(struct sigcontext *, sc_a4); + PRINT_OFFSET(struct sigcontext *, sc_a5); + PRINT_OFFSET(struct sigcontext *, sc_a6); + PRINT_OFFSET(struct sigcontext *, sc_a7); + PRINT_OFFSET(struct sigcontext *, sc_at); + PRINT_OFFSET(struct sigcontext *, sc_ft0); + PRINT_OFFSET(struct sigcontext *, sc_fa0); + PRINT_OFFSET(struct sigcontext *, sc_fa1); + PRINT_OFFSET(struct sigcontext *, sc_fa2); + PRINT_OFFSET(struct sigcontext *, sc_fa3); + PRINT_OFFSET(struct sigcontext *, sc_fa4); + PRINT_OFFSET(struct sigcontext *, sc_fa5); + PRINT_OFFSET(struct sigcontext *, sc_fa6); + PRINT_OFFSET(struct sigcontext *, sc_fa7); + PRINT_OFFSET(struct sigcontext *, sc_fa8); + PRINT_OFFSET(struct sigcontext *, sc_fa9); + PRINT_OFFSET(struct sigcontext *, sc_fa10); + PRINT_OFFSET(struct sigcontext *, sc_fa11); + PRINT_OFFSET(struct sigcontext *, sc_fa12); + PRINT_OFFSET(struct sigcontext *, sc_s17); + PRINT_OFFSET(struct sigcontext *, sc_s16); + PRINT_OFFSET(struct sigcontext *, sc_s15); + PRINT_OFFSET(struct sigcontext *, sc_s14); + PRINT_OFFSET(struct sigcontext *, sc_s13); + PRINT_OFFSET(struct sigcontext *, sc_s12); + PRINT_OFFSET(struct sigcontext *, sc_s11); + PRINT_OFFSET(struct sigcontext *, sc_s10); + PRINT_OFFSET(struct sigcontext *, sc_s9); + PRINT_OFFSET(struct sigcontext *, sc_s8); + PRINT_OFFSET(struct sigcontext *, sc_s7); + PRINT_OFFSET(struct sigcontext *, sc_s6); + PRINT_OFFSET(struct sigcontext *, sc_s5); + PRINT_OFFSET(struct sigcontext *, sc_s4); + PRINT_OFFSET(struct sigcontext *, sc_s3); + PRINT_OFFSET(struct sigcontext *, sc_s2); + PRINT_OFFSET(struct sigcontext *, sc_s1); + PRINT_OFFSET(struct sigcontext *, sc_s0); + PRINT_OFFSET(struct sigcontext *, sc_toc); + PRINT_OFFSET(struct sigcontext *, sc_fp); + PRINT_OFFSET(struct sigcontext *, sc_fs17); + PRINT_OFFSET(struct sigcontext *, sc_fs16); + PRINT_OFFSET(struct sigcontext *, sc_fs15); + PRINT_OFFSET(struct sigcontext *, sc_fs14); + PRINT_OFFSET(struct sigcontext *, sc_fs13); + PRINT_OFFSET(struct sigcontext *, sc_fs12); + PRINT_OFFSET(struct sigcontext *, sc_fs11); + PRINT_OFFSET(struct sigcontext *, sc_fs10); + PRINT_OFFSET(struct sigcontext *, sc_fs9); + PRINT_OFFSET(struct sigcontext *, sc_fs8); + PRINT_OFFSET(struct sigcontext *, sc_fs7); + PRINT_OFFSET(struct sigcontext *, sc_fs6); + PRINT_OFFSET(struct sigcontext *, sc_fs5); + PRINT_OFFSET(struct sigcontext *, sc_fs4); + PRINT_OFFSET(struct sigcontext *, sc_fs3); + PRINT_OFFSET(struct sigcontext *, sc_fs2); + PRINT_OFFSET(struct sigcontext *, sc_fs1); + PRINT_OFFSET(struct sigcontext *, sc_fs0); + PRINT_ENUM(REGS_SAVED_NONE); + PRINT_ENUM(REGS_SAVED_CALLER); + PRINT_ENUM(REGS_SAVED_ALL); + + comment(MINOR, "struct sigstack offsets and sizes"); + PRINT_SIZEOF(struct sigstack); + PRINT_OFFSET(struct sigstack *, ss_sp); + PRINT_OFFSET(struct sigstack *, ss_onstack); + + comment(MINOR, "sigcatch_t offsets"); + PRINT_SIZEOF(sigcatch_t); + PRINT_OFFSET(sigcatch_t *, handler); +// PRINT_OFFSET(sigcatch_t *, flags); + PRINT_CONSTANT(SV_SAVE_REGS); +} diff --git a/sys.subproj/ppc.subproj/bind.s b/ppc/sys/bind.s similarity index 100% rename from sys.subproj/ppc.subproj/bind.s rename to ppc/sys/bind.s diff --git a/sys.subproj/ppc.subproj/cerror.s b/ppc/sys/cerror.s similarity index 100% rename from sys.subproj/ppc.subproj/cerror.s rename to ppc/sys/cerror.s diff --git a/sys.subproj/ppc.subproj/chdir.s b/ppc/sys/chdir.s similarity index 100% rename from sys.subproj/ppc.subproj/chdir.s rename to ppc/sys/chdir.s diff --git a/sys.subproj/ppc.subproj/checkuseraccess.s b/ppc/sys/checkuseraccess.s similarity index 100% rename from sys.subproj/ppc.subproj/checkuseraccess.s rename to ppc/sys/checkuseraccess.s diff --git a/sys.subproj/ppc.subproj/chflags.s b/ppc/sys/chflags.s similarity index 100% rename from sys.subproj/ppc.subproj/chflags.s rename to ppc/sys/chflags.s diff --git a/sys.subproj/ppc.subproj/chmod.s b/ppc/sys/chmod.s similarity index 100% rename from sys.subproj/ppc.subproj/chmod.s rename to ppc/sys/chmod.s diff --git a/sys.subproj/ppc.subproj/chown.s b/ppc/sys/chown.s similarity index 100% rename from sys.subproj/ppc.subproj/chown.s rename to ppc/sys/chown.s diff --git a/sys.subproj/ppc.subproj/chroot.s b/ppc/sys/chroot.s similarity index 100% rename from sys.subproj/ppc.subproj/chroot.s rename to ppc/sys/chroot.s diff --git a/sys.subproj/ppc.subproj/close.s b/ppc/sys/close.s similarity index 100% rename from sys.subproj/ppc.subproj/close.s rename to ppc/sys/close.s diff --git a/sys.subproj/ppc.subproj/connect.s b/ppc/sys/connect.s similarity index 100% rename from sys.subproj/ppc.subproj/connect.s rename to ppc/sys/connect.s diff --git a/sys.subproj/ppc.subproj/cthread.s b/ppc/sys/cthread.s similarity index 100% rename from sys.subproj/ppc.subproj/cthread.s rename to ppc/sys/cthread.s diff --git a/sys.subproj/ppc.subproj/dup.s b/ppc/sys/dup.s similarity index 100% rename from sys.subproj/ppc.subproj/dup.s rename to ppc/sys/dup.s diff --git a/sys.subproj/ppc.subproj/dup2.s b/ppc/sys/dup2.s similarity index 100% rename from sys.subproj/ppc.subproj/dup2.s rename to ppc/sys/dup2.s diff --git a/sys.subproj/ppc.subproj/exchangedata.s b/ppc/sys/exchangedata.s similarity index 100% rename from sys.subproj/ppc.subproj/exchangedata.s rename to ppc/sys/exchangedata.s diff --git a/sys.subproj/ppc.subproj/execve.s b/ppc/sys/execve.s similarity index 100% rename from sys.subproj/ppc.subproj/execve.s rename to ppc/sys/execve.s diff --git a/sys.subproj/ppc.subproj/fchdir.s b/ppc/sys/fchdir.s similarity index 100% rename from sys.subproj/ppc.subproj/fchdir.s rename to ppc/sys/fchdir.s diff --git a/sys.subproj/ppc.subproj/fchflags.s b/ppc/sys/fchflags.s similarity index 100% rename from sys.subproj/ppc.subproj/fchflags.s rename to ppc/sys/fchflags.s diff --git a/sys.subproj/ppc.subproj/fchmod.s b/ppc/sys/fchmod.s similarity index 100% rename from sys.subproj/ppc.subproj/fchmod.s rename to ppc/sys/fchmod.s diff --git a/sys.subproj/ppc.subproj/fchown.s b/ppc/sys/fchown.s similarity index 100% rename from sys.subproj/ppc.subproj/fchown.s rename to ppc/sys/fchown.s diff --git a/sys.subproj/ppc.subproj/fcntl.s b/ppc/sys/fcntl.s similarity index 100% rename from sys.subproj/ppc.subproj/fcntl.s rename to ppc/sys/fcntl.s diff --git a/sys.subproj/ppc.subproj/flock.s b/ppc/sys/flock.s similarity index 100% rename from sys.subproj/ppc.subproj/flock.s rename to ppc/sys/flock.s diff --git a/sys.subproj/ppc.subproj/fork.s b/ppc/sys/fork.s similarity index 97% rename from sys.subproj/ppc.subproj/fork.s rename to ppc/sys/fork.s index 6df807e..fc038ab 100644 --- a/sys.subproj/ppc.subproj/fork.s +++ b/ppc/sys/fork.s @@ -82,6 +82,8 @@ LC3: mtspr ctr,r3 bctrl #endif + li r3,0x0 // clear cached pid in child + REG_TO_EXTERN(r3,__current_pid) CALL_EXTERN(_fork_mach_init) CALL_EXTERN(__cthread_fork_child) #if defined(__DYNAMIC__) diff --git a/sys.subproj/ppc.subproj/fpathconf.s b/ppc/sys/fpathconf.s similarity index 100% rename from sys.subproj/ppc.subproj/fpathconf.s rename to ppc/sys/fpathconf.s diff --git a/sys.subproj/ppc.subproj/fstat.s b/ppc/sys/fstat.s similarity index 100% rename from sys.subproj/ppc.subproj/fstat.s rename to ppc/sys/fstat.s diff --git a/sys.subproj/ppc.subproj/fstatfs.s b/ppc/sys/fstatfs.s similarity index 100% rename from sys.subproj/ppc.subproj/fstatfs.s rename to ppc/sys/fstatfs.s diff --git a/sys.subproj/ppc.subproj/fstatv.s b/ppc/sys/fstatv.s similarity index 100% rename from sys.subproj/ppc.subproj/fstatv.s rename to ppc/sys/fstatv.s diff --git a/sys.subproj/ppc.subproj/fsync.s b/ppc/sys/fsync.s similarity index 100% rename from sys.subproj/ppc.subproj/fsync.s rename to ppc/sys/fsync.s diff --git a/sys.subproj/ppc.subproj/ftruncate.s b/ppc/sys/ftruncate.s similarity index 100% rename from sys.subproj/ppc.subproj/ftruncate.s rename to ppc/sys/ftruncate.s diff --git a/sys.subproj/ppc.subproj/lfs_bmapv.s b/ppc/sys/futimes.s similarity index 97% rename from sys.subproj/ppc.subproj/lfs_bmapv.s rename to ppc/sys/futimes.s index 24c4507..478a8af 100644 --- a/sys.subproj/ppc.subproj/lfs_bmapv.s +++ b/ppc/sys/futimes.s @@ -21,5 +21,6 @@ */ #include "SYS.h" -SYSCALL(lfs_bmapv, 2) +SYSCALL(futimes, 2) blr + diff --git a/ppc/sys/genassym.c b/ppc/sys/genassym.c new file mode 100644 index 0000000..ca608b1 --- /dev/null +++ b/ppc/sys/genassym.c @@ -0,0 +1,205 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +#import +#import +#import +#import + +#import "genassym.h" + +#define NAME_LEN 30 + +char *progname; + +unsigned bit_num(char *reg_type, char *field, unsigned bits) +{ + unsigned bit; + unsigned mask; + + for (bit = 0, mask = 0x1; + (mask & bits) == 0 && mask; + mask <<= 1, bit += 1) + continue; + if (mask) + return bit; + fprintf(stderr, "%s: Bad BIT_POS for %s.%s\n", progname, + reg_type, field); + exit(1); +} + +unsigned field_width(char *reg_type, char *field, unsigned bits) +{ + unsigned width; + + while (bits && (bits & 0x1) == 0) + bits >>= 1; + for (width = 0; (bits & 0x1) == 1; bits >>= 1, width += 1) + continue; + if (bits == 0 && width) + return width; + fprintf(stderr, "%s: Bad BIT_FIELD for %s.%s\n", progname, + reg_type, field); + exit(1); +} + +unsigned log2(unsigned val, char *type) +{ + unsigned l2 = 0; + + if (val == 0) { + fprintf(stderr, "log2: sizeof(%s) is zero!\n", type); + exit(1); + } + while ((val & 0x1) == 0) { + l2 += 1; + val >>= 1; + } + if (val != 0x1) { + fprintf(stderr, "log2: sizeof(%s) is not power of two!\n", + type); + exit(1); + } + return l2; +} + +const char *skip_white(const char *cp) +{ + while (*cp && isspace(*cp)) + cp += 1; + return cp; +} + +const char *strip_prefix(const char *cp, const char *prefix) +{ + int len; + + cp = skip_white(cp); + len = strlen(prefix); + if (strncmp(cp, prefix, len) == 0 && isspace(*(cp+len))) + cp += len; + return cp; +} + +void +print_define(const char *prefix, const char *type_name, const char *field) +{ + const char *cp; + int col = 0; + + printf("#define\t"); + if (prefix != NULL && *prefix != '\0') { + printf("%s", prefix); + col += strlen(prefix); + } + if (type_name != NULL && *type_name != '\0') { + cp = strip_prefix(type_name, "struct"); + cp = strip_prefix(cp, "enum"); + cp = skip_white(cp); + if (*cp != '\0' && col != 0) { + putchar('_'); + col += 1; + } + for (; *cp != '\0'; cp++) { + if (isspace(*cp)) + break; + if (*cp == '*') + break; + if (strncmp(cp, "_t", 2) == 0 && !isalnum(cp[2])) + break; + putchar(isalpha(*cp) ? toupper(*cp) : *cp); + col += 1; + + } + } + if (field != NULL && *field != '\0') { + if (col != 0) { + putchar('_'); + col++; + } + for (cp = field; *cp != 0; cp++) { + if (*cp == '.') + putchar('_'); + else if (*cp == '[') + putchar('_'); + else if (*cp == ']') + continue; + else if (!isspace(*cp)) + putchar(isalpha(*cp) ? toupper(*cp) : *cp); + col++; + } + } + if (col == 0) { + fprintf(stderr, "%s: Bad call to print_define\n", progname); + exit(1); + } + do { + putchar(' '); + col += 1; + } while (col < NAME_LEN); +} + +void print_dec(int val) +{ + printf("%d\n", val); +} + +void print_hex(unsigned val) +{ + printf("%#010x\n", val); +} + +void print_str(const char *str) +{ + printf("%s\n", str); +} + +void comment(cmt_level_t level, const char *cmt) +{ + switch (level) { + case MAJOR: + printf("\n\n"); + printf("/*\n"); + printf(" * %s\n", cmt); + printf(" */\n"); + break; + case MINOR: + printf("\n"); + printf("/* %s */\n", cmt); + printf("\n"); + break; + default: + fprintf(stderr, "%s: Bad comment level\n", progname); + exit(1); + } +} + +void main(int argc, char **argv) +{ + progname = argv[0]; + + printf("/* assym.h -- generated by genassym */\n"); + printf("/* DON'T EDIT THIS -- change assymdefs.c */\n"); + + assymdefs(); + + exit(0); +} diff --git a/sys.subproj/ppc.subproj/genassym.h b/ppc/sys/genassym.h similarity index 100% rename from sys.subproj/ppc.subproj/genassym.h rename to ppc/sys/genassym.h diff --git a/sys.subproj/ppc.subproj/getattrlist.s b/ppc/sys/getattrlist.s similarity index 100% rename from sys.subproj/ppc.subproj/getattrlist.s rename to ppc/sys/getattrlist.s diff --git a/sys.subproj/ppc.subproj/getdirentries.s b/ppc/sys/getdirentries.s similarity index 100% rename from sys.subproj/ppc.subproj/getdirentries.s rename to ppc/sys/getdirentries.s diff --git a/sys.subproj/ppc.subproj/getdirentriesattr.s b/ppc/sys/getdirentriesattr.s similarity index 100% rename from sys.subproj/ppc.subproj/getdirentriesattr.s rename to ppc/sys/getdirentriesattr.s diff --git a/sys.subproj/ppc.subproj/getegid.s b/ppc/sys/getegid.s similarity index 100% rename from sys.subproj/ppc.subproj/getegid.s rename to ppc/sys/getegid.s diff --git a/sys.subproj/ppc.subproj/geteuid.s b/ppc/sys/geteuid.s similarity index 100% rename from sys.subproj/ppc.subproj/geteuid.s rename to ppc/sys/geteuid.s diff --git a/sys.subproj/ppc.subproj/getfh.s b/ppc/sys/getfh.s similarity index 100% rename from sys.subproj/ppc.subproj/getfh.s rename to ppc/sys/getfh.s diff --git a/sys.subproj/ppc.subproj/getfsstat.s b/ppc/sys/getfsstat.s similarity index 100% rename from sys.subproj/ppc.subproj/getfsstat.s rename to ppc/sys/getfsstat.s diff --git a/sys.subproj/ppc.subproj/getgid.s b/ppc/sys/getgid.s similarity index 100% rename from sys.subproj/ppc.subproj/getgid.s rename to ppc/sys/getgid.s diff --git a/sys.subproj/ppc.subproj/getgroups.s b/ppc/sys/getgroups.s similarity index 100% rename from sys.subproj/ppc.subproj/getgroups.s rename to ppc/sys/getgroups.s diff --git a/sys.subproj/ppc.subproj/getitimer.s b/ppc/sys/getitimer.s similarity index 100% rename from sys.subproj/ppc.subproj/getitimer.s rename to ppc/sys/getitimer.s diff --git a/sys.subproj/ppc.subproj/getpeername.s b/ppc/sys/getpeername.s similarity index 100% rename from sys.subproj/ppc.subproj/getpeername.s rename to ppc/sys/getpeername.s diff --git a/sys.subproj/ppc.subproj/lfs_markv.s b/ppc/sys/getpgid.s similarity index 97% rename from sys.subproj/ppc.subproj/lfs_markv.s rename to ppc/sys/getpgid.s index dbb69c9..fb6a4e4 100644 --- a/sys.subproj/ppc.subproj/lfs_markv.s +++ b/ppc/sys/getpgid.s @@ -21,5 +21,6 @@ */ #include "SYS.h" -SYSCALL(lfs_markv, 2) +SYSCALL(getpgid, 1) blr + diff --git a/sys.subproj/ppc.subproj/getpgrp.s b/ppc/sys/getpgrp.s similarity index 100% rename from sys.subproj/ppc.subproj/getpgrp.s rename to ppc/sys/getpgrp.s diff --git a/ppc/sys/getpid.s b/ppc/sys/getpid.s new file mode 100644 index 0000000..02e2b59 --- /dev/null +++ b/ppc/sys/getpid.s @@ -0,0 +1,53 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +#include "SYS.h" + .data + EXPORT(__current_pid) + .long 0 + +TEXT +LEAF(_getpid) +#if defined(__DYNAMIC__) + mflr r0 + bcl 20,31,1f +1: + mflr r5 + mtlr r0 + addis r5, r5, ha16(__current_pid - 1b) + addi r5, r5, lo16(__current_pid - 1b) +#else + lis r5,ha16(__current_pid) + ori r5,r5,lo16(__current_pid) +#endif + lwz r3,0(r5) // get the cached pid + cmpwi r3,0 // if positive, + bgtlr+ // return it + + SYSCALL_NONAME(getpid, 0) + + lwarx r4,0,r5 // see if we can cache it + cmpwi r4,0 // we cant if there are any + bltlr- // vforks in progress + + stwcx. r3,0,r5 // ignore cache conflicts + blr +END(_getpid) diff --git a/sys.subproj/ppc.subproj/getppid.s b/ppc/sys/getppid.s similarity index 100% rename from sys.subproj/ppc.subproj/getppid.s rename to ppc/sys/getppid.s diff --git a/sys.subproj/ppc.subproj/getpriority.s b/ppc/sys/getpriority.s similarity index 100% rename from sys.subproj/ppc.subproj/getpriority.s rename to ppc/sys/getpriority.s diff --git a/sys.subproj/ppc.subproj/getrlimit.s b/ppc/sys/getrlimit.s similarity index 100% rename from sys.subproj/ppc.subproj/getrlimit.s rename to ppc/sys/getrlimit.s diff --git a/sys.subproj/ppc.subproj/getrusage.s b/ppc/sys/getrusage.s similarity index 100% rename from sys.subproj/ppc.subproj/getrusage.s rename to ppc/sys/getrusage.s diff --git a/sys.subproj/ppc.subproj/getpid.s b/ppc/sys/getsid.s similarity index 98% rename from sys.subproj/ppc.subproj/getpid.s rename to ppc/sys/getsid.s index 0445d37..f6c262d 100644 --- a/sys.subproj/ppc.subproj/getpid.s +++ b/ppc/sys/getsid.s @@ -21,6 +21,6 @@ */ #include "SYS.h" -SYSCALL(getpid, 0) +SYSCALL(getsid, 1) blr diff --git a/sys.subproj/ppc.subproj/getsockname.s b/ppc/sys/getsockname.s similarity index 100% rename from sys.subproj/ppc.subproj/getsockname.s rename to ppc/sys/getsockname.s diff --git a/sys.subproj/ppc.subproj/getsockopt.s b/ppc/sys/getsockopt.s similarity index 100% rename from sys.subproj/ppc.subproj/getsockopt.s rename to ppc/sys/getsockopt.s diff --git a/sys.subproj/ppc.subproj/getuid.s b/ppc/sys/getuid.s similarity index 100% rename from sys.subproj/ppc.subproj/getuid.s rename to ppc/sys/getuid.s diff --git a/sys.subproj/ppc.subproj/ioctl.s b/ppc/sys/ioctl.s similarity index 100% rename from sys.subproj/ppc.subproj/ioctl.s rename to ppc/sys/ioctl.s diff --git a/sys.subproj/ppc.subproj/lfs_segwait.s b/ppc/sys/issetugid.s similarity index 97% rename from sys.subproj/ppc.subproj/lfs_segwait.s rename to ppc/sys/issetugid.s index 2dc8335..41bde6f 100644 --- a/sys.subproj/ppc.subproj/lfs_segwait.s +++ b/ppc/sys/issetugid.s @@ -21,5 +21,6 @@ */ #include "SYS.h" -SYSCALL(lfs_segwait, 2) +SYSCALL(issetugid, 0) blr + diff --git a/sys.subproj/ppc.subproj/kill.s b/ppc/sys/kill.s similarity index 100% rename from sys.subproj/ppc.subproj/kill.s rename to ppc/sys/kill.s diff --git a/sys.subproj/ppc.subproj/ktrace.s b/ppc/sys/ktrace.s similarity index 100% rename from sys.subproj/ppc.subproj/ktrace.s rename to ppc/sys/ktrace.s diff --git a/sys.subproj/ppc.subproj/link.s b/ppc/sys/link.s similarity index 100% rename from sys.subproj/ppc.subproj/link.s rename to ppc/sys/link.s diff --git a/sys.subproj/ppc.subproj/listen.s b/ppc/sys/listen.s similarity index 100% rename from sys.subproj/ppc.subproj/listen.s rename to ppc/sys/listen.s diff --git a/sys.subproj/ppc.subproj/load_shared_file.s b/ppc/sys/load_shared_file.s similarity index 100% rename from sys.subproj/ppc.subproj/load_shared_file.s rename to ppc/sys/load_shared_file.s diff --git a/sys.subproj/ppc.subproj/longjmp.s b/ppc/sys/longjmp.s similarity index 100% rename from sys.subproj/ppc.subproj/longjmp.s rename to ppc/sys/longjmp.s diff --git a/sys.subproj/ppc.subproj/lseek.s b/ppc/sys/lseek.s similarity index 100% rename from sys.subproj/ppc.subproj/lseek.s rename to ppc/sys/lseek.s diff --git a/sys.subproj/ppc.subproj/lstat.s b/ppc/sys/lstat.s similarity index 100% rename from sys.subproj/ppc.subproj/lstat.s rename to ppc/sys/lstat.s diff --git a/sys.subproj/ppc.subproj/lstatv.s b/ppc/sys/lstatv.s similarity index 100% rename from sys.subproj/ppc.subproj/lstatv.s rename to ppc/sys/lstatv.s diff --git a/sys.subproj/ppc.subproj/madvise.s b/ppc/sys/madvise.s similarity index 99% rename from sys.subproj/ppc.subproj/madvise.s rename to ppc/sys/madvise.s index a656a59..1a0c3af 100644 --- a/sys.subproj/ppc.subproj/madvise.s +++ b/ppc/sys/madvise.s @@ -25,3 +25,4 @@ SYSCALL(madvise, 3) blr + diff --git a/sys.subproj/ppc.subproj/mincore.s b/ppc/sys/mincore.s similarity index 100% rename from sys.subproj/ppc.subproj/mincore.s rename to ppc/sys/mincore.s diff --git a/sys.subproj/ppc.subproj/minherit.s b/ppc/sys/minherit.s similarity index 100% rename from sys.subproj/ppc.subproj/minherit.s rename to ppc/sys/minherit.s diff --git a/sys.subproj/ppc.subproj/mkcomplex.s b/ppc/sys/mkcomplex.s similarity index 100% rename from sys.subproj/ppc.subproj/mkcomplex.s rename to ppc/sys/mkcomplex.s diff --git a/sys.subproj/ppc.subproj/mkdir.s b/ppc/sys/mkdir.s similarity index 100% rename from sys.subproj/ppc.subproj/mkdir.s rename to ppc/sys/mkdir.s diff --git a/sys.subproj/ppc.subproj/mkfifo.s b/ppc/sys/mkfifo.s similarity index 100% rename from sys.subproj/ppc.subproj/mkfifo.s rename to ppc/sys/mkfifo.s diff --git a/sys.subproj/ppc.subproj/mknod.s b/ppc/sys/mknod.s similarity index 100% rename from sys.subproj/ppc.subproj/mknod.s rename to ppc/sys/mknod.s diff --git a/sys.subproj/ppc.subproj/mlock.s b/ppc/sys/mlock.s similarity index 100% rename from sys.subproj/ppc.subproj/mlock.s rename to ppc/sys/mlock.s diff --git a/sys.subproj/ppc.subproj/mlockall.s b/ppc/sys/mlockall.s similarity index 100% rename from sys.subproj/ppc.subproj/mlockall.s rename to ppc/sys/mlockall.s diff --git a/sys.subproj/ppc.subproj/mmap.s b/ppc/sys/mmap.s similarity index 100% rename from sys.subproj/ppc.subproj/mmap.s rename to ppc/sys/mmap.s diff --git a/sys.subproj/ppc.subproj/mount.s b/ppc/sys/mount.s similarity index 100% rename from sys.subproj/ppc.subproj/mount.s rename to ppc/sys/mount.s diff --git a/sys.subproj/ppc.subproj/mprotect.s b/ppc/sys/mprotect.s similarity index 100% rename from sys.subproj/ppc.subproj/mprotect.s rename to ppc/sys/mprotect.s diff --git a/sys.subproj/ppc.subproj/msgctl.s b/ppc/sys/msgctl.s similarity index 100% rename from sys.subproj/ppc.subproj/msgctl.s rename to ppc/sys/msgctl.s diff --git a/sys.subproj/ppc.subproj/msgget.s b/ppc/sys/msgget.s similarity index 100% rename from sys.subproj/ppc.subproj/msgget.s rename to ppc/sys/msgget.s diff --git a/sys.subproj/ppc.subproj/msgrcv.s b/ppc/sys/msgrcv.s similarity index 100% rename from sys.subproj/ppc.subproj/msgrcv.s rename to ppc/sys/msgrcv.s diff --git a/sys.subproj/ppc.subproj/msgsnd.s b/ppc/sys/msgsnd.s similarity index 100% rename from sys.subproj/ppc.subproj/msgsnd.s rename to ppc/sys/msgsnd.s diff --git a/sys.subproj/ppc.subproj/msgsys.s b/ppc/sys/msgsys.s similarity index 100% rename from sys.subproj/ppc.subproj/msgsys.s rename to ppc/sys/msgsys.s diff --git a/sys.subproj/ppc.subproj/msync.s b/ppc/sys/msync.s similarity index 100% rename from sys.subproj/ppc.subproj/msync.s rename to ppc/sys/msync.s diff --git a/sys.subproj/ppc.subproj/munlock.s b/ppc/sys/munlock.s similarity index 100% rename from sys.subproj/ppc.subproj/munlock.s rename to ppc/sys/munlock.s diff --git a/sys.subproj/ppc.subproj/munlockall.s b/ppc/sys/munlockall.s similarity index 100% rename from sys.subproj/ppc.subproj/munlockall.s rename to ppc/sys/munlockall.s diff --git a/sys.subproj/ppc.subproj/munmap.s b/ppc/sys/munmap.s similarity index 100% rename from sys.subproj/ppc.subproj/munmap.s rename to ppc/sys/munmap.s diff --git a/ppc/sys/new_system_shared_regions.s b/ppc/sys/new_system_shared_regions.s new file mode 100644 index 0000000..15c107e --- /dev/null +++ b/ppc/sys/new_system_shared_regions.s @@ -0,0 +1,26 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +#include "SYS.h" + +SYSCALL(new_system_shared_regions, 0) + blr + diff --git a/sys.subproj/ppc.subproj/nfssvc.s b/ppc/sys/nfssvc.s similarity index 100% rename from sys.subproj/ppc.subproj/nfssvc.s rename to ppc/sys/nfssvc.s diff --git a/sys.subproj/ppc.subproj/open.s b/ppc/sys/open.s similarity index 100% rename from sys.subproj/ppc.subproj/open.s rename to ppc/sys/open.s diff --git a/sys.subproj/ppc.subproj/pathconf.s b/ppc/sys/pathconf.s similarity index 100% rename from sys.subproj/ppc.subproj/pathconf.s rename to ppc/sys/pathconf.s diff --git a/sys.subproj/ppc.subproj/pipe.s b/ppc/sys/pipe.s similarity index 100% rename from sys.subproj/ppc.subproj/pipe.s rename to ppc/sys/pipe.s diff --git a/ppc/sys/posix_madvise.s b/ppc/sys/posix_madvise.s new file mode 100644 index 0000000..259a9b4 --- /dev/null +++ b/ppc/sys/posix_madvise.s @@ -0,0 +1,27 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* Copyright 1998 Apple Computer, Inc. */ + +#include "SYS.h" + +PSEUDO(posix_madvise, madvise, 3) + blr diff --git a/ppc/sys/ppc_gettimeofday.s b/ppc/sys/ppc_gettimeofday.s new file mode 100644 index 0000000..5632789 --- /dev/null +++ b/ppc/sys/ppc_gettimeofday.s @@ -0,0 +1,42 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* Copyright 1998 Apple Computer, Inc. */ + +#include "SYS.h" + + .globl cerror +LEAF(___ppc_gettimeofday) + li r0,SYS_gettimeofday + mr r12,r3 + sc + b 1f + b 2f +1: BRANCH_EXTERN(cerror) +2: + mr. r12,r12 + beq 3f + stw r3,0(r12) + stw r4,4(r12) + li r3,0 +3: + blr + diff --git a/ppc/sys/pread.s b/ppc/sys/pread.s new file mode 100644 index 0000000..fcab3d5 --- /dev/null +++ b/ppc/sys/pread.s @@ -0,0 +1,26 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +#include "SYS.h" + +SYSCALL(pread, 4) + blr + diff --git a/sys.subproj/ppc.subproj/processor_facilities.h b/ppc/sys/processor_facilities.h similarity index 100% rename from sys.subproj/ppc.subproj/processor_facilities.h rename to ppc/sys/processor_facilities.h diff --git a/sys.subproj/ppc.subproj/processor_facilities.s b/ppc/sys/processor_facilities.s similarity index 100% rename from sys.subproj/ppc.subproj/processor_facilities.s rename to ppc/sys/processor_facilities.s diff --git a/sys.subproj/ppc.subproj/profil.s b/ppc/sys/profil.s similarity index 100% rename from sys.subproj/ppc.subproj/profil.s rename to ppc/sys/profil.s diff --git a/ppc/sys/pthread_sigmask.s b/ppc/sys/pthread_sigmask.s new file mode 100644 index 0000000..69657d4 --- /dev/null +++ b/ppc/sys/pthread_sigmask.s @@ -0,0 +1,26 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +#include "SYS.h" + +SYSCALL(pthread_sigmask, 3) + blr + diff --git a/sys.subproj/ppc.subproj/ptrace.s b/ppc/sys/ptrace.s similarity index 100% rename from sys.subproj/ppc.subproj/ptrace.s rename to ppc/sys/ptrace.s diff --git a/ppc/sys/pwrite.s b/ppc/sys/pwrite.s new file mode 100644 index 0000000..f23bf5c --- /dev/null +++ b/ppc/sys/pwrite.s @@ -0,0 +1,26 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +#include "SYS.h" + +SYSCALL(pwrite, 4) + blr + diff --git a/sys.subproj/ppc.subproj/quota.s b/ppc/sys/quota.s similarity index 100% rename from sys.subproj/ppc.subproj/quota.s rename to ppc/sys/quota.s diff --git a/sys.subproj/ppc.subproj/quotactl.s b/ppc/sys/quotactl.s similarity index 100% rename from sys.subproj/ppc.subproj/quotactl.s rename to ppc/sys/quotactl.s diff --git a/sys.subproj/ppc.subproj/read.s b/ppc/sys/read.s similarity index 100% rename from sys.subproj/ppc.subproj/read.s rename to ppc/sys/read.s diff --git a/sys.subproj/ppc.subproj/readlink.s b/ppc/sys/readlink.s similarity index 100% rename from sys.subproj/ppc.subproj/readlink.s rename to ppc/sys/readlink.s diff --git a/sys.subproj/ppc.subproj/readv.s b/ppc/sys/readv.s similarity index 100% rename from sys.subproj/ppc.subproj/readv.s rename to ppc/sys/readv.s diff --git a/sys.subproj/ppc.subproj/reboot.s b/ppc/sys/reboot.s similarity index 100% rename from sys.subproj/ppc.subproj/reboot.s rename to ppc/sys/reboot.s diff --git a/sys.subproj/ppc.subproj/recvfrom.s b/ppc/sys/recvfrom.s similarity index 100% rename from sys.subproj/ppc.subproj/recvfrom.s rename to ppc/sys/recvfrom.s diff --git a/sys.subproj/ppc.subproj/recvmsg.s b/ppc/sys/recvmsg.s similarity index 100% rename from sys.subproj/ppc.subproj/recvmsg.s rename to ppc/sys/recvmsg.s diff --git a/sys.subproj/ppc.subproj/rename.s b/ppc/sys/rename.s similarity index 100% rename from sys.subproj/ppc.subproj/rename.s rename to ppc/sys/rename.s diff --git a/sys.subproj/ppc.subproj/reset_shared_file.s b/ppc/sys/reset_shared_file.s similarity index 100% rename from sys.subproj/ppc.subproj/reset_shared_file.s rename to ppc/sys/reset_shared_file.s diff --git a/sys.subproj/ppc.subproj/revoke.s b/ppc/sys/revoke.s similarity index 100% rename from sys.subproj/ppc.subproj/revoke.s rename to ppc/sys/revoke.s diff --git a/sys.subproj/ppc.subproj/rmdir.s b/ppc/sys/rmdir.s similarity index 100% rename from sys.subproj/ppc.subproj/rmdir.s rename to ppc/sys/rmdir.s diff --git a/ppc/sys/s.template b/ppc/sys/s.template new file mode 100644 index 0000000..171d0ed --- /dev/null +++ b/ppc/sys/s.template @@ -0,0 +1,6 @@ +/* Copyright 1998 Apple Computer, Inc. */ + +#include "SYS.h" + +SYSCALL($FILENAMESANSEXTENSION$, 0) + blr diff --git a/sys.subproj/ppc.subproj/searchfs.s b/ppc/sys/searchfs.s similarity index 100% rename from sys.subproj/ppc.subproj/searchfs.s rename to ppc/sys/searchfs.s diff --git a/sys.subproj/ppc.subproj/select.s b/ppc/sys/select.s similarity index 100% rename from sys.subproj/ppc.subproj/select.s rename to ppc/sys/select.s diff --git a/sys.subproj/ppc.subproj/sem_close.s b/ppc/sys/sem_close.s similarity index 100% rename from sys.subproj/ppc.subproj/sem_close.s rename to ppc/sys/sem_close.s diff --git a/sys.subproj/ppc.subproj/sem_destroy.s b/ppc/sys/sem_destroy.s similarity index 100% rename from sys.subproj/ppc.subproj/sem_destroy.s rename to ppc/sys/sem_destroy.s diff --git a/sys.subproj/ppc.subproj/sem_getvalue.s b/ppc/sys/sem_getvalue.s similarity index 100% rename from sys.subproj/ppc.subproj/sem_getvalue.s rename to ppc/sys/sem_getvalue.s diff --git a/sys.subproj/ppc.subproj/sem_init.s b/ppc/sys/sem_init.s similarity index 100% rename from sys.subproj/ppc.subproj/sem_init.s rename to ppc/sys/sem_init.s diff --git a/sys.subproj/ppc.subproj/sem_open.s b/ppc/sys/sem_open.s similarity index 100% rename from sys.subproj/ppc.subproj/sem_open.s rename to ppc/sys/sem_open.s diff --git a/sys.subproj/ppc.subproj/sem_post.s b/ppc/sys/sem_post.s similarity index 100% rename from sys.subproj/ppc.subproj/sem_post.s rename to ppc/sys/sem_post.s diff --git a/sys.subproj/ppc.subproj/sem_trywait.s b/ppc/sys/sem_trywait.s similarity index 100% rename from sys.subproj/ppc.subproj/sem_trywait.s rename to ppc/sys/sem_trywait.s diff --git a/sys.subproj/ppc.subproj/sem_unlink.s b/ppc/sys/sem_unlink.s similarity index 100% rename from sys.subproj/ppc.subproj/sem_unlink.s rename to ppc/sys/sem_unlink.s diff --git a/sys.subproj/ppc.subproj/sem_wait.s b/ppc/sys/sem_wait.s similarity index 100% rename from sys.subproj/ppc.subproj/sem_wait.s rename to ppc/sys/sem_wait.s diff --git a/sys.subproj/ppc.subproj/semconfig.s b/ppc/sys/semconfig.s similarity index 100% rename from sys.subproj/ppc.subproj/semconfig.s rename to ppc/sys/semconfig.s diff --git a/sys.subproj/ppc.subproj/semctl.s b/ppc/sys/semctl.s similarity index 100% rename from sys.subproj/ppc.subproj/semctl.s rename to ppc/sys/semctl.s diff --git a/sys.subproj/ppc.subproj/semget.s b/ppc/sys/semget.s similarity index 100% rename from sys.subproj/ppc.subproj/semget.s rename to ppc/sys/semget.s diff --git a/sys.subproj/ppc.subproj/semop.s b/ppc/sys/semop.s similarity index 100% rename from sys.subproj/ppc.subproj/semop.s rename to ppc/sys/semop.s diff --git a/sys.subproj/ppc.subproj/semsys.s b/ppc/sys/semsys.s similarity index 100% rename from sys.subproj/ppc.subproj/semsys.s rename to ppc/sys/semsys.s diff --git a/sys.subproj/ppc.subproj/sendmsg.s b/ppc/sys/sendmsg.s similarity index 100% rename from sys.subproj/ppc.subproj/sendmsg.s rename to ppc/sys/sendmsg.s diff --git a/sys.subproj/ppc.subproj/sendto.s b/ppc/sys/sendto.s similarity index 100% rename from sys.subproj/ppc.subproj/sendto.s rename to ppc/sys/sendto.s diff --git a/sys.subproj/ppc.subproj/setattrlist.s b/ppc/sys/setattrlist.s similarity index 100% rename from sys.subproj/ppc.subproj/setattrlist.s rename to ppc/sys/setattrlist.s diff --git a/sys.subproj/ppc.subproj/setegid.s b/ppc/sys/setegid.s similarity index 100% rename from sys.subproj/ppc.subproj/setegid.s rename to ppc/sys/setegid.s diff --git a/sys.subproj/ppc.subproj/seteuid.s b/ppc/sys/seteuid.s similarity index 100% rename from sys.subproj/ppc.subproj/seteuid.s rename to ppc/sys/seteuid.s diff --git a/sys.subproj/ppc.subproj/setgid.s b/ppc/sys/setgid.s similarity index 100% rename from sys.subproj/ppc.subproj/setgid.s rename to ppc/sys/setgid.s diff --git a/sys.subproj/ppc.subproj/setgroups.s b/ppc/sys/setgroups.s similarity index 100% rename from sys.subproj/ppc.subproj/setgroups.s rename to ppc/sys/setgroups.s diff --git a/sys.subproj/ppc.subproj/setitimer.s b/ppc/sys/setitimer.s similarity index 100% rename from sys.subproj/ppc.subproj/setitimer.s rename to ppc/sys/setitimer.s diff --git a/sys.subproj/ppc.subproj/setjmp.s b/ppc/sys/setjmp.s similarity index 100% rename from sys.subproj/ppc.subproj/setjmp.s rename to ppc/sys/setjmp.s diff --git a/sys.subproj/ppc.subproj/setpgid.s b/ppc/sys/setpgid.s similarity index 100% rename from sys.subproj/ppc.subproj/setpgid.s rename to ppc/sys/setpgid.s diff --git a/sys.subproj/ppc.subproj/setpriority.s b/ppc/sys/setpriority.s similarity index 100% rename from sys.subproj/ppc.subproj/setpriority.s rename to ppc/sys/setpriority.s diff --git a/sys.subproj/ppc.subproj/setprivexec.s b/ppc/sys/setprivexec.s similarity index 100% rename from sys.subproj/ppc.subproj/setprivexec.s rename to ppc/sys/setprivexec.s diff --git a/sys.subproj/ppc.subproj/setquota.s b/ppc/sys/setquota.s similarity index 100% rename from sys.subproj/ppc.subproj/setquota.s rename to ppc/sys/setquota.s diff --git a/sys.subproj/ppc.subproj/setrlimit.s b/ppc/sys/setrlimit.s similarity index 100% rename from sys.subproj/ppc.subproj/setrlimit.s rename to ppc/sys/setrlimit.s diff --git a/sys.subproj/ppc.subproj/setsid.s b/ppc/sys/setsid.s similarity index 100% rename from sys.subproj/ppc.subproj/setsid.s rename to ppc/sys/setsid.s diff --git a/sys.subproj/ppc.subproj/setsockopt.s b/ppc/sys/setsockopt.s similarity index 100% rename from sys.subproj/ppc.subproj/setsockopt.s rename to ppc/sys/setsockopt.s diff --git a/sys.subproj/ppc.subproj/settimeofday.s b/ppc/sys/settimeofday.s similarity index 100% rename from sys.subproj/ppc.subproj/settimeofday.s rename to ppc/sys/settimeofday.s diff --git a/sys.subproj/ppc.subproj/setuid.s b/ppc/sys/setuid.s similarity index 100% rename from sys.subproj/ppc.subproj/setuid.s rename to ppc/sys/setuid.s diff --git a/sys.subproj/ppc.subproj/shm_open.s b/ppc/sys/shm_open.s similarity index 100% rename from sys.subproj/ppc.subproj/shm_open.s rename to ppc/sys/shm_open.s diff --git a/sys.subproj/ppc.subproj/shm_unlink.s b/ppc/sys/shm_unlink.s similarity index 100% rename from sys.subproj/ppc.subproj/shm_unlink.s rename to ppc/sys/shm_unlink.s diff --git a/sys.subproj/ppc.subproj/shmat.s b/ppc/sys/shmat.s similarity index 100% rename from sys.subproj/ppc.subproj/shmat.s rename to ppc/sys/shmat.s diff --git a/sys.subproj/ppc.subproj/shmctl.s b/ppc/sys/shmctl.s similarity index 100% rename from sys.subproj/ppc.subproj/shmctl.s rename to ppc/sys/shmctl.s diff --git a/sys.subproj/ppc.subproj/shmdt.s b/ppc/sys/shmdt.s similarity index 100% rename from sys.subproj/ppc.subproj/shmdt.s rename to ppc/sys/shmdt.s diff --git a/sys.subproj/ppc.subproj/shmget.s b/ppc/sys/shmget.s similarity index 100% rename from sys.subproj/ppc.subproj/shmget.s rename to ppc/sys/shmget.s diff --git a/sys.subproj/ppc.subproj/shmsys.s b/ppc/sys/shmsys.s similarity index 100% rename from sys.subproj/ppc.subproj/shmsys.s rename to ppc/sys/shmsys.s diff --git a/sys.subproj/ppc.subproj/shutdown.s b/ppc/sys/shutdown.s similarity index 100% rename from sys.subproj/ppc.subproj/shutdown.s rename to ppc/sys/shutdown.s diff --git a/sys.subproj/ppc.subproj/sigaltstack.s b/ppc/sys/sigaltstack.s similarity index 100% rename from sys.subproj/ppc.subproj/sigaltstack.s rename to ppc/sys/sigaltstack.s diff --git a/sys.subproj/ppc.subproj/sigpending.s b/ppc/sys/sigpending.s similarity index 100% rename from sys.subproj/ppc.subproj/sigpending.s rename to ppc/sys/sigpending.s diff --git a/sys.subproj/ppc.subproj/lfs_segclean.s b/ppc/sys/sigprocmask.s similarity index 97% rename from sys.subproj/ppc.subproj/lfs_segclean.s rename to ppc/sys/sigprocmask.s index 8a36388..08ee95f 100644 --- a/sys.subproj/ppc.subproj/lfs_segclean.s +++ b/ppc/sys/sigprocmask.s @@ -21,5 +21,6 @@ */ #include "SYS.h" -SYSCALL(lfs_segclean, 2) +SYSCALL(sigprocmask, 3) blr + diff --git a/sys.subproj/ppc.subproj/sigreturn.s b/ppc/sys/sigreturn.s similarity index 100% rename from sys.subproj/ppc.subproj/sigreturn.s rename to ppc/sys/sigreturn.s diff --git a/ppc/sys/sigwait.s b/ppc/sys/sigwait.s new file mode 100644 index 0000000..a879b4d --- /dev/null +++ b/ppc/sys/sigwait.s @@ -0,0 +1,26 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +#include "SYS.h" + +SYSCALL(sigwait, 2) + blr + diff --git a/sys.subproj/ppc.subproj/socket.s b/ppc/sys/socket.s similarity index 100% rename from sys.subproj/ppc.subproj/socket.s rename to ppc/sys/socket.s diff --git a/sys.subproj/ppc.subproj/socketpair.s b/ppc/sys/socketpair.s similarity index 100% rename from sys.subproj/ppc.subproj/socketpair.s rename to ppc/sys/socketpair.s diff --git a/sys.subproj/ppc.subproj/stat.s b/ppc/sys/stat.s similarity index 100% rename from sys.subproj/ppc.subproj/stat.s rename to ppc/sys/stat.s diff --git a/sys.subproj/ppc.subproj/statfs.s b/ppc/sys/statfs.s similarity index 100% rename from sys.subproj/ppc.subproj/statfs.s rename to ppc/sys/statfs.s diff --git a/sys.subproj/ppc.subproj/statv.s b/ppc/sys/statv.s similarity index 100% rename from sys.subproj/ppc.subproj/statv.s rename to ppc/sys/statv.s diff --git a/sys.subproj/ppc.subproj/swapon.s b/ppc/sys/swapon.s similarity index 100% rename from sys.subproj/ppc.subproj/swapon.s rename to ppc/sys/swapon.s diff --git a/sys.subproj/ppc.subproj/symlink.s b/ppc/sys/symlink.s similarity index 100% rename from sys.subproj/ppc.subproj/symlink.s rename to ppc/sys/symlink.s diff --git a/sys.subproj/ppc.subproj/sync.s b/ppc/sys/sync.s similarity index 100% rename from sys.subproj/ppc.subproj/sync.s rename to ppc/sys/sync.s diff --git a/sys.subproj/ppc.subproj/syscall.s b/ppc/sys/syscall.s similarity index 100% rename from sys.subproj/ppc.subproj/syscall.s rename to ppc/sys/syscall.s diff --git a/sys.subproj/ppc.subproj/table.s b/ppc/sys/systable.s similarity index 100% rename from sys.subproj/ppc.subproj/table.s rename to ppc/sys/systable.s diff --git a/sys.subproj/ppc.subproj/truncate.s b/ppc/sys/truncate.s similarity index 100% rename from sys.subproj/ppc.subproj/truncate.s rename to ppc/sys/truncate.s diff --git a/sys.subproj/ppc.subproj/umask.s b/ppc/sys/umask.s similarity index 100% rename from sys.subproj/ppc.subproj/umask.s rename to ppc/sys/umask.s diff --git a/sys.subproj/ppc.subproj/undelete.s b/ppc/sys/undelete.s similarity index 100% rename from sys.subproj/ppc.subproj/undelete.s rename to ppc/sys/undelete.s diff --git a/sys.subproj/ppc.subproj/unlink.s b/ppc/sys/unlink.s similarity index 100% rename from sys.subproj/ppc.subproj/unlink.s rename to ppc/sys/unlink.s diff --git a/sys.subproj/ppc.subproj/unmount.s b/ppc/sys/unmount.s similarity index 100% rename from sys.subproj/ppc.subproj/unmount.s rename to ppc/sys/unmount.s diff --git a/sys.subproj/ppc.subproj/ur_cthread.s b/ppc/sys/ur_cthread.s similarity index 100% rename from sys.subproj/ppc.subproj/ur_cthread.s rename to ppc/sys/ur_cthread.s diff --git a/sys.subproj/ppc.subproj/utimes.s b/ppc/sys/utimes.s similarity index 100% rename from sys.subproj/ppc.subproj/utimes.s rename to ppc/sys/utimes.s diff --git a/sys.subproj/ppc.subproj/vfork.s b/ppc/sys/vfork.s similarity index 82% rename from sys.subproj/ppc.subproj/vfork.s rename to ppc/sys/vfork.s index 14bc4f3..99aff4d 100644 --- a/sys.subproj/ppc.subproj/vfork.s +++ b/ppc/sys/vfork.s @@ -28,7 +28,6 @@ * Created from fork.s * */ - #if 0 #import #import @@ -81,6 +80,8 @@ LC3: mtspr ctr,r3 bctrl #endif + li r3,0 + REG_TO_EXTERN(r3, EXT(_current_pid)) CALL_EXTERN(_fork_mach_init) CALL_EXTERN(__cthread_fork_child) #if defined(__DYNAMIC__) @@ -162,19 +163,49 @@ END(_vfork) #else #include "SYS.h" -.text -.align 2 -.globl _vfork -_vfork: +LEAF(_vfork) +#if defined(__DYNAMIC__) + PICIFY(__current_pid) + mr r5,PICIFY_REG + NON_LAZY_STUB(__current_pid) +#else + lis r5,ha16(__current_pid) + ori r5,r5,lo16(__current_pid) +#endif +2: + lwarx r6,0,r5 // dont cache pid across vfork + cmpwi r6,0 + ble- 3f // is another vfork in progress + li r6,0 // if not, erase the stored pid +3: + addi r6,r6,-1 // count the parallel vforks in + stwcx. r6,0,r5 // negative cached pid values + bne- 2b + li r0,SYS_vfork sc b Lbotch // error return cmpwi r4,0 - beqlr // parent, since a1 == 0 in parent, - li r3,0 + beq Lparent // parent, since a1 == 0 in parent, + + li r3,0 // child blr -Lbotch: + +Lparent: + lwarx r6,0,r5 // were back, decrement vfork count + addi r6,r6,1 + stwcx. r6,0,r5 + bne- Lparent + blr + +Lbotch: + lwarx r6,0,r5 // never went, decrement vfork count + addi r6,r6,1 + stwcx. r6,0,r5 + bne- Lbotch + BRANCH_EXTERN(cerror) +END(_vfork) #endif diff --git a/sys.subproj/ppc.subproj/wait4.s b/ppc/sys/wait4.s similarity index 100% rename from sys.subproj/ppc.subproj/wait4.s rename to ppc/sys/wait4.s diff --git a/sys.subproj/ppc.subproj/write.s b/ppc/sys/write.s similarity index 100% rename from sys.subproj/ppc.subproj/write.s rename to ppc/sys/write.s diff --git a/sys.subproj/ppc.subproj/writev.s b/ppc/sys/writev.s similarity index 100% rename from sys.subproj/ppc.subproj/writev.s rename to ppc/sys/writev.s diff --git a/pthreads.subproj/Makefile b/pthreads.subproj/Makefile deleted file mode 100644 index 5aaeca9..0000000 --- a/pthreads.subproj/Makefile +++ /dev/null @@ -1,63 +0,0 @@ -# -# Generated by the NeXT Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = pthreads - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -HFILES = posix_sched.h pthread.h pthread_impl.h pthread_internals.h\ - pthread_machdep.h sched.h - -OTHERLINKED = lock.s stack.s - -CFILES = pthread.c pthread_cond.c pthread_mutex.c pthread_tsd.c\ - thread_setup.c - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble\ - mk_pthread_impl.c - -OTHERLINKEDOFILES = lock.o stack.o - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -NEXTSTEP_INSTALLDIR = /Local/Developer/System -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - -NEXTSTEP_PB_CFLAGS = -D__POSIX_LIB__ -PUBLIC_HEADERS = sched.h pthread_impl.h pthread.h - -PROJECT_HEADERS = pthread_internals.h sched.h pthread_impl.h pthread.h - - - -NEXTSTEP_BUILD_OUTPUT_DIR = /Local/Public/Sandbox/$(USER)/BUILD/$(NAME) - -NEXTSTEP_PUBLIC_HEADERS_DIR = /usr/include - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/pthreads.subproj/Makefile.postamble b/pthreads.subproj/Makefile.postamble deleted file mode 100644 index 411cde6..0000000 --- a/pthreads.subproj/Makefile.postamble +++ /dev/null @@ -1,100 +0,0 @@ -############################################################################### -# Makefile.postamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile, which is imported after all other makefiles, to -# override attributes for a project's Makefile environment. This allows you -# to take advantage of the environment set up by the other Makefiles. -# You can also define custom rules at the end of this file. -# -############################################################################### -# -# These variables are exported by the standard makefiles and can be -# used in any customizations you make. They are *outputs* of -# the Makefiles and should be used, not set. -# -# PRODUCTS: products to install. All of these products will be placed in -# the directory $(DSTROOT)$(INSTALLDIR) -# GLOBAL_RESOURCE_DIR: The directory to which resources are copied. -# LOCAL_RESOURCE_DIR: The directory to which localized resources are copied. -# OFILE_DIR: Directory into which .o object files are generated. -# DERIVED_SRC_DIR: Directory used for all other derived files -# -# ALL_CFLAGS: flags to pass when compiling .c files -# ALL_MFLAGS: flags to pass when compiling .m files -# ALL_CCFLAGS: flags to pass when compiling .cc, .cxx, and .C files -# ALL_MMFLAGS: flags to pass when compiling .mm, .mxx, and .M files -# ALL_PRECOMPFLAGS: flags to pass when precompiling .h files -# ALL_LDFLAGS: flags to pass when linking object files -# ALL_LIBTOOL_FLAGS: flags to pass when libtooling object files -# ALL_PSWFLAGS: flags to pass when processing .psw and .pswm (pswrap) files -# ALL_RPCFLAGS: flags to pass when processing .rpc (rpcgen) files -# ALL_YFLAGS: flags to pass when processing .y (yacc) files -# ALL_LFLAGS: flags to pass when processing .l (lex) files -# -# NAME: name of application, bundle, subproject, palette, etc. -# LANGUAGES: langages in which the project is written (default "English") -# English_RESOURCES: localized resources (e.g. nib's, images) of project -# GLOBAL_RESOURCES: non-localized resources of project -# -# SRCROOT: base directory in which to place the new source files -# SRCPATH: relative path from SRCROOT to present subdirectory -# -# INSTALLDIR: Directory the product will be installed into by 'install' target -# PUBLIC_HDR_INSTALLDIR: where to install public headers. Don't forget -# to prefix this with DSTROOT when you use it. -# PRIVATE_HDR_INSTALLDIR: where to install private headers. Don't forget -# to prefix this with DSTROOT when you use it. -# -# EXECUTABLE_EXT: Executable extension for the platform (i.e. .exe on Windows) -# -############################################################################### - -# Some compiler flags can be overridden here for certain build situations. -# -# WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost) -# DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults -# to -g) -# DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG) -# OPTIMIZE_BUILD_CFLAGS: flags passed during optimized builds (defaults -# to -O) -# PROFILE_BUILD_CFLAGS: flags passed during profile builds (defaults -# to -pg -DPROFILE) -# LOCAL_DIR_INCLUDE_DIRECTIVE: flag used to add current directory to -# the include path (defaults to -I.) -# DEBUG_BUILD_LDFLAGS, OPTIMIZE_BUILD_LDFLAGS, PROFILE_BUILD_LDFLAGS: flags -# passed to ld/libtool (defaults to nothing) - - -# Library and Framework projects only: -# INSTALL_NAME_DIRECTIVE: This directive ensures that executables linked -# against the framework will run against the correct version even if -# the current version of the framework changes. You may override this -# to "" as an alternative to using the DYLD_LIBRARY_PATH during your -# development cycle, but be sure to restore it before installing. - - -# Ownership and permissions of files installed by 'install' target - -#INSTALL_AS_USER = root - # User/group ownership -#INSTALL_AS_GROUP = wheel - # (probably want to set both of these) -#INSTALL_PERMISSIONS = - # If set, 'install' chmod's executable to this - - -# Options to strip. Note: -S strips debugging symbols (executables can be stripped -# down further with -x or, if they load no bundles, with no options at all). - -#STRIPFLAGS = -S - - -######################################################################### -# Put rules to extend the behavior of the standard Makefiles here. Include them in -# the dependency tree via cvariables like AFTER_INSTALL in the Makefile.preamble. -# -# You should avoid redefining things like "install" or "app", as they are -# owned by the top-level Makefile API and no context has been set up for where -# derived files should go. -# diff --git a/pthreads.subproj/Makefile.preamble b/pthreads.subproj/Makefile.preamble deleted file mode 100644 index c1624b4..0000000 --- a/pthreads.subproj/Makefile.preamble +++ /dev/null @@ -1,137 +0,0 @@ -############################################################################### -# Makefile.preamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile for configuring the standard application makefiles -# associated with ProjectBuilder. It is included before the main makefile. -# In Makefile.preamble you set attributes for a project, so they are available -# to the project's makefiles. In contrast, you typically write additional rules or -# override built-in behavior in the Makefile.postamble. -# -# Each directory in a project tree (main project plus subprojects) should -# have its own Makefile.preamble and Makefile.postamble. -############################################################################### -# -# Before the main makefile is included for this project, you may set: -# -# MAKEFILEDIR: Directory in which to find $(MAKEFILE) -# MAKEFILE: Top level mechanism Makefile (e.g., app.make, bundle.make) - -# Compiler/linker flags added to the defaults: The OTHER_* variables will be -# inherited by all nested sub-projects, but the LOCAL_ versions of the same -# variables will not. Put your -I, -D, -U, and -L flags in ProjectBuilder's -# Build Attributes inspector if at all possible. To override the default flags -# that get passed to ${CC} (e.g. change -O to -O2), see Makefile.postamble. The -# variables below are *inputs* to the build process and distinct from the override -# settings done (less often) in the Makefile.postamble. -# -# OTHER_CFLAGS, LOCAL_CFLAGS: additional flags to pass to the compiler -# Note that $(OTHER_CFLAGS) and $(LOCAL_CFLAGS) are used for .h, ...c, .m, -# .cc, .cxx, .C, and .M files. There is no need to respecify the -# flags in OTHER_MFLAGS, etc. -# OTHER_MFLAGS, LOCAL_MFLAGS: additional flags for .m files -# OTHER_CCFLAGS, LOCAL_CCFLAGS: additional flags for .cc, .cxx, and ...C files -# OTHER_MMFLAGS, LOCAL_MMFLAGS: additional flags for .mm and .M files -# OTHER_PRECOMPFLAGS, LOCAL_PRECOMPFLAGS: additional flags used when -# precompiling header files -# OTHER_LDFLAGS, LOCAL_LDFLAGS: additional flags passed to ld and libtool -# OTHER_PSWFLAGS, LOCAL_PSWFLAGS: additional flags passed to pswrap -# OTHER_RPCFLAGS, LOCAL_RPCFLAGS: additional flags passed to rpcgen -# OTHER_YFLAGS, LOCAL_YFLAGS: additional flags passed to yacc -# OTHER_LFLAGS, LOCAL_LFLAGS: additional flags passed to lex - -# These variables provide hooks enabling you to add behavior at almost every -# stage of the make: -# -# BEFORE_PREBUILD: targets to build before installing headers for a subproject -# AFTER_PREBUILD: targets to build after installing headers for a subproject -# BEFORE_BUILD_RECURSION: targets to make before building subprojects -# BEFORE_BUILD: targets to make before a build, but after subprojects -# AFTER_BUILD: targets to make after a build -# -# BEFORE_INSTALL: targets to build before installing the product -# AFTER_INSTALL: targets to build after installing the product -# BEFORE_POSTINSTALL: targets to build before postinstalling every subproject -# AFTER_POSTINSTALL: targts to build after postinstalling every subproject -# -# BEFORE_INSTALLHDRS: targets to build before installing headers for a -# subproject -# AFTER_INSTALLHDRS: targets to build after installing headers for a subproject -# BEFORE_INSTALLSRC: targets to build before installing source for a subproject -# AFTER_INSTALLSRC: targets to build after installing source for a subproject -# -# BEFORE_DEPEND: targets to build before building dependencies for a -# subproject -# AFTER_DEPEND: targets to build after building dependencies for a -# subproject -# -# AUTOMATIC_DEPENDENCY_INFO: if YES, then the dependency file is -# updated every time the project is built. If NO, the dependency -# file is only built when the depend target is invoked. - -# Framework-related variables: -# FRAMEWORK_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the framework's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables - -# Library-related variables: -# PUBLIC_HEADER_DIR: Determines where public exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. For library projects you should -# set this to something like /Developer/Headers/$(NAME). Do not set -# this variable for framework projects unless you do not want the -# header files included in the framework. -# PRIVATE_HEADER_DIR: Determines where private exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. -# LIBRARY_STYLE: This may be either STATIC or DYNAMIC, and determines -# whether the libraries produced are statically linked when they -# are used or if they are dynamically loadable. This defaults to -# DYNAMIC. -# LIBRARY_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the library's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables -# -# INSTALL_AS_USER: owner of the intalled products (default root) -# INSTALL_AS_GROUP: group of the installed products (default wheel) -# INSTALL_PERMISSIONS: permissions of the installed product (default o+rX) -# -# OTHER_RECURSIVE_VARIABLES: The names of variables which you want to be -# passed on the command line to recursive invocations of make. Note that -# the values in OTHER_*FLAGS are inherited by subprojects automatically -- -# you do not have to (and shouldn't) add OTHER_*FLAGS to -# OTHER_RECURSIVE_VARIABLES. - -# Additional headers to export beyond those in the PB.project: -# OTHER_PUBLIC_HEADERS -# OTHER_PROJECT_HEADERS -# OTHER_PRIVATE_HEADERS - -# Additional files for the project's product: <> -# OTHER_RESOURCES: (non-localized) resources for this project -# OTHER_OFILES: relocatables to be linked into this project -# OTHER_LIBS: more libraries to link against -# OTHER_PRODUCT_DEPENDS: other dependencies of this project -# OTHER_SOURCEFILES: other source files maintained by .pre/postamble -# OTHER_GARBAGE: additional files to be removed by `make clean' - -# Set this to YES if you don't want a final libtool call for a library/framework. -# BUILD_OFILES_LIST_ONLY - -# To include a version string, project source must exist in a directory named -# $(NAME).%d[.%d][.%d] and the following line must be uncommented. -# OTHER_GENERATED_OFILES = $(VERS_OFILE) - -# This definition will suppress stripping of debug symbols when an executable -# is installed. By default it is YES. -# STRIP_ON_INSTALL = NO - -# Uncomment to suppress generation of a KeyValueCoding index when installing -# frameworks (This index is used by WOB and IB to determine keys available -# for an object). Set to YES by default. -# PREINDEX_FRAMEWORK = NO - -# Change this definition to install projects somewhere other than the -# standard locations. NEXT_ROOT defaults to "C:/Apple" on Windows systems -# and "" on other systems. -DSTROOT = $(HOME) diff --git a/pthreads.subproj/PB.project b/pthreads.subproj/PB.project deleted file mode 100644 index cb9a7f3..0000000 --- a/pthreads.subproj/PB.project +++ /dev/null @@ -1,44 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - H_FILES = ( - posix_sched.h, - pthread.h, - pthread_impl.h, - pthread_internals.h, - pthread_machdep.h, - sched.h - ); - OTHER_LINKED = ( - lock.s, - pthread.c, - pthread_cond.c, - pthread_mutex.c, - pthread_tsd.c, - stack.s, - thread_setup.c - ); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble, mk_pthread_impl.c); - PROJECT_HEADERS = (pthread_internals.h, sched.h, pthread_impl.h, pthread.h); - PUBLIC_HEADERS = (sched.h, pthread_impl.h, pthread.h); - SUBPROJECTS = (); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDDIR = "/Local/Public/Sandbox/$(USER)/BUILD/$(NAME)"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_COMPILEROPTIONS = "-D__POSIX_LIB__"; - NEXTSTEP_INSTALLDIR = /Local/Developer/System; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - NEXTSTEP_PUBLICHEADERSDIR = /usr/include; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = pthreads; - PROJECTTYPE = Component; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/pthreads/Makefile.inc b/pthreads/Makefile.inc new file mode 100644 index 0000000..acd3d05 --- /dev/null +++ b/pthreads/Makefile.inc @@ -0,0 +1,70 @@ +.PATH: ${.CURDIR}/${MACHINE_ARCH}/pthreads ${.CURDIR}/pthreads + +SRCS += pthread_cond.c pthread_tsd.c pthread.c \ + pthread_mutex.c thread_setup.c lock.s stack.s pthread_rwlock.c + +PTHREADS_INSTHDRS += pthread.h pthread_impl.h sched.h +PTHREADS_INSTHDRS := ${PTHREADS_INSTHDRS:S/^/${.CURDIR}\/pthreads\//} +INSTHDRS += ${PTHREADS_INSTHDRS} + +.if ${LIB} == "c" +MAN3+= pthread.3 pthread_attr.3 pthread_cancel.3 \ + pthread_cleanup_pop.3 pthread_cleanup_push.3 \ + pthread_cond_broadcast.3 pthread_cond_destroy.3 \ + pthread_cond_init.3 pthread_cond_signal.3 \ + pthread_cond_timedwait.3 pthread_cond_wait.3 \ + pthread_create.3 pthread_detach.3 \ + pthread_equal.3 pthread_exit.3 \ + pthread_getschedparam.3 pthread_getspecific.3 \ + pthread_join.3 pthread_key_create.3 \ + pthread_key_delete.3 pthread_mutex_destroy.3 \ + pthread_mutex_init.3 pthread_mutex_lock.3 \ + pthread_mutex_trylock.3 pthread_mutex_unlock.3 \ + pthread_mutexattr.3 pthread_once.3 \ + pthread_self.3 pthread_setcancelstate.3 \ + pthread_setspecific.3 pthread_condattr.3 \ + pthread_rwlock_destroy.3 pthread_rwlock_init.3 \ + pthread_rwlock_rdlock.3 pthread_rwlock_unlock.3 \ + pthread_rwlock_wrlock.3 pthread_rwlockattr_destroy.3 \ + pthread_rwlockattr_getpshared.3 pthread_rwlockattr_init.3 \ + pthread_rwlockattr_setpshared.3 + +MLINKS+=pthread_attr.3 pthread_attr_destroy.3 \ + pthread_attr.3 pthread_attr_getdetachstate.3 \ + pthread_attr.3 pthread_attr_getinheritsched.3 \ + pthread_attr.3 pthread_attr_getschedparam.3 \ + pthread_attr.3 pthread_attr_getschedpolicy.3 \ + pthread_attr.3 pthread_attr_getscope.3 \ + pthread_attr.3 pthread_attr_getstackaddr.3 \ + pthread_attr.3 pthread_attr_getstacksize.3 \ + pthread_attr.3 pthread_attr_init.3 \ + pthread_attr.3 pthread_attr_setdetachstate.3 \ + pthread_attr.3 pthread_attr_setinheritsched.3 \ + pthread_attr.3 pthread_attr_setschedparam.3 \ + pthread_attr.3 pthread_attr_setschedpolicy.3 \ + pthread_attr.3 pthread_attr_setscope.3 \ + pthread_attr.3 pthread_attr_setstackaddr.3 \ + pthread_attr.3 pthread_attr_setstacksize.3 + +MLINKS+=pthread_getschedparam.3 pthread_setschedparam.3 + +MLINKS+=pthread_mutexattr.3 pthread_mutexattr_destroy.3 \ + pthread_mutexattr.3 pthread_mutexattr_getprioceiling.3 \ + pthread_mutexattr.3 pthread_mutexattr_getprotocol.3 \ + pthread_mutexattr.3 pthread_mutexattr_init.3 \ + pthread_mutexattr.3 pthread_mutexattr_setprioceiling.3 \ + pthread_mutexattr.3 pthread_mutexattr_setprotocol.3 + +MLINKS+=pthread_setcancelstate.3 pthread_setcanceltype.3 \ + pthread_setcancelstate.3 pthread_testcancel.3 + +MLINKS+=pthread_condattr.3 pthread_condattr_init.3 \ + pthread_condattr.3 pthread_condattr_destroy.3 + +MLINKS+=pthread_rwlock_rdlock.3 pthread_rwlock_tryrdlock.3 + +MLINKS+=pthread_rwlock_wrlock.3 pthread_rwlock_trywrlock.3 + +.endif + + diff --git a/pthreads.subproj/lock.s b/pthreads/lock.s similarity index 93% rename from pthreads.subproj/lock.s rename to pthreads/lock.s index baac7af..257bc1b 100644 --- a/pthreads.subproj/lock.s +++ b/pthreads/lock.s @@ -54,15 +54,18 @@ END(__spin_lock_try) .globl _spin_lock LEAF(__spin_lock) _spin_lock: - addi r4,0,0x1 // Lock value 1: lwarx r5,0,r3 // Read the lock + addi r4,0,0x1 // Lock value cmpwi r5,0x0 // Is it busy? - bne- 1b // Yes, spin + bne- 2f // Yes, goto retry logic stwcx. r4,0,r3 // Try to lock the lock bne- 1b // Lost reservation, try again isync // Sync instruction stream - blr // Got it, return + blr // Return +2: + CALL_EXTERN(__spin_lock_retry) + blr // Return END(__spin_lock) /* void spin_unlock(int *p); @@ -105,14 +108,17 @@ END(__spin_lock_try) LEAF(__spin_lock, 0) _spin_lock: movl 4(%esp), %ecx -1: movl (%ecx), %eax orl %eax, %eax - jnz 1b + jnz 1f movl $0xFFFFFFFF, %eax xchgl %eax, (%ecx) orl %eax, %eax - jnz 1b + jz 2f +1: pushl %ecx + CALL_EXTERN(__spin_lock_retry) + addl $4, %esp +2: END(__spin_lock) diff --git a/pthreads.subproj/mk_pthread_impl.c b/pthreads/mk_pthread_impl.c similarity index 100% rename from pthreads.subproj/mk_pthread_impl.c rename to pthreads/mk_pthread_impl.c diff --git a/pthreads.subproj/posix_sched.h b/pthreads/posix_sched.h similarity index 100% rename from pthreads.subproj/posix_sched.h rename to pthreads/posix_sched.h diff --git a/pthreads/pthread.3 b/pthreads/pthread.3 new file mode 100644 index 0000000..444e361 --- /dev/null +++ b/pthreads/pthread.3 @@ -0,0 +1,435 @@ +.\" Portions Copyright (c) 2001 Apple Computer, Inc. All Rights Reserved. +.\" Copyright (c) 1996 John Birrell . +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by John Birrell. +.\" 4. Neither the name of the author nor the names of any co-contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. +.\" +.\" $FreeBSD: src/share/man/man3/pthread.3,v 1.12.2.4 2001/08/17 13:08:36 ru Exp $ +.\" +.Dd November 5, 2001 +.Dt PTHREAD 3 +.Os Darwin +.Sh NAME +.Nm pthread +.Nd POSIX thread functions +.Sh SYNOPSIS +.Fd #include +.Sh DESCRIPTION +POSIX threads are a set of functions that support applications with +requirements for multiple flows of control, called +.Fa threads , +within a process. +Multithreading is used to improve the performance of a +program. +.Pp +The POSIX thread functions are summarized in this section in the following +groups: +.Bl -bullet -offset indent +.It +Thread Routines +.It +Attribute Object Routines +.It +Mutex Routines +.It +Condition Variable Routines +.It +Read/Write Lock Routines +.It +Per-Thread Context Routines +.It +Cleanup Routines +.El +.Sh THREAD ROUTINES +.Bl -tag -width Er +.It Xo +.Ft int +.Fn pthread_create "pthread_t *thread" "const pthread_attr_t *attr" "void *(*start_routine)(void *)" "void *arg" +.Xc +Creates a new thread of execution. +.It Xo +.Ft int +.Fn pthread_detach "pthread_t thread" +.Xc +Marks a thread for deletion. +.It Xo +.Ft int +.Fn pthread_equal "pthread_t t1" "pthread_t t2" +.Xc +Compares two thread IDs. +.It Xo +.Ft void +.Fn pthread_exit "void *value_ptr" +.Xc +Terminates the calling thread. +.It Xo +.Ft int +.Fn pthread_join "pthread_t thread" "void **value_ptr" +.Xc +Causes the calling thread to wait for the termination of the specified thread. +.It Xo +.Ft int +.Fn pthread_cancel "pthread_t thread" +.Xc +Cancels execution of a thread. +.It Xo +.Ft int +.Fn pthread_once "pthread_once_t *once_control" "void (*init_routine)(void)" +.Xc +Calls an initialization routine once. +.It Xo +.Ft pthread_t +.Fn pthread_self void +.Xc +Returns the thread ID of the calling thread. +.El +.Sh ATTRIBUTE OBJECT ROUTINES +.Bl -tag -width Er +.It Xo +.Ft int +.Fn pthread_attr_destroy "pthread_attr_t *attr" +.Xc +Destroy a thread attributes object. +.It Xo +.Ft int +.Fn pthread_attr_getinheritsched "const pthread_attr_t *attr" "int *inheritsched" +.Xc +Get the inherit scheduling attribute from a thread attributes object. +.It Xo +.Ft int +.Fn pthread_attr_getschedparam "const pthread_attr_t *attr" "struct sched_param *param" +.Xc +Get the scheduling parameter attribute from a thread attributes object. +.It Xo +.Ft int +.Fn pthread_attr_getschedpolicy "const pthread_attr_t *attr" "int *policy" +.Xc +Get the scheduling policy attribute from a thread attributes object. +.It Xo +.Ft int +.Fn pthread_attr_getscope "const pthread_attr_t *attr" "int *contentionscope" +.Xc +Get the contention scope attribute from a thread attributes object. +.It Xo +.Ft int +.Fn pthread_attr_getstacksize "const pthread_attr_t *attr" "size_t *stacksize" +.Xc +Get the stack size attribute from a thread attributes object. +.It Xo +.Ft int +.Fn pthread_attr_getstackaddr "const pthread_attr_t *attr" "void **stackaddr" +.Xc +Get the stack address attribute from a thread attributes object. +.It Xo +.Ft int +.Fn pthread_attr_getdetachstate "const pthread_attr_t *attr" "int *detachstate" +.Xc +Get the detach state attribute from a thread attributes object. +.It Xo +.Ft int +.Fn pthread_attr_init "pthread_attr_t *attr" +.Xc +Initialize a thread attributes object with default values. +.It Xo +.Ft int +.Fn pthread_attr_setinheritsched "pthread_attr_t *attr" "int inheritsched" +.Xc +Set the inherit scheduling attribute in a thread attributes object. +.It Xo +.Ft int +.Fn pthread_attr_setschedparam "pthread_attr_t *attr" "const struct sched_param *param" +.Xc +Set the scheduling parameter attribute in a thread attributes object. +.It Xo +.Ft int +.Fn pthread_attr_setschedpolicy "pthread_attr_t *attr" "int policy" +.Xc +Set the scheduling policy attribute in a thread attributes object. +.It Xo +.Ft int +.Fn pthread_attr_setscope "pthread_attr_t *attr" "int contentionscope" +.Xc +Set the contention scope attribute in a thread attributes object. +.It Xo +.Ft int +.Fn pthread_attr_setstacksize "pthread_attr_t *attr" "size_t stacksize" +.Xc +Set the stack size attribute in a thread attributes object. +.It Xo +.Ft int +.Fn pthread_attr_setstackaddr "pthread_attr_t *attr" "void *stackaddr" +.Xc +Set the stack address attribute in a thread attributes object. +.It Xo +.Ft int +.Fn pthread_attr_setdetachstate "pthread_attr_t *attr" "int detachstate" +.Xc +Set the detach state in a thread attributes object. +.El +.Sh MUTEX ROUTINES +.Bl -tag -width Er +.It Xo +.Ft int +.Fn pthread_mutexattr_destroy "pthread_mutexattr_t *attr" +.Xc +Destroy a mutex attributes object. +.It Xo +.Ft int +.Fn pthread_mutexattr_init "pthread_mutexattr_t *attr" +.Xc +Initialize a mutex attributes object with default values. +.It Xo +.Ft int +.Fn pthread_mutex_destroy "pthread_mutex_t *mutex" +.Xc +Destroy a mutex. +.It Xo +.Ft int +.Fn pthread_mutex_init "pthread_mutex_t *mutex" "const pthread_mutexattr_t *attr" +.Xc +Initialize a mutex with specified attributes. +.It Xo +.Ft int +.Fn pthread_mutex_lock "pthread_mutex_t *mutex" +.Xc +Lock a mutex and block until it becomes available. +.It Xo +.Ft int +.Fn pthread_mutex_trylock "pthread_mutex_t *mutex" +.Xc +Try to lock a mutex, but don't block if the mutex is locked by another thread, +including the current thread. +.It Xo +.Ft int +.Fn pthread_mutex_unlock "pthread_mutex_t *mutex" +.Xc +Unlock a mutex. +.El +.Sh CONDITION VARIABLE ROUTINES +.Bl -tag -width Er +.It Xo +.Ft int +.Fn pthread_condattr_init "pthread_condattr_t *attr" +.Xc +Initialize a condition variable attributes object with default values. +.It Xo +.Ft int +.Fn pthread_condattr_destroy "pthread_condattr_t *attr" +.Xc +Destroy a condition variable attributes object. +.It Xo +.Ft int +.Fn pthread_cond_broadcast "pthread_cond_t *cond" +.Xc +Unblock all threads currently blocked on the specified condition variable. +.It Xo +.Ft int +.Fn pthread_cond_destroy "pthread_cond_t *cond" +.Xc +Destroy a condition variable. +.It Xo +.Ft int +.Fn pthread_cond_init "pthread_cond_t *cond" "const pthread_condattr_t *attr" +.Xc +Initialize a condition variable with specified attributes. +.It Xo +.Ft int +.Fn pthread_cond_signal "pthread_cond_t *cond" +.Xc +Unblock at least one of the threads blocked on the specified condition variable. +.It Xo +.Ft int +.Fn pthread_cond_timedwait "pthread_cond_t *cond" "pthread_mutex_t *mutex" "const struct timespec *abstime" +.Xc +Wait no longer than the specified time for a condition and lock the specified mutex. +.It Xo +.Ft int +.Fn pthread_cond_wait "pthread_cond_t *" "pthread_mutex_t *mutex" +.Xc +Wait for a condition and lock the specified mutex. +.El +.Sh READ/WRITE LOCK ROUTINES +.Bl -tag -width Er +.It Xo +.Ft int +.Fn pthread_rwlock_destroy "pthread_rwlock_t *lock" +.Xc +Destroy a read/write lock object. +.It Xo +.Ft int +.Fn pthread_rwlock_init "pthread_rwlock_t *lock" "const pthread_rwlockattr_t *attr" +.Xc +Initialize a read/write lock object. +.It Xo +.Ft int +.Fn pthread_rwlock_rdlock "pthread_rwlock_t *lock" +.Xc +Lock a read/write lock for reading, blocking until the lock can be +acquired. +.It Xo +.Ft int +.Fn pthread_rwlock_tryrdlock "pthread_rwlock_t *lock" +.Xc +Attempt to lock a read/write lock for reading, without blocking if the +lock is unavailable. +.It Xo +.Ft int +.Fn pthread_rwlock_trywrlock "pthread_rwlock_t *lock" +.Xc +Attempt to lock a read/write lock for writing, without blocking if the +lock is unavailable. +.It Xo +.Ft int +.Fn pthread_rwlock_unlock "pthread_rwlock_t *lock" +.Xc +Unlock a read/write lock. +.It Xo +.Ft int +.Fn pthread_rwlock_wrlock "pthread_rwlock_t *lock" +.Xc +Lock a read/write lock for writing, blocking until the lock can be +acquired. +.It Xo +.Ft int +.Fn pthread_rwlockattr_destroy "pthread_rwlockattr_t *attr" +.Xc +Destroy a read/write lock attribute object. +.It Xo +.Ft int +.Fn pthread_rwlockattr_getpshared "const pthread_rwlockattr_t *attr" "int *pshared" +.Xc +Retrieve the process shared setting for the read/write lock attribute +object. +.It Xo +.Ft int +.Fn pthread_rwlockattr_init "pthread_rwlockattr_t *attr" +.Xc +Initialize a read/write lock attribute object. +.It Xo +.Ft int +.Fn pthread_rwlockattr_setpshared "pthread_rwlockattr_t *attr" "int pshared" +.Xc +Set the process shared setting for the read/write lock attribute object. +.El +.Sh PER-THREAD CONTEXT ROUTINES +.Bl -tag -width Er +.It Xo +.Ft int +.Fn pthread_key_create "pthread_key_t *key" "void (*routine)(void *)" +.Xc +Create a thread-specific data key. +.It Xo +.Ft int +.Fn pthread_key_delete "pthread_key_t key" +.Xc +Delete a thread-specific data key. +.It Xo +.Ft "void *" +.Fn pthread_getspecific "pthread_key_t key" +.Xc +Get the thread-specific value for the specified key. +.It Xo +.Ft int +.Fn pthread_setspecific "pthread_key_t key" "const void *value_ptr" +.Xc +Set the thread-specific value for the specified key. +.El +.Sh CLEANUP ROUTINES +.Bl -tag -width Er +.It Xo +.Ft void +.Fn pthread_cleanup_pop "int execute" +.Xc +Remove the routine at the top of the calling thread's cancellation cleanup +stack and optionally invoke it. +.It Xo +.Ft void +.Fn pthread_cleanup_push "void (*routine)(void *)" "void *routine_arg" +.Xc +Push the specified cancellation cleanup handler onto the calling thread's +cancellation stack. +.El +.Sh INSTALLATION +The default system libraries include +.Nm +funcitons. No additional libraries or CFLAGS are necessary to use this API. +.Sh SEE ALSO +.Xr pthread_cleanup_pop 3 , +.Xr pthread_cleanup_push 3 , +.Xr pthread_cond_broadcast 3 , +.Xr pthread_cond_destroy 3 , +.Xr pthread_cond_init 3 , +.Xr pthread_cond_signal 3 , +.Xr pthread_cond_timedwait 3 , +.Xr pthread_cond_wait 3 , +.Xr pthread_create 3 , +.Xr pthread_detach 3 , +.Xr pthread_equal 3 , +.Xr pthread_exit 3 , +.Xr pthread_getspecific 3 , +.Xr pthread_join 3 , +.Xr pthread_key_delete 3 , +.Xr pthread_mutex_destroy 3 , +.Xr pthread_mutex_init 3 , +.Xr pthread_mutex_lock 3 , +.Xr pthread_mutex_trylock 3 , +.Xr pthread_mutex_unlock 3 , +.Xr pthread_once 3 , +.Xr pthread_rwlockattr_destroy 3 , +.Xr pthread_rwlockattr_getpshared 3 , +.Xr pthread_rwlockattr_init 3 , +.Xr pthread_rwlockattr_setpshared 3 , +.Xr pthread_rwlock_destroy 3 , +.Xr pthread_rwlock_init 3 , +.Xr pthread_rwlock_rdlock 3 , +.Xr pthread_rwlock_unlock 3 , +.Xr pthread_rwlock_wrlock 3 , +.Xr pthread_self 3 , +.Xr pthread_setspecific 3 +.Sh STANDARDS +The functions in +.Fa libc +with the +.Fa pthread_ +prefix and not +.Fa _np +suffix or +.Fa pthread_rwlock +prefix conform to +.St -p1003.1-96 . +.Pp +The functions in libc with the +.Fa pthread_ +prefix and +.Fa _np +suffix are non-portable extensions to POSIX threads. +.Pp +The functions in libc with the +.Fa pthread_rwlock +prefix are extensions created by The Open Group as part of the +.St -susv2 . diff --git a/pthreads.subproj/pthread.c b/pthreads/pthread.c similarity index 67% rename from pthreads.subproj/pthread.c rename to pthreads/pthread.c index 3a927bd..14d7446 100644 --- a/pthreads.subproj/pthread.c +++ b/pthreads/pthread.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -50,20 +51,35 @@ extern void set_malloc_singlethreaded(int); /* Used when we need to call into the kernel with no reply port */ extern pthread_lock_t reply_port_lock; -/* - * [Internal] stack support - */ +/* We'll implement this when the main thread is a pthread */ +/* Use the local _pthread struct to avoid malloc before our MiG reply port is set */ +static struct _pthread _thread = {0}; -size_t _pthread_stack_size = 0; +/* This global should be used (carefully) by anyone needing to know if a +** pthread has been created. +*/ +int __is_threaded = 0; +static int _pthread_count = 1; + +static pthread_lock_t _pthread_count_lock = LOCK_INITIALIZER; + +/* Same implementation as LOCK, but without the __is_threaded check */ int _spin_tries = 0; -#if !defined(__ppc__) +__private_extern__ void _spin_lock_retry(pthread_lock_t *lock) +{ + int tries = _spin_tries; + do { + if (tries-- > 0) + continue; + syscall_thread_switch(THREAD_NULL, SWITCH_OPTION_DEPRESS, 1); + tries = _spin_tries; + } while(!_spin_lock_try(lock)); +} + +/* Apparently, bcopy doesn't declare _cpu_has_altivec anymore */ int _cpu_has_altivec = 0; -#endif -/* This global should be used (carefully) by anyone needing to know if a pthread has been -** created. -*/ -int __is_threaded = 0; +extern mach_port_t thread_recycle_port; /* These are used to keep track of a semaphore pool shared by mutexes and condition ** variables. @@ -77,9 +93,12 @@ static pthread_lock_t sem_pool_lock = LOCK_INITIALIZER; static int default_priority; static int max_priority; static int min_priority; +static int pthread_concurrency; -extern mach_port_t thread_recycle_port; - +/* + * [Internal] stack support + */ +size_t _pthread_stack_size = 0; #define STACK_LOWEST(sp) ((sp) & ~__pthread_stack_mask) #define STACK_RESERVED (sizeof (struct _pthread)) @@ -107,33 +126,52 @@ extern mach_port_t thread_recycle_port; #endif +#if defined(__ppc__) +static const vm_address_t PTHREAD_STACK_HINT = 0xF0000000; +#elif defined(__i386__) +static const vm_address_t PTHREAD_STACK_HINT = 0xB0000000; +#else +#error Need to define a stack address hint for this architecture +#endif + /* Set the base address to use as the stack pointer, before adjusting due to the ABI */ static int -_pthread_allocate_stack(pthread_attr_t *attrs, vm_address_t *stack) +_pthread_allocate_stack(pthread_attr_t *attrs, void **stack) { kern_return_t kr; #if 1 assert(attrs->stacksize >= PTHREAD_STACK_MIN); if (attrs->stackaddr != NULL) { - assert(((vm_offset_t)(attrs->stackaddr) & (vm_page_size - 1)) == 0); - *stack = (vm_address_t)attrs->stackaddr; - return 0; + assert(((vm_address_t)(attrs->stackaddr) & (vm_page_size - 1)) == 0); + *stack = attrs->stackaddr; + return 0; } - kr = vm_allocate(mach_task_self(), stack, attrs->stacksize + vm_page_size, VM_MAKE_TAG(VM_MEMORY_STACK)| TRUE); + + *((vm_address_t *)stack) = PTHREAD_STACK_HINT; + kr = vm_map(mach_task_self(), (vm_address_t *)stack, + attrs->stacksize + vm_page_size, + vm_page_size-1, + VM_MAKE_TAG(VM_MEMORY_STACK)| VM_FLAGS_ANYWHERE , MEMORY_OBJECT_NULL, + 0, FALSE, VM_PROT_DEFAULT, VM_PROT_ALL, + VM_INHERIT_DEFAULT); + if (kr != KERN_SUCCESS) + kr = vm_allocate(mach_task_self(), + (vm_address_t *)stack, attrs->stacksize + vm_page_size, + VM_MAKE_TAG(VM_MEMORY_STACK)| VM_FLAGS_ANYWHERE); if (kr != KERN_SUCCESS) { return EAGAIN; } -#ifdef STACK_GROWS_UP - /* The guard page is the page one higher than the stack */ - /* The stack base is at the lowest address */ + #ifdef STACK_GROWS_UP + /* The guard page is the page one higher than the stack */ + /* The stack base is at the lowest address */ kr = vm_protect(mach_task_self(), *stack + attrs->stacksize, vm_page_size, FALSE, VM_PROT_NONE); -#else - /* The guard page is at the lowest address */ - /* The stack base is the highest address */ - kr = vm_protect(mach_task_self(), *stack, vm_page_size, FALSE, VM_PROT_NONE); + #else + /* The guard page is at the lowest address */ + /* The stack base is the highest address */ + kr = vm_protect(mach_task_self(), (vm_address_t)*stack, vm_page_size, FALSE, VM_PROT_NONE); *stack += attrs->stacksize + vm_page_size; -#endif + #endif #else vm_address_t cur_stack = (vm_address_t)0; @@ -227,6 +265,8 @@ _pthread_allocate_stack(pthread_attr_t *attrs, vm_address_t *stack) return 0; } +static pthread_attr_t _pthread_attr_default = {0}; + /* * Destroy a thread attribute structure */ @@ -508,6 +548,33 @@ pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize) } } +int +pthread_attr_getstack(const pthread_attr_t *attr, void **stackaddr, size_t * stacksize) +{ + if (attr->sig == _PTHREAD_ATTR_SIG) { + *stackaddr = attr->stackaddr; + *stacksize = attr->stacksize; + return (ESUCCESS); + } else { + return (EINVAL); /* Not an attribute structure! */ + } +} + +int +pthread_attr_setstack(pthread_attr_t *attr, void *stackaddr, size_t stacksize) +{ + if ((attr->sig == _PTHREAD_ATTR_SIG) && + (((vm_offset_t)stackaddr & (vm_page_size - 1)) == 0) && + ((stacksize % vm_page_size) == 0) && (stacksize >= PTHREAD_STACK_MIN)) { + attr->stackaddr = stackaddr; + attr->freeStackOnExit = FALSE; + attr->stacksize = stacksize; + return (ESUCCESS); + } else { + return (EINVAL); /* Not an attribute structure! */ + } +} + /* * Create and start execution of a new thread. */ @@ -522,12 +589,12 @@ _pthread_body(pthread_t self) int _pthread_create(pthread_t t, const pthread_attr_t *attrs, - vm_address_t stack, + void *stack, const mach_port_t kernel_thread) { int res; - kern_return_t kern_res; res = ESUCCESS; + do { memset(t, 0, sizeof(*t)); @@ -546,49 +613,42 @@ _pthread_create(pthread_t t, LOCK_INIT(t->lock); t->cancel_state = PTHREAD_CANCEL_ENABLE | PTHREAD_CANCEL_DEFERRED; t->cleanup_stack = (struct _pthread_handler_rec *)NULL; - pthread_setschedparam(t, t->policy, &t->param); - /* Create control semaphores */ - if (t->detached == PTHREAD_CREATE_JOINABLE) - { - PTHREAD_MACH_CALL(semaphore_create(mach_task_self(), - &t->death, - SYNC_POLICY_FIFO, - 0), kern_res); - if (kern_res != KERN_SUCCESS) - { - printf("Can't create 'death' semaphore: %d\n", kern_res); - res = EINVAL; /* Need better error here? */ - break; - } - PTHREAD_MACH_CALL(semaphore_create(mach_task_self(), - &t->joiners, - SYNC_POLICY_FIFO, - 0), kern_res); - if (kern_res != KERN_SUCCESS) - { - printf("Can't create 'joiners' semaphore: %d\n", kern_res); - res = EINVAL; /* Need better error here? */ - break; - } - t->num_joiners = 0; - } else - { - t->death = MACH_PORT_NULL; - } + t->death = SEMAPHORE_NULL; + + if (kernel_thread != MACH_PORT_NULL) + pthread_setschedparam(t, t->policy, &t->param); } while (0); return (res); } +/* Need to deprecate this in future */ int _pthread_is_threaded(void) { return __is_threaded; } +/* Non portable public api to know whether this process has(had) atleast one thread + * apart from main thread. There could be race if there is a thread in the process of + * creation at the time of call . It does not tell whether there are more than one thread + * at this point of time. + */ +int +pthread_is_threaded_np(void) +{ + return (__is_threaded); +} + mach_port_t pthread_mach_thread_np(pthread_t t) { - return t->kernel_thread; + thread_t kernel_thread; + + /* Wait for the creator to initialize it */ + while ((kernel_thread = t->kernel_thread) == MACH_PORT_NULL) + sched_yield(); + + return kernel_thread; } size_t @@ -609,6 +669,16 @@ _pthread_reply_port(pthread_t t) return t->reply_port; } + +/* returns non-zero if the current thread is the main thread */ +int +pthread_main_np(void) +{ + pthread_t self = pthread_self(); + + return ((self->detached & _PTHREAD_CREATE_PARENT) == _PTHREAD_CREATE_PARENT); +} + static int _pthread_create_suspended(pthread_t *thread, const pthread_attr_t *attr, @@ -616,20 +686,32 @@ _pthread_create_suspended(pthread_t *thread, void *arg, int suspended) { - pthread_attr_t _attr, *attrs; - vm_address_t stack; + pthread_attr_t *attrs; + void *stack; int res; pthread_t t; kern_return_t kern_res; - mach_port_t kernel_thread; + mach_port_t kernel_thread = MACH_PORT_NULL; + int needresume; + if ((attrs = (pthread_attr_t *)attr) == (pthread_attr_t *)NULL) { /* Set up default paramters */ - attrs = &_attr; - pthread_attr_init(attrs); - } else if (attrs->sig != _PTHREAD_ATTR_SIG) { + attrs = &_pthread_attr_default; + } else if (attrs->sig != _PTHREAD_ATTR_SIG) { return EINVAL; - } + } res = ESUCCESS; + + /* In default policy (ie SCHED_OTHER) only sched_priority is used. Check for + * any change in priority or policy is needed here. + */ + if (((attrs->policy != _PTHREAD_DEFAULT_POLICY) || + (attrs->param.sched_priority != default_priority)) && (suspended == 0)) { + needresume = 1; + suspended = 1; + } else + needresume = 0; + do { /* Allocate a stack for the thread */ @@ -638,34 +720,31 @@ _pthread_create_suspended(pthread_t *thread, } t = (pthread_t)malloc(sizeof(struct _pthread)); *thread = t; - /* Create the Mach thread for this thread */ - PTHREAD_MACH_CALL(thread_create(mach_task_self(), &kernel_thread), kern_res); - if (kern_res != KERN_SUCCESS) - { - printf("Can't create thread: %d\n", kern_res); - res = EINVAL; /* Need better error here? */ - break; + if (suspended) { + /* Create the Mach thread for this thread */ + PTHREAD_MACH_CALL(thread_create(mach_task_self(), &kernel_thread), kern_res); + if (kern_res != KERN_SUCCESS) + { + printf("Can't create thread: %d\n", kern_res); + res = EINVAL; /* Need better error here? */ + break; + } } if ((res = _pthread_create(t, attrs, stack, kernel_thread)) != 0) { break; } + set_malloc_singlethreaded(0); + __is_threaded = 1; + LOCK(_pthread_count_lock); + _pthread_count++; + UNLOCK(_pthread_count_lock); + + /* Send it on it's way */ t->arg = arg; t->fun = start_routine; /* Now set it up to execute */ - _pthread_setup(t, _pthread_body, stack); - /* Send it on it's way */ - set_malloc_singlethreaded(0); - __is_threaded = 1; - if (suspended == 0) { - PTHREAD_MACH_CALL(thread_resume(kernel_thread), kern_res); - } - if (kern_res != KERN_SUCCESS) - { - printf("Can't resume thread: %d\n", kern_res); - res = EINVAL; /* Need better error here? */ - break; - } + _pthread_setup(t, _pthread_body, stack, suspended, needresume); } while (0); return (res); } @@ -694,115 +773,159 @@ pthread_create_suspended_np(pthread_t *thread, int pthread_detach(pthread_t thread) { - kern_return_t kern_res; - int num_joiners; - mach_port_t death; if (thread->sig == _PTHREAD_SIG) { LOCK(thread->lock); - if (thread->detached == PTHREAD_CREATE_JOINABLE) + if (thread->detached & PTHREAD_CREATE_JOINABLE) { - thread->detached = PTHREAD_CREATE_DETACHED; - num_joiners = thread->num_joiners; - death = thread->death; - thread->death = MACH_PORT_NULL; - UNLOCK(thread->lock); - if (num_joiners > 0) - { - /* Wake up a joiner */ - PTHREAD_MACH_CALL(semaphore_signal(thread->joiners), kern_res); + if (thread->detached & _PTHREAD_EXITED) { + UNLOCK(thread->lock); + pthread_join(thread, NULL); + return ESUCCESS; + } else { + semaphore_t death = thread->death; + + thread->detached &= ~PTHREAD_CREATE_JOINABLE; + thread->detached |= PTHREAD_CREATE_DETACHED; + UNLOCK(thread->lock); + if (death) + (void) semaphore_signal(death); + return (ESUCCESS); } - /* Destroy 'control' semaphores */ - PTHREAD_MACH_CALL(semaphore_destroy(mach_task_self(), - thread->joiners), kern_res); - PTHREAD_MACH_CALL(semaphore_destroy(mach_task_self(), - death), kern_res); - return (ESUCCESS); - } else if (thread->detached == _PTHREAD_EXITED) { - UNLOCK(thread->lock); - pthread_join(thread, NULL); - return ESUCCESS; - } else - { + } else { UNLOCK(thread->lock); return (EINVAL); } - } else - { + } else { return (ESRCH); /* Not a valid thread */ } } -/* Announce that there is a thread ready to be reclaimed for pthread_create */ -/* or terminated by pthread_exit. If the thread is reused, it will have its */ -/* thread state set and will continue in the thread body function. If it is */ -/* terminated, it will be yanked out from under the mach_msg() call. */ -static void _pthread_become_available(pthread_t thread) { - mach_msg_empty_rcv_t msg = { { 0 } }; - kern_return_t ret; +/* + * pthread_kill call to system call + */ - if (thread->reply_port == MACH_PORT_NULL) { - thread->reply_port = mach_reply_port(); + +int +pthread_kill ( + pthread_t th, + int sig) +{ + int error = 0; + + if ((sig < 0) || (sig > NSIG)) + return(EINVAL); + + if (th && (th->sig == _PTHREAD_SIG)) { + error = __pthread_kill(pthread_mach_thread_np(th), sig); + if (error == -1) + error = errno; + return(error); } + else + return(ESRCH); +} + +/* Announce that there are pthread resources ready to be reclaimed in a */ +/* subsequent pthread_exit or reaped by pthread_join. In either case, the Mach */ +/* thread underneath is terminated right away. */ +static +void _pthread_become_available(pthread_t thread, mach_port_t kernel_thread) { + mach_msg_empty_rcv_t msg; + kern_return_t ret; + + msg.header.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_MAKE_SEND, + MACH_MSG_TYPE_MOVE_SEND); msg.header.msgh_size = sizeof msg - sizeof msg.trailer; msg.header.msgh_remote_port = thread_recycle_port; - msg.header.msgh_local_port = MACH_PORT_NULL; + msg.header.msgh_local_port = kernel_thread; msg.header.msgh_id = (int)thread; - msg.header.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, 0); - ret = mach_msg(&msg.header, MACH_SEND_MSG | MACH_RCV_MSG, - msg.header.msgh_size, sizeof msg, - thread->reply_port, MACH_MSG_TIMEOUT_NONE, - MACH_PORT_NULL); - while (1) { - ret = thread_suspend(thread->kernel_thread); - } - /* We should never get here */ + ret = mach_msg_send(&msg.header); + assert(ret == MACH_MSG_SUCCESS); } -/* Check to see if any threads are available. Return immediately */ +/* Reap the resources for available threads */ +static +int _pthread_reap_thread(pthread_t th, mach_port_t kernel_thread, void **value_ptr) { + mach_port_type_t ptype; + kern_return_t ret; + task_t self; + + self = mach_task_self(); + if (kernel_thread != MACH_PORT_DEAD) { + ret = mach_port_type(self, kernel_thread, &ptype); + if (ret == KERN_SUCCESS && ptype != MACH_PORT_TYPE_DEAD_NAME) { + /* not quite dead yet... */ + return EAGAIN; + } + ret = mach_port_deallocate(self, kernel_thread); + if (ret != KERN_SUCCESS) { + fprintf(stderr, + "mach_port_deallocate(kernel_thread) failed: %s\n", + mach_error_string(ret)); + } + } -static kern_return_t _pthread_check_for_available_threads(mach_msg_empty_rcv_t *msg) { - return mach_msg(&msg->header, MACH_RCV_MSG|MACH_RCV_TIMEOUT, 0, - sizeof(mach_msg_empty_rcv_t), thread_recycle_port, 0, - MACH_PORT_NULL); -} + if (th->reply_port != MACH_PORT_NULL) { + ret = mach_port_mod_refs(self, th->reply_port, + MACH_PORT_RIGHT_RECEIVE, -1); + if (ret != KERN_SUCCESS) { + fprintf(stderr, + "mach_port_mod_refs(reply_port) failed: %s\n", + mach_error_string(ret)); + } + } -/* Terminate all available threads and deallocate their stacks */ -static void _pthread_reap_threads(void) { - kern_return_t ret; - mach_msg_empty_rcv_t msg = { { 0 } }; - while((ret = _pthread_check_for_available_threads(&msg)) == KERN_SUCCESS) { - pthread_t th = (pthread_t)msg.header.msgh_id; - mach_port_t kernel_thread = th->kernel_thread; - mach_port_t reply_port = th->reply_port; - vm_size_t size = (vm_size_t)th->stacksize + vm_page_size; + if (th->freeStackOnExit) { vm_address_t addr = (vm_address_t)th->stackaddr; + vm_size_t size; + + size = (vm_size_t)th->stacksize + vm_page_size; + #if !defined(STACK_GROWS_UP) addr -= size; #endif - ret = thread_terminate(kernel_thread); - if (ret != KERN_SUCCESS) { - fprintf(stderr, "thread_terminate() failed: %s\n", - mach_error_string(ret)); - } - ret = mach_port_destroy(mach_task_self(), reply_port); + ret = vm_deallocate(self, addr, size); if (ret != KERN_SUCCESS) { - fprintf(stderr, - "mach_port_destroy(thread_reply) failed: %s\n", - mach_error_string(ret)); - } - if (th->freeStackOnExit) { - ret = vm_deallocate(mach_task_self(), addr, size); - if (ret != KERN_SUCCESS) { - fprintf(stderr, - "vm_deallocate(stack) failed: %s\n", - mach_error_string(ret)); - } + fprintf(stderr, + "vm_deallocate(stack) failed: %s\n", + mach_error_string(ret)); } + } + + if (value_ptr) + *value_ptr = th->exit_value; + + if (th != &_thread) free(th); + + return ESUCCESS; +} + +static +void _pthread_reap_threads(void) +{ + mach_msg_empty_rcv_t msg; + kern_return_t ret; + + ret = mach_msg(&msg.header, MACH_RCV_MSG|MACH_RCV_TIMEOUT, 0, + sizeof(mach_msg_empty_rcv_t), thread_recycle_port, + MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + while (ret == MACH_MSG_SUCCESS) { + mach_port_t kernel_thread = msg.header.msgh_remote_port; + pthread_t thread = (pthread_t)msg.header.msgh_id; + + if (_pthread_reap_thread(thread, kernel_thread, (void **)0) == EAGAIN) + { + /* not dead yet, put it back for someone else to reap, stop here */ + _pthread_become_available(thread, kernel_thread); + return; + } + ret = mach_msg(&msg.header, MACH_RCV_MSG|MACH_RCV_TIMEOUT, 0, + sizeof(mach_msg_empty_rcv_t), thread_recycle_port, + MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); } - assert(ret == MACH_RCV_TIMED_OUT); } /* For compatibility... */ @@ -818,48 +941,55 @@ _pthread_self() { void pthread_exit(void *value_ptr) { + struct _pthread_handler_rec *handler; pthread_t self = pthread_self(); - struct _pthread_handler_rec *handler; kern_return_t kern_res; - int num_joiners; + int thread_count; + + /* Make this thread not to receive any signals */ + syscall(331,1); + while ((handler = self->cleanup_stack) != 0) { (handler->routine)(handler->arg); self->cleanup_stack = handler->next; } _pthread_tsd_cleanup(self); + + _pthread_reap_threads(); + LOCK(self->lock); - if (self->detached == PTHREAD_CREATE_JOINABLE) - { - self->detached = _PTHREAD_EXITED; + self->detached |= _PTHREAD_EXITED; + + if (self->detached & PTHREAD_CREATE_JOINABLE) { + mach_port_t death = self->death; self->exit_value = value_ptr; - num_joiners = self->num_joiners; UNLOCK(self->lock); - if (num_joiners > 0) - { - /* POSIX says that multiple pthread_join() calls on */ - /* the same thread are undefined so we just wake up */ - /* the first one to join */ - PTHREAD_MACH_CALL(semaphore_signal(self->joiners), kern_res); + /* the joiner will need a kernel thread reference, leave ours for it */ + if (death) { + PTHREAD_MACH_CALL(semaphore_signal(death), kern_res); + if (kern_res != KERN_SUCCESS) + fprintf(stderr, + "semaphore_signal(death) failed: %s\n", + mach_error_string(kern_res)); } - do { - PTHREAD_MACH_CALL(semaphore_wait(self->death), kern_res); - } while (kern_res == KERN_ABORTED); - } else + } else { UNLOCK(self->lock); - /* Destroy thread & reclaim resources */ - if (self->death) - { - PTHREAD_MACH_CALL(semaphore_destroy(mach_task_self(), self->joiners), kern_res); - PTHREAD_MACH_CALL(semaphore_destroy(mach_task_self(), self->death), kern_res); - } - if (self->detached == _PTHREAD_CREATE_PARENT) { - exit((int)(self->exit_value)); + /* with no joiner, we let become available consume our cached ref */ + _pthread_become_available(self, pthread_mach_thread_np(self)); } - _pthread_reap_threads(); - - _pthread_become_available(self); + LOCK(_pthread_count_lock); + thread_count = --_pthread_count; + UNLOCK(_pthread_count_lock); + if (thread_count <= 0) + exit(0); + + /* Use a new reference to terminate ourselves. Should never return. */ + PTHREAD_MACH_CALL(thread_terminate(mach_thread_self()), kern_res); + fprintf(stderr, "thread_terminate(mach_thread_self()) failed: %s\n", + mach_error_string(kern_res)); + abort(); } /* @@ -870,44 +1000,54 @@ pthread_join(pthread_t thread, void **value_ptr) { kern_return_t kern_res; + int res = ESUCCESS; + if (thread->sig == _PTHREAD_SIG) { + semaphore_t death = new_sem_from_pool(); /* in case we need it */ + LOCK(thread->lock); - if (thread->detached == PTHREAD_CREATE_JOINABLE) - { - thread->num_joiners++; - UNLOCK(thread->lock); - do { - PTHREAD_MACH_CALL(semaphore_wait(thread->joiners), kern_res); - } while (kern_res == KERN_ABORTED); - LOCK(thread->lock); - thread->num_joiners--; - } - if (thread->detached == _PTHREAD_EXITED) + if ((thread->detached & PTHREAD_CREATE_JOINABLE) && + thread->death == SEMAPHORE_NULL) { - if (thread->num_joiners == 0) - { /* Give the result to this thread */ - if (value_ptr) + pthread_t self = pthread_self(); + + assert(thread->joiner == NULL); + if (thread != self && (self == NULL || self->joiner != thread)) + { + int already_exited = (thread->detached & _PTHREAD_EXITED); + + thread->death = death; + thread->joiner = self; + UNLOCK(thread->lock); + + if (!already_exited) { - *value_ptr = thread->exit_value; + /* Wait for it to signal... */ + do { + PTHREAD_MACH_CALL(semaphore_wait(death), kern_res); + } while (kern_res != KERN_SUCCESS); } + + /* ... and wait for it to really be dead */ + while ((res = _pthread_reap_thread(thread, + thread->kernel_thread, + value_ptr)) == EAGAIN) + { + sched_yield(); + } + } else { UNLOCK(thread->lock); - PTHREAD_MACH_CALL(semaphore_signal(thread->death), kern_res); - return (ESUCCESS); - } else - { /* This 'joiner' missed the catch! */ - UNLOCK(thread->lock); - return (ESRCH); + res = EDEADLK; } - } else - { /* The thread has become anti-social! */ + } else { UNLOCK(thread->lock); - return (EINVAL); + res = EINVAL; } - } else - { - return (ESRCH); /* Not a valid thread */ + restore_sem_to_pool(death); + return res; } + return ESRCH; } /* @@ -968,7 +1108,7 @@ pthread_setschedparam(pthread_t thread, } thread->policy = policy; thread->param = *param; - ret = thread_policy(thread->kernel_thread, policy, base, count, TRUE); + ret = thread_policy(pthread_mach_thread_np(thread), policy, base, count, TRUE); if (ret != KERN_SUCCESS) { return (EINVAL); @@ -1093,7 +1233,8 @@ pthread_setcancelstate(int state, int *oldstate) pthread_t self = pthread_self(); int err = ESUCCESS; LOCK(self->lock); - *oldstate = self->cancel_state & _PTHREAD_CANCEL_STATE_MASK; + if (oldstate) + *oldstate = self->cancel_state & ~_PTHREAD_CANCEL_STATE_MASK; if ((state == PTHREAD_CANCEL_ENABLE) || (state == PTHREAD_CANCEL_DISABLE)) { self->cancel_state = (self->cancel_state & _PTHREAD_CANCEL_STATE_MASK) | state; @@ -1115,7 +1256,8 @@ pthread_setcanceltype(int type, int *oldtype) pthread_t self = pthread_self(); int err = ESUCCESS; LOCK(self->lock); - *oldtype = self->cancel_state & _PTHREAD_CANCEL_TYPE_MASK; + if (oldtype) + *oldtype = self->cancel_state & ~_PTHREAD_CANCEL_TYPE_MASK; if ((type == PTHREAD_CANCEL_DEFERRED) || (type == PTHREAD_CANCEL_ASYNCHRONOUS)) { self->cancel_state = (self->cancel_state & _PTHREAD_CANCEL_TYPE_MASK) | type; @@ -1128,34 +1270,55 @@ pthread_setcanceltype(int type, int *oldtype) return (err); } +int +pthread_getconcurrency(void) +{ + return(pthread_concurrency); +} + +int +pthread_setconcurrency(int new_level) +{ + pthread_concurrency = new_level; + return(ESUCCESS); +} + /* * Perform package initialization - called automatically when application starts */ -/* We'll implement this when the main thread is a pthread */ -/* Use the local _pthread struct to avoid malloc before our MiG reply port is set */ +extern int _cpu_capabilities; -static struct _pthread _thread = {0}; +#define kHasAltivec 0x01 +#define kCache32 0x04 +#define kUseDcba 0x20 +#define kNoDcba 0x40 static int pthread_init(void) { - pthread_attr_t _attr, *attrs; + pthread_attr_t *attrs; pthread_t thread; kern_return_t kr; host_basic_info_data_t basic_info; host_priority_info_data_t priority_info; host_info_t info; host_flavor_t flavor; + host_t host; mach_msg_type_number_t count; int mib[2]; size_t len; int hasvectorunit, numcpus; + + extern int _bcopy_initialize(void); + int dynamic_choice; + count = HOST_PRIORITY_INFO_COUNT; info = (host_info_t)&priority_info; flavor = HOST_PRIORITY_INFO; - kr = host_info(mach_host_self(), flavor, info, &count); + host = mach_host_self(); + kr = host_info(host, flavor, info, &count); if (kr != KERN_SUCCESS) printf("host_info failed (%d); probably need privilege.\n", kr); else { @@ -1163,13 +1326,13 @@ pthread_init(void) min_priority = priority_info.minimum_priority; max_priority = priority_info.maximum_priority; } - attrs = &_attr; + attrs = &_pthread_attr_default; pthread_attr_init(attrs); - _pthread_set_self(&_thread); - _pthread_create(&_thread, attrs, USRSTACK, mach_thread_self()); - thread = &_thread; - thread->detached = _PTHREAD_CREATE_PARENT; + thread = &_thread; + _pthread_set_self(thread); + _pthread_create(thread, attrs, (void *)USRSTACK, mach_thread_self()); + thread->detached = PTHREAD_CREATE_JOINABLE|_PTHREAD_CREATE_PARENT; /* See if we're on a multiprocessor and set _spin_tries if so. */ mib[0] = CTL_HW; @@ -1183,7 +1346,7 @@ pthread_init(void) count = HOST_BASIC_INFO_COUNT; info = (host_info_t)&basic_info; flavor = HOST_BASIC_INFO; - kr = host_info(mach_host_self(), flavor, info, &count); + kr = host_info(host, flavor, info, &count); if (kr != KERN_SUCCESS) printf("host_info failed (%d)\n", kr); else { @@ -1194,12 +1357,22 @@ pthread_init(void) _cpu_has_altivec = 1; } } + mach_port_deallocate(mach_task_self(), host); + mib[0] = CTL_HW; mib[1] = HW_VECTORUNIT; len = sizeof(hasvectorunit); if (sysctl(mib, 2, &hasvectorunit, &len, NULL, 0) == 0) { _cpu_has_altivec = hasvectorunit; } + if (_cpu_has_altivec) { // G4, let bcopy decide whether to use dcba + _cpu_capabilities = kCache32 + kHasAltivec; + } else { // G3, no altivec and no dcba + _cpu_capabilities = kCache32 + kNoDcba; + } + + dynamic_choice = _bcopy_initialize(); // returns 0, kUseDcba, or kNoDcba + _cpu_capabilities |= dynamic_choice; // remember dynamic choice, if any mig_init(1); /* enable multi-threaded mig interfaces */ return 0; } @@ -1252,5 +1425,7 @@ __private_extern__ void _pthread_fork_child(void) { /* Just in case somebody had it locked... */ UNLOCK(sem_pool_lock); sem_pool_reset(); + UNLOCK(_pthread_count_lock); + _pthread_count = 1; } diff --git a/pthreads.subproj/pthread.h b/pthreads/pthread.h similarity index 74% rename from pthreads.subproj/pthread.h rename to pthreads/pthread.h index 0f1ea58..d110560 100644 --- a/pthreads.subproj/pthread.h +++ b/pthreads/pthread.h @@ -36,9 +36,13 @@ #include #include #include -#include #include #include +#include + +#ifndef _POSIX_C_SOURCE +#include +#endif /* ! _POSIX_C_SOURCE */ /* * These symbols indicate which [optional] features are available @@ -112,23 +116,34 @@ __BEGIN_DECLS #define PTHREAD_SCOPE_SYSTEM 1 #define PTHREAD_SCOPE_PROCESS 2 +/* We only support PTHREAD_PROCESS_PRIVATE */ +#define PTHREAD_PROCESS_SHARED 1 +#define PTHREAD_PROCESS_PRIVATE 2 + /* Who defines this? */ #if !defined(ENOTSUP) #define ENOTSUP 89 #endif /* - * Mutex attributes + * Mutex protocol attributes */ #define PTHREAD_PRIO_NONE 0 #define PTHREAD_PRIO_INHERIT 1 #define PTHREAD_PRIO_PROTECT 2 +/* + * Mutex type attributes + */ +#define PTHREAD_MUTEX_NORMAL 0 +#define PTHREAD_MUTEX_ERRORCHECK 1 +#define PTHREAD_MUTEX_RECURSIVE 2 +#define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL /* * Mutex variables */ -#define PTHREAD_MUTEX_INITIALIZER {_PTHREAD_MUTEX_SIG_init} +#define PTHREAD_MUTEX_INITIALIZER {_PTHREAD_MUTEX_SIG_init, {}} /* * Condition variable attributes @@ -138,13 +153,13 @@ __BEGIN_DECLS * Condition variables */ -#define PTHREAD_COND_INITIALIZER {_PTHREAD_COND_SIG_init} +#define PTHREAD_COND_INITIALIZER {_PTHREAD_COND_SIG_init, {}} /* * Initialization control (once) variables */ -#define PTHREAD_ONCE_INIT {_PTHREAD_ONCE_SIG_init} +#define PTHREAD_ONCE_INIT {_PTHREAD_ONCE_SIG_init, {}} /* * Thread Specific Data - keys @@ -168,6 +183,8 @@ int pthread_attr_getstackaddr __P((const pthread_attr_t *attr, void **stackaddr)); int pthread_attr_getstacksize __P((const pthread_attr_t *attr, size_t *stacksize)); +int pthread_attr_getstack __P((const pthread_attr_t *attr, + void **stackaddr, size_t *stacksize)); int pthread_attr_init __P((pthread_attr_t *attr)); int pthread_attr_setdetachstate __P((pthread_attr_t *attr, int detachstate)); @@ -181,6 +198,8 @@ int pthread_attr_setstackaddr __P((pthread_attr_t *attr, void *stackaddr)); int pthread_attr_setstacksize __P((pthread_attr_t *attr, size_t stacksize)); +int pthread_attr_setstack __P((pthread_attr_t *attr, + void *stackaddr, size_t stacksize)); int pthread_cancel __P((pthread_t thread)); int pthread_setcancelstate __P((int state, int *oldstate)); int pthread_setcanceltype __P((int type, int *oldtype)); @@ -195,9 +214,12 @@ int pthread_cond_wait __P((pthread_cond_t *cond, int pthread_cond_timedwait __P((pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime)); -int pthread_cond_timedwait_relative_np __P((pthread_cond_t *cond, - pthread_mutex_t *mutex, - const struct timespec *reltime)); +int pthread_condattr_init __P((pthread_condattr_t *attr)); +int pthread_condattr_destroy __P((pthread_condattr_t *attr)); +int pthread_condattr_getpshared __P((const pthread_condattr_t *attr, + int *pshared)); +int pthread_condattr_setpshared __P((pthread_condattr_t *attr, + int pshared)); int pthread_create __P((pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), @@ -206,6 +228,9 @@ int pthread_detach __P((pthread_t thread)); int pthread_equal __P((pthread_t t1, pthread_t t2)); void pthread_exit __P((void *value_ptr)); +int pthread_kill __P((pthread_t, int)); +int pthread_sigmask __P((int, const sigset_t *, sigset_t *)); +int sigwait __P((const sigset_t *, int *)); int pthread_getschedparam __P((pthread_t thread, int *policy, struct sched_param *param)); @@ -227,11 +252,19 @@ int pthread_mutexattr_getprioceiling __P((const pthread_mutexattr_t *attr, int *prioceiling)); int pthread_mutexattr_getprotocol __P((const pthread_mutexattr_t *attr, int *protocol)); +int pthread_mutexattr_getpshared __P((const pthread_mutexattr_t *attr, + int *pshared)); +int pthread_mutexattr_gettype __P((const pthread_mutexattr_t *attr, + int *type)); int pthread_mutexattr_init __P((pthread_mutexattr_t *attr)); int pthread_mutexattr_setprioceiling __P((pthread_mutexattr_t *attr, int prioceiling)); int pthread_mutexattr_setprotocol __P((pthread_mutexattr_t *attr, int protocol)); +int pthread_mutexattr_settype __P((pthread_mutexattr_t *attr, + int type)); +int pthread_mutexattr_setpshared __P((pthread_mutexattr_t *attr, + int pshared)); int pthread_once __P((pthread_once_t *once_control, void (*init_routine)(void))); pthread_t pthread_self __P((void)); @@ -246,10 +279,30 @@ int pthread_setspecific __P((pthread_key_t key, void *pthread_getspecific __P((pthread_key_t key)); int pthread_attr_getscope __P((pthread_attr_t *, int *)); int pthread_attr_setscope __P((pthread_attr_t *, int)); - +int pthread_getconcurrency __P((void)); +int pthread_setconcurrency __P((int)); +int pthread_rwlock_destroy __P((pthread_rwlock_t * rwlock)); +int pthread_rwlock_init __P((pthread_rwlock_t * rwlock, + const pthread_rwlockattr_t *attr)); +int pthread_rwlock_rdlock __P((pthread_rwlock_t *rwlock)); +int pthread_rwlock_tryrdlock __P((pthread_rwlock_t *rwlock)); +int pthread_rwlock_wrlock __P((pthread_rwlock_t *rwlock)); +int pthread_rwlock_trywrlock __P((pthread_rwlock_t *rwlock)); +int pthread_rwlock_unlock __P((pthread_rwlock_t *rwlock)); +int pthread_rwlockattr_init __P((pthread_rwlockattr_t *attr)); +int pthread_rwlockattr_destroy __P((pthread_rwlockattr_t *attr)); +int pthread_rwlockattr_getpshared __P((const pthread_rwlockattr_t *attr, + int *pshared)); +int pthread_rwlockattr_setpshared __P((pthread_rwlockattr_t *attr, + int pshared)); + +#ifndef _POSIX_C_SOURCE /* returns non-zero if pthread_create or cthread_fork have been called */ int pthread_is_threaded_np __P((void)); +/* returns non-zero if the current thread is the main thread */ +int pthread_main_np __P((void)); + /* return the mach thread bound to the pthread */ mach_port_t pthread_mach_thread_np __P((pthread_t)); size_t pthread_get_stacksize_np __P((pthread_t)); @@ -258,10 +311,17 @@ void * pthread_get_stackaddr_np __P((pthread_t)); /* Like pthread_cond_signal(), but only wake up the specified pthread */ int pthread_cond_signal_thread_np __P((pthread_cond_t *, pthread_t)); +/* Like pthread_cond_timedwait, but use a relative timeout */ +int pthread_cond_timedwait_relative_np __P((pthread_cond_t *cond, + pthread_mutex_t *mutex, + const struct timespec *reltime)); + /* Like pthread_create(), but leaves the thread suspended */ int pthread_create_suspended_np __P((pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg)); +void pthread_yield_np __P((void)); +#endif /* ! _POSIX_C_SOURCE */ __END_DECLS #endif /* _POSIX_PTHREAD_H */ diff --git a/pthreads/pthread_attr.3 b/pthreads/pthread_attr.3 new file mode 100644 index 0000000..4926715 --- /dev/null +++ b/pthreads/pthread_attr.3 @@ -0,0 +1,211 @@ +.\" Copyright (C) 2000 Jason Evans . +.\" 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(s), this list of conditions and the following disclaimer as +.\" the first lines of this file unmodified other than the possible +.\" addition of one or more copyright notices. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice(s), this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_attr.3,v 1.4.2.5 2001/08/17 15:42:51 ru Exp $ +.Dd April 28, 2000 +.Dt PTHREAD_ATTR 3 +.Os +.Sh NAME +.Nm pthread_attr_init , +.Nm pthread_attr_destroy , +.Nm pthread_attr_setstacksize , +.Nm pthread_attr_getstacksize , +.Nm pthread_attr_setstackaddr , +.Nm pthread_attr_getstackaddr , +.Nm pthread_attr_setdetachstate , +.Nm pthread_attr_getdetachstate , +.Nm pthread_attr_setinheritsched , +.Nm pthread_attr_getinheritsched , +.Nm pthread_attr_setschedparam , +.Nm pthread_attr_getschedparam , +.Nm pthread_attr_setschedpolicy , +.Nm pthread_attr_getschedpolicy , +.Nm pthread_attr_setscope , +.Nm pthread_attr_getscope +.Nd thread attribute operations +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn pthread_attr_init "pthread_attr_t *attr" +.Ft int +.Fn pthread_attr_destroy "pthread_attr_t *attr" +.Ft int +.Fn pthread_attr_setstacksize "pthread_attr_t *attr" "size_t stacksize" +.Ft int +.Fn pthread_attr_getstacksize "const pthread_attr_t *attr" "size_t *stacksize" +.Ft int +.Fn pthread_attr_setstackaddr "pthread_attr_t *attr" "void *stackaddr" +.Ft int +.Fn pthread_attr_getstackaddr "const pthread_attr_t *attr" "void **stackaddr" +.Ft int +.Fn pthread_attr_setdetachstate "pthread_attr_t *attr" "int detachstate" +.Ft int +.Fn pthread_attr_getdetachstate "const pthread_attr_t *attr" "int *detachstate" +.Ft int +.Fn pthread_attr_setinheritsched "pthread_attr_t *attr" "int inheritsched" +.Ft int +.Fn pthread_attr_getinheritsched "const pthread_attr_t *attr" "int *inheritsched" +.Ft int +.Fn pthread_attr_setschedparam "pthread_attr_t *attr" "const struct sched_param *param" +.Ft int +.Fn pthread_attr_getschedparam "const pthread_attr_t *attr" "struct sched_param *param" +.Ft int +.Fn pthread_attr_setschedpolicy "pthread_attr_t *attr" "int policy" +.Ft int +.Fn pthread_attr_getschedpolicy "const pthread_attr_t *attr" "int *policy" +.Ft int +.Fn pthread_attr_setscope "pthread_attr_t *attr" "int contentionscope" +.Ft int +.Fn pthread_attr_getscope "const pthread_attr_t *attr" "int *contentionscope" +.Sh DESCRIPTION +Thread attributes are used to specify parameters to +.Fn pthread_create . +One attribute object can be used in multiple calls to +.Fn pthread_create , +with or without modifications between calls. +.Pp +The +.Fn pthread_attr_init +function initializes +.Fa attr +with all the default thread attributes. +.Pp +The +.Fn pthread_attr_destroy +function destroys +.Fa attr . +.Pp +The +.Fn pthread_attr_set* +functions set the attribute that corresponds to each function name. +.Pp +The +.Fn pthread_attr_get* +functions copy the value of the attribute that corresponds to each function name +to the location pointed to by the second function parameter. +.Sh RETURN VALUES +If successful, these functions return 0. +Otherwise, an error number is returned to indicate the error. +.Sh ERRORS +.Fn pthread_attr_init +will fail if: +.Bl -tag -width Er +.It Bq Er ENOMEM +Out of memory. +.El +.Pp +.Fn pthread_attr_destroy +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +Invalid value for +.Fa attr . +.El +.Pp +.Fn pthread_attr_setstacksize +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +.Fa stacksize +is less than +.Dv PTHREAD_STACK_MIN . +.El +.Pp +.Fn pthread_attr_setdetachstate +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +Invalid value for +.Fa detachstate . +.El +.Pp +.Fn pthread_attr_setinheritsched +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +Invalid value for +.Fa attr . +.El +.Pp +.Fn pthread_attr_setschedparam +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +Invalid value for +.Fa attr . +.It Bq Er ENOTSUP +Invalid value for +.Fa param . +.El +.Pp +.Fn pthread_attr_setschedpolicy +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +Invalid value for +.Fa attr . +.It Bq Er ENOTSUP +Invalid or unsupported value for +.Fa policy . +.El +.Pp +.Fn pthread_attr_setscope +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +Invalid value for +.Fa attr . +.It Bq Er ENOTSUP +Invalid or unsupported value for +.Fa contentionscope . +.El +.Sh SEE ALSO +.Xr pthread_create 3 +.Sh STANDARDS +.Fn pthread_attr_init , +.Fn pthread_attr_destroy , +.Fn pthread_attr_setstacksize , +.Fn pthread_attr_getstacksize , +.Fn pthread_attr_setstackaddr , +.Fn pthread_attr_getstackaddr , +.Fn pthread_attr_setdetachstate , +and +.Fn pthread_attr_getdetachstate +conform to +.St -p1003.1-96 +.Pp +.Fn pthread_attr_setinheritsched , +.Fn pthread_attr_getinheritsched , +.Fn pthread_attr_setschedparam , +.Fn pthread_attr_getschedparam , +.Fn pthread_attr_setschedpolicy , +.Fn pthread_attr_getschedpolicy , +.Fn pthread_attr_setscope , +and +.Fn pthread_attr_getscope +conform to +.St -susv2 diff --git a/pthreads/pthread_cancel.3 b/pthreads/pthread_cancel.3 new file mode 100644 index 0000000..fae332e --- /dev/null +++ b/pthreads/pthread_cancel.3 @@ -0,0 +1,77 @@ +.\" $FreeBSD: src/lib/libc_r/man/pthread_cancel.3,v 1.3.2.3 2001/03/06 16:46:08 ru Exp $ +.Dd January 17, 1999 +.Dt PTHREAD_CANCEL 3 +.Os +.Sh NAME +.Nm pthread_cancel +.Nd cancel execution of a thread +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn pthread_cancel "pthread_t thread" +.Sh DESCRIPTION +The +.Fn pthread_cancel +function requests that +.Fa thread +be canceled. +The target thread's cancelability state and type determines +when the cancellation takes effect. +When the cancellation is acted on, +the cancellation cleanup handlers for +.Fa thread +are called. +When the last cancellation cleanup handler returns, +the thread-specific data destructor functions will be called for +.Fa thread . +When the last destructor function returns, +.Fa thread +will be terminated. +.Pp +The cancellation processing in the target thread runs asynchronously with +respect to the calling thread returning from +.Fn pthread_cancel . +.Pp +A status of +.Dv PTHREAD_CANCELED +is made available to any threads joining with the target. +The symbolic +constant +.Dv PTHREAD_CANCELED +expands to a constant expression of type +.Ft "(void *)" , +whose value matches no pointer to an object in memory nor the value +.Dv NULL . +.Sh RETURN VALUES +If successful, the +.Fn pthread_cancel +functions will return zero. +Otherwise an error number will be returned to +indicate the error. +.Sh ERRORS +.Fn pthread_cancel +will fail if: +.Bl -tag -width Er +.It Bq Er ESRCH +No thread could be found corresponding to that specified by the given +thread ID. +.El +.Sh SEE ALSO +.Xr pthread_cleanup_pop 3 , +.Xr pthread_cleanup_push 3 , +.Xr pthread_exit 3 , +.Xr pthread_join 3 , +.Xr pthread_setcancelstate 3 , +.Xr pthread_setcanceltype 3 , +.Xr pthread_testcancel 3 +.Sh STANDARDS +.Fn pthread_cancel +conforms to +.St -p1003.1-96 . +.Sh AUTHORS +This man page was written by +.An David Leonard Aq d@openbsd.org +for the +.Ox +implementation of +.Fn pthread_cancel . diff --git a/pthreads/pthread_cleanup_pop.3 b/pthreads/pthread_cleanup_pop.3 new file mode 100644 index 0000000..a965922 --- /dev/null +++ b/pthreads/pthread_cleanup_pop.3 @@ -0,0 +1,62 @@ +.\" Copyright (c) 1997 Brian Cully +.\" 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 author nor the names of any co-contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_cleanup_pop.3,v 1.5.2.3 2001/08/17 15:42:51 ru Exp $ +.\" +.Dd July 30, 1998 +.Dt PTHREAD_CLEANUP_POP 3 +.Os +.Sh NAME +.Nm pthread_cleanup_pop +.Nd call the first cleanup routine +.Sh SYNOPSIS +.Fd #include +.Ft void +.Fn pthread_cleanup_pop "int execute" +.Sh DESCRIPTION +The +.Fn pthread_cleanup_pop +function pops the top cleanup routine off of the current threads cleanup +routine stack, and, if +.Fa execute +is non-zero, it will execute the function. +If there is no cleanup routine +then +.Fn pthread_cleanup_pop +does nothing. +.Sh RETURN VALUES +.Fn pthread_cleanup_pop +does not return any value. +.Sh ERRORS +None +.Sh SEE ALSO +.Xr pthread_cleanup_push 3 , +.Xr pthread_exit 3 +.Sh STANDARDS +.Fn pthread_cleanup_pop +conforms to +.St -p1003.1-96 . diff --git a/pthreads/pthread_cleanup_push.3 b/pthreads/pthread_cleanup_push.3 new file mode 100644 index 0000000..5a8aa9d --- /dev/null +++ b/pthreads/pthread_cleanup_push.3 @@ -0,0 +1,64 @@ +.\" Copyright (c) 1997 Brian Cully +.\" 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 author nor the names of any co-contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_cleanup_push.3,v 1.5.2.4 2001/08/17 15:42:51 ru Exp $ +.\" +.Dd July 30, 1998 +.Dt PTHREAD_CLEANUP_PUSH 3 +.Os +.Sh NAME +.Nm pthread_cleanup_push +.Nd add a cleanup function for thread exit +.Sh SYNOPSIS +.Fd #include +.Ft void +.Fn pthread_cleanup_push "void \*[lp]*cleanup_routine\*[rp]\*[lp]void *\*[rp]" "void *arg" +.Sh DESCRIPTION +The +.Fn pthread_cleanup_push +function adds +.Fa cleanup_routine +to the top of the stack of cleanup handlers that +get called when the current thread exits. +.Pp +When +.Fa cleanup_routine +is called, it is passed +.Fa arg +as its only argument. +.Sh RETURN VALUES +.Fn pthread_cleanup_push +does not return any value. +.Sh ERRORS +None +.Sh SEE ALSO +.Xr pthread_cleanup_pop 3 , +.Xr pthread_exit 3 +.Sh STANDARDS +.Fn pthread_cleanup_push +conforms to +.St -p1003.1-96 . diff --git a/pthreads.subproj/pthread_cond.c b/pthreads/pthread_cond.c similarity index 86% rename from pthreads.subproj/pthread_cond.c rename to pthreads/pthread_cond.c index 4eee4a5..409f231 100644 --- a/pthreads.subproj/pthread_cond.c +++ b/pthreads/pthread_cond.c @@ -142,7 +142,8 @@ pthread_cond_signal_thread_np(pthread_cond_t *cond, pthread_t thread) kern_res = KERN_SUCCESS; } } else if (thread->sig == _PTHREAD_SIG) { - PTHREAD_MACH_CALL(semaphore_signal_thread(cond->sem, thread->kernel_thread), kern_res); + PTHREAD_MACH_CALL(semaphore_signal_thread( + cond->sem, pthread_mach_thread_np(thread)), kern_res); } else { kern_res = KERN_FAILURE; } @@ -249,7 +250,7 @@ _pthread_cond_wait(pthread_cond_t *cond, then.tv_nsec = abstime->tv_nsec - now.tv_nsec; then.tv_sec = abstime->tv_sec - now.tv_sec; if (then.tv_nsec < 0) { - then.tv_nsec += 1000000000; /* nsec/sec */ + then.tv_nsec += NSEC_PER_SEC; then.tv_sec--; } if (((int)then.tv_sec < 0) || @@ -260,6 +261,9 @@ _pthread_cond_wait(pthread_cond_t *cond, then.tv_sec = abstime->tv_sec; then.tv_nsec = abstime->tv_nsec; } + if (then.tv_nsec >= NSEC_PER_SEC) { + return EINVAL; + } } LOCK(cond->lock); busy = cond->busy; @@ -328,3 +332,52 @@ pthread_cond_timedwait_relative_np(pthread_cond_t *cond, return (_pthread_cond_wait(cond, mutex, abstime, 1)); } +int +pthread_condattr_init(pthread_condattr_t *attr) +{ + attr->sig = _PTHREAD_COND_ATTR_SIG; + return (ESUCCESS); +} + +int +pthread_condattr_destroy(pthread_condattr_t *attr) +{ + attr->sig = _PTHREAD_NO_SIG; /* Uninitialized */ + return (ESUCCESS); +} + +int +pthread_condattr_getpshared(const pthread_condattr_t *attr, + int *pshared) +{ + if (attr->sig == _PTHREAD_COND_ATTR_SIG) + { + *pshared = (int)PTHREAD_PROCESS_PRIVATE; + return (ESUCCESS); + } else + { + return (EINVAL); /* Not an initialized 'attribute' structure */ + } +} + + +int +pthread_condattr_setpshared(pthread_condattr_t * attr, int pshared) +{ + if (attr->sig == _PTHREAD_COND_ATTR_SIG) + { + if ( pshared == PTHREAD_PROCESS_PRIVATE) + { + /* attr->pshared = pshared */ + return (ESUCCESS); + } else + { + return (EINVAL); /* Invalid parameter */ + } + } else + { + return (EINVAL); /* Not an initialized 'attribute' structure */ + } + +} + diff --git a/pthreads/pthread_cond_broadcast.3 b/pthreads/pthread_cond_broadcast.3 new file mode 100644 index 0000000..27600a6 --- /dev/null +++ b/pthreads/pthread_cond_broadcast.3 @@ -0,0 +1,68 @@ +.\" Copyright (c) 1997 Brian Cully +.\" 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 author nor the names of any co-contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_cond_broadcast.3,v 1.5.2.4 2001/08/17 15:42:51 ru Exp $ +.\" +.Dd July 28, 1998 +.Dt PTHREAD_COND_BROADCAST 3 +.Os +.Sh NAME +.Nm pthread_cond_broadcast +.Nd unblock all threads waiting for a condition variable +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn pthread_cond_broadcast "pthread_cond_t *cond" +.Sh DESCRIPTION +The +.Fn pthread_cond_broadcast +function unblocks all threads waiting for the condition variable +.Fa cond . +.Sh RETURN VALUES +If successful, the +.Fn pthread_cond_broadcast +function will return zero, otherwise an error number will be returned +to indicate the error. +.Sh ERRORS +.Fn pthread_cond_broadcast +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The value specified by +.Fa cond +is invalid. +.El +.Sh SEE ALSO +.Xr pthread_cond_destroy 3 , +.Xr pthread_cond_init 3 , +.Xr pthread_cond_signal 3 , +.Xr pthread_cond_timedwait 3 , +.Xr pthread_cond_wait 3 +.Sh STANDARDS +.Fn pthread_cond_broadcast +conforms to +.St -p1003.1-96 . diff --git a/pthreads/pthread_cond_destroy.3 b/pthreads/pthread_cond_destroy.3 new file mode 100644 index 0000000..6b0ecc2 --- /dev/null +++ b/pthreads/pthread_cond_destroy.3 @@ -0,0 +1,72 @@ +.\" Copyright (c) 1997 Brian Cully +.\" 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 author nor the names of any co-contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_cond_destroy.3,v 1.6.2.4 2001/08/17 15:42:51 ru Exp $ +.\" +.Dd July 28, 1998 +.Dt PTHREAD_COND_DESTROY 3 +.Os +.Sh NAME +.Nm pthread_cond_destroy +.Nd destroy a condition variable +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn pthread_cond_destroy "pthread_cond_t *cond" +.Sh DESCRIPTION +The +.Fn pthread_cond_destroy +function frees the resources allocated by the condition variable +.Fa cond . +.Sh RETURN VALUES +If successful, the +.Fn pthread_cond_destroy +function will return zero, otherwise an error number will be returned +to indicate the error. +.Sh ERRORS +.Fn pthread_cond_destroy +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The value specified by +.Fa cond +is invalid. +.It Bq Er EBUSY +The variable +.Fa cond +is locked by another thread. +.El +.Sh SEE ALSO +.Xr pthread_cond_broadcast 3 , +.Xr pthread_cond_init 3 , +.Xr pthread_cond_signal 3 , +.Xr pthread_cond_timedwait 3 , +.Xr pthread_cond_wait 3 +.Sh STANDARDS +.Fn pthread_cond_destroy +conforms to +.St -p1003.1-96 . diff --git a/pthreads/pthread_cond_init.3 b/pthreads/pthread_cond_init.3 new file mode 100644 index 0000000..ec30f86 --- /dev/null +++ b/pthreads/pthread_cond_init.3 @@ -0,0 +1,78 @@ +.\" Copyright (c) 1997 Brian Cully +.\" 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 author nor the names of any co-contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_cond_init.3,v 1.6.2.5 2001/08/17 15:42:51 ru Exp $ +.\" +.Dd July 28, 1998 +.Dt PTHREAD_COND_INIT 3 +.Os +.Sh NAME +.Nm pthread_cond_init +.Nd create a condition variable +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn pthread_cond_init "pthread_cond_t *cond" "const pthread_condattr_t *attr" +.Sh DESCRIPTION +The +.Fn pthread_cond_init +function creates a new condition variable, with attributes specified with +.Fa attr . +If +.Fa attr +is NULL the default attributes are used. +.Sh RETURN VALUES +If successful, the +.Fn pthread_cond_init +function will return zero and put the new condition variable id into +.Fa cond , +otherwise an error number will be returned to indicate the error. +.Sh ERRORS +.Fn pthread_cond_init +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The value specified by +.Fa attr +is invalid. +.It Bq Er ENOMEM +The process cannot allocate enough memory to create another condition +variable. +.It Bq Er EAGAIN +The system temporarily lacks the resources to create another condition +variable. +.El +.Sh SEE ALSO +.Xr pthread_cond_broadcast 3 , +.Xr pthread_cond_destroy 3 , +.Xr pthread_cond_signal 3 , +.Xr pthread_cond_timedwait 3 , +.Xr pthread_cond_wait 3 +.Sh STANDARDS +.Fn pthread_cond_init +conforms to +.St -p1003.1-96 . diff --git a/pthreads/pthread_cond_signal.3 b/pthreads/pthread_cond_signal.3 new file mode 100644 index 0000000..06078a9 --- /dev/null +++ b/pthreads/pthread_cond_signal.3 @@ -0,0 +1,68 @@ +.\" Copyright (c) 1997 Brian Cully +.\" 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 author nor the names of any co-contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_cond_signal.3,v 1.5.2.4 2001/08/17 15:42:51 ru Exp $ +.\" +.Dd July 28, 1998 +.Dt PTHREAD_COND_SIGNAL 3 +.Os +.Sh NAME +.Nm pthread_cond_signal +.Nd unblock a thread waiting for a condition variable +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn pthread_cond_signal "pthread_cond_t *cond" +.Sh DESCRIPTION +The +.Fn pthread_cond_signal +function unblocks one thread waiting for the condition variable +.Fa cond . +.Sh RETURN VALUES +If successful, the +.Fn pthread_cond_signal +function will return zero, otherwise an error number will be returned +to indicate the error. +.Sh ERRORS +.Fn pthread_cond_signal +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The value specified by +.Fa cond +is invalid. +.El +.Sh SEE ALSO +.Xr pthread_cond_broadcast 3 , +.Xr pthread_cond_destroy 3 , +.Xr pthread_cond_init 3 , +.Xr pthread_cond_timedwait 3 , +.Xr pthread_cond_wait 3 +.Sh STANDARDS +.Fn pthread_cond_signal +conforms to +.St -p1003.1-96 . diff --git a/pthreads/pthread_cond_timedwait.3 b/pthreads/pthread_cond_timedwait.3 new file mode 100644 index 0000000..3ff427d --- /dev/null +++ b/pthreads/pthread_cond_timedwait.3 @@ -0,0 +1,87 @@ +.\" Copyright (c) 1997 Brian Cully +.\" 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 author nor the names of any co-contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_cond_timedwait.3,v 1.8.2.6 2001/08/17 15:42:51 ru Exp $ +.\" +.Dd July 28, 1998 +.Dt PTHREAD_COND_TIMEDWAIT 3 +.Os +.Sh NAME +.Nm pthread_cond_timedwait +.Nd "wait on a condition variable for a specific amount of time" +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn pthread_cond_timedwait "pthread_cond_t *cond" "pthread_mutex_t *mutex" "const struct timespec *abstime" +.Sh DESCRIPTION +The +.Fn pthread_cond_timedwait +function atomically blocks the current thread waiting on the condition +variable specified by +.Fa cond , +and unblocks the mutex specified by +.Fa mutex . +The waiting thread unblocks only after another thread calls +.Xr pthread_cond_signal 3 , +or +.Xr pthread_cond_broadcast 3 +with the same condition variable, or if the system time reaches the +time specified in +.Fa abstime , +and the current thread reacquires the lock on +.Fa mutex . +.Sh RETURN VALUES +If successful, the +.Fn pthread_cond_timedwait +function will return zero. +Otherwise an error number will be returned to +indicate the error. +.Sh ERRORS +.Fn pthread_cond_timedwait +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The value specified by +.Fa cond , +.Fa mutex +or +.Fa abstime +is invalid. +.It Bq Er ETIMEDOUT +The system time has reached or exceeded the time specified in +.Fa abstime . +.El +.Sh SEE ALSO +.Xr pthread_cond_broadcast 3 , +.Xr pthread_cond_destroy 3 , +.Xr pthread_cond_init 3 , +.Xr pthread_cond_signal 3 , +.Xr pthread_cond_wait 3 +.Sh STANDARDS +.Fn pthread_cond_timedwait +conforms to +.St -p1003.1-96 . diff --git a/pthreads/pthread_cond_wait.3 b/pthreads/pthread_cond_wait.3 new file mode 100644 index 0000000..d64c49e --- /dev/null +++ b/pthreads/pthread_cond_wait.3 @@ -0,0 +1,75 @@ +.\" Portions Copyright (c) 2001 Apple Computer, Inc. All Rights Reserved. +.\" Copyright (c) 1997 Brian Cully +.\" 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 author nor the names of any co-contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_cond_wait.3,v 1.8.2.4 2001/08/17 15:42:51 ru Exp $ +.\" +.Dd November 5, 2001 +.Dt PTHREAD_COND_WAIT 3 +.Os Darwin +.Sh NAME +.Nm pthread_cond_wait +.Nd wait on a condition variable +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn pthread_cond_wait "pthread_cond_t *cond" "pthread_mutex_t *mutex" +.Sh DESCRIPTION +The +.Fn pthread_cond_wait +function atomically unlocks the +.Fa mutex +argument and waits on the +.Fa cond +argument. +.Sh RETURN VALUES +If successful, the +.Fn pthread_cond_wait +function will return zero. +Otherwise an error number will be returned to +indicate the error. +.Sh ERRORS +.Fn pthread_cond_wait +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The value specified by +.Fa cond +or the value specified by +.Fa mutex +is invalid. +.El +.Sh SEE ALSO +.Xr pthread_cond_broadcast 3 , +.Xr pthread_cond_destroy 3 , +.Xr pthread_cond_init 3 , +.Xr pthread_cond_signal 3 , +.Xr pthread_cond_timedwait 3 +.Sh STANDARDS +.Fn pthread_cond_wait +conforms to +.St -p1003.1-96 . diff --git a/pthreads/pthread_condattr.3 b/pthreads/pthread_condattr.3 new file mode 100644 index 0000000..e63da0d --- /dev/null +++ b/pthreads/pthread_condattr.3 @@ -0,0 +1,83 @@ +.\" Copyright (C) 2000 Jason Evans . +.\" 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(s), this list of conditions and the following disclaimer as +.\" the first lines of this file unmodified other than the possible +.\" addition of one or more copyright notices. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice(s), this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_condattr.3,v 1.9 2001/10/01 16:09:09 ru Exp $ +.Dd April 28, 2000 +.Dt PTHREAD_CONDATTR 3 +.Os +.Sh NAME +.Nm pthread_condattr_init , +.Nm pthread_condattr_destroy +.Nd condition attribute operations +.Sh SYNOPSIS +.In pthread.h +.Ft int +.Fn pthread_condattr_init "pthread_condattr_t *attr" +.Ft int +.Fn pthread_condattr_destroy "pthread_condattr_t *attr" +.Sh DESCRIPTION +Condition attribute objects are used to specify parameters to +.Fn pthread_cond_init . +.Fx Ns 's +implementation of conditions does not support any non-default +attributes, so these functions are not very useful, though they are required to +to be present by +.Tn POSIX . +.Pp +The +.Fn pthread_condattr_init +function initializes a condition attribute object with the default attributes. +.Pp +The +.Fn pthread_condattr_destroy +function destroys a condition attribute object. +.Sh RETURN VALUES +If successful, these functions return 0. +Otherwise, an error number is returned to indicate the error. +.Sh ERRORS +.Fn pthread_condattr_init +will fail if: +.Bl -tag -width Er +.It Bq Er ENOMEM +Out of memory. +.El +.Pp +.Fn pthread_condattr_destroy +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +Invalid value for +.Fa attr . +.El +.Sh SEE ALSO +.Xr pthread_cond_init 3 +.Sh STANDARDS +.Fn pthread_condattr_init +and +.Fn pthread_condattr_destroy +conform to +.St -p1003.1-96 diff --git a/pthreads/pthread_create.3 b/pthreads/pthread_create.3 new file mode 100644 index 0000000..c495109 --- /dev/null +++ b/pthreads/pthread_create.3 @@ -0,0 +1,119 @@ +.\" Copyright (c) 1996 John Birrell . +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by John Birrell. +.\" 4. Neither the name of the author nor the names of any co-contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_create.3,v 1.9.2.4 2001/08/17 15:42:51 ru Exp $ +.\" +.Dd April 4, 1996 +.Dt PTHREAD_CREATE 3 +.Os +.Sh NAME +.Nm pthread_create +.Nd create a new thread +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn pthread_create "pthread_t *thread" "const pthread_attr_t *attr" "void *(*start_routine)(void *)" "void *arg" +.Sh DESCRIPTION +The +.Fn pthread_create +function is used to create a new thread, with attributes specified by +.Fa attr , +within a process. +If +.Fa attr +is NULL, the default attributes are used. +If the attributes specified by +.Fa attr +are modified later, the thread's attributes are not affected. +Upon +successful completion +.Fn pthread_create +will store the ID of the created thread in the location specified by +.Fa thread . +.Pp +The thread is created executing +.Fa start_routine +with +.Fa arg +as its sole argument. +If the +.Fa start_routine +returns, the effect is as if there was an implicit call to +.Fn pthread_exit +using the return value of +.Fa start_routine +as the exit status. +Note that the thread in which +.Fn main +was originally invoked differs from this. +When it returns from +.Fn main , +the effect is as if there was an implicit call to +.Fn exit +using the return value of +.Fn main +as the exit status. +.Pp +The signal state of the new thread is initialized as: +.Bl -bullet -offset indent +.It +The signal mask is inherited from the creating thread. +.It +The set of signals pending for the new thread is empty. +.El +.Sh RETURN VALUES +If successful, the +.Fn pthread_create +function will return zero. +Otherwise an error number will be returned to +indicate the error. +.Sh ERRORS +.Fn pthread_create +will fail if: +.Bl -tag -width Er +.It Bq Er EAGAIN +The system lacked the necessary resources to create another thread, or +the system-imposed limit on the total number of threads in a process +[PTHREAD_THREADS_MAX] would be exceeded. +.It Bq Er EINVAL +The value specified by +.Fa attr +is invalid. +.El +.Sh SEE ALSO +.Xr fork 2 , +.Xr pthread_cleanup_pop 3 , +.Xr pthread_cleanup_push 3 , +.Xr pthread_exit 3 , +.Xr pthread_join 3 +.Sh STANDARDS +.Fn pthread_create +conforms to +.St -p1003.1-96 . diff --git a/pthreads/pthread_detach.3 b/pthreads/pthread_detach.3 new file mode 100644 index 0000000..3608bc3 --- /dev/null +++ b/pthreads/pthread_detach.3 @@ -0,0 +1,87 @@ +.\" Copyright (c) 1996-1998 John Birrell . +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by John Birrell. +.\" 4. Neither the name of the author nor the names of any co-contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_detach.3,v 1.6.2.5 2001/08/17 15:42:51 ru Exp $ +.\" +.Dd April 4, 1996 +.Dt PTHREAD_DETACH 3 +.Os +.Sh NAME +.Nm pthread_detach +.Nd detach a thread +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn pthread_detach "pthread_t thread" +.Sh DESCRIPTION +The +.Fn pthread_detach +function is used to indicate to the implementation that storage for the +thread +.Fa thread +can be reclaimed when the thread terminates. +If +.Fa thread +has not terminated, +.Fn pthread_detach +will not cause it to terminate. +The effect of multiple +.Fn pthread_detach +calls on the same target thread is unspecified. +.Sh RETURN VALUES +If successful, the +.Fn pthread_detach +function will return zero. +Otherwise an error number will be returned to +indicate the error. +Note that the function does not change the value +of errno as it did for some drafts of the standard. +These early drafts +also passed a pointer to pthread_t as the argument. +Beware! +.Sh ERRORS +.Fn pthread_detach +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The implementation has detected that the value specified by +.Fa thread +does not refer to a joinable thread. +.It Bq Er ESRCH +No thread could be found corresponding to that specified by the given +thread ID, +.Fa thread . +.El +.Sh SEE ALSO +.Xr pthread_join 3 +.Sh STANDARDS +.Fn pthread_detach +conforms to +.St -p1003.1-96 . diff --git a/pthreads/pthread_equal.3 b/pthreads/pthread_equal.3 new file mode 100644 index 0000000..37b2c01 --- /dev/null +++ b/pthreads/pthread_equal.3 @@ -0,0 +1,66 @@ +.\" Copyright (c) 1996 John Birrell . +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by John Birrell. +.\" 4. Neither the name of the author nor the names of any co-contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_equal.3,v 1.4.2.5 2001/08/17 15:42:51 ru Exp $ +.\" +.Dd April 4, 1996 +.Dt PTHREAD_EQUAL 3 +.Os +.Sh NAME +.Nm pthread_equal +.Nd compare thread IDs +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn pthread_equal "pthread_t t1" "pthread_t t2" +.Sh DESCRIPTION +The +.Fn pthread_equal +function compares the thread IDs +.Fa t1 +and +.Fa t2 . +.Sh RETURN VALUES +The +.Fn pthread_equal +function will return non-zero if the thread IDs +.Fa t1 +and +.Fa t2 +correspond to the same thread, otherwise it will return zero. +.Sh ERRORS +None. +.Sh SEE ALSO +.Xr pthread_create 3 , +.Xr pthread_exit 3 +.Sh STANDARDS +.Fn pthread_equal +conforms to +.St -p1003.1-96 . diff --git a/pthreads/pthread_exit.3 b/pthreads/pthread_exit.3 new file mode 100644 index 0000000..3bb690a --- /dev/null +++ b/pthreads/pthread_exit.3 @@ -0,0 +1,102 @@ +.\" Copyright (c) 1996 John Birrell . +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by John Birrell. +.\" 4. Neither the name of the author nor the names of any co-contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_exit.3,v 1.8.2.6 2001/08/17 15:42:51 ru Exp $ +.\" +.Dd April 4, 1996 +.Dt PTHREAD_EXIT 3 +.Os +.Sh NAME +.Nm pthread_exit +.Nd terminate the calling thread +.Sh SYNOPSIS +.Fd #include +.Ft void +.Fn pthread_exit "void *value_ptr" +.Sh DESCRIPTION +The +.Fn pthread_exit +function terminates the calling thread and makes the value +.Fa value_ptr +available to any successful join with the terminating thread. +Any +cancellation cleanup handlers that have been pushed and are not yet popped +are popped in the reverse order that they were pushed and then executed. +After all cancellation handlers have been executed, if the thread has any +thread-specific data, appropriate destructor functions are called in an +unspecified order. +Thread termination does not release any application +visible process resources, including, but not limited to, mutexes and +file descriptors, nor does it perform any process level cleanup +actions, including, but not limited to, calling +.Fn atexit +routines that may exist. +.Pp +An implicit call to +.Fn pthread_exit +is made when a thread other than the thread in which +.Fn main +was first invoked returns from the start routine that was used to create +it. The function's return value serves as the thread's exit status. +.Pp +The behavior of +.Fn pthread_exit +is undefined if called from a cancellation handler or destructor function +that was invoked as the result of an implicit or explicit call to +.Fn pthread_exit . +.Pp +After a thread has terminated, the result of access to local (auto) +variables of the thread is undefined. +Thus, references to local variables +of the exiting thread should not be used for the +.Fn pthread_exit +.Fa value_ptr +parameter value. +.Pp +The process will exit with an exit status of 0 after the last thread has +been terminated. +The behavior is as if the implementation called +.Fn exit +with a zero argument at thread termination time. +.Sh RETURN VALUES +The +.Fn pthread_exit +function cannot return to its caller. +.Sh ERRORS +None. +.Sh SEE ALSO +.Xr _exit 2 , +.Xr exit 3 , +.Xr pthread_create 3 , +.Xr pthread_join 3 +.Sh STANDARDS +.Fn pthread_exit +conforms to +.St -p1003.1-96 . diff --git a/pthreads/pthread_getschedparam.3 b/pthreads/pthread_getschedparam.3 new file mode 100644 index 0000000..e00454b --- /dev/null +++ b/pthreads/pthread_getschedparam.3 @@ -0,0 +1,88 @@ +.\" Copyright (C) 2000 Jason Evans . +.\" 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(s), this list of conditions and the following disclaimer as +.\" the first lines of this file unmodified other than the possible +.\" addition of one or more copyright notices. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice(s), this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_schedparam.3,v 1.2.2.4 2001/08/17 15:42:52 ru Exp $ +.Dd May 1, 2000 +.Dt PTHREAD_SCHEDPARAM 3 +.Os +.Sh NAME +.Nm pthread_setschedparam , +.Nm pthread_getschedparam +.Nd thread scheduling parameter manipulation +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn pthread_setschedparam "pthread_t thread" "int policy" "const struct sched_param *param" +.Ft int +.Fn pthread_getschedparam "pthread_t thread" "int *policy" "struct sched_param *param" +.Sh DESCRIPTION +The +.Fn pthread_setschedparam +and +.Fn pthread_getschedparam +functions set and get the scheduling parameters of individual threads. +The scheduling policy for a thread can either be +.Dv SCHED_FIFO +(first in, first out) or +.Dv SCHED_RR +(round-robin). +The thread priority (accessed via +.Va param->sched_priority ) +must be at least +.Dv PTHREAD_MIN_PRIORITY +and no more than +.Dv PTHREAD_MAX_PRIORITY . +.Sh RETURN VALUES +If successful, these functions return 0. +Otherwise, an error number is returned to indicate the error. +.Sh ERRORS +.Fn pthread_setschedparam +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +Invalid value for +.Va policy . +.It Bq Er ENOTSUP +Invalid value for scheduling parameters. +.It Bq Er ESRCH +Non-existent thread +.Va thread . +.El +.Pp +.Fn pthread_getschedparam +will fail if: +.Bl -tag -width Er +.It Bq Er ESRCH +Non-existent thread +.Va thread . +.El +.Sh STANDARDS +.Fn pthread_setschedparam +and +.Fn pthread_getschedparam +conform to +.St -susv2 diff --git a/pthreads/pthread_getspecific.3 b/pthreads/pthread_getspecific.3 new file mode 100644 index 0000000..d53ba46 --- /dev/null +++ b/pthreads/pthread_getspecific.3 @@ -0,0 +1,81 @@ +.\" Copyright (c) 1996 John Birrell . +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by John Birrell. +.\" 4. Neither the name of the author nor the names of any co-contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_getspecific.3,v 1.6.2.3 2001/08/17 15:42:51 ru Exp $ +.\" +.Dd April 4, 1996 +.Dt PTHREAD_GETSPECIFIC 3 +.Os +.Sh NAME +.Nm pthread_getspecific +.Nd get a thread-specific data value +.Sh SYNOPSIS +.Fd #include +.Ft void * +.Fn pthread_getspecific "pthread_key_t key" +.Sh DESCRIPTION +The +.Fn pthread_getspecific +function returns the value currently bound to the specified +.Fa key +on behalf of the calling thread. +.Pp +The effect of calling +.Fn pthread_getspecific +with a +.Fa key +value not obtained from +.Fn pthread_key_create +or after +.Fa key +has been deleted with +.Fn pthread_key_delete +is undefined. +.Pp +.Fn pthread_getspecific +may be called from a thread-specific data destructor function. +.Sh RETURN VALUES +The +.Fn pthread_getspecific +function will return the thread-specific data value associated with the given +.Fa key . +If no thread-specific data value is associated with +.Fa key , +then the value NULL is returned. +.Sh ERRORS +None. +.Sh SEE ALSO +.Xr pthread_key_create 3 , +.Xr pthread_key_delete 3 , +.Xr pthread_setspecific 3 +.Sh STANDARDS +.Fn pthread_getspecific +conforms to +.St -p1003.1-96 . diff --git a/pthreads.subproj/pthread_impl.h b/pthreads/pthread_impl.h similarity index 100% rename from pthreads.subproj/pthread_impl.h rename to pthreads/pthread_impl.h diff --git a/pthreads.subproj/pthread_internals.h b/pthreads/pthread_internals.h similarity index 86% rename from pthreads.subproj/pthread_internals.h rename to pthreads/pthread_internals.h index 2cfde61..6a26786 100644 --- a/pthreads.subproj/pthread_internals.h +++ b/pthreads/pthread_internals.h @@ -74,15 +74,15 @@ typedef struct _pthread int policy; struct sched_param param; struct _pthread_mutex *mutexes; - mach_port_t joiners; /* pthread_join() uses this to wait for death's call */ - int num_joiners; - void *exit_value; - mach_port_t death; /* pthread_exit() uses this to wait for the hearse */ + struct _pthread *joiner; + int pad1; + void *exit_value; + semaphore_t death; /* pthread_join() uses this to wait for death's call */ mach_port_t kernel_thread; /* kernel thread this thread is bound to */ void *(*fun)(void*);/* Thread start routine */ void *arg; /* Argment for thread start routine */ int cancel_state; /* Whether thread can be cancelled */ - int err_no; /* thread-local errno */ + int err_no; /* thread-local errno */ void *tsd[_POSIX_THREAD_KEYS_MAX]; /* Thread specific data */ void *stackaddr; /* Base of the stack (is aligned on vm_page_size boundary */ size_t stacksize; /* Size of the stack (is a multiple of vm_page_size and >= PTHREAD_STACK_MIN) */ @@ -115,7 +115,9 @@ typedef struct { long sig; /* Unique signature for this structure */ int prioceiling; - int protocol; + u_int32_t protocol:2, /* protocol attribute */ + type:2, /* mutex type */ + rfu:28; } pthread_mutexattr_t; /* @@ -125,15 +127,19 @@ typedef struct _pthread_mutex { long sig; /* Unique signature for this structure */ pthread_lock_t lock; /* Used for internal mutex on structure */ - int prioceiling; - int priority; /* Priority to restore when mutex unlocked */ - int protocol; + int waiters:30, /* Count of threads waiting for this mutex */ + def:1, + cond_lock:1; /* Is there a condition locking me? */ pthread_t owner; /* Which thread has this mutex locked */ + mach_port_t sem; /* Semaphore used for waiting */ + u_int32_t protocol:2, /* protocol */ + type:2, /* mutex type */ + rfu:12, + lock_count:16; struct _pthread_mutex *next, *prev; /* List of other mutexes he owns */ struct _pthread_cond *busy; /* List of condition variables using this mutex */ - int waiters:31, /* Count of threads waiting for this mutex */ - cond_lock:1; /* Is there a condition locking me? */ - mach_port_t sem; /* Semaphore used for waiting */ + int prioceiling; + int priority; /* Priority to restore when mutex unlocked */ } pthread_mutex_t; /* @@ -168,6 +174,23 @@ typedef struct pthread_lock_t lock; /* Used for internal mutex on structure */ } pthread_once_t; +typedef struct { + long sig; /* Unique signature for this structure */ + int pshared; + int rfu[2]; /* reserved for future use */ +} pthread_rwlockattr_t; + +typedef struct { + long sig; + pthread_mutex_t lock; /* monitor lock */ + int state; + pthread_cond_t read_signal; + pthread_cond_t write_signal; + int blocked_writers; + int pshared; + int rfu[3]; +} pthread_rwlock_t; + #include "pthread.h" #define _PTHREAD_DEFAULT_INHERITSCHED PTHREAD_INHERIT_SCHED @@ -180,15 +203,19 @@ typedef struct #define _PTHREAD_MUTEX_ATTR_SIG 0x4D545841 /* 'MTXA' */ #define _PTHREAD_MUTEX_SIG 0x4D555458 /* 'MUTX' */ #define _PTHREAD_MUTEX_SIG_init 0x32AAABA7 /* [almost] ~'MUTX' */ +#define _PTHREAD_COND_ATTR_SIG 0x434E4441 /* 'CNDA' */ #define _PTHREAD_COND_SIG 0x434F4E44 /* 'COND' */ #define _PTHREAD_COND_SIG_init 0x3CB0B1BB /* [almost] ~'COND' */ #define _PTHREAD_ATTR_SIG 0x54484441 /* 'THDA' */ #define _PTHREAD_ONCE_SIG 0x4F4E4345 /* 'ONCE' */ #define _PTHREAD_ONCE_SIG_init 0x30B1BCBA /* [almost] ~'ONCE' */ #define _PTHREAD_SIG 0x54485244 /* 'THRD' */ +#define _PTHREAD_RWLOCK_ATTR_SIG 0x52574C41 /* 'RWLA' */ +#define _PTHREAD_RWLOCK_SIG 0x52574C4B /* 'RWLK' */ +#define _PTHREAD_RWLOCK_SIG_init 0x2DA8B3B4 /* [almost] ~'RWLK' */ -#define _PTHREAD_EXITED 3 #define _PTHREAD_CREATE_PARENT 4 +#define _PTHREAD_EXITED 8 #define _PTHREAD_CANCEL_STATE_MASK 0xFE #define _PTHREAD_CANCEL_TYPE_MASK 0xFD @@ -241,7 +268,7 @@ extern vm_address_t _adjust_sp(vm_address_t sp); extern void _spin_lock(pthread_lock_t *lockp); extern int _spin_lock_try(pthread_lock_t *lockp); extern void _spin_unlock(pthread_lock_t *lockp); -extern void _pthread_setup(pthread_t th, void (*f)(pthread_t), vm_address_t sp); +extern void _pthread_setup(pthread_t th, void (*f)(pthread_t), void *sp, int suspended, int needresume); extern void _pthread_tsd_cleanup(pthread_t self); diff --git a/pthreads/pthread_join.3 b/pthreads/pthread_join.3 new file mode 100644 index 0000000..9fcbfab --- /dev/null +++ b/pthreads/pthread_join.3 @@ -0,0 +1,102 @@ +.\" Copyright (c) 1996-1998 John Birrell . +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by John Birrell. +.\" 4. Neither the name of the author nor the names of any co-contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_join.3,v 1.7.2.4 2001/08/17 15:42:51 ru Exp $ +.\" +.Dd April 4, 1996 +.Dt PTHREAD_JOIN 3 +.Os +.Sh NAME +.Nm pthread_join +.Nd wait for thread termination +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn pthread_join "pthread_t thread" "void **value_ptr" +.Sh DESCRIPTION +The +.Fn pthread_join +function suspends execution of the calling thread until the target +.Fa thread +terminates unless the target +.Fa thread +has already terminated. +.Pp +On return from a successful +.Fn pthread_join +call with a non-NULL +.Fa value_ptr +argument, the value passed to +.Fn pthread_exit +by the terminating thread is stored in the location referenced by +.Fa value_ptr . +When a +.Fn pthread_join +returns successfully, the target thread has been terminated. +The results +of multiple simultaneous calls to +.Fn pthread_join +specifying the same target thread are undefined. +If the thread calling +.Fn pthread_join +is cancelled, then the target thread is not detached. +.Pp +A thread that has exited but remains unjoined counts against +[_POSIX_THREAD_THREADS_MAX]. +.Sh RETURN VALUES +If successful, the +.Fn pthread_join +function will return zero. +Otherwise an error number will be returned to +indicate the error. +.Sh ERRORS +.Fn pthread_join +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The implementation has detected that the value specified by +.Fa thread +does not refer to a joinable thread. +.It Bq Er ESRCH +No thread could be found corresponding to that specified by the given +thread ID, +.Fa thread . +.It Bq Er EDEADLK +A deadlock was detected or the value of +.Fa thread +specifies the calling thread. +.El +.Sh SEE ALSO +.Xr wait 2 , +.Xr pthread_create 3 +.Sh STANDARDS +.Fn pthread_join +conforms to +.St -p1003.1-96 . diff --git a/pthreads/pthread_key_create.3 b/pthreads/pthread_key_create.3 new file mode 100644 index 0000000..82a8a1c --- /dev/null +++ b/pthreads/pthread_key_create.3 @@ -0,0 +1,105 @@ +.\" Copyright (c) 1996 John Birrell . +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by John Birrell. +.\" 4. Neither the name of the author nor the names of any co-contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_key_create.3,v 1.6.2.4 2001/08/17 15:42:51 ru Exp $ +.\" +.Dd April 4, 1996 +.Dt PTHREAD_KEY_CREATE 3 +.Os +.Sh NAME +.Nm pthread_key_create +.Nd thread-specific data key creation +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn pthread_key_create "pthread_key_t *key" "void (*destructor)(void *)" +.Sh DESCRIPTION +The +.Fn pthread_key_create +function creates a thread-specific data key visible to all threads in the +process. +Key values provided by +.Fn pthread_key_create +are opaque objects used to locate thread-specific data. +Although the same +key value may be used by different threads, the values bound to the key +by +.Fn pthread_setspecific +are maintained on a per-thread basis and persist for the life of the calling +thread. +.Pp +Upon key creation, the value NULL is associated with the new key in all +active threads. +Upon thread creation, the value NULL is associated with all +defined keys in the new thread. +.Pp +An optional destructor function may be associated with each key value. +At +thread exit, if a key value has a non-NULL destructor pointer, and the +thread has a non-NULL value associated with the key, the function pointed +to is called with the current associated value as its sole argument. +The +order of destructor calls is unspecified if more than one destructor exists +for a thread when it exits. +.Pp +If, after all the destructors have been called for all non-NULL values +with associated destructors, there are still some non-NULL values with +associated destructors, then the process is repeated. +If, after at least +[PTHREAD_DESTRUCTOR_ITERATIONS] iterations of destructor calls for +outstanding non-NULL values, there are still some non-NULL values with +associated destructors, the implementation stops calling destructors. +.Sh RETURN VALUES +If successful, the +.Fn pthread_key_create +function will store the newly created key value at the location specified by +.Fa key +and returns zero. +Otherwise an error number will be returned to indicate +the error. +.Sh ERRORS +.Fn pthread_key_create +will fail if: +.Bl -tag -width Er +.It Bq Er EAGAIN +The system lacked the necessary resources to create another thread-specific +data key, or the system-imposed limit on the total number of keys per process +[PTHREAD_KEYS_MAX] would be exceeded. +.It Bq Er ENOMEM +Insufficient memory exists to create the key. +.El +.Sh SEE ALSO +.Xr pthread_getspecific 3 , +.Xr pthread_key_delete 3 , +.Xr pthread_setspecific 3 +.Sh STANDARDS +.Fn pthread_key_create +conforms to +.St -p1003.1-96 . diff --git a/pthreads/pthread_key_delete.3 b/pthreads/pthread_key_delete.3 new file mode 100644 index 0000000..9e4a1ae --- /dev/null +++ b/pthreads/pthread_key_delete.3 @@ -0,0 +1,96 @@ +.\" Copyright (c) 1996 John Birrell . +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by John Birrell. +.\" 4. Neither the name of the author nor the names of any co-contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_key_delete.3,v 1.6.2.4 2001/08/17 15:42:51 ru Exp $ +.\" +.Dd April 4, 1996 +.Dt PTHREAD_KEY_DELETE 3 +.Os +.Sh NAME +.Nm pthread_key_delete +.Nd delete a thread-specific data key +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn pthread_key_delete "pthread_key_t key" +.Sh DESCRIPTION +The +.Fn pthread_key_delete +function deletes a thread-specific data key previously returned by +.Fn pthread_key_create . +The thread-specific data values associated with +.Fa key +need not be NULL at the time that +.Fn pthread_key_delete +is called. +It is the responsibility of the application to free any +application storage or perform any cleanup actions for data structures +related to the deleted key or associated thread-specific data in any threads; +this cleanup can be done either before or after +.Fn pthread_key_delete +is called. +Any attempt to use +.Fa key +following the call to +.Fn pthread_key_delete +results in undefined behavior. +.Pp +The +.Fn pthread_key_delete +function is callable from within destructor functions. +Destructor functions +are not invoked by +.Fn pthread_key_delete . +Any destructor function that may have been associated with +.Fa key +will no longer be called upon thread exit. +.Sh RETURN VALUES +If successful, the +.Fn pthread_key_delete +function will return zero. +Otherwise an error number will be returned to +indicate the error. +.Sh ERRORS +.Fn pthread_key_delete +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The +.Fa key +value is invalid. +.El +.Sh SEE ALSO +.Xr pthread_getspecific 3 , +.Xr pthread_key_create 3 , +.Xr pthread_setspecific 3 +.Sh STANDARDS +.Fn pthread_key_delete +conforms to +.St -p1003.1-96 . diff --git a/pthreads.subproj/pthread_machdep.h b/pthreads/pthread_machdep.h similarity index 100% rename from pthreads.subproj/pthread_machdep.h rename to pthreads/pthread_machdep.h diff --git a/pthreads.subproj/pthread_mutex.c b/pthreads/pthread_mutex.c similarity index 68% rename from pthreads.subproj/pthread_mutex.c rename to pthreads/pthread_mutex.c index 427026a..c82a692 100644 --- a/pthreads.subproj/pthread_mutex.c +++ b/pthreads/pthread_mutex.c @@ -59,11 +59,18 @@ pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr) return (EINVAL); mutex->prioceiling = attr->prioceiling; mutex->protocol = attr->protocol; - } else - { + mutex->type = attr->type; + if ((mutex->type == PTHREAD_MUTEX_DEFAULT) || (mutex->type == PTHREAD_MUTEX_NORMAL)) + mutex->def = 1; + else + mutex->def = 0; + } else { mutex->prioceiling = _PTHREAD_DEFAULT_PRIOCEILING; mutex->protocol = _PTHREAD_DEFAULT_PROTOCOL; + mutex->type = PTHREAD_MUTEX_DEFAULT; + mutex->def = 1; } + mutex->lock_count = 0; mutex->owner = (pthread_t)NULL; mutex->next = (pthread_mutex_t *)NULL; mutex->prev = (pthread_mutex_t *)NULL; @@ -79,15 +86,13 @@ pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr) */ #if defined(DEBUG) static void -_pthread_mutex_add(pthread_mutex_t *mutex) +_pthread_mutex_add(pthread_mutex_t *mutex, pthread_t self) { pthread_mutex_t *m; - pthread_t self = pthread_self(); if (self != (pthread_t)0) { - mutex->owner = self; if ((m = self->mutexes) != (pthread_mutex_t *)NULL) { /* Add to list */ - m->prev = mutex; + m->prev = mutex; } mutex->next = m; mutex->prev = (pthread_mutex_t *)NULL; @@ -112,7 +117,6 @@ _pthread_mutex_remove(pthread_mutex_t *mutex, pthread_t self) self->mutexes = n; } } - mutex->owner = (pthread_t)NULL; } #endif @@ -124,6 +128,8 @@ int pthread_mutex_lock(pthread_mutex_t *mutex) { kern_return_t kern_res; + pthread_t self; + int slowpath; if (mutex->sig == _PTHREAD_MUTEX_SIG_init) { @@ -133,9 +139,36 @@ pthread_mutex_lock(pthread_mutex_t *mutex) } if (mutex->sig != _PTHREAD_MUTEX_SIG) return (EINVAL); /* Not a mutex variable */ + +#if !defined(DEBUG) + if (mutex->def) { + slowpath = 0; + self = (pthread_t)0x12141968; + } else +#endif /* DEBUG */ + { + slowpath = 1; + self = pthread_self(); + } + LOCK(mutex->lock); + if (mutex->waiters || (mutex->owner != (pthread_t)NULL)) { + if(slowpath && (mutex->owner == self)) { + if(mutex->type == PTHREAD_MUTEX_ERRORCHECK ) { + UNLOCK(mutex->lock); + return(EDEADLK); + } else if (mutex->type == PTHREAD_MUTEX_RECURSIVE ) { + if (mutex->lock_count >= USHRT_MAX){ + UNLOCK(mutex->lock); + return(EAGAIN); + } + mutex->lock_count++; + UNLOCK(mutex->lock); + return(ESUCCESS); + } + } mutex->waiters++; if (mutex->sem == MACH_PORT_NULL) { mutex->sem = new_sem_from_pool(); @@ -154,11 +187,12 @@ pthread_mutex_lock(pthread_mutex_t *mutex) mutex->cond_lock = 0; } } -#if defined(DEBUG) - _pthread_mutex_add(mutex); -#else - mutex->owner = (pthread_t)0x12141968; +#if defined(DEBUG) + _pthread_mutex_add(mutex, self); #endif + mutex->owner = self; + if (slowpath && (mutex->type == PTHREAD_MUTEX_RECURSIVE)) + mutex->lock_count = 1; UNLOCK(mutex->lock); return (ESUCCESS); } @@ -170,6 +204,8 @@ int pthread_mutex_trylock(pthread_mutex_t *mutex) { kern_return_t kern_res; + pthread_t self; + int slowpath; if (mutex->sig == _PTHREAD_MUTEX_SIG_init) { @@ -179,27 +215,50 @@ pthread_mutex_trylock(pthread_mutex_t *mutex) } if (mutex->sig != _PTHREAD_MUTEX_SIG) return (EINVAL); /* Not a mutex variable */ + +#if !defined(DEBUG) + if (mutex->def) { + slowpath = 0; + self = (pthread_t)0x12141968; + } else +#endif /* DEBUG */ + { + slowpath = 1; + self = pthread_self(); + } + if (!TRY_LOCK(mutex->lock)) { return (EBUSY); } + + if(slowpath && (mutex->owner == self) && (mutex->type == PTHREAD_MUTEX_RECURSIVE )) { + if (mutex->lock_count >= USHRT_MAX) { + UNLOCK(mutex->lock); + return(EAGAIN); + } + mutex->lock_count++; + UNLOCK(mutex->lock); + return(ESUCCESS); + } + if (mutex->waiters || ((mutex->owner != (pthread_t)NULL) && (mutex->cond_lock == 0))) { UNLOCK(mutex->lock); return (EBUSY); - } else - { + } else { #if defined(DEBUG) - _pthread_mutex_add(mutex); -#else - mutex->owner = (pthread_t)0x12141968; + _pthread_mutex_add(mutex, self); #endif + mutex->owner = (pthread_t)self; if (mutex->cond_lock) { PTHREAD_MACH_CALL(semaphore_wait(mutex->sem), kern_res); mutex->cond_lock = 0; restore_sem_to_pool(mutex->sem); mutex->sem = MACH_PORT_NULL; } + if (slowpath && (mutex->type == PTHREAD_MUTEX_RECURSIVE)) + mutex->lock_count = 1; UNLOCK(mutex->lock); return (ESUCCESS); } @@ -214,6 +273,9 @@ pthread_mutex_unlock(pthread_mutex_t *mutex) { kern_return_t kern_res; int waiters; + pthread_t self; + int slowpath; + if (mutex->sig == _PTHREAD_MUTEX_SIG_init) { int res; @@ -222,28 +284,53 @@ pthread_mutex_unlock(pthread_mutex_t *mutex) } if (mutex->sig != _PTHREAD_MUTEX_SIG) return (EINVAL); /* Not a mutex variable */ + +#if !defined(DEBUG) + if (mutex->def) { + slowpath = 0; + self = (pthread_t)0x12141968; + } else +#endif /* DEBUG */ + { + slowpath = 1; + self = pthread_self(); + } + LOCK(mutex->lock); + #if defined(DEBUG) - if (mutex->owner != pthread_self()) - { - UNLOCK(mutex->lock); - abort(); - return (EPERM); - } else + if (mutex->owner != self) +#else + if (slowpath + && ((mutex->type == PTHREAD_MUTEX_ERRORCHECK ) + || (mutex->type == PTHREAD_MUTEX_RECURSIVE )) + && (mutex->owner != self)) +#endif /* DEBUG */ + { + UNLOCK(mutex->lock); +#if defined(DEBUG) + abort(); #endif - { + return(EPERM); + } + + if (slowpath && (mutex->type == PTHREAD_MUTEX_RECURSIVE) && --mutex->lock_count) { + UNLOCK(mutex->lock); + return (ESUCCESS); + + } else { #if defined(DEBUG) _pthread_mutex_remove(mutex, mutex->owner); -#else - mutex->owner = (pthread_t)NULL; -#endif +#endif /* DEBUG */ waiters = mutex->waiters; + mutex->owner = (pthread_t)NULL; UNLOCK(mutex->lock); if (waiters) { PTHREAD_MACH_CALL(semaphore_signal(mutex->sem), kern_res); } return (ESUCCESS); + } } @@ -337,6 +424,39 @@ pthread_mutexattr_getprotocol(const pthread_mutexattr_t *attr, return (EINVAL); /* Not an initialized 'attribute' structure */ } } +/* + * Get the mutex 'type' value from a mutex attribute structure. + * Note: written as a 'helper' function to hide implementation details. + */ +int +pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, + int *type) +{ + if (attr->sig == _PTHREAD_MUTEX_ATTR_SIG) + { + *type = attr->type; + return (ESUCCESS); + } else + { + return (EINVAL); /* Not an initialized 'attribute' structure */ + } +} + +/* + * + */ +int +pthread_mutexattr_getpshared(const pthread_mutexattr_t *attr, int *pshared) +{ + if (attr->sig == _PTHREAD_MUTEX_ATTR_SIG) + { + *pshared = (int)PTHREAD_PROCESS_PRIVATE; + return (ESUCCESS); + } else + { + return (EINVAL); /* Not an initialized 'attribute' structure */ + } +} /* * Initialize a mutex attribute structure to system defaults. @@ -346,6 +466,7 @@ pthread_mutexattr_init(pthread_mutexattr_t *attr) { attr->prioceiling = _PTHREAD_DEFAULT_PRIOCEILING; attr->protocol = _PTHREAD_DEFAULT_PROTOCOL; + attr->type = PTHREAD_MUTEX_DEFAULT; attr->sig = _PTHREAD_MUTEX_ATTR_SIG; return (ESUCCESS); } @@ -400,6 +521,54 @@ pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, return (EINVAL); /* Not an initialized 'attribute' structure */ } } +/* + * Set the mutex 'type' value in a mutex attribute structure. + * Note: written as a 'helper' function to hide implementation details. + */ +int +pthread_mutexattr_settype(pthread_mutexattr_t *attr, + int type) +{ + if (attr->sig == _PTHREAD_MUTEX_ATTR_SIG) + { + if ((type == PTHREAD_MUTEX_NORMAL) || + (type == PTHREAD_MUTEX_ERRORCHECK) || + (type == PTHREAD_MUTEX_RECURSIVE) || + (type == PTHREAD_MUTEX_DEFAULT)) + { + attr->type = type; + return (ESUCCESS); + } else + { + return (EINVAL); /* Invalid parameter */ + } + } else + { + return (EINVAL); /* Not an initialized 'attribute' structure */ + } +} + +/* + * + */ +int +pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared) +{ + if (attr->sig == _PTHREAD_MUTEX_ATTR_SIG) + { + if (pshared == PTHREAD_PROCESS_PRIVATE) + { + /* attr->pshared = protocol; */ + return (ESUCCESS); + } else + { + return (EINVAL); /* Invalid parameter */ + } + } else + { + return (EINVAL); /* Not an initialized 'attribute' structure */ + } +} int mutex_try_lock(int *x) { return _spin_lock_try((pthread_lock_t *)x); @@ -414,7 +583,15 @@ void mutex_wait_lock(int *x) { } } -void cthread_yield(void) { +void +cthread_yield(void) +{ + sched_yield(); +} + +void +pthread_yield_np (void) +{ sched_yield(); } diff --git a/pthreads/pthread_mutex_destroy.3 b/pthreads/pthread_mutex_destroy.3 new file mode 100644 index 0000000..d00d976 --- /dev/null +++ b/pthreads/pthread_mutex_destroy.3 @@ -0,0 +1,70 @@ +.\" Copyright (c) 1997 Brian Cully +.\" 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 author nor the names of any co-contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_mutex_destroy.3,v 1.5.2.4 2001/08/17 15:42:51 ru Exp $ +.\" +.Dd July 29, 1998 +.Dt PTHREAD_MUTEX_DESTROY 3 +.Os +.Sh NAME +.Nm pthread_mutex_destroy +.Nd free resources allocated for a mutex +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn pthread_mutex_destroy "pthread_mutex_t *mutex" +.Sh DESCRIPTION +The +.Fn pthread_mutex_destroy +function frees the resources allocated for +.Fa mutex . +.Sh RETURN VALUES +If successful, +.Fn pthread_mutex_destroy +will return zero, otherwise an error number will be returned to +indicate the error. +.Sh ERRORS +.Fn pthread_mutex_destroy +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The value specified by +.Fa mutex +is invalid. +.It Bq Er EBUSY +.Fa Mutex +is locked by another thread. +.El +.Sh SEE ALSO +.Xr pthread_mutex_init 3 , +.Xr pthread_mutex_lock 3 , +.Xr pthread_mutex_trylock 3 , +.Xr pthread_mutex_unlock 3 +.Sh STANDARDS +.Fn pthread_mutex_destroy +conforms to +.St -p1003.1-96 . diff --git a/pthreads/pthread_mutex_init.3 b/pthreads/pthread_mutex_init.3 new file mode 100644 index 0000000..bd6e2f5 --- /dev/null +++ b/pthreads/pthread_mutex_init.3 @@ -0,0 +1,75 @@ +.\" Copyright (c) 1997 Brian Cully +.\" 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 author nor the names of any co-contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_mutex_init.3,v 1.6.2.4 2001/08/17 15:42:51 ru Exp $ +.\" +.Dd July 29, 1998 +.Dt PTHREAD_MUTEX_INIT 3 +.Os +.Sh NAME +.Nm pthread_mutex_init +.Nd create a mutex +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn pthread_mutex_init "pthread_mutex_t *mutex" "const pthread_mutexattr_t *attr" +.Sh DESCRIPTION +The +.Fn pthread_mutex_init +function creates a new mutex, with attributes specified with +.Fa attr . +If +.Fa attr +is NULL the default attributes are used. +.Sh RETURN VALUES +If successful, +.Fn pthread_mutex_init +will return zero and put the new mutex id into +.Fa mutex , +otherwise an error number will be returned to indicate the error. +.Sh ERRORS +.Fn pthread_mutex_init +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The value specified by +.Fa attr +is invalid. +.It Bq Er ENOMEM +The process cannot allocate enough memory to create another mutex. +.It Bq Er EAGAIN +The temporarily lacks the resources to create another mutex. +.El +.Sh SEE ALSO +.Xr pthread_mutex_destroy 3 , +.Xr pthread_mutex_lock 3 , +.Xr pthread_mutex_trylock 3 , +.Xr pthread_mutex_unlock 3 +.Sh STANDARDS +.Fn pthread_mutex_init +conforms to +.St -p1003.1-96 . diff --git a/pthreads/pthread_mutex_lock.3 b/pthreads/pthread_mutex_lock.3 new file mode 100644 index 0000000..468bd0c --- /dev/null +++ b/pthreads/pthread_mutex_lock.3 @@ -0,0 +1,72 @@ +.\" Copyright (c) 1997 Brian Cully +.\" 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 author nor the names of any co-contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_mutex_lock.3,v 1.5.2.4 2001/08/17 15:42:51 ru Exp $ +.\" +.Dd July 30, 1998 +.Dt PTHREAD_MUTEX_LOCK 3 +.Os +.Sh NAME +.Nm pthread_mutex_lock +.Nd lock a mutex +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn pthread_mutex_lock "pthread_mutex_t *mutex" +.Sh DESCRIPTION +The +.Fn pthread_mutex_lock +function locks +.Fa mutex . +If the mutex is already locked, the calling thread will block until the +mutex becomes available. +.Sh RETURN VALUES +If successful, +.Fn pthread_mutex_lock +will return zero, otherwise an error number will be returned to +indicate the error. +.Sh ERRORS +.Fn pthread_mutex_lock +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The value specified by +.Fa mutex +is invalid. +.It Bq Er EDEADLK +A deadlock would occur if the thread blocked waiting for +.Fa mutex . +.El +.Sh SEE ALSO +.Xr pthread_mutex_destroy 3 , +.Xr pthread_mutex_init 3 , +.Xr pthread_mutex_trylock 3 , +.Xr pthread_mutex_unlock 3 +.Sh STANDARDS +.Fn pthread_mutex_lock +conforms to +.St -p1003.1-96 . diff --git a/pthreads/pthread_mutex_trylock.3 b/pthreads/pthread_mutex_trylock.3 new file mode 100644 index 0000000..87fac64 --- /dev/null +++ b/pthreads/pthread_mutex_trylock.3 @@ -0,0 +1,73 @@ +.\" Copyright (c) 1997 Brian Cully +.\" 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 author nor the names of any co-contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_mutex_trylock.3,v 1.5.2.4 2001/08/17 15:42:51 ru Exp $ +.\" +.Dd July 30, 1998 +.Dt PTHREAD_MUTEX_TRYLOCK 3 +.Os +.Sh NAME +.Nm pthread_mutex_trylock +.Nd attempt to lock a mutex without blocking +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn pthread_mutex_trylock "pthread_mutex_t *mutex" +.Sh DESCRIPTION +The +.Fn pthread_mutex_trylock +function locks +.Fa mutex . +If the mutex is already locked, +.Fn pthread_mutex_trylock +will not block waiting for the mutex, but will return an error condition. +.Sh RETURN VALUES +If successful, +.Fn pthread_mutex_trylock +will return zero, otherwise an error number will be returned to +indicate the error. +.Sh ERRORS +.Fn pthread_mutex_trylock +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The value specified by +.Fa mutex +is invalid. +.It Bq Er EBUSY +.Fa Mutex +is already locked. +.El +.Sh SEE ALSO +.Xr pthread_mutex_destroy 3 , +.Xr pthread_mutex_init 3 , +.Xr pthread_mutex_lock 3 , +.Xr pthread_mutex_unlock 3 +.Sh STANDARDS +.Fn pthread_mutex_trylock +conforms to +.St -p1003.1-96 . diff --git a/pthreads/pthread_mutex_unlock.3 b/pthreads/pthread_mutex_unlock.3 new file mode 100644 index 0000000..38c509f --- /dev/null +++ b/pthreads/pthread_mutex_unlock.3 @@ -0,0 +1,72 @@ +.\" Copyright (c) 1997 Brian Cully +.\" 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 author nor the names of any co-contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_mutex_unlock.3,v 1.5.2.4 2001/08/17 15:42:51 ru Exp $ +.\" +.Dd July 30, 1998 +.Dt PTHREAD_MUTEX_UNLOCK 3 +.Os +.Sh NAME +.Nm pthread_mutex_unlock +.Nd unlock a mutex +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn pthread_mutex_unlock "pthread_mutex_t *mutex" +.Sh DESCRIPTION +If the current thread holds the lock on +.Fa mutex , +then the +.Fn pthread_mutex_unlock +function unlocks +.Fa mutex . +.Sh RETURN VALUES +If successful, +.Fn pthread_mutex_unlock +will return zero, otherwise an error number will be returned to +indicate the error. +.Sh ERRORS +.Fn pthread_mutex_trylock +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The value specified by +.Fa mutex +is invalid. +.It Bq Er EPERM +The current thread does not hold a lock on +.Fa mutex . +.El +.Sh SEE ALSO +.Xr pthread_mutex_destroy 3 , +.Xr pthread_mutex_init 3 , +.Xr pthread_mutex_lock 3 , +.Xr pthread_mutex_trylock 3 +.Sh STANDARDS +.Fn pthread_mutex_unlock +conforms to +.St -p1003.1-96 . diff --git a/pthreads/pthread_mutexattr.3 b/pthreads/pthread_mutexattr.3 new file mode 100644 index 0000000..7588739 --- /dev/null +++ b/pthreads/pthread_mutexattr.3 @@ -0,0 +1,175 @@ +.\" Copyright (C) 2000 Jason Evans . +.\" 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(s), this list of conditions and the following disclaimer as +.\" the first lines of this file unmodified other than the possible +.\" addition of one or more copyright notices. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice(s), this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_mutexattr.3,v 1.2.2.5 2001/08/17 15:42:52 ru Exp $ +.Dd May 1, 2000 +.Dt PTHREAD_MUTEXATTR 3 +.Os +.Sh NAME +.Nm pthread_mutexattr_init , +.Nm pthread_mutexattr_destroy , +.Nm pthread_mutexattr_setprioceiling , +.Nm pthread_mutexattr_getprioceiling , +.Nm pthread_mutexattr_setprotocol , +.Nm pthread_mutexattr_getprotocol , +.Nm pthread_mutexattr_settype , +.Nm pthread_mutexattr_gettype +.Nd mutex attribute operations +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn pthread_mutexattr_init "pthread_mutexattr_t *attr" +.Ft int +.Fn pthread_mutexattr_destroy "pthread_mutexattr_t *attr" +.Ft int +.Fn pthread_mutexattr_setprioceiling "pthread_mutexattr_t *attr" "int prioceiling" +.Ft int +.Fn pthread_mutexattr_getprioceiling "pthread_mutexattr_t *attr" "int *prioceiling" +.Ft int +.Fn pthread_mutexattr_setprotocol "pthread_mutexattr_t *attr" "int protocol" +.Ft int +.Fn pthread_mutexattr_getprotocol "pthread_mutexattr_t *attr" "int *protocol" +.Ft int +.Fn pthread_mutexattr_settype "pthread_mutexattr_t *attr" "int type" +.Ft int +.Fn pthread_mutexattr_gettype "pthread_mutexattr_t *attr" "int *type" +.Sh DESCRIPTION +Mutex attributes are used to specify parameters to +.Fn pthread_mutex_init . +One attribute object can be used in multiple calls to +.Fn pthread_mutex_init , +with or without modifications between calls. +.Pp +The +.Fn pthread_mutexattr_init +function initializes +.Fa attr +with all the default mutex attributes. +.Pp +The +.Fn pthread_mutexattr_destroy +function destroys +.Fa attr . +.Pp +The +.Fn pthread_mutexattr_set* +functions set the attribute that corresponds to each function name. +.Pp +The +.Fn pthread_mutexattr_get* +functions copy the value of the attribute that corresponds to each function name +to the location pointed to by the second function parameter. +.Sh RETURN VALUES +If successful, these functions return 0. +Otherwise, an error number is returned to indicacte the error. +.Sh ERRORS +.Fn pthread_mutexattr_init +will fail if: +.Bl -tag -width Er +.It Bq Er ENOMEM +Out of memory. +.El +.Pp +.Fn pthread_mutexattr_destroy +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +Invalid value for +.Fa attr . +.El +.Pp +.Fn pthread_mutexattr_setprioceiling +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +Invalid value for +.Fa attr , +or invalid value for +.Fa prioceiling . +.El +.Pp +.Fn pthread_mutexattr_getprioceiling +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +Invalid value for +.Fa attr . +.El +.Pp +.Fn pthread_mutexattr_setprotocol +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +Invalid value for +.Fa attr , +or invalid value for +.Fa protocol . +.El +.Pp +.Fn pthread_mutexattr_getprotocol +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +Invalid value for +.Fa attr . +.El +.Pp +.Fn pthread_mutexattr_settype +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +Invalid value for +.Fa attr , +or invalid value for +.Fa type . +.El +.Pp +.Fn pthread_mutexattr_gettype +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +Invalid value for +.Fa attr . +.El +.Sh SEE ALSO +.Xr pthread_mutex_init 3 +.Sh STANDARDS +.Fn pthread_mutexattr_init +and +.Fn pthread_mutexattr_destroy +conform to +.St -p1003.1-96 +.Pp +.Fn pthread_mutexattr_setprioceiling , +.Fn pthread_mutexattr_getprioceiling , +.Fn pthread_mutexattr_setprotocol , +.Fn pthread_mutexattr_getprotocol , +.Fn pthread_mutexattr_settype , +and +.Fn pthread_mutexattr_gettype +conform to +.St -susv2 diff --git a/pthreads/pthread_once.3 b/pthreads/pthread_once.3 new file mode 100644 index 0000000..d9d5685 --- /dev/null +++ b/pthreads/pthread_once.3 @@ -0,0 +1,103 @@ +.\" Copyright (c) 1996 John Birrell . +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by John Birrell. +.\" 4. Neither the name of the author nor the names of any co-contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_once.3,v 1.6.2.6 2001/08/17 15:42:52 ru Exp $ +.\" +.Dd April 4, 1996 +.Dt PTHREAD_ONCE 3 +.Os +.Sh NAME +.Nm pthread_once +.Nd dynamic package initialization +.Sh SYNOPSIS +.Fd #include +.Pp +pthread_once_t +.Fa once_control += PTHREAD_ONCE_INIT; +.Ft int +.Fn pthread_once "pthread_once_t *once_control" "void (*init_routine)(void)" +.Sh DESCRIPTION +The first call to +.Fn pthread_once +by any thread in a process, with a given +.Fa once_control , +will call the +.Fn init_routine +with no arguments. +Subsequent calls to +.Fn pthread_once +with the same +.Fa once_control +will not call the +.Fn init_routine . +On return from +.Fn pthread_once , +it is guaranteed that +.Fn init_routine +has completed. +The +.Fa once_control +parameter is used to determine whether the associated initialization +routine has been called. +.Pp +The function +.Fn pthread_once +is not a cancellation point. +However, if +.Fn init_routine +is a cancellation point and is cancelled, the effect on +.Fa once_control is as if +.Fn pthread_once +was never called. +.Pp +The constant +.Fa PTHREAD_ONCE_INIT +is defined by header +.Aq Pa pthread.h . +.Pp +The behavior of +.Fn pthread_once +is undefined if +.Fa once_control +has automatic storage duration or is not initialized by +.Fa PTHREAD_ONCE_INIT . +.Sh RETURN VALUES +If successful, the +.Fn pthread_once +function will return zero. +Otherwise an error number will be returned to +indicate the error. +.Sh ERRORS +None. +.Sh STANDARDS +.Fn pthread_once +conforms to +.St -p1003.1-96 . diff --git a/pthreads/pthread_rwlock.c b/pthreads/pthread_rwlock.c new file mode 100644 index 0000000..978ed80 --- /dev/null +++ b/pthreads/pthread_rwlock.c @@ -0,0 +1,319 @@ +/*- + * Copyright (c) 1998 Alex Nash + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + * $FreeBSD: src/lib/libc_r/uthread/uthread_rwlock.c,v 1.6 2001/04/10 04:19:20 deischen Exp $ + */ + +/* + * POSIX Pthread Library + * -- Read Write Lock support + * 4/24/02: A. Ramesh + * Ported from FreeBSD + */ + +#include "pthread_internals.h" + +/* maximum number of times a read lock may be obtained */ +#define MAX_READ_LOCKS (INT_MAX - 1) + +int +pthread_rwlock_destroy(pthread_rwlock_t *rwlock) +{ + + if (rwlock->sig != _PTHREAD_RWLOCK_SIG) { + return(EINVAL); + } else { + pthread_mutex_destroy(&rwlock->lock); + pthread_cond_destroy(&rwlock->read_signal); + pthread_cond_destroy(&rwlock->write_signal); + rwlock->sig = _PTHREAD_NO_SIG; + return(ESUCCESS); + } +} + +int +pthread_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr) +{ + int ret; + + /* initialize the lock */ + if ((ret = pthread_mutex_init(&rwlock->lock, NULL)) != 0) + return(ret); + else { + /* initialize the read condition signal */ + ret = pthread_cond_init(&rwlock->read_signal, NULL); + + if (ret != 0) { + pthread_mutex_destroy(&rwlock->lock); + return(ret); + } else { + /* initialize the write condition signal */ + ret = pthread_cond_init(&rwlock->write_signal, NULL); + + if (ret != 0) { + pthread_cond_destroy(&rwlock->read_signal); + pthread_mutex_destroy(&rwlock->lock); + return(ret); + } else { + /* success */ + rwlock->state = 0; + rwlock->blocked_writers = 0; + rwlock->sig = _PTHREAD_RWLOCK_SIG; + return(ESUCCESS); + } + } + } +} + +int +pthread_rwlock_rdlock(pthread_rwlock_t *rwlock) +{ + int ret; + + if (rwlock->sig == _PTHREAD_RWLOCK_SIG_init) { + if ((ret = pthread_rwlock_init(rwlock, NULL)) != 0) { + return(ret); + } + } + + if (rwlock->sig != _PTHREAD_RWLOCK_SIG) + return(EINVAL); + /* grab the monitor lock */ + if ((ret = pthread_mutex_lock(&rwlock->lock)) != 0) + return(ret); + + /* give writers priority over readers */ + while (rwlock->blocked_writers || rwlock->state < 0) { + ret = pthread_cond_wait(&rwlock->read_signal, &rwlock->lock); + + if (ret != 0) { + /* can't do a whole lot if this fails */ + pthread_mutex_unlock(&rwlock->lock); + return(ret); + } + } + + /* check lock count */ + if (rwlock->state == MAX_READ_LOCKS) + ret = EAGAIN; + else + ++rwlock->state; /* indicate we are locked for reading */ + + /* + * Something is really wrong if this call fails. Returning + * error won't do because we've already obtained the read + * lock. Decrementing 'state' is no good because we probably + * don't have the monitor lock. + */ + pthread_mutex_unlock(&rwlock->lock); + + return(ret); +} + +int +pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock) +{ + int ret; + + /* check for static initialization */ + if (rwlock->sig == _PTHREAD_RWLOCK_SIG_init) { + if ((ret = pthread_rwlock_init(rwlock, NULL)) != 0) { + return(ret); + } + } + + if (rwlock->sig != _PTHREAD_RWLOCK_SIG) + return(EINVAL); + /* grab the monitor lock */ + if ((ret = pthread_mutex_lock(&rwlock->lock)) != 0) + return(ret); + + /* give writers priority over readers */ + if (rwlock->blocked_writers || rwlock->state < 0) + ret = EBUSY; + else if (rwlock->state == MAX_READ_LOCKS) + ret = EAGAIN; /* too many read locks acquired */ + else + ++rwlock->state; /* indicate we are locked for reading */ + + /* see the comment on this in pthread_rwlock_rdlock */ + pthread_mutex_unlock(&rwlock->lock); + + return(ret); +} + +int +pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock) +{ + int ret; + + /* check for static initialization */ + if (rwlock->sig == _PTHREAD_RWLOCK_SIG_init) { + if ((ret = pthread_rwlock_init(rwlock, NULL)) != 0) { + return(ret); + } + } + + if (rwlock->sig != _PTHREAD_RWLOCK_SIG) + return(EINVAL); + /* grab the monitor lock */ + if ((ret = pthread_mutex_lock(&rwlock->lock)) != 0) + return(ret); + + if (rwlock->state != 0) + ret = EBUSY; + else + /* indicate we are locked for writing */ + rwlock->state = -1; + + /* see the comment on this in pthread_rwlock_rdlock */ + pthread_mutex_unlock(&rwlock->lock); + + return(ret); +} + +int +pthread_rwlock_unlock(pthread_rwlock_t *rwlock) +{ + int ret; + + if (rwlock->sig != _PTHREAD_RWLOCK_SIG) + return(EINVAL); + /* grab the monitor lock */ + if ((ret = pthread_mutex_lock(&rwlock->lock)) != 0) + return(ret); + + if (rwlock->state > 0) { + if (--rwlock->state == 0 && rwlock->blocked_writers) + ret = pthread_cond_signal(&rwlock->write_signal); + } else if (rwlock->state < 0) { + rwlock->state = 0; + + if (rwlock->blocked_writers) + ret = pthread_cond_signal(&rwlock->write_signal); + else + ret = pthread_cond_broadcast(&rwlock->read_signal); + } else + ret = EINVAL; + + /* see the comment on this in pthread_rwlock_rdlock */ + pthread_mutex_unlock(&rwlock->lock); + + return(ret); +} + +int +pthread_rwlock_wrlock(pthread_rwlock_t *rwlock) +{ + int ret; + + /* check for static initialization */ + if (rwlock->sig == _PTHREAD_RWLOCK_SIG_init) { + if ((ret = pthread_rwlock_init(rwlock, NULL)) != 0) { + return(ret); + } + } + + if (rwlock->sig != _PTHREAD_RWLOCK_SIG) + return(EINVAL); + /* grab the monitor lock */ + if ((ret = pthread_mutex_lock(&rwlock->lock)) != 0) + return(ret); + + while (rwlock->state != 0) { + ++rwlock->blocked_writers; + + ret = pthread_cond_wait(&rwlock->write_signal, &rwlock->lock); + + if (ret != 0) { + --rwlock->blocked_writers; + pthread_mutex_unlock(&rwlock->lock); + return(ret); + } + + --rwlock->blocked_writers; + } + + /* indicate we are locked for writing */ + rwlock->state = -1; + + /* see the comment on this in pthread_rwlock_rdlock */ + pthread_mutex_unlock(&rwlock->lock); + + return(ret); +} + +int +pthread_rwlockattr_init(pthread_rwlockattr_t *attr) +{ + attr->sig = _PTHREAD_RWLOCK_ATTR_SIG; + attr->pshared = PTHREAD_PROCESS_PRIVATE; + return (ESUCCESS); +} + +int +pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr) +{ + attr->sig = _PTHREAD_NO_SIG; /* Uninitialized */ + attr->pshared = 0; + return (ESUCCESS); +} + +int +pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *attr, + int *pshared) +{ + if (attr->sig == _PTHREAD_RWLOCK_ATTR_SIG) + { + /* *pshared = (int)attr->pshared; */ + *pshared = (int)PTHREAD_PROCESS_PRIVATE; + return (ESUCCESS); + } else + { + return (EINVAL); /* Not an initialized 'attribute' structure */ + } +} + + +int +pthread_rwlockattr_setpshared(pthread_rwlockattr_t * attr, int pshared) +{ + if (attr->sig == _PTHREAD_RWLOCK_ATTR_SIG) + { + if ( pshared == PTHREAD_PROCESS_PRIVATE) + { + attr->pshared = pshared ; + return (ESUCCESS); + } else + { + return (EINVAL); /* Invalid parameter */ + } + } else + { + return (EINVAL); /* Not an initialized 'attribute' structure */ + } + +} + diff --git a/pthreads/pthread_rwlock_destroy.3 b/pthreads/pthread_rwlock_destroy.3 new file mode 100644 index 0000000..2e77f37 --- /dev/null +++ b/pthreads/pthread_rwlock_destroy.3 @@ -0,0 +1,80 @@ +.\" Copyright (c) 1998 Alex Nash +.\" 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. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_rwlock_destroy.3,v 1.6 2001/10/01 16:09:09 ru Exp $ +.\" +.Dd August 4, 1998 +.Dt PTHREAD_RWLOCK_DESTROY 3 +.Os +.Sh NAME +.Nm pthread_rwlock_destroy +.Nd destroy a read/write lock +.Sh SYNOPSIS +.In pthread.h +.Ft int +.Fn pthread_rwlock_destroy "pthread_rwlock_t *lock" +.Sh DESCRIPTION +The +.Fn pthread_rwlock_destroy +function is used to destroy a read/write lock previously created with +.Fn pthread_rwlock_init . +.Sh RETURN VALUES +If successful, the +.Fn pthread_rwlock_destroy +function will return zero. Otherwise an error number will be returned +to indicate the error. +.Sh SEE ALSO +.Xr pthread_rwlock_init 3 +.Sh STANDARDS +The +.Fn pthread_rwlock_destroy +function is expected to conform to +.St -susv2 . +.Sh ERRORS +The +.Fn pthread_rwlock_destroy +function will fail if: +.Bl -tag -width Er +.It Bq Er EPERM +The caller does not have the privilege to perform the operation. +.El +.Pp +The +.Fn pthread_rwlock_destroy +function may fail if: +.Bl -tag -width Er +.It Bq Er EBUSY +The system has detected an attempt to destroy the object referenced by +.Fa lock +while it is locked. +.It Bq Er EINVAL +The value specified by +.Fa lock +is invalid. +.El +.Sh HISTORY +The +.Fn pthread_rwlock_destroy +function first appeared in +.Fx 3.0 . diff --git a/pthreads/pthread_rwlock_init.3 b/pthreads/pthread_rwlock_init.3 new file mode 100644 index 0000000..6a47d38 --- /dev/null +++ b/pthreads/pthread_rwlock_init.3 @@ -0,0 +1,99 @@ +.\" Copyright (c) 1998 Alex Nash +.\" 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. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_rwlock_init.3,v 1.5 2001/10/01 16:09:09 ru Exp $ +.\" +.Dd August 4, 1998 +.Dt PTHREAD_RWLOCK_INIT 3 +.Os +.Sh NAME +.Nm pthread_rwlock_init +.Nd initialize a read/write lock +.Sh SYNOPSIS +.In pthread.h +.Ft int +.Fn pthread_rwlock_init "pthread_rwlock_t *lock" "const pthread_rwlockattr_t *attr" +.Sh DESCRIPTION +The +.Fn pthread_rwlock_init +function is used to initialize a read/write lock, with attributes +specified by +.Fa attr . +If +.Fa attr +is NULL, the default read/write lock attributes are used. +.Pp +The results of calling +.Fn pthread_rwlock_init +with an already initialized lock are undefined. +.Sh RETURN VALUES +If successful, the +.Fn pthread_rwlock_init +function will return zero. Otherwise an error number will be returned +to indicate the error. +.Sh SEE ALSO +.Xr pthread_rwlockattr_init 3 , +.Xr pthread_rwlockattr_setpshared 3 , +.Xr pthread_rwlock_destroy 3 +.Sh STANDARDS +The +.Fn pthread_rwlock_init +function is expected to conform to +.St -susv2 . +.Sh ERRORS +The +.Fn pthread_rwlock_init +function will fail if: +.Bl -tag -width Er +.It Bq Er EAGAIN +The system lacked the necessary resources (other than memory) to +initialize the lock. +.It Bq Er ENOMEM +Insufficient memory exists to initialize the lock. +.It Bq Er EPERM +The caller does not have sufficient privilege to perform the +operation. +.El +.Pp +The +.Fn pthread_rwlock_init +function may fail if: +.Bl -tag -width Er +.It Bq Er EBUSY +The system has detected an attempt to re-initialize the object +referenced by +.Fa lock , +a previously initialized but not yet destroyed read/write lock. +.It Bq Er EINVAL +The value specified by +.Fa attr +is invalid. +.El +.Sh HISTORY +The +.Fn pthread_rwlock_init +function first appeared in +.Fx 3.0 . +.Sh BUGS +The PTHREAD_PROCESS_SHARED attribute is not supported. diff --git a/pthreads/pthread_rwlock_rdlock.3 b/pthreads/pthread_rwlock_rdlock.3 new file mode 100644 index 0000000..b703359 --- /dev/null +++ b/pthreads/pthread_rwlock_rdlock.3 @@ -0,0 +1,122 @@ +.\" Copyright (c) 1998 Alex Nash +.\" 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. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_rwlock_rdlock.3,v 1.4 2001/10/01 16:09:09 ru Exp $ +.\" +.Dd August 4, 1998 +.Dt PTHREAD_RWLOCK_RDLOCK 3 +.Os +.Sh NAME +.Nm pthread_rwlock_rdlock , +.Nm pthread_rwlock_tryrdlock +.Nd acquire a read/write lock for reading +.Sh SYNOPSIS +.In pthread.h +.Ft int +.Fn pthread_rwlock_rdlock "pthread_rwlock_t *lock" +.Ft int +.Fn pthread_rwlock_tryrdlock "pthread_rwlock_t *lock" +.Sh DESCRIPTION +The +.Fn pthread_rwlock_rdlock +function acquires a read lock on +.Fa lock +provided that +.Fa lock +is not presently held for writing and no writer threads are +presently blocked on the lock. If the read lock cannot be +immediately acquired, the calling thread blocks until it can +acquire the lock. +.Pp +The +.Fn pthread_rwlock_tryrdlock +function performs the same action, but does not block if the lock +cannot be immediately obtained (i.e. the lock is held for writing +or there are waiting writers). +.Pp +A thread may hold multiple concurrent read locks. If so, +.Fn pthread_rwlock_unlock +must be called once for each lock obtained. +.Pp +The results of acquiring a read lock while the calling thread holds +a write lock are undefined. +.Sh IMPLEMENTATION NOTES +To prevent writer starvation, writers are favored over readers. +.Sh RETURN VALUES +If successful, the +.Fn pthread_rwlock_rdlock +and +.Fn pthread_rwlock_tryrdlock +functions will return zero. Otherwise an error number will be returned +to indicate the error. +.Sh SEE ALSO +.Xr pthread_rwlock_init 3 , +.Xr pthread_rwlock_trywrlock 3 , +.Xr pthread_rwlock_unlock 3 , +.Xr pthread_rwlock_wrlock 3 +.Sh STANDARDS +The +.Fn pthread_rwlock_rdlock +and +.Fn pthread_rwlock_tryrdlock +functions are expected to conform to +.St -susv2 . +.Sh ERRORS +The +.Fn pthread_rwlock_tryrdlock +function will fail if: +.Bl -tag -width Er +.It Bq Er EBUSY +The lock could not be acquired because a writer holds the lock or +was blocked on it. +.El +.Pp +The +.Fn pthread_rwlock_rdlock +and +.Fn pthread_rwlock_tryrdlock +functions may fail if: +.Bl -tag -width Er +.It Bq Er EAGAIN +The lock could not be acquired because the maximum number of read locks +against +.Fa lock +has been exceeded. +.It Bq Er EDEADLK +The current thread already owns +.Fa lock +for writing. +.It Bq Er EINVAL +The value specified by +.Fa lock +is invalid. +.It Bq Er ENOMEM +Insufficient memory exists to initialize the lock (applies to +statically initialized locks only). +.El +.Sh HISTORY +The +.Fn pthread_rwlock_rdlock +function first appeared in +.Fx 3.0 . diff --git a/pthreads/pthread_rwlock_unlock.3 b/pthreads/pthread_rwlock_unlock.3 new file mode 100644 index 0000000..4384cec --- /dev/null +++ b/pthreads/pthread_rwlock_unlock.3 @@ -0,0 +1,79 @@ +.\" Copyright (c) 1998 Alex Nash +.\" 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. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_rwlock_unlock.3,v 1.4 2001/10/01 16:09:09 ru Exp $ +.\" +.Dd August 4, 1998 +.Dt PTHREAD_RWLOCK_UNLOCK 3 +.Os +.Sh NAME +.Nm pthread_rwlock_unlock +.Nd release a read/write lock +.Sh SYNOPSIS +.In pthread.h +.Ft int +.Fn pthread_rwlock_unlock "pthread_rwlock_t *lock" +.Sh DESCRIPTION +The +.Fn pthread_rwlock_unlock +function is used to release the read/write lock previously obtained by +.Fn pthread_rwlock_rdlock , +.Fn pthread_rwlock_wrlock , +.Fn pthread_rwlock_tryrdlock , +or +.Fn pthread_rwlock_trywrlock . +.Sh RETURN VALUES +If successful, the +.Fn pthread_rwlock_unlock +function will return zero. Otherwise an error number will be returned +to indicate the error. +.Pp +The results are undefined if +.Fa lock +is not held by the calling thread. +.Sh SEE ALSO +.Xr pthread_rwlock_rdlock 3 , +.Xr pthread_rwlock_wrlock 3 +.Sh STANDARDS +The +.Fn pthread_rwlock_unlock +function is expected to conform to +.St -susv2 . +.Sh ERRORS +The +.Fn pthread_rwlock_unlock +function may fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The value specified by +.Fa lock +is invalid. +.It Bq Er EPERM +The current thread does not own the read/write lock. +.El +.Sh HISTORY +The +.Fn pthread_rwlock_unlock +function first appeared in +.Fx 3.0 . diff --git a/pthreads/pthread_rwlock_wrlock.3 b/pthreads/pthread_rwlock_wrlock.3 new file mode 100644 index 0000000..f30df5a --- /dev/null +++ b/pthreads/pthread_rwlock_wrlock.3 @@ -0,0 +1,102 @@ +.\" Copyright (c) 1998 Alex Nash +.\" 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. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_rwlock_wrlock.3,v 1.4 2001/10/01 16:09:09 ru Exp $ +.\" +.Dd August 4, 1998 +.Dt PTHREAD_RWLOCK_WRLOCK 3 +.Os +.Sh NAME +.Nm pthread_rwlock_wrlock , +.Nm pthread_rwlock_trywrlock +.Nd acquire a read/write lock for writing +.Sh SYNOPSIS +.In pthread.h +.Ft int +.Fn pthread_rwlock_wrlock "pthread_rwlock_t *lock" +.Ft int +.Fn pthread_rwlock_trywrlock "pthread_rwlock_t *lock" +.Sh DESCRIPTION +The +.Fn pthread_rwlock_wrlock +function blocks until a write lock can be acquired against +.Fa lock . +The +.Fn pthread_rwlock_trywrlock +function performs the same action, but does not block if the lock +cannot be immediately obtained. +.Pp +The results are undefined if the calling thread already holds the +lock at the time the call is made. +.Sh IMPLEMENTATION NOTES +To prevent writer starvation, writers are favored over readers. +.Sh RETURN VALUES +If successful, the +.Fn pthread_rwlock_wrlock +and +.Fn pthread_rwlock_trywrlock +functions will return zero. Otherwise an error number will be returned +to indicate the error. +.Sh SEE ALSO +.Xr pthread_rwlock_trywrlock 3 , +.Xr pthread_rwlock_unlock 3 , +.Xr pthread_rwlock_wrlock 3 +.Sh STANDARDS +The +.Fn pthread_rwlock_wrlock +and +.Fn pthread_rwlock_trywrlock +functions are expected to conform to +.St -susv2 . +.Sh ERRORS +The +.Fn pthread_rwlock_trywrlock +function will fail if: +.Bl -tag -width Er +.It Bq Er EBUSY +The calling thread is not able to acquire the lock without blocking. +.El +.Pp +The +.Fn pthread_rwlock_wrlock +and +.Fn pthread_rwlock_trywrlock +functions may fail if: +.Bl -tag -width Er +.It Bq Er EDEADLK +The calling thread already owns the read/write lock (for reading +or writing). +.It Bq Er EINVAL +The value specified by +.Fa lock +is invalid. +.It Bq Er ENOMEM +Insufficient memory exists to initialize the lock (applies to +statically initialized locks only). +.El +.Sh HISTORY +The +.Fn pthread_rwlock_wrlock +function first appeared in +.Fx 3.0 . diff --git a/pthreads/pthread_rwlockattr_destroy.3 b/pthreads/pthread_rwlockattr_destroy.3 new file mode 100644 index 0000000..5a7a143 --- /dev/null +++ b/pthreads/pthread_rwlockattr_destroy.3 @@ -0,0 +1,68 @@ +.\" Copyright (c) 1998 Alex Nash +.\" 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. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_rwlockattr_destroy.3,v 1.6 2001/10/01 16:09:09 ru Exp $ +.\" +.Dd August 4, 1998 +.Dt PTHREAD_RWLOCKATTR_DESTROY 3 +.Os +.Sh NAME +.Nm pthread_rwlockattr_destroy +.Nd destroy a read/write lock +.Sh SYNOPSIS +.In pthread.h +.Ft int +.Fn pthread_rwlockattr_destroy "pthread_rwlockattr_t *attr" +.Sh DESCRIPTION +The +.Fn pthread_rwlockattr_destroy +function is used to destroy a read/write lock attribute object +previously created with +.Fn pthread_rwlockattr_init . +.Sh RETURN VALUES +If successful, the +.Fn pthread_rwlockattr_destroy +function will return zero. Otherwise an error number will be returned +to indicate the error. +.Sh SEE ALSO +.Xr pthread_rwlockattr_init 3 +.Sh STANDARDS +The +.Fn pthread_rwlockattr_destroy +function is expected to conform to +.St -susv2 . +.Sh ERRORS +.Fn pthread_rwlockattr_destroy +may fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The value specified by +.Fa attr +is invalid. +.El +.Sh HISTORY +The +.Fn pthread_rwlockattr_destroy +function first appeared in +.Fx 3.0 . diff --git a/pthreads/pthread_rwlockattr_getpshared.3 b/pthreads/pthread_rwlockattr_getpshared.3 new file mode 100644 index 0000000..a07c37b --- /dev/null +++ b/pthreads/pthread_rwlockattr_getpshared.3 @@ -0,0 +1,80 @@ +.\" Copyright (c) 1998 Alex Nash +.\" 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. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_rwlockattr_getpshared.3,v 1.8 2001/10/01 16:09:09 ru Exp $ +.\" +.Dd March 22, 1999 +.Dt PTHREAD_RWLOCKATTR_GETPSHARED 3 +.Os +.Sh NAME +.Nm pthread_rwlockattr_getpshared +.Nd get the process shared attribute +.Sh SYNOPSIS +.In pthread.h +.Ft int +.Fn pthread_rwlockattr_getpshared "const pthread_rwlockattr_t *attr" "int *pshared" +.Sh DESCRIPTION +The +.Fn pthread_rwlockattr_getpshared +function is used to get the process shared setting of a read/write +lock attribute object. The setting is returned via +.Fa pshared , +and may be one of two values: +.Bl -tag -width PTHREAD_PROCESS_PRIVATE +.It Dv PTHREAD_PROCESS_SHARED +Any thread of any process that has access to the memory where the +read/write lock resides can manipulate the lock. +.It Dv PTHREAD_PROCESS_PRIVATE +Only threads created within the same process as the thread that +initialized the read/write lock can manipulate the lock. This is +the default value. +.El +.Sh RETURN VALUES +If successful, the +.Fn pthread_rwlockattr_getpshared +function will return zero. Otherwise an error number will be returned +to indicate the error. +.Sh SEE ALSO +.Xr pthread_rwlockattr_init 3 , +.Xr pthread_rwlockattr_setpshared 3 , +.Xr pthread_rwlock_init 3 +.Sh STANDARDS +The +.Fn pthread_rwlockattr_getpshared +function is expected to conform to +.St -susv2 . +.Sh ERRORS +.Fn pthread_rwlockattr_getpshared +may fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The value specified by +.Fa attr +is invalid. +.El +.Sh HISTORY +The +.Fn pthread_rwlockattr_getpshared +function first appeared in +.Fx 3.0 . diff --git a/pthreads/pthread_rwlockattr_init.3 b/pthreads/pthread_rwlockattr_init.3 new file mode 100644 index 0000000..6d125e6 --- /dev/null +++ b/pthreads/pthread_rwlockattr_init.3 @@ -0,0 +1,67 @@ +.\" Copyright (c) 1998 Alex Nash +.\" 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. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_rwlockattr_init.3,v 1.6 2001/10/01 16:09:09 ru Exp $ +.\" +.Dd August 4, 1998 +.Dt PTHREAD_RWLOCKATTR_INIT 3 +.Os +.Sh NAME +.Nm pthread_rwlockattr_init +.Nd initialize a read/write lock +.Sh SYNOPSIS +.In pthread.h +.Ft int +.Fn pthread_rwlockattr_init "pthread_rwlockattr_t *attr" +.Sh DESCRIPTION +The +.Fn pthread_rwlockattr_init +function is used to initialize a read/write lock attributes object. +.Sh RETURN VALUES +If successful, the +.Fn pthread_rwlockattr_init +function will return zero. Otherwise an error number will be returned +to indicate the error. +.Sh SEE ALSO +.Xr pthread_rwlockattr_destroy 3 , +.Xr pthread_rwlockattr_getpshared 3 , +.Xr pthread_rwlockattr_setpshared 3 , +.Xr pthread_rwlock_init 3 +.Sh STANDARDS +The +.Fn pthread_rwlockattr_init +function is expected to conform to +.St -susv2 . +.Sh ERRORS +.Fn pthread_rwlockattr_init +will fail if: +.Bl -tag -width Er +.It Bq Er ENOMEM +Insufficient memory exists to initialize the attribute object. +.El +.Sh HISTORY +The +.Fn pthread_rwlockattr_init +function first appeared in +.Fx 3.0 . diff --git a/pthreads/pthread_rwlockattr_setpshared.3 b/pthreads/pthread_rwlockattr_setpshared.3 new file mode 100644 index 0000000..9824c63 --- /dev/null +++ b/pthreads/pthread_rwlockattr_setpshared.3 @@ -0,0 +1,88 @@ +.\" Copyright (c) 1998 Alex Nash +.\" 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. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_rwlockattr_setpshared.3,v 1.7 2001/10/01 16:09:09 ru Exp $ +.\" +.Dd August 4, 1998 +.Dt PTHREAD_RWLOCKATTR_SETPSHARED 3 +.Os +.Sh NAME +.Nm pthread_rwlockattr_setpshared +.Nd set the process shared attribute +.Sh SYNOPSIS +.In pthread.h +.Ft int +.Fn pthread_rwlockattr_setpshared "pthread_rwlockattr_t *attr" "int pshared" +.Sh DESCRIPTION +The +.Fn pthread_rwlockattr_setpshared +function sets the process shared attribute of +.Fa attr +to the value referenced by +.Fa pshared . +.Fa pshared +may be one of two values: +.Bl -tag -width PTHREAD_PROCESS_PRIVATE +.It Dv PTHREAD_PROCESS_SHARED +Any thread of any process that has access to the memory where the +read/write lock resides can manipulate the lock. +.It Dv PTHREAD_PROCESS_PRIVATE +Only threads created within the same process as the thread that +initialized the read/write lock can manipulate the lock. This is +the default value. +.El +.Sh RETURN VALUES +If successful, the +.Fn pthread_rwlockattr_setpshared +function will return zero. Otherwise an error number will be returned +to indicate the error. +.Sh SEE ALSO +.Xr pthread_rwlockattr_init 3 , +.Xr pthread_rwlockattr_setpshared 3 , +.Xr pthread_rwlock_init 3 +.Sh STANDARDS +The +.Fn pthread_rwlockattr_setpshared +function is expected to conform to +.St -susv2 . +.Sh ERRORS +.Fn pthread_rwlockattr_setpshared +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The value specified by +.Fa attr +or +.Fa pshared +is invalid. +.El +.Sh HISTORY +The +.Fn pthread_rwlockattr_setpshared +function first appeared in +.Fx 3.0 . +.Sh BUGS +The +.Dv PTHREAD_PROCESS_SHARED +attribute is not supported. diff --git a/pthreads/pthread_self.3 b/pthreads/pthread_self.3 new file mode 100644 index 0000000..d7c2bcd --- /dev/null +++ b/pthreads/pthread_self.3 @@ -0,0 +1,59 @@ +.\" Copyright (c) 1996 John Birrell . +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by John Birrell. +.\" 4. Neither the name of the author nor the names of any co-contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_self.3,v 1.4.2.4 2001/08/17 15:42:52 ru Exp $ +.\" +.Dd April 4, 1996 +.Dt PTHREAD_SELF 3 +.Os +.Sh NAME +.Nm pthread_self +.Nd get the calling thread's ID +.Sh SYNOPSIS +.Fd #include +.Ft pthread_t +.Fn pthread_self "void" +.Sh DESCRIPTION +The +.Fn pthread_self +function returns the thread ID of the calling thread. +.Sh RETURN VALUES +The +.Fn pthread_self +function returns the thread ID of the calling thread. +.Sh ERRORS +None. +.Sh SEE ALSO +.Xr pthread_create 3 , +.Xr pthread_equal 3 +.Sh STANDARDS +.Fn pthread_self +conforms to +.St -p1003.1-96 . diff --git a/pthreads/pthread_setcancelstate.3 b/pthreads/pthread_setcancelstate.3 new file mode 100644 index 0000000..c68970c --- /dev/null +++ b/pthreads/pthread_setcancelstate.3 @@ -0,0 +1,199 @@ +.\" $FreeBSD: src/lib/libc_r/man/pthread_testcancel.3,v 1.2.2.3 2001/08/17 15:42:52 ru Exp $ +.Dd January 17, 1999 +.Dt PTHREAD_TESTCANCEL 3 +.Os +.Sh NAME +.Nm pthread_setcancelstate , +.Nm pthread_setcanceltype , +.Nm pthread_testcancel +.Nd set cancelability state +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn pthread_setcancelstate "int state" "int *oldstate" +.Ft int +.Fn pthread_setcanceltype "int type" "int *oldtype" +.Ft void +.Fn pthread_testcancel "void" +.Sh DESCRIPTION +The +.Fn pthread_setcancelstate +function atomically both sets the calling thread's cancelability state +to the indicated +.Fa state +and returns the previous cancelability state at the location referenced by +.Fa oldstate . +Legal values for +.Fa state +are +.Dv PTHREAD_CANCEL_ENABLE +and +.Dv PTHREAD_CANCEL_DISABLE . +.Pp +The +.Fn pthread_setcanceltype +function atomically both sets the calling thread's cancelability type +to the indicated +.Fa type +and returns the previous cancelability type at the location referenced by +.Fa oldtype . +Legal values for +.Fa type +are +.Dv PTHREAD_CANCEL_DEFERRED +and +.Dv PTHREAD_CANCEL_ASYNCHRONOUS . +.Pp +The cancelability state and type of any newly created threads, including the +thread in which +.Fn main +was first invoked, are +.Dv PTHREAD_CANCEL_ENABLE +and +.Dv PTHREAD_CANCEL_DEFERRED +respectively. +.Pp +The +.Fn pthread_testcancel +function creates a cancellation point in the calling thread. +The +.Fn pthread_testcancel +function has no effect if cancelability is disabled. +.Pp +.Ss Cancelability States +The cancelability state of a thread determines the action taken upon +receipt of a cancellation request. +The thread may control cancellation in +a number of ways. +.Pp +Each thread maintains its own +.Dq cancelability state +which may be encoded in two bits: +.Bl -hang +.It Em Cancelability Enable +When cancelability is +.Dv PTHREAD_CANCEL_DISABLE , +cancellation requests against the target thread are held pending. +.It Em Cancelability Type +When cancelability is enabled and the cancelability type is +.Dv PTHREAD_CANCEL_ASYNCHRONOUS , +new or pending cancellation requests may be acted upon at any time. +When cancelability is enabled and the cancelability type is +.Dv PTHREAD_CANCEL_DEFERRED , +cancellation requests are held pending until a cancellation point (see +below) is reached. +If cancelability is disabled, the setting of the +cancelability type has no immediate effect as all cancellation requests +are held pending; however, once cancelability is enabled again the new +type will be in effect. +.El +.Ss Cancellation Points +Cancellation points will occur when a thread is executing the following +functions: +.Fn close , +.Fn creat , +.Fn fcntl , +.Fn fsync , +.Fn msync , +.Fn nanosleep , +.Fn open , +.Fn pause , +.Fn pthread_cond_timedwait , +.Fn pthread_cond_wait , +.Fn pthread_join , +.Fn pthread_testcancel , +.Fn read , +.Fn sigwaitinfo , +.Fn sigsuspend , +.Fn sigwait , +.Fn sleep , +.Fn system , +.Fn tcdrain , +.Fn wait , +.Fn waitpid , +.Fn write . +.Sh RETURN VALUES +If successful, the +.Fn pthread_setcancelstate +and +.Fn pthread_setcanceltype +functions will return zero. +Otherwise, an error number shall be returned to +indicate the error. +.Pp +The +.Fn pthread_setcancelstate +and +.Fn pthread_setcanceltype +functions are used to control the points at which a thread may be +asynchronously canceled. +For cancellation control to be usable in modular +fashion, some rules must be followed. +.Pp +For purposes of this discussion, consider an object to be a generalization +of a procedure. +It is a set of procedures and global variables written as +a unit and called by clients not known by the object. +Objects may depend +on other objects. +.Pp +First, cancelability should only be disabled on entry to an object, never +explicitly enabled. +On exit from an object, the cancelability state should +always be restored to its value on entry to the object. +.Pp +This follows from a modularity argument: if the client of an object (or the +client of an object that uses that object) has disabled cancelability, it is +because the client doesn't want to have to worry about how to clean up if the +thread is canceled while executing some sequence of actions. +If an object +is called in such a state and it enables cancelability and a cancellation +request is pending for that thread, then the thread will be canceled, +contrary to the wish of the client that disabled. +.Pp +Second, the cancelability type may be explicitly set to either +.Em deferred +or +.Em asynchronous +upon entry to an object. +But as with the cancelability state, on exit from +an object that cancelability type should always be restored to its value on +entry to the object. +.Pp +Finally, only functions that are cancel-safe may be called from a thread that +is asynchronously cancelable. +.Sh ERRORS +The function +.Fn pthread_setcancelstate +may fail with: +.Bl -tag -width Er +.It Bq Er EINVAL +The specified state is not +.Dv PTHREAD_CANCEL_ENABLE +or +.Dv PTHREAD_CANCEL_DISABLE . +.El +.Pp +The function +.Fn pthread_setcanceltype +may fail with: +.Bl -tag -width Er +.It Bq Er EINVAL +The specified state is not +.Dv PTHREAD_CANCEL_DEFERRED +or +.Dv PTHREAD_CANCEL_ASYNCHRONOUS . +.El +.Sh SEE ALSO +.Xr pthread_cancel 3 +.Sh STANDARDS +.Fn pthread_testcancel +conforms to +.St -p1003.1-96 . +.Sh AUTHORS +This man page was written by +.An David Leonard Aq d@openbsd.org +for the +.Ox +implementation of +.Xr pthread_cancel 3 . diff --git a/pthreads/pthread_setspecific.3 b/pthreads/pthread_setspecific.3 new file mode 100644 index 0000000..f820eb8 --- /dev/null +++ b/pthreads/pthread_setspecific.3 @@ -0,0 +1,93 @@ +.\" Copyright (c) 1996 John Birrell . +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by John Birrell. +.\" 4. Neither the name of the author nor the names of any co-contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_setspecific.3,v 1.6.2.4 2001/08/17 15:42:52 ru Exp $ +.\" +.Dd April 4, 1996 +.Dt PTHREAD_SETSPECIFIC 3 +.Os +.Sh NAME +.Nm pthread_setspecific +.Nd set a thread-specific data value +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn pthread_setspecific "pthread_key_t key" "const void *value" +.Sh DESCRIPTION +The +.Fn pthread_setspecific +function associates a thread-specific value with a +.Fa key +obtained via a previous call to +.Fn pthread_key_create . +Different threads man bind different values to the same key. +These values are +typically pointers to blocks of dynamically allocated memory that have been +reserved for use by the calling thread. +.Pp +The effect of calling +.Fn pthread_setspecific +with a key value not obtained from +.Fn pthread_key_create +or after +.Fa key +has been deleted with +.Fn pthread_key_delete +is undefined. +.Pp +.Fn pthread_setspecific +may be called from a thread-specific data destructor function, however this +may result in lost storage or infinite loops. +.Sh RETURN VALUES +If successful, the +.Fn pthread_setspecific +function will return zero. +Otherwise an error number will be returned to +indicate the error. +.Sh ERRORS +.Fn pthread_setspecific +will fail if: +.Bl -tag -width Er +.It Bq Er ENOMEM +Insufficient memory exists to associate the value with the +.Fa key . +.It Bq Er EINVAL +The +.Fa key +value is invalid. +.El +.Sh SEE ALSO +.Xr pthread_getspecific 3 , +.Xr pthread_key_create 3 , +.Xr pthread_key_delete 3 +.Sh STANDARDS +.Fn pthread_setspecific +conforms to +.St -p1003.1-96 . diff --git a/pthreads.subproj/pthread_tsd.c b/pthreads/pthread_tsd.c similarity index 100% rename from pthreads.subproj/pthread_tsd.c rename to pthreads/pthread_tsd.c diff --git a/pthreads.subproj/sched.h b/pthreads/sched.h similarity index 100% rename from pthreads.subproj/sched.h rename to pthreads/sched.h diff --git a/pthreads.subproj/stack.s b/pthreads/stack.s similarity index 100% rename from pthreads.subproj/stack.s rename to pthreads/stack.s diff --git a/pthreads.subproj/thread_setup.c b/pthreads/thread_setup.c similarity index 55% rename from pthreads.subproj/thread_setup.c rename to pthreads/thread_setup.c index 13502dc..28c08f5 100644 --- a/pthreads.subproj/thread_setup.c +++ b/pthreads/thread_setup.c @@ -39,55 +39,85 @@ void _pthread_setup(pthread_t thread, void (*routine)(pthread_t), - vm_address_t vsp) + void *vsp, int suspended, + int needresume) { kern_return_t r; unsigned int count; #if defined(__ppc__) - struct ppc_thread_state state; + struct ppc_thread_state state = {0}; struct ppc_thread_state *ts = &state; /* * Set up PowerPC registers. */ count = PPC_THREAD_STATE_COUNT; - PTHREAD_MACH_CALL(thread_get_state(thread->kernel_thread, - PPC_THREAD_STATE, - (thread_state_t) &state, - &count), - r); - + if (suspended) { + PTHREAD_MACH_CALL(thread_get_state(thread->kernel_thread, + PPC_THREAD_STATE, + (thread_state_t) &state, + &count), + r); + } ts->srr0 = (int) routine; - ts->r1 = vsp - C_ARGSAVE_LEN - C_RED_ZONE; + ts->r1 = (uintptr_t)vsp - C_ARGSAVE_LEN - C_RED_ZONE; ts->r3 = (int)thread; - PTHREAD_MACH_CALL(thread_set_state(thread->kernel_thread, - PPC_THREAD_STATE, - (thread_state_t) &state, - PPC_THREAD_STATE_COUNT), - r); + /* Incase of needresume, suspend is always set */ + if (suspended) { + PTHREAD_MACH_CALL(thread_set_state(thread->kernel_thread, + PPC_THREAD_STATE, + (thread_state_t) &state, + PPC_THREAD_STATE_COUNT), + r); + if (needresume) + PTHREAD_MACH_CALL(thread_resume(thread->kernel_thread), + r); + } else { + PTHREAD_MACH_CALL(thread_create_running(mach_task_self(), + PPC_THREAD_STATE, + (thread_state_t) ts, + PPC_THREAD_STATE_COUNT, + &thread->kernel_thread), + r); + } #elif defined(__i386__) - i386_thread_state_t state; + i386_thread_state_t state = {0}; i386_thread_state_t *ts = &state; - int *sp = (int *) vsp; + int *sp = vsp; /* * Set up i386 registers & function call. */ count = i386_THREAD_STATE_COUNT; - PTHREAD_MACH_CALL(thread_get_state(thread->kernel_thread, - i386_THREAD_STATE, - (thread_state_t) &state, - &count), - r); + if (suspended) { + PTHREAD_MACH_CALL(thread_get_state(thread->kernel_thread, + i386_THREAD_STATE, + (thread_state_t) &state, + &count), + r); + } ts->eip = (int) routine; *--sp = (int) thread; /* argument to function */ *--sp = 0; /* fake return address */ ts->esp = (int) sp; /* set stack pointer */ - PTHREAD_MACH_CALL(thread_set_state(thread->kernel_thread, - i386_THREAD_STATE, - (thread_state_t) &state, - i386_THREAD_STATE_COUNT), - r); + /* Incase of needresume, suspend is always set */ + if (suspended) { + PTHREAD_MACH_CALL(thread_set_state(thread->kernel_thread, + i386_THREAD_STATE, + (thread_state_t) &state, + i386_THREAD_STATE_COUNT), + r); + if (needresume) + PTHREAD_MACH_CALL(thread_resume(thread->kernel_thread), + r); + } else { + PTHREAD_MACH_CALL(thread_create_running(mach_task_self(), + i386_THREAD_STATE, + (thread_state_t) ts, + i386_THREAD_STATE_COUNT, + &thread->kernel_thread), + r); + } #else #error _pthread_setup not defined for this architecture diff --git a/quad/Makefile.inc b/quad/Makefile.inc new file mode 100644 index 0000000..679f6cc --- /dev/null +++ b/quad/Makefile.inc @@ -0,0 +1,19 @@ +# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 +# $FreeBSD: src/lib/libc/quad/Makefile.inc,v 1.8 1999/08/28 00:00:27 peter Exp $ + +# Quad support, if needed +.PATH: ${.CURDIR}/../libc/${MACHINE_ARCH}/quad ${.CURDIR}/../libc/quad + +.if ${MACHINE_ARCH} == "i386" + +SRCS+= cmpdi2.c divdi3.c moddi3.c qdivrem.c ucmpdi2.c udivdi3.c umoddi3.c + +.else + +SRCS+= adddi3.c anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c fixdfdi.c \ + fixsfdi.c fixunsdfdi.c fixunssfdi.c floatdidf.c floatdisf.c \ + floatunsdidf.c iordi3.c lshldi3.c lshrdi3.c moddi3.c muldi3.c \ + negdi2.c notdi2.c qdivrem.c subdi3.c ucmpdi2.c udivdi3.c umoddi3.c \ + xordi3.c + +.endif diff --git a/regex.subproj/Makefile b/regex.subproj/Makefile deleted file mode 100644 index df9cdf6..0000000 --- a/regex.subproj/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -# -# Generated by the NeXT Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = regex - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -HFILES = cclass.h cname.h regex2.h utils.h - -CFILES = regcomp.c regerror.c regexec.c regfree.c - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble engine.c - - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - - - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/regex.subproj/Makefile.postamble b/regex.subproj/Makefile.postamble deleted file mode 100644 index 411cde6..0000000 --- a/regex.subproj/Makefile.postamble +++ /dev/null @@ -1,100 +0,0 @@ -############################################################################### -# Makefile.postamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile, which is imported after all other makefiles, to -# override attributes for a project's Makefile environment. This allows you -# to take advantage of the environment set up by the other Makefiles. -# You can also define custom rules at the end of this file. -# -############################################################################### -# -# These variables are exported by the standard makefiles and can be -# used in any customizations you make. They are *outputs* of -# the Makefiles and should be used, not set. -# -# PRODUCTS: products to install. All of these products will be placed in -# the directory $(DSTROOT)$(INSTALLDIR) -# GLOBAL_RESOURCE_DIR: The directory to which resources are copied. -# LOCAL_RESOURCE_DIR: The directory to which localized resources are copied. -# OFILE_DIR: Directory into which .o object files are generated. -# DERIVED_SRC_DIR: Directory used for all other derived files -# -# ALL_CFLAGS: flags to pass when compiling .c files -# ALL_MFLAGS: flags to pass when compiling .m files -# ALL_CCFLAGS: flags to pass when compiling .cc, .cxx, and .C files -# ALL_MMFLAGS: flags to pass when compiling .mm, .mxx, and .M files -# ALL_PRECOMPFLAGS: flags to pass when precompiling .h files -# ALL_LDFLAGS: flags to pass when linking object files -# ALL_LIBTOOL_FLAGS: flags to pass when libtooling object files -# ALL_PSWFLAGS: flags to pass when processing .psw and .pswm (pswrap) files -# ALL_RPCFLAGS: flags to pass when processing .rpc (rpcgen) files -# ALL_YFLAGS: flags to pass when processing .y (yacc) files -# ALL_LFLAGS: flags to pass when processing .l (lex) files -# -# NAME: name of application, bundle, subproject, palette, etc. -# LANGUAGES: langages in which the project is written (default "English") -# English_RESOURCES: localized resources (e.g. nib's, images) of project -# GLOBAL_RESOURCES: non-localized resources of project -# -# SRCROOT: base directory in which to place the new source files -# SRCPATH: relative path from SRCROOT to present subdirectory -# -# INSTALLDIR: Directory the product will be installed into by 'install' target -# PUBLIC_HDR_INSTALLDIR: where to install public headers. Don't forget -# to prefix this with DSTROOT when you use it. -# PRIVATE_HDR_INSTALLDIR: where to install private headers. Don't forget -# to prefix this with DSTROOT when you use it. -# -# EXECUTABLE_EXT: Executable extension for the platform (i.e. .exe on Windows) -# -############################################################################### - -# Some compiler flags can be overridden here for certain build situations. -# -# WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost) -# DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults -# to -g) -# DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG) -# OPTIMIZE_BUILD_CFLAGS: flags passed during optimized builds (defaults -# to -O) -# PROFILE_BUILD_CFLAGS: flags passed during profile builds (defaults -# to -pg -DPROFILE) -# LOCAL_DIR_INCLUDE_DIRECTIVE: flag used to add current directory to -# the include path (defaults to -I.) -# DEBUG_BUILD_LDFLAGS, OPTIMIZE_BUILD_LDFLAGS, PROFILE_BUILD_LDFLAGS: flags -# passed to ld/libtool (defaults to nothing) - - -# Library and Framework projects only: -# INSTALL_NAME_DIRECTIVE: This directive ensures that executables linked -# against the framework will run against the correct version even if -# the current version of the framework changes. You may override this -# to "" as an alternative to using the DYLD_LIBRARY_PATH during your -# development cycle, but be sure to restore it before installing. - - -# Ownership and permissions of files installed by 'install' target - -#INSTALL_AS_USER = root - # User/group ownership -#INSTALL_AS_GROUP = wheel - # (probably want to set both of these) -#INSTALL_PERMISSIONS = - # If set, 'install' chmod's executable to this - - -# Options to strip. Note: -S strips debugging symbols (executables can be stripped -# down further with -x or, if they load no bundles, with no options at all). - -#STRIPFLAGS = -S - - -######################################################################### -# Put rules to extend the behavior of the standard Makefiles here. Include them in -# the dependency tree via cvariables like AFTER_INSTALL in the Makefile.preamble. -# -# You should avoid redefining things like "install" or "app", as they are -# owned by the top-level Makefile API and no context has been set up for where -# derived files should go. -# diff --git a/regex.subproj/Makefile.preamble b/regex.subproj/Makefile.preamble deleted file mode 100644 index c1624b4..0000000 --- a/regex.subproj/Makefile.preamble +++ /dev/null @@ -1,137 +0,0 @@ -############################################################################### -# Makefile.preamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile for configuring the standard application makefiles -# associated with ProjectBuilder. It is included before the main makefile. -# In Makefile.preamble you set attributes for a project, so they are available -# to the project's makefiles. In contrast, you typically write additional rules or -# override built-in behavior in the Makefile.postamble. -# -# Each directory in a project tree (main project plus subprojects) should -# have its own Makefile.preamble and Makefile.postamble. -############################################################################### -# -# Before the main makefile is included for this project, you may set: -# -# MAKEFILEDIR: Directory in which to find $(MAKEFILE) -# MAKEFILE: Top level mechanism Makefile (e.g., app.make, bundle.make) - -# Compiler/linker flags added to the defaults: The OTHER_* variables will be -# inherited by all nested sub-projects, but the LOCAL_ versions of the same -# variables will not. Put your -I, -D, -U, and -L flags in ProjectBuilder's -# Build Attributes inspector if at all possible. To override the default flags -# that get passed to ${CC} (e.g. change -O to -O2), see Makefile.postamble. The -# variables below are *inputs* to the build process and distinct from the override -# settings done (less often) in the Makefile.postamble. -# -# OTHER_CFLAGS, LOCAL_CFLAGS: additional flags to pass to the compiler -# Note that $(OTHER_CFLAGS) and $(LOCAL_CFLAGS) are used for .h, ...c, .m, -# .cc, .cxx, .C, and .M files. There is no need to respecify the -# flags in OTHER_MFLAGS, etc. -# OTHER_MFLAGS, LOCAL_MFLAGS: additional flags for .m files -# OTHER_CCFLAGS, LOCAL_CCFLAGS: additional flags for .cc, .cxx, and ...C files -# OTHER_MMFLAGS, LOCAL_MMFLAGS: additional flags for .mm and .M files -# OTHER_PRECOMPFLAGS, LOCAL_PRECOMPFLAGS: additional flags used when -# precompiling header files -# OTHER_LDFLAGS, LOCAL_LDFLAGS: additional flags passed to ld and libtool -# OTHER_PSWFLAGS, LOCAL_PSWFLAGS: additional flags passed to pswrap -# OTHER_RPCFLAGS, LOCAL_RPCFLAGS: additional flags passed to rpcgen -# OTHER_YFLAGS, LOCAL_YFLAGS: additional flags passed to yacc -# OTHER_LFLAGS, LOCAL_LFLAGS: additional flags passed to lex - -# These variables provide hooks enabling you to add behavior at almost every -# stage of the make: -# -# BEFORE_PREBUILD: targets to build before installing headers for a subproject -# AFTER_PREBUILD: targets to build after installing headers for a subproject -# BEFORE_BUILD_RECURSION: targets to make before building subprojects -# BEFORE_BUILD: targets to make before a build, but after subprojects -# AFTER_BUILD: targets to make after a build -# -# BEFORE_INSTALL: targets to build before installing the product -# AFTER_INSTALL: targets to build after installing the product -# BEFORE_POSTINSTALL: targets to build before postinstalling every subproject -# AFTER_POSTINSTALL: targts to build after postinstalling every subproject -# -# BEFORE_INSTALLHDRS: targets to build before installing headers for a -# subproject -# AFTER_INSTALLHDRS: targets to build after installing headers for a subproject -# BEFORE_INSTALLSRC: targets to build before installing source for a subproject -# AFTER_INSTALLSRC: targets to build after installing source for a subproject -# -# BEFORE_DEPEND: targets to build before building dependencies for a -# subproject -# AFTER_DEPEND: targets to build after building dependencies for a -# subproject -# -# AUTOMATIC_DEPENDENCY_INFO: if YES, then the dependency file is -# updated every time the project is built. If NO, the dependency -# file is only built when the depend target is invoked. - -# Framework-related variables: -# FRAMEWORK_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the framework's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables - -# Library-related variables: -# PUBLIC_HEADER_DIR: Determines where public exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. For library projects you should -# set this to something like /Developer/Headers/$(NAME). Do not set -# this variable for framework projects unless you do not want the -# header files included in the framework. -# PRIVATE_HEADER_DIR: Determines where private exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. -# LIBRARY_STYLE: This may be either STATIC or DYNAMIC, and determines -# whether the libraries produced are statically linked when they -# are used or if they are dynamically loadable. This defaults to -# DYNAMIC. -# LIBRARY_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the library's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables -# -# INSTALL_AS_USER: owner of the intalled products (default root) -# INSTALL_AS_GROUP: group of the installed products (default wheel) -# INSTALL_PERMISSIONS: permissions of the installed product (default o+rX) -# -# OTHER_RECURSIVE_VARIABLES: The names of variables which you want to be -# passed on the command line to recursive invocations of make. Note that -# the values in OTHER_*FLAGS are inherited by subprojects automatically -- -# you do not have to (and shouldn't) add OTHER_*FLAGS to -# OTHER_RECURSIVE_VARIABLES. - -# Additional headers to export beyond those in the PB.project: -# OTHER_PUBLIC_HEADERS -# OTHER_PROJECT_HEADERS -# OTHER_PRIVATE_HEADERS - -# Additional files for the project's product: <> -# OTHER_RESOURCES: (non-localized) resources for this project -# OTHER_OFILES: relocatables to be linked into this project -# OTHER_LIBS: more libraries to link against -# OTHER_PRODUCT_DEPENDS: other dependencies of this project -# OTHER_SOURCEFILES: other source files maintained by .pre/postamble -# OTHER_GARBAGE: additional files to be removed by `make clean' - -# Set this to YES if you don't want a final libtool call for a library/framework. -# BUILD_OFILES_LIST_ONLY - -# To include a version string, project source must exist in a directory named -# $(NAME).%d[.%d][.%d] and the following line must be uncommented. -# OTHER_GENERATED_OFILES = $(VERS_OFILE) - -# This definition will suppress stripping of debug symbols when an executable -# is installed. By default it is YES. -# STRIP_ON_INSTALL = NO - -# Uncomment to suppress generation of a KeyValueCoding index when installing -# frameworks (This index is used by WOB and IB to determine keys available -# for an object). Set to YES by default. -# PREINDEX_FRAMEWORK = NO - -# Change this definition to install projects somewhere other than the -# standard locations. NEXT_ROOT defaults to "C:/Apple" on Windows systems -# and "" on other systems. -DSTROOT = $(HOME) diff --git a/regex.subproj/PB.project b/regex.subproj/PB.project deleted file mode 100644 index 2ef71b3..0000000 --- a/regex.subproj/PB.project +++ /dev/null @@ -1,23 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - H_FILES = (cclass.h, cname.h, regex2.h, utils.h); - OTHER_LINKED = (regcomp.c, regerror.c, regexec.c, regfree.c); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble, engine.c); - SUBPROJECTS = (); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = regex; - PROJECTTYPE = Component; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/regex/Makefile.inc b/regex/Makefile.inc new file mode 100644 index 0000000..a71b092 --- /dev/null +++ b/regex/Makefile.inc @@ -0,0 +1,17 @@ +# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 +# $FreeBSD: src/lib/libc/regex/Makefile.inc,v 1.6 2001/03/27 17:26:51 ru Exp $ + +# regex sources +.PATH: ${.CURDIR}/regex + +CFLAGS+=-DPOSIX_MISTAKE + +SRCS+= regcomp.c regerror.c regexec.c regfree.c + +.if ${LIB} == "c" +MAN3+= regex.3 +MAN7+= re_format.7 + +MLINKS+=regex.3 regcomp.3 regex.3 regexec.3 regex.3 regerror.3 +MLINKS+=regexec.3 regfree.3 +.endif diff --git a/regex.subproj/cclass.h b/regex/cclass.h similarity index 100% rename from regex.subproj/cclass.h rename to regex/cclass.h diff --git a/regex.subproj/cname.h b/regex/cname.h similarity index 100% rename from regex.subproj/cname.h rename to regex/cname.h diff --git a/regex.subproj/engine.c b/regex/engine.c similarity index 100% rename from regex.subproj/engine.c rename to regex/engine.c diff --git a/regex/re_format.7 b/regex/re_format.7 new file mode 100644 index 0000000..32303f2 --- /dev/null +++ b/regex/re_format.7 @@ -0,0 +1,476 @@ +.\" Copyright (c) 1992, 1993, 1994 Henry Spencer. +.\" Copyright (c) 1992, 1993, 1994 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Henry Spencer. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)re_format.7 8.3 (Berkeley) 3/20/94 +.\" $FreeBSD: src/lib/libc/regex/re_format.7,v 1.9 2001/07/15 07:53:08 dd Exp $ +.\" +.Dd March 20, 1994 +.Dt RE_FORMAT 7 +.Os +.Sh NAME +.Nm re_format +.Nd POSIX 1003.2 regular expressions +.Sh DESCRIPTION +Regular expressions +.Pq Dq RE Ns s , +as defined in +.St -p1003.2 , +come in two forms: +modern REs (roughly those of +.Xr egrep 1 ; +1003.2 calls these +.Dq extended +REs) +and obsolete REs (roughly those of +.Xr ed 1 ; +1003.2 +.Dq basic +REs). +Obsolete REs mostly exist for backward compatibility in some old programs; +they will be discussed at the end. +.St -p1003.2 +leaves some aspects of RE syntax and semantics open; +`\(dd' marks decisions on these aspects that +may not be fully portable to other +.St -p1003.2 +implementations. +.Pp +A (modern) RE is one\(dd or more non-empty\(dd +.Em branches , +separated by +.Ql \&| . +It matches anything that matches one of the branches. +.Pp +A branch is one\(dd or more +.Em pieces , +concatenated. +It matches a match for the first, followed by a match for the second, etc. +.Pp +A piece is an +.Em atom +possibly followed +by a single\(dd +.Ql \&* , +.Ql \&+ , +.Ql \&? , +or +.Em bound . +An atom followed by +.Ql \&* +matches a sequence of 0 or more matches of the atom. +An atom followed by +.Ql \&+ +matches a sequence of 1 or more matches of the atom. +An atom followed by +.Ql ?\& +matches a sequence of 0 or 1 matches of the atom. +.Pp +A +.Em bound +is +.Ql \&{ +followed by an unsigned decimal integer, +possibly followed by +.Ql \&, +possibly followed by another unsigned decimal integer, +always followed by +.Ql \&} . +The integers must lie between 0 and +.Dv RE_DUP_MAX +(255\(dd) inclusive, +and if there are two of them, the first may not exceed the second. +An atom followed by a bound containing one integer +.Em i +and no comma matches +a sequence of exactly +.Em i +matches of the atom. +An atom followed by a bound +containing one integer +.Em i +and a comma matches +a sequence o +.Em i +or more matches of the atom. +An atom followed by a bound +containing two integers +.Em i +and +.Em j +matches +a sequence of +.Em i +through +.Em j +(inclusive) matches of the atom. +.Pp +An atom is a regular expression enclosed in +.Ql () +(matching a match for the +regular expression), +an empty set of +.Ql () +(matching the null string)\(dd, +a +.Em bracket expression +(see below), +.Ql .\& +(matching any single character), +.Ql \&^ +(matching the null string at the beginning of a line), +.Ql \&$ +(matching the null string at the end of a line), a +.Ql \e +followed by one of the characters +.Ql ^.[$()|*+?{\e +(matching that character taken as an ordinary character), +a +.Ql \e +followed by any other character\(dd +(matching that character taken as an ordinary character, +as if the +.Ql \e +had not been present\(dd), +or a single character with no other significance (matching that character). +A +.Ql \&{ +followed by a character other than a digit is an ordinary +character, not the beginning of a bound\(dd. +It is illegal to end an RE with +.Ql \e . +.Pp +A +.Em bracket expression +is a list of characters enclosed in +.Ql [] . +It normally matches any single character from the list (but see below). +If the list begins with +.Ql \&^ , +it matches any single character +(but see below) +.Em not +from the rest of the list. +If two characters in the list are separated by +.Ql \&- , +this is shorthand +for the full +.Em range +of characters between those two (inclusive) in the +collating sequence, +.No e.g. Ql [0-9] +in ASCII matches any decimal digit. +It is illegal\(dd for two ranges to share an +endpoint, +.No e.g. Ql a-c-e . +Ranges are very collating-sequence-dependent, +and portable programs should avoid relying on them. +.Pp +To include a literal +.Ql \&] +in the list, make it the first character +(following a possible +.Ql \&^ ) . +To include a literal +.Ql \&- , +make it the first or last character, +or the second endpoint of a range. +To use a literal +.Ql \&- +as the first endpoint of a range, +enclose it in +.Ql [.\& +and +.Ql .]\& +to make it a collating element (see below). +With the exception of these and some combinations using +.Ql \&[ +(see next paragraphs), all other special characters, including +.Ql \e , +lose their special significance within a bracket expression. +.Pp +Within a bracket expression, a collating element (a character, +a multi-character sequence that collates as if it were a single character, +or a collating-sequence name for either) +enclosed in +.Ql [.\& +and +.Ql .]\& +stands for the +sequence of characters of that collating element. +The sequence is a single element of the bracket expression's list. +A bracket expression containing a multi-character collating element +can thus match more than one character, +e.g. if the collating sequence includes a +.Ql ch +collating element, +then the RE +.Ql [[.ch.]]*c +matches the first five characters +of +.Ql chchcc . +.Pp +Within a bracket expression, a collating element enclosed in +.Ql [= +and +.Ql =] +is an equivalence class, standing for the sequences of characters +of all collating elements equivalent to that one, including itself. +(If there are no other equivalent collating elements, +the treatment is as if the enclosing delimiters were +.Ql [.\& +and +.Ql .] . ) +For example, if +.Ql x +and +.Ql y +are the members of an equivalence class, +then +.Ql [[=x=]] , +.Ql [[=y=]] , +and +.Ql [xy] +are all synonymous. +An equivalence class may not\(dd be an endpoint +of a range. +.Pp +Within a bracket expression, the name of a +.Em character class +enclosed in +.Ql [: +and +.Ql :] +stands for the list of all characters belonging to that +class. +Standard character class names are: +.Pp +.Bl -column "alnum" "digit" "xdigit" -offset indent +.It Em "alnum digit punct" +.It Em "alpha graph space" +.It Em "blank lower upper" +.It Em "cntrl print xdigit" +.El +.Pp +These stand for the character classes defined in +.Xr ctype 3 . +A locale may provide others. +A character class may not be used as an endpoint of a range. +.Pp +There are two special cases\(dd of bracket expressions: +the bracket expressions +.Ql [[:<:]] +and +.Ql [[:>:]] +match the null string at the beginning and end of a word respectively. +A word is defined as a sequence of word characters +which is neither preceded nor followed by +word characters. +A word character is an +.Em alnum +character (as defined by +.Xr ctype 3 ) +or an underscore. +This is an extension, +compatible with but not specified by +.St -p1003.2 , +and should be used with +caution in software intended to be portable to other systems. +.Pp +In the event that an RE could match more than one substring of a given +string, +the RE matches the one starting earliest in the string. +If the RE could match more than one substring starting at that point, +it matches the longest. +Subexpressions also match the longest possible substrings, subject to +the constraint that the whole match be as long as possible, +with subexpressions starting earlier in the RE taking priority over +ones starting later. +Note that higher-level subexpressions thus take priority over +their lower-level component subexpressions. +.Pp +Match lengths are measured in characters, not collating elements. +A null string is considered longer than no match at all. +For example, +.Ql bb* +matches the three middle characters of +.Ql abbbc , +.Ql (wee|week)(knights|nights) +matches all ten characters of +.Ql weeknights , +when +.Ql (.*).*\& +is matched against +.Ql abc +the parenthesized subexpression +matches all three characters, and +when +.Ql (a*)* +is matched against +.Ql bc +both the whole RE and the parenthesized +subexpression match the null string. +.Pp +If case-independent matching is specified, +the effect is much as if all case distinctions had vanished from the +alphabet. +When an alphabetic that exists in multiple cases appears as an +ordinary character outside a bracket expression, it is effectively +transformed into a bracket expression containing both cases, +.No e.g. Ql x +becomes +.Ql [xX] . +When it appears inside a bracket expression, all case counterparts +of it are added to the bracket expression, so that (e.g.) +.Ql [x] +becomes +.Ql [xX] +and +.Ql [^x] +becomes +.Ql [^xX] . +.Pp +No particular limit is imposed on the length of REs\(dd. +Programs intended to be portable should not employ REs longer +than 256 bytes, +as an implementation can refuse to accept such REs and remain +POSIX-compliant. +.Pp +Obsolete +.Pq Dq basic +regular expressions differ in several respects. +.Ql \&| +is an ordinary character and there is no equivalent +for its functionality. +.Ql \&+ +and +.Ql ?\& +are ordinary characters, and their functionality +can be expressed using bounds +.No ( Ql {1,} +or +.Ql {0,1} +respectively). +Also note that +.Ql x+ +in modern REs is equivalent to +.Ql xx* . +The delimiters for bounds are +.Ql \e{ +and +.Ql \e} , +with +.Ql \&{ +and +.Ql \&} +by themselves ordinary characters. +The parentheses for nested subexpressions are +.Ql \e( +and +.Ql \e) , +with +.Ql \&( +and +.Ql \&) +by themselves ordinary characters. +.Ql \&^ +is an ordinary character except at the beginning of the +RE or\(dd the beginning of a parenthesized subexpression, +.Ql \&$ +is an ordinary character except at the end of the +RE or\(dd the end of a parenthesized subexpression, +and +.Ql \&* +is an ordinary character if it appears at the beginning of the +RE or the beginning of a parenthesized subexpression +(after a possible leading +.Ql \&^ ) . +Finally, there is one new type of atom, a +.Em back reference : +.Ql \e +followed by a non-zero decimal digit +.Em d +matches the same sequence of characters +matched by the +.Em d Ns th +parenthesized subexpression +(numbering subexpressions by the positions of their opening parentheses, +left to right), +so that (e.g.) +.Ql \e([bc]\e)\e1 +matches +.Ql bb +or +.Ql cc +but not +.Ql bc . +.Sh SEE ALSO +.Xr regex 3 +.Rs +.%T Regular Expression Notation +.%R IEEE Std +.%N 1003.2 +.%P section 2.8 +.Re +.Sh BUGS +Having two kinds of REs is a botch. +.Pp +The current +.St -p1003.2 +spec says that +.Ql \&) +is an ordinary character in +the absence of an unmatched +.Ql \&( ; +this was an unintentional result of a wording error, +and change is likely. +Avoid relying on it. +.Pp +Back references are a dreadful botch, +posing major problems for efficient implementations. +They are also somewhat vaguely defined +(does +.Ql a\e(\e(b\e)*\e2\e)*d +match +.Ql abbbd ? ) . +Avoid using them. +.Pp +.St -p1003.2 +specification of case-independent matching is vague. +The +.Dq one case implies all cases +definition given above +is current consensus among implementors as to the right interpretation. +.Pp +The syntax for word boundaries is incredibly ugly. diff --git a/regex.subproj/regcomp.c b/regex/regcomp.c similarity index 100% rename from regex.subproj/regcomp.c rename to regex/regcomp.c diff --git a/regex.subproj/regerror.c b/regex/regerror.c similarity index 100% rename from regex.subproj/regerror.c rename to regex/regerror.c diff --git a/regex/regex.3 b/regex/regex.3 new file mode 100644 index 0000000..d871641 --- /dev/null +++ b/regex/regex.3 @@ -0,0 +1,701 @@ +.\" Copyright (c) 1992, 1993, 1994 Henry Spencer. +.\" Copyright (c) 1992, 1993, 1994 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Henry Spencer. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)regex.3 8.4 (Berkeley) 3/20/94 +.\" $FreeBSD: src/lib/libc/regex/regex.3,v 1.9 2001/10/01 16:08:58 ru Exp $ +.\" +.Dd March 20, 1994 +.Dt REGEX 3 +.Os +.Sh NAME +.Nm regcomp , +.Nm regexec , +.Nm regerror , +.Nm regfree +.Nd regular-expression library +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/types.h +.In regex.h +.Ft int +.Fn regcomp "regex_t *preg" "const char *pattern" "int cflags" +.Ft int +.Fo regexec +.Fa "const regex_t *preg" "const char *string" +.Fa "size_t nmatch" "regmatch_t pmatch[]" "int eflags" +.Fc +.Ft size_t +.Fo regerror +.Fa "int errcode" "const regex_t *preg" +.Fa "char *errbuf" "size_t errbuf_size" +.Fc +.Ft void +.Fn regfree "regex_t *preg" +.Sh DESCRIPTION +These routines implement +.St -p1003.2 +regular expressions +.Pq Do RE Dc Ns s ; +see +.Xr re_format 7 . +.Fn Regcomp +compiles an RE written as a string into an internal form, +.Fn regexec +matches that internal form against a string and reports results, +.Fn regerror +transforms error codes from either into human-readable messages, +and +.Fn regfree +frees any dynamically-allocated storage used by the internal form +of an RE. +.Pp +The header +.Aq Pa regex.h +declares two structure types, +.Ft regex_t +and +.Ft regmatch_t , +the former for compiled internal forms and the latter for match reporting. +It also declares the four functions, +a type +.Ft regoff_t , +and a number of constants with names starting with +.Dq Dv REG_ . +.Pp +.Fn Regcomp +compiles the regular expression contained in the +.Fa pattern +string, +subject to the flags in +.Fa cflags , +and places the results in the +.Ft regex_t +structure pointed to by +.Fa preg . +.Fa Cflags +is the bitwise OR of zero or more of the following flags: +.Bl -tag -width REG_EXTENDED +.It Dv REG_EXTENDED +Compile modern +.Pq Dq extended +REs, +rather than the obsolete +.Pq Dq basic +REs that +are the default. +.It Dv REG_BASIC +This is a synonym for 0, +provided as a counterpart to +.Dv REG_EXTENDED +to improve readability. +.It Dv REG_NOSPEC +Compile with recognition of all special characters turned off. +All characters are thus considered ordinary, +so the +.Dq RE +is a literal string. +This is an extension, +compatible with but not specified by +.St -p1003.2 , +and should be used with +caution in software intended to be portable to other systems. +.Dv REG_EXTENDED +and +.Dv REG_NOSPEC +may not be used +in the same call to +.Fn regcomp . +.It Dv REG_ICASE +Compile for matching that ignores upper/lower case distinctions. +See +.Xr re_format 7 . +.It Dv REG_NOSUB +Compile for matching that need only report success or failure, +not what was matched. +.It Dv REG_NEWLINE +Compile for newline-sensitive matching. +By default, newline is a completely ordinary character with no special +meaning in either REs or strings. +With this flag, +.Ql [^ +bracket expressions and +.Ql .\& +never match newline, +a +.Ql ^\& +anchor matches the null string after any newline in the string +in addition to its normal function, +and the +.Ql $\& +anchor matches the null string before any newline in the +string in addition to its normal function. +.It Dv REG_PEND +The regular expression ends, +not at the first NUL, +but just before the character pointed to by the +.Va re_endp +member of the structure pointed to by +.Fa preg . +The +.Va re_endp +member is of type +.Ft "const char *" . +This flag permits inclusion of NULs in the RE; +they are considered ordinary characters. +This is an extension, +compatible with but not specified by +.St -p1003.2 , +and should be used with +caution in software intended to be portable to other systems. +.El +.Pp +When successful, +.Fn regcomp +returns 0 and fills in the structure pointed to by +.Fa preg . +One member of that structure +(other than +.Va re_endp ) +is publicized: +.Va re_nsub , +of type +.Ft size_t , +contains the number of parenthesized subexpressions within the RE +(except that the value of this member is undefined if the +.Dv REG_NOSUB +flag was used). +If +.Fn regcomp +fails, it returns a non-zero error code; +see +.Sx DIAGNOSTICS . +.Pp +.Fn Regexec +matches the compiled RE pointed to by +.Fa preg +against the +.Fa string , +subject to the flags in +.Fa eflags , +and reports results using +.Fa nmatch , +.Fa pmatch , +and the returned value. +The RE must have been compiled by a previous invocation of +.Fn regcomp . +The compiled form is not altered during execution of +.Fn regexec , +so a single compiled RE can be used simultaneously by multiple threads. +.Pp +By default, +the NUL-terminated string pointed to by +.Fa string +is considered to be the text of an entire line, minus any terminating +newline. +The +.Fa eflags +argument is the bitwise OR of zero or more of the following flags: +.Bl -tag -width REG_STARTEND +.It Dv REG_NOTBOL +The first character of +the string +is not the beginning of a line, so the +.Ql ^\& +anchor should not match before it. +This does not affect the behavior of newlines under +.Dv REG_NEWLINE . +.It Dv REG_NOTEOL +The NUL terminating +the string +does not end a line, so the +.Ql $\& +anchor should not match before it. +This does not affect the behavior of newlines under +.Dv REG_NEWLINE . +.It Dv REG_STARTEND +The string is considered to start at +.Fa string ++ +.Fa pmatch Ns [0]. Ns Va rm_so +and to have a terminating NUL located at +.Fa string ++ +.Fa pmatch Ns [0]. Ns Va rm_eo +(there need not actually be a NUL at that location), +regardless of the value of +.Fa nmatch . +See below for the definition of +.Fa pmatch +and +.Fa nmatch . +This is an extension, +compatible with but not specified by +.St -p1003.2 , +and should be used with +caution in software intended to be portable to other systems. +Note that a non-zero +.Va rm_so +does not imply +.Dv REG_NOTBOL ; +.Dv REG_STARTEND +affects only the location of the string, +not how it is matched. +.El +.Pp +See +.Xr re_format 7 +for a discussion of what is matched in situations where an RE or a +portion thereof could match any of several substrings of +.Fa string . +.Pp +Normally, +.Fn regexec +returns 0 for success and the non-zero code +.Dv REG_NOMATCH +for failure. +Other non-zero error codes may be returned in exceptional situations; +see +.Sx DIAGNOSTICS . +.Pp +If +.Dv REG_NOSUB +was specified in the compilation of the RE, +or if +.Fa nmatch +is 0, +.Fn regexec +ignores the +.Fa pmatch +argument (but see below for the case where +.Dv REG_STARTEND +is specified). +Otherwise, +.Fa pmatch +points to an array of +.Fa nmatch +structures of type +.Ft regmatch_t . +Such a structure has at least the members +.Va rm_so +and +.Va rm_eo , +both of type +.Ft regoff_t +(a signed arithmetic type at least as large as an +.Ft off_t +and a +.Ft ssize_t ) , +containing respectively the offset of the first character of a substring +and the offset of the first character after the end of the substring. +Offsets are measured from the beginning of the +.Fa string +argument given to +.Fn regexec . +An empty substring is denoted by equal offsets, +both indicating the character following the empty substring. +.Pp +The 0th member of the +.Fa pmatch +array is filled in to indicate what substring of +.Fa string +was matched by the entire RE. +Remaining members report what substring was matched by parenthesized +subexpressions within the RE; +member +.Va i +reports subexpression +.Va i , +with subexpressions counted (starting at 1) by the order of their opening +parentheses in the RE, left to right. +Unused entries in the array (corresponding either to subexpressions that +did not participate in the match at all, or to subexpressions that do not +exist in the RE (that is, +.Va i +> +.Fa preg Ns -> Ns Va re_nsub ) ) +have both +.Va rm_so +and +.Va rm_eo +set to -1. +If a subexpression participated in the match several times, +the reported substring is the last one it matched. +(Note, as an example in particular, that when the RE +.Ql "(b*)+" +matches +.Ql bbb , +the parenthesized subexpression matches each of the three +.So Li b Sc Ns s +and then +an infinite number of empty strings following the last +.Ql b , +so the reported substring is one of the empties.) +.Pp +If +.Dv REG_STARTEND +is specified, +.Fa pmatch +must point to at least one +.Ft regmatch_t +(even if +.Fa nmatch +is 0 or +.Dv REG_NOSUB +was specified), +to hold the input offsets for +.Dv REG_STARTEND . +Use for output is still entirely controlled by +.Fa nmatch ; +if +.Fa nmatch +is 0 or +.Dv REG_NOSUB +was specified, +the value of +.Fa pmatch Ns [0] +will not be changed by a successful +.Fn regexec . +.Pp +.Fn Regerror +maps a non-zero +.Fa errcode +from either +.Fn regcomp +or +.Fn regexec +to a human-readable, printable message. +If +.Fa preg +is +.No non\- Ns Dv NULL , +the error code should have arisen from use of +the +.Ft regex_t +pointed to by +.Fa preg , +and if the error code came from +.Fn regcomp , +it should have been the result from the most recent +.Fn regcomp +using that +.Ft regex_t . +.No ( Fn Regerror +may be able to supply a more detailed message using information +from the +.Ft regex_t . ) +.Fn Regerror +places the NUL-terminated message into the buffer pointed to by +.Fa errbuf , +limiting the length (including the NUL) to at most +.Fa errbuf_size +bytes. +If the whole message won't fit, +as much of it as will fit before the terminating NUL is supplied. +In any case, +the returned value is the size of buffer needed to hold the whole +message (including terminating NUL). +If +.Fa errbuf_size +is 0, +.Fa errbuf +is ignored but the return value is still correct. +.Pp +If the +.Fa errcode +given to +.Fn regerror +is first ORed with +.Dv REG_ITOA , +the +.Dq message +that results is the printable name of the error code, +e.g.\& +.Dq Dv REG_NOMATCH , +rather than an explanation thereof. +If +.Fa errcode +is +.Dv REG_ATOI , +then +.Fa preg +shall be +.No non\- Ns Dv NULL +and the +.Va re_endp +member of the structure it points to +must point to the printable name of an error code; +in this case, the result in +.Fa errbuf +is the decimal digits of +the numeric value of the error code +(0 if the name is not recognized). +.Dv REG_ITOA +and +.Dv REG_ATOI +are intended primarily as debugging facilities; +they are extensions, +compatible with but not specified by +.St -p1003.2 , +and should be used with +caution in software intended to be portable to other systems. +Be warned also that they are considered experimental and changes are possible. +.Pp +.Fn Regfree +frees any dynamically-allocated storage associated with the compiled RE +pointed to by +.Fa preg . +The remaining +.Ft regex_t +is no longer a valid compiled RE +and the effect of supplying it to +.Fn regexec +or +.Fn regerror +is undefined. +.Pp +None of these functions references global variables except for tables +of constants; +all are safe for use from multiple threads if the arguments are safe. +.Sh IMPLEMENTATION CHOICES +There are a number of decisions that +.St -p1003.2 +leaves up to the implementor, +either by explicitly saying +.Dq undefined +or by virtue of them being +forbidden by the RE grammar. +This implementation treats them as follows. +.Pp +See +.Xr re_format 7 +for a discussion of the definition of case-independent matching. +.Pp +There is no particular limit on the length of REs, +except insofar as memory is limited. +Memory usage is approximately linear in RE size, and largely insensitive +to RE complexity, except for bounded repetitions. +See +.Sx BUGS +for one short RE using them +that will run almost any system out of memory. +.Pp +A backslashed character other than one specifically given a magic meaning +by +.St -p1003.2 +(such magic meanings occur only in obsolete +.Bq Dq basic +REs) +is taken as an ordinary character. +.Pp +Any unmatched +.Ql [\& +is a +.Dv REG_EBRACK +error. +.Pp +Equivalence classes cannot begin or end bracket-expression ranges. +The endpoint of one range cannot begin another. +.Pp +.Dv RE_DUP_MAX , +the limit on repetition counts in bounded repetitions, is 255. +.Pp +A repetition operator +.Ql ( ?\& , +.Ql *\& , +.Ql +\& , +or bounds) +cannot follow another +repetition operator. +A repetition operator cannot begin an expression or subexpression +or follow +.Ql ^\& +or +.Ql |\& . +.Pp +.Ql |\& +cannot appear first or last in a (sub)expression or after another +.Ql |\& , +i.e. an operand of +.Ql |\& +cannot be an empty subexpression. +An empty parenthesized subexpression, +.Ql "()" , +is legal and matches an +empty (sub)string. +An empty string is not a legal RE. +.Pp +A +.Ql {\& +followed by a digit is considered the beginning of bounds for a +bounded repetition, which must then follow the syntax for bounds. +A +.Ql {\& +.Em not +followed by a digit is considered an ordinary character. +.Pp +.Ql ^\& +and +.Ql $\& +beginning and ending subexpressions in obsolete +.Pq Dq basic +REs are anchors, not ordinary characters. +.Sh SEE ALSO +.Xr grep 1 , +.Xr re_format 7 +.Pp +.St -p1003.2 , +sections 2.8 (Regular Expression Notation) +and +B.5 (C Binding for Regular Expression Matching). +.Sh DIAGNOSTICS +Non-zero error codes from +.Fn regcomp +and +.Fn regexec +include the following: +.Pp +.Bl -tag -width REG_ECOLLATE -compact +.It Dv REG_NOMATCH +.Fn regexec +failed to match +.It Dv REG_BADPAT +invalid regular expression +.It Dv REG_ECOLLATE +invalid collating element +.It Dv REG_ECTYPE +invalid character class +.It Dv REG_EESCAPE +.Ql \e +applied to unescapable character +.It Dv REG_ESUBREG +invalid backreference number +.It Dv REG_EBRACK +brackets +.Ql "[ ]" +not balanced +.It Dv REG_EPAREN +parentheses +.Ql "( )" +not balanced +.It Dv REG_EBRACE +braces +.Ql "{ }" +not balanced +.It Dv REG_BADBR +invalid repetition count(s) in +.Ql "{ }" +.It Dv REG_ERANGE +invalid character range in +.Ql "[ ]" +.It Dv REG_ESPACE +ran out of memory +.It Dv REG_BADRPT +.Ql ?\& , +.Ql *\& , +or +.Ql +\& +operand invalid +.It Dv REG_EMPTY +empty (sub)expression +.It Dv REG_ASSERT +can't happen - you found a bug +.It Dv REG_INVARG +invalid argument, e.g. negative-length string +.El +.Sh HISTORY +Originally written by +.An Henry Spencer . +Altered for inclusion in the +.Bx 4.4 +distribution. +.Sh BUGS +This is an alpha release with known defects. +Please report problems. +.Pp +The back-reference code is subtle and doubts linger about its correctness +in complex cases. +.Pp +.Fn Regexec +performance is poor. +This will improve with later releases. +.Fa Nmatch +exceeding 0 is expensive; +.Fa nmatch +exceeding 1 is worse. +.Fn Regexec +is largely insensitive to RE complexity +.Em except +that back +references are massively expensive. +RE length does matter; in particular, there is a strong speed bonus +for keeping RE length under about 30 characters, +with most special characters counting roughly double. +.Pp +.Fn Regcomp +implements bounded repetitions by macro expansion, +which is costly in time and space if counts are large +or bounded repetitions are nested. +An RE like, say, +.Ql "((((a{1,100}){1,100}){1,100}){1,100}){1,100}" +will (eventually) run almost any existing machine out of swap space. +.Pp +There are suspected problems with response to obscure error conditions. +Notably, +certain kinds of internal overflow, +produced only by truly enormous REs or by multiply nested bounded repetitions, +are probably not handled well. +.Pp +Due to a mistake in +.St -p1003.2 , +things like +.Ql "a)b" +are legal REs because +.Ql )\& +is +a special character only in the presence of a previous unmatched +.Ql (\& . +This can't be fixed until the spec is fixed. +.Pp +The standard's definition of back references is vague. +For example, does +.Ql "a\e(\e(b\e)*\e2\e)*d" +match +.Ql "abbbd" ? +Until the standard is clarified, +behavior in such cases should not be relied on. +.Pp +The implementation of word-boundary matching is a bit of a kludge, +and bugs may lurk in combinations of word-boundary matching and anchoring. diff --git a/regex.subproj/regex2.h b/regex/regex2.h similarity index 100% rename from regex.subproj/regex2.h rename to regex/regex2.h diff --git a/regex.subproj/regexec.c b/regex/regexec.c similarity index 100% rename from regex.subproj/regexec.c rename to regex/regexec.c diff --git a/regex.subproj/regfree.c b/regex/regfree.c similarity index 100% rename from regex.subproj/regfree.c rename to regex/regfree.c diff --git a/regex.subproj/utils.h b/regex/utils.h similarity index 100% rename from regex.subproj/utils.h rename to regex/utils.h diff --git a/rpc/Makefile.inc b/rpc/Makefile.inc new file mode 100644 index 0000000..223003f --- /dev/null +++ b/rpc/Makefile.inc @@ -0,0 +1,159 @@ +# @(#)Makefile 5.11 (Berkeley) 9/6/90 +# $FreeBSD: src/lib/libc/rpc/Makefile.inc,v 1.21 2001/10/04 21:03:17 wpaul Exp $ + +.PATH: ${.CURDIR}/../libc/rpc ${.CURDIR}/. +SRCS+= auth_none.c auth_unix.c authunix_prot.c bindresvport.c clnt_bcast.c \ + clnt_dg.c clnt_generic.c clnt_perror.c clnt_raw.c clnt_simple.c \ + clnt_vc.c rpc_dtablesize.c getnetconfig.c getnetpath.c getrpcent.c \ + getrpcport.c mt_misc.c pmap_clnt.c pmap_getmaps.c pmap_getport.c \ + pmap_prot.c pmap_prot2.c pmap_rmt.c rpc_prot.c rpc_commondata.c \ + rpc_callmsg.c rpc_generic.c rpc_soc.c rpcb_clnt.c rpcb_prot.c \ + rpcb_st_xdr.c svc.c svc_auth.c svc_dg.c svc_auth_unix.c svc_generic.c \ + svc_raw.c svc_run.c svc_simple.c svc_vc.c + +# XDR +SRCS+= xdr.c xdr_array.c xdr_float.c xdr_mem.c xdr_rec.c xdr_reference.c \ + xdr_stdio.c + +# Secure-RPC +SRCS+= auth_time.c auth_des.c authdes_prot.c des_crypt.c des_soft.c \ + crypt_client.c key_call.c key_prot_xdr.c getpublickey.c \ + svc_auth_des.c + +# Resolver stuff +SRCS+= netname.c netnamer.c rpcdname.c + +# Misc Source +SRCS+= rtime.c + +# generated sources +SRCS+= crypt_clnt.c crypt_xdr.c crypt.h + +CFLAGS+= -DBROKEN_DES -DPORTMAP -DDES_BUILTIN + +CLEANFILES+= crypt_clnt.c crypt_xdr.c crypt.h + +RPCDIR= ${DESTDIR}/usr/include/rpcsvc +RPCGEN= rpcgen -C + +crypt_clnt.c: ${RPCDIR}/crypt.x crypt.h + ${RPCGEN} -l -o ${.TARGET} ${RPCDIR}/crypt.x + +crypt_xdr.c: ${RPCDIR}/crypt.x crypt.h + ${RPCGEN} -c -o ${.TARGET} ${RPCDIR}/crypt.x + +crypt.h: ${RPCDIR}/crypt.x + ${RPCGEN} -h -o ${.TARGET} ${RPCDIR}/crypt.x +MAN+= bindresvport.3 des_crypt.3 getnetconfig.3 getnetpath.3 getrpcent.3 \ + getrpcport.3 rpc.3 rpc_soc.3 rpc_clnt_auth.3 rpc_clnt_calls.3 \ + rpc_clnt_create.3 rpc_svc_calls.3 rpc_svc_create.3 rpc_svc_err.3 \ + rpc_svc_reg.3 rpc_xdr.3 rpcbind.3 xdr.3 publickey.3 rpc_secure.3 \ + rtime.3 +MAN+= publickey.5 rpc.5 netconfig.5 +MLINKS+= bindresvport.3 bindresvport_sa.3 \ + getnetconfig.3 setnetconfig.3 \ + getnetconfig.3 getnetconfigent.3 \ + getnetconfig.3 endnetconfig.3 \ + getnetconfig.3 nc_perror.3 \ + getnetconfig.3 nc_sperror.3 \ + getnetpath.3 setnetpath.3 \ + getnetpath.3 endnetpath.3 \ + getrpcent.3 getrpcbyname.3 \ + getrpcent.3 getrpcbynumber.3 \ + getrpcent.3 endrpcent.3 \ + getrpcent.3 setrpcent.3 \ + rpc_clnt_auth.3 auth_destroy.3 \ + rpc_clnt_auth.3 authnone_create.3 \ + rpc_clnt_auth.3 authsys_create.3 \ + rpc_clnt_auth.3 authsys_create_default.3 \ + rpc_clnt_calls.3 clnt_call.3 \ + rpc_clnt_calls.3 clnt_perrno.3 \ + rpc_clnt_calls.3 clnt_perror.3 \ + rpc_clnt_calls.3 clnt_sperrno.3 \ + rpc_clnt_calls.3 clnt_sperror.3 \ + rpc_clnt_calls.3 rpc_call.3 \ + rpc_clnt_calls.3 rpc_broadcast.3 \ + rpc_clnt_calls.3 rpc_broadcast_exp.3 \ + rpc_clnt_calls.3 clnt_freeres.3 \ + rpc_clnt_calls.3 clnt_geterr.3 \ + rpc_clnt_create.3 clnt_control.3 \ + rpc_clnt_create.3 clnt_create.3 \ + rpc_clnt_create.3 clnt_create_vers.3 \ + rpc_clnt_create.3 clnt_destroy.3 \ + rpc_clnt_create.3 clnt_pcreateerror.3 \ + rpc_clnt_create.3 clnt_spcreateerror.3 \ + rpc_clnt_create.3 clnt_dg_create.3 \ + rpc_clnt_create.3 clnt_raw_create.3 \ + rpc_clnt_create.3 clnt_tli_create.3 \ + rpc_clnt_create.3 clnt_tp_create.3 \ + rpc_clnt_create.3 clnt_vc_create.3 \ + rpc_svc_calls.3 svc_dg_enablecache.3 \ + rpc_svc_calls.3 svc_exit.3 \ + rpc_svc_calls.3 svc_freeargs.3 \ + rpc_svc_calls.3 svc_getargs.3 \ + rpc_svc_calls.3 svc_getreq_common.3 \ + rpc_svc_calls.3 svc_getreq_poll.3 \ + rpc_svc_calls.3 svc_getreqset.3 \ + rpc_svc_calls.3 svc_getrpccaller.3 \ + rpc_svc_calls.3 __svc_getcallercreds.3 \ + rpc_svc_calls.3 svc_pollset.3 \ + rpc_svc_calls.3 svc_run.3 \ + rpc_svc_calls.3 svc_sendreply.3 \ + rpc_svc_create.3 svc_control.3 \ + rpc_svc_create.3 svc_create.3 \ + rpc_svc_create.3 svc_dg_create.3 \ + rpc_svc_create.3 svc_destroy.3 \ + rpc_svc_create.3 svc_fd_create.3 \ + rpc_svc_create.3 svc_raw_create.3 \ + rpc_svc_create.3 svc_tli_create.3 \ + rpc_svc_create.3 svc_tp_create.3 \ + rpc_svc_create.3 svc_vc_create.3 \ + rpc_svc_err.3 svcerr_auth.3 \ + rpc_svc_err.3 svcerr_decode.3 \ + rpc_svc_err.3 svcerr_noproc.3 \ + rpc_svc_err.3 svcerr_noprog.3 \ + rpc_svc_err.3 svcerr_progvers.3 \ + rpc_svc_err.3 svcerr_systemerr.3 \ + rpc_svc_err.3 svcerr_weakauth.3 \ + rpc_svc_reg.3 rpc_reg.3 \ + rpc_svc_reg.3 svc_reg.3 \ + rpc_svc_reg.3 svc_unreg.3 \ + rpc_svc_reg.3 svc_auth_reg.3 \ + rpc_svc_reg.3 xprt_register.3 \ + rpc_svc_reg.3 xprt_unregister.3 \ + rpcbind.3 rpcb_getmaps.3 \ + rpcbind.3 rpcb_getaddr.3 \ + rpcbind.3 rpcb_gettime.3 \ + rpcbind.3 rpcb_rmtcall.3 \ + rpcbind.3 rpcb_set.3 \ + rpcbind.3 rpcb_unset.3 \ + rpc_soc.3 authunix_create.3 \ + rpc_soc.3 authunix_create_default.3 \ + rpc_soc.3 callrpc.3 \ + rpc_soc.3 clnt_broadcast.3 \ + rpc_soc.3 clntraw_create.3 \ + rpc_soc.3 clnttcp_create.3 \ + rpc_soc.3 clntunix_create.3 \ + rpc_soc.3 clntudp_bufcreate.3 \ + rpc_soc.3 clntudp_create.3 \ + rpc_soc.3 get_myaddress.3 \ + rpc_soc.3 pmap_getmaps.3 \ + rpc_soc.3 pmap_getport.3 \ + rpc_soc.3 pmap_rmtcall.3 \ + rpc_soc.3 pmap_set.3 \ + rpc_soc.3 pmap_unset.3 \ + rpc_soc.3 registerrpc.3 \ + rpc_soc.3 rpc_createerr.3 \ + rpc_soc.3 svc_fds.3 \ + rpc_soc.3 svc_fdset.3 \ + rpc_soc.3 svc_getcaller.3 \ + rpc_soc.3 svc_register.3 \ + rpc_soc.3 svc_unregister.3 \ + rpc_soc.3 svcfd_create.3 \ + rpc_soc.3 svcunixfd_create.3 \ + rpc_soc.3 svcraw_create.3 \ + rpc_soc.3 svctcp_create.3 \ + rpc_soc.3 svcudp_bufcreate.3 \ + rpc_soc.3 svcunix_create.3 \ + rpc_soc.3 xdr_pmap.3 \ + rpc_soc.3 xdr_pmaplist.3 diff --git a/stdio.subproj/Makefile b/stdio.subproj/Makefile deleted file mode 100644 index 4fc67ac..0000000 --- a/stdio.subproj/Makefile +++ /dev/null @@ -1,57 +0,0 @@ -# -# Generated by the NeXT Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = stdio - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -HFILES = floatio.h fvwrite.h glue.h local.h - -CFILES = clrerr.c fclose.c fdopen.c feof.c ferror.c fflush.c fgetc.c\ - fgetln.c fgetpos.c fgets.c fileno.c findfp.c flags.c\ - fopen.c fprintf.c fpurge.c fputc.c fputs.c fread.c\ - freopen.c fscanf.c fseek.c fsetpos.c ftell.c funopen.c\ - fvwrite.c fwalk.c fwrite.c getc.c getchar.c gets.c getw.c\ - makebuf.c mktemp.c perror.c printf.c putc.c putchar.c\ - puts.c putw.c refill.c remove.c rewind.c rget.c scanf.c\ - setbuf.c setbuffer.c setvbuf.c snprintf.c sprintf.c sscanf.c\ - stdio.c tempnam.c tmpfile.c tmpnam.c ungetc.c vfprintf.c\ - vfscanf.c vprintf.c vscanf.c vsnprintf.c vsprintf.c\ - vsscanf.c wbuf.c wsetup.c - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble - - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - - - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/stdio.subproj/Makefile.postamble b/stdio.subproj/Makefile.postamble deleted file mode 100644 index 411cde6..0000000 --- a/stdio.subproj/Makefile.postamble +++ /dev/null @@ -1,100 +0,0 @@ -############################################################################### -# Makefile.postamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile, which is imported after all other makefiles, to -# override attributes for a project's Makefile environment. This allows you -# to take advantage of the environment set up by the other Makefiles. -# You can also define custom rules at the end of this file. -# -############################################################################### -# -# These variables are exported by the standard makefiles and can be -# used in any customizations you make. They are *outputs* of -# the Makefiles and should be used, not set. -# -# PRODUCTS: products to install. All of these products will be placed in -# the directory $(DSTROOT)$(INSTALLDIR) -# GLOBAL_RESOURCE_DIR: The directory to which resources are copied. -# LOCAL_RESOURCE_DIR: The directory to which localized resources are copied. -# OFILE_DIR: Directory into which .o object files are generated. -# DERIVED_SRC_DIR: Directory used for all other derived files -# -# ALL_CFLAGS: flags to pass when compiling .c files -# ALL_MFLAGS: flags to pass when compiling .m files -# ALL_CCFLAGS: flags to pass when compiling .cc, .cxx, and .C files -# ALL_MMFLAGS: flags to pass when compiling .mm, .mxx, and .M files -# ALL_PRECOMPFLAGS: flags to pass when precompiling .h files -# ALL_LDFLAGS: flags to pass when linking object files -# ALL_LIBTOOL_FLAGS: flags to pass when libtooling object files -# ALL_PSWFLAGS: flags to pass when processing .psw and .pswm (pswrap) files -# ALL_RPCFLAGS: flags to pass when processing .rpc (rpcgen) files -# ALL_YFLAGS: flags to pass when processing .y (yacc) files -# ALL_LFLAGS: flags to pass when processing .l (lex) files -# -# NAME: name of application, bundle, subproject, palette, etc. -# LANGUAGES: langages in which the project is written (default "English") -# English_RESOURCES: localized resources (e.g. nib's, images) of project -# GLOBAL_RESOURCES: non-localized resources of project -# -# SRCROOT: base directory in which to place the new source files -# SRCPATH: relative path from SRCROOT to present subdirectory -# -# INSTALLDIR: Directory the product will be installed into by 'install' target -# PUBLIC_HDR_INSTALLDIR: where to install public headers. Don't forget -# to prefix this with DSTROOT when you use it. -# PRIVATE_HDR_INSTALLDIR: where to install private headers. Don't forget -# to prefix this with DSTROOT when you use it. -# -# EXECUTABLE_EXT: Executable extension for the platform (i.e. .exe on Windows) -# -############################################################################### - -# Some compiler flags can be overridden here for certain build situations. -# -# WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost) -# DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults -# to -g) -# DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG) -# OPTIMIZE_BUILD_CFLAGS: flags passed during optimized builds (defaults -# to -O) -# PROFILE_BUILD_CFLAGS: flags passed during profile builds (defaults -# to -pg -DPROFILE) -# LOCAL_DIR_INCLUDE_DIRECTIVE: flag used to add current directory to -# the include path (defaults to -I.) -# DEBUG_BUILD_LDFLAGS, OPTIMIZE_BUILD_LDFLAGS, PROFILE_BUILD_LDFLAGS: flags -# passed to ld/libtool (defaults to nothing) - - -# Library and Framework projects only: -# INSTALL_NAME_DIRECTIVE: This directive ensures that executables linked -# against the framework will run against the correct version even if -# the current version of the framework changes. You may override this -# to "" as an alternative to using the DYLD_LIBRARY_PATH during your -# development cycle, but be sure to restore it before installing. - - -# Ownership and permissions of files installed by 'install' target - -#INSTALL_AS_USER = root - # User/group ownership -#INSTALL_AS_GROUP = wheel - # (probably want to set both of these) -#INSTALL_PERMISSIONS = - # If set, 'install' chmod's executable to this - - -# Options to strip. Note: -S strips debugging symbols (executables can be stripped -# down further with -x or, if they load no bundles, with no options at all). - -#STRIPFLAGS = -S - - -######################################################################### -# Put rules to extend the behavior of the standard Makefiles here. Include them in -# the dependency tree via cvariables like AFTER_INSTALL in the Makefile.preamble. -# -# You should avoid redefining things like "install" or "app", as they are -# owned by the top-level Makefile API and no context has been set up for where -# derived files should go. -# diff --git a/stdio.subproj/Makefile.preamble b/stdio.subproj/Makefile.preamble deleted file mode 100644 index c1624b4..0000000 --- a/stdio.subproj/Makefile.preamble +++ /dev/null @@ -1,137 +0,0 @@ -############################################################################### -# Makefile.preamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile for configuring the standard application makefiles -# associated with ProjectBuilder. It is included before the main makefile. -# In Makefile.preamble you set attributes for a project, so they are available -# to the project's makefiles. In contrast, you typically write additional rules or -# override built-in behavior in the Makefile.postamble. -# -# Each directory in a project tree (main project plus subprojects) should -# have its own Makefile.preamble and Makefile.postamble. -############################################################################### -# -# Before the main makefile is included for this project, you may set: -# -# MAKEFILEDIR: Directory in which to find $(MAKEFILE) -# MAKEFILE: Top level mechanism Makefile (e.g., app.make, bundle.make) - -# Compiler/linker flags added to the defaults: The OTHER_* variables will be -# inherited by all nested sub-projects, but the LOCAL_ versions of the same -# variables will not. Put your -I, -D, -U, and -L flags in ProjectBuilder's -# Build Attributes inspector if at all possible. To override the default flags -# that get passed to ${CC} (e.g. change -O to -O2), see Makefile.postamble. The -# variables below are *inputs* to the build process and distinct from the override -# settings done (less often) in the Makefile.postamble. -# -# OTHER_CFLAGS, LOCAL_CFLAGS: additional flags to pass to the compiler -# Note that $(OTHER_CFLAGS) and $(LOCAL_CFLAGS) are used for .h, ...c, .m, -# .cc, .cxx, .C, and .M files. There is no need to respecify the -# flags in OTHER_MFLAGS, etc. -# OTHER_MFLAGS, LOCAL_MFLAGS: additional flags for .m files -# OTHER_CCFLAGS, LOCAL_CCFLAGS: additional flags for .cc, .cxx, and ...C files -# OTHER_MMFLAGS, LOCAL_MMFLAGS: additional flags for .mm and .M files -# OTHER_PRECOMPFLAGS, LOCAL_PRECOMPFLAGS: additional flags used when -# precompiling header files -# OTHER_LDFLAGS, LOCAL_LDFLAGS: additional flags passed to ld and libtool -# OTHER_PSWFLAGS, LOCAL_PSWFLAGS: additional flags passed to pswrap -# OTHER_RPCFLAGS, LOCAL_RPCFLAGS: additional flags passed to rpcgen -# OTHER_YFLAGS, LOCAL_YFLAGS: additional flags passed to yacc -# OTHER_LFLAGS, LOCAL_LFLAGS: additional flags passed to lex - -# These variables provide hooks enabling you to add behavior at almost every -# stage of the make: -# -# BEFORE_PREBUILD: targets to build before installing headers for a subproject -# AFTER_PREBUILD: targets to build after installing headers for a subproject -# BEFORE_BUILD_RECURSION: targets to make before building subprojects -# BEFORE_BUILD: targets to make before a build, but after subprojects -# AFTER_BUILD: targets to make after a build -# -# BEFORE_INSTALL: targets to build before installing the product -# AFTER_INSTALL: targets to build after installing the product -# BEFORE_POSTINSTALL: targets to build before postinstalling every subproject -# AFTER_POSTINSTALL: targts to build after postinstalling every subproject -# -# BEFORE_INSTALLHDRS: targets to build before installing headers for a -# subproject -# AFTER_INSTALLHDRS: targets to build after installing headers for a subproject -# BEFORE_INSTALLSRC: targets to build before installing source for a subproject -# AFTER_INSTALLSRC: targets to build after installing source for a subproject -# -# BEFORE_DEPEND: targets to build before building dependencies for a -# subproject -# AFTER_DEPEND: targets to build after building dependencies for a -# subproject -# -# AUTOMATIC_DEPENDENCY_INFO: if YES, then the dependency file is -# updated every time the project is built. If NO, the dependency -# file is only built when the depend target is invoked. - -# Framework-related variables: -# FRAMEWORK_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the framework's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables - -# Library-related variables: -# PUBLIC_HEADER_DIR: Determines where public exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. For library projects you should -# set this to something like /Developer/Headers/$(NAME). Do not set -# this variable for framework projects unless you do not want the -# header files included in the framework. -# PRIVATE_HEADER_DIR: Determines where private exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. -# LIBRARY_STYLE: This may be either STATIC or DYNAMIC, and determines -# whether the libraries produced are statically linked when they -# are used or if they are dynamically loadable. This defaults to -# DYNAMIC. -# LIBRARY_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the library's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables -# -# INSTALL_AS_USER: owner of the intalled products (default root) -# INSTALL_AS_GROUP: group of the installed products (default wheel) -# INSTALL_PERMISSIONS: permissions of the installed product (default o+rX) -# -# OTHER_RECURSIVE_VARIABLES: The names of variables which you want to be -# passed on the command line to recursive invocations of make. Note that -# the values in OTHER_*FLAGS are inherited by subprojects automatically -- -# you do not have to (and shouldn't) add OTHER_*FLAGS to -# OTHER_RECURSIVE_VARIABLES. - -# Additional headers to export beyond those in the PB.project: -# OTHER_PUBLIC_HEADERS -# OTHER_PROJECT_HEADERS -# OTHER_PRIVATE_HEADERS - -# Additional files for the project's product: <> -# OTHER_RESOURCES: (non-localized) resources for this project -# OTHER_OFILES: relocatables to be linked into this project -# OTHER_LIBS: more libraries to link against -# OTHER_PRODUCT_DEPENDS: other dependencies of this project -# OTHER_SOURCEFILES: other source files maintained by .pre/postamble -# OTHER_GARBAGE: additional files to be removed by `make clean' - -# Set this to YES if you don't want a final libtool call for a library/framework. -# BUILD_OFILES_LIST_ONLY - -# To include a version string, project source must exist in a directory named -# $(NAME).%d[.%d][.%d] and the following line must be uncommented. -# OTHER_GENERATED_OFILES = $(VERS_OFILE) - -# This definition will suppress stripping of debug symbols when an executable -# is installed. By default it is YES. -# STRIP_ON_INSTALL = NO - -# Uncomment to suppress generation of a KeyValueCoding index when installing -# frameworks (This index is used by WOB and IB to determine keys available -# for an object). Set to YES by default. -# PREINDEX_FRAMEWORK = NO - -# Change this definition to install projects somewhere other than the -# standard locations. NEXT_ROOT defaults to "C:/Apple" on Windows systems -# and "" on other systems. -DSTROOT = $(HOME) diff --git a/stdio.subproj/PB.project b/stdio.subproj/PB.project deleted file mode 100644 index 5d739da..0000000 --- a/stdio.subproj/PB.project +++ /dev/null @@ -1,89 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - H_FILES = (floatio.h, fvwrite.h, glue.h, local.h); - OTHER_LINKED = ( - clrerr.c, - fclose.c, - fdopen.c, - feof.c, - ferror.c, - fflush.c, - fgetc.c, - fgetln.c, - fgetpos.c, - fgets.c, - fileno.c, - findfp.c, - flags.c, - fopen.c, - fprintf.c, - fpurge.c, - fputc.c, - fputs.c, - fread.c, - freopen.c, - fscanf.c, - fseek.c, - fsetpos.c, - ftell.c, - funopen.c, - fvwrite.c, - fwalk.c, - fwrite.c, - getc.c, - getchar.c, - gets.c, - getw.c, - makebuf.c, - mktemp.c, - perror.c, - printf.c, - putc.c, - putchar.c, - puts.c, - putw.c, - refill.c, - remove.c, - rewind.c, - rget.c, - scanf.c, - setbuf.c, - setbuffer.c, - setvbuf.c, - snprintf.c, - sprintf.c, - sscanf.c, - stdio.c, - tempnam.c, - tmpfile.c, - tmpnam.c, - ungetc.c, - vfprintf.c, - vfscanf.c, - vprintf.c, - vscanf.c, - vsnprintf.c, - vsprintf.c, - vsscanf.c, - wbuf.c, - wsetup.c - ); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble); - SUBPROJECTS = (); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = stdio; - PROJECTTYPE = Component; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/stdio/Makefile.inc b/stdio/Makefile.inc new file mode 100644 index 0000000..0054af3 --- /dev/null +++ b/stdio/Makefile.inc @@ -0,0 +1,47 @@ +# @(#)Makefile.inc 8.3 (Berkeley) 4/17/94 +# $FreeBSD: src/lib/libc/stdio/Makefile.inc,v 1.20 2001/03/27 17:26:52 ru Exp $ + +# stdio sources +.PATH: ${.CURDIR}/stdio + +SRCS+= clrerr.c findfp.c fsetpos.c mktemp.c scanf.c ungetc.c \ + fclose.c flags.c ftell.c perror.c setbuf.c vfprintf.c \ + fdopen.c fopen.c funopen.c printf.c setbuffer.c vfscanf.c \ + feof.c fprintf.c fvwrite.c putc.c setvbuf.c vprintf.c \ + ferror.c fpurge.c fwalk.c putchar.c snprintf.c vscanf.c \ + fflush.c fputc.c fwrite.c puts.c sprintf.c vsnprintf.c \ + fgetc.c fputs.c getc.c putw.c sscanf.c vsprintf.c \ + fgetln.c fread.c getchar.c refill.c stdio.c vsscanf.c \ + fgetpos.c freopen.c gets.c remove.c tempnam.c wbuf.c \ + fgets.c fscanf.c getw.c rewind.c tmpfile.c wsetup.c \ + fileno.c fseek.c makebuf.c rget.c tmpnam.c asprintf.c \ + vasprintf.c + + +.if ${LIB} == "c" +MAN3+= fclose.3 ferror.3 fflush.3 fgetln.3 fgets.3 fopen.3 fputs.3 \ + fread.3 fseek.3 funopen.3 getc.3 mktemp.3 printf.3 putc.3 remove.3 \ + scanf.3 setbuf.3 stdio.3 tmpnam.3 ungetc.3 + +MLINKS+=ferror.3 clearerr.3 ferror.3 feof.3 ferror.3 fileno.3 +MLINKS+=fflush.3 fpurge.3 +MLINKS+=fgets.3 gets.3 +MLINKS+=fopen.3 fdopen.3 fopen.3 freopen.3 +MLINKS+=fputs.3 puts.3 +MLINKS+=fread.3 fwrite.3 +MLINKS+=fseek.3 fgetpos.3 fseek.3 fseeko.3 fseek.3 fsetpos.3 fseek.3 ftell.3 \ + fseek.3 ftello.3 fseek.3 rewind.3 +MLINKS+=funopen.3 fropen.3 funopen.3 fwopen.3 +MLINKS+=getc.3 fgetc.3 getc.3 getchar.3 getc.3 getw.3 +MLINKS+=mktemp.3 mkdtemp.3 mktemp.3 mkstemp.3 mktemp.3 mkstemps.3 +MLINKS+=printf.3 asprintf.3 printf.3 fprintf.3 \ + printf.3 snprintf.3 printf.3 sprintf.3 \ + printf.3 vasprintf.3 \ + printf.3 vfprintf.3 printf.3 vprintf.3 printf.3 vsnprintf.3 \ + printf.3 vsprintf.3 +MLINKS+=putc.3 fputc.3 putc.3 putchar.3 putc.3 putw.3 +MLINKS+=scanf.3 fscanf.3 scanf.3 sscanf.3 scanf.3 vfscanf.3 scanf.3 vscanf.3 \ + scanf.3 vsscanf.3 +MLINKS+=setbuf.3 setbuffer.3 setbuf.3 setlinebuf.3 setbuf.3 setvbuf.3 +MLINKS+=tmpnam.3 tempnam.3 tmpnam.3 tmpfile.3 +.endif diff --git a/stdio/asprintf.c b/stdio/asprintf.c new file mode 100644 index 0000000..e0da796 --- /dev/null +++ b/stdio/asprintf.c @@ -0,0 +1,81 @@ +/* $OpenBSD: asprintf.c,v 1.4 1998/06/21 22:13:46 millert Exp $ */ + +/* + * Copyright (c) 1997 Todd C. Miller + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#if defined(LIBC_RCS) && !defined(lint) +static char rcsid[] = "$FreeBSD: src/lib/libc/stdio/asprintf.c,v 1.6 1999/08/28 00:00:55 peter Exp $"; +#endif /* LIBC_RCS and not lint */ + +#include +#include +#include +#if __STDC__ +#include +#else +#include +#endif + +int +#if __STDC__ +asprintf(char **str, char const *fmt, ...) +#else +asprintf(str, fmt, va_alist) + char **str; + const char *fmt; + va_dcl +#endif +{ + int ret; + va_list ap; + FILE f; + +#if __STDC__ + va_start(ap, fmt); +#else + va_start(ap); +#endif + f._file = -1; + f._flags = __SWR | __SSTR | __SALC; + f._bf._base = f._p = (unsigned char *)malloc(128); + if (f._bf._base == NULL) { + *str = NULL; + errno = ENOMEM; + return (-1); + } + f._bf._size = f._w = 127; /* Leave room for the NULL */ + ret = vfprintf(&f, fmt, ap); + *f._p = '\0'; + va_end(ap); + f._bf._base = reallocf(f._bf._base, f._bf._size + 1); + if (f._bf._base == NULL) { + errno = ENOMEM; + ret = -1; + } + *str = (char *)f._bf._base; + return (ret); +} diff --git a/stdio.subproj/clrerr.c b/stdio/clrerr.c similarity index 100% rename from stdio.subproj/clrerr.c rename to stdio/clrerr.c diff --git a/stdio/fclose.3 b/stdio/fclose.3 new file mode 100644 index 0000000..5dded81 --- /dev/null +++ b/stdio/fclose.3 @@ -0,0 +1,99 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)fclose.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdio/fclose.3,v 1.11 2001/10/01 16:08:58 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt FCLOSE 3 +.Os +.Sh NAME +.Nm fclose +.Nd close a stream +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.Ft int +.Fn fclose "FILE *stream" +.Sh DESCRIPTION +The +.Fn fclose +function +dissociates the named +.Fa stream +from its underlying file or set of functions. +If the stream was being used for output, any buffered data is written +first, using +.Xr fflush 3 . +.Sh RETURN VALUES +Upon successful completion 0 is returned. +Otherwise, +.Dv EOF +is returned and the global variable +.Va errno +is set to indicate the error. +In either case no further access to the stream is possible. +.Sh ERRORS +The +.Fn fclose +function +may also fail and set +.Va errno +for any of the errors specified for the routines +.Xr close 2 +or +.Xr fflush 3 . +.Sh NOTES +.Fn fclose +does not handle NULL arguments; they will result in a segmentation +violation. +This is intentional - it makes it easier to make sure programs written +under +.Fx +are bug free. +This behaviour is an implementation detail, and programs should not +rely upon it. +.Sh SEE ALSO +.Xr close 2 , +.Xr fflush 3 , +.Xr fopen 3 , +.Xr setbuf 3 +.Sh STANDARDS +The +.Fn fclose +function +conforms to +.St -isoC . diff --git a/stdio.subproj/fclose.c b/stdio/fclose.c similarity index 100% rename from stdio.subproj/fclose.c rename to stdio/fclose.c diff --git a/stdio.subproj/fdopen.c b/stdio/fdopen.c similarity index 100% rename from stdio.subproj/fdopen.c rename to stdio/fdopen.c diff --git a/stdio.subproj/feof.c b/stdio/feof.c similarity index 100% rename from stdio.subproj/feof.c rename to stdio/feof.c diff --git a/stdio/ferror.3 b/stdio/ferror.3 new file mode 100644 index 0000000..ff8b1f6 --- /dev/null +++ b/stdio/ferror.3 @@ -0,0 +1,103 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)ferror.3 8.2 (Berkeley) 4/19/94 +.\" $FreeBSD: src/lib/libc/stdio/ferror.3,v 1.6 2001/10/01 16:08:59 ru Exp $ +.\" +.Dd April 19, 1994 +.Dt FERROR 3 +.Os +.Sh NAME +.Nm clearerr , +.Nm feof , +.Nm ferror , +.Nm fileno +.Nd check and reset stream status +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.Ft void +.Fn clearerr "FILE *stream" +.Ft int +.Fn feof "FILE *stream" +.Ft int +.Fn ferror "FILE *stream" +.Ft int +.Fn fileno "FILE *stream" +.Sh DESCRIPTION +The function +.Fn clearerr +clears the end-of-file and error indicators for the stream pointed +to by +.Fa stream . +.Pp +The function +.Fn feof +tests the end-of-file indicator for the stream pointed to by +.Fa stream , +returning non-zero if it is set. +The end-of-file indicator can only be cleared by the function +.Fn clearerr . +.Pp +The function +.Fn ferror +tests the error indicator for the stream pointed to by +.Fa stream , +returning non-zero if it is set. +The error indicator can only be reset by the +.Fn clearerr +function. +.Pp +The function +.Fn fileno +examines the argument +.Fa stream +and returns its integer descriptor. +.Sh ERRORS +These functions should not fail and do not set the external +variable +.Va errno . +.Sh SEE ALSO +.Xr open 2 , +.Xr stdio 3 +.Sh STANDARDS +The functions +.Fn clearerr , +.Fn feof , +and +.Fn ferror +conform to +.St -isoC . diff --git a/stdio.subproj/ferror.c b/stdio/ferror.c similarity index 100% rename from stdio.subproj/ferror.c rename to stdio/ferror.c diff --git a/stdio/fflush.3 b/stdio/fflush.3 new file mode 100644 index 0000000..37c7dcd --- /dev/null +++ b/stdio/fflush.3 @@ -0,0 +1,113 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)fflush.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdio/fflush.3,v 1.8 2001/10/01 16:08:59 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt FFLUSH 3 +.Os +.Sh NAME +.Nm fflush , +.Nm fpurge +.Nd flush a stream +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.Ft int +.Fn fflush "FILE *stream" +.Ft int +.Fn fpurge "FILE *stream" +.Sh DESCRIPTION +The function +.Fn fflush +forces a write of all buffered data for the given output or update +.Fa stream +via the stream's underlying write function. +The open status of the stream is unaffected. +.Pp +If the +.Fa stream +argument is +.Dv NULL , +.Fn fflush +flushes +.Em all +open output streams. +.Pp +The function +.Fn fpurge +erases any input or output buffered in the given +.Fa stream . +For output streams this discards any unwritten output. +For input streams this discards any input read from the underlying object +but not yet obtained via +.Xr getc 3 ; +this includes any text pushed back via +.Xr ungetc . +.Sh RETURN VALUES +Upon successful completion 0 is returned. +Otherwise, +.Dv EOF +is returned and the global variable +.Va errno +is set to indicate the error. +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er EBADF +.Fa Stream +is not an open stream, or, in the case of +.Fn fflush , +not a stream open for writing. +.El +.Pp +The function +.Fn fflush +may also fail and set +.Va errno +for any of the errors specified for the routine +.Xr write 2 . +.Sh SEE ALSO +.Xr write 2 , +.Xr fclose 3 , +.Xr fopen 3 , +.Xr setbuf 3 +.Sh STANDARDS +The +.Fn fflush +function +conforms to +.St -isoC . diff --git a/stdio.subproj/fflush.c b/stdio/fflush.c similarity index 100% rename from stdio.subproj/fflush.c rename to stdio/fflush.c diff --git a/stdio.subproj/fgetc.c b/stdio/fgetc.c similarity index 100% rename from stdio.subproj/fgetc.c rename to stdio/fgetc.c diff --git a/stdio/fgetln.3 b/stdio/fgetln.3 new file mode 100644 index 0000000..e779aec --- /dev/null +++ b/stdio/fgetln.3 @@ -0,0 +1,127 @@ +.\" Copyright (c) 1990, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)fgetln.3 8.3 (Berkeley) 4/19/94 +.\" $FreeBSD: src/lib/libc/stdio/fgetln.3,v 1.7 2001/10/01 16:08:59 ru Exp $ +.\" +.Dd April 19, 1994 +.Dt FGETLN 3 +.Os +.Sh NAME +.Nm fgetln +.Nd get a line from a stream +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.Ft char * +.Fn fgetln "FILE *stream" "size_t *len" +.Sh DESCRIPTION +The +.Fn fgetln +function +returns a pointer to the next line from the stream referenced by +.Fa stream . +This line is +.Em not +a C string as it does not end with a terminating +.Dv NUL +character. +The length of the line, including the final newline, +is stored in the memory location to which +.Fa len +points. +(Note, however, that if the line is the last +in a file that does not end in a newline, +the returned text will not contain a newline.) +.Sh RETURN VALUES +Upon successful completion a pointer is returned; +this pointer becomes invalid after the next +.Tn I/O +operation on +.Fa stream +(whether successful or not) +or as soon as the stream is closed. +Otherwise, +.Dv NULL +is returned. +The +.Fn fgetln +function +does not distinguish between end-of-file and error; the routines +.Xr feof 3 +and +.Xr ferror 3 +must be used +to determine which occurred. +If an error occurs, the global variable +.Va errno +is set to indicate the error. +The end-of-file condition is remembered, even on a terminal, and all +subsequent attempts to read will return +.Dv NULL +until the condition is +cleared with +.Xr clearerr 3 . +.Pp +The text to which the returned pointer points may be modified, +provided that no changes are made beyond the returned size. +These changes are lost as soon as the pointer becomes invalid. +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er EBADF +The argument +.Fa stream +is not a stream open for reading. +.El +.Pp +The +.Fn fgetln +function +may also fail and set +.Va errno +for any of the errors specified for the routines +.Xr fflush 3 , +.Xr malloc 3 , +.Xr read 2 , +.Xr stat 2 , +or +.Xr realloc 3 . +.Sh SEE ALSO +.Xr ferror 3 , +.Xr fgets 3 , +.Xr fopen 3 , +.Xr putc 3 +.Sh HISTORY +The +.Fn fgetln +function first appeared in +.Bx 4.4 . diff --git a/stdio.subproj/fgetln.c b/stdio/fgetln.c similarity index 100% rename from stdio.subproj/fgetln.c rename to stdio/fgetln.c diff --git a/stdio.subproj/fgetpos.c b/stdio/fgetpos.c similarity index 100% rename from stdio.subproj/fgetpos.c rename to stdio/fgetpos.c diff --git a/stdio/fgets.3 b/stdio/fgets.3 new file mode 100644 index 0000000..cb808a0 --- /dev/null +++ b/stdio/fgets.3 @@ -0,0 +1,158 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)fgets.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdio/fgets.3,v 1.12 2001/10/01 16:08:59 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt FGETS 3 +.Os +.Sh NAME +.Nm fgets , +.Nm gets +.Nd get a line from a stream +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.Ft char * +.Fn fgets "char *str" "int size" "FILE *stream" +.Ft char * +.Fn gets "char *str" +.Sh DESCRIPTION +The +.Fn fgets +function +reads at most one less than the number of characters specified by +.Fa size +from the given +.Fa stream +and stores them in the string +.Fa str . +Reading stops when a newline character is found, +at end-of-file or error. +The newline, if any, is retained. +If any characters are read and there is no error, a +.Ql \e0 +character is appended to end the string. +.Pp +The +.Fn gets +function +is equivalent to +.Fn fgets +with an infinite +.Fa size +and a +.Fa stream +of +.Em stdin , +except that the newline character (if any) is not stored in the string. +It is the caller's responsibility to ensure that the input line, +if any, is sufficiently short to fit in the string. +.Sh RETURN VALUES +Upon successful completion, +.Fn fgets +and +.Fn gets +return +a pointer to the string. +If end-of-file occurs before any characters are read, +they return +.Dv NULL +and the buffer contents is unchanged. +If an error occurs, +they return +.Dv NULL +and the buffer contents is indeterminate. +The +.Fn fgets +and +.Fn gets +functions +do not distinguish between end-of-file and error, and callers must use +.Xr feof 3 +and +.Xr ferror 3 +to determine which occurred. +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er EBADF +The given +.Fa stream +is not a readable stream. +.El +.Pp +The function +.Fn fgets +may also fail and set +.Va errno +for any of the errors specified for the routines +.Xr fflush 3 , +.Xr fstat 2 , +.Xr read 2 , +or +.Xr malloc 3 . +.Pp +The function +.Fn gets +may also fail and set +.Va errno +for any of the errors specified for the routine +.Xr getchar 3 . +.Sh SEE ALSO +.Xr feof 3 , +.Xr ferror 3 , +.Xr fgetln 3 +.Sh STANDARDS +The functions +.Fn fgets +and +.Fn gets +conform to +.St -isoC . +.Sh BUGS +Since it is usually impossible to ensure that the next input line +is less than some arbitrary length, and because overflowing the +input buffer is almost invariably a security violation, programs +should +.Em NEVER +use +.Fn gets . +The +.Fn gets +function +exists purely to conform to +.St -isoC . diff --git a/stdio.subproj/fgets.c b/stdio/fgets.c similarity index 99% rename from stdio.subproj/fgets.c rename to stdio/fgets.c index 45da44e..554f485 100644 --- a/stdio.subproj/fgets.c +++ b/stdio/fgets.c @@ -67,7 +67,7 @@ char * fgets(buf, n, fp) char *buf; - register size_t n; + register int n; register FILE *fp; { register size_t len; diff --git a/stdio.subproj/fileno.c b/stdio/fileno.c similarity index 100% rename from stdio.subproj/fileno.c rename to stdio/fileno.c diff --git a/stdio.subproj/findfp.c b/stdio/findfp.c similarity index 100% rename from stdio.subproj/findfp.c rename to stdio/findfp.c diff --git a/stdio.subproj/flags.c b/stdio/flags.c similarity index 100% rename from stdio.subproj/flags.c rename to stdio/flags.c diff --git a/stdio.subproj/floatio.h b/stdio/floatio.h similarity index 100% rename from stdio.subproj/floatio.h rename to stdio/floatio.h diff --git a/stdio/fopen.3 b/stdio/fopen.3 new file mode 100644 index 0000000..cbf6234 --- /dev/null +++ b/stdio/fopen.3 @@ -0,0 +1,252 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)fopen.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdio/fopen.3,v 1.12 2001/10/01 16:08:59 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt FOPEN 3 +.Os +.Sh NAME +.Nm fopen , +.Nm fdopen , +.Nm freopen +.Nd stream open functions +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.Ft FILE * +.Fn fopen "const char *path" "const char *mode" +.Ft FILE * +.Fn fdopen "int fildes" "const char *mode" +.Ft FILE * +.Fn freopen "const char *path" "const char *mode" "FILE *stream" +.Sh DESCRIPTION +The +.Fn fopen +function +opens the file whose name is the string pointed to by +.Fa path +and associates a stream with it. +.Pp +The argument +.Fa mode +points to a string beginning with one of the following +sequences (Additional characters may follow these sequences.): +.Bl -tag -width indent +.It Dq Li r +Open text file for reading. +The stream is positioned at the beginning of the file. +.It Dq Li r+ +Open for reading and writing. +The stream is positioned at the beginning of the file. +.It Dq Li w +Truncate file to zero length or create text file for writing. +The stream is positioned at the beginning of the file. +.It Dq Li w+ +Open for reading and writing. +The file is created if it does not exist, otherwise it is truncated. +The stream is positioned at the beginning of the file. +.It Dq Li a +Open for writing. +The file is created if it does not exist. +The stream is positioned at the end of the file. +Subsequent writes to the file will always end up at the then current +end of file, irrespective of any intervening +.Xr fseek 3 +or similar. +.It Dq Li a+ +Open for reading and writing. +The file is created if it does not exist. +The stream is positioned at the end of the file. +Subsequent writes to the file will always end up at the then current +end of file, irrespective of any intervening +.Xr fseek 3 +or similar. +.El +.Pp +The +.Fa mode +string can also include the letter ``b'' either as a third character or +as a character between the characters in any of the two-character strings +described above. +This is strictly for compatibility with +.St -isoC +and has no effect; the ``b'' is ignored. +.Pp +Any created files will have mode +.Pf \\*q Dv S_IRUSR +\&| +.Dv S_IWUSR +\&| +.Dv S_IRGRP +\&| +.Dv S_IWGRP +\&| +.Dv S_IROTH +\&| +.Dv S_IWOTH Ns \\*q +.Pq Li 0666 , +as modified by the process' +umask value (see +.Xr umask 2 ) . +.Pp +Reads and writes may be intermixed on read/write streams in any order, +and do not require an intermediate seek as in previous versions of +.Em stdio . +This is not portable to other systems, however; +.Tn ANSI C +requires that +a file positioning function intervene between output and input, unless +an input operation encounters end-of-file. +.Pp +The +.Fn fdopen +function associates a stream with the existing file descriptor, +.Fa fildes . +The +.Fa mode +of the stream must be compatible with the mode of the file descriptor. +When the stream is closed via +.Xr fclose 3 , +.Fa fildes +is closed also. +.Pp +The +.Fn freopen +function +opens the file whose name is the string pointed to by +.Fa path +and associates the stream pointed to by +.Fa stream +with it. +The original stream (if it exists) is closed. +The +.Fa mode +argument is used just as in the +.Fn fopen +function. +The primary use of the +.Fn freopen +function +is to change the file associated with a +standard text stream +.Pf ( Em stderr , +.Em stdin , +or +.Em stdout ) . +.Sh RETURN VALUES +Upon successful completion +.Fn fopen , +.Fn fdopen +and +.Fn freopen +return a +.Tn FILE +pointer. +Otherwise, +.Dv NULL +is returned and the global variable +.Va errno +is set to indicate the error. +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er EINVAL +The +.Fa mode +provided to +.Fn fopen , +.Fn fdopen , +or +.Fn freopen +was invalid. +.El +.Pp +The +.Fn fopen , +.Fn fdopen +and +.Fn freopen +functions +may also fail and set +.Va errno +for any of the errors specified for the routine +.Xr malloc 3 . +.Pp +The +.Fn fopen +function +may also fail and set +.Va errno +for any of the errors specified for the routine +.Xr open 2 . +.Pp +The +.Fn fdopen +function +may also fail and set +.Va errno +for any of the errors specified for the routine +.Xr fcntl 2 . +.Pp +The +.Fn freopen +function +may also fail and set +.Va errno +for any of the errors specified for the routines +.Xr open 2 , +.Xr fclose 3 +and +.Xr fflush 3 . +.Sh SEE ALSO +.Xr open 2 , +.Xr fclose 3 , +.Xr fseek 3 , +.Xr funopen 3 +.Sh STANDARDS +The +.Fn fopen +and +.Fn freopen +functions +conform to +.St -isoC . +The +.Fn fdopen +function +conforms to +.St -p1003.1-88 . diff --git a/stdio.subproj/fopen.c b/stdio/fopen.c similarity index 100% rename from stdio.subproj/fopen.c rename to stdio/fopen.c diff --git a/stdio.subproj/fprintf.c b/stdio/fprintf.c similarity index 100% rename from stdio.subproj/fprintf.c rename to stdio/fprintf.c diff --git a/stdio.subproj/fpurge.c b/stdio/fpurge.c similarity index 100% rename from stdio.subproj/fpurge.c rename to stdio/fpurge.c diff --git a/stdio.subproj/fputc.c b/stdio/fputc.c similarity index 100% rename from stdio.subproj/fputc.c rename to stdio/fputc.c diff --git a/stdio/fputs.3 b/stdio/fputs.3 new file mode 100644 index 0000000..4702017 --- /dev/null +++ b/stdio/fputs.3 @@ -0,0 +1,110 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)fputs.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdio/fputs.3,v 1.8 2001/10/01 16:08:59 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt FPUTS 3 +.Os +.Sh NAME +.Nm fputs , +.Nm puts +.Nd output a line to a stream +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.Ft int +.Fn fputs "const char *str" "FILE *stream" +.Ft int +.Fn puts "const char *str" +.Sh DESCRIPTION +The function +.Fn fputs +writes the string pointed to by +.Fa str +to the stream pointed to by +.Fa stream . +.\" The terminating +.\" .Dv NUL +.\" character is not written. +.Pp +The function +.Fn puts +writes the string +.Fa str , +and a terminating newline character, +to the stream +.Em stdout . +.Sh RETURN VALUES +The +.Fn fputs +function +returns 0 on success and +.Dv EOF +on error; +.Fn puts +returns a nonnegative integer on success and +.Dv EOF +on error. +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er EBADF +The +.Fa stream +supplied +is not a writable stream. +.El +.Pp +The functions +.Fn fputs +and +.Fn puts +may also fail and set +.Va errno +for any of the errors specified for the routines +.Xr write 2 . +.Sh SEE ALSO +.Xr ferror 3 , +.Xr putc 3 , +.Xr stdio 3 +.Sh STANDARDS +The functions +.Fn fputs +and +.Fn puts +conform to +.St -isoC . diff --git a/stdio.subproj/fputs.c b/stdio/fputs.c similarity index 100% rename from stdio.subproj/fputs.c rename to stdio/fputs.c diff --git a/stdio/fread.3 b/stdio/fread.3 new file mode 100644 index 0000000..16cebfc --- /dev/null +++ b/stdio/fread.3 @@ -0,0 +1,109 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)fread.3 8.2 (Berkeley) 3/8/94 +.\" $FreeBSD: src/lib/libc/stdio/fread.3,v 1.8 2001/10/01 16:08:59 ru Exp $ +.\" +.Dd March 8, 1994 +.Dt FREAD 3 +.Os +.Sh NAME +.Nm fread , +.Nm fwrite +.Nd binary stream input/output +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.Ft size_t +.Fn fread "void *ptr" "size_t size" "size_t nmemb" "FILE *stream" +.Ft size_t +.Fn fwrite "const void *ptr" "size_t size" "size_t nmemb" "FILE *stream" +.Sh DESCRIPTION +The function +.Fn fread +reads +.Fa nmemb +objects, each +.Fa size +bytes long, from the stream pointed to by +.Fa stream , +storing them at the location given by +.Fa ptr . +.Pp +The function +.Fn fwrite +writes +.Fa nmemb +objects, each +.Fa size +bytes long, to the stream pointed to by +.Fa stream , +obtaining them from the location given by +.Fa ptr . +.Sh RETURN VALUES +The functions +.Fn fread +and +.Fn fwrite +advance the file position indicator for the stream +by the number of bytes read or written. +They return the number of objects read or written. +If an error occurs, or the end-of-file is reached, +the return value is a short object count (or zero). +.Pp +The function +.Fn fread +does not distinguish between end-of-file and error, and callers +must use +.Xr feof 3 +and +.Xr ferror 3 +to determine which occurred. +The function +.Fn fwrite +returns a value less than +.Fa nmemb +only if a write error has occurred. +.Sh SEE ALSO +.Xr read 2 , +.Xr write 2 +.Sh STANDARDS +The functions +.Fn fread +and +.Fn fwrite +conform to +.St -isoC . diff --git a/stdio.subproj/fread.c b/stdio/fread.c similarity index 100% rename from stdio.subproj/fread.c rename to stdio/fread.c diff --git a/stdio.subproj/freopen.c b/stdio/freopen.c similarity index 100% rename from stdio.subproj/freopen.c rename to stdio/freopen.c diff --git a/stdio.subproj/fscanf.c b/stdio/fscanf.c similarity index 100% rename from stdio.subproj/fscanf.c rename to stdio/fscanf.c diff --git a/stdio/fseek.3 b/stdio/fseek.3 new file mode 100644 index 0000000..7343c96 --- /dev/null +++ b/stdio/fseek.3 @@ -0,0 +1,252 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)fseek.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdio/fseek.3,v 1.19 2001/10/01 16:08:59 ru Exp $ +.\" +.Dd March 5, 1999 +.Dt FSEEK 3 +.Os +.Sh NAME +.Nm fgetpos , +.Nm fseek , +.Nm fseeko , +.Nm fsetpos , +.Nm ftell , +.Nm ftello , +.Nm rewind +.Nd reposition a stream +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.Ft int +.Fn fseek "FILE *stream" "long offset" "int whence" +.Ft long +.Fn ftell "FILE *stream" +.Ft void +.Fn rewind "FILE *stream" +.Ft int +.Fn fgetpos "FILE *stream" "fpos_t *pos" +.Ft int +.Fn fsetpos "FILE *stream" "const fpos_t *pos" +.In sys/types.h +.Ft int +.Fn fseeko "FILE *stream" "off_t offset" "int whence" +.Ft off_t +.Fn ftello "FILE *stream" +.Sh DESCRIPTION +The +.Fn fseek +function sets the file position indicator for the stream pointed +to by +.Fa stream . +The new position, measured in bytes, is obtained by adding +.Fa offset +bytes to the position specified by +.Fa whence . +If +.Fa whence +is set to +.Dv SEEK_SET , +.Dv SEEK_CUR , +or +.Dv SEEK_END , +the offset is relative to the +start of the file, the current position indicator, or end-of-file, +respectively. +A successful call to the +.Fn fseek +function clears the end-of-file indicator for the stream and undoes +any effects of the +.Xr ungetc 3 +function on the same stream. +.Pp +The +.Fn ftell +function +obtains the current value of the file position indicator for the +stream pointed to by +.Fa stream . +.Pp +The +.Fn rewind +function sets the file position indicator for the stream pointed +to by +.Fa stream +to the beginning of the file. +It is equivalent to: +.Pp +.Dl (void)fseek(stream, 0L, SEEK_SET) +.Pp +except that the error indicator for the stream is also cleared +(see +.Xr clearerr 3 ) . +.Pp +Since +.Fn rewind +does not return a value, +an application wishing to detect errors should clear +.Va errno , +then call +.Fn rewind , +and if +.Va errno +is non-zero, assume an error has occurred. +.Pp +The +.Fn fseeko +function is identical to +.Fn fseek , +except it takes an +.Fa off_t +argument +instead of a +.Fa long . +Likewise, the +.Fn ftello +function is identical to +.Fn ftell , +except it returns an +.Fa off_t . +.Pp +The +.Fn fgetpos +and +.Fn fsetpos +functions +are alternate interfaces equivalent to +.Fn ftell +and +.Fn fseek +(with whence set to +.Dv SEEK_SET ) , +setting and storing the current value of +the file offset into or from the object referenced by +.Fa pos . +On some +.Pq non- Ns Tn UNIX +systems an +.Dq Fa fpos_t +object may be a complex object +and these routines may be the only way to portably reposition a text stream. +.Sh RETURN VALUES +The +.Fn rewind +function +returns no value. +.Pp +.Rv -std fgetpos fseek fseeko fsetpos +.Pp +Upon successful completion, +.Fn ftell +and +.Fn ftello +return the current offset. +Otherwise, \-1 is returned and the global variable +.Va errno +is set to indicate the error. +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er EBADF +The +.Fa stream +specified +is not a seekable stream. +.It Bq Er EINVAL +The +.Fa whence +argument is invalid or +the resulting file-position +indicator would be set to a negative value. +.It Bq Er EOVERFLOW +The resulting file offset would be a value which +cannot be represented correctly in an object of type +.Fa off_t +for +.Fn fseeko +and +.Fn ftello +or +.Fa long +for +.Fn fseek +and +.Fn ftell . +.It Bq Er ESPIPE +The file descriptor underlying stream is associated with a pipe or FIFO +or file-position indicator value is unspecified +(see +.Xr ungetc 3 ) . +.El +.Pp +The functions +.Fn fgetpos , +.Fn fseek , +.Fn fseeko , +.Fn fsetpos , +.Fn ftell , +and +.Fn ftello +may also fail and set +.Va errno +for any of the errors specified for the routines +.Xr fflush 3 , +.Xr fstat 2 , +.Xr lseek 2 , +and +.Xr malloc 3 . +.Sh SEE ALSO +.Xr lseek 2 , +.Xr clearerr 3 , +.Xr ungetc 3 +.Sh STANDARDS +The +.Fn fgetpos , +.Fn fsetpos , +.Fn fseek , +.Fn ftell , +and +.Fn rewind +functions +conform to +.St -isoC . +.Pp +The +.Fn fseeko +and +.Fn ftello +functions conform to +.St -susv2 . diff --git a/stdio.subproj/fseek.c b/stdio/fseek.c similarity index 100% rename from stdio.subproj/fseek.c rename to stdio/fseek.c diff --git a/stdio.subproj/fsetpos.c b/stdio/fsetpos.c similarity index 100% rename from stdio.subproj/fsetpos.c rename to stdio/fsetpos.c diff --git a/stdio.subproj/ftell.c b/stdio/ftell.c similarity index 100% rename from stdio.subproj/ftell.c rename to stdio/ftell.c diff --git a/stdio/funopen.3 b/stdio/funopen.3 new file mode 100644 index 0000000..ad5603e --- /dev/null +++ b/stdio/funopen.3 @@ -0,0 +1,172 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek. +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)funopen.3 8.1 (Berkeley) 6/9/93 +.\" $FreeBSD: src/lib/libc/stdio/funopen.3,v 1.12 2001/10/01 16:08:59 ru Exp $ +.\" +.Dd June 9, 1993 +.Dt FUNOPEN 3 +.Os +.Sh NAME +.Nm funopen , +.Nm fropen , +.Nm fwopen +.Nd open a stream +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.Ft FILE * +.Fn funopen "const void *cookie" "int (*readfn)(void *, char *, int)" "int (*writefn)(void *, const char *, int)" "fpos_t (*seekfn)(void *, fpos_t, int)" "int (*closefn)(void *)" +.Ft FILE * +.Fn fropen "void *cookie" "int (*readfn)(void *, char *, int)" +.Ft FILE * +.Fn fwopen "void *cookie" "int (*writefn)(void *, const char *, int)" +.Sh DESCRIPTION +The +.Fn funopen +function +associates a stream with up to four +.Dq Tn I/O No functions . +Either +.Fa readfn +or +.Fa writefn +must be specified; +the others can be given as an appropriately-typed +.Dv NULL +pointer. +These +.Tn I/O +functions will be used to read, write, seek and +close the new stream. +.Pp +In general, omitting a function means that any attempt to perform the +associated operation on the resulting stream will fail. +If the close function is omitted, closing the stream will flush +any buffered output and then succeed. +.Pp +The calling conventions of +.Fa readfn , +.Fa writefn , +.Fa seekfn +and +.Fa closefn +must match those, respectively, of +.Xr read 2 , +.Xr write 2 , +.Xr lseek 2 , +and +.Xr close 2 +with the single exception that they are passed the +.Fa cookie +argument specified to +.Fn funopen +in place of the traditional file descriptor argument. +.Pp +Read and write +.Tn I/O +functions are allowed to change the underlying buffer +on fully buffered or line buffered streams by calling +.Xr setvbuf 3 . +They are also not required to completely fill or empty the buffer. +They are not, however, allowed to change streams from unbuffered to buffered +or to change the state of the line buffering flag. +They must also be prepared to have read or write calls occur on buffers other +than the one most recently specified. +.Pp +All user +.Tn I/O +functions can report an error by returning \-1. +Additionally, all of the functions should set the external variable +.Va errno +appropriately if an error occurs. +.Pp +An error on +.Fn closefn +does not keep the stream open. +.Pp +As a convenience, the include file +.Aq Pa stdio.h +defines the macros +.Fn fropen +and +.Fn fwopen +as calls to +.Fn funopen +with only a read or write function specified. +.Sh RETURN VALUES +Upon successful completion, +.Fn funopen +returns a +.Dv FILE +pointer. +Otherwise, +.Dv NULL +is returned and the global variable +.Va errno +is set to indicate the error. +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er EINVAL +The +.Fn funopen +function +was called without either a read or write function. +The +.Fn funopen +function +may also fail and set +.Va errno +for any of the errors +specified for the routine +.Xr malloc 3 . +.El +.Sh SEE ALSO +.Xr fcntl 2 , +.Xr open 2 , +.Xr fclose 3 , +.Xr fopen 3 , +.Xr fseek 3 , +.Xr setbuf 3 +.Sh HISTORY +The +.Fn funopen +functions first appeared in +.Bx 4.4 . +.Sh BUGS +The +.Fn funopen +function +may not be portable to systems other than +.Bx . diff --git a/stdio.subproj/funopen.c b/stdio/funopen.c similarity index 100% rename from stdio.subproj/funopen.c rename to stdio/funopen.c diff --git a/stdio.subproj/fvwrite.c b/stdio/fvwrite.c similarity index 84% rename from stdio.subproj/fvwrite.c rename to stdio/fvwrite.c index f7d2c86..b316854 100644 --- a/stdio.subproj/fvwrite.c +++ b/stdio/fvwrite.c @@ -1,25 +1,4 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ -/* +/*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * @@ -55,8 +34,16 @@ * SUCH DAMAGE. */ +#if defined(LIBC_SCCS) && !defined(lint) +#if 0 +static char sccsid[] = "@(#)fvwrite.c 8.1 (Berkeley) 6/4/93"; +#endif +static const char rcsid[] = + "$FreeBSD: src/lib/libc/stdio/fvwrite.c,v 1.10 1999/08/28 00:01:06 peter Exp $"; +#endif /* LIBC_SCCS and not lint */ #include +#include #include #include "local.h" #include "fvwrite.h" @@ -125,13 +112,31 @@ __sfvwrite(fp, uio) */ do { GETIOV(;); + if ((fp->_flags & (__SALC | __SSTR)) == + (__SALC | __SSTR) && fp->_w < len) { + size_t blen = fp->_p - fp->_bf._base; + + /* + * Alloc an extra 128 bytes (+ 1 for NULL) + * so we don't call realloc(3) so often. + */ + fp->_w = len + 128; + fp->_bf._size = blen + len + 128; + fp->_bf._base = + reallocf(fp->_bf._base, fp->_bf._size + 1); + if (fp->_bf._base == NULL) + goto err; + fp->_p = fp->_bf._base + blen; + } w = fp->_w; if (fp->_flags & __SSTR) { if (len < w) w = len; - COPY(w); /* copy MIN(fp->_w,len), */ - fp->_w -= w; - fp->_p += w; + if (w > 0) { + COPY(w); /* copy MIN(fp->_w,len), */ + fp->_w -= w; + fp->_p += w; + } w = len; /* but pretend copied all */ } else if (fp->_p > fp->_bf._base && len > w) { /* fill and flush */ diff --git a/stdio/fvwrite.h b/stdio/fvwrite.h new file mode 100644 index 0000000..ec6bc0b --- /dev/null +++ b/stdio/fvwrite.h @@ -0,0 +1,56 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)fvwrite.h 8.1 (Berkeley) 6/4/93 + */ + +/* + * I/O descriptors for __sfvwrite(). + */ +struct __siov { + void *iov_base; + size_t iov_len; +}; +struct __suio { + struct __siov *uio_iov; + int uio_iovcnt; + int uio_resid; +}; + +#if __STDC__ || c_plusplus +extern int __sfvwrite(FILE *, struct __suio *); +#else +extern int __sfvwrite(); +#endif diff --git a/stdio.subproj/fwalk.c b/stdio/fwalk.c similarity index 100% rename from stdio.subproj/fwalk.c rename to stdio/fwalk.c diff --git a/stdio.subproj/fwrite.c b/stdio/fwrite.c similarity index 100% rename from stdio.subproj/fwrite.c rename to stdio/fwrite.c diff --git a/stdio/getc.3 b/stdio/getc.3 new file mode 100644 index 0000000..3db3eca --- /dev/null +++ b/stdio/getc.3 @@ -0,0 +1,139 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)getc.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdio/getc.3,v 1.11 2001/10/01 16:08:59 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt GETC 3 +.Os +.Sh NAME +.Nm fgetc , +.Nm getc , +.Nm getchar , +.Nm getw +.Nd get next character or word from input stream +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.Ft int +.Fn fgetc "FILE *stream" +.Ft int +.Fn getc "FILE *stream" +.Ft int +.Fn getchar +.Ft int +.Fn getw "FILE *stream" +.Sh DESCRIPTION +The +.Fn fgetc +function +obtains the next input character (if present) from the stream pointed at by +.Fa stream , +or the next character pushed back on the stream via +.Xr ungetc 3 . +.Pp +The +.Fn getc +function +acts essentially identically to +.Fn fgetc , +but is a macro that expands in-line. +.Pp +The +.Fn getchar +function +is equivalent to +.Fn getc stdin . +.Pp +The +.Fn getw +function +obtains the next +.Em int +(if present) +from the stream pointed at by +.Fa stream . +.Sh RETURN VALUES +If successful, these routines return the next requested object +from the +.Fa stream . +If the stream is at end-of-file or a read error occurs, +the routines return +.Dv EOF . +The routines +.Xr feof 3 +and +.Xr ferror 3 +must be used to distinguish between end-of-file and error. +If an error occurs, the global variable +.Va errno +is set to indicate the error. +The end-of-file condition is remembered, even on a terminal, and all +subsequent attempts to read will return +.Dv EOF +until the condition is cleared with +.Xr clearerr 3 . +.Sh SEE ALSO +.Xr ferror 3 , +.Xr fopen 3 , +.Xr fread 3 , +.Xr putc 3 , +.Xr ungetc 3 +.Sh STANDARDS +The +.Fn fgetc , +.Fn getc +and +.Fn getchar +functions +conform to +.St -isoC . +.Sh BUGS +Since +.Dv EOF +is a valid integer value, +.Xr feof 3 +and +.Xr ferror 3 +must be used to check for failure after calling +.Fn getw . +The size and byte order of an +.Em int +varies from one machine to another, and +.Fn getw +is not recommended for portable applications. +.Pp diff --git a/stdio.subproj/getc.c b/stdio/getc.c similarity index 100% rename from stdio.subproj/getc.c rename to stdio/getc.c diff --git a/stdio.subproj/getchar.c b/stdio/getchar.c similarity index 100% rename from stdio.subproj/getchar.c rename to stdio/getchar.c diff --git a/stdio.subproj/gets.c b/stdio/gets.c similarity index 100% rename from stdio.subproj/gets.c rename to stdio/gets.c diff --git a/stdio.subproj/getw.c b/stdio/getw.c similarity index 100% rename from stdio.subproj/getw.c rename to stdio/getw.c diff --git a/stdio.subproj/glue.h b/stdio/glue.h similarity index 100% rename from stdio.subproj/glue.h rename to stdio/glue.h diff --git a/stdio.subproj/local.h b/stdio/local.h similarity index 100% rename from stdio.subproj/local.h rename to stdio/local.h diff --git a/stdio.subproj/makebuf.c b/stdio/makebuf.c similarity index 100% rename from stdio.subproj/makebuf.c rename to stdio/makebuf.c diff --git a/stdio/mktemp.3 b/stdio/mktemp.3 new file mode 100644 index 0000000..b19d61f --- /dev/null +++ b/stdio/mktemp.3 @@ -0,0 +1,246 @@ +.\" Copyright (c) 1989, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)mktemp.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdio/mktemp.3,v 1.17 2001/10/01 16:08:59 ru Exp $ +.\" +.Dd February 11, 1998 +.Dt MKTEMP 3 +.Os +.Sh NAME +.Nm mktemp +.Nd make temporary file name (unique) +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft char * +.Fn mktemp "char *template" +.Ft int +.Fn mkstemp "char *template" +.Ft int +.Fn mkstemps "char *template" "int suffixlen" +.Ft char * +.Fn mkdtemp "char *template" +.Sh DESCRIPTION +The +.Fn mktemp +function +takes the given file name template and overwrites a portion of it +to create a file name. +This file name is guaranteed not to exist at the time of function invocation +and is suitable for use +by the application. +The template may be any file name with some number of +.Ql X Ns s +appended +to it, for example +.Pa /tmp/temp.XXXXXX . +The trailing +.Ql X Ns s +are replaced with a +unique alphanumeric combination. +The number of unique file names +.Fn mktemp +can return depends on the number of +.Ql X Ns s +provided; six +.Ql X Ns s +will +result in +.Fn mktemp +selecting one of 56800235584 (62 ** 6) possible temporary file names. +.Pp +The +.Fn mkstemp +function +makes the same replacement to the template and creates the template file, +mode 0600, returning a file descriptor opened for reading and writing. +This avoids the race between testing for a file's existence and opening it +for use. +.Pp +The +.Fn mkstemps +function acts the same as +.Fn mkstemp , +except it permits a suffix to exist in the template. +The template should be of the form +.Pa /tmp/tmpXXXXXXsuffix . +.Fn mkstemps +is told the length of the suffix string. +.Pp +The +.Fn mkdtemp +function makes the same replacement to the template as in +.Xr mktemp 3 +and creates the template directory, mode 0700. +.Sh RETURN VALUES +The +.Fn mktemp +and +.Fn mkdtemp +functions return a pointer to the template on success and +.Dv NULL +on failure. +The +.Fn mkstemp +and +.Fn mkstemps +functions +return \-1 if no suitable file could be created. +If either call fails an error code is placed in the global variable +.Va errno . +.Sh ERRORS +The +.Fn mkstemp , +.Fn mkstemps +and +.Fn mkdtemp +functions +may set +.Va errno +to one of the following values: +.Bl -tag -width Er +.It Bq Er ENOTDIR +The pathname portion of the template is not an existing directory. +.El +.Pp +The +.Fn mkstemp , +.Fn mkstemps +and +.Fn mkdtemp +functions +may also set +.Va errno +to any value specified by the +.Xr stat 2 +function. +.Pp +The +.Fn mkstemp +and +.Fn mkstemps +functions +may also set +.Va errno +to any value specified by the +.Xr open 2 +function. +.Pp +The +.Fn mkdtemp +function +may also set +.Va errno +to any value specified by the +.Xr mkdir 2 +function. +.Sh NOTES +A common problem that results in a core dump is that the programmer +passes in a read-only string to +.Fn mktemp , +.Fn mkstemp , +.Fn mkstemps +or +.Fn mkdtemp . +This is common with programs that were developed before +.St -isoC +compilers were common. +For example, calling +.Fn mkstemp +with an argument of +.Qq /tmp/tempfile.XXXXXX +will result in a core dump due to +.Fn mkstemp +attempting to modify the string constant that was given. +If the program in question makes heavy use of that type +of function call, you do have the option of compiling the program +so that it will store string constants in a writable segment of memory. +See +.Xr gcc 1 +for more information. +.Sh BUGS +This family of functions produces filenames which can be guessed, +though the risk is minimized when large numbers of +.Ql X Ns s +are used to +increase the number of possible temporary filenames. +This makes the race in +.Fn mktemp , +between testing for a file's existence (in the +.Fn mktemp +function call) +and opening it for use +(later in the user application) +particularly dangerous from a security perspective. +Whenever it is possible, +.Fn mkstemp +should be used instead, since it does not have the race condition. +If +.Fn mkstemp +cannot be used, the filename created by +.Fn mktemp +should be created using the +.Dv O_EXCL +flag to +.Xr open 2 +and the return status of the call should be tested for failure. +This will ensure that the program does not continue blindly +in the event that an attacker has already created the file +with the intention of manipulating or reading its contents. +.Sh SEE ALSO +.Xr chmod 2 , +.Xr getpid 2 , +.Xr mkdir 2 , +.Xr open 2 , +.Xr stat 2 +.Sh HISTORY +A +.Fn mktemp +function appeared in +.At v7 . +The +.Fn mkstemp +function appeared in +.Bx 4.4 . +The +.Fn mkdtemp +function first appeared in +.Ox 2.2 , +and later in +.Fx 3.2 . +The +.Fn mkstemps +function first appeared in +.Ox 2.4 , +and later in +.Fx 3.4 . diff --git a/stdio/mktemp.c b/stdio/mktemp.c new file mode 100644 index 0000000..c044a67 --- /dev/null +++ b/stdio/mktemp.c @@ -0,0 +1,186 @@ +/* + * Copyright (c) 1987, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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) +#if 0 +static char sccsid[] = "@(#)mktemp.c 8.1 (Berkeley) 6/4/93"; +#endif +static const char rcsid[] = + "$FreeBSD: src/lib/libc/stdio/mktemp.c,v 1.19.2.1 2001/01/20 09:35:24 kris Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +char *_mktemp __P((char *)); + +static int _gettemp __P((char *, int *, int, int)); + +static const unsigned char padchar[] = +"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + +int +mkstemps(path, slen) + char *path; + int slen; +{ + int fd; + + return (_gettemp(path, &fd, 0, slen) ? fd : -1); +} + +int +mkstemp(path) + char *path; +{ + int fd; + + return (_gettemp(path, &fd, 0, 0) ? fd : -1); +} + +char * +mkdtemp(path) + char *path; +{ + return(_gettemp(path, (int *)NULL, 1, 0) ? path : (char *)NULL); +} + +char * +_mktemp(path) + char *path; +{ + return(_gettemp(path, (int *)NULL, 0, 0) ? path : (char *)NULL); +} + +char * +mktemp(path) + char *path; +{ + return(_mktemp(path)); +} + +static int +_gettemp(path, doopen, domkdir, slen) + char *path; + register int *doopen; + int domkdir; + int slen; +{ + register char *start, *trv, *suffp; + char *pad; + struct stat sbuf; + int rval; + uint32_t rand; + + if (doopen && domkdir) { + errno = EINVAL; + return(0); + } + + for (trv = path; *trv; ++trv) + ; + trv -= slen; + suffp = trv; + --trv; + if (trv < path) { + errno = EINVAL; + return (0); + } + + /* Fill space with random characters */ + while (trv >= path && *trv == 'X') { + rand = arc4random() % (sizeof(padchar) - 1); + *trv-- = padchar[rand]; + } + start = trv + 1; + + /* + * check the target directory. + */ + if (doopen || domkdir) { + for (;; --trv) { + if (trv <= path) + break; + if (*trv == '/') { + *trv = '\0'; + rval = stat(path, &sbuf); + *trv = '/'; + if (rval != 0) + return(0); + if (!S_ISDIR(sbuf.st_mode)) { + errno = ENOTDIR; + return(0); + } + break; + } + } + } + + for (;;) { + if (doopen) { + if ((*doopen = + open(path, O_CREAT|O_EXCL|O_RDWR, 0600)) >= 0) + return(1); + if (errno != EEXIST) + return(0); + } else if (domkdir) { + if (mkdir(path, 0700) == 0) + return(1); + if (errno != EEXIST) + return(0); + } else if (lstat(path, &sbuf)) + return(errno == ENOENT ? 1 : 0); + + /* If we have a collision, cycle through the space of filenames */ + for (trv = start;;) { + if (*trv == '\0' || trv == suffp) + return(0); + pad = strchr(padchar, *trv); + if (pad == NULL || !*++pad) + *trv++ = padchar[0]; + else { + *trv++ = *pad; + break; + } + } + } + /*NOTREACHED*/ +} diff --git a/stdio.subproj/perror.c b/stdio/perror.c similarity index 100% rename from stdio.subproj/perror.c rename to stdio/perror.c diff --git a/stdio/printf.3 b/stdio/printf.3 new file mode 100644 index 0000000..dacf1d4 --- /dev/null +++ b/stdio/printf.3 @@ -0,0 +1,643 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)printf.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdio/printf.3,v 1.17.2.10 2001/12/14 18:33:57 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt PRINTF 3 +.Os +.Sh NAME +.Nm printf , fprintf , sprintf , snprintf , asprintf , +.Nm vprintf , vfprintf, vsprintf , vsnprintf , vasprintf +.Nd formatted output conversion +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.Ft int +.Fn printf "const char *format" ... +.Ft int +.Fn fprintf "FILE *stream" "const char *format" ... +.Ft int +.Fn sprintf "char *str" "const char *format" ... +.Ft int +.Fn snprintf "char *str" "size_t size" "const char *format" ... +.Ft int +.Fn asprintf "char **ret" "const char *format" ... +.In stdarg.h +.Ft int +.Fn vprintf "const char *format" "va_list ap" +.Ft int +.Fn vfprintf "FILE *stream" "const char *format" "va_list ap" +.Ft int +.Fn vsprintf "char *str" "const char *format" "va_list ap" +.Ft int +.Fn vsnprintf "char *str" "size_t size" "const char *format" "va_list ap" +.Ft int +.Fn vasprintf "char **ret" "const char *format" "va_list ap" +.Sh DESCRIPTION +The +.Fn printf +family of functions produces output according to a +.Fa format +as described below. +.Fn Printf +and +.Fn vprintf +write output to +.Pa stdout , +the standard output stream; +.Fn fprintf +and +.Fn vfprintf +write output to the given output +.Fa stream ; +.Fn sprintf , +.Fn snprintf , +.Fn vsprintf , +and +.Fn vsnprintf +write to the character string +.Fa str ; +and +.Fn asprintf +and +.Fn vasprintf +dynamically allocate a new string with +.Xr malloc 3 . +.Pp +These functions write the output under the control of a +.Fa format +string that specifies how subsequent arguments +(or arguments accessed via the variable-length argument facilities of +.Xr stdarg 3 ) +are converted for output. +.Pp +These functions return the number of characters printed +(not including the trailing +.Ql \e0 +used to end output to strings), +except for +.Fn snprintf +and +.Fn vsnprintf , +which return the number of characters that would have been printed if the +.Fa size +were unlimited +(again, not including the final +.Ql \e0 ) . +.Pp +.Fn Asprintf +and +.Fn vasprintf +set +.Fa *ret +to be a pointer to a buffer sufficiently large to hold the formatted string. +This pointer should be passed to +.Xr free 3 +to release the allocated storage when it is no longer needed. +If sufficient space cannot be allocated, +.Fn asprintf +and +.Fn vasprintf +will return -1 and set +.Fa ret +to be a +.Dv NULL +pointer. +.Pp +.Fn Snprintf +and +.Fn vsnprintf +will write at most +.Fa size Ns \-1 +of the characters printed into the output string +(the +.Fa size Ns 'th +character then gets the terminating +.Ql \e0 ) ; +if the return value is greater than or equal to the +.Fa size +argument, the string was too short +and some of the printed characters were discarded. +.Pp +.Fn Sprintf +and +.Fn vsprintf +effectively assume an infinite +.Fa size . +.Pp +The format string is composed of zero or more directives: +ordinary +.\" multibyte +characters (not +.Cm % ) , +which are copied unchanged to the output stream; +and conversion specifications, each of which results +in fetching zero or more subsequent arguments. +Each conversion specification is introduced by +the +.Cm % +character. +The arguments must correspond properly (after type promotion) +with the conversion specifier. +After the +.Cm % , +the following appear in sequence: +.Bl -bullet +.It +An optional field, consisting of a decimal digit string followed by a +.Cm $ , +specifying the next argument to access. +If this field is not provided, the argument following the last +argument accessed will be used. +Arguments are numbered starting at +.Cm 1 . +If unaccessed arguments in the format string are interspersed with ones that +are accessed the results will be indeterminate. +.It +Zero or more of the following flags: +.Bl -hyphen +.It +A +.Cm # +character +specifying that the value should be converted to an +.Dq alternate form . +For +.Cm c , d , i , n , p , s , +and +.Cm u +conversions, this option has no effect. +For +.Cm o +conversions, the precision of the number is increased to force the first +character of the output string to a zero (except if a zero value is printed +with an explicit precision of zero). +For +.Cm x +and +.Cm X +conversions, a non-zero result has the string +.Ql 0x +(or +.Ql 0X +for +.Cm X +conversions) prepended to it. +For +.Cm e , E , f , g , +and +.Cm G +conversions, the result will always contain a decimal point, even if no +digits follow it (normally, a decimal point appears in the results of +those conversions only if a digit follows). +For +.Cm g +and +.Cm G +conversions, trailing zeros are not removed from the result as they +would otherwise be. +.It +A +.Cm 0 +(zero) +character specifying zero padding. +For all conversions except +.Cm n , +the converted value is padded on the left with zeros rather than blanks. +If a precision is given with a numeric conversion +.Cm ( d , i , o , u , i , x , +and +.Cm X ) , +the +.Cm 0 +flag is ignored. +.It +A negative field width flag +.Cm \- +indicates the converted value is to be left adjusted on the field boundary. +Except for +.Cm n +conversions, the converted value is padded on the right with blanks, +rather than on the left with blanks or zeros. +A +.Cm \- +overrides a +.Cm 0 +if both are given. +.It +A space, specifying that a blank should be left before a positive number +produced by a signed conversion +.Cm ( d , e , E , f , g , G , +or +.Cm i ) . +.It +A +.Cm + +character specifying that a sign always be placed before a +number produced by a signed conversion. +A +.Cm + +overrides a space if both are used. +.El +.It +An optional decimal digit string specifying a minimum field width. +If the converted value has fewer characters than the field width, it will +be padded with spaces on the left (or right, if the left-adjustment +flag has been given) to fill out +the field width. +.It +An optional precision, in the form of a period +.Cm \&. +followed by an +optional digit string. +If the digit string is omitted, the precision is taken as zero. +This gives the minimum number of digits to appear for +.Cm d , i , o , u , x , +and +.Cm X +conversions, the number of digits to appear after the decimal-point for +.Cm e , E , +and +.Cm f +conversions, the maximum number of significant digits for +.Cm g +and +.Cm G +conversions, or the maximum number of characters to be printed from a +string for +.Cm s +conversions. +.It +The optional character +.Cm h , +specifying that a following +.Cm d , i , o , u , x , +or +.Cm X +conversion corresponds to a +.Vt short int +or +.Vt unsigned short int +argument, or that a following +.Cm n +conversion corresponds to a pointer to a +.Vt short int +argument. +.It +The optional character +.Cm l +(ell) specifying that a following +.Cm d , i , o , u , x , +or +.Cm X +conversion applies to a pointer to a +.Vt long int +or +.Vt unsigned long int +argument, or that a following +.Cm n +conversion corresponds to a pointer to a +.Vt long int +argument. +.It +The optional characters +.Cm ll +(ell ell) specifying that a following +.Cm d , i , o , u , x , +or +.Cm X +conversion applies to a pointer to a +.Vt long long int +or +.Vt unsigned long long int +argument, or that a following +.Cm n +conversion corresponds to a pointer to a +.Vt long long int +argument. +.It +The optional character +.Cm q , +specifying that a following +.Cm d , i , o , u , x , +or +.Cm X +conversion corresponds to a +.Vt quad int +or +.Vt unsigned quad int +argument, or that a following +.Cm n +conversion corresponds to a pointer to a +.Vt quad int +argument. +.It +The character +.Cm L +specifying that a following +.Cm e , E , f , g , +or +.Cm G +conversion corresponds to a +.Vt long double +argument. +.It +A character that specifies the type of conversion to be applied. +.El +.Pp +A field width or precision, or both, may be indicated by +an asterisk +.Ql * +or an asterisk followed by one or more decimal digits and a +.Ql $ +instead of a +digit string. +In this case, an +.Vt int +argument supplies the field width or precision. +A negative field width is treated as a left adjustment flag followed by a +positive field width; a negative precision is treated as though it were +missing. +If a single format directive mixes positional (nn$) +and non-positional arguments, the results are undefined. +.Pp +The conversion specifiers and their meanings are: +.Bl -tag -width "diouxX" +.It Cm diouxX +The +.Vt int +(or appropriate variant) argument is converted to signed decimal +.Cm ( d +and +.Cm i ) , +unsigned octal +.Pq Cm o , +unsigned decimal +.Pq Cm u , +or unsigned hexadecimal +.Cm ( x +and +.Cm X ) +notation. +The letters +.Cm abcdef +are used for +.Cm x +conversions; the letters +.Cm ABCDEF +are used for +.Cm X +conversions. +The precision, if any, gives the minimum number of digits that must +appear; if the converted value requires fewer digits, it is padded on +the left with zeros. +.It Cm DOU +The +.Vt long int +argument is converted to signed decimal, unsigned octal, or unsigned +decimal, as if the format had been +.Cm ld , lo , +or +.Cm lu +respectively. +These conversion characters are deprecated, and will eventually disappear. +.It Cm eE +The +.Vt double +argument is rounded and converted in the style +.Oo \- Oc Ns d Ns Cm \&. Ns ddd Ns Cm e Ns \\*[Pm]dd +where there is one digit before the +decimal-point character +and the number of digits after it is equal to the precision; +if the precision is missing, +it is taken as 6; if the precision is +zero, no decimal-point character appears. +An +.Cm E +conversion uses the letter +.Cm E +(rather than +.Cm e ) +to introduce the exponent. +The exponent always contains at least two digits; if the value is zero, +the exponent is 00. +.It Cm f +The +.Vt double +argument is rounded and converted to decimal notation in the style +.Oo \- Oc Ns ddd Ns Cm \&. Ns ddd , +where the number of digits after the decimal-point character +is equal to the precision specification. +If the precision is missing, it is taken as 6; if the precision is +explicitly zero, no decimal-point character appears. +If a decimal point appears, at least one digit appears before it. +.It Cm gG +The +.Vt double +argument is converted in style +.Cm f +or +.Cm e +(or +.Cm E +for +.Cm G +conversions). +The precision specifies the number of significant digits. +If the precision is missing, 6 digits are given; if the precision is zero, +it is treated as 1. +Style +.Cm e +is used if the exponent from its conversion is less than -4 or greater than +or equal to the precision. +Trailing zeros are removed from the fractional part of the result; a +decimal point appears only if it is followed by at least one digit. +.It Cm c +The +.Vt int +argument is converted to an +.Vt unsigned char , +and the resulting character is written. +.It Cm s +The +.Vt char * +argument is expected to be a pointer to an array of character type (pointer +to a string). +Characters from the array are written up to (but not including) +a terminating +.Dv NUL +character; +if a precision is specified, no more than the number specified are +written. +If a precision is given, no null character +need be present; if the precision is not specified, or is greater than +the size of the array, the array must contain a terminating +.Dv NUL +character. +.It Cm p +The +.Vt void * +pointer argument is printed in hexadecimal (as if by +.Ql %#x +or +.Ql %#lx ) . +.It Cm n +The number of characters written so far is stored into the +integer indicated by the +.Vt int * +(or variant) pointer argument. +No argument is converted. +.It Cm % +A +.Ql % +is written. +No argument is converted. +The complete conversion specification +is +.Ql %% . +.El +.Pp +In no case does a non-existent or small field width cause truncation of +a field; if the result of a conversion is wider than the field width, the +field is expanded to contain the conversion result. +.Sh EXAMPLES +To print a date and time in the form +.Dq Li "Sunday, July 3, 10:02" , +where +.Fa weekday +and +.Fa month +are pointers to strings: +.Bd -literal -offset indent +#include +fprintf(stdout, "%s, %s %d, %.2d:%.2d\en", + weekday, month, day, hour, min); +.Ed +.Pp +To print \*(Pi +to five decimal places: +.Bd -literal -offset indent +#include +#include +fprintf(stdout, "pi = %.5f\en", 4 * atan(1.0)); +.Ed +.Pp +To allocate a 128 byte string and print into it: +.Bd -literal -offset indent +#include +#include +#include +char *newfmt(const char *fmt, ...) +{ + char *p; + va_list ap; + if ((p = malloc(128)) == NULL) + return (NULL); + va_start(ap, fmt); + (void) vsnprintf(p, 128, fmt, ap); + va_end(ap); + return (p); +} +.Ed +.Sh SEE ALSO +.Xr printf 1 , +.Xr scanf 3 +.Sh STANDARDS +The +.Fn fprintf , +.Fn printf , +.Fn sprintf , +.Fn vprintf , +.Fn vfprintf , +and +.Fn vsprintf +functions +conform to +.St -isoC . +.Sh HISTORY +The functions +.Fn asprintf +and +.Fn vasprintf +first appeared in the +.Tn GNU C +library. +These were implemented by +.An Peter Wemm Aq peter@FreeBSD.org +in +.Fx 2.2 , +but were later replaced with a different implementation +from +.An Todd C. Miller Aq Todd.Miller@courtesan.com +for +.Ox 2.3 . +.Sh BUGS +The conversion formats +.Cm \&%D , \&%O , +and +.Cm %U +are not standard and +are provided only for backward compatibility. +The effect of padding the +.Cm %p +format with zeros (either by the +.Cm 0 +flag or by specifying a precision), and the benign effect (i.e., none) +of the +.Cm # +flag on +.Cm %n +and +.Cm %p +conversions, as well as other +nonsensical combinations such as +.Cm %Ld , +are not standard; such combinations +should be avoided. +.Pp +Because +.Fn sprintf +and +.Fn vsprintf +assume an infinitely long string, +callers must be careful not to overflow the actual space; +this is often hard to assure. +For safety, programmers should use the +.Fn snprintf +interface instead. +Unfortunately, this interface is not portable. diff --git a/stdio.subproj/printf.c b/stdio/printf.c similarity index 100% rename from stdio.subproj/printf.c rename to stdio/printf.c diff --git a/stdio/putc.3 b/stdio/putc.3 new file mode 100644 index 0000000..551135f --- /dev/null +++ b/stdio/putc.3 @@ -0,0 +1,136 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)putc.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdio/putc.3,v 1.8 2001/10/01 16:08:59 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt PUTC 3 +.Os +.Sh NAME +.Nm fputc , +.Nm putc , +.Nm putchar , +.Nm putw +.Nd output a character or word to a stream +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.Ft int +.Fn fputc "int c" "FILE *stream" +.Ft int +.Fn putc "int c" "FILE *stream" +.Ft int +.Fn putchar "int c" +.Ft int +.Fn putw "int w" "FILE *stream" +.Sh DESCRIPTION +The +.Fn fputc +function +writes the character +.Fa c +(converted to an ``unsigned char'') +to the output stream pointed to by +.Fa stream . +.Pp +The +.Fn putc +macro acts essentially identically to +.Fn fputc , +but is a macro that expands in-line. +It may evaluate +.Fa stream +more than once, so arguments given to +.Fn putc +should not be expressions with potential side effects. +.Pp +The +.Fn putchar +macro +is identical to +.Fn putc +with an output stream of +.Em stdout . +.Pp +The +.Fn putw +function +writes the specified +.Em int +to the named output +.Fa stream . +.Sh RETURN VALUES +The functions, +.Fn fputc , +.Fn putc +and +.Fn putchar +return the character written. +If an error occurs, the value +.Dv EOF +is returned. +The +.Fn putw +function +returns 0 on success; +.Dv EOF +is returned if +a write error occurs, +or if an attempt is made to write a read-only stream. +.Sh SEE ALSO +.Xr ferror 3 , +.Xr fopen 3 , +.Xr getc 3 , +.Xr stdio 3 +.Sh STANDARDS +The functions +.Fn fputc , +.Fn putc , +and +.Fn putchar , +conform to +.St -isoC . +A function +.Fn putw +function appeared in +.At v6 . +.Sh BUGS +The size and byte order of an +.Em int +varies from one machine to another, and +.Fn putw +is not recommended for portable applications. diff --git a/stdio.subproj/putc.c b/stdio/putc.c similarity index 100% rename from stdio.subproj/putc.c rename to stdio/putc.c diff --git a/stdio.subproj/putchar.c b/stdio/putchar.c similarity index 100% rename from stdio.subproj/putchar.c rename to stdio/putchar.c diff --git a/stdio.subproj/puts.c b/stdio/puts.c similarity index 100% rename from stdio.subproj/puts.c rename to stdio/puts.c diff --git a/stdio.subproj/putw.c b/stdio/putw.c similarity index 100% rename from stdio.subproj/putw.c rename to stdio/putw.c diff --git a/stdio.subproj/refill.c b/stdio/refill.c similarity index 100% rename from stdio.subproj/refill.c rename to stdio/refill.c diff --git a/stdio/remove.3 b/stdio/remove.3 new file mode 100644 index 0000000..8c9d65f --- /dev/null +++ b/stdio/remove.3 @@ -0,0 +1,87 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)remove.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdio/remove.3,v 1.9 2001/10/01 16:08:59 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt REMOVE 3 +.Os +.Sh NAME +.Nm remove +.Nd remove directory entry +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.Ft int +.Fn remove "const char *path" +.Sh DESCRIPTION +The +.Fn remove +function removes the file or directory specified by +.Fa path . +.Pp +If +.Fa path +specifies a directory, +.Fn remove "path" +is the equivalent of +.Fn rmdir "path" . +Otherwise, it is the equivalent of +.Fn unlink "path" . +.Sh RETURN VALUES +.Rv -std remove +.Sh ERRORS +The +.Fn remove +function +may fail and set +.Va errno +for any of the errors specified for the routines +.Xr lstat 2 , +.Xr rmdir 2 +or +.Xr unlink 2 . +.Sh SEE ALSO +.Xr rmdir 2 , +.Xr unlink 2 +.Sh STANDARDS +The +.Fn remove +function conforms to +.St -isoC +and +.St -xpg4.2 . diff --git a/stdio/remove.c b/stdio/remove.c new file mode 100644 index 0000000..4e20f08 --- /dev/null +++ b/stdio/remove.c @@ -0,0 +1,61 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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) +#if 0 +static char sccsid[] = "@(#)remove.c 8.1 (Berkeley) 6/4/93"; +#endif +static const char rcsid[] = + "$FreeBSD: src/lib/libc/stdio/remove.c,v 1.6.2.1 2000/09/20 04:43:12 jkh Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include +#include + +int +remove(file) + const char *file; +{ + struct stat sb; + + if (lstat(file, &sb) < 0) + return (-1); + if (S_ISDIR(sb.st_mode)) + return (rmdir(file)); + return (unlink(file)); +} diff --git a/stdio.subproj/rewind.c b/stdio/rewind.c similarity index 100% rename from stdio.subproj/rewind.c rename to stdio/rewind.c diff --git a/stdio.subproj/rget.c b/stdio/rget.c similarity index 100% rename from stdio.subproj/rget.c rename to stdio/rget.c diff --git a/stdio/scanf.3 b/stdio/scanf.3 new file mode 100644 index 0000000..776ab49 --- /dev/null +++ b/stdio/scanf.3 @@ -0,0 +1,446 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)scanf.3 8.2 (Berkeley) 12/11/93 +.\" $FreeBSD: src/lib/libc/stdio/scanf.3,v 1.13 2001/10/01 16:08:59 ru Exp $ +.\" +.Dd December 11, 1993 +.Dt SCANF 3 +.Os +.Sh NAME +.Nm scanf , +.Nm fscanf , +.Nm sscanf , +.Nm vscanf , +.Nm vsscanf , +.Nm vfscanf +.Nd input format conversion +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.Ft int +.Fn scanf "const char *format" ... +.Ft int +.Fn fscanf "FILE *stream" "const char *format" ... +.Ft int +.Fn sscanf "const char *str" "const char *format" ... +.In stdarg.h +.Ft int +.Fn vscanf "const char *format" "va_list ap" +.Ft int +.Fn vsscanf "const char *str" "const char *format" "va_list ap" +.Ft int +.Fn vfscanf "FILE *stream" "const char *format" "va_list ap" +.Sh DESCRIPTION +The +.Fn scanf +family of functions scans input according to a +.Fa format +as described below. +This format may contain +.Em conversion specifiers ; +the results from such conversions, if any, +are stored through the +.Em pointer +arguments. +The +.Fn scanf +function +reads input from the standard input stream +.Em stdin , +.Fn fscanf +reads input from the stream pointer +.Fa stream , +and +.Fn sscanf +reads its input from the character string pointed to by +.Fa str . +The +.Fn vfscanf +function +is analogous to +.Xr vfprintf 3 +and reads input from the stream pointer +.Fa stream +using a variable argument list of pointers (see +.Xr stdarg 3 ) . +The +.Fn vscanf +function scans a variable argument list from the standard input and +the +.Fn vsscanf +function scans it from a string; +these are analogous to +the +.Fn vprintf +and +.Fn vsprintf +functions respectively. +Each successive +.Em pointer +argument must correspond properly with +each successive conversion specifier +(but see `suppression' below). +All conversions are introduced by the +.Cm % +(percent sign) character. +The +.Fa format +string +may also contain other characters. +White space (such as blanks, tabs, or newlines) in the +.Fa format +string match any amount of white space, including none, in the input. +Everything else +matches only itself. +Scanning stops +when an input character does not match such a format character. +Scanning also stops +when an input conversion cannot be made (see below). +.Sh CONVERSIONS +Following the +.Cm % +character introducing a conversion +there may be a number of +.Em flag +characters, as follows: +.Bl -tag -width indent +.It Cm * +Suppresses assignment. +The conversion that follows occurs as usual, but no pointer is used; +the result of the conversion is simply discarded. +.It Cm h +Indicates that the conversion will be one of +.Cm dioux +or +.Cm n +and the next pointer is a pointer to a +.Em short int +(rather than +.Em int ) . +.It Cm l +Indicates either that the conversion will be one of +.Cm dioux +or +.Cm n +and the next pointer is a pointer to a +.Em long int +(rather than +.Em int ) , +or that the conversion will be one of +.Cm efg +and the next pointer is a pointer to +.Em double +(rather than +.Em float ) . +.It Cm L +Indicates that the conversion will be +.Cm efg +and the next pointer is a pointer to +.Em long double . +(This type is not implemented; the +.Cm L +flag is currently ignored.) +.It Cm q +Indicates either that the conversion will be one of +.Cm dioux +or +.Cm n +and the next pointer is a pointer to a +.Em long long int +(rather than +.Em int ) , +.El +.Pp +In addition to these flags, +there may be an optional maximum field width, +expressed as a decimal integer, +between the +.Cm % +and the conversion. +If no width is given, +a default of `infinity' is used (with one exception, below); +otherwise at most this many characters are scanned +in processing the conversion. +Before conversion begins, +most conversions skip white space; +this white space is not counted against the field width. +.Pp +The following conversions are available: +.Bl -tag -width XXXX +.It Cm % +Matches a literal `%'. +That is, `%\&%' in the format string +matches a single input `%' character. +No conversion is done, and assignment does not occur. +.It Cm d +Matches an optionally signed decimal integer; +the next pointer must be a pointer to +.Em int . +.It Cm D +Equivalent to +.Cm ld ; +this exists only for backwards compatibility. +.It Cm i +Matches an optionally signed integer; +the next pointer must be a pointer to +.Em int . +The integer is read in base 16 if it begins +with +.Ql 0x +or +.Ql 0X , +in base 8 if it begins with +.Ql 0 , +and in base 10 otherwise. +Only characters that correspond to the base are used. +.It Cm o +Matches an octal integer; +the next pointer must be a pointer to +.Em unsigned int . +.It Cm O +Equivalent to +.Cm lo ; +this exists for backwards compatibility. +.It Cm u +Matches an optionally signed decimal integer; +the next pointer must be a pointer to +.Em unsigned int . +.It Cm x +Matches an optionally signed hexadecimal integer; +the next pointer must be a pointer to +.Em unsigned int . +.It Cm X +Equivalent to +.Cm lx ; +this violates the +.St -isoC , +but is backwards compatible with previous +.Ux +systems. +.It Cm f +Matches an optionally signed floating-point number; +the next pointer must be a pointer to +.Em float . +.It Cm e +Equivalent to +.Cm f . +.It Cm g +Equivalent to +.Cm f . +.It Cm E +Equivalent to +.Cm lf ; +this violates the +.St -isoC , +but is backwards compatible with previous +.Ux +systems. +.It Cm F +Equivalent to +.Cm lf ; +this exists only for backwards compatibility. +.It Cm s +Matches a sequence of non-white-space characters; +the next pointer must be a pointer to +.Em char , +and the array must be large enough to accept all the sequence and the +terminating +.Dv NUL +character. +The input string stops at white space +or at the maximum field width, whichever occurs first. +.It Cm c +Matches a sequence of +.Em width +count +characters (default 1); +the next pointer must be a pointer to +.Em char , +and there must be enough room for all the characters +(no terminating +.Dv NUL +is added). +The usual skip of leading white space is suppressed. +To skip white space first, use an explicit space in the format. +.It Cm \&[ +Matches a nonempty sequence of characters from the specified set +of accepted characters; +the next pointer must be a pointer to +.Em char , +and there must be enough room for all the characters in the string, +plus a terminating +.Dv NUL +character. +The usual skip of leading white space is suppressed. +The string is to be made up of characters in +(or not in) +a particular set; +the set is defined by the characters between the open bracket +.Cm [ +character +and a close bracket +.Cm ] +character. +The set +.Em excludes +those characters +if the first character after the open bracket is a circumflex +.Cm ^ . +To include a close bracket in the set, +make it the first character after the open bracket +or the circumflex; +any other position will end the set. +The hyphen character +.Cm - +is also special; +when placed between two other characters, +it adds all intervening characters to the set. +To include a hyphen, +make it the last character before the final close bracket. +For instance, +.Ql [^]0-9-] +means the set `everything except close bracket, zero through nine, +and hyphen'. +The string ends with the appearance of a character not in the +(or, with a circumflex, in) set +or when the field width runs out. +.It Cm p +Matches a pointer value (as printed by +.Ql %p +in +.Xr printf 3 ) ; +the next pointer must be a pointer to +.Em void . +.It Cm n +Nothing is expected; +instead, the number of characters consumed thus far from the input +is stored through the next pointer, +which must be a pointer to +.Em int . +This is +.Em not +a conversion, although it can be suppressed with the +.Cm * +flag. +.El +.Pp +The decimal point +character is defined in the program's locale (category +.Dv LC_NUMERIC ) . +.Pp +For backwards compatibility, +other conversion characters (except +.Ql \e0 ) +are taken as if they were +.Ql %d +or, if uppercase, +.Ql %ld , +and a `conversion' of +.Ql %\e0 +causes an immediate return of +.Dv EOF . +The +.Cm F +and +.Cm X +conversions will be changed in the future +to conform to the +.Tn ANSI +C standard, +after which they will act like +.Cm f +and +.Cm x +respectively. +.Sh RETURN VALUES +These +functions +return +the number of input items assigned, which can be fewer than provided +for, or even zero, in the event of a matching failure. +Zero +indicates that, while there was input available, +no conversions were assigned; +typically this is due to an invalid input character, +such as an alphabetic character for a +.Ql %d +conversion. +The value +.Dv EOF +is returned if an input failure occurs before any conversion such as an +end-of-file occurs. +If an error or end-of-file occurs after conversion +has begun, +the number of conversions which were successfully completed is returned. +.Sh SEE ALSO +.Xr getc 3 , +.Xr printf 3 , +.Xr strtod 3 , +.Xr strtol 3 , +.Xr strtoul 3 +.Sh STANDARDS +The functions +.Fn fscanf , +.Fn scanf , +and +.Fn sscanf +conform to +.St -isoC . +.Sh HISTORY +The functions +.Fn vscanf , +.Fn vsscanf +and +.Fn vfscanf +are new to this release. +.Sh BUGS +The current situation with +.Cm %F +and +.Cm %X +conversions is unfortunate. +.Pp +All of the backwards compatibility formats will be removed in the future. +.Pp +Numerical strings are truncated to 512 characters; for example, +.Cm %f +and +.Cm %d +are implicitly +.Cm %512f +and +.Cm %512d . diff --git a/stdio.subproj/scanf.c b/stdio/scanf.c similarity index 100% rename from stdio.subproj/scanf.c rename to stdio/scanf.c diff --git a/stdio/setbuf.3 b/stdio/setbuf.3 new file mode 100644 index 0000000..bf88ada --- /dev/null +++ b/stdio/setbuf.3 @@ -0,0 +1,205 @@ +.\" Copyright (c) 1980, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)setbuf.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdio/setbuf.3,v 1.10 2001/10/01 16:08:59 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt SETBUF 3 +.Os +.Sh NAME +.Nm setbuf , +.Nm setbuffer , +.Nm setlinebuf , +.Nm setvbuf +.Nd stream buffering operations +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.Ft void +.Fn setbuf "FILE *stream" "char *buf" +.Ft void +.Fn setbuffer "FILE *stream" "char *buf" "int size" +.Ft int +.Fn setlinebuf "FILE *stream" +.Ft int +.Fn setvbuf "FILE *stream" "char *buf" "int mode" "size_t size" +.Sh DESCRIPTION +The three types of buffering available are unbuffered, block buffered, +and line buffered. +When an output stream is unbuffered, information appears on the +destination file or terminal as soon as written; +when it is block buffered many characters are saved up and written as a block; +when it is line buffered characters are saved up until a newline is +output or input is read from any stream attached to a terminal device +(typically stdin). +The function +.Xr fflush 3 +may be used to force the block out early. +(See +.Xr fclose 3 . ) +.Pp +Normally all files are block buffered. +When the first +.Tn I/O +operation occurs on a file, +.Xr malloc 3 +is called, +and an optimally-sized buffer is obtained. +If a stream refers to a terminal +(as +.Em stdout +normally does) it is line buffered. +The standard error stream +.Em stderr +is always unbuffered. +.Pp +The +.Fn setvbuf +function +may be used to alter the buffering behavior of a stream. +The +.Fa mode +parameter must be one of the following three macros: +.Bl -tag -width _IOFBF -offset indent +.It Dv _IONBF +unbuffered +.It Dv _IOLBF +line buffered +.It Dv _IOFBF +fully buffered +.El +.Pp +The +.Fa size +parameter may be given as zero +to obtain deferred optimal-size buffer allocation as usual. +If it is not zero, +then except for unbuffered files, the +.Fa buf +argument should point to a buffer at least +.Fa size +bytes long; +this buffer will be used instead of the current buffer. +(If the +.Fa size +argument +is not zero but +.Fa buf +is +.Dv NULL , +a buffer of the given size will be allocated immediately, +and released on close. +This is an extension to ANSI C; +portable code should use a size of 0 with any +.Dv NULL +buffer.) +.Pp +The +.Fn setvbuf +function may be used at any time, +but may have peculiar side effects +(such as discarding input or flushing output) +if the stream is ``active''. +Portable applications should call it only once on any given stream, +and before any +.Tn I/O +is performed. +.Pp +The other three calls are, in effect, simply aliases for calls to +.Fn setvbuf . +Except for the lack of a return value, the +.Fn setbuf +function is exactly equivalent to the call +.Pp +.Dl "setvbuf(stream, buf, buf ? _IOFBF : _IONBF, BUFSIZ);" +.Pp +The +.Fn setbuffer +function +is the same, except that the size of the buffer is up to the caller, +rather than being determined by the default +.Dv BUFSIZ . +The +.Fn setlinebuf +function +is exactly equivalent to the call: +.Pp +.Dl "setvbuf(stream, (char *)NULL, _IOLBF, 0);" +.Sh RETURN VALUES +The +.Fn setvbuf +function returns 0 on success, or +.Dv EOF +if the request cannot be honored +(note that the stream is still functional in this case). +.Pp +The +.Fn setlinebuf +function returns what the equivalent +.Fn setvbuf +would have returned. +.Sh SEE ALSO +.Xr fclose 3 , +.Xr fopen 3 , +.Xr fread 3 , +.Xr malloc 3 , +.Xr printf 3 , +.Xr puts 3 +.Sh STANDARDS +The +.Fn setbuf +and +.Fn setvbuf +functions +conform to +.St -isoC . +.Sh BUGS +The +.Fn setbuffer +and +.Fn setlinebuf +functions are not portable to versions of +.Bx +before +.Bx 4.2 . +On +.Bx 4.2 +and +.Bx 4.3 +systems, +.Fn setbuf +always uses a suboptimal buffer size and should be avoided. diff --git a/stdio.subproj/setbuf.c b/stdio/setbuf.c similarity index 100% rename from stdio.subproj/setbuf.c rename to stdio/setbuf.c diff --git a/stdio.subproj/setbuffer.c b/stdio/setbuffer.c similarity index 100% rename from stdio.subproj/setbuffer.c rename to stdio/setbuffer.c diff --git a/stdio.subproj/setvbuf.c b/stdio/setvbuf.c similarity index 100% rename from stdio.subproj/setvbuf.c rename to stdio/setvbuf.c diff --git a/stdio.subproj/snprintf.c b/stdio/snprintf.c similarity index 100% rename from stdio.subproj/snprintf.c rename to stdio/snprintf.c diff --git a/stdio.subproj/sprintf.c b/stdio/sprintf.c similarity index 100% rename from stdio.subproj/sprintf.c rename to stdio/sprintf.c diff --git a/stdio.subproj/sscanf.c b/stdio/sscanf.c similarity index 100% rename from stdio.subproj/sscanf.c rename to stdio/sscanf.c diff --git a/stdio/stdio.3 b/stdio/stdio.3 new file mode 100644 index 0000000..59fd492 --- /dev/null +++ b/stdio/stdio.3 @@ -0,0 +1,297 @@ +.\" Copyright (c) 1990, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)stdio.3 8.7 (Berkeley) 4/19/94 +.\" $FreeBSD: src/lib/libc/stdio/stdio.3,v 1.18 2001/10/01 16:08:59 ru Exp $ +.\" +.Dd April 19, 1994 +.Dt STDIO 3 +.Os +.Sh NAME +.Nm stdio +.Nd standard input/output library functions +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.Vt FILE *stdin ; +.Vt FILE *stdout ; +.Vt FILE *stderr ; +.Sh DESCRIPTION +The standard +.Tn I/O +library provides a simple and efficient buffered stream +.Tn I/O +interface. +Input and output is mapped into logical data streams +and the physical +.Tn I/O +characteristics are concealed. +The functions and macros are listed +below; more information is available from the individual man pages. +.Pp +A stream is associated with an external file (which may be a physical +device) by +.Em opening +a file, which may involve creating a new file. +Creating an +existing file causes its former contents to be discarded. +If a file can support positioning requests (such as a disk file, as opposed +to a terminal) then a +.Em file position indicator +associated with the stream is positioned at the start of the file (byte +zero), unless the file is opened with append mode. +If append mode +is used, the position indicator will be placed at the end-of-file. +The position indicator is maintained by subsequent reads, writes +and positioning requests. +All input occurs as if the characters +were read by successive calls to the +.Xr fgetc 3 +function; all output takes place as if all characters were +written by successive calls to the +.Xr fputc 3 +function. +.Pp +A file is disassociated from a stream by +.Em closing +the file. +Output streams are flushed (any unwritten buffer contents are transferred +to the host environment) before the stream is disassociated from the file. +The value of a pointer to a +.Dv FILE +object is indeterminate (garbage) after a file is closed. +.Pp +A file may be subsequently reopened, by the same or another program +execution, and its contents reclaimed or modified (if it can be repositioned +at the start). If the main function returns to its original caller, or +the +.Xr exit 3 +function is called, all open files are closed (hence all output +streams are flushed) before program termination. Other methods +of program termination may not close files properly and hence +buffered output may be lost. In particular, +.Xr _exit 2 +does not flush stdio files. Neither does an exit due to a signal. +Buffers are flushed by +.Xr abort 3 +as required by POSIX, although previous implementations did not. +.Pp +This implementation makes no distinction between +.Dq text +and +.Dq binary +streams. +In effect, all streams are binary. +No translation is performed and no extra padding appears on any stream. +.Pp +At program startup, three streams are predefined and need not be +opened explicitly: +.Bl -bullet -compact -offset indent +.It +.Em standard input +(for reading conventional input), +.It +.Em standard output +(for writing conventional output), and +.It +.Em standard error +(for writing diagnostic output). +.El +These streams are abbreviated +.Em stdin , stdout +and +.Em stderr . +Initially, the standard error stream +is unbuffered; the standard input and output streams are +fully buffered if and only if the streams do not refer to +an interactive or +.Dq terminal +device, as determined by the +.Xr isatty 3 +function. +In fact, +.Em all +freshly-opened streams that refer to terminal devices +default to line buffering, and +pending output to such streams is written automatically +whenever such an input stream is read. +Note that this applies only to +.Dq "true reads" ; +if the read request can be satisfied by existing buffered data, +no automatic flush will occur. +In these cases, +or when a large amount of computation is done after printing +part of a line on an output terminal, it is necessary to +.Xr fflush 3 +the standard output before going off and computing so that the output +will appear. +Alternatively, these defaults may be modified via the +.Xr setvbuf 3 +function. +.Pp +The +.Nm +library is a part of the library +.Nm libc +and routines are automatically loaded as needed by the C compiler. +The +.Tn SYNOPSIS +sections of the following manual pages indicate which include files +are to be used, what the compiler declaration for the function +looks like and which external variables are of interest. +.Pp +The following are defined as macros; +these names may not be re-used +without first removing their current definitions with +.Dv #undef : +.Dv BUFSIZ , +.Dv EOF , +.Dv FILENAME_MAX , +.Dv FOPEN_MAX , +.Dv L_cuserid , +.Dv L_ctermid , +.Dv L_tmpnam , +.Dv NULL , +.Dv P_tmpdir , +.Dv SEEK_CUR , +.Dv SEEK_END , +.Dv SEEK_SET , +.Dv TMP_MAX , +.Dv clearerr , +.Dv feof , +.Dv ferror , +.Dv fileno , +.Dv fropen , +.Dv fwopen , +.Dv getc , +.Dv getchar , +.Dv putc , +.Dv putchar , +.Dv stderr , +.Dv stdin , +.Dv stdout , +.Dv vfscanf . +Function versions of the macro functions +.Fn clearerr , +.Fn feof , +.Fn ferror , +.Fn fileno , +.Fn getc , +.Fn getchar , +.Fn putc , +and +.Fn putchar +exist and will be used if the macro +definitions are explicitly removed. +.Sh SEE ALSO +.Xr close 2 , +.Xr open 2 , +.Xr read 2 , +.Xr write 2 +.Sh BUGS +The standard buffered functions do not interact well with certain other +library and system functions, especially +.Xr vfork 2 . +.Sh STANDARDS +The +.Nm +library conforms to +.St -isoC . +.Sh LIST OF FUNCTIONS +.Bl -column "Description" +.It Sy "Function Description" +.It "asprintf formatted output conversion" +.It "clearerr check and reset stream status" +.It "fclose close a stream" +.It "fdopen stream open functions" +.It "feof check and reset stream status" +.It "ferror check and reset stream status" +.It "fflush flush a stream" +.It "fgetc get next character or word from input stream" +.It "fgetln get a line from a stream" +.It "fgetpos reposition a stream" +.It "fgets get a line from a stream" +.It "fileno check and reset stream status" +.It "fopen stream open functions" +.It "fprintf formatted output conversion" +.It "fpurge flush a stream" +.It "fputc output a character or word to a stream" +.It "fputs output a line to a stream" +.It "fread binary stream input/output" +.It "freopen stream open functions" +.It "fropen open a stream" +.It "fscanf input format conversion" +.It "fseek reposition a stream" +.It "fsetpos reposition a stream" +.It "ftell reposition a stream" +.It "funopen open a stream" +.It "fwopen open a stream" +.It "fwrite binary stream input/output" +.It "getc get next character or word from input stream" +.It "getchar get next character or word from input stream" +.It "gets get a line from a stream" +.It "getw get next character or word from input stream" +.It "mkdtemp create unique temporary file" +.It "mkstemp create unique temporary file" +.It "mktemp create unique temporary file" +.It "perror system error messages" +.It "printf formatted output conversion" +.It "putc output a character or word to a stream" +.It "putchar output a character or word to a stream" +.It "puts output a line to a stream" +.It "putw output a character or word to a stream" +.It "remove remove directory entry" +.It "rewind reposition a stream" +.It "scanf input format conversion" +.It "setbuf stream buffering operations" +.It "setbuffer stream buffering operations" +.It "setlinebuf stream buffering operations" +.It "setvbuf stream buffering operations" +.It "snprintf formatted output conversion" +.It "sprintf formatted output conversion" +.It "sscanf input format conversion" +.It "strerror system error messages" +.It "sys_errlist system error messages" +.It "sys_nerr system error messages" +.It "tempnam temporary file routines" +.It "tmpfile temporary file routines" +.It "tmpnam temporary file routines" +.It "ungetc un-get character from input stream" +.It "vasprintf formatted output conversion" +.It "vfprintf formatted output conversion" +.It "vfscanf input format conversion" +.It "vprintf formatted output conversion" +.It "vscanf input format conversion" +.It "vsnprintf formatted output conversion" +.It "vsprintf formatted output conversion" +.It "vsscanf input format conversion" +.El diff --git a/stdio.subproj/stdio.c b/stdio/stdio.c similarity index 100% rename from stdio.subproj/stdio.c rename to stdio/stdio.c diff --git a/stdio.subproj/tempnam.c b/stdio/tempnam.c similarity index 100% rename from stdio.subproj/tempnam.c rename to stdio/tempnam.c diff --git a/stdio.subproj/tmpfile.c b/stdio/tmpfile.c similarity index 100% rename from stdio.subproj/tmpfile.c rename to stdio/tmpfile.c diff --git a/stdio/tmpnam.3 b/stdio/tmpnam.3 new file mode 100644 index 0000000..fa4c1e9 --- /dev/null +++ b/stdio/tmpnam.3 @@ -0,0 +1,229 @@ +.\" Copyright (c) 1988, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)tmpnam.3 8.2 (Berkeley) 11/17/93 +.\" $FreeBSD: src/lib/libc/stdio/tmpnam.3,v 1.10 2001/10/01 16:08:59 ru Exp $ +.\" +.Dd November 17, 1993 +.Dt TMPFILE 3 +.Os +.Sh NAME +.Nm tempnam , +.Nm tmpfile , +.Nm tmpnam +.Nd temporary file routines +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.Ft FILE * +.Fn tmpfile void +.Ft char * +.Fn tmpnam "char *str" +.Ft char * +.Fn tempnam "const char *tmpdir" "const char *prefix" +.Sh DESCRIPTION +The +.Fn tmpfile +function +returns a pointer to a stream associated with a file descriptor returned +by the routine +.Xr mkstemp 3 . +The created file is unlinked before +.Fn tmpfile +returns, causing the file to be automatically deleted when the last +reference to it is closed. +The file is opened with the access value +.Ql w+ . +The file is created in the directory determined by the environment variable +.Ev TMPDIR +if set. +The default location if +.Ev TMPDIR +is not set is +.Pa /tmp . +.Pp +The +.Fn tmpnam +function +returns a pointer to a file name, in the +.Dv P_tmpdir +directory, which +did not reference an existing file at some indeterminate point in the +past. +.Dv P_tmpdir +is defined in the include file +.Aq Pa stdio.h . +If the argument +.Fa str +is +.Pf non- Dv NULL , +the file name is copied to the buffer it references. +Otherwise, the file name is copied to a static buffer. +In either case, +.Fn tmpnam +returns a pointer to the file name. +.Pp +The buffer referenced by +.Fa str +is expected to be at least +.Dv L_tmpnam +bytes in length. +.Dv L_tmpnam +is defined in the include file +.Aq Pa stdio.h . +.Pp +The +.Fn tempnam +function +is similar to +.Fn tmpnam , +but provides the ability to specify the directory which will +contain the temporary file and the file name prefix. +.Pp +The environment variable +.Ev TMPDIR +(if set), the argument +.Fa tmpdir +(if +.Pf non- Dv NULL ) , +the directory +.Dv P_tmpdir , +and the directory +.Pa /tmp +are tried, in the listed order, as directories in which to store the +temporary file. +.Pp +The argument +.Fa prefix , +if +.Pf non- Dv NULL , +is used to specify a file name prefix, which will be the +first part of the created file name. +.Fn Tempnam +allocates memory in which to store the file name; the returned pointer +may be used as a subsequent argument to +.Xr free 3 . +.Sh RETURN VALUES +The +.Fn tmpfile +function +returns a pointer to an open file stream on success, and a +.Dv NULL +pointer +on error. +.Pp +The +.Fn tmpnam +and +.Fn tempfile +functions +return a pointer to a file name on success, and a +.Dv NULL +pointer +on error. +.Sh ERRORS +The +.Fn tmpfile +function +may fail and set the global variable +.Va errno +for any of the errors specified for the library functions +.Xr fdopen 3 +or +.Xr mkstemp 3 . +.Pp +The +.Fn tmpnam +function +may fail and set +.Va errno +for any of the errors specified for the library function +.Xr mktemp 3 . +.Pp +The +.Fn tempnam +function +may fail and set +.Va errno +for any of the errors specified for the library functions +.Xr malloc 3 +or +.Xr mktemp 3 . +.Sh SEE ALSO +.Xr mkstemp 3 , +.Xr mktemp 3 +.Sh STANDARDS +The +.Fn tmpfile +and +.Fn tmpnam +functions +conform to +.St -isoC . +.Sh BUGS +These interfaces are provided for System V and +.Tn ANSI +compatibility only. +The +.Xr mkstemp 3 +interface is strongly preferred. +.Pp +There are four important problems with these interfaces (as well as +with the historic +.Xr mktemp 3 +interface). +First, there is an obvious race between file name selection and file +creation and deletion. +Second, most historic implementations provide only a limited number +of possible temporary file names (usually 26) before file names will +start being recycled. +Third, the System V implementations of these functions (and of +.Xr mktemp 3 ) +use the +.Xr access 2 +function to determine whether or not the temporary file may be created. +This has obvious ramifications for setuid or setgid programs, complicating +the portable use of these interfaces in such programs. +Finally, there is no specification of the permissions with which the +temporary files are created. +.Pp +This implementation does not have these flaws, but portable software +cannot depend on that. +In particular, the +.Fn tmpfile +interface should not be used in software expected to be used on other systems +if there is any possibility that the user does not wish the temporary file to +be publicly readable and writable. diff --git a/stdio.subproj/tmpnam.c b/stdio/tmpnam.c similarity index 95% rename from stdio.subproj/tmpnam.c rename to stdio/tmpnam.c index 3ab71b1..ba8a60b 100644 --- a/stdio.subproj/tmpnam.c +++ b/stdio/tmpnam.c @@ -60,13 +60,20 @@ #include #include +#include char * tmpnam(s) char *s; { static u_long tmpcount; - static char buf[L_tmpnam]; + static char *buf = NULL; + + if( buf == NULL ) { + buf = malloc(L_tmpnam); + if( buf == NULL ) + return NULL; + } if (s == NULL) s = buf; diff --git a/stdio/ungetc.3 b/stdio/ungetc.3 new file mode 100644 index 0000000..adb91fa --- /dev/null +++ b/stdio/ungetc.3 @@ -0,0 +1,101 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)ungetc.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdio/ungetc.3,v 1.12 2001/10/01 16:08:59 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt UNGETC 3 +.Os +.Sh NAME +.Nm ungetc +.Nd un-get character from input stream +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.Ft int +.Fn ungetc "int c" "FILE *stream" +.Sh DESCRIPTION +The +.Fn ungetc +function pushes the character +.Fa c +(converted to an unsigned char) +back onto the input stream pointed to by +.Fa stream . +The pushed-back characters will be returned by subsequent reads on the +stream (in reverse order). +A successful intervening call, +using the same stream, +to one of the file positioning functions +.Xr ( fseek 3 , +.Xr fsetpos 3 , +or +.Xr rewind 3 ) +will discard the pushed back characters. +.Pp +One character of push-back is guaranteed, +but as long as there is sufficient memory, +an effectively infinite amount of pushback is allowed. +.Pp +If a character is successfully pushed-back, +the end-of-file indicator for the stream is cleared. +The file-position indicator is decremented +by each successful call to +.Fn ungetc ; +if its value was 0 before a call, its value is unspecified after +the call. +.Sh RETURN VALUES +The +.Fn ungetc +function returns the character pushed-back after the conversion, +or +.Dv EOF +if the operation fails. +If the value of the argument +.Fa c +character equals +.Dv EOF , +the operation will fail and the stream will remain unchanged. +.Sh SEE ALSO +.Xr fseek 3 , +.Xr getc 3 , +.Xr setvbuf 3 +.Sh STANDARDS +The +.Fn ungetc +function conforms to +.St -isoC . diff --git a/stdio.subproj/ungetc.c b/stdio/ungetc.c similarity index 100% rename from stdio.subproj/ungetc.c rename to stdio/ungetc.c diff --git a/stdio/vasprintf.c b/stdio/vasprintf.c new file mode 100644 index 0000000..0937701 --- /dev/null +++ b/stdio/vasprintf.c @@ -0,0 +1,65 @@ +/* $OpenBSD: vasprintf.c,v 1.4 1998/06/21 22:13:47 millert Exp $ */ + +/* + * Copyright (c) 1997 Todd C. Miller + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#if defined(LIBC_RCS) && !defined(lint) +static char rcsid[] = "$FreeBSD: src/lib/libc/stdio/vasprintf.c,v 1.11 1999/08/28 00:01:19 peter Exp $"; +#endif /* LIBC_RCS and not lint */ + +#include +#include +#include + +int +vasprintf(str, fmt, ap) + char **str; + const char *fmt; + _BSD_VA_LIST_ ap; +{ + int ret; + FILE f; + + f._file = -1; + f._flags = __SWR | __SSTR | __SALC; + f._bf._base = f._p = (unsigned char *)malloc(128); + if (f._bf._base == NULL) { + *str = NULL; + errno = ENOMEM; + return (-1); + } + f._bf._size = f._w = 127; /* Leave room for the NULL */ + ret = vfprintf(&f, fmt, ap); + *f._p = '\0'; + f._bf._base = reallocf(f._bf._base, f._bf._size + 1); + if (f._bf._base == NULL) { + errno = ENOMEM; + ret = -1; + } + *str = (char *)f._bf._base; + return (ret); +} diff --git a/stdio.subproj/vfprintf.c b/stdio/vfprintf.c similarity index 77% rename from stdio.subproj/vfprintf.c rename to stdio/vfprintf.c index 2e49b6b..d1cf00b 100644 --- a/stdio.subproj/vfprintf.c +++ b/stdio/vfprintf.c @@ -67,6 +67,7 @@ #include #include #include +#include #if __STDC__ #include @@ -79,14 +80,61 @@ /* Define FLOATING_POINT to get floating point. */ #define FLOATING_POINT +union arg { + int intarg; + unsigned int uintarg; + long longarg; + unsigned long ulongarg; + quad_t quadarg; + u_quad_t uquadarg; + void *pvoidarg; + char *pchararg; + short *pshortarg; + int *pintarg; + long *plongarg; + quad_t *pquadarg; +#ifdef FLOATING_POINT + double doublearg; + long double longdoublearg; +#endif +#ifdef ALTIVEC + unsigned char vuchararg[16]; + signed char vchararg[16]; + unsigned short vushortarg[8]; + signed short vshortarg[8]; + unsigned int vuintarg[4]; + signed int vintarg[4]; + float vfloatarg[4]; +#endif +}; static int __sprint __P((FILE *, struct __suio *)); static int __sbprintf __P((FILE *, const char *, va_list)); static char * __ultoa __P((u_long, char *, int, int, char *)); static char * __uqtoa __P((u_quad_t, char *, int, int, char *)); -static void __find_arguments __P((const char *, va_list, void ***)); +static void __find_arguments __P((const char *, va_list, union arg **)); static void __grow_type_table __P((int, unsigned char **, int *)); + /* + * Get the argument indexed by nextarg. If the argument table is + * built, use it to get the argument. If its not, get the next + * argument (and arguments must be gotten sequentially). + */ +#define GETARG(type) \ + ((argtable != NULL) ? *((type*)(&argtable[nextarg++])) : \ + (nextarg++, va_arg(ap, type))) + +#ifdef ALTIVEC +static void getvec(union arg *dst, const union arg *argtable, int nextarg, va_list ap) +{ + vector unsigned char tmp; + + tmp = GETARG(vector unsigned char); + memcpy( dst, &tmp, 16 ); +} + +#endif + /* * Flush out all the vectors defined by the given uio, * then reset it so that it can be reused. @@ -279,6 +327,19 @@ __uqtoa(val, endp, base, octzero, xdigs) static char *cvt __P((double, int, int, char *, int *, int, int *, char **)); static int exponent __P((char *, int, int)); +#if defined(__APPLE__) +/* + * We don't want to be dependent on any libm symbols so use the versions in Libc + */ + +#undef isinf +#undef isnan + +extern int isnan(double); +extern int isinf(double); + +#endif /* __APPLE __ */ + #else /* no FLOATING_POINT */ #define BUF 68 @@ -299,6 +360,7 @@ static int exponent __P((char *, int, int)); #define SHORTINT 0x040 /* short integer */ #define ZEROPAD 0x080 /* zero (as opposed to blank) pad */ #define FPT 0x100 /* Floating point number */ +#define VECTOR 0x200 /* Altivec vector */ int vfprintf(fp, fmt0, ap) FILE *fp; @@ -323,6 +385,11 @@ vfprintf(fp, fmt0, ap) int ndig; /* actual number of digits returned by cvt */ char expstr[7]; /* buffer for exponent string */ char *dtoaresult; /* buffer allocated by dtoa */ +#endif +#ifdef ALTIVEC + union arg vval; /* Vector argument. */ + char *pct; /* Pointer to '%' at beginning of specifier. */ + char vsep; /* Vector separator character. */ #endif u_long ulval = 0; /* integer arguments %[diouxX] */ u_quad_t uqval = 0; /* %q integers */ @@ -337,8 +404,8 @@ vfprintf(fp, fmt0, ap) struct __siov iov[NIOV];/* ... and individual io vectors */ char buf[BUF]; /* space for %c, %[diouxX], %[eEfgG] */ char ox[2]; /* space for 0x hex-prefix */ - void **argtable; /* args, built due to positional arg */ - void *statargtable [STATIC_ARG_TBL_SIZE]; + union arg *argtable; /* args, built due to positional arg */ + union arg statargtable [STATIC_ARG_TBL_SIZE]; int nextarg; /* 1-based argument index */ va_list orgap; /* original argument pointer */ @@ -383,14 +450,6 @@ vfprintf(fp, fmt0, ap) iovp = iov; \ } - /* - * Get the argument indexed by nextarg. If the argument table is - * built, use it to get the argument. If its not, get the next - * argument (and arguments must be gotten sequentially). - */ -#define GETARG(type) \ - ((argtable != NULL) ? *((type*)(argtable[nextarg++])) : \ - (nextarg++, va_arg(ap, type))) /* * To extend shorts properly, we need both signed and unsigned @@ -471,6 +530,9 @@ vfprintf(fp, fmt0, ap) } if (ch == '\0') goto done; +#ifdef ALTIVEC + pct = fmt; +#endif fmt++; /* skip over '%' */ flags = 0; @@ -478,6 +540,9 @@ vfprintf(fp, fmt0, ap) width = 0; prec = -1; sign = '\0'; +#ifdef ALTIVEC + vsep = 'X'; /* Illegal value, changed to defaults later. */ +#endif rflag: ch = *fmt++; reswitch: switch (ch) { @@ -493,6 +558,11 @@ reswitch: switch (ch) { case '#': flags |= ALT; goto rflag; +#ifdef ALTIVEC + case ',': case ';': case ':': case '_': + vsep = ch; + goto rflag; +#endif case '*': /* * ``A negative field width argument is taken as a @@ -554,6 +624,11 @@ reswitch: switch (ch) { case 'L': flags |= LONGDBL; goto rflag; +#endif +#ifdef ALTIVEC + case 'v': + flags |= VECTOR; + goto rflag; #endif case 'h': flags |= SHORTINT; @@ -567,7 +642,20 @@ reswitch: switch (ch) { case 'q': flags |= QUADINT; goto rflag; + case 'z': + if (sizeof(size_t) == sizeof(long)) + flags |= LONGINT; + if (sizeof(size_t) == sizeof(quad_t)) + flags |= QUADINT; + goto rflag; case 'c': +#ifdef ALTIVEC + if (flags & VECTOR) { + getvec(&vval, argtable, nextarg, ap); + nextarg++; + break; + } +#endif *(cp = buf) = GETARG(int); size = 1; sign = '\0'; @@ -577,6 +665,12 @@ reswitch: switch (ch) { /*FALLTHROUGH*/ case 'd': case 'i': +#ifdef ALTIVEC + if (flags & VECTOR) { + getvec(&vval, argtable, nextarg, ap); + break; + } else +#endif if (flags & QUADINT) { uqval = GETARG(quad_t); if ((quad_t)uqval < 0) { @@ -596,9 +690,25 @@ reswitch: switch (ch) { case 'e': case 'E': case 'f': +#ifdef ALTIVEC + if (flags & VECTOR) { + flags |= FPT; + getvec(&vval, argtable, nextarg, ap); + nextarg++; + break; + } +#endif goto fp_begin; case 'g': case 'G': +#ifdef ALTIVEC + if (flags & VECTOR) { + flags |= FPT; + getvec(&vval, argtable, nextarg, ap); + nextarg++; + break; + } +#endif if (prec == 0) prec = 1; fp_begin: if (prec == -1) @@ -622,6 +732,10 @@ fp_begin: if (prec == -1) break; } flags |= FPT; + if (dtoaresult != NULL) { + free(dtoaresult); + dtoaresult = NULL; + } cp = cvt(_double, prec, flags, &softsign, &expt, ch, &ndig, &dtoaresult); if (ch == 'g' || ch == 'G') { @@ -669,6 +783,13 @@ fp_begin: if (prec == -1) flags |= LONGINT; /*FALLTHROUGH*/ case 'o': +#ifdef ALTIVEC + if (flags & VECTOR) { + getvec(&vval, argtable, nextarg, ap); + nextarg++; + break; + } else +#endif if (flags & QUADINT) uqval = GETARG(u_quad_t); else @@ -683,6 +804,13 @@ fp_begin: if (prec == -1) * defined manner.'' * -- ANSI X3J11 */ +#ifdef ALTIVEC + if (flags & VECTOR) { + getvec(&vval, argtable, nextarg, ap); + nextarg++; + break; + } +#endif ulval = (u_long)GETARG(void *); base = 16; xdigs = "0123456789abcdef"; @@ -714,6 +842,13 @@ fp_begin: if (prec == -1) flags |= LONGINT; /*FALLTHROUGH*/ case 'u': +#ifdef ALTIVEC + if (flags & VECTOR) { + getvec(&vval, argtable, nextarg, ap); + nextarg++; + break; + } else +#endif if (flags & QUADINT) uqval = GETARG(u_quad_t); else @@ -725,7 +860,15 @@ fp_begin: if (prec == -1) goto hex; case 'x': xdigs = "0123456789abcdef"; -hex: if (flags & QUADINT) +hex: +#ifdef ALTIVEC + if (flags & VECTOR) { + getvec(&vval, argtable, nextarg, ap); + nextarg++; + break; + } else +#endif + if (flags & QUADINT) uqval = GETARG(u_quad_t); else ulval = UARG(); @@ -773,6 +916,180 @@ number: if ((dprec = prec) >= 0) break; } +#ifdef ALTIVEC + if (flags & VECTOR) { + /* + * Do the minimum amount of work necessary to construct + * a format specifier that can be used to recursively + * call vfprintf() for each element in the vector. + */ + int i, j; /* Counter. */ + int vcnt; /* Number of elements in vector. */ + char *vfmt; /* Pointer to format specifier. */ + char vfmt_buf[32]; /* Static buffer for format spec. */ + int vwidth = 0; /* Width specified via '*'. */ + int vprec = 0; /* Precision specified via '*'. */ + union { /* Element. */ + int i; + float f; + } velm; + char *vstr; /* Used for asprintf(). */ + int vlen; /* Length returned by asprintf(). */ + + /* + * Set vfmt. If vfmt_buf may not be big enough, + * malloc() space, taking care to free it later. + */ + if (&fmt[-1] - pct < sizeof(vfmt_buf)) + vfmt = vfmt_buf; + else + vfmt = (char *)malloc(&fmt[-1] - pct + 1); + + /* Set the separator character, if not specified. */ + if (vsep == 'X') { + if (ch == 'c') + vsep = '\0'; + else + vsep = ' '; + } + + /* Create the format specifier. */ + for (i = j = 0; i < &fmt[-1] - pct; i++) { + switch (pct[i]) { + case ',': case ';': case ':': case '_': + case 'v': case 'h': case 'l': + /* Ignore. */ + break; + case '*': + if (pct[i - 1] != '.') + vwidth = 1; + else + vprec = 1; + /* FALLTHROUGH */ + default: + vfmt[j++] = pct[i]; + } + } + + /* + * Determine the number of elements in the vector and + * finish up the format specifier. + */ + if (flags & SHORTINT) { + vfmt[j++] = 'h'; + vcnt = 8; + } else if (flags & LONGINT) { + vfmt[j++] = 'l'; + vcnt = 4; + } else { + switch (ch) { + case 'e': + case 'E': + case 'f': + case 'g': + case 'G': + vcnt = 4; + break; + default: + /* + * The default case should never + * happen. + */ + case 'c': + case 'd': + case 'i': + case 'u': + case 'o': + case 'p': + case 'x': + case 'X': + vcnt = 16; + } + } + vfmt[j++] = ch; + vfmt[j++] = '\0'; + +/* Get a vector element. */ +#define VPRINT(cnt, ind, args...) do { \ + if (flags & FPT) { \ + velm.f = vval.vfloatarg[ind]; \ + vlen = asprintf(&vstr, vfmt , ## args, velm.f); \ + } else { \ + switch (cnt) { \ + default: \ + /* The default case should never happen. */ \ + case 4: \ + velm.i = vval.vintarg[ind]; \ + break; \ + case 8: \ + velm.i = vval.vshortarg[ind]; \ + break; \ + case 16: \ + velm.i = vval.vchararg[ind]; \ + break; \ + } \ + vlen = asprintf(&vstr, vfmt , ## args, velm.i); \ + } \ + ret += vlen; \ + PRINT(vstr, vlen); \ + FLUSH(); \ + free(vstr); \ +} while (0) + + /* Actually print. */ + if (vwidth == 0) { + if (vprec == 0) { + /* First element. */ + VPRINT(vcnt, 0); + for (i = 1; i < vcnt; i++) { + /* Separator. */ + PRINT(&vsep, 1); + + /* Element. */ + VPRINT(vcnt, i); + } + } else { + /* First element. */ + VPRINT(vcnt, 0, prec); + for (i = 1; i < vcnt; i++) { + /* Separator. */ + PRINT(&vsep, 1); + + /* Element. */ + VPRINT(vcnt, i, prec); + } + } + } else { + if (vprec == 0) { + /* First element. */ + VPRINT(vcnt, 0, width); + for (i = 1; i < vcnt; i++) { + /* Separator. */ + PRINT(&vsep, 1); + + /* Element. */ + VPRINT(vcnt, i, width); + } + } else { + /* First element. */ + VPRINT(vcnt, 0, width, prec); + for (i = 1; i < vcnt; i++) { + /* Separator. */ + PRINT(&vsep, 1); + + /* Element. */ + VPRINT(vcnt, i, width, prec); + } + } + } +#undef VPRINT + + if (vfmt != vfmt_buf) + free(vfmt); + + continue; + } +#endif /* * All reasonable formats wind up here. At this point, `cp' * points to a string which (if not flags&LADJUST) should be @@ -867,6 +1184,7 @@ number: if ((dprec = prec) >= 0) #else PRINT(cp, size); #endif + /* left-adjusting padding (always blank) */ if (flags & LADJUST) PAD(width - realsz, blanks); @@ -912,6 +1230,7 @@ error: #define T_LONG_DOUBLE 14 #define TP_CHAR 15 #define TP_VOID 16 +#define T_VECTOR 17 /* * Find all arguments when a positional parameter is encountered. Returns a @@ -923,7 +1242,7 @@ static void __find_arguments (fmt0, ap, argtable) const char *fmt0; va_list ap; - void ***argtable; + union arg **argtable; { register char *fmt; /* format string */ register int ch; /* character from fmt */ @@ -1046,13 +1365,23 @@ reswitch: switch (ch) { flags |= QUADINT; goto rflag; case 'c': - ADDTYPE(T_INT); +#ifdef ALTIVEC + if (flags & VECTOR) + ADDTYPE(T_VECTOR); + else +#endif + ADDTYPE(T_INT); break; case 'D': flags |= LONGINT; /*FALLTHROUGH*/ case 'd': case 'i': +#ifdef ALTIVEC + if (flags & VECTOR) + ADDTYPE(T_VECTOR); + else +#endif if (flags & QUADINT) { ADDTYPE(T_QUAD); } else { @@ -1065,6 +1394,11 @@ reswitch: switch (ch) { case 'f': case 'g': case 'G': +#ifdef ALTIVEC + if (flags & VECTOR) + ADDTYPE(T_VECTOR); + else +#endif if (flags & LONGDBL) ADDTYPE(T_LONG_DOUBLE); else @@ -1085,13 +1419,23 @@ reswitch: switch (ch) { flags |= LONGINT; /*FALLTHROUGH*/ case 'o': +#ifdef ALTIVEC + if (flags & VECTOR) + ADDTYPE(T_VECTOR); + else +#endif if (flags & QUADINT) ADDTYPE(T_U_QUAD); else ADDUARG(); break; case 'p': - ADDTYPE(TP_VOID); +#ifdef ALTIVEC + if (flags & VECTOR) + ADDTYPE(T_VECTOR); + else +#endif + ADDTYPE(TP_VOID); break; case 's': ADDTYPE(TP_CHAR); @@ -1100,6 +1444,11 @@ reswitch: switch (ch) { flags |= LONGINT; /*FALLTHROUGH*/ case 'u': +#ifdef ALTIVEC + if (flags & VECTOR) + ADDTYPE(T_VECTOR); + else +#endif if (flags & QUADINT) ADDTYPE(T_U_QUAD); else @@ -1107,6 +1456,11 @@ reswitch: switch (ch) { break; case 'X': case 'x': +#ifdef ALTIVEC + if (flags & VECTOR) + ADDTYPE(T_VECTOR); + else +#endif if (flags & QUADINT) ADDTYPE(T_U_QUAD); else @@ -1123,63 +1477,71 @@ done: * Build the argument table. */ if (tablemax >= STATIC_ARG_TBL_SIZE) { - *argtable = (void **) - malloc (sizeof (void *) * (tablemax + 1)); + *argtable = (union arg *) + malloc (sizeof (union arg) * (tablemax + 1)); } - (*argtable) [0] = NULL; + (*argtable) [0].intarg = NULL; for (n = 1; n <= tablemax; n++) { switch (typetable [n]) { case T_UNUSED: - (*argtable) [n] = (void *) &va_arg (ap, int); + (*argtable) [n].intarg = va_arg (ap, int); break; case T_SHORT: - (*argtable) [n] = (void *) &va_arg (ap, int); + (*argtable) [n].intarg = va_arg (ap, int); break; case T_U_SHORT: - (*argtable) [n] = (void *) &va_arg (ap, int); + (*argtable) [n].intarg = va_arg (ap, int); break; case TP_SHORT: - (*argtable) [n] = (void *) &va_arg (ap, short *); + (*argtable) [n].pshortarg = va_arg (ap, short *); break; case T_INT: - (*argtable) [n] = (void *) &va_arg (ap, int); + (*argtable) [n].intarg = va_arg (ap, int); break; case T_U_INT: - (*argtable) [n] = (void *) &va_arg (ap, unsigned int); + (*argtable) [n].uintarg = va_arg (ap, unsigned int); break; case TP_INT: - (*argtable) [n] = (void *) &va_arg (ap, int *); + (*argtable) [n].pintarg = va_arg (ap, int *); break; case T_LONG: - (*argtable) [n] = (void *) &va_arg (ap, long); + (*argtable) [n].longarg = va_arg (ap, long); break; case T_U_LONG: - (*argtable) [n] = (void *) &va_arg (ap, unsigned long); + (*argtable) [n].ulongarg = va_arg (ap, unsigned long); break; case TP_LONG: - (*argtable) [n] = (void *) &va_arg (ap, long *); + (*argtable) [n].plongarg = va_arg (ap, long *); break; case T_QUAD: - (*argtable) [n] = (void *) &va_arg (ap, quad_t); + (*argtable) [n].quadarg = va_arg (ap, quad_t); break; case T_U_QUAD: - (*argtable) [n] = (void *) &va_arg (ap, u_quad_t); + (*argtable) [n].uquadarg = va_arg (ap, u_quad_t); break; case TP_QUAD: - (*argtable) [n] = (void *) &va_arg (ap, quad_t *); + (*argtable) [n].pquadarg = va_arg (ap, quad_t *); break; +#ifdef FLOATING_POINT case T_DOUBLE: - (*argtable) [n] = (void *) &va_arg (ap, double); + (*argtable) [n].doublearg = va_arg (ap, double); break; case T_LONG_DOUBLE: - (*argtable) [n] = (void *) &va_arg (ap, long double); + (*argtable) [n].longdoublearg = va_arg (ap, long double); break; +#endif +#ifdef ALTIVEC + case T_VECTOR: + { int tmp = 0; + getvec( &((*argtable) [n]), NULL, tmp, ap ); + } +#endif case TP_CHAR: - (*argtable) [n] = (void *) &va_arg (ap, char *); + (*argtable) [n].pchararg = va_arg (ap, char *); break; case TP_VOID: - (*argtable) [n] = (void *) &va_arg (ap, void *); + (*argtable) [n].pvoidarg = va_arg (ap, void *); break; } } diff --git a/stdio.subproj/vfscanf.c b/stdio/vfscanf.c similarity index 98% rename from stdio.subproj/vfscanf.c rename to stdio/vfscanf.c index a12e167..35bb094 100644 --- a/stdio.subproj/vfscanf.c +++ b/stdio/vfscanf.c @@ -179,11 +179,20 @@ literal: flags |= SUPPRESS; goto again; case 'l': - flags |= LONG; + if( flags & LONG ) + flags |= QUAD; + else + flags |= LONG; goto again; case 'q': flags |= QUAD; goto again; + case 'z': + if( sizeof(size_t) == sizeof(long) ) + flags |= LONG; + if( sizeof(size_t) == sizeof(quad_t) ) + flags |= QUAD; + goto again; case 'L': flags |= LONGDBL; goto again; @@ -566,10 +575,10 @@ literal: *va_arg(ap, void **) = (void *)res; else if (flags & SHORT) *va_arg(ap, short *) = res; - else if (flags & LONG) - *va_arg(ap, long *) = res; else if (flags & QUAD) *va_arg(ap, quad_t *) = res; + else if (flags & LONG) + *va_arg(ap, long *) = res; else *va_arg(ap, int *) = res; nassigned++; @@ -655,7 +664,7 @@ literal: (void) ungetc(c, fp); } if ((flags & SUPPRESS) == 0) { - double res; + long double res; *p = 0; res = strtod(buf,(char **) NULL); diff --git a/stdio.subproj/vprintf.c b/stdio/vprintf.c similarity index 100% rename from stdio.subproj/vprintf.c rename to stdio/vprintf.c diff --git a/stdio.subproj/vscanf.c b/stdio/vscanf.c similarity index 100% rename from stdio.subproj/vscanf.c rename to stdio/vscanf.c diff --git a/stdio.subproj/vsnprintf.c b/stdio/vsnprintf.c similarity index 100% rename from stdio.subproj/vsnprintf.c rename to stdio/vsnprintf.c diff --git a/stdio.subproj/vsprintf.c b/stdio/vsprintf.c similarity index 100% rename from stdio.subproj/vsprintf.c rename to stdio/vsprintf.c diff --git a/stdio.subproj/vsscanf.c b/stdio/vsscanf.c similarity index 100% rename from stdio.subproj/vsscanf.c rename to stdio/vsscanf.c diff --git a/stdio.subproj/wbuf.c b/stdio/wbuf.c similarity index 100% rename from stdio.subproj/wbuf.c rename to stdio/wbuf.c diff --git a/stdio.subproj/wsetup.c b/stdio/wsetup.c similarity index 100% rename from stdio.subproj/wsetup.c rename to stdio/wsetup.c diff --git a/stdlib.subproj/Makefile b/stdlib.subproj/Makefile deleted file mode 100644 index f952411..0000000 --- a/stdlib.subproj/Makefile +++ /dev/null @@ -1,51 +0,0 @@ -# -# Generated by the NeXT Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = stdlib - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -HFILES = atexit.h - -CFILES = abort.c atexit.c atof.c atoi.c atol.c bsearch.c div.c\ - exit.c getenv.c getopt.c getsubopt.c heapsort.c labs.c\ - ldiv.c merge.c putenv.c qsort.c radixsort.c rand.c random.c\ - setenv.c strtod.c strtol.c strtoq.c strtoul.c strtouq.c\ - system.c - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble - - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - - - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/stdlib.subproj/Makefile.postamble b/stdlib.subproj/Makefile.postamble deleted file mode 100644 index 411cde6..0000000 --- a/stdlib.subproj/Makefile.postamble +++ /dev/null @@ -1,100 +0,0 @@ -############################################################################### -# Makefile.postamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile, which is imported after all other makefiles, to -# override attributes for a project's Makefile environment. This allows you -# to take advantage of the environment set up by the other Makefiles. -# You can also define custom rules at the end of this file. -# -############################################################################### -# -# These variables are exported by the standard makefiles and can be -# used in any customizations you make. They are *outputs* of -# the Makefiles and should be used, not set. -# -# PRODUCTS: products to install. All of these products will be placed in -# the directory $(DSTROOT)$(INSTALLDIR) -# GLOBAL_RESOURCE_DIR: The directory to which resources are copied. -# LOCAL_RESOURCE_DIR: The directory to which localized resources are copied. -# OFILE_DIR: Directory into which .o object files are generated. -# DERIVED_SRC_DIR: Directory used for all other derived files -# -# ALL_CFLAGS: flags to pass when compiling .c files -# ALL_MFLAGS: flags to pass when compiling .m files -# ALL_CCFLAGS: flags to pass when compiling .cc, .cxx, and .C files -# ALL_MMFLAGS: flags to pass when compiling .mm, .mxx, and .M files -# ALL_PRECOMPFLAGS: flags to pass when precompiling .h files -# ALL_LDFLAGS: flags to pass when linking object files -# ALL_LIBTOOL_FLAGS: flags to pass when libtooling object files -# ALL_PSWFLAGS: flags to pass when processing .psw and .pswm (pswrap) files -# ALL_RPCFLAGS: flags to pass when processing .rpc (rpcgen) files -# ALL_YFLAGS: flags to pass when processing .y (yacc) files -# ALL_LFLAGS: flags to pass when processing .l (lex) files -# -# NAME: name of application, bundle, subproject, palette, etc. -# LANGUAGES: langages in which the project is written (default "English") -# English_RESOURCES: localized resources (e.g. nib's, images) of project -# GLOBAL_RESOURCES: non-localized resources of project -# -# SRCROOT: base directory in which to place the new source files -# SRCPATH: relative path from SRCROOT to present subdirectory -# -# INSTALLDIR: Directory the product will be installed into by 'install' target -# PUBLIC_HDR_INSTALLDIR: where to install public headers. Don't forget -# to prefix this with DSTROOT when you use it. -# PRIVATE_HDR_INSTALLDIR: where to install private headers. Don't forget -# to prefix this with DSTROOT when you use it. -# -# EXECUTABLE_EXT: Executable extension for the platform (i.e. .exe on Windows) -# -############################################################################### - -# Some compiler flags can be overridden here for certain build situations. -# -# WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost) -# DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults -# to -g) -# DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG) -# OPTIMIZE_BUILD_CFLAGS: flags passed during optimized builds (defaults -# to -O) -# PROFILE_BUILD_CFLAGS: flags passed during profile builds (defaults -# to -pg -DPROFILE) -# LOCAL_DIR_INCLUDE_DIRECTIVE: flag used to add current directory to -# the include path (defaults to -I.) -# DEBUG_BUILD_LDFLAGS, OPTIMIZE_BUILD_LDFLAGS, PROFILE_BUILD_LDFLAGS: flags -# passed to ld/libtool (defaults to nothing) - - -# Library and Framework projects only: -# INSTALL_NAME_DIRECTIVE: This directive ensures that executables linked -# against the framework will run against the correct version even if -# the current version of the framework changes. You may override this -# to "" as an alternative to using the DYLD_LIBRARY_PATH during your -# development cycle, but be sure to restore it before installing. - - -# Ownership and permissions of files installed by 'install' target - -#INSTALL_AS_USER = root - # User/group ownership -#INSTALL_AS_GROUP = wheel - # (probably want to set both of these) -#INSTALL_PERMISSIONS = - # If set, 'install' chmod's executable to this - - -# Options to strip. Note: -S strips debugging symbols (executables can be stripped -# down further with -x or, if they load no bundles, with no options at all). - -#STRIPFLAGS = -S - - -######################################################################### -# Put rules to extend the behavior of the standard Makefiles here. Include them in -# the dependency tree via cvariables like AFTER_INSTALL in the Makefile.preamble. -# -# You should avoid redefining things like "install" or "app", as they are -# owned by the top-level Makefile API and no context has been set up for where -# derived files should go. -# diff --git a/stdlib.subproj/Makefile.preamble b/stdlib.subproj/Makefile.preamble deleted file mode 100644 index c1624b4..0000000 --- a/stdlib.subproj/Makefile.preamble +++ /dev/null @@ -1,137 +0,0 @@ -############################################################################### -# Makefile.preamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile for configuring the standard application makefiles -# associated with ProjectBuilder. It is included before the main makefile. -# In Makefile.preamble you set attributes for a project, so they are available -# to the project's makefiles. In contrast, you typically write additional rules or -# override built-in behavior in the Makefile.postamble. -# -# Each directory in a project tree (main project plus subprojects) should -# have its own Makefile.preamble and Makefile.postamble. -############################################################################### -# -# Before the main makefile is included for this project, you may set: -# -# MAKEFILEDIR: Directory in which to find $(MAKEFILE) -# MAKEFILE: Top level mechanism Makefile (e.g., app.make, bundle.make) - -# Compiler/linker flags added to the defaults: The OTHER_* variables will be -# inherited by all nested sub-projects, but the LOCAL_ versions of the same -# variables will not. Put your -I, -D, -U, and -L flags in ProjectBuilder's -# Build Attributes inspector if at all possible. To override the default flags -# that get passed to ${CC} (e.g. change -O to -O2), see Makefile.postamble. The -# variables below are *inputs* to the build process and distinct from the override -# settings done (less often) in the Makefile.postamble. -# -# OTHER_CFLAGS, LOCAL_CFLAGS: additional flags to pass to the compiler -# Note that $(OTHER_CFLAGS) and $(LOCAL_CFLAGS) are used for .h, ...c, .m, -# .cc, .cxx, .C, and .M files. There is no need to respecify the -# flags in OTHER_MFLAGS, etc. -# OTHER_MFLAGS, LOCAL_MFLAGS: additional flags for .m files -# OTHER_CCFLAGS, LOCAL_CCFLAGS: additional flags for .cc, .cxx, and ...C files -# OTHER_MMFLAGS, LOCAL_MMFLAGS: additional flags for .mm and .M files -# OTHER_PRECOMPFLAGS, LOCAL_PRECOMPFLAGS: additional flags used when -# precompiling header files -# OTHER_LDFLAGS, LOCAL_LDFLAGS: additional flags passed to ld and libtool -# OTHER_PSWFLAGS, LOCAL_PSWFLAGS: additional flags passed to pswrap -# OTHER_RPCFLAGS, LOCAL_RPCFLAGS: additional flags passed to rpcgen -# OTHER_YFLAGS, LOCAL_YFLAGS: additional flags passed to yacc -# OTHER_LFLAGS, LOCAL_LFLAGS: additional flags passed to lex - -# These variables provide hooks enabling you to add behavior at almost every -# stage of the make: -# -# BEFORE_PREBUILD: targets to build before installing headers for a subproject -# AFTER_PREBUILD: targets to build after installing headers for a subproject -# BEFORE_BUILD_RECURSION: targets to make before building subprojects -# BEFORE_BUILD: targets to make before a build, but after subprojects -# AFTER_BUILD: targets to make after a build -# -# BEFORE_INSTALL: targets to build before installing the product -# AFTER_INSTALL: targets to build after installing the product -# BEFORE_POSTINSTALL: targets to build before postinstalling every subproject -# AFTER_POSTINSTALL: targts to build after postinstalling every subproject -# -# BEFORE_INSTALLHDRS: targets to build before installing headers for a -# subproject -# AFTER_INSTALLHDRS: targets to build after installing headers for a subproject -# BEFORE_INSTALLSRC: targets to build before installing source for a subproject -# AFTER_INSTALLSRC: targets to build after installing source for a subproject -# -# BEFORE_DEPEND: targets to build before building dependencies for a -# subproject -# AFTER_DEPEND: targets to build after building dependencies for a -# subproject -# -# AUTOMATIC_DEPENDENCY_INFO: if YES, then the dependency file is -# updated every time the project is built. If NO, the dependency -# file is only built when the depend target is invoked. - -# Framework-related variables: -# FRAMEWORK_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the framework's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables - -# Library-related variables: -# PUBLIC_HEADER_DIR: Determines where public exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. For library projects you should -# set this to something like /Developer/Headers/$(NAME). Do not set -# this variable for framework projects unless you do not want the -# header files included in the framework. -# PRIVATE_HEADER_DIR: Determines where private exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. -# LIBRARY_STYLE: This may be either STATIC or DYNAMIC, and determines -# whether the libraries produced are statically linked when they -# are used or if they are dynamically loadable. This defaults to -# DYNAMIC. -# LIBRARY_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the library's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables -# -# INSTALL_AS_USER: owner of the intalled products (default root) -# INSTALL_AS_GROUP: group of the installed products (default wheel) -# INSTALL_PERMISSIONS: permissions of the installed product (default o+rX) -# -# OTHER_RECURSIVE_VARIABLES: The names of variables which you want to be -# passed on the command line to recursive invocations of make. Note that -# the values in OTHER_*FLAGS are inherited by subprojects automatically -- -# you do not have to (and shouldn't) add OTHER_*FLAGS to -# OTHER_RECURSIVE_VARIABLES. - -# Additional headers to export beyond those in the PB.project: -# OTHER_PUBLIC_HEADERS -# OTHER_PROJECT_HEADERS -# OTHER_PRIVATE_HEADERS - -# Additional files for the project's product: <> -# OTHER_RESOURCES: (non-localized) resources for this project -# OTHER_OFILES: relocatables to be linked into this project -# OTHER_LIBS: more libraries to link against -# OTHER_PRODUCT_DEPENDS: other dependencies of this project -# OTHER_SOURCEFILES: other source files maintained by .pre/postamble -# OTHER_GARBAGE: additional files to be removed by `make clean' - -# Set this to YES if you don't want a final libtool call for a library/framework. -# BUILD_OFILES_LIST_ONLY - -# To include a version string, project source must exist in a directory named -# $(NAME).%d[.%d][.%d] and the following line must be uncommented. -# OTHER_GENERATED_OFILES = $(VERS_OFILE) - -# This definition will suppress stripping of debug symbols when an executable -# is installed. By default it is YES. -# STRIP_ON_INSTALL = NO - -# Uncomment to suppress generation of a KeyValueCoding index when installing -# frameworks (This index is used by WOB and IB to determine keys available -# for an object). Set to YES by default. -# PREINDEX_FRAMEWORK = NO - -# Change this definition to install projects somewhere other than the -# standard locations. NEXT_ROOT defaults to "C:/Apple" on Windows systems -# and "" on other systems. -DSTROOT = $(HOME) diff --git a/stdlib.subproj/PB.project b/stdlib.subproj/PB.project deleted file mode 100644 index 7480e6f..0000000 --- a/stdlib.subproj/PB.project +++ /dev/null @@ -1,51 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - H_FILES = (atexit.h); - OTHER_LINKED = ( - abort.c, - atexit.c, - atof.c, - atoi.c, - atol.c, - bsearch.c, - div.c, - exit.c, - getenv.c, - getopt.c, - getsubopt.c, - heapsort.c, - labs.c, - ldiv.c, - merge.c, - putenv.c, - qsort.c, - radixsort.c, - rand.c, - random.c, - setenv.c, - strtod.c, - strtol.c, - strtoq.c, - strtoul.c, - strtouq.c, - system.c - ); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble); - SUBPROJECTS = (); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = stdlib; - PROJECTTYPE = Component; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/stdlib/Makefile.inc b/stdlib/Makefile.inc new file mode 100644 index 0000000..2ed34f1 --- /dev/null +++ b/stdlib/Makefile.inc @@ -0,0 +1,45 @@ +# from @(#)Makefile.inc 8.3 (Berkeley) 2/4/95 +# $FreeBSD: src/lib/libc/stdlib/Makefile.inc,v 1.32 2001/09/07 13:03:16 phantom Exp $ + +# machine-independent stdlib sources +.PATH: ${.CURDIR}/${MACHINE_ARCH}/stdlib ${.CURDIR}/stdlib + +MISRCS+=abort.c bsearch.c getsubopt.c putenv.c setenv.c strtouq.c \ + atexit.c div.c heapsort.c qsort.c strtod.c system.c \ + atof.c exit.c labs.c radixsort.c strtol.c \ + atoi.c getenv.c ldiv.c rand.c strtoq.c \ + atol.c getopt.c merge.c random.c strtoul.c \ + reallocf.c a64l.c l64a.c strtoll.c strtoull.c + +.if ${MACHINE_ARCH} == "alpha" +# XXX Temporary until the assumption that a long is 32-bits is resolved +# XXX FreeBSD's code. NetBSD kludged this with Long = int32_t and +# XXX ULong = u_int32_t +SRCS+= netbsd_strtod.c +.else +SRCS+= strtod.c +.endif + +# machine-dependent stdlib sources +.if exists(${.CURDIR}/${MACHINE_ARCH}/stdlib/Makefile.inc) +.include "${.CURDIR}/${MACHINE_ARCH}/stdlib/Makefile.inc" +.endif + +.if ${LIB} == "c" +MAN3+= abort.3 abs.3 alloca.3 atexit.3 atof.3 atoi.3 atol.3 bsearch.3 \ + div.3 exit.3 getenv.3 getopt.3 getsubopt.3 hcreate.3 labs.3 \ + ldiv.3 malloc.3 memory.3 qsort.3 radixsort.3 rand.3 random.3 \ + realpath.3 strfmon.3 strtod.3 strtol.3 strtoul.3 system.3 tsearch.3 \ + a64l.3 + +MLINKS+=getenv.3 putenv.3 getenv.3 setenv.3 getenv.3 unsetenv.3 +MLINKS+=hcreate.3 hdestroy.3 hcreate.3 hsearch.3 +MLINKS+=qsort.3 heapsort.3 qsort.3 mergesort.3 +MLINKS+=rand.3 rand_r.3 rand.3 srand.3 rand.3 sranddev.3 +MLINKS+=random.3 initstate.3 random.3 setstate.3 random.3 srandom.3 \ + random.3 srandomdev.3 +MLINKS+=strtol.3 strtoll.3 strtol.3 strtoq.3 +MLINKS+=strtoul.3 strtoull.3 strtoul.3 strtouq.3 +MLINKS+=malloc.3 calloc.3 malloc.3 free.3 malloc.3 realloc.3 malloc.3 reallocf.3 +MLINKS+=tsearch.3 tdelete.3 tsearch.3 tfind.3 tsearch.3 twalk.3 a64l.3 l64a.3 +.endif diff --git a/stdlib/a64l.3 b/stdlib/a64l.3 new file mode 100644 index 0000000..0c15487 --- /dev/null +++ b/stdlib/a64l.3 @@ -0,0 +1,145 @@ +.\" Copyright (c) 1997 Todd C. Miller +.\" 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. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +.\" AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +.\" THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +.\" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +.\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +.\" OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" $OpenBSD: a64l.3,v 1.5 2000/04/20 13:50:01 aaron Exp $ +.\" +.Dd August 17, 1997 +.Dt A64L 3 +.Os +.Sh NAME +.Nm a64l , +.Nm l64a +.Nd convert between 32-bit integer and radix-64 ASCII string +.Sh SYNOPSIS +.Fd #include +.Ft long +.Fn a64l "const char *s" +.Ft char * +.Fn l64a "long l" +.Sh DESCRIPTION +The +.Fn a64l +and +.Fn l64a +functions are used to maintain numbers stored in radix-64 +.Tn ASCII +characters. +This is a notation by which 32-bit integers +can be represented by up to six characters; each character represents a +.Dq digit +in a radix-64 notation. +.Pp +The characters used to represent digits are +.Ql \&. +for 0, +.Ql / +for 1, +.Ql 0 +through +.Ql 9 +for 2-11, +.Ql A +through +.Ql Z +for 12-37, and +.Ql a +through +.Ql z +for 38-63. +.Pp +The +.Fn a64l +function takes a pointer to a null-terminated radix-64 representation +and returns a corresponding 32-bit value. +If the string pointed to by +.Fa s +contains more than six characters, +.Fn a64l +will use the first six. +.Fn a64l +scans the character string from left to right, decoding +each character as a 6-bit radix-64 number. +If a long integer is +larger than 32 bits, the return value will be sign-extended. +.Pp +.Fn l64a +takes a long integer argument +.Fa l +and returns a pointer to the corresponding radix-64 representation. +.Sh RETURN VALUES +On success, +.Fn a64l +returns a 32-bit representation of +.Fa s . +If +.Fa s +is a null pointer or if it contains digits other than those described above. +.Fn a64l +returns \-1 and sets the global variable +.Va errno +to +.Er EINVAL . +.Pp +On success, +.Fn l64a +returns a pointer to a string containing the radix-64 representation of +.Fa l . +If +.Fa l +is 0, +.Fn l64a +returns a pointer to the empty string. +If +.Fa l +is negative, +.Fn l64a +returns a null pointer and sets the global variable +.Va errno +to +.Er EINVAL . +.Sh WARNINGS +The value returned by +.Fn l64a +is a pointer into a static buffer, the contents of which +will be overwritten by subsequent calls. +.Pp +The value returned by +.Fn a64l +may be incorrect if the value is too large; for that reason, only strings +that resulted from a call to +.Fn l64a +should be used to call +.Fn a64l . +.Pp +If a long integer is larger than 32 bits, only the low-order +32 bits are used. +.Sh STANDARDS +The +.Fn a64l +and +.Fn l64a +functions conform to +.St -xpg4.2 . + diff --git a/stdlib/a64l.c b/stdlib/a64l.c new file mode 100644 index 0000000..67415b4 --- /dev/null +++ b/stdlib/a64l.c @@ -0,0 +1,47 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char *rcsid = "$OpenBSD: a64l.c,v 1.3 1997/08/17 22:58:34 millert Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include + +long +a64l(s) + const char *s; +{ + long value, digit, shift; + int i; + + if (s == NULL) { + errno = EINVAL; + return(-1L); + } + + value = 0; + shift = 0; + for (i = 0; *s && i < 6; i++, s++) { + if (*s >= '.' && *s <= '/') + digit = *s - '.'; + else if (*s >= '0' && *s <= '9') + digit = *s - '0' + 2; + else if (*s >= 'A' && *s <= 'Z') + digit = *s - 'A' + 12; + else if (*s >= 'a' && *s <= 'z') + digit = *s - 'a' + 38; + else { + errno = EINVAL; + return(-1L); + } + + value |= digit << shift; + shift += 6; + } + + return(value); +} + diff --git a/stdlib/abort.3 b/stdlib/abort.3 new file mode 100644 index 0000000..07ca798 --- /dev/null +++ b/stdlib/abort.3 @@ -0,0 +1,83 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)abort.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdlib/abort.3,v 1.9 2001/09/09 18:52:00 asmodai Exp $ +.\" +.Dd June 4, 1993 +.Dt ABORT 3 +.Os +.Sh NAME +.Nm abort +.Nd cause abnormal program termination +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft void +.Fn abort void +.Sh DESCRIPTION +The +.Fn abort +function causes abnormal program termination to occur, unless the +signal +.Dv SIGABRT +is being caught and the signal handler does not return. +.Pp +Any open streams are flushed and closed. +.Sh IMPLEMENTATION NOTES +The +.Fn abort +function is thread-safe. +It is unknown if it is async-cancel-safe. +.Sh RETURN VALUES +The +.Fn abort +function +never returns. +.Sh SEE ALSO +.Xr sigaction 2 , +.Xr exit 3 +.Sh STANDARDS +The +.Fn abort +function +conforms to +.St -p1003.1-90 . +The +.Fn abort +function also conforms to +.St -isoC-99 +with the implementation specific details as noted above. diff --git a/stdlib.subproj/abort.c b/stdlib/abort.c similarity index 82% rename from stdlib.subproj/abort.c rename to stdlib/abort.c index df2ae6e..5616ad9 100644 --- a/stdlib.subproj/abort.c +++ b/stdlib/abort.c @@ -61,16 +61,19 @@ void abort() { + int mypid = getpid(); + volatile long i; + volatile long *excp = 0; sigset_t mask; sigfillset(&mask); /* * don't block SIGABRT to give any handler a chance; we ignore - * any errors -- X311J doesn't allow abort to return anyway. + * any errors -- X3J11 doesn't allow abort to return anyway. */ sigdelset(&mask, SIGABRT); (void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL); - (void)kill(getpid(), SIGABRT); + (void)kill(mypid, SIGABRT); /* * if SIGABRT ignored, or caught and the handler returns, do @@ -78,6 +81,26 @@ abort() */ (void)signal(SIGABRT, SIG_DFL); (void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL); - (void)kill(getpid(), SIGABRT); - exit(1); + (void)kill(mypid, SIGABRT); + + i = *excp; /* still no joy; cause a processor trap */ + i = *++excp; /* maybe an unaligned address will do it */ + + /* okay, let's try to write text space */ + excp = (volatile long *)&abort; + *excp = ~*excp; + *excp = ~*excp; + + i /= 0; /* this time for sure! */ + + /* increasing desperation; try signals until one of them sticks */ + (void)kill(mypid, SIGILL); + (void)kill(mypid, SIGBUS); + + /* almost last resort */ + _exit(1); + + /* if _exit returns, do not return */ + for (;;) + sleep(600); } diff --git a/stdlib/abs.3 b/stdlib/abs.3 new file mode 100644 index 0000000..e1d0337 --- /dev/null +++ b/stdlib/abs.3 @@ -0,0 +1,77 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)abs.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdlib/abs.3,v 1.10 2001/09/07 14:46:35 asmodai Exp $ +.\" +.Dd June 4, 1993 +.Dt ABS 3 +.Os +.Sh NAME +.Nm abs +.Nd integer absolute value function +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft int +.Fn abs "int j" +.Sh DESCRIPTION +The +.Fn abs +function +computes +the absolute value of the integer +.Ar j . +.Sh RETURN VALUES +The +.Fn abs +function +returns +the absolute value. +.Sh SEE ALSO +.Xr cabs 3 , +.Xr fabs 3 , +.Xr floor 3 , +.Xr hypot 3 , +.Xr labs 3 , +.Xr math 3 +.Sh STANDARDS +The +.Fn abs +function conforms to +.St -isoC . +.Sh BUGS +The absolute value of the most negative integer remains negative. diff --git a/stdlib/alloca.3 b/stdlib/alloca.3 new file mode 100644 index 0000000..9567ded --- /dev/null +++ b/stdlib/alloca.3 @@ -0,0 +1,81 @@ +.\" Copyright (c) 1980, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)alloca.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdlib/alloca.3,v 1.8 2001/09/07 14:46:35 asmodai Exp $ +.\" +.Dd June 4, 1993 +.Dt ALLOCA 3 +.Os +.Sh NAME +.Nm alloca +.Nd memory allocator +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft void * +.Fn alloca "size_t size" +.Sh DESCRIPTION +The +.Fn alloca +function +allocates +.Fa size +bytes of space in the stack frame of the caller. +This temporary space is automatically freed on +return. +.Sh RETURN VALUES +The +.Fn alloca +function returns a pointer to the beginning of the allocated space. +If the allocation failed, a +.Dv NULL +pointer is returned. +.Sh SEE ALSO +.Xr brk 2 , +.Xr calloc 3 , +.Xr getpagesize 3 , +.Xr malloc 3 , +.Xr realloc 3 +.Sh BUGS +The +.Fn alloca +function +is machine dependent; its use is discouraged. +.\" .Sh HISTORY +.\" The +.\" .Fn alloca +.\" function appeared in +.\" .Bx ?? . +.\" The function appeared in 32v, pwb and pwb.2 and in 3bsd 4bsd +.\" The first man page (or link to a man page that I can find at the +.\" moment is 4.3... diff --git a/stdlib/atexit.3 b/stdlib/atexit.3 new file mode 100644 index 0000000..f1b0acf --- /dev/null +++ b/stdlib/atexit.3 @@ -0,0 +1,80 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)atexit.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdlib/atexit.3,v 1.7 2001/09/07 14:46:35 asmodai Exp $ +.\" +.Dd June 4, 1993 +.Dt ATEXIT 3 +.Os +.Sh NAME +.Nm atexit +.Nd register a function to be called on exit +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft int +.Fn atexit "void (*function)(void)" +.Sh DESCRIPTION +The +.Fn atexit +function +registers the given +.Ar function +to be called at program exit, whether via +.Xr exit 3 +or via return from the program's +.Em main . +Functions so registered are called in reverse order; +no arguments are passed. +At least 32 functions can always be registered, +and more are allowed as long as sufficient memory can be allocated. +.Sh RETURN VALUES +.Rv -std atexit +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er ENOMEM +No memory was available to add the function to the list. +The existing list of functions is unmodified. +.El +.Sh SEE ALSO +.Xr exit 3 +.Sh STANDARDS +The +.Fn atexit +function +conforms to +.St -isoC . diff --git a/stdlib.subproj/atexit.c b/stdlib/atexit.c similarity index 100% rename from stdlib.subproj/atexit.c rename to stdlib/atexit.c diff --git a/stdlib.subproj/atexit.h b/stdlib/atexit.h similarity index 100% rename from stdlib.subproj/atexit.h rename to stdlib/atexit.h diff --git a/stdlib/atof.3 b/stdlib/atof.3 new file mode 100644 index 0000000..1f5042d --- /dev/null +++ b/stdlib/atof.3 @@ -0,0 +1,97 @@ +.\" Copyright (c) 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)atof.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdlib/atof.3,v 1.12 2001/09/26 20:10:10 asmodai Exp $ +.\" +.Dd June 4, 1993 +.Dt ATOF 3 +.Os +.Sh NAME +.Nm atof +.Nd convert +.Tn ASCII +string to double +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft double +.Fn atof "const char *nptr" +.Sh DESCRIPTION +The +.Fn atof +function converts the initial portion of the string pointed to by +.Ar nptr +to +.Ar double +representation. +.Pp +It is equivalent to: +.Bd -literal -offset indent +strtod(nptr, (char **)NULL); +.Ed +.Pp +The decimal point +character is defined in the program's locale (category +.Dv LC_NUMERIC ) . +.Sh IMPLEMENTATION NOTES +The +.Fn atof +function is not thread-safe and also not async-cancel-safe. +.Pp +The +.Fn atof +function has been deprecated by +.Fn strtod +and should not be used in new code. +.Sh ERRORS +The +.Fn atof +function does not detect errors. +.Sh SEE ALSO +.Xr atoi 3 , +.Xr atol 3 , +.Xr strtod 3 , +.Xr strtol 3 , +.Xr strtoul 3 +.Sh STANDARDS +The +.Fn atof +function conforms to +.St -p1003.1-90 , +.St -isoC , +and +.St -isoC-99 . diff --git a/stdlib.subproj/atof.c b/stdlib/atof.c similarity index 100% rename from stdlib.subproj/atof.c rename to stdlib/atof.c diff --git a/stdlib/atoi.3 b/stdlib/atoi.3 new file mode 100644 index 0000000..40ac028 --- /dev/null +++ b/stdlib/atoi.3 @@ -0,0 +1,93 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)atoi.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdlib/atoi.3,v 1.8 2001/10/01 12:44:24 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt ATOI 3 +.Os +.Sh NAME +.Nm atoi +.Nd convert +.Tn ASCII +string to integer +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft int +.Fn atoi "const char *nptr" +.Sh DESCRIPTION +The +.Fn atoi +function converts the initial portion of the string pointed to by +.Em nptr +to +.Em integer +representation. +.Pp +It is equivalent to: +.Bd -literal -offset indent +(int)strtol(nptr, (char **)NULL, 10); +.Ed +.Sh IMPLEMENTATION NOTES +The +.Fn atoi +function is not thread-safe and also not async-cancel safe. +.Pp +The +.Fn atoi +function has been deprecated by +.Fn strtol +and should not be used in new code. +.Sh ERRORS +The +.Fn atoi +function does not detect errors. +.Sh SEE ALSO +.Xr atof 3 , +.Xr atol 3 , +.Xr strtod 3 , +.Xr strtol 3 , +.Xr strtoul 3 +.Sh STANDARDS +The +.Fn atoi +function conforms to +.St -p1003.1-90 , +.St -isoC , +and +.St -isoC-99 . diff --git a/stdlib.subproj/atoi.c b/stdlib/atoi.c similarity index 100% rename from stdlib.subproj/atoi.c rename to stdlib/atoi.c diff --git a/stdlib/atol.3 b/stdlib/atol.3 new file mode 100644 index 0000000..c18ced0 --- /dev/null +++ b/stdlib/atol.3 @@ -0,0 +1,77 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)atol.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdlib/atol.3,v 1.6 2001/09/07 14:46:35 asmodai Exp $ +.\" +.Dd June 4, 1993 +.Dt ATOL 3 +.Os +.Sh NAME +.Nm atol +.Nd convert +.Tn ASCII +string to long integer +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft long +.Fn atol "const char *nptr" +.Sh DESCRIPTION +The +.Fn atol +function converts the initial portion of the string pointed to by +.Ar nptr +to +.Em long integer +representation. +.Pp +It is equivalent to: +.Bd -literal -offset indent +strtol(nptr, (char **)NULL, 10); +.Ed +.Sh SEE ALSO +.Xr atof 3 , +.Xr atoi 3 , +.Xr strtod 3 , +.Xr strtol 3 , +.Xr strtoul 3 +.Sh STANDARDS +The +.Fn atol +function +conforms to +.St -isoC . diff --git a/stdlib.subproj/atol.c b/stdlib/atol.c similarity index 100% rename from stdlib.subproj/atol.c rename to stdlib/atol.c diff --git a/stdlib/bsearch.3 b/stdlib/bsearch.3 new file mode 100644 index 0000000..25c608d --- /dev/null +++ b/stdlib/bsearch.3 @@ -0,0 +1,93 @@ +.\" Copyright (c) 1990, 1991, 1993, 1994 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)bsearch.3 8.3 (Berkeley) 4/19/94 +.\" $FreeBSD: src/lib/libc/stdlib/bsearch.3,v 1.8 2001/09/07 14:46:35 asmodai Exp $ +.\" +.Dd April 19, 1994 +.Dt BSEARCH 3 +.Os +.Sh NAME +.Nm bsearch +.Nd binary search of a sorted table +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft void * +.Fn bsearch "const void *key" "const void *base" "size_t nmemb" "size_t size" "int (*compar) (const void *, const void *)" +.Sh DESCRIPTION +The +.Fn bsearch +function searches an array of +.Fa nmemb +objects, the initial member of which is +pointed to by +.Fa base , +for a member that matches the object pointed to by +.Fa key . +The size of each member of the array is specified by +.Fa size . +.Pp +The contents of the array should be in ascending sorted order according +to the comparison function referenced by +.Fa compar . +The +.Fa compar +routine +is expected to have +two arguments which point to the +.Fa key +object and to an array member, in that order, and should return an integer +less than, equal to, or greater than zero if the +.Fa key +object is found, respectively, to be less than, to match, or be +greater than the array member. +.Sh RETURN VALUES +The +.Fn bsearch +function returns a pointer to a matching member of the array, or a null +pointer if no match is found. +If two members compare as equal, which member is matched is unspecified. +.Sh SEE ALSO +.Xr db 3 , +.Xr lsearch 3 , +.Xr qsort 3 +.\" .Xr tsearch 3 +.Sh STANDARDS +The +.Fn bsearch +function conforms to +.St -isoC . diff --git a/stdlib.subproj/bsearch.c b/stdlib/bsearch.c similarity index 100% rename from stdlib.subproj/bsearch.c rename to stdlib/bsearch.c diff --git a/stdlib/div.3 b/stdlib/div.3 new file mode 100644 index 0000000..b567fed --- /dev/null +++ b/stdlib/div.3 @@ -0,0 +1,70 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek. +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)div.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdlib/div.3,v 1.6 2001/09/07 14:46:35 asmodai Exp $ +.\" +.Dd June 4, 1993 +.Dt DIV 3 +.Os +.Sh NAME +.Nm div +.Nd return quotient and remainder from division +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft div_t +.Fn div "int num" "int denom" +.Sh DESCRIPTION +The +.Fn div +function +computes the value +.Fa num/denom +and returns the quotient and remainder in a structure named +.Fa div_t +that contains two +.Em int +members named +.Fa quot +and +.Fa rem . +.Sh SEE ALSO +.Xr ldiv 3 +.Sh STANDARDS +The +.Fn div +function +conforms to +.St -isoC . diff --git a/stdlib.subproj/div.c b/stdlib/div.c similarity index 100% rename from stdlib.subproj/div.c rename to stdlib/div.c diff --git a/stdlib/exit.3 b/stdlib/exit.3 new file mode 100644 index 0000000..e74285e --- /dev/null +++ b/stdlib/exit.3 @@ -0,0 +1,98 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)exit.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdlib/exit.3,v 1.10 2001/09/07 14:46:35 asmodai Exp $ +.\" +.Dd June 4, 1993 +.Dt EXIT 3 +.Os +.Sh NAME +.Nm exit +.Nd perform normal program termination +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft void +.Fn exit "int status" +.Sh DESCRIPTION +.Fn Exit +terminates a process. +.Pp +Before termination it performs the following functions in the +order listed: +.Bl -enum -offset indent +.It +Call the functions registered with the +.Xr atexit 3 +function, in the reverse order of their registration. +.It +Flush all open output streams. +.It +Close all open streams. +.It +Unlink all files created with the +.Xr tmpfile 3 +function. +.El +.Pp +Passing arbitrary values back to the environment as +.Ar status +is considered bad style; +you should use the values +.Dv EXIT_SUCCESS +and +.Dv EXIT_FAILURE . +If portability is not a concern, you may +use the values described in +.Xr sysexits 3 . +.Sh RETURN VALUES +The +.Fn exit +function +never returns. +.Sh SEE ALSO +.Xr _exit 2 , +.Xr atexit 3 , +.Xr intro 3 , +.Xr sysexits 3 , +.Xr tmpfile 3 +.Sh STANDARDS +The +.Fn exit +function +conforms to +.St -isoC . diff --git a/stdlib.subproj/exit.c b/stdlib/exit.c similarity index 100% rename from stdlib.subproj/exit.c rename to stdlib/exit.c diff --git a/stdlib/getenv.3 b/stdlib/getenv.3 new file mode 100644 index 0000000..9a2d953 --- /dev/null +++ b/stdlib/getenv.3 @@ -0,0 +1,164 @@ +.\" Copyright (c) 1988, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)getenv.3 8.2 (Berkeley) 12/11/93 +.\" $FreeBSD: src/lib/libc/stdlib/getenv.3,v 1.12 2001/09/07 14:46:35 asmodai Exp $ +.\" +.Dd December 11, 1993 +.Dt GETENV 3 +.Os +.Sh NAME +.Nm getenv , +.Nm putenv , +.Nm setenv , +.Nm unsetenv +.Nd environment variable functions +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft char * +.Fn getenv "const char *name" +.Ft int +.Fn setenv "const char *name" "const char *value" "int overwrite" +.Ft int +.Fn putenv "const char *string" +.Ft void +.Fn unsetenv "const char *name" +.Sh DESCRIPTION +These functions set, unset and fetch environment variables from the +host +.Em environment list . +For compatibility with differing environment conventions, +the given arguments +.Ar name +and +.Ar value +may be appended and prepended, +respectively, +with an equal sign +.Dq Li \&= . +.Pp +The +.Fn getenv +function obtains the current value of the environment variable, +.Ar name . +If the variable +.Ar name +is not in the current environment, +a null pointer is returned. +.Pp +The +.Fn setenv +function inserts or resets the environment variable +.Ar name +in the current environment list. +If the variable +.Ar name +does not exist in the list, +it is inserted with the given +.Ar value . +If the variable does exist, the argument +.Ar overwrite +is tested; if +.Ar overwrite is +zero, the +variable is not reset, otherwise it is reset +to the given +.Ar value . +.Pp +The +.Fn putenv +function takes an argument of the form ``name=value'' and is +equivalent to: +.Bd -literal -offset indent +setenv(name, value, 1); +.Ed +.Pp +The +.Fn unsetenv +function +deletes all instances of the variable name pointed to by +.Fa name +from the list. +.Sh RETURN VALUES +.Rv -std setenv putenv +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er ENOMEM +The function +.Fn setenv +or +.Fn putenv +failed because they were unable to allocate memory for the environment. +.El +.Sh SEE ALSO +.Xr csh 1 , +.Xr sh 1 , +.Xr execve 2 , +.Xr environ 7 +.Sh STANDARDS +The +.Fn getenv +function conforms to +.St -isoC . +.Sh BUGS +Successive calls to +.Fn setenv +or +.Fn putenv +assigning a differently sized +.Ar value +to the same +.Ar name +will result in a memory leak. The +.Fx +semantics for these functions +(namely, that the contents of +.Ar value +are copied and that old values remain accessible indefinitely) make this +bug unavoidable. Future versions may eliminate one or both of these +semantic guarantees in order to fix the bug. +.Sh HISTORY +The functions +.Fn setenv +and +.Fn unsetenv +appeared in +.At v7 . +The +.Fn putenv +function appeared in +.Bx 4.3 Reno . diff --git a/stdlib.subproj/getenv.c b/stdlib/getenv.c similarity index 100% rename from stdlib.subproj/getenv.c rename to stdlib/getenv.c diff --git a/stdlib/getopt.3 b/stdlib/getopt.3 new file mode 100644 index 0000000..7b08faf --- /dev/null +++ b/stdlib/getopt.3 @@ -0,0 +1,266 @@ +.\" Copyright (c) 1988, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)getopt.3 8.5 (Berkeley) 4/27/95 +.\" $FreeBSD: src/lib/libc/stdlib/getopt.3,v 1.20 2001/09/07 14:46:35 asmodai Exp $ +.\" +.Dd April 27, 1995 +.Dt GETOPT 3 +.Os +.Sh NAME +.Nm getopt +.Nd get option character from command line argument list +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Vt extern char *optarg ; +.Vt extern int optind ; +.Vt extern int optopt ; +.Vt extern int opterr ; +.Vt extern int optreset ; +.Ft int +.Fn getopt "int argc" "char * const *argv" "const char *optstring" +.Sh DESCRIPTION +The +.Fn getopt +function incrementally parses a command line argument list +.Fa argv +and returns the next +.Em known +option character. +An option character is +.Em known +if it has been specified in the string of accepted option characters, +.Fa optstring . +.Pp +The option string +.Fa optstring +may contain the following elements: individual characters, and +characters followed by a colon to indicate an option argument +is to follow. +For example, an option string +.Li "\&""x"" +recognizes an option +.Dq Fl x , +and an option string +.Li "\&""x:"" +recognizes an option and argument +.Dq Fl x Ar argument . +It does not matter to +.Fn getopt +if a following argument has leading white space. +.Pp +On return from +.Fn getopt , +.Va optarg +points to an option argument, if it is anticipated, +and the variable +.Va optind +contains the index to the next +.Fa argv +argument for a subsequent call +to +.Fn getopt . +The variable +.Va optopt +saves the last +.Em known +option character returned by +.Fn getopt . +.Pp +The variable +.Va opterr +and +.Va optind +are both initialized to 1. +The +.Va optind +variable may be set to another value before a set of calls to +.Fn getopt +in order to skip over more or less argv entries. +.Pp +In order to use +.Fn getopt +to evaluate multiple sets of arguments, or to evaluate a single set of +arguments multiple times, +the variable +.Va optreset +must be set to 1 before the second and each additional set of calls to +.Fn getopt , +and the variable +.Va optind +must be reinitialized. +.Pp +The +.Fn getopt +function +returns \-1 +when the argument list is exhausted, or +.Ql ?\& +if a non-recognized +option is encountered. +The interpretation of options in the argument list may be cancelled +by the option +.Ql -- +(double dash) which causes +.Fn getopt +to signal the end of argument processing and return \-1. +When all options have been processed (i.e., up to the first non-option +argument), +.Fn getopt +returns \-1. +.Sh DIAGNOSTICS +If the +.Fn getopt +function encounters a character not found in the string +.Va optstring +or detects +a missing option argument it writes an error message to the +.Em stderr +and returns +.Ql ?\& . +Setting +.Va opterr +to a zero will disable these error messages. +If +.Va optstring +has a leading +.Ql \&: +then a missing option argument causes a +.Ql \&: +to be returned in addition to suppressing any error messages. +.Pp +Option arguments are allowed to begin with +.Dq Li \- ; +this is reasonable but +reduces the amount of error checking possible. +.Sh EXTENSIONS +The +.Va optreset +variable was added to make it possible to call the +.Fn getopt +function multiple times. +This is an extension to the +.St -p1003.2 +specification. +.Sh EXAMPLES +.Bd -literal -compact +int bflag, ch, fd; + +bflag = 0; +while ((ch = getopt(argc, argv, "bf:")) != -1) + switch (ch) { + case 'b': + bflag = 1; + break; + case 'f': + if ((fd = open(optarg, O_RDONLY, 0)) < 0) + err(1, "%s", optarg); + break; + case '?': + default: + usage(); + } +argc -= optind; +argv += optind; +.Ed +.Sh HISTORY +The +.Fn getopt +function appeared in +.Bx 4.3 . +.Sh BUGS +The +.Fn getopt +function was once specified to return +.Dv EOF +instead of \-1. +This was changed by +.St -p1003.2-92 +to decouple +.Fn getopt +from +.Pa . +.Pp +A single dash +.Dq Li - +may be specified as a character in +.Fa optstring , +however it should +.Em never +have an argument associated with it. +This allows +.Fn getopt +to be used with programs that expect +.Dq Li - +as an option flag. +This practice is wrong, and should not be used in any current development. +It is provided for backward compatibility +.Em only . +By default, a single dash causes +.Fn getopt +to return \-1. +This is, we believe, compatible with System V. +.Pp +It is also possible to handle digits as option letters. +This allows +.Fn getopt +to be used with programs that expect a number +.Pq Dq Li \&-\&3 +as an option. +This practice is wrong, and should not be used in any current development. +It is provided for backward compatibility +.Em only . +The following code fragment works in most (but not all) cases. +.Bd -literal -offset indent +int length; +char *p, *ep; + +while ((ch = getopt(argc, argv, "0123456789")) != -1) + switch (ch) { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + p = argv[optind - 1]; + if (p[0] == '-' && p[1] == ch && !p[2]) + length = strtol(++p, &ep, 10); + else if (argv[optind] && argv[optind][1] == ch) { + length = strtol((p = argv[optind] + 1), + &ep, 10); + optind++; + optreset = 1; + } else + usage(); + if (*ep != '\0') + errx(EX_USAGE, "illegal number -- %s", p); + break; + } +.Ed diff --git a/stdlib.subproj/getopt.c b/stdlib/getopt.c similarity index 100% rename from stdlib.subproj/getopt.c rename to stdlib/getopt.c diff --git a/stdlib/getsubopt.3 b/stdlib/getsubopt.3 new file mode 100644 index 0000000..83c5f7c --- /dev/null +++ b/stdlib/getsubopt.3 @@ -0,0 +1,149 @@ +.\" Copyright (c) 1990, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)getsubopt.3 8.1 (Berkeley) 6/9/93 +.\" $FreeBSD: src/lib/libc/stdlib/getsubopt.3,v 1.9 2001/09/07 14:46:35 asmodai Exp $ +.\" +.Dd June 9, 1993 +.Dt GETSUBOPT 3 +.Os +.Sh NAME +.Nm getsubopt +.Nd get sub options from an argument +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Vt extern char *suboptarg ; +.Ft int +.Fn getsubopt "char **optionp" "char * const *tokens" "char **valuep" +.Sh DESCRIPTION +The +.Fn getsubopt +function +parses a string containing tokens delimited by one or more tab, space or +comma +.Pq Ql \&, +characters. +It is intended for use in parsing groups of option arguments provided +as part of a utility command line. +.Pp +The argument +.Fa optionp +is a pointer to a pointer to the string. +The argument +.Fa tokens +is a pointer to a +.Dv NULL Ns -terminated +array of pointers to strings. +.Pp +The +.Fn getsubopt +function +returns the zero-based offset of the pointer in the +.Fa tokens +array referencing a string which matches the first token +in the string, or, \-1 if the string contains no tokens or +.Fa tokens +does not contain a matching string. +.Pp +If the token is of the form ``name=value'', the location referenced by +.Fa valuep +will be set to point to the start of the ``value'' portion of the token. +.Pp +On return from +.Fn getsubopt , +.Fa optionp +will be set to point to the start of the next token in the string, +or the null at the end of the string if no more tokens are present. +The external variable +.Fa suboptarg +will be set to point to the start of the current token, or +.Dv NULL +if no +tokens were present. +The argument +.Fa valuep +will be set to point to the ``value'' portion of the token, or +.Dv NULL +if no ``value'' portion was present. +.Sh EXAMPLES +.Bd -literal -compact +char *tokens[] = { + #define ONE 0 + "one", + #define TWO 1 + "two", + NULL +}; + +\&... + +extern char *optarg, *suboptarg; +char *options, *value; + +while ((ch = getopt(argc, argv, "ab:")) != \-1) { + switch(ch) { + case 'a': + /* process ``a'' option */ + break; + case 'b': + options = optarg; + while (*options) { + switch(getsubopt(&options, tokens, &value)) { + case ONE: + /* process ``one'' sub option */ + break; + case TWO: + /* process ``two'' sub option */ + if (!value) + error("no value for two"); + i = atoi(value); + break; + case \-1: + if (suboptarg) + error("illegal sub option %s", + suboptarg); + else + error("missing sub option"); + break; + } + break; + } +.Ed +.Sh SEE ALSO +.Xr getopt 3 , +.Xr strsep 3 +.Sh HISTORY +The +.Fn getsubopt +function first appeared in +.Bx 4.4 . diff --git a/stdlib.subproj/getsubopt.c b/stdlib/getsubopt.c similarity index 100% rename from stdlib.subproj/getsubopt.c rename to stdlib/getsubopt.c diff --git a/stdlib/hcreate.3 b/stdlib/hcreate.3 new file mode 100644 index 0000000..1619c98 --- /dev/null +++ b/stdlib/hcreate.3 @@ -0,0 +1,206 @@ +.\" $FreeBSD: src/lib/libc/stdlib/hcreate.3,v 1.2 2001/07/09 15:54:36 ru Exp $ +.\" +.Dd May 8, 2001 +.Os +.Dt HCREATE 3 +.Sh NAME +.Nm hcreate , hdestroy , hsearch +.Nd manage hash search table +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In search.h +.Ft int +.Fn hcreate "size_t nel" +.Ft void +.Fn hdestroy void +.Ft ENTRY * +.Fn hsearch "ENTRY item" "ACTION action" +.Sh DESCRIPTION +The +.Fn hcreate , +.Fn hdestroy , +and +.Fn hsearch +functions manage hash search tables. +.Pp +The +.Fn hcreate +function allocates sufficient space for the table, and the application should +ensure it is called before +.Fn hsearch +is used. +The +.Fa nel +argument is an estimate of the maximum +number of entries that the table should contain. +This number may be adjusted upward by the +algorithm in order to obtain certain mathematically favorable circumstances. +.Pp +The +.Fn hdestroy +function disposes of the search table, and may be followed by another call to +.Fn hcreate . +After the call to +.Fn hdestroy , +the data can no longer be considered accessible. +.Pp +The +.Fn hsearch +function is a hash-table search routine. +It returns a pointer into a hash table +indicating the location at which an entry can be found. +The +.Fa item +argument is a structure of type +.Vt ENTRY +(defined in the +.Aq Pa search.h +header) containing two pointers: +.Fa item.key +points to the comparison key (a +.Vt "char *" ) , +and +.Fa item.data +(a +.Vt "void *" ) +points to any other data to be associated with +that key. +The comparison function used by +.Fn hsearch +is +.Xr strcmp 3 . +The +.Fa action +argument is a +member of an enumeration type +.Vt ACTION +indicating the disposition of the entry if it cannot be +found in the table. +.Dv ENTER +indicates that the +.Fa item +should be inserted in the table at an +appropriate point. +.Dv FIND +indicates that no entry should be made. +Unsuccessful resolution is +indicated by the return of a +.Dv NULL +pointer. +.Sh RETURN VALUES +The +.Fn hcreate +function returns 0 if it cannot allocate sufficient space for the table; +otherwise, it returns non-zero. +.Pp +The +.Fn hdestroy +function does not return a value. +.Pp +The +.Fn hsearch +function returns a +.Dv NULL +pointer if either the +.Fa action +is +.Dv FIND +and the +.Fa item +could not be found or the +.Fa action +is +.Dv ENTER +and the table is full. +.Sh ERRORS +The +.Fn hcreate +and +.Fn hsearch +functions may fail if: +.Bl -tag -width Er +.It Bq Er ENOMEM +Insufficient storage space is available. +.El +.Sh EXAMPLES +The following example reads in strings followed by two numbers +and stores them in a hash table, discarding duplicates. +It then reads in strings and finds the matching entry in the hash +table and prints it out. +.Bd -literal +#include +#include +#include + +struct info { /* This is the info stored in the table */ + int age, room; /* other than the key. */ +}; + +#define NUM_EMPL 5000 /* # of elements in search table. */ + +int +main(void) +{ + char string_space[NUM_EMPL*20]; /* Space to store strings. */ + struct info info_space[NUM_EMPL]; /* Space to store employee info. */ + char *str_ptr = string_space; /* Next space in string_space. */ + struct info *info_ptr = info_space; /* Next space in info_space. */ + ENTRY item; + ENTRY *found_item; /* Name to look for in table. */ + char name_to_find[30]; + int i = 0; + + /* Create table; no error checking is performed. */ + (void) hcreate(NUM_EMPL); + + while (scanf("%s%d%d", str_ptr, &info_ptr->age, + &info_ptr->room) != EOF && i++ < NUM_EMPL) { + /* Put information in structure, and structure in item. */ + item.key = str_ptr; + item.data = info_ptr; + str_ptr += strlen(str_ptr) + 1; + info_ptr++; + /* Put item into table. */ + (void) hsearch(item, ENTER); + } + + /* Access table. */ + item.key = name_to_find; + while (scanf("%s", item.key) != EOF) { + if ((found_item = hsearch(item, FIND)) != NULL) { + /* If item is in the table. */ + (void)printf("found %s, age = %d, room = %d\en", + found_item->key, + ((struct info *)found_item->data)->age, + ((struct info *)found_item->data)->room); + } else + (void)printf("no such employee %s\en", name_to_find); + } + return 0; +} +.Ed +.Sh SEE ALSO +.Xr bsearch 3 , +.Xr lsearch 3 , +.Xr malloc 3 , +.Xr strcmp 3 , +.Xr tsearch 3 +.Sh STANDARDS +The +.Fn hcreate , +.Fn hdestroy , +and +.Fn hsearch +functions conform to +.St -xpg4.2 . +.Sh HISTORY +The +.Fn hcreate , +.Fn hdestroy , +and +.Fn hsearch +functions first appeared in +.At V . +.Sh BUGS +The interface permits the use of only one hash table at a time. diff --git a/stdlib.subproj/heapsort.c b/stdlib/heapsort.c similarity index 100% rename from stdlib.subproj/heapsort.c rename to stdlib/heapsort.c diff --git a/stdlib/l64a.c b/stdlib/l64a.c new file mode 100644 index 0000000..c666bc6 --- /dev/null +++ b/stdlib/l64a.c @@ -0,0 +1,47 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char *rcsid = "$OpenBSD: l64a.c,v 1.3 1997/08/17 22:58:34 millert Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include + +char * +l64a(value) + long value; +{ + static char buf[8]; + char *s = buf; + int digit; + int i; + + if (value < 0) { + errno = EINVAL; + return(NULL); + } + + for (i = 0; value != 0 && i < 6; i++) { + digit = value & 0x3f; + + if (digit < 2) + *s = digit + '.'; + else if (digit < 12) + *s = digit + '0' - 2; + else if (digit < 38) + *s = digit + 'A' - 12; + else + *s = digit + 'a' - 38; + + value >>= 6; + s++; + } + + *s = '\0'; + + return(buf); +} + diff --git a/stdlib/labs.3 b/stdlib/labs.3 new file mode 100644 index 0000000..8cd757f --- /dev/null +++ b/stdlib/labs.3 @@ -0,0 +1,69 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)labs.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdlib/labs.3,v 1.7 2001/09/07 14:46:35 asmodai Exp $ +.\" +.Dd June 4, 1993 +.Dt LABS 3 +.Os +.Sh NAME +.Nm labs +.Nd return the absolute value of a long integer +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft long +.Fn labs "long j" +.Sh DESCRIPTION +The +.Fn labs +function +returns the absolute value of the long integer +.Ar j . +.Sh SEE ALSO +.Xr abs 3 , +.Xr cabs 3 , +.Xr floor 3 , +.Xr math 3 +.Sh STANDARDS +The +.Fn labs +function +conforms to +.St -isoC . +.Sh BUGS +The absolute value of the most negative integer remains negative. diff --git a/stdlib.subproj/labs.c b/stdlib/labs.c similarity index 100% rename from stdlib.subproj/labs.c rename to stdlib/labs.c diff --git a/stdlib/ldiv.3 b/stdlib/ldiv.3 new file mode 100644 index 0000000..c9f168e --- /dev/null +++ b/stdlib/ldiv.3 @@ -0,0 +1,73 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)ldiv.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdlib/ldiv.3,v 1.7 2001/09/07 14:46:35 asmodai Exp $ +.\" +.Dd June 4, 1993 +.Dt LDIV 3 +.Os +.Sh NAME +.Nm ldiv +.Nd return quotient and remainder from division +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft ldiv_t +.Fn ldiv "long num" "long denom" +.Sh DESCRIPTION +The +.Fn ldiv +function +computes the value +.Ar num/denom +and returns the quotient and remainder in a structure named +.Ar ldiv_t +that contains two +.Em long integer +members named +.Ar quot +and +.Ar rem . +.Sh SEE ALSO +.Xr div 3 , +.Xr math 3 +.Sh STANDARDS +The +.Fn ldiv +function +conforms to +.St -isoC . diff --git a/stdlib.subproj/ldiv.c b/stdlib/ldiv.c similarity index 100% rename from stdlib.subproj/ldiv.c rename to stdlib/ldiv.c diff --git a/stdlib/malloc.3 b/stdlib/malloc.3 new file mode 100644 index 0000000..76af046 --- /dev/null +++ b/stdlib/malloc.3 @@ -0,0 +1,483 @@ +.\" Copyright (c) 1980, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)malloc.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdlib/malloc.3,v 1.49 2001/11/05 00:39:27 dd Exp $ +.\" +.Dd August 27, 1996 +.Dt MALLOC 3 +.Os +.Sh NAME +.Nm malloc , calloc , realloc , free , reallocf +.Nd general purpose memory allocation functions +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft void * +.Fn malloc "size_t size" +.Ft void * +.Fn calloc "size_t number" "size_t size" +.Ft void * +.Fn realloc "void *ptr" "size_t size" +.Ft void * +.Fn reallocf "void *ptr" "size_t size" +.Ft void +.Fn free "void *ptr" +.Ft char * +.Va _malloc_options +.Ft void +.Fn \*(lp*_malloc_message\*(rp "char *p1" "char *p2" "char *p3" "char *p4" +.Sh DESCRIPTION +The +.Fn malloc +function allocates +.Fa size +bytes of memory. +The allocated space is suitably aligned (after possible pointer coercion) +for storage of any type of object. +If the space is at least +.Em pagesize +bytes in length (see +.Xr getpagesize 3 ) , +the returned memory will be page boundary aligned as well. +If +.Fn malloc +fails, a +.Dv NULL +pointer is returned. +.Pp +Note that +.Fn malloc +does +.Em NOT +normally initialize the returned memory to zero bytes. +.Pp +The +.Fn calloc +function allocates space for +.Fa number +objects, +each +.Fa size +bytes in length. +The result is identical to calling +.Fn malloc +with an argument of +.Dq "number * size" , +with the exception that the allocated memory is explicitly initialized +to zero bytes. +.Pp +The +.Fn realloc +function changes the size of the previously allocated memory referenced by +.Fa ptr +to +.Fa size +bytes. +The contents of the memory are unchanged up to the lesser of the new and +old sizes. +If the new size is larger, +the value of the newly allocated portion of the memory is undefined. +If the requested memory cannot be allocated, +.Dv NULL +is returned and +the memory referenced by +.Fa ptr +is valid and unchanged. +If +.Fa ptr +is +.Dv NULL , +the +.Fn realloc +function behaves identically to +.Fn malloc +for the specified size. +.Pp +The +.Fn reallocf +function call is identical to the realloc function call, except that it +will free the passed pointer when the requested memory cannot be allocated. +This is a +.Fx +specific API designed to ease the problems with traditional coding styles +for realloc causing memory leaks in libraries. +.Pp +The +.Fn free +function causes the allocated memory referenced by +.Fa ptr +to be made available for future allocations. +If +.Fa ptr +is +.Dv NULL , +no action occurs. +.Sh TUNING +Once, when the first call is made to one of these memory allocation +routines, various flags will be set or reset, which affect the +workings of this allocation implementation. +.Pp +The ``name'' of the file referenced by the symbolic link named +.Pa /etc/malloc.conf , +the value of the environment variable +.Ev MALLOC_OPTIONS , +and the string pointed to by the global variable +.Va _malloc_options +will be interpreted, in that order, character by character as flags. +.Pp +Most flags are single letters, +where uppercase indicates that the behavior is set, or on, +and lowercase means that the behavior is not set, or off. +.Bl -tag -width indent +.It A +All warnings (except for the warning about unknown +flags being set) become fatal. +The process will call +.Xr abort 3 +in these cases. +.It J +Each byte of new memory allocated by +.Fn malloc , +.Fn realloc +or +.Fn reallocf +as well as all memory returned by +.Fn free , +.Fn realloc +or +.Fn reallocf +will be initialized to 0xd0. +This options also sets the +.Dq R +option. +This is intended for debugging and will impact performance negatively. +.It H +Pass a hint to the kernel about pages unused by the allocation functions. +This will help performance if the system is paging excessively. This +option is off by default. +.It R +Causes the +.Fn realloc +and +.Fn reallocf +functions to always reallocate memory even if the initial allocation was +sufficiently large. +This can substantially aid in compacting memory. +.It U +Generate +.Dq utrace +entries for +.Xr ktrace 1 , +for all operations. +Consult the source for details on this option. +.It V +Attempting to allocate zero bytes will return a +.Dv NULL +pointer instead of +a valid pointer. +(The default behavior is to make a minimal allocation and return a +pointer to it.) +This option is provided for System V compatibility. +This option is incompatible with the +.Dq X +option. +.It X +Rather than return failure for any allocation function, +display a diagnostic message on stderr and cause the program to drop +core (using +.Xr abort 3 ) . +This option should be set at compile time by including the following in +the source code: +.Bd -literal -offset indent +_malloc_options = "X"; +.Ed +.It Z +This option implicitly sets the +.Dq J +and +.Dq R +options, and then zeros out the bytes that were requested. +This is intended for debugging and will impact performance negatively. +.It < +Reduce the size of the cache by a factor of two. +The default cache size is 16 pages. +This option can be specified multiple times. +.It > +Double the size of the cache by a factor of two. +The default cache size is 16 pages. +This option can be specified multiple times. +.El +.Pp +The +.Dq J +and +.Dq Z +options are intended for testing and debugging. +An application which changes its behavior when these options are used +is flawed. +.Sh EXAMPLES +To set a systemwide reduction of cache size, and to dump core whenever +a problem occurs: +.Pp +.Bd -literal -offset indent +ln -s 'A<' /etc/malloc.conf +.Ed +.Pp +To specify in the source that a program does no return value checking +on calls to these functions: +.Bd -literal -offset indent +_malloc_options = "X"; +.Ed +.Sh ENVIRONMENT +The following environment variables affect the execution of the allocation +functions: +.Bl -tag -width ".Ev MALLOC_OPTIONS" +.It Ev MALLOC_OPTIONS +If the environment variable +.Ev MALLOC_OPTIONS +is set, the characters it contains will be interpreted as flags to the +allocation functions. +.El +.Sh RETURN VALUES +The +.Fn malloc +and +.Fn calloc +functions return a pointer to the allocated memory if successful; otherwise +a +.Dv NULL +pointer is returned and +.Va errno +is set to +.Er ENOMEM . +.Pp +The +.Fn realloc +and +.Fn reallocf +functions return a pointer, possibly identical to +.Fa ptr , +to the allocated memory +if successful; otherwise a +.Dv NULL +pointer is returned, in which case the +memory referenced by +.Fa ptr +is still available and intact. +In the case of memory allocation failure, +.Va errno +is set to +.Er ENOMEM . +.Pp +The +.Fn free +function returns no value. +.Sh DEBUGGING MALLOC PROBLEMS +The major difference between this implementation and other allocation +implementations is that the free pages are not accessed unless allocated, +and are aggressively returned to the kernel for reuse. +.Bd -ragged -offset indent +Most allocation implementations will store a data structure containing a +linked list in the free chunks of memory, +used to tie all the free memory together. +That can be suboptimal, +as every time the free-list is traversed, +the otherwise unused, and likely paged out, +pages are faulted into primary memory. +On systems which are paging, +this can result in a factor of five increase in the number of page-faults +done by a process. +.Ed +.Pp +A side effect of this architecture is that many minor transgressions on +the interface which would traditionally not be detected are in fact +detected. As a result, programs that have been running happily for +years may suddenly start to complain loudly, when linked with this +allocation implementation. +.Pp +The first and most important thing to do is to set the +.Dq A +option. +This option forces a coredump (if possible) at the first sign of trouble, +rather than the normal policy of trying to continue if at all possible. +.Pp +It is probably also a good idea to recompile the program with suitable +options and symbols for debugger support. +.Pp +If the program starts to give unusual results, coredump or generally behave +differently without emitting any of the messages listed in the next +section, it is likely because it depends on the storage being filled with +zero bytes. Try running it with +.Dq Z +option set; +if that improves the situation, this diagnosis has been confirmed. +If the program still misbehaves, +the likely problem is accessing memory outside the allocated area, +more likely after than before the allocated area. +.Pp +Alternatively, if the symptoms are not easy to reproduce, setting the +.Dq J +option may help provoke the problem. +.Pp +In truly difficult cases, the +.Dq U +option, if supported by the kernel, can provide a detailed trace of +all calls made to these functions. +.Pp +Unfortunately this implementation does not provide much detail about +the problems it detects, the performance impact for storing such information +would be prohibitive. +There are a number of allocation implementations available on the 'Net +which focus on detecting and pinpointing problems by trading performance +for extra sanity checks and detailed diagnostics. +.Sh DIAGNOSTIC MESSAGES +If +.Fn malloc , +.Fn calloc , +.Fn realloc +or +.Fn free +detect an error or warning condition, +a message will be printed to file descriptor STDERR_FILENO. +Errors will result in the process dumping core. +If the +.Dq A +option is set, all warnings are treated as errors. +.Pp +The +.Va _malloc_message +variable allows the programmer to override the function which emits +the text strings forming the errors and warnings if for some reason +the stderr filedescriptor is not suitable for this. +Please note that doing anything which tries to allocate memory in +this function will assure death of the process. +.Pp +The following is a brief description of possible error messages and +their meanings: +.Pp +.Bl -diag +.It "(ES): mumble mumble mumble" +The allocation functions were compiled with +.Dq EXTRA_SANITY +defined, and an error was found during the additional error checking. +Consult the source code for further information. +.It "mmap(2) failed, check limits" +This most likely means that the system is dangerously overloaded or that +the process' limits are incorrectly specified. +.It "freelist is destroyed" +The internal free-list has been corrupted. +.It "out of memory" +The +.Dq X +option was specified and an allocation of memory failed. +.El +.Pp +The following is a brief description of possible warning messages and +their meanings: +.Bl -diag +.It "chunk/page is already free" +The process attempted to +.Fn free +memory which had already been freed. +.It "junk pointer, ..." +A pointer specified to one of the allocation functions points outside the +bounds of the memory of which they are aware. +.It "malloc() has never been called" +No memory has been allocated, +yet something is being freed or +realloc'ed. +.It "modified (chunk-/page-) pointer" +The pointer passed to +.Fn free +or +.Fn realloc +has been modified. +.It "pointer to wrong page" +The pointer that +.Fn free , +.Fn realloc , +or +.Fn reallocf +is trying to free does not reference a possible page. +.It "recursive call" +A process has attempted to call an allocation function recursively. +This is not permitted. In particular, signal handlers should not +attempt to allocate memory. +.It "unknown char in MALLOC_OPTIONS" +An unknown option was specified. +Even with the +.Dq A +option set, this warning is still only a warning. +.El +.Sh SEE ALSO +.Xr brk 2 , +.Xr mmap 2 , +.Xr alloca 3 , +.Xr getpagesize 3 , +.Xr memory 3 +.Pa /usr/share/doc/papers/malloc.ascii.gz +.Sh STANDARDS +The +.Fn malloc , +.Fn calloc , +.Fn realloc +and +.Fn free +functions conform to +.St -isoC . +.Sh HISTORY +The present allocation implementation started out as a filesystem for a +drum attached to a 20bit binary challenged computer which was built +with discrete germanium transistors. It has since graduated to +handle primary storage rather than secondary. +It first appeared in its new shape and ability in +.Fx 2.2 . +.Pp +The +.Xr reallocf 3 +function first appeared in +.Fx 3.0 . +.Sh AUTHORS +.An Poul-Henning Kamp Aq phk@FreeBSD.org +.Sh BUGS +The messages printed in case of problems provide no detail about the +actual values. +.Pp +It can be argued that returning a +.Dv NULL +pointer when asked to +allocate zero bytes is a silly response to a silly question. diff --git a/stdlib/memory.3 b/stdlib/memory.3 new file mode 100644 index 0000000..25222d4 --- /dev/null +++ b/stdlib/memory.3 @@ -0,0 +1,81 @@ +.\" Copyright (c) 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)memory.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdlib/memory.3,v 1.11 2001/09/07 14:46:35 asmodai Exp $ +.\" +.Dd June 4, 1993 +.Dt MEMORY 3 +.Os +.Sh NAME +.Nm malloc , +.Nm free , +.Nm realloc , +.Nm calloc , +.Nm alloca , +.Nm mmap +.Nd general memory allocation operations +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft void * +.Fn malloc "size_t size" +.Ft void +.Fn free "void *ptr" +.Ft void * +.Fn realloc "void *ptr" "size_t size" +.Ft void * +.Fn calloc "size_t nelem" "size_t elsize" +.Ft void * +.Fn alloca "size_t size" +.In sys/types.h +.In sys/mman.h +.Ft void * +.Fn mmap "void * addr" "size_t len" "int prot" "int flags" "int fd" "off_t offset" +.Sh DESCRIPTION +These functions allocate and free memory for the calling process. +They are described in the +individual manual pages. +.Sh SEE ALSO +.Xr mmap 2 , +.Xr alloca 3 , +.Xr calloc 3 , +.Xr free 3 , +.Xr malloc 3 , +.Xr realloc 3 +.Sh STANDARDS +These functions, with the exception of +.Fn alloca +and +.Fn mmap +conform to +.St -isoC . diff --git a/stdlib.subproj/merge.c b/stdlib/merge.c similarity index 100% rename from stdlib.subproj/merge.c rename to stdlib/merge.c diff --git a/stdlib.subproj/putenv.c b/stdlib/putenv.c similarity index 100% rename from stdlib.subproj/putenv.c rename to stdlib/putenv.c diff --git a/stdlib/qsort.3 b/stdlib/qsort.3 new file mode 100644 index 0000000..9f591b9 --- /dev/null +++ b/stdlib/qsort.3 @@ -0,0 +1,231 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)qsort.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdlib/qsort.3,v 1.10 2001/09/07 14:46:35 asmodai Exp $ +.\" +.Dd June 4, 1993 +.Dt QSORT 3 +.Os +.Sh NAME +.Nm qsort , heapsort , mergesort +.Nd sort functions +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft void +.Fn qsort "void *base" "size_t nmemb" "size_t size" "int (*compar)(const void *, const void *)" +.Ft int +.Fn heapsort "void *base" "size_t nmemb" "size_t size" "int (*compar)(const void *, const void *)" +.Ft int +.Fn mergesort "void *base" "size_t nmemb" "size_t size" "int (*compar)(const void *, const void *)" +.Sh DESCRIPTION +The +.Fn qsort +function is a modified partition-exchange sort, or quicksort. +The +.Fn heapsort +function is a modified selection sort. +The +.Fn mergesort +function is a modified merge sort with exponential search +intended for sorting data with pre-existing order. +.Pp +The +.Fn qsort +and +.Fn heapsort +functions sort an array of +.Fa nmemb +objects, the initial member of which is pointed to by +.Fa base . +The size of each object is specified by +.Fa size . +.Fn Mergesort +behaves similarly, but +.Em requires +that +.Fa size +be greater than +.Dq "sizeof(void *) / 2" . +.Pp +The contents of the array +.Fa base +are sorted in ascending order according to +a comparison function pointed to by +.Fa compar , +which requires two arguments pointing to the objects being +compared. +.Pp +The comparison function must return an integer less than, equal to, or +greater than zero if the first argument is considered to be respectively +less than, equal to, or greater than the second. +.Pp +The functions +.Fn qsort +and +.Fn heapsort +are +.Em not +stable, that is, if two members compare as equal, their order in +the sorted array is undefined. +The function +.Fn mergesort +is stable. +.Pp +The +.Fn qsort +function is an implementation of C.A.R. Hoare's ``quicksort'' algorithm, +a variant of partition-exchange sorting; in particular, see D.E. Knuth's +Algorithm Q. +.Fn Qsort +takes O N lg N average time. +This implementation uses median selection to avoid its +O N**2 worst-case behavior. +.Pp +The +.Fn heapsort +function is an implementation of J.W.J. William's ``heapsort'' algorithm, +a variant of selection sorting; in particular, see D.E. Knuth's Algorithm H. +.Fn Heapsort +takes O N lg N worst-case time. +Its +.Em only +advantage over +.Fn qsort +is that it uses almost no additional memory; while +.Fn qsort +does not allocate memory, it is implemented using recursion. +.Pp +The function +.Fn mergesort +requires additional memory of size +.Fa nmemb * +.Fa size +bytes; it should be used only when space is not at a premium. +.Fn Mergesort +is optimized for data with pre-existing order; its worst case +time is O N lg N; its best case is O N. +.Pp +Normally, +.Fn qsort +is faster than +.Fn mergesort +is faster than +.Fn heapsort . +Memory availability and pre-existing order in the data can make this +untrue. +.Sh RETURN VALUES +The +.Fn qsort +function +returns no value. +.Pp +.Rv -std heapsort mergesort +.Sh ERRORS +The +.Fn heapsort +and +.Fn mergesort +functions succeed unless: +.Bl -tag -width Er +.It Bq Er EINVAL +The +.Fa size +argument is zero, or, +the +.Fa size +argument to +.Fn mergesort +is less than +.Dq "sizeof(void *) / 2" . +.It Bq Er ENOMEM +.Fn Heapsort +or +.Fn mergesort +were unable to allocate memory. +.El +.Sh COMPATIBILITY +Previous versions of +.Fn qsort +did not permit the comparison routine itself to call +.Fn qsort 3 . +This is no longer true. +.Sh SEE ALSO +.Xr sort 1 , +.Xr radixsort 3 +.Rs +.%A Hoare, C.A.R. +.%D 1962 +.%T "Quicksort" +.%J "The Computer Journal" +.%V 5:1 +.%P pp. 10-15 +.Re +.Rs +.%A Williams, J.W.J +.%D 1964 +.%T "Heapsort" +.%J "Communications of the ACM" +.%V 7:1 +.%P pp. 347-348 +.Re +.Rs +.%A Knuth, D.E. +.%D 1968 +.%B "The Art of Computer Programming" +.%V Vol. 3 +.%T "Sorting and Searching" +.%P pp. 114-123, 145-149 +.Re +.Rs +.%A Mcilroy, P.M. +.%T "Optimistic Sorting and Information Theoretic Complexity" +.%J "Fourth Annual ACM-SIAM Symposium on Discrete Algorithms" +.%V January 1992 +.Re +.Rs +.%A Bentley, J.L. +.%T "Engineering a Sort Function" +.%J "bentley@research.att.com" +.%V January 1992 +.Re +.Sh STANDARDS +The +.Fn qsort +function +conforms to +.St -isoC . diff --git a/stdlib.subproj/qsort.c b/stdlib/qsort.c similarity index 100% rename from stdlib.subproj/qsort.c rename to stdlib/qsort.c diff --git a/stdlib/radixsort.3 b/stdlib/radixsort.3 new file mode 100644 index 0000000..f4e6171 --- /dev/null +++ b/stdlib/radixsort.3 @@ -0,0 +1,161 @@ +.\" Copyright (c) 1990, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)radixsort.3 8.2 (Berkeley) 1/27/94 +.\" $FreeBSD: src/lib/libc/stdlib/radixsort.3,v 1.9 2001/09/07 14:46:35 asmodai Exp $ +.\" +.Dd January 27, 1994 +.Dt RADIXSORT 3 +.Os +.Sh NAME +.Nm radixsort +.Nd radix sort +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In limits.h +.In stdlib.h +.Ft int +.Fn radixsort "const unsigned char **base" "int nmemb" "const unsigned char *table" "unsigned endbyte" +.Ft int +.Fn sradixsort "const unsigned char **base" "int nmemb" "const unsigned char *table" "unsigned endbyte" +.Sh DESCRIPTION +The +.Fn radixsort +and +.Fn sradixsort +functions +are implementations of radix sort. +.Pp +These functions sort an array of pointers to byte strings, the initial +member of which is referenced by +.Fa base . +The byte strings may contain any values; the end of each string +is denoted by the user-specified value +.Fa endbyte . +.Pp +Applications may specify a sort order by providing the +.Fa table +argument. +If +.Pf non- Dv NULL , +.Fa table +must reference an array of +.Dv UCHAR_MAX ++ 1 bytes which contains the sort +weight of each possible byte value. +The end-of-string byte must have a sort weight of 0 or 255 +(for sorting in reverse order). +More than one byte may have the same sort weight. +The +.Fa table +argument +is useful for applications which wish to sort different characters +equally, for example, providing a table with the same weights +for A-Z as for a-z will result in a case-insensitive sort. +If +.Fa table +is NULL, the contents of the array are sorted in ascending order +according to the +.Tn ASCII +order of the byte strings they reference and +.Fa endbyte +has a sorting weight of 0. +.Pp +The +.Fn sradixsort +function is stable, that is, if two elements compare as equal, their +order in the sorted array is unchanged. +The +.Fn sradixsort +function uses additional memory sufficient to hold +.Fa nmemb +pointers. +.Pp +The +.Fn radixsort +function is not stable, but uses no additional memory. +.Pp +These functions are variants of most-significant-byte radix sorting; in +particular, see D.E. Knuth's Algorithm R and section 5.2.5, exercise 10. +They take linear time relative to the number of bytes in the strings. +.Sh RETURN VALUES +.Rv -std radixsort +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er EINVAL +The value of the +.Fa endbyte +element of +.Fa table +is not 0 or 255. +.El +.Pp +Additionally, the +.Fn sradixsort +function +may fail and set +.Va errno +for any of the errors specified for the library routine +.Xr malloc 3 . +.Sh SEE ALSO +.Xr sort 1 , +.Xr qsort 3 +.Pp +.Rs +.%A Knuth, D.E. +.%D 1968 +.%B "The Art of Computer Programming" +.%T "Sorting and Searching" +.%V Vol. 3 +.%P pp. 170-178 +.Re +.Rs +.%A Paige, R. +.%D 1987 +.%T "Three Partition Refinement Algorithms" +.%J "SIAM J. Comput." +.%V Vol. 16 +.%N No. 6 +.Re +.Rs +.%A McIlroy, P. +.%D 1993 +.%B "Engineering Radix Sort" +.%T "Computing Systems" +.%V Vol. 6:1 +.%P pp. 5-27 +.Re +.Sh HISTORY +The +.Fn radixsort +function first appeared in +.Bx 4.4 . diff --git a/stdlib.subproj/radixsort.c b/stdlib/radixsort.c similarity index 97% rename from stdlib.subproj/radixsort.c rename to stdlib/radixsort.c index 53a02b5..44a39d0 100644 --- a/stdlib.subproj/radixsort.c +++ b/stdlib/radixsort.c @@ -157,13 +157,19 @@ r_sort_a(a, n, i, tr, endch) const u_char *tr; u_int endch; { - static int count[256], nc, bmin; + static int *count = NULL, nc, bmin; register int c; register const u_char **ak, *r; stack s[SIZE], *sp, *sp0, *sp1, temp; int *cp, bigc; const u_char **an, *t, **aj, **top[256]; + if( count == NULL ) { + count = malloc(256*sizeof(int)); + if( count == NULL ) + return; + } + /* Set up stack. */ sp = s; push(a, n, i); @@ -248,13 +254,19 @@ r_sort_b(a, ta, n, i, tr, endch) const u_char *tr; u_int endch; { - static int count[256], nc, bmin; + static int *count = NULL, nc, bmin; register int c; register const u_char **ak, **ai; stack s[512], *sp, *sp0, *sp1, temp; const u_char **top[256]; int *cp, bigc; + if( count == NULL ) { + count = malloc(256*sizeof(int)); + if( count == NULL ) + return; + } + sp = s; push(a, n, i); while (!empty(s)) { diff --git a/stdlib/rand.3 b/stdlib/rand.3 new file mode 100644 index 0000000..609c263 --- /dev/null +++ b/stdlib/rand.3 @@ -0,0 +1,117 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)rand.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdlib/rand.3,v 1.12 2001/09/07 14:46:36 asmodai Exp $ +.\" +.Dd May 25, 1999 +.Dt RAND 3 +.Os +.Sh NAME +.Nm rand , +.Nm srand , +.Nm sranddev , +.Nm rand_r +.Nd bad random number generator +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft void +.Fn srand "unsigned seed" +.Ft void +.Fn sranddev void +.Ft int +.Fn rand void +.Ft int +.Fn rand_r "unsigned *ctx" +.Sh DESCRIPTION +.Bf -symbolic +These interfaces are obsoleted by +.Xr random 3 . +.Ef +.Pp +The +.Fn rand +function computes a sequence of pseudo-random integers in the range +of 0 to +.Dv RAND_MAX +(as defined by the header file +.Aq Pa stdlib.h ) . +.Pp +The +.Fn srand +function sets its argument +.Fa seed +as the seed for a new sequence of +pseudo-random numbers to be returned by +.Fn rand . +These sequences are repeatable by calling +.Fn srand +with the same seed value. +.Pp +If no +.Fa seed +value is provided, the functions are automatically +seeded with a value of 1. +.Pp +The +.Fn sranddev +function initializes a seed using the +.Xr random 4 +random number device which returns good random numbers, +suitable for cryptographic use. +.Pp +.Fn rand_r +provides the same functionality as +.Fn rand . +A pointer to the context value +.Fa ctx +must be supplied by the caller. +.Sh SEE ALSO +.Xr random 3 , +.Xr random 4 +.Sh STANDARDS +The +.Fn rand +and +.Fn srand +functions +conform to +.St -isoC . +.Pp +The +.Fn rand_r +function is as proposed in the POSIX.4a Draft #6 document. diff --git a/stdlib/rand.c b/stdlib/rand.c new file mode 100644 index 0000000..42a5bd4 --- /dev/null +++ b/stdlib/rand.c @@ -0,0 +1,107 @@ +/*- + * Copyright (c) 1990, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * Posix rand_r function added May 1999 by Wes Peters . + * + * $FreeBSD: src/lib/libc/stdlib/rand.c,v 1.2.2.1 2001/03/05 11:33:57 obrien Exp $ + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)rand.c 8.1 (Berkeley) 6/14/93"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include + +#ifdef TEST +#include +#endif /* TEST */ + +static int +do_rand(unsigned long *ctx) +{ + return ((*ctx = *ctx * 1103515245 + 12345) % ((u_long)RAND_MAX + 1)); +} + + +int +rand_r(unsigned int *ctx) +{ + u_long val = (u_long) *ctx; + *ctx = do_rand(&val); + return (int) *ctx; +} + + +static u_long next = 1; + +int +rand() +{ + return do_rand(&next); +} + +void +srand(seed) +u_int seed; +{ + next = seed; +} + +#ifdef TEST + +main() +{ + int i; + unsigned myseed; + + printf("seeding rand with 0x19610910: \n"); + srand(0x19610910); + + printf("generating three pseudo-random numbers:\n"); + for (i = 0; i < 3; i++) + { + printf("next random number = %d\n", rand()); + } + + printf("generating the same sequence with rand_r:\n"); + myseed = 0x19610910; + for (i = 0; i < 3; i++) + { + printf("next random number = %d\n", rand_r(&myseed)); + } + + return 0; +} + +#endif /* TEST */ + diff --git a/stdlib/random.3 b/stdlib/random.3 new file mode 100644 index 0000000..172030d --- /dev/null +++ b/stdlib/random.3 @@ -0,0 +1,191 @@ +.\" Copyright (c) 1983, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)random.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdlib/random.3,v 1.17 2001/09/07 14:46:36 asmodai Exp $ +.\" +.Dd June 4, 1993 +.Dt RANDOM 3 +.Os +.Sh NAME +.Nm random , +.Nm srandom , +.Nm srandomdev , +.Nm initstate , +.Nm setstate +.Nd better random number generator; routines for changing generators +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft long +.Fn random void +.Ft void +.Fn srandom "unsigned long seed" +.Ft void +.Fn srandomdev void +.Ft char * +.Fn initstate "unsigned long seed" "char *state" "long n" +.Ft char * +.Fn setstate "char *state" +.Sh DESCRIPTION +The +.Fn random +function +uses a non-linear additive feedback random number generator employing a +default table of size 31 long integers to return successive pseudo-random +numbers in the range from 0 to +.if t 2\u\s731\s10\d\(mi1. +.if n (2**31)\(mi1. +The period of this random number generator is very large, approximately +.if t 16\(mu(2\u\s731\s10\d\(mi1). +.if n 16*((2**31)\(mi1). +.Pp +The +.Fn random +and +.Fn srandom +functions have (almost) the same calling sequence and initialization properties as the +.Xr rand 3 +and +.Xr srand 3 +functions. +The difference is that +.Xr rand 3 +produces a much less random sequence \(em in fact, the low dozen bits +generated by rand go through a cyclic pattern. All the bits generated by +.Fn random +are usable. For example, +.Sq Li random()&01 +will produce a random binary +value. +.Pp +Like +.Xr rand 3 , +.Fn random +will by default produce a sequence of numbers that can be duplicated +by calling +.Fn srandom +with +.Ql 1 +as the seed. +.Pp +The +.Fn srandomdev +routine initialize a state array using +.Xr random 4 +random number device which returns good random numbers, +suitable for cryptographic use. +Note that this particular seeding +procedure can generate states which are impossible to reproduce by +calling +.Fn srandom +with any value, since the succeeding terms in the +state buffer are no longer derived from the LC algorithm applied to +a fixed seed. +.Pp +The +.Fn initstate +routine allows a state array, passed in as an argument, to be initialized +for future use. The size of the state array (in bytes) is used by +.Fn initstate +to decide how sophisticated a random number generator it should use \(em the +more state, the better the random numbers will be. +(Current "optimal" values for the amount of state information are +8, 32, 64, 128, and 256 bytes; other amounts will be rounded down to +the nearest known amount. Using less than 8 bytes will cause an error.) +The seed for the initialization (which specifies a starting point for +the random number sequence, and provides for restarting at the same +point) is also an argument. +The +.Fn initstate +function +returns a pointer to the previous state information array. +.Pp +Once a state has been initialized, the +.Fn setstate +routine provides for rapid switching between states. +The +.Fn setstate +function +returns a pointer to the previous state array; its +argument state array is used for further random number generation +until the next call to +.Fn initstate +or +.Fn setstate . +.Pp +Once a state array has been initialized, it may be restarted at a +different point either by calling +.Fn initstate +(with the desired seed, the state array, and its size) or by calling +both +.Fn setstate +(with the state array) and +.Fn srandom +(with the desired seed). +The advantage of calling both +.Fn setstate +and +.Fn srandom +is that the size of the state array does not have to be remembered after +it is initialized. +.Pp +With 256 bytes of state information, the period of the random number +generator is greater than +.if t 2\u\s769\s10\d, +.if n 2**69 +which should be sufficient for most purposes. +.Sh AUTHORS +.An Earl T. Cohen +.Sh DIAGNOSTICS +If +.Fn initstate +is called with less than 8 bytes of state information, or if +.Fn setstate +detects that the state information has been garbled, error +messages are printed on the standard error output. +.Sh SEE ALSO +.Xr rand 3 , +.Xr srand 3 , +.Xr random 4 +.Sh HISTORY +These +functions appeared in +.Bx 4.2 . +.Sh BUGS +About 2/3 the speed of +.Xr rand 3 . +.Pp +The historical implementation used to have a very weak seeding; the +random sequence did not vary much with the seed. +The current implementation employs a better pseudo-random number +generator for the initial state calculation. diff --git a/stdlib.subproj/random.c b/stdlib/random.c similarity index 100% rename from stdlib.subproj/random.c rename to stdlib/random.c diff --git a/stdlib/reallocf.c b/stdlib/reallocf.c new file mode 100644 index 0000000..c4cd9d9 --- /dev/null +++ b/stdlib/reallocf.c @@ -0,0 +1,39 @@ +/*- + * Copyright (c) 1998, M. Warner Losh + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + * $FreeBSD: src/lib/libc/stdlib/reallocf.c,v 1.3 1999/08/28 00:01:37 peter Exp $ + */ +#include + +void * +reallocf(void *ptr, size_t size) +{ + void *nptr; + + nptr = realloc(ptr, size); + if (!nptr && ptr) + free(ptr); + return (nptr); +} diff --git a/stdlib/realpath.3 b/stdlib/realpath.3 new file mode 100644 index 0000000..90dc5c0 --- /dev/null +++ b/stdlib/realpath.3 @@ -0,0 +1,128 @@ +.\" Copyright (c) 1994 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Jan-Simon Pendry. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)realpath.3 8.2 (Berkeley) 2/16/94 +.\" $FreeBSD: src/lib/libc/stdlib/realpath.3,v 1.10 2001/09/07 14:46:36 asmodai Exp $ +.\" +.Dd February 16, 1994 +.Dt REALPATH 3 +.Os +.Sh NAME +.Nm realpath +.Nd returns the canonicalized absolute pathname +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/param.h +.In stdlib.h +.Ft "char *" +.Fn realpath "const char *pathname" "char resolved_path[MAXPATHLEN]" +.Sh DESCRIPTION +The +.Fn realpath +function resolves all symbolic links, extra +.Dq / +characters and references to +.Pa /./ +and +.Pa /../ +in +.Fa pathname , +and copies the resulting absolute pathname into +the memory referenced by +.Fa resolved_path . +The +.Fa resolved_path +argument +.Em must +refer to a buffer capable of storing at least +.Dv MAXPATHLEN +characters. +.Pp +The +.Fn realpath +function will resolve both absolute and relative paths +and return the absolute pathname corresponding to +.Fa pathname . +All but the last component of +.Fa pathname +must exist when +.Fn realpath +is called. +.Sh "RETURN VALUES" +The +.Fn realpath +function returns +.Fa resolved_path +on success. +If an error occurs, +.Fn realpath +returns +.Dv NULL , +and +.Fa resolved_path +contains the pathname which caused the problem. +.Sh ERRORS +The function +.Fn realpath +may fail and set the external variable +.Va errno +for any of the errors specified for the library functions +.Xr chdir 2 , +.Xr close 2 , +.Xr fchdir 2 , +.Xr lstat 2 , +.Xr open 2 , +.Xr readlink 2 +and +.Xr getcwd 3 . +.Sh CAVEATS +This implementation of +.Fn realpath +differs slightly from the Solaris implementation. +The +.Bx 4.4 +version always returns absolute pathnames, +whereas the Solaris implementation will, +under certain circumstances, return a relative +.Fa resolved_path +when given a relative +.Fa pathname . +.Sh "SEE ALSO" +.Xr getcwd 3 +.Sh HISTORY +The +.Fn realpath +function call first appeared in +.Bx 4.4 . diff --git a/stdlib.subproj/setenv.c b/stdlib/setenv.c similarity index 100% rename from stdlib.subproj/setenv.c rename to stdlib/setenv.c diff --git a/stdlib/strfmon.3 b/stdlib/strfmon.3 new file mode 100644 index 0000000..a01bd42 --- /dev/null +++ b/stdlib/strfmon.3 @@ -0,0 +1,92 @@ +.\" Copyright (c) 2001 Jeroen Ruigrok van der Werven +.\" 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. +.\" +.\" 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. +.\" +.\" $FreeBSD: src/lib/libc/stdlib/strfmon.3,v 1.3 2001/10/01 13:50:03 ru Exp $ +.\" +.Dd September 7, 2001 +.Dt STRFMON 3 +.Os +.Sh NAME +.Nm strfmon +.Nd convert monetary value to string +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In monetary.h +.Ft ssize_t +.Fn strfmon "char *s" "size_t maxsize" "const char *format" "..." +.Sh DESCRIPTION +The +.Fn strfmon +function places characters into the array pointed to by +.Fa s +as controlled by the string pointed to by +.Fa format . +No more than +.Fa maxsize +bytes are placed into the array. +.Sh RETURN VALUES +If the total number of resulting bytes including the terminating +.Dv NULL +byte is not more than +.Fa maxsize , +.Fn strfmon +returns the number of bytes placed into the array pointed to by +.Fa s , +not including the terminating +.Dv NULL +byte. +Otherwise, \-1 is returned, +the contents of the array are indeterminate, +and +.Va errno +is set to indicate the error. +.Sh ERRORS +The +.Fn strfmon +function will fail if: +.Bl -tag -width Er +.It Bq Er E2BIG +Conversion stopped due to lack of space in the buffer. +.El +.Sh SEE ALSO +.Xr localeconv 3 +.Sh STANDARDS +The +.Fn strfmon +function +conforms to +.St -xpg4 +and +.St -susv2 . +.Sh AUTHORS +.An -nosplit +The +.Fn strfmon +function was implemented by +.An Alexey Zelkin Aq phantom@FreeBSD.org . +.Pp +This manual page was written by +.An Jeroen Ruigrok van der Werven Aq asmodai@FreeBSD.org +based on the standards' text. diff --git a/stdlib/strtod.3 b/stdlib/strtod.3 new file mode 100644 index 0000000..2aaa34f --- /dev/null +++ b/stdlib/strtod.3 @@ -0,0 +1,140 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)strtod.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdlib/strtod.3,v 1.13 2001/09/07 14:46:36 asmodai Exp $ +.\" +.Dd June 4, 1993 +.Dt STRTOD 3 +.Os +.Sh NAME +.Nm strtod +.Nd convert +.Tn ASCII +string to double +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft double +.Fn strtod "const char *nptr" "char **endptr" +.Sh DESCRIPTION +The +.Fn strtod +function converts the initial portion of the string +pointed to by +.Fa nptr +to +.Em double +representation. +.Pp +The expected form of the string is an optional plus (``+'') or minus +sign (``\-'') followed by a sequence of digits optionally containing +a decimal-point character, optionally followed by an exponent. +An exponent consists of an ``E'' or ``e'', followed by an optional plus +or minus sign, followed by a sequence of digits. +.Pp +Leading white-space characters in the string (as defined by the +.Xr isspace 3 +function) are skipped. +The decimal point +character is defined in the program's locale (category +.Dv LC_NUMERIC ) . +.Sh RETURN VALUES +The +.Fn strtod +function returns the converted value, if any. +.Pp +If +.Fa endptr +is not +.Dv NULL , +a pointer to the character after the last character used +in the conversion is stored in the location referenced by +.Fa endptr . +.Pp +If no conversion is performed, zero is returned and the value of +.Fa nptr +is stored in the location referenced by +.Fa endptr . +.Pp +If the correct value would cause overflow, plus or minus +.Dv HUGE_VAL +is returned (according to the sign of the value), and +.Er ERANGE +is stored in +.Va errno . +If the correct value would cause underflow, zero is +returned and +.Er ERANGE +is stored in +.Va errno . +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er ERANGE +Overflow or underflow occurred. +.El +.Sh SEE ALSO +.Xr atof 3 , +.Xr atoi 3 , +.Xr atol 3 , +.Xr strtol 3 , +.Xr strtoul 3 +.Sh STANDARDS +The +.Fn strtod +function +conforms to +.St -isoC . +.Sh AUTHORS +The author of this software is +.An David M. Gay . +.Pp +Copyright (c) 1991 by AT&T. +.Pp +Permission to use, copy, modify, and distribute this software for any +purpose without fee is hereby granted, provided that this entire notice +is included in all copies of any software which is or includes a copy +or modification of this software and in all copies of the supporting +documentation for such software. +.Pp +THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED +WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY +REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY +OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. +.Pp +Contact your vendor for a free copy of the source code to +.Fn strtod +and accompanying functions. diff --git a/stdlib.subproj/strtod.c b/stdlib/strtod.c similarity index 99% rename from stdlib.subproj/strtod.c rename to stdlib/strtod.c index 05c075e..50a37a6 100644 --- a/stdlib.subproj/strtod.c +++ b/stdlib/strtod.c @@ -173,6 +173,13 @@ extern void *MALLOC(size_t); #include "ctype.h" #include "errno.h" +#if defined(__APPLE__) +/* + * Temporarily define this, so we avoid pulling in symbols from libm + */ +#define Bad_float_h +#endif + #ifdef Bad_float_h #undef __STDC__ #ifdef IEEE_BIG_ENDIAN diff --git a/stdlib/strtol.3 b/stdlib/strtol.3 new file mode 100644 index 0000000..0033f4e --- /dev/null +++ b/stdlib/strtol.3 @@ -0,0 +1,207 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)strtol.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdlib/strtol.3,v 1.14 2001/09/11 09:39:23 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt STRTOL 3 +.Os +.Sh NAME +.Nm strtol , strtoll , strtoq +.Nd "convert a string value to a long, long long, or quad_t integer" +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.In limits.h +.Ft long +.Fn strtol "const char *nptr" "char **endptr" "int base" +.Ft long long +.Fn strtoll "const char *nptr" "char **endptr" "int base" +.In sys/types.h +.In stdlib.h +.In limits.h +.Ft quad_t +.Fn strtoq "const char *nptr" "char **endptr" "int base" +.Sh DESCRIPTION +The +.Fn strtol +function +converts the string in +.Fa nptr +to a +.Em long +value. +The +.Fn strtoll +function +converts the string in +.Fa nptr +to a +.Em long long +value. +The +.Fn strtoq +function +converts the string in +.Fa nptr +to a +.Em quad_t +value. +The conversion is done according to the given +.Fa base , +which must be between 2 and 36 inclusive, +or be the special value 0. +.Pp +The string may begin with an arbitrary amount of white space +(as determined by +.Xr isspace 3 ) +followed by a single optional +.Ql + +or +.Ql - +sign. +If +.Fa base +is zero or 16, +the string may then include a +.Ql 0x +prefix, +and the number will be read in base 16; otherwise, a zero +.Fa base +is taken as 10 (decimal) unless the next character is +.Ql 0 , +in which case it is taken as 8 (octal). +.Pp +The remainder of the string is converted to a +.Em long +value in the obvious manner, +stopping at the first character which is not a valid digit +in the given base. +(In bases above 10, the letter +.Ql A +in either upper or lower case +represents 10, +.Ql B +represents 11, and so forth, with +.Ql Z +representing 35.) +.Pp +If +.Fa endptr +is non nil, +.Fn strtol +stores the address of the first invalid character in +.Fa *endptr . +If there were no digits at all, however, +.Fn strtol +stores the original value of +.Fa nptr +in +.Fa *endptr . +(Thus, if +.Fa *nptr +is not +.Ql \e0 +but +.Fa **endptr +is +.Ql \e0 +on return, the entire string was valid.) +.Sh RETURN VALUES +The +.Fn strtol +or +.Fn strtoll +function +returns the result of the conversion, +unless the value would underflow or overflow. +If no conversion could be performed, 0 is returned and +the global variable +.Va errno +is set to +.Er EINVAL . +If an underflow occurs, +.Fn strtol +returns +.Dv LONG_MIN . +If an overflow occurs, +.Fn strtol +returns +.Dv LONG_MAX . +If an underflow occurs, +.Fn strtoll +returns +.Dv LLONG_MIN . +If an overflow occurs, +.Fn strtoll +returns +.Dv LLONG_MAX . +In all cases, +.Va errno +is set to +.Er ERANGE . +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er EINVAL +The value of +.Fa base +is not supported or +no conversion could be performed. +.It Bq Er ERANGE +The given string was out of range; the value converted has been clamped. +.El +.Sh SEE ALSO +.Xr atof 3 , +.Xr atoi 3 , +.Xr atol 3 , +.Xr strtod 3 , +.Xr strtoul 3 +.Sh STANDARDS +The +.Fn strtol +function +conforms to +.St -isoC . +The +.Fn strtoll +function +conforms to +.St -isoC-99 . +The +.Bx +.Fn strtoq +function is deprecated. diff --git a/stdlib.subproj/strtol.c b/stdlib/strtol.c similarity index 100% rename from stdlib.subproj/strtol.c rename to stdlib/strtol.c diff --git a/stdlib.subproj/strtoq.c b/stdlib/strtoll.c similarity index 76% rename from stdlib.subproj/strtoq.c rename to stdlib/strtoll.c index c099ba1..41a16c6 100644 --- a/stdlib.subproj/strtoq.c +++ b/stdlib/strtoll.c @@ -1,25 +1,4 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ -/* +/*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * @@ -52,6 +31,14 @@ * SUCH DAMAGE. */ +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)strtoq.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ + +#if defined(LIBC_SCCS) && !defined(lint) +static const char rcsid[] = + "$FreeBSD: src/lib/libc/stdlib/strtoll.c,v 1.5.2.1 2001/03/02 09:45:20 obrien Exp $"; +#endif #include @@ -61,21 +48,21 @@ #include /* - * Convert a string to a quad integer. + * Convert a string to a long long integer. * * Ignores `locale' stuff. Assumes that the upper and lower case * alphabets and digits are each contiguous. */ -quad_t -strtoq(nptr, endptr, base) +long long +strtoll(nptr, endptr, base) const char *nptr; char **endptr; register int base; { register const char *s; - register u_quad_t acc; - register int c; - register u_quad_t qbase, cutoff; + register unsigned long long acc; + register unsigned char c; + register unsigned long long qbase, cutoff; register int neg, any, cutlim; /* @@ -123,10 +110,13 @@ strtoq(nptr, endptr, base) * overflow. */ qbase = (unsigned)base; - cutoff = neg ? -(u_quad_t)QUAD_MIN : QUAD_MAX; + cutoff = neg ? (unsigned long long)-(LLONG_MIN + LLONG_MAX) + LLONG_MAX + : LLONG_MAX; cutlim = cutoff % qbase; cutoff /= qbase; for (acc = 0, any = 0;; c = *s++) { + if (!isascii(c)) + break; if (isdigit(c)) c -= '0'; else if (isalpha(c)) @@ -135,7 +125,7 @@ strtoq(nptr, endptr, base) break; if (c >= base) break; - if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) + if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) any = -1; else { any = 1; @@ -144,7 +134,7 @@ strtoq(nptr, endptr, base) } } if (any < 0) { - acc = neg ? QUAD_MIN : QUAD_MAX; + acc = neg ? LLONG_MIN : LLONG_MAX; errno = ERANGE; } else if (neg) acc = -acc; diff --git a/stdlib/strtoq.c b/stdlib/strtoq.c new file mode 100644 index 0000000..dcda96a --- /dev/null +++ b/stdlib/strtoq.c @@ -0,0 +1,61 @@ +/*- + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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[] = "@(#)strtoq.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ + +#if defined(LIBC_SCCS) && !defined(lint) +static const char rcsid[] = + "$FreeBSD: src/lib/libc/stdlib/strtoq.c,v 1.4.6.1 2001/03/02 09:45:20 obrien Exp $"; +#endif + +#include + +#include + +/* + * Convert a string to a quad integer. + * + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ +quad_t +strtoq(nptr, endptr, base) + const char *nptr; + char **endptr; + int base; +{ + + return strtoll(nptr, endptr, base); +} diff --git a/stdlib/strtoul.3 b/stdlib/strtoul.3 new file mode 100644 index 0000000..2bc473e --- /dev/null +++ b/stdlib/strtoul.3 @@ -0,0 +1,198 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)strtoul.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdlib/strtoul.3,v 1.14 2001/09/11 09:39:23 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt STRTOUL 3 +.Os +.Sh NAME +.Nm strtoul , strtoull , strtouq +.Nd "convert a string to an unsigned long, unsigned long long, or uquad_t integer" +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.In limits.h +.Ft unsigned long +.Fn strtoul "const char *nptr" "char **endptr" "int base" +.Ft unsigned long long +.Fn strtoull "const char *nptr" "char **endptr" "int base" +.In sys/types.h +.In stdlib.h +.In limits.h +.Ft u_quad_t +.Fn strtouq "const char *nptr" "char **endptr" "int base" +.Sh DESCRIPTION +The +.Fn strtoul +function +converts the string in +.Fa nptr +to an +.Em unsigned long +value. +The +.Fn strtoull +function +converts the string in +.Fa nptr +to an +.Em unsigned long long +value. +The +.Fn strtouq +function +converts the string in +.Fa nptr +to a +.Em u_quad_t +value. +The conversion is done according to the given +.Fa base , +which must be between 2 and 36 inclusive, +or be the special value 0. +.Pp +The string may begin with an arbitrary amount of white space +(as determined by +.Xr isspace 3 ) +followed by a single optional +.Ql + +or +.Ql - +sign. +If +.Fa base +is zero or 16, +the string may then include a +.Ql 0x +prefix, +and the number will be read in base 16; otherwise, a zero +.Fa base +is taken as 10 (decimal) unless the next character is +.Ql 0 , +in which case it is taken as 8 (octal). +.Pp +The remainder of the string is converted to an +.Em unsigned long +value in the obvious manner, +stopping at the end of the string +or at the first character that does not produce a valid digit +in the given base. +(In bases above 10, the letter +.Ql A +in either upper or lower case +represents 10, +.Ql B +represents 11, and so forth, with +.Ql Z +representing 35.) +.Pp +If +.Fa endptr +is non nil, +.Fn strtoul +stores the address of the first invalid character in +.Fa *endptr . +If there were no digits at all, however, +.Fn strtoul +stores the original value of +.Fa nptr +in +.Fa *endptr . +(Thus, if +.Fa *nptr +is not +.Ql \e0 +but +.Fa **endptr +is +.Ql \e0 +on return, the entire string was valid.) +.Sh RETURN VALUES +The +.Fn strtoul +or +.Fn strtoull +function +returns either the result of the conversion +or, if there was a leading minus sign, +the negation of the result of the conversion, +unless the original (non-negated) value would overflow; +in the latter case, +.Fn strtoul +returns +.Dv ULONG_MAX +and +.Fn strtoull +returns +.Dv ULLONG_MAX . +In all cases, +.Va errno +is set to +.Er ERANGE . +If no conversion could be performed, 0 is returned and +the global variable +.Va errno +is set to +.Er EINVAL . +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er EINVAL +The value of +.Fa base +is not supported or +no conversion could be performed. +.It Bq Er ERANGE +The given string was out of range; the value converted has been clamped. +.El +.Sh SEE ALSO +.Xr strtol 3 +.Sh STANDARDS +The +.Fn strtoul +function +conforms to +.St -isoC . +The +.Fn strtoull +function +conforms to +.St -isoC-99 . +The +.Bx +.Fn strtoq +function is deprecated. diff --git a/stdlib.subproj/strtoul.c b/stdlib/strtoul.c similarity index 100% rename from stdlib.subproj/strtoul.c rename to stdlib/strtoul.c diff --git a/stdlib.subproj/strtouq.c b/stdlib/strtoull.c similarity index 69% rename from stdlib.subproj/strtouq.c rename to stdlib/strtoull.c index 1fefc54..f80850e 100644 --- a/stdlib.subproj/strtouq.c +++ b/stdlib/strtoull.c @@ -1,25 +1,4 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ -/* +/*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * @@ -52,6 +31,14 @@ * SUCH DAMAGE. */ +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)strtouq.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ + +#if defined(LIBC_SCCS) && !defined(lint) +static const char rcsid[] = + "$FreeBSD: src/lib/libc/stdlib/strtoull.c,v 1.5.2.1 2001/03/02 09:45:20 obrien Exp $"; +#endif #include @@ -61,21 +48,21 @@ #include /* - * Convert a string to an unsigned quad integer. + * Convert a string to an unsigned long long integer. * * Ignores `locale' stuff. Assumes that the upper and lower case * alphabets and digits are each contiguous. */ -u_quad_t -strtouq(nptr, endptr, base) +unsigned long long +strtoull(nptr, endptr, base) const char *nptr; char **endptr; register int base; { register const char *s = nptr; - register u_quad_t acc; - register int c; - register u_quad_t qbase, cutoff; + register unsigned long long acc; + register unsigned char c; + register unsigned long long qbase, cutoff; register int neg, any, cutlim; /* @@ -88,7 +75,7 @@ strtouq(nptr, endptr, base) if (c == '-') { neg = 1; c = *s++; - } else { + } else { neg = 0; if (c == '+') c = *s++; @@ -102,9 +89,11 @@ strtouq(nptr, endptr, base) if (base == 0) base = c == '0' ? 8 : 10; qbase = (unsigned)base; - cutoff = (u_quad_t)UQUAD_MAX / qbase; - cutlim = (u_quad_t)UQUAD_MAX % qbase; + cutoff = (unsigned long long)ULLONG_MAX / qbase; + cutlim = (unsigned long long)ULLONG_MAX % qbase; for (acc = 0, any = 0;; c = *s++) { + if (!isascii(c)) + break; if (isdigit(c)) c -= '0'; else if (isalpha(c)) @@ -113,7 +102,7 @@ strtouq(nptr, endptr, base) break; if (c >= base) break; - if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) + if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) any = -1; else { any = 1; @@ -122,7 +111,7 @@ strtouq(nptr, endptr, base) } } if (any < 0) { - acc = UQUAD_MAX; + acc = ULLONG_MAX; errno = ERANGE; } else if (neg) acc = -acc; diff --git a/stdlib/strtouq.c b/stdlib/strtouq.c new file mode 100644 index 0000000..89f26d8 --- /dev/null +++ b/stdlib/strtouq.c @@ -0,0 +1,61 @@ +/*- + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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[] = "@(#)strtouq.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ + +#if defined(LIBC_SCCS) && !defined(lint) +static const char rcsid[] = + "$FreeBSD: src/lib/libc/stdlib/strtouq.c,v 1.4.8.1 2001/03/02 09:45:20 obrien Exp $"; +#endif + +#include + +#include + +/* + * Convert a string to an unsigned quad integer. + * + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ +u_quad_t +strtouq(nptr, endptr, base) + const char *nptr; + char **endptr; + int base; +{ + + return strtoull(nptr, endptr, base); +} diff --git a/stdlib/system.3 b/stdlib/system.3 new file mode 100644 index 0000000..a6aa661 --- /dev/null +++ b/stdlib/system.3 @@ -0,0 +1,103 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)system.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdlib/system.3,v 1.10 2001/09/07 14:46:36 asmodai Exp $ +.\" +.Dd June 4, 1993 +.Dt SYSTEM 3 +.Os +.Sh NAME +.Nm system +.Nd pass a command to the shell +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdlib.h +.Ft int +.Fn system "const char *string" +.Sh DESCRIPTION +The +.Fn system +function +hands the argument +.Fa string +to the command interpreter +.Xr sh 1 . +The calling process waits for the shell +to finish executing the command, +ignoring +.Dv SIGINT +and +.Dv SIGQUIT , +and blocking +.Dv SIGCHLD . +.Pp +If +.Fa string +is a +.Dv NULL +pointer, +.Fn system +will return non-zero if the command interpreter +.Xr sh 1 +is available, and zero if it is not. +.Pp +The +.Fn system +function +returns the exit status of the shell as returned by +.Xr waitpid 2 , +or \-1 if an error occurred when invoking +.Xr fork 2 +or +.Xr waitpid 2 . +A return value of 127 means the execution of the shell +failed. +.Sh SEE ALSO +.Xr sh 1 , +.Xr execve 2 , +.Xr fork 2 , +.Xr waitpid 2 , +.Xr popen 3 +.Sh STANDARDS +The +.Fn system +function +conforms to +.St -isoC . +and is expected to be +.St -p1003.2 +compatible. diff --git a/stdlib.subproj/system.c b/stdlib/system.c similarity index 96% rename from stdlib.subproj/system.c rename to stdlib/system.c index f31e4db..19d7c76 100644 --- a/stdlib.subproj/system.c +++ b/stdlib/system.c @@ -60,12 +60,13 @@ #include #include #include +#include system(command) const char *command; { union wait pstat; - pid_t pid; + pid_t kid, pid; int omask; sig_t intsave, quitsave; @@ -73,7 +74,7 @@ system(command) return(1); omask = sigblock(sigmask(SIGCHLD)); - switch(pid = vfork()) { + switch(kid = vfork()) { case -1: /* error */ (void)sigsetmask(omask); pstat.w_status = 0; @@ -86,7 +87,9 @@ system(command) } intsave = signal(SIGINT, SIG_IGN); quitsave = signal(SIGQUIT, SIG_IGN); - pid = waitpid(pid, (int *)&pstat, 0); + do { + pid = waitpid(kid, (int *)&pstat, 0); + } while (pid < 0 && errno == EINTR); (void)sigsetmask(omask); (void)signal(SIGINT, intsave); (void)signal(SIGQUIT, quitsave); diff --git a/stdlib/tsearch.3 b/stdlib/tsearch.3 new file mode 100644 index 0000000..a36fe89 --- /dev/null +++ b/stdlib/tsearch.3 @@ -0,0 +1,118 @@ +.\" $NetBSD$ +.\" Copyright (c) 1997 Todd C. Miller +.\" 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. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +.\" AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +.\" THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +.\" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +.\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +.\" OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" OpenBSD: tsearch.3,v 1.2 1998/06/21 22:13:49 millert Exp +.\" $FreeBSD: src/lib/libc/stdlib/tsearch.3,v 1.7 2001/09/07 14:46:36 asmodai Exp $ +.\" +.Dd June 15, 1997 +.Dt TSEARCH 3 +.Os +.Sh NAME +.Nm tsearch , tfind , tdelete , twalk +.Nd manipulate binary search trees +.Sh SYNOPSIS +.In search.h +.Ft void * +.Fn tdelete "const void *key" "void **rootp" "int (*compar) (const void *, const void *)" +.Ft void * +.Fn tfind "const void *key" "void **rootp" "int (*compar) (const void *, const void *)" +.Ft void * +.Fn tsearch "const void *key" "void **rootp" "int (*compar) (const void *, const void *)" +.Ft void +.Fn twalk "const void *root" "void (*compar) (const void *, VISIT, int)" +.Sh DESCRIPTION +The +.Fn tdelete , +.Fn tfind , +.Fn tsearch , +and +.Fn twalk +functions manage binary search trees based on algorithms T and D +from Knuth (6.2.2). The comparison function passed in by +the user has the same style of return values as +.Xr strcmp 3 . +.Pp +.Fn Tfind +searches for the datum matched by the argument +.Fa key +in the binary tree rooted at +.Fa rootp , +returning a pointer to the datum if it is found and NULL +if it is not. +.Pp +.Fn Tsearch +is identical to +.Fn tfind +except that if no match is found, +.Fa key +is inserted into the tree and a pointer to it is returned. If +.Fa rootp +points to a NULL value a new binary search tree is created. +.Pp +.Fn Tdelete +deletes a node from the specified binary search tree and returns +a pointer to the parent of the node to be deleted. +It takes the same arguments as +.Fn tfind +and +.Fn tsearch . +If the node to be deleted is the root of the binary search tree, +.Fa rootp +will be adjusted. +.Pp +.Fn Twalk +walks the binary search tree rooted in +.Fa root +and calls the function +.Fa action +on each node. +.Fa Action +is called with three arguments: a pointer to the current node, +a value from the enum +.Sy "typedef enum { preorder, postorder, endorder, leaf } VISIT;" +specifying the traversal type, and a node level (where level +zero is the root of the tree). +.Sh SEE ALSO +.Xr bsearch 3 , +.Xr hsearch 3 , +.Xr lsearch 3 +.Sh RETURN VALUES +The +.Fn tsearch +function returns NULL if allocation of a new node fails (usually +due to a lack of free memory). +.Pp +.Fn Tfind , +.Fn tsearch , +and +.Fn tdelete +return NULL if +.Fa rootp +is NULL or the datum cannot be found. +.Pp +The +.Fn twalk +function returns no value. diff --git a/stdtime/Makefile.inc b/stdtime/Makefile.inc new file mode 100644 index 0000000..12c4b0c --- /dev/null +++ b/stdtime/Makefile.inc @@ -0,0 +1,17 @@ +# Makefile.inc,v 1.2 1994/09/13 21:26:01 wollman Exp +# $FreeBSD: src/lib/libc/stdtime/Makefile.inc,v 1.13 2001/10/28 19:54:49 dillon Exp $ + +.PATH: ${.CURDIR}/stdtime ${.CURDIR}/locale + +SRCS+= timelocal.c asctime.c difftime.c localtime.c strftime.c strptime.c + +.if ${LIB} == "c" +MAN3+= ctime.3 strftime.3 strptime.3 time2posix.3 +MAN5+= tzfile.5 + +MLINKS+=ctime.3 asctime.3 ctime.3 difftime.3 ctime.3 gmtime.3 \ + ctime.3 localtime.3 ctime.3 mktime.3 ctime.3 timegm.3 \ + ctime.3 ctime_r.3 ctime.3 localtime_r.3 ctime.3 gmtime_r.3 \ + ctime.3 asctime_r.3 +MLINKS+=time2posix.3 posix2time.3 +.endif diff --git a/stdtime/asctime.c b/stdtime/asctime.c new file mode 100644 index 0000000..c669b54 --- /dev/null +++ b/stdtime/asctime.c @@ -0,0 +1,78 @@ +/* +** This file is in the public domain, so clarified as of +** June 5, 1996 by Arthur David Olson (arthur_david_olson@nih.gov). +** +** $FreeBSD: src/lib/libc/stdtime/asctime.c,v 1.7.6.1 2001/03/05 11:37:20 obrien Exp $ +*/ + +#ifndef lint +#ifndef NOID +static char elsieid[] = "@(#)asctime.c 7.7"; +#endif /* !defined NOID */ +#endif /* !defined lint */ + +/*LINTLIBRARY*/ + +#include "private.h" +#include "tzfile.h" + +/* +** A la X3J11, with core dump avoidance. +*/ + + +char * +asctime(timeptr) +const struct tm * timeptr; +{ + static char *result = NULL; + + if( result == NULL ) { + result = (char *)malloc(3 * 2 + 5 * INT_STRLEN_MAXIMUM(int) + + 3 + 2 + 1 + 1); + if( result == NULL ) + return NULL; + } + return(asctime_r(timeptr, result)); +} + +char * +asctime_r(timeptr, result) +const struct tm * timeptr; +char *result; +{ + static const char wday_name[][3] = { + "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" + }; + static const char mon_name[][3] = { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" + }; + /* + ** Big enough for something such as + ** ??? ???-2147483648 -2147483648:-2147483648:-2147483648 -2147483648\n + ** (two three-character abbreviations, five strings denoting integers, + ** three explicit spaces, two explicit colons, a newline, + ** and a trailing ASCII nul). + */ + register const char * wn; + register const char * mn; + + if (timeptr->tm_wday < 0 || timeptr->tm_wday >= DAYSPERWEEK) + wn = "???"; + else wn = wday_name[timeptr->tm_wday]; + if (timeptr->tm_mon < 0 || timeptr->tm_mon >= MONSPERYEAR) + mn = "???"; + else mn = mon_name[timeptr->tm_mon]; + /* + ** The X3J11-suggested format is + ** "%.3s %.3s%3d %02.2d:%02.2d:%02.2d %d\n" + ** Since the .2 in 02.2d is ignored, we drop it. + */ + (void) sprintf(result, "%.3s %.3s%3d %02d:%02d:%02d %d\n", + wn, mn, + timeptr->tm_mday, timeptr->tm_hour, + timeptr->tm_min, timeptr->tm_sec, + TM_YEAR_BASE + timeptr->tm_year); + return result; +} diff --git a/stdtime/ctime.3 b/stdtime/ctime.3 new file mode 100644 index 0000000..fa2895d --- /dev/null +++ b/stdtime/ctime.3 @@ -0,0 +1,363 @@ +.\" Copyright (c) 1989, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Arthur Olson. +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" From: @(#)ctime.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdtime/ctime.3,v 1.11.2.6 2001/10/02 11:36:10 ru Exp $ +.\" +.Dd January 2, 1999 +.Dt CTIME 3 +.Os +.Sh NAME +.Nm asctime , +.Nm asctime_r , +.Nm ctime , +.Nm ctime_r , +.Nm difftime , +.Nm gmtime , +.Nm gmtime_r , +.Nm localtime , +.Nm localtime_r , +.Nm mktime , +.Nm timegm +.Nd transform binary date and time values +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In time.h +.Vt extern char *tzname[2] ; +.Ft char * +.Fn ctime "const time_t *clock" +.Ft double +.Fn difftime "time_t time1" "time_t time0" +.Ft char * +.Fn asctime "const struct tm *tm" +.Ft struct tm * +.Fn localtime "const time_t *clock" +.Ft struct tm * +.Fn gmtime "const time_t *clock" +.Ft time_t +.Fn mktime "struct tm *tm" +.Ft time_t +.Fn timegm "struct tm *tm" +.Ft char * +.Fn ctime_r "const time_t *clock" "char *buf" +.Ft struct tm * +.Fn localtime_r "const time_t *clock" "struct tm *result" +.Ft struct tm * +.Fn gmtime_r "const time_t *clock" "struct tm *result" +.Ft char * +.Fn asctime_r "const struct tm *tm" "char *buf" +.Sh DESCRIPTION +The functions +.Fn ctime , +.Fn gmtime +and +.Fn localtime +all take as an argument a time value representing the time in seconds since +the Epoch (00:00:00 +.Tn UTC , +January 1, 1970; see +.Xr time 3 ) . +.Pp +The function +.Fn localtime +converts the time value pointed at by +.Fa clock , +and returns a pointer to a +.Dq Fa struct tm +(described below) which contains +the broken-out time information for the value after adjusting for the current +time zone (and any other factors such as Daylight Saving Time). +Time zone adjustments are performed as specified by the +.Ev TZ +environment variable (see +.Xr tzset 3 ) . +The function +.Fn localtime +uses +.Xr tzset 3 +to initialize time conversion information if +.Xr tzset 3 +has not already been called by the process. +.Pp +After filling in the tm structure, +.Fn localtime +sets the +.Fa tm_isdst Ns 'th +element of +.Fa tzname +to a pointer to an +.Tn ASCII +string that's the time zone abbreviation to be +used with +.Fn localtime Ns 's +return value. +.Pp +The function +.Fn gmtime +similarly converts the time value, but without any time zone adjustment, +and returns a pointer to a tm structure (described below). +.Pp +The +.Fn ctime +function +adjusts the time value for the current time zone in the same manner as +.Fn localtime , +and returns a pointer to a 26-character string of the form: +.Bd -literal -offset indent +Thu Nov 24 18:22:48 1986\en\e0 +.Ed +.Pp +All the fields have constant width. +.Pp +.Fn ctime_r +provides the same functionality as +.Fn ctime +except the caller must provide the output buffer +.Fa buf +to store the result, which must be at least 26 characters long. +.Fn localtime_r +and +.Fn gmtime_r +provide the same functionality as +.Fn localtime +and +.Fn gmtime +respectively, except the caller must provide the output buffer +.Fa result . +.Pp +The +.Fn asctime +function +converts the broken down time in the structure +.Fa tm +pointed at by +.Fa *tm +to the form +shown in the example above. +.Pp +.Fn asctime_r +provides the same functionality as +.Fn asctime +except the caller provide the output buffer +.Fa buf +to store the result, which must be at least 26 characters long. +.Pp +The functions +.Fn mktime +and +.Fn timegm +convert the broken-down time in the structure +pointed to by tm into a time value with the same encoding as that of the +values returned by the +.Xr time 3 +function (that is, seconds from the Epoch, +.Tn UTC ) . +.Fn mktime +interprets the input structure according to the current timezone setting +(see +.Xr tzset 3 ) . +.Fn timegm +interprets the input structure as representing Universal Coordinated Time +.Pq Tn UTC . +.Pp +The original values of the +.Fa tm_wday +and +.Fa tm_yday +components of the structure are ignored, and the original values of the +other components are not restricted to their normal ranges, and will be +normalized if needed. +For example, +October 40 is changed into November 9, +a +.Fa tm_hour +of \-1 means 1 hour before midnight, +.Fa tm_mday +of 0 means the day preceding the current month, and +.Fa tm_mon +of \-2 means 2 months before January of +.Fa tm_year . +(A positive or zero value for +.Fa tm_isdst +causes +.Fn mktime +to presume initially that summer time (for example, Daylight Saving Time) +is or is not in effect for the specified time, respectively. +A negative value for +.Fa tm_isdst +causes the +.Fn mktime +function to attempt to divine whether summer time is in effect for the +specified time. +The +.Fa tm_isdst +and +.Fa tm_gmtoff +members are forced to zero by +.Fn timegm . ) +.Pp +On successful completion, the values of the +.Fa tm_wday +and +.Fa tm_yday +components of the structure are set appropriately, and the other components +are set to represent the specified calendar time, but with their values +forced to their normal ranges; the final value of +.Fa tm_mday +is not set until +.Fa tm_mon +and +.Fa tm_year +are determined. +.Fn Mktime +returns the specified calendar time; if the calendar time cannot be +represented, it returns \-1; +.Pp +The +.Fn difftime +function +returns the difference between two calendar times, +.Pf ( Fa time1 +- +.Fa time0 ) , +expressed in seconds. +.Pp +External declarations as well as the tm structure definition are in the +.Aq Pa time.h +include file. +The tm structure includes at least the following fields: +.Bd -literal -offset indent +int tm_sec; /\(** seconds (0 - 60) \(**/ +int tm_min; /\(** minutes (0 - 59) \(**/ +int tm_hour; /\(** hours (0 - 23) \(**/ +int tm_mday; /\(** day of month (1 - 31) \(**/ +int tm_mon; /\(** month of year (0 - 11) \(**/ +int tm_year; /\(** year \- 1900 \(**/ +int tm_wday; /\(** day of week (Sunday = 0) \(**/ +int tm_yday; /\(** day of year (0 - 365) \(**/ +int tm_isdst; /\(** is summer time in effect? \(**/ +char \(**tm_zone; /\(** abbreviation of timezone name \(**/ +long tm_gmtoff; /\(** offset from UTC in seconds \(**/ +.Ed +.Pp +The +field +.Fa tm_isdst +is non-zero if summer time is in effect. +.Pp +The field +.Fa tm_gmtoff +is the offset (in seconds) of the time represented from +.Tn UTC , +with positive +values indicating east of the Prime Meridian. +.Sh SEE ALSO +.Xr date 1 , +.Xr gettimeofday 2 , +.Xr getenv 3 , +.Xr time 3 , +.Xr tzset 3 , +.Xr tzfile 5 +.Sh STANDARDS +The +.Fn asctime , +.Fn ctime , +.Fn difftime , +.Fn gmtime , +.Fn localtime , +and +.Fn mktime +functions conform to +.St -isoC , +and conform to +.St -p1003.1-96 +provided the selected local timezone does not contain a leap-second table +(see +.Xr zic 8 ) . +.Pp +The +.Fn asctime_r , +.Fn ctime_r , +.Fn gmtime_r , +and +.Fn localtime_r +functions are expected to conform to +.St -p1003.1-96 +(again provided the selected local timezone does not contain a leap-second +table). +.Pp +The +.Fn timegm +function is not specified by any standard; its function cannot be +completely emulated using the standard functions described above. +.Sh HISTORY +This manual page is derived from +the time package contributed to Berkeley by +.An Arthur Olson +and which appeared in +.Bx 4.3 . +.Sh BUGS +Except for +.Fn difftime , +.Fn mktime , +and the +.Fn \&_r +variants of the other functions, +these functions leaves their result in an internal static object and return +a pointer to that object. +Subsequent calls to these +function will modify the same object. +.Pp +The C Standard provides no mechanism for a program to modify its current +local timezone setting, and the +.Tn POSIX Ns No \&-standard +method is not reentrant. (However, thread-safe implementations are provided +in the +.Tn POSIX +threaded environment.) +.Pp +The +.Fa tm_zone +field of a returned tm structure points to a static array of characters, +which will also be overwritten by any subsequent calls (as well as by +subsequent calls to +.Xr tzset 3 +and +.Xr tzsetwall 3 ) . +.Pp +Use of the external variable +.Fa tzname +is discouraged; the +.Fa tm_zone +entry in the tm structure is preferred. diff --git a/stdtime/difftime.c b/stdtime/difftime.c new file mode 100644 index 0000000..5a6c5c6 --- /dev/null +++ b/stdtime/difftime.c @@ -0,0 +1,79 @@ +/* +** This file is in the public domain, so clarified as of +** June 5, 1996 by Arthur David Olson (arthur_david_olson@nih.gov). +** +** $FreeBSD: src/lib/libc/stdtime/difftime.c,v 1.4.8.1 2001/03/05 11:37:21 obrien Exp $ +*/ + +#ifndef lint +#ifndef NOID +static char elsieid[] = "@(#)difftime.c 7.7"; +#endif /* !defined NOID */ +#endif /* !defined lint */ + +/*LINTLIBRARY*/ + +#include "private.h" + +/* +** Algorithm courtesy Paul Eggert (eggert@twinsun.com). +*/ + +#ifdef HAVE_LONG_DOUBLE +#define long_double long double +#endif /* defined HAVE_LONG_DOUBLE */ +#ifndef HAVE_LONG_DOUBLE +#define long_double double +#endif /* !defined HAVE_LONG_DOUBLE */ + +double +difftime(time1, time0) +const time_t time1; +const time_t time0; +{ + time_t delta; + time_t hibit; + + if (sizeof(time_t) < sizeof(double)) + return (double) time1 - (double) time0; + if (sizeof(time_t) < sizeof(long_double)) + return (long_double) time1 - (long_double) time0; + if (time1 < time0) + return -difftime(time0, time1); + /* + ** As much as possible, avoid loss of precision + ** by computing the difference before converting to double. + */ + delta = time1 - time0; + if (delta >= 0) + return delta; + /* + ** Repair delta overflow. + */ + hibit = (~ (time_t) 0) << (TYPE_BIT(time_t) - 1); + /* + ** The following expression rounds twice, which means + ** the result may not be the closest to the true answer. + ** For example, suppose time_t is 64-bit signed int, + ** long_double is IEEE 754 double with default rounding, + ** time1 = 9223372036854775807 and time0 = -1536. + ** Then the true difference is 9223372036854777343, + ** which rounds to 9223372036854777856 + ** with a total error of 513. + ** But delta overflows to -9223372036854774273, + ** which rounds to -9223372036854774784, and correcting + ** this by subtracting 2 * (long_double) hibit + ** (i.e. by adding 2**64 = 18446744073709551616) + ** yields 9223372036854776832, which + ** rounds to 9223372036854775808 + ** with a total error of 1535 instead. + ** This problem occurs only with very large differences. + ** It's too painful to fix this portably. + ** We are not alone in this problem; + ** some C compilers round twice when converting + ** large unsigned types to small floating types, + ** so if time_t is unsigned the "return delta" above + ** has the same double-rounding problem with those compilers. + */ + return delta - 2 * (long_double) hibit; +} diff --git a/stdtime/localtime.c b/stdtime/localtime.c new file mode 100644 index 0000000..680d750 --- /dev/null +++ b/stdtime/localtime.c @@ -0,0 +1,1770 @@ +/* +** This file is in the public domain, so clarified as of +** June 5, 1996 by Arthur David Olson (arthur_david_olson@nih.gov). +** +** $FreeBSD: src/lib/libc/stdtime/localtime.c,v 1.25.2.1 2001/03/05 11:37:21 obrien Exp $ +*/ + +#ifndef lint +#ifndef NOID +static char elsieid[] = "@(#)localtime.c 7.57"; +#endif /* !defined NOID */ +#endif /* !defined lint */ + +/* +** Leap second handling from Bradley White (bww@k.gp.cs.cmu.edu). +** POSIX-style TZ environment variable handling from Guy Harris +** (guy@auspex.com). +*/ + +/*LINTLIBRARY*/ + +#include +#include +#include "private.h" +#include "tzfile.h" +#include "fcntl.h" +#ifdef _THREAD_SAFE +#include +#include "pthread_private.h" +#endif + +/* +** SunOS 4.1.1 headers lack O_BINARY. +*/ + +#ifdef O_BINARY +#define OPEN_MODE (O_RDONLY | O_BINARY) +#endif /* defined O_BINARY */ +#ifndef O_BINARY +#define OPEN_MODE O_RDONLY +#endif /* !defined O_BINARY */ + +#ifndef WILDABBR +/* +** Someone might make incorrect use of a time zone abbreviation: +** 1. They might reference tzname[0] before calling tzset (explicitly +** or implicitly). +** 2. They might reference tzname[1] before calling tzset (explicitly +** or implicitly). +** 3. They might reference tzname[1] after setting to a time zone +** in which Daylight Saving Time is never observed. +** 4. They might reference tzname[0] after setting to a time zone +** in which Standard Time is never observed. +** 5. They might reference tm.TM_ZONE after calling offtime. +** What's best to do in the above cases is open to debate; +** for now, we just set things up so that in any of the five cases +** WILDABBR is used. Another possibility: initialize tzname[0] to the +** string "tzname[0] used before set", and similarly for the other cases. +** And another: initialize tzname[0] to "ERA", with an explanation in the +** manual page of what this "time zone abbreviation" means (doing this so +** that tzname[0] has the "normal" length of three characters). +*/ +#define WILDABBR " " +#endif /* !defined WILDABBR */ + +static char wildabbr[] = "WILDABBR"; + +static const char gmt[] = "GMT"; + +struct ttinfo { /* time type information */ + long tt_gmtoff; /* GMT offset in seconds */ + int tt_isdst; /* used to set tm_isdst */ + int tt_abbrind; /* abbreviation list index */ + int tt_ttisstd; /* TRUE if transition is std time */ + int tt_ttisgmt; /* TRUE if transition is GMT */ +}; + +struct lsinfo { /* leap second information */ + time_t ls_trans; /* transition time */ + long ls_corr; /* correction to apply */ +}; + +#define BIGGEST(a, b) (((a) > (b)) ? (a) : (b)) + +#ifdef TZNAME_MAX +#define MY_TZNAME_MAX TZNAME_MAX +#endif /* defined TZNAME_MAX */ +#ifndef TZNAME_MAX +#define MY_TZNAME_MAX 255 +#endif /* !defined TZNAME_MAX */ + +struct state { + int leapcnt; + int timecnt; + int typecnt; + int charcnt; + time_t ats[TZ_MAX_TIMES]; + unsigned char types[TZ_MAX_TIMES]; + struct ttinfo ttis[TZ_MAX_TYPES]; + char chars[BIGGEST(BIGGEST(TZ_MAX_CHARS + 1, sizeof gmt), + (2 * (MY_TZNAME_MAX + 1)))]; + struct lsinfo lsis[TZ_MAX_LEAPS]; +}; + +struct rule { + int r_type; /* type of rule--see below */ + int r_day; /* day number of rule */ + int r_week; /* week number of rule */ + int r_mon; /* month number of rule */ + long r_time; /* transition time of rule */ +}; + +#define JULIAN_DAY 0 /* Jn - Julian day */ +#define DAY_OF_YEAR 1 /* n - day of year */ +#define MONTH_NTH_DAY_OF_WEEK 2 /* Mm.n.d - month, week, day of week */ + +/* +** Prototypes for static functions. +*/ + +static long detzcode P((const char * codep)); +static const char * getzname P((const char * strp)); +static const char * getnum P((const char * strp, int * nump, int min, + int max)); +static const char * getsecs P((const char * strp, long * secsp)); +static const char * getoffset P((const char * strp, long * offsetp)); +static const char * getrule P((const char * strp, struct rule * rulep)); +static void gmtload P((struct state * sp)); +static void gmtsub P((const time_t * timep, long offset, + struct tm * tmp)); +static void localsub P((const time_t * timep, long offset, + struct tm * tmp)); +static int increment_overflow P((int * number, int delta)); +static int normalize_overflow P((int * tensptr, int * unitsptr, + int base)); +static void settzname P((void)); +static time_t time1 P((struct tm * tmp, + void(*funcp) P((const time_t *, + long, struct tm *)), + long offset)); +static time_t time2 P((struct tm *tmp, + void(*funcp) P((const time_t *, + long, struct tm*)), + long offset, int * okayp)); +static void timesub P((const time_t * timep, long offset, + const struct state * sp, struct tm * tmp)); +static int tmcomp P((const struct tm * atmp, + const struct tm * btmp)); +static time_t transtime P((time_t janfirst, int year, + const struct rule * rulep, long offset)); +static int tzload P((const char * name, struct state * sp)); +static int tzparse P((const char * name, struct state * sp, + int lastditch)); + +#ifdef ALL_STATE +static struct state * lclptr; +static struct state * gmtptr; +#endif /* defined ALL_STATE */ + +#ifndef ALL_STATE +static struct state lclmem; +static struct state gmtmem; +#define lclptr (&lclmem) +#define gmtptr (&gmtmem) +#endif /* State Farm */ + +#ifndef TZ_STRLEN_MAX +#define TZ_STRLEN_MAX 255 +#endif /* !defined TZ_STRLEN_MAX */ + +static char lcl_TZname[TZ_STRLEN_MAX + 1]; +#ifdef _THREAD_SAFE +static struct pthread_mutex _lcl_mutexd = PTHREAD_MUTEX_STATIC_INITIALIZER; +static struct pthread_mutex _gmt_mutexd = PTHREAD_MUTEX_STATIC_INITIALIZER; +static pthread_mutex_t lcl_mutex = &_lcl_mutexd; +static pthread_mutex_t gmt_mutex = &_gmt_mutexd; +#endif + +char * tzname[2] = { + wildabbr, + wildabbr +}; + +/* +** Section 4.12.3 of X3.159-1989 requires that +** Except for the strftime function, these functions [asctime, +** ctime, gmtime, localtime] return values in one of two static +** objects: a broken-down time structure and an array of char. +** Thanks to Paul Eggert (eggert@twinsun.com) for noting this. +*/ + +static struct tm tm; + +#ifdef USG_COMPAT +time_t timezone = 0; +int daylight = 0; +#endif /* defined USG_COMPAT */ + +#ifdef ALTZONE +time_t altzone = 0; +#endif /* defined ALTZONE */ + +static long +detzcode(codep) +const char * const codep; +{ + register long result; + register int i; + + result = (codep[0] & 0x80) ? ~0L : 0L; + for (i = 0; i < 4; ++i) + result = (result << 8) | (codep[i] & 0xff); + return result; +} + +static void +settzname P((void)) +{ + register struct state * sp = lclptr; + register int i; + + tzname[0] = wildabbr; + tzname[1] = wildabbr; +#ifdef USG_COMPAT + daylight = 0; + timezone = 0; +#endif /* defined USG_COMPAT */ +#ifdef ALTZONE + altzone = 0; +#endif /* defined ALTZONE */ +#ifdef ALL_STATE + if (sp == NULL) { + tzname[0] = tzname[1] = gmt; + return; + } +#endif /* defined ALL_STATE */ + for (i = 0; i < sp->typecnt; ++i) { + register const struct ttinfo * const ttisp = &sp->ttis[i]; + + tzname[ttisp->tt_isdst] = + &sp->chars[ttisp->tt_abbrind]; +#ifdef USG_COMPAT + if (ttisp->tt_isdst) + daylight = 1; + if (i == 0 || !ttisp->tt_isdst) + timezone = -(ttisp->tt_gmtoff); +#endif /* defined USG_COMPAT */ +#ifdef ALTZONE + if (i == 0 || ttisp->tt_isdst) + altzone = -(ttisp->tt_gmtoff); +#endif /* defined ALTZONE */ + } + /* + ** And to get the latest zone names into tzname. . . + */ + for (i = 0; i < sp->timecnt; ++i) { + register const struct ttinfo * const ttisp = + &sp->ttis[ + sp->types[i]]; + + tzname[ttisp->tt_isdst] = + &sp->chars[ttisp->tt_abbrind]; + } +} + +static int +tzload(name, sp) +register const char * name; +register struct state * const sp; +{ + register const char * p; + register int i; + register int fid; + static struct stat sb; + struct stat newsb; + + /* XXX The following is from OpenBSD, and I'm not sure it is correct */ + if (name != NULL && issetugid() != 0) + if ((name[0] == ':' && name[1] == '/') || + name[0] == '/' || strchr(name, '.')) + name = NULL; + if (name == NULL && (name = TZDEFAULT) == NULL) + return -1; + { + register int doaccess; + struct stat stab; + /* + ** Section 4.9.1 of the C standard says that + ** "FILENAME_MAX expands to an integral constant expression + ** that is the size needed for an array of char large enough + ** to hold the longest file name string that the implementation + ** guarantees can be opened." + */ + char fullname[FILENAME_MAX + 1]; + + if (name[0] == ':') + ++name; + doaccess = name[0] == '/'; + if (!doaccess) { + if ((p = TZDIR) == NULL) + return -1; + if ((strlen(p) + 1 + strlen(name) + 1) >= sizeof fullname) + return -1; + (void) strcpy(fullname, p); + (void) strcat(fullname, "/"); + (void) strcat(fullname, name); + /* + ** Set doaccess if '.' (as in "../") shows up in name. + */ + if (strchr(name, '.') != NULL) + doaccess = TRUE; + name = fullname; + } + if (lstat(name, &newsb) == -1) + return -1; + if( (sb.st_dev == newsb.st_dev) && (sb.st_ino == newsb.st_ino) && + (sb.st_gen == newsb.st_gen) && + (memcmp(&sb.st_ctimespec, &newsb.st_ctimespec, + sizeof(struct timespec)) == 0) ) { + return 0; + } + memcpy(&sb, &newsb, sizeof(sb)); + if ((fid = open(name, OPEN_MODE)) == -1) + return -1; + if ((fstat(fid, &stab) < 0) || !S_ISREG(stab.st_mode)) + return -1; + } + { + struct tzhead * tzhp; + char buf[sizeof *sp + sizeof *tzhp]; + int ttisstdcnt; + int ttisgmtcnt; + + i = read(fid, buf, sizeof buf); + if (close(fid) != 0) + return -1; + p = buf; + p += (sizeof tzhp->tzh_magic) + (sizeof tzhp->tzh_reserved); + ttisstdcnt = (int) detzcode(p); + p += 4; + ttisgmtcnt = (int) detzcode(p); + p += 4; + sp->leapcnt = (int) detzcode(p); + p += 4; + sp->timecnt = (int) detzcode(p); + p += 4; + sp->typecnt = (int) detzcode(p); + p += 4; + sp->charcnt = (int) detzcode(p); + p += 4; + if (sp->leapcnt < 0 || sp->leapcnt > TZ_MAX_LEAPS || + sp->typecnt <= 0 || sp->typecnt > TZ_MAX_TYPES || + sp->timecnt < 0 || sp->timecnt > TZ_MAX_TIMES || + sp->charcnt < 0 || sp->charcnt > TZ_MAX_CHARS || + (ttisstdcnt != sp->typecnt && ttisstdcnt != 0) || + (ttisgmtcnt != sp->typecnt && ttisgmtcnt != 0)) + return -1; + if (i - (p - buf) < sp->timecnt * 4 + /* ats */ + sp->timecnt + /* types */ + sp->typecnt * (4 + 2) + /* ttinfos */ + sp->charcnt + /* chars */ + sp->leapcnt * (4 + 4) + /* lsinfos */ + ttisstdcnt + /* ttisstds */ + ttisgmtcnt) /* ttisgmts */ + return -1; + for (i = 0; i < sp->timecnt; ++i) { + sp->ats[i] = detzcode(p); + p += 4; + } + for (i = 0; i < sp->timecnt; ++i) { + sp->types[i] = (unsigned char) *p++; + if (sp->types[i] >= sp->typecnt) + return -1; + } + for (i = 0; i < sp->typecnt; ++i) { + register struct ttinfo * ttisp; + + ttisp = &sp->ttis[i]; + ttisp->tt_gmtoff = detzcode(p); + p += 4; + ttisp->tt_isdst = (unsigned char) *p++; + if (ttisp->tt_isdst != 0 && ttisp->tt_isdst != 1) + return -1; + ttisp->tt_abbrind = (unsigned char) *p++; + if (ttisp->tt_abbrind < 0 || + ttisp->tt_abbrind > sp->charcnt) + return -1; + } + for (i = 0; i < sp->charcnt; ++i) + sp->chars[i] = *p++; + sp->chars[i] = '\0'; /* ensure '\0' at end */ + for (i = 0; i < sp->leapcnt; ++i) { + register struct lsinfo * lsisp; + + lsisp = &sp->lsis[i]; + lsisp->ls_trans = detzcode(p); + p += 4; + lsisp->ls_corr = detzcode(p); + p += 4; + } + for (i = 0; i < sp->typecnt; ++i) { + register struct ttinfo * ttisp; + + ttisp = &sp->ttis[i]; + if (ttisstdcnt == 0) + ttisp->tt_ttisstd = FALSE; + else { + ttisp->tt_ttisstd = *p++; + if (ttisp->tt_ttisstd != TRUE && + ttisp->tt_ttisstd != FALSE) + return -1; + } + } + for (i = 0; i < sp->typecnt; ++i) { + register struct ttinfo * ttisp; + + ttisp = &sp->ttis[i]; + if (ttisgmtcnt == 0) + ttisp->tt_ttisgmt = FALSE; + else { + ttisp->tt_ttisgmt = *p++; + if (ttisp->tt_ttisgmt != TRUE && + ttisp->tt_ttisgmt != FALSE) + return -1; + } + } + } + return 0; +} + +static const int mon_lengths[2][MONSPERYEAR] = { + { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, + { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } +}; + +static const int year_lengths[2] = { + DAYSPERNYEAR, DAYSPERLYEAR +}; + +/* +** Given a pointer into a time zone string, scan until a character that is not +** a valid character in a zone name is found. Return a pointer to that +** character. +*/ + +static const char * +getzname(strp) +register const char * strp; +{ + register char c; + + while ((c = *strp) != '\0' && !is_digit(c) && c != ',' && c != '-' && + c != '+') + ++strp; + return strp; +} + +/* +** Given a pointer into a time zone string, extract a number from that string. +** Check that the number is within a specified range; if it is not, return +** NULL. +** Otherwise, return a pointer to the first character not part of the number. +*/ + +static const char * +getnum(strp, nump, min, max) +register const char * strp; +int * const nump; +const int min; +const int max; +{ + register char c; + register int num; + + if (strp == NULL || !is_digit(c = *strp)) + return NULL; + num = 0; + do { + num = num * 10 + (c - '0'); + if (num > max) + return NULL; /* illegal value */ + c = *++strp; + } while (is_digit(c)); + if (num < min) + return NULL; /* illegal value */ + *nump = num; + return strp; +} + +/* +** Given a pointer into a time zone string, extract a number of seconds, +** in hh[:mm[:ss]] form, from the string. +** If any error occurs, return NULL. +** Otherwise, return a pointer to the first character not part of the number +** of seconds. +*/ + +static const char * +getsecs(strp, secsp) +register const char * strp; +long * const secsp; +{ + int num; + + /* + ** `HOURSPERDAY * DAYSPERWEEK - 1' allows quasi-Posix rules like + ** "M10.4.6/26", which does not conform to Posix, + ** but which specifies the equivalent of + ** ``02:00 on the first Sunday on or after 23 Oct''. + */ + strp = getnum(strp, &num, 0, HOURSPERDAY * DAYSPERWEEK - 1); + if (strp == NULL) + return NULL; + *secsp = num * (long) SECSPERHOUR; + if (*strp == ':') { + ++strp; + strp = getnum(strp, &num, 0, MINSPERHOUR - 1); + if (strp == NULL) + return NULL; + *secsp += num * SECSPERMIN; + if (*strp == ':') { + ++strp; + /* `SECSPERMIN' allows for leap seconds. */ + strp = getnum(strp, &num, 0, SECSPERMIN); + if (strp == NULL) + return NULL; + *secsp += num; + } + } + return strp; +} + +/* +** Given a pointer into a time zone string, extract an offset, in +** [+-]hh[:mm[:ss]] form, from the string. +** If any error occurs, return NULL. +** Otherwise, return a pointer to the first character not part of the time. +*/ + +static const char * +getoffset(strp, offsetp) +register const char * strp; +long * const offsetp; +{ + register int neg = 0; + + if (*strp == '-') { + neg = 1; + ++strp; + } else if (*strp == '+') + ++strp; + strp = getsecs(strp, offsetp); + if (strp == NULL) + return NULL; /* illegal time */ + if (neg) + *offsetp = -*offsetp; + return strp; +} + +/* +** Given a pointer into a time zone string, extract a rule in the form +** date[/time]. See POSIX section 8 for the format of "date" and "time". +** If a valid rule is not found, return NULL. +** Otherwise, return a pointer to the first character not part of the rule. +*/ + +static const char * +getrule(strp, rulep) +const char * strp; +register struct rule * const rulep; +{ + if (*strp == 'J') { + /* + ** Julian day. + */ + rulep->r_type = JULIAN_DAY; + ++strp; + strp = getnum(strp, &rulep->r_day, 1, DAYSPERNYEAR); + } else if (*strp == 'M') { + /* + ** Month, week, day. + */ + rulep->r_type = MONTH_NTH_DAY_OF_WEEK; + ++strp; + strp = getnum(strp, &rulep->r_mon, 1, MONSPERYEAR); + if (strp == NULL) + return NULL; + if (*strp++ != '.') + return NULL; + strp = getnum(strp, &rulep->r_week, 1, 5); + if (strp == NULL) + return NULL; + if (*strp++ != '.') + return NULL; + strp = getnum(strp, &rulep->r_day, 0, DAYSPERWEEK - 1); + } else if (is_digit(*strp)) { + /* + ** Day of year. + */ + rulep->r_type = DAY_OF_YEAR; + strp = getnum(strp, &rulep->r_day, 0, DAYSPERLYEAR - 1); + } else return NULL; /* invalid format */ + if (strp == NULL) + return NULL; + if (*strp == '/') { + /* + ** Time specified. + */ + ++strp; + strp = getsecs(strp, &rulep->r_time); + } else rulep->r_time = 2 * SECSPERHOUR; /* default = 2:00:00 */ + return strp; +} + +/* +** Given the Epoch-relative time of January 1, 00:00:00 GMT, in a year, the +** year, a rule, and the offset from GMT at the time that rule takes effect, +** calculate the Epoch-relative time that rule takes effect. +*/ + +static time_t +transtime(janfirst, year, rulep, offset) +const time_t janfirst; +const int year; +register const struct rule * const rulep; +const long offset; +{ + register int leapyear; + register time_t value; + register int i; + int d, m1, yy0, yy1, yy2, dow; + + INITIALIZE(value); + leapyear = isleap(year); + switch (rulep->r_type) { + + case JULIAN_DAY: + /* + ** Jn - Julian day, 1 == January 1, 60 == March 1 even in leap + ** years. + ** In non-leap years, or if the day number is 59 or less, just + ** add SECSPERDAY times the day number-1 to the time of + ** January 1, midnight, to get the day. + */ + value = janfirst + (rulep->r_day - 1) * SECSPERDAY; + if (leapyear && rulep->r_day >= 60) + value += SECSPERDAY; + break; + + case DAY_OF_YEAR: + /* + ** n - day of year. + ** Just add SECSPERDAY times the day number to the time of + ** January 1, midnight, to get the day. + */ + value = janfirst + rulep->r_day * SECSPERDAY; + break; + + case MONTH_NTH_DAY_OF_WEEK: + /* + ** Mm.n.d - nth "dth day" of month m. + */ + value = janfirst; + for (i = 0; i < rulep->r_mon - 1; ++i) + value += mon_lengths[leapyear][i] * SECSPERDAY; + + /* + ** Use Zeller's Congruence to get day-of-week of first day of + ** month. + */ + m1 = (rulep->r_mon + 9) % 12 + 1; + yy0 = (rulep->r_mon <= 2) ? (year - 1) : year; + yy1 = yy0 / 100; + yy2 = yy0 % 100; + dow = ((26 * m1 - 2) / 10 + + 1 + yy2 + yy2 / 4 + yy1 / 4 - 2 * yy1) % 7; + if (dow < 0) + dow += DAYSPERWEEK; + + /* + ** "dow" is the day-of-week of the first day of the month. Get + ** the day-of-month (zero-origin) of the first "dow" day of the + ** month. + */ + d = rulep->r_day - dow; + if (d < 0) + d += DAYSPERWEEK; + for (i = 1; i < rulep->r_week; ++i) { + if (d + DAYSPERWEEK >= + mon_lengths[leapyear][rulep->r_mon - 1]) + break; + d += DAYSPERWEEK; + } + + /* + ** "d" is the day-of-month (zero-origin) of the day we want. + */ + value += d * SECSPERDAY; + break; + } + + /* + ** "value" is the Epoch-relative time of 00:00:00 GMT on the day in + ** question. To get the Epoch-relative time of the specified local + ** time on that day, add the transition time and the current offset + ** from GMT. + */ + return value + rulep->r_time + offset; +} + +/* +** Given a POSIX section 8-style TZ string, fill in the rule tables as +** appropriate. +*/ + +static int +tzparse(name, sp, lastditch) +const char * name; +register struct state * const sp; +const int lastditch; +{ + const char * stdname; + const char * dstname; + size_t stdlen; + size_t dstlen; + long stdoffset; + long dstoffset; + register time_t * atp; + register unsigned char * typep; + register char * cp; + register int load_result; + + INITIALIZE(dstname); + stdname = name; + if (lastditch) { + stdlen = strlen(name); /* length of standard zone name */ + name += stdlen; + if (stdlen >= sizeof sp->chars) + stdlen = (sizeof sp->chars) - 1; + stdoffset = 0; + } else { + name = getzname(name); + stdlen = name - stdname; + if (stdlen < 3) + return -1; + if (*name == '\0') + return -1; /* was "stdoffset = 0;" */ + else { + name = getoffset(name, &stdoffset); + if (name == NULL) + return -1; + } + } + load_result = tzload(TZDEFRULES, sp); + if (load_result != 0) + sp->leapcnt = 0; /* so, we're off a little */ + if (*name != '\0') { + dstname = name; + name = getzname(name); + dstlen = name - dstname; /* length of DST zone name */ + if (dstlen < 3) + return -1; + if (*name != '\0' && *name != ',' && *name != ';') { + name = getoffset(name, &dstoffset); + if (name == NULL) + return -1; + } else dstoffset = stdoffset - SECSPERHOUR; + if (*name == ',' || *name == ';') { + struct rule start; + struct rule end; + register int year; + register time_t janfirst; + time_t starttime; + time_t endtime; + + ++name; + if ((name = getrule(name, &start)) == NULL) + return -1; + if (*name++ != ',') + return -1; + if ((name = getrule(name, &end)) == NULL) + return -1; + if (*name != '\0') + return -1; + sp->typecnt = 2; /* standard time and DST */ + /* + ** Two transitions per year, from EPOCH_YEAR to 2037. + */ + sp->timecnt = 2 * (2037 - EPOCH_YEAR + 1); + if (sp->timecnt > TZ_MAX_TIMES) + return -1; + sp->ttis[0].tt_gmtoff = -dstoffset; + sp->ttis[0].tt_isdst = 1; + sp->ttis[0].tt_abbrind = stdlen + 1; + sp->ttis[1].tt_gmtoff = -stdoffset; + sp->ttis[1].tt_isdst = 0; + sp->ttis[1].tt_abbrind = 0; + atp = sp->ats; + typep = sp->types; + janfirst = 0; + for (year = EPOCH_YEAR; year <= 2037; ++year) { + starttime = transtime(janfirst, year, &start, + stdoffset); + endtime = transtime(janfirst, year, &end, + dstoffset); + if (starttime > endtime) { + *atp++ = endtime; + *typep++ = 1; /* DST ends */ + *atp++ = starttime; + *typep++ = 0; /* DST begins */ + } else { + *atp++ = starttime; + *typep++ = 0; /* DST begins */ + *atp++ = endtime; + *typep++ = 1; /* DST ends */ + } + janfirst += year_lengths[isleap(year)] * + SECSPERDAY; + } + } else { + register long theirstdoffset; + register long theirdstoffset; + register long theiroffset; + register int isdst; + register int i; + register int j; + + if (*name != '\0') + return -1; + if (load_result != 0) + return -1; + /* + ** Initial values of theirstdoffset and theirdstoffset. + */ + theirstdoffset = 0; + for (i = 0; i < sp->timecnt; ++i) { + j = sp->types[i]; + if (!sp->ttis[j].tt_isdst) { + theirstdoffset = + -sp->ttis[j].tt_gmtoff; + break; + } + } + theirdstoffset = 0; + for (i = 0; i < sp->timecnt; ++i) { + j = sp->types[i]; + if (sp->ttis[j].tt_isdst) { + theirdstoffset = + -sp->ttis[j].tt_gmtoff; + break; + } + } + /* + ** Initially we're assumed to be in standard time. + */ + isdst = FALSE; + theiroffset = theirstdoffset; + /* + ** Now juggle transition times and types + ** tracking offsets as you do. + */ + for (i = 0; i < sp->timecnt; ++i) { + j = sp->types[i]; + sp->types[i] = sp->ttis[j].tt_isdst; + if (sp->ttis[j].tt_ttisgmt) { + /* No adjustment to transition time */ + } else { + /* + ** If summer time is in effect, and the + ** transition time was not specified as + ** standard time, add the summer time + ** offset to the transition time; + ** otherwise, add the standard time + ** offset to the transition time. + */ + /* + ** Transitions from DST to DDST + ** will effectively disappear since + ** POSIX provides for only one DST + ** offset. + */ + if (isdst && !sp->ttis[j].tt_ttisstd) { + sp->ats[i] += dstoffset - + theirdstoffset; + } else { + sp->ats[i] += stdoffset - + theirstdoffset; + } + } + theiroffset = -sp->ttis[j].tt_gmtoff; + if (sp->ttis[j].tt_isdst) + theirdstoffset = theiroffset; + else theirstdoffset = theiroffset; + } + /* + ** Finally, fill in ttis. + ** ttisstd and ttisgmt need not be handled. + */ + sp->ttis[0].tt_gmtoff = -stdoffset; + sp->ttis[0].tt_isdst = FALSE; + sp->ttis[0].tt_abbrind = 0; + sp->ttis[1].tt_gmtoff = -dstoffset; + sp->ttis[1].tt_isdst = TRUE; + sp->ttis[1].tt_abbrind = stdlen + 1; + } + } else { + dstlen = 0; + sp->typecnt = 1; /* only standard time */ + sp->timecnt = 0; + sp->ttis[0].tt_gmtoff = -stdoffset; + sp->ttis[0].tt_isdst = 0; + sp->ttis[0].tt_abbrind = 0; + } + sp->charcnt = stdlen + 1; + if (dstlen != 0) + sp->charcnt += dstlen + 1; + if (sp->charcnt > sizeof sp->chars) + return -1; + cp = sp->chars; + (void) strncpy(cp, stdname, stdlen); + cp += stdlen; + *cp++ = '\0'; + if (dstlen != 0) { + (void) strncpy(cp, dstname, dstlen); + *(cp + dstlen) = '\0'; + } + return 0; +} + +static void +gmtload(sp) +struct state * const sp; +{ + if (tzload(gmt, sp) != 0) + (void) tzparse(gmt, sp, TRUE); +} + +#ifndef STD_INSPIRED +/* +** A non-static declaration of tzsetwall in a system header file +** may cause a warning about this upcoming static declaration... +*/ +static +#endif /* !defined STD_INSPIRED */ +#ifdef _THREAD_SAFE +void +tzsetwall_basic P((void)) +#else +void +tzsetwall P((void)) +#endif +{ + +#ifdef ALL_STATE + if (lclptr == NULL) { + lclptr = (struct state *) malloc(sizeof *lclptr); + if (lclptr == NULL) { + settzname(); /* all we can do */ + return; + } + } +#endif /* defined ALL_STATE */ + if (tzload((char *) NULL, lclptr) != 0) + gmtload(lclptr); + settzname(); +} + +#ifdef _THREAD_SAFE +void +tzsetwall P((void)) +{ + pthread_mutex_lock(&lcl_mutex); + tzsetwall_basic(); + pthread_mutex_unlock(&lcl_mutex); +} +#endif + +#ifdef _THREAD_SAFE +static void +tzset_basic P((void)) +#else +void +tzset P((void)) +#endif +{ + register const char * name; + + name = getenv("TZ"); + if (name == NULL) { + tzsetwall(); + return; + } + + if (strlen(name) < sizeof(lcl_TZname)) + (void) strcpy(lcl_TZname, name); + +#ifdef ALL_STATE + if (lclptr == NULL) { + lclptr = (struct state *) malloc(sizeof *lclptr); + if (lclptr == NULL) { + settzname(); /* all we can do */ + return; + } + } +#endif /* defined ALL_STATE */ + if (*name == '\0') { + /* + ** User wants it fast rather than right. + */ + lclptr->leapcnt = 0; /* so, we're off a little */ + lclptr->timecnt = 0; + lclptr->ttis[0].tt_gmtoff = 0; + lclptr->ttis[0].tt_abbrind = 0; + (void) strcpy(lclptr->chars, gmt); + } else if (tzload(name, lclptr) != 0) + if (name[0] == ':' || tzparse(name, lclptr, FALSE) != 0) + (void) gmtload(lclptr); + settzname(); +} + +#ifdef _THREAD_SAFE +void +tzset P((void)) +{ + pthread_mutex_lock(&lcl_mutex); + tzset_basic(); + pthread_mutex_unlock(&lcl_mutex); +} +#endif + +/* +** The easy way to behave "as if no library function calls" localtime +** is to not call it--so we drop its guts into "localsub", which can be +** freely called. (And no, the PANS doesn't require the above behavior-- +** but it *is* desirable.) +** +** The unused offset argument is for the benefit of mktime variants. +*/ + +/*ARGSUSED*/ +static void +localsub(timep, offset, tmp) +const time_t * const timep; +const long offset; +struct tm * const tmp; +{ + register struct state * sp; + register const struct ttinfo * ttisp; + register int i; + const time_t t = *timep; + + sp = lclptr; +#ifdef ALL_STATE + if (sp == NULL) { + gmtsub(timep, offset, tmp); + return; + } +#endif /* defined ALL_STATE */ + if (sp->timecnt == 0 || t < sp->ats[0]) { + i = 0; + while (sp->ttis[i].tt_isdst) + if (++i >= sp->typecnt) { + i = 0; + break; + } + } else { + for (i = 1; i < sp->timecnt; ++i) + if (t < sp->ats[i]) + break; + i = sp->types[i - 1]; + } + ttisp = &sp->ttis[i]; + /* + ** To get (wrong) behavior that's compatible with System V Release 2.0 + ** you'd replace the statement below with + ** t += ttisp->tt_gmtoff; + ** timesub(&t, 0L, sp, tmp); + */ + timesub(&t, ttisp->tt_gmtoff, sp, tmp); + tmp->tm_isdst = ttisp->tt_isdst; + tzname[tmp->tm_isdst] = &sp->chars[ttisp->tt_abbrind]; +#ifdef TM_ZONE + tmp->TM_ZONE = &sp->chars[ttisp->tt_abbrind]; +#endif /* defined TM_ZONE */ +} + +struct tm * +localtime_r(timep, p_tm) +const time_t * const timep; +struct tm *p_tm; +{ +#ifdef _THREAD_SAFE + pthread_mutex_lock(&lcl_mutex); +#endif + tzset(); + localsub(timep, 0L, p_tm); +#ifdef _THREAD_SAFE + pthread_mutex_unlock(&lcl_mutex); +#endif + return(p_tm); +} + +struct tm * +localtime(timep) +const time_t * const timep; +{ +#ifdef _THREAD_SAFE + static struct pthread_mutex _localtime_mutex = PTHREAD_MUTEX_STATIC_INITIALIZER; + static pthread_mutex_t localtime_mutex = &_localtime_mutex; + static pthread_key_t localtime_key = -1; + struct tm *p_tm; + + pthread_mutex_lock(&localtime_mutex); + if (localtime_key < 0) { + if (pthread_key_create(&localtime_key, free) < 0) { + pthread_mutex_unlock(&localtime_mutex); + return(NULL); + } + } + pthread_mutex_unlock(&localtime_mutex); + p_tm = pthread_getspecific(localtime_key); + if (p_tm == NULL) { + if ((p_tm = (struct tm *)malloc(sizeof(struct tm))) == NULL) + return(NULL); + pthread_setspecific(localtime_key, p_tm); + } + pthread_mutex_lock(&lcl_mutex); + tzset(); + localsub(timep, 0L, p_tm); + pthread_mutex_unlock(&lcl_mutex); + return p_tm; +#else + tzset(); + localsub(timep, 0L, &tm); + return &tm; +#endif +} + +/* +** gmtsub is to gmtime as localsub is to localtime. +*/ + +static void +gmtsub(timep, offset, tmp) +const time_t * const timep; +const long offset; +struct tm * const tmp; +{ +#ifdef _THREAD_SAFE + pthread_mutex_lock(&gmt_mutex); +#endif +#ifdef ALL_STATE + if( gmtptr == NULL ) + gmtptr = (struct state *) malloc(sizeof *gmtptr); + if (gmtptr != NULL) +#endif /* defined ALL_STATE */ + gmtload(gmtptr); +#ifdef _THREAD_SAFE + pthread_mutex_unlock(&gmt_mutex); +#endif + timesub(timep, offset, gmtptr, tmp); +#ifdef TM_ZONE + /* + ** Could get fancy here and deliver something such as + ** "GMT+xxxx" or "GMT-xxxx" if offset is non-zero, + ** but this is no time for a treasure hunt. + */ + if (offset != 0) + tmp->TM_ZONE = wildabbr; + else { +#ifdef ALL_STATE + if (gmtptr == NULL) + tmp->TM_ZONE = gmt; + else tmp->TM_ZONE = gmtptr->chars; +#endif /* defined ALL_STATE */ +#ifndef ALL_STATE + tmp->TM_ZONE = gmtptr->chars; +#endif /* State Farm */ + } +#endif /* defined TM_ZONE */ +} + +struct tm * +gmtime(timep) +const time_t * const timep; +{ +#ifdef _THREAD_SAFE + static struct pthread_mutex _gmtime_mutex = PTHREAD_MUTEX_STATIC_INITIALIZER; + static pthread_mutex_t gmtime_mutex = &_gmtime_mutex; + static pthread_key_t gmtime_key = -1; + struct tm *p_tm; + + pthread_mutex_lock(&gmtime_mutex); + if (gmtime_key < 0) { + if (pthread_key_create(&gmtime_key, free) < 0) { + pthread_mutex_unlock(&gmtime_mutex); + return(NULL); + } + } + pthread_mutex_unlock(&gmtime_mutex); + /* + * Changed to follow draft 4 pthreads standard, which + * is what BSD currently has. + */ + if ((p_tm = pthread_getspecific(gmtime_key)) == NULL) { + if ((p_tm = (struct tm *)malloc(sizeof(struct tm))) == NULL) { + return(NULL); + } + pthread_setspecific(gmtime_key, p_tm); + } + gmtsub(timep, 0L, p_tm); + return(p_tm); +#else + gmtsub(timep, 0L, &tm); + return &tm; +#endif +} + +struct tm * +gmtime_r(const time_t * timep, struct tm * tm) +{ + gmtsub(timep, 0L, tm); + return(tm); +} + +#ifdef STD_INSPIRED + +struct tm * +offtime(timep, offset) +const time_t * const timep; +const long offset; +{ + gmtsub(timep, offset, &tm); + return &tm; +} + +#endif /* defined STD_INSPIRED */ + +static void +timesub(timep, offset, sp, tmp) +const time_t * const timep; +const long offset; +register const struct state * const sp; +register struct tm * const tmp; +{ + register const struct lsinfo * lp; + register long days; + register long rem; + register int y; + register int yleap; + register const int * ip; + register long corr; + register int hit; + register int i; + + corr = 0; + hit = 0; +#ifdef ALL_STATE + i = (sp == NULL) ? 0 : sp->leapcnt; +#endif /* defined ALL_STATE */ +#ifndef ALL_STATE + i = sp->leapcnt; +#endif /* State Farm */ + while (--i >= 0) { + lp = &sp->lsis[i]; + if (*timep >= lp->ls_trans) { + if (*timep == lp->ls_trans) { + hit = ((i == 0 && lp->ls_corr > 0) || + lp->ls_corr > sp->lsis[i - 1].ls_corr); + if (hit) + while (i > 0 && + sp->lsis[i].ls_trans == + sp->lsis[i - 1].ls_trans + 1 && + sp->lsis[i].ls_corr == + sp->lsis[i - 1].ls_corr + 1) { + ++hit; + --i; + } + } + corr = lp->ls_corr; + break; + } + } + days = *timep / SECSPERDAY; + rem = *timep % SECSPERDAY; +#ifdef mc68k + if (*timep == 0x80000000) { + /* + ** A 3B1 muffs the division on the most negative number. + */ + days = -24855; + rem = -11648; + } +#endif /* defined mc68k */ + rem += (offset - corr); + while (rem < 0) { + rem += SECSPERDAY; + --days; + } + while (rem >= SECSPERDAY) { + rem -= SECSPERDAY; + ++days; + } + tmp->tm_hour = (int) (rem / SECSPERHOUR); + rem = rem % SECSPERHOUR; + tmp->tm_min = (int) (rem / SECSPERMIN); + /* + ** A positive leap second requires a special + ** representation. This uses "... ??:59:60" et seq. + */ + tmp->tm_sec = (int) (rem % SECSPERMIN) + hit; + tmp->tm_wday = (int) ((EPOCH_WDAY + days) % DAYSPERWEEK); + if (tmp->tm_wday < 0) + tmp->tm_wday += DAYSPERWEEK; + y = EPOCH_YEAR; +#define LEAPS_THRU_END_OF(y) ((y) / 4 - (y) / 100 + (y) / 400) + while (days < 0 || days >= (long) year_lengths[yleap = isleap(y)]) { + register int newy; + + newy = y + days / DAYSPERNYEAR; + if (days < 0) + --newy; + days -= (newy - y) * DAYSPERNYEAR + + LEAPS_THRU_END_OF(newy - 1) - + LEAPS_THRU_END_OF(y - 1); + y = newy; + } + tmp->tm_year = y - TM_YEAR_BASE; + tmp->tm_yday = (int) days; + ip = mon_lengths[yleap]; + for (tmp->tm_mon = 0; days >= (long) ip[tmp->tm_mon]; ++(tmp->tm_mon)) + days = days - (long) ip[tmp->tm_mon]; + tmp->tm_mday = (int) (days + 1); + tmp->tm_isdst = 0; +#ifdef TM_GMTOFF + tmp->TM_GMTOFF = offset; +#endif /* defined TM_GMTOFF */ +} + +char * +ctime(timep) +const time_t * const timep; +{ +/* +** Section 4.12.3.2 of X3.159-1989 requires that +** The ctime funciton converts the calendar time pointed to by timer +** to local time in the form of a string. It is equivalent to +** asctime(localtime(timer)) +*/ + return asctime(localtime(timep)); +} + +char * +ctime_r(timep, buf) +const time_t * const timep; +char *buf; +{ + struct tm tm; + return asctime_r(localtime_r(timep, &tm), buf); +} + +/* +** Adapted from code provided by Robert Elz, who writes: +** The "best" way to do mktime I think is based on an idea of Bob +** Kridle's (so its said...) from a long time ago. +** [kridle@xinet.com as of 1996-01-16.] +** It does a binary search of the time_t space. Since time_t's are +** just 32 bits, its a max of 32 iterations (even at 64 bits it +** would still be very reasonable). +*/ + +#ifndef WRONG +#define WRONG (-1) +#endif /* !defined WRONG */ + +/* +** Simplified normalize logic courtesy Paul Eggert (eggert@twinsun.com). +*/ + +static int +increment_overflow(number, delta) +int * number; +int delta; +{ + int number0; + + number0 = *number; + *number += delta; + return (*number < number0) != (delta < 0); +} + +static int +normalize_overflow(tensptr, unitsptr, base) +int * const tensptr; +int * const unitsptr; +const int base; +{ + register int tensdelta; + + tensdelta = (*unitsptr >= 0) ? + (*unitsptr / base) : + (-1 - (-1 - *unitsptr) / base); + *unitsptr -= tensdelta * base; + return increment_overflow(tensptr, tensdelta); +} + +static int +tmcomp(atmp, btmp) +register const struct tm * const atmp; +register const struct tm * const btmp; +{ + register int result; + + if ((result = (atmp->tm_year - btmp->tm_year)) == 0 && + (result = (atmp->tm_mon - btmp->tm_mon)) == 0 && + (result = (atmp->tm_mday - btmp->tm_mday)) == 0 && + (result = (atmp->tm_hour - btmp->tm_hour)) == 0 && + (result = (atmp->tm_min - btmp->tm_min)) == 0) + result = atmp->tm_sec - btmp->tm_sec; + return result; +} + +static time_t +time2(tmp, funcp, offset, okayp) +struct tm * const tmp; +void (* const funcp) P((const time_t*, long, struct tm*)); +const long offset; +int * const okayp; +{ + register const struct state * sp; + register int dir; + register int bits; + register int i, j ; + register int saved_seconds; + time_t newt; + time_t t; + struct tm yourtm, mytm; + + *okayp = FALSE; + yourtm = *tmp; + if (normalize_overflow(&yourtm.tm_hour, &yourtm.tm_min, MINSPERHOUR)) + return WRONG; + if (normalize_overflow(&yourtm.tm_mday, &yourtm.tm_hour, HOURSPERDAY)) + return WRONG; + if (normalize_overflow(&yourtm.tm_year, &yourtm.tm_mon, MONSPERYEAR)) + return WRONG; + /* + ** Turn yourtm.tm_year into an actual year number for now. + ** It is converted back to an offset from TM_YEAR_BASE later. + */ + if (increment_overflow(&yourtm.tm_year, TM_YEAR_BASE)) + return WRONG; + while (yourtm.tm_mday <= 0) { + if (increment_overflow(&yourtm.tm_year, -1)) + return WRONG; + i = yourtm.tm_year + (1 < yourtm.tm_mon); + yourtm.tm_mday += year_lengths[isleap(i)]; + } + while (yourtm.tm_mday > DAYSPERLYEAR) { + i = yourtm.tm_year + (1 < yourtm.tm_mon); + yourtm.tm_mday -= year_lengths[isleap(i)]; + if (increment_overflow(&yourtm.tm_year, 1)) + return WRONG; + } + for ( ; ; ) { + i = mon_lengths[isleap(yourtm.tm_year)][yourtm.tm_mon]; + if (yourtm.tm_mday <= i) + break; + yourtm.tm_mday -= i; + if (++yourtm.tm_mon >= MONSPERYEAR) { + yourtm.tm_mon = 0; + if (increment_overflow(&yourtm.tm_year, 1)) + return WRONG; + } + } + if (increment_overflow(&yourtm.tm_year, -TM_YEAR_BASE)) + return WRONG; + if (yourtm.tm_year + TM_YEAR_BASE < EPOCH_YEAR) { + /* + ** We can't set tm_sec to 0, because that might push the + ** time below the minimum representable time. + ** Set tm_sec to 59 instead. + ** This assumes that the minimum representable time is + ** not in the same minute that a leap second was deleted from, + ** which is a safer assumption than using 58 would be. + */ + if (increment_overflow(&yourtm.tm_sec, 1 - SECSPERMIN)) + return WRONG; + saved_seconds = yourtm.tm_sec; + yourtm.tm_sec = SECSPERMIN - 1; + } else { + saved_seconds = yourtm.tm_sec; + yourtm.tm_sec = 0; + } + /* + ** Divide the search space in half + ** (this works whether time_t is signed or unsigned). + */ + bits = TYPE_BIT(time_t) - 1; + /* + ** If time_t is signed, then 0 is just above the median, + ** assuming two's complement arithmetic. + ** If time_t is unsigned, then (1 << bits) is just above the median. + */ + t = TYPE_SIGNED(time_t) ? 0 : (((time_t) 1) << bits); + for ( ; ; ) { + (*funcp)(&t, offset, &mytm); + dir = tmcomp(&mytm, &yourtm); + if (dir != 0) { + if (bits-- < 0) + return WRONG; + if (bits < 0) + --t; /* may be needed if new t is minimal */ + else if (dir > 0) + t -= ((time_t) 1) << bits; + else t += ((time_t) 1) << bits; + continue; + } + if (yourtm.tm_isdst < 0 || mytm.tm_isdst == yourtm.tm_isdst) + break; + /* + ** Right time, wrong type. + ** Hunt for right time, right type. + ** It's okay to guess wrong since the guess + ** gets checked. + */ + /* + ** The (void *) casts are the benefit of SunOS 3.3 on Sun 2's. + */ + sp = (const struct state *) + (((void *) funcp == (void *) localsub) ? + lclptr : gmtptr); +#ifdef ALL_STATE + if (sp == NULL) + return WRONG; +#endif /* defined ALL_STATE */ + for (i = sp->typecnt - 1; i >= 0; --i) { + if (sp->ttis[i].tt_isdst != yourtm.tm_isdst) + continue; + for (j = sp->typecnt - 1; j >= 0; --j) { + if (sp->ttis[j].tt_isdst == yourtm.tm_isdst) + continue; + newt = t + sp->ttis[j].tt_gmtoff - + sp->ttis[i].tt_gmtoff; + (*funcp)(&newt, offset, &mytm); + if (tmcomp(&mytm, &yourtm) != 0) + continue; + if (mytm.tm_isdst != yourtm.tm_isdst) + continue; + /* + ** We have a match. + */ + t = newt; + goto label; + } + } + return WRONG; + } +label: + newt = t + saved_seconds; + if ((newt < t) != (saved_seconds < 0)) + return WRONG; + t = newt; + (*funcp)(&t, offset, tmp); + *okayp = TRUE; + return t; +} + +static time_t +time1(tmp, funcp, offset) +struct tm * const tmp; +void (* const funcp) P((const time_t *, long, struct tm *)); +const long offset; +{ + register time_t t; + register const struct state * sp; + register int samei, otheri; + int okay; + + if (tmp->tm_isdst > 1) + tmp->tm_isdst = 1; + t = time2(tmp, funcp, offset, &okay); +#ifdef PCTS + /* + ** PCTS code courtesy Grant Sullivan (grant@osf.org). + */ + if (okay) + return t; + if (tmp->tm_isdst < 0) + tmp->tm_isdst = 0; /* reset to std and try again */ +#endif /* defined PCTS */ +#ifndef PCTS + if (okay || tmp->tm_isdst < 0) + return t; +#endif /* !defined PCTS */ + /* + ** We're supposed to assume that somebody took a time of one type + ** and did some math on it that yielded a "struct tm" that's bad. + ** We try to divine the type they started from and adjust to the + ** type they need. + */ + /* + ** The (void *) casts are the benefit of SunOS 3.3 on Sun 2's. + */ + sp = (const struct state *) (((void *) funcp == (void *) localsub) ? + lclptr : gmtptr); +#ifdef ALL_STATE + if (sp == NULL) + return WRONG; +#endif /* defined ALL_STATE */ + for (samei = sp->typecnt - 1; samei >= 0; --samei) { + if (sp->ttis[samei].tt_isdst != tmp->tm_isdst) + continue; + for (otheri = sp->typecnt - 1; otheri >= 0; --otheri) { + if (sp->ttis[otheri].tt_isdst == tmp->tm_isdst) + continue; + tmp->tm_sec += sp->ttis[otheri].tt_gmtoff - + sp->ttis[samei].tt_gmtoff; + tmp->tm_isdst = !tmp->tm_isdst; + t = time2(tmp, funcp, offset, &okay); + if (okay) + return t; + tmp->tm_sec -= sp->ttis[otheri].tt_gmtoff - + sp->ttis[samei].tt_gmtoff; + tmp->tm_isdst = !tmp->tm_isdst; + } + } + return WRONG; +} + +time_t +mktime(tmp) +struct tm * const tmp; +{ + time_t mktime_return_value; +#ifdef _THREAD_SAFE + pthread_mutex_lock(&lcl_mutex); +#endif + tzset(); + mktime_return_value = time1(tmp, localsub, 0L); +#ifdef _THREAD_SAFE + pthread_mutex_unlock(&lcl_mutex); +#endif + return(mktime_return_value); +} + +#ifdef STD_INSPIRED + +time_t +timelocal(tmp) +struct tm * const tmp; +{ + tmp->tm_isdst = -1; /* in case it wasn't initialized */ + return mktime(tmp); +} + +time_t +timegm(tmp) +struct tm * const tmp; +{ + tmp->tm_isdst = 0; + return time1(tmp, gmtsub, 0L); +} + +time_t +timeoff(tmp, offset) +struct tm * const tmp; +const long offset; +{ + tmp->tm_isdst = 0; + return time1(tmp, gmtsub, offset); +} + +#endif /* defined STD_INSPIRED */ + +#ifdef CMUCS + +/* +** The following is supplied for compatibility with +** previous versions of the CMUCS runtime library. +*/ + +long +gtime(tmp) +struct tm * const tmp; +{ + const time_t t = mktime(tmp); + + if (t == WRONG) + return -1; + return t; +} + +#endif /* defined CMUCS */ + +/* +** XXX--is the below the right way to conditionalize?? +*/ + +#ifdef STD_INSPIRED + +/* +** IEEE Std 1003.1-1988 (POSIX) legislates that 536457599 +** shall correspond to "Wed Dec 31 23:59:59 GMT 1986", which +** is not the case if we are accounting for leap seconds. +** So, we provide the following conversion routines for use +** when exchanging timestamps with POSIX conforming systems. +*/ + +static long +leapcorr(timep) +time_t * timep; +{ + register struct state * sp; + register struct lsinfo * lp; + register int i; + + sp = lclptr; + i = sp->leapcnt; + while (--i >= 0) { + lp = &sp->lsis[i]; + if (*timep >= lp->ls_trans) + return lp->ls_corr; + } + return 0; +} + +time_t +time2posix(t) +time_t t; +{ + tzset(); + return t - leapcorr(&t); +} + +time_t +posix2time(t) +time_t t; +{ + time_t x; + time_t y; + + tzset(); + /* + ** For a positive leap second hit, the result + ** is not unique. For a negative leap second + ** hit, the corresponding time doesn't exist, + ** so we return an adjacent second. + */ + x = t + leapcorr(&t); + y = x - leapcorr(&x); + if (y < t) { + do { + x++; + y = x - leapcorr(&x); + } while (y < t); + if (t != y) + return x - 1; + } else if (y > t) { + do { + --x; + y = x - leapcorr(&x); + } while (y > t); + if (t != y) + return x + 1; + } + return x; +} + +#endif /* defined STD_INSPIRED */ diff --git a/stdtime/private.h b/stdtime/private.h new file mode 100644 index 0000000..90329d3 --- /dev/null +++ b/stdtime/private.h @@ -0,0 +1,220 @@ +/* $FreeBSD: src/lib/libc/stdtime/private.h,v 1.6.8.1 2000/08/23 00:19:15 jhb Exp $ */ + +#ifndef PRIVATE_H + +#define PRIVATE_H +/* +** This file is in the public domain, so clarified as of +** June 5, 1996 by Arthur David Olson (arthur_david_olson@nih.gov). +*/ + +/* Stuff moved from Makefile.inc to reduce clutter */ +#ifndef TM_GMTOFF +#define TM_GMTOFF tm_gmtoff +#define TM_ZONE tm_zone +#define STD_INSPIRED 1 +#define PCTS 1 +#define HAVE_LONG_DOUBLE 1 +#define HAVE_STRERROR 1 +#define HAVE_UNISTD_H 1 +#define LOCALE_HOME _PATH_LOCALE +#define TZDIR "/usr/share/zoneinfo" +#endif /* ndef TM_GMTOFF */ + +/* +** This header is for use ONLY with the time conversion code. +** There is no guarantee that it will remain unchanged, +** or that it will remain at all. +** Do NOT copy it to any system include directory. +** Thank you! +*/ + +/* +** ID +*/ + +#ifndef lint +#ifndef NOID +/* +static char privatehid[] = "@(#)private.h 7.43"; +*/ +#endif /* !defined NOID */ +#endif /* !defined lint */ + +/* +** Defaults for preprocessor symbols. +** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'. +*/ + +#ifndef HAVE_ADJTIME +#define HAVE_ADJTIME 1 +#endif /* !defined HAVE_ADJTIME */ + +#ifndef HAVE_GETTEXT +#define HAVE_GETTEXT 0 +#endif /* !defined HAVE_GETTEXT */ + +#ifndef HAVE_SETTIMEOFDAY +#define HAVE_SETTIMEOFDAY 3 +#endif /* !defined HAVE_SETTIMEOFDAY */ + +#ifndef HAVE_STRERROR +#define HAVE_STRERROR 0 +#endif /* !defined HAVE_STRERROR */ + +#ifndef HAVE_UNISTD_H +#define HAVE_UNISTD_H 1 +#endif /* !defined HAVE_UNISTD_H */ + +#ifndef HAVE_UTMPX_H +#define HAVE_UTMPX_H 0 +#endif /* !defined HAVE_UTMPX_H */ + +#ifndef LOCALE_HOME +#define LOCALE_HOME "/usr/lib/locale" +#endif /* !defined LOCALE_HOME */ + +/* +** Nested includes +*/ + +#include "sys/types.h" /* for time_t */ +#include "stdio.h" +#include "errno.h" +#include "string.h" +#include "limits.h" /* for CHAR_BIT */ +#include "time.h" +#include "stdlib.h" + +#if HAVE_GETTEXT - 0 +#include "libintl.h" +#endif /* HAVE_GETTEXT - 0 */ + +#if HAVE_UNISTD_H - 0 +#include "unistd.h" /* for F_OK and R_OK */ +#endif /* HAVE_UNISTD_H - 0 */ + +#if !(HAVE_UNISTD_H - 0) +#ifndef F_OK +#define F_OK 0 +#endif /* !defined F_OK */ +#ifndef R_OK +#define R_OK 4 +#endif /* !defined R_OK */ +#endif /* !(HAVE_UNISTD_H - 0) */ + +/* Unlike 's isdigit, this also works if c < 0 | c > UCHAR_MAX. */ +#define is_digit(c) ((unsigned)(c) - '0' <= 9) + +/* +** Workarounds for compilers/systems. +*/ + +#ifndef P +#ifdef __STDC__ +#define P(x) x +#endif /* defined __STDC__ */ +#ifndef __STDC__ +#define P(x) () +#endif /* !defined __STDC__ */ +#endif /* !defined P */ + +/* +** SunOS 4.1.1 headers lack FILENAME_MAX. +*/ + +#ifndef FILENAME_MAX + +#ifndef MAXPATHLEN +#ifdef unix +#include "sys/param.h" +#endif /* defined unix */ +#endif /* !defined MAXPATHLEN */ + +#ifdef MAXPATHLEN +#define FILENAME_MAX MAXPATHLEN +#endif /* defined MAXPATHLEN */ +#ifndef MAXPATHLEN +#define FILENAME_MAX 1024 /* Pure guesswork */ +#endif /* !defined MAXPATHLEN */ + +#endif /* !defined FILENAME_MAX */ + +/* +** Finally, some convenience items. +*/ + +#ifndef TRUE +#define TRUE 1 +#endif /* !defined TRUE */ + +#ifndef FALSE +#define FALSE 0 +#endif /* !defined FALSE */ + +#ifndef TYPE_BIT +#define TYPE_BIT(type) (sizeof (type) * CHAR_BIT) +#endif /* !defined TYPE_BIT */ + +#ifndef TYPE_SIGNED +#define TYPE_SIGNED(type) (((type) -1) < 0) +#endif /* !defined TYPE_SIGNED */ + +#ifndef INT_STRLEN_MAXIMUM +/* +** 302 / 1000 is log10(2.0) rounded up. +** Subtract one for the sign bit if the type is signed; +** add one for integer division truncation; +** add one more for a minus sign if the type is signed. +*/ +#define INT_STRLEN_MAXIMUM(type) \ + ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type)) +#endif /* !defined INT_STRLEN_MAXIMUM */ + +/* +** INITIALIZE(x) +*/ + +#ifndef GNUC_or_lint +#ifdef lint +#define GNUC_or_lint +#endif /* defined lint */ +#ifndef lint +#ifdef __GNUC__ +#define GNUC_or_lint +#endif /* defined __GNUC__ */ +#endif /* !defined lint */ +#endif /* !defined GNUC_or_lint */ + +#ifndef INITIALIZE +#ifdef GNUC_or_lint +#define INITIALIZE(x) ((x) = 0) +#endif /* defined GNUC_or_lint */ +#ifndef GNUC_or_lint +#define INITIALIZE(x) +#endif /* !defined GNUC_or_lint */ +#endif /* !defined INITIALIZE */ + +/* +** For the benefit of GNU folk... +** `_(MSGID)' uses the current locale's message library string for MSGID. +** The default is to use gettext if available, and use MSGID otherwise. +*/ + +#ifndef _ +#if HAVE_GETTEXT - 0 +#define _(msgid) gettext(msgid) +#else /* !(HAVE_GETTEXT - 0) */ +#define _(msgid) msgid +#endif /* !(HAVE_GETTEXT - 0) */ +#endif /* !defined _ */ + +#ifndef TZ_DOMAIN +#define TZ_DOMAIN "tz" +#endif /* !defined TZ_DOMAIN */ + +/* +** UNIX was a registered trademark of UNIX System Laboratories in 1993. +*/ + +#endif /* !defined PRIVATE_H */ diff --git a/stdtime/strftime.3 b/stdtime/strftime.3 new file mode 100644 index 0000000..1a6f074 --- /dev/null +++ b/stdtime/strftime.3 @@ -0,0 +1,265 @@ +.\" Copyright (c) 1989, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)strftime.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/stdtime/strftime.3,v 1.18.2.7 2001/12/14 18:33:59 ru Exp $ +.\" +.Dd October 4, 1997 +.Dt STRFTIME 3 +.Os +.Sh NAME +.Nm strftime +.Nd format date and time +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In time.h +.Ft size_t +.Fn strftime "char *buf" "size_t maxsize" "const char *format" "const struct tm *timeptr" +.Sh DESCRIPTION +The +.Fn strftime +function formats the information from +.Fa timeptr +into the buffer +.Fa buf +according to the string pointed to by +.Fa format . +.Pp +The +.Fa format +string consists of zero or more conversion specifications and +ordinary characters. +All ordinary characters are copied directly into the buffer. +A conversion specification consists of a percent sign +.Dq Ql % +and one other character. +.Pp +No more than +.Fa maxsize +characters will be placed into the array. +If the total number of resulting characters, including the terminating +NUL character, is not more than +.Fa maxsize , +.Fn strftime +returns the number of characters in the array, not counting the +terminating NUL. +Otherwise, zero is returned and the buffer contents is indeterminate. +.Pp +The conversion specifications are copied to the buffer after expansion +as follows:- +.Bl -tag -width "xxxx" +.It Cm \&%A +is replaced by national representation of the full weekday name. +.It Cm %a +is replaced by national representation of +the abbreviated weekday name, where the abbreviation +is the first three characters. +.It Cm \&%B +is replaced by national representation of the full month name. +.It Cm %b +is replaced by national representation of +the abbreviated month name, where the abbreviation is +the first three characters. +.It Cm \&%C +is replaced by (year / 100) as decimal number; single +digits are preceded by a zero. +.It Cm %c +is replaced by national representation of time and date. +The format is similar to that produced by +.Xr ctime 3 +and is +equivalent to "%a %Ef %T %Y". +It also implies the +"3+1+6+1+8+1+4" format of output. +.It Cm \&%D +is equivalent to +.Dq Li %m/%d/%y . +.It Cm %d +is replaced by the day of the month as a decimal number (01-31). +.It Cm \&%E* Cm \&%O* +POSIX locale extensions. +The sequences +%Ec %EC %Ex %EX %Ey %EY +%Od %Oe %OH %OI %Om %OM +%OS %Ou %OU %OV %Ow %OW %Oy +are supposed to provide alternate +representations. +.Pp +Additionly %Ef implemented to represent short month name / day +order of the date, %EF to represent long month name / day +order +and %OB to represent alternative months names +(used standalone, without day mentioned). +.It Cm %e +is replaced by the day of month as a decimal number (1-31); single +digits are preceded by a blank. +.It Cm \&%G +is replaced by a year as a decimal number with century. +This year is the one that contains the greater part of +the week (Monday as the first day of the week). +.It Cm %g +is replaced by the same year as in +.Dq Li %G , +but as a decimal number without century (00-99). +.It Cm \&%H +is replaced by the hour (24-hour clock) as a decimal number (00-23). +.It Cm %h +the same as %b. +.It Cm \&%I +is replaced by the hour (12-hour clock) as a decimal number (01-12). +.It Cm %j +is replaced by the day of the year as a decimal number (001-366). +.It Cm %k +is replaced by the hour (24-hour clock) as a decimal number (0-23); +single digits are preceded by a blank. +.It Cm %l +is replaced by the hour (12-hour clock) as a decimal number (1-12); +single digits are preceded by a blank. +.It Cm \&%M +is replaced by the minute as a decimal number (00-59). +.It Cm %m +is replaced by the month as a decimal number (01-12). +.It Cm %n +is replaced by a newline. +.It Cm \&%O* +the same as %E*. +.It Cm %p +is replaced by national representation of either +"ante meridiem" +or +"post meridiem" +as appropriate. +.It Cm \&%R +is equivalent to +.Dq Li %H:%M . +.It Cm %r +is equivalent to +.Dq Li %I:%M:%S %p . +.It Cm \&%S +is replaced by the second as a decimal number (00-60). +.It Cm %s +is replaced by the number of seconds since the Epoch, UTC (see +.Xr mktime 3 ) . +.It Cm \&%T +is equivalent to +.Dq Li %H:%M:%S . +.It Cm %t +is replaced by a tab. +.It Cm \&%U +is replaced by the week number of the year (Sunday as the first day of +the week) as a decimal number (00-53). +.It Cm %u +is replaced by the weekday (Monday as the first day of the week) +as a decimal number (1-7). +.It Cm \&%V +is replaced by the week number of the year (Monday as the first day of +the week) as a decimal number (01-53). If the week containing January +1 has four or more days in the new year, then it is week 1; otherwise +it is the last week of the previous year, and the next week is week 1. +.It Cm %v +is equivalent to +.Dq Li %e-%b-%Y . +.It Cm \&%W +is replaced by the week number of the year (Monday as the first day of +the week) as a decimal number (00-53). +.It Cm %w +is replaced by the weekday (Sunday as the first day of the week) +as a decimal number (0-6). +.It Cm \&%X +is replaced by national representation of the time. +.It Cm %x +is replaced by national representation of the date. +.It Cm \&%Y +is replaced by the year with century as a decimal number. +.It Cm %y +is replaced by the year without century as a decimal number (00-99). +.It Cm \&%Z +is replaced by the time zone name. +.It Cm \&%z +is replaced by the time zone offset from UTC; a leading plus sign stands for +east of UTC, a minus sign for west of UTC, hours and minutes follow +with two digits each and no delimiter between them (common form for +RFC 822 date headers). +.It Cm %+ +is replaced by national representation of the date and time +(the format is similar to that produced by +.Xr date 1 ) . +.It Cm %% +is replaced by +.Ql % . +.El +.Sh SEE ALSO +.Xr date 1 , +.Xr printf 1 , +.Xr ctime 3 , +.Xr printf 3 , +.Xr strptime 3 +.Sh STANDARDS +The +.Fn strftime +function +conforms to +.St -isoC +with a lot of extensions including +.Ql %C , +.Ql \&%D , +.Ql %E* , +.Ql %e , +.Ql %G , +.Ql %g , +.Ql %h , +.Ql %k , +.Ql %l , +.Ql %n , +.Ql %O* , +.Ql \&%R , +.Ql %r , +.Ql %s , +.Ql \&%T , +.Ql %t , +.Ql %u , +.Ql \&%V , +.Ql %z , +.Ql %+ . +.Pp +The peculiar week number and year in the replacements of +.Ql %G , +.Ql %g +and +.Ql \&%V +are defined in ISO 8601: 1988. +.Sh BUGS +There is no conversion specification for the phase of the moon. diff --git a/stdtime/strftime.c b/stdtime/strftime.c new file mode 100644 index 0000000..21625c7 --- /dev/null +++ b/stdtime/strftime.c @@ -0,0 +1,459 @@ +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#ifdef LIBC_RCS +static const char rcsid[] = + "$FreeBSD: src/lib/libc/stdtime/strftime.c,v 1.25.2.3 2001/02/18 04:06:49 kris Exp $"; +#endif + +#ifndef lint +#ifndef NOID +static const char elsieid[] = "@(#)strftime.c 7.38"; +/* +** Based on the UCB version with the ID appearing below. +** This is ANSIish only when "multibyte character == plain character". +*/ +#endif /* !defined NOID */ +#endif /* !defined lint */ + +#include "private.h" + +#ifndef LIBC_SCCS +#ifndef lint +static const char sccsid[] = "@(#)strftime.c 5.4 (Berkeley) 3/14/89"; +#endif /* !defined lint */ +#endif /* !defined LIBC_SCCS */ + +#include "tzfile.h" +#include +#include +#include "timelocal.h" + +static char * _add P((const char *, char *, const char *)); +static char * _conv P((int, const char *, char *, const char *)); +static char * _fmt P((const char *, const struct tm *, char *, const char *)); + +size_t strftime P((char *, size_t, const char *, const struct tm *)); + +extern char * tzname[]; + +size_t +strftime(s, maxsize, format, t) + char *const s; + const size_t maxsize; + const char *const format; + const struct tm *const t; +{ + char *p; + + tzset(); + p = _fmt(((format == NULL) ? "%c" : format), t, s, s + maxsize); + if (p == s + maxsize) + return 0; + *p = '\0'; + return p - s; +} + +static char * +_fmt(format, t, pt, ptlim) + const char *format; + const struct tm *const t; + char *pt; + const char *const ptlim; +{ + int Ealternative, Oalternative; + + for ( ; *format; ++format) { + if (*format == '%') { + Ealternative = 0; + Oalternative = 0; +label: + switch (*++format) { + case '\0': + --format; + break; + case 'A': + pt = _add((t->tm_wday < 0 || t->tm_wday > 6) ? + "?" : Locale->weekday[t->tm_wday], + pt, ptlim); + continue; + case 'a': + pt = _add((t->tm_wday < 0 || t->tm_wday > 6) ? + "?" : Locale->wday[t->tm_wday], + pt, ptlim); + continue; + case 'B': + pt = _add((t->tm_mon < 0 || t->tm_mon > 11) ? + "?" : (Oalternative ? Locale->alt_month : + Locale->month)[t->tm_mon], + pt, ptlim); + continue; + case 'b': + case 'h': + pt = _add((t->tm_mon < 0 || t->tm_mon > 11) ? + "?" : Locale->mon[t->tm_mon], + pt, ptlim); + continue; + case 'C': + /* + ** %C used to do a... + ** _fmt("%a %b %e %X %Y", t); + ** ...whereas now POSIX 1003.2 calls for + ** something completely different. + ** (ado, 5/24/93) + */ + pt = _conv((t->tm_year + TM_YEAR_BASE) / 100, + "%02d", pt, ptlim); + continue; + case 'c': + /* NOTE: c_fmt is intentionally ignored */ + pt = _fmt("%a %Ef %T %Y", t, pt, ptlim); + continue; + case 'D': + pt = _fmt("%m/%d/%y", t, pt, ptlim); + continue; + case 'd': + pt = _conv(t->tm_mday, "%02d", pt, ptlim); + continue; + case 'E': + if (Ealternative || Oalternative) + break; + Ealternative++; + goto label; + case 'O': + /* + ** POSIX locale extensions, a la + ** Arnold Robbins' strftime version 3.0. + ** The sequences + ** %Ec %EC %Ex %EX %Ey %EY + ** %Od %oe %OH %OI %Om %OM + ** %OS %Ou %OU %OV %Ow %OW %Oy + ** are supposed to provide alternate + ** representations. + ** (ado, 5/24/93) + ** + ** FreeBSD extensions + ** %OB %Ef %EF + */ + if (Ealternative || Oalternative) + break; + Oalternative++; + goto label; + case 'e': + pt = _conv(t->tm_mday, "%2d", pt, ptlim); + continue; + case 'f': + if (!Ealternative) + break; + pt = _fmt(Locale->Ef_fmt, t, pt, ptlim); + continue; + case 'F': + if (!Ealternative) + break; + pt = _fmt(Locale->EF_fmt, t, pt, ptlim); + continue; + case 'H': + pt = _conv(t->tm_hour, "%02d", pt, ptlim); + continue; + case 'I': + pt = _conv((t->tm_hour % 12) ? + (t->tm_hour % 12) : 12, + "%02d", pt, ptlim); + continue; + case 'j': + pt = _conv(t->tm_yday + 1, "%03d", pt, ptlim); + continue; + case 'k': + /* + ** This used to be... + ** _conv(t->tm_hour % 12 ? + ** t->tm_hour % 12 : 12, 2, ' '); + ** ...and has been changed to the below to + ** match SunOS 4.1.1 and Arnold Robbins' + ** strftime version 3.0. That is, "%k" and + ** "%l" have been swapped. + ** (ado, 5/24/93) + */ + pt = _conv(t->tm_hour, "%2d", pt, ptlim); + continue; +#ifdef KITCHEN_SINK + case 'K': + /* + ** After all this time, still unclaimed! + */ + pt = _add("kitchen sink", pt, ptlim); + continue; +#endif /* defined KITCHEN_SINK */ + case 'l': + /* + ** This used to be... + ** _conv(t->tm_hour, 2, ' '); + ** ...and has been changed to the below to + ** match SunOS 4.1.1 and Arnold Robbin's + ** strftime version 3.0. That is, "%k" and + ** "%l" have been swapped. + ** (ado, 5/24/93) + */ + pt = _conv((t->tm_hour % 12) ? + (t->tm_hour % 12) : 12, + "%2d", pt, ptlim); + continue; + case 'M': + pt = _conv(t->tm_min, "%02d", pt, ptlim); + continue; + case 'm': + pt = _conv(t->tm_mon + 1, "%02d", pt, ptlim); + continue; + case 'n': + pt = _add("\n", pt, ptlim); + continue; + case 'p': + pt = _add((t->tm_hour >= 12) ? + Locale->pm : + Locale->am, + pt, ptlim); + continue; + case 'R': + pt = _fmt("%H:%M", t, pt, ptlim); + continue; + case 'r': + pt = _fmt("%I:%M:%S %p", t, pt, ptlim); + continue; + case 'S': + pt = _conv(t->tm_sec, "%02d", pt, ptlim); + continue; + case 's': + { + struct tm tm; + char buf[INT_STRLEN_MAXIMUM( + time_t) + 1]; + time_t mkt; + + tm = *t; + mkt = mktime(&tm); + if (TYPE_SIGNED(time_t)) + (void) sprintf(buf, "%ld", + (long) mkt); + else (void) sprintf(buf, "%lu", + (unsigned long) mkt); + pt = _add(buf, pt, ptlim); + } + continue; + case 'T': + pt = _fmt("%H:%M:%S", t, pt, ptlim); + continue; + case 't': + pt = _add("\t", pt, ptlim); + continue; + case 'U': + pt = _conv((t->tm_yday + 7 - t->tm_wday) / 7, + "%02d", pt, ptlim); + continue; + case 'u': + /* + ** From Arnold Robbins' strftime version 3.0: + ** "ISO 8601: Weekday as a decimal number + ** [1 (Monday) - 7]" + ** (ado, 5/24/93) + */ + pt = _conv((t->tm_wday == 0) ? 7 : t->tm_wday, + "%d", pt, ptlim); + continue; + case 'V': /* ISO 8601 week number */ + case 'G': /* ISO 8601 year (four digits) */ + case 'g': /* ISO 8601 year (two digits) */ +/* +** From Arnold Robbins' strftime version 3.0: "the week number of the +** year (the first Monday as the first day of week 1) as a decimal number +** (01-53)." +** (ado, 1993-05-24) +** +** From "http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html" by Markus Kuhn: +** "Week 01 of a year is per definition the first week which has the +** Thursday in this year, which is equivalent to the week which contains +** the fourth day of January. In other words, the first week of a new year +** is the week which has the majority of its days in the new year. Week 01 +** might also contain days from the previous year and the week before week +** 01 of a year is the last week (52 or 53) of the previous year even if +** it contains days from the new year. A week starts with Monday (day 1) +** and ends with Sunday (day 7). For example, the first week of the year +** 1997 lasts from 1996-12-30 to 1997-01-05..." +** (ado, 1996-01-02) +*/ + { + int year; + int yday; + int wday; + int w; + + year = t->tm_year + TM_YEAR_BASE; + yday = t->tm_yday; + wday = t->tm_wday; + for ( ; ; ) { + int len; + int bot; + int top; + + len = isleap(year) ? + DAYSPERLYEAR : + DAYSPERNYEAR; + /* + ** What yday (-3 ... 3) does + ** the ISO year begin on? + */ + bot = ((yday + 11 - wday) % + DAYSPERWEEK) - 3; + /* + ** What yday does the NEXT + ** ISO year begin on? + */ + top = bot - + (len % DAYSPERWEEK); + if (top < -3) + top += DAYSPERWEEK; + top += len; + if (yday >= top) { + ++year; + w = 1; + break; + } + if (yday >= bot) { + w = 1 + ((yday - bot) / + DAYSPERWEEK); + break; + } + --year; + yday += isleap(year) ? + DAYSPERLYEAR : + DAYSPERNYEAR; + } +#ifdef XPG4_1994_04_09 + if ((w == 52 + && t->tm_mon == TM_JANUARY) + || (w == 1 + && t->tm_mon == TM_DECEMBER)) + w = 53; +#endif /* defined XPG4_1994_04_09 */ + if (*format == 'V') + pt = _conv(w, "%02d", + pt, ptlim); + else if (*format == 'g') { + pt = _conv(year % 100, "%02d", + pt, ptlim); + } else pt = _conv(year, "%04d", + pt, ptlim); + } + continue; + case 'v': + /* + ** From Arnold Robbins' strftime version 3.0: + ** "date as dd-bbb-YYYY" + ** (ado, 5/24/93) + */ + pt = _fmt("%e-%b-%Y", t, pt, ptlim); + continue; + case 'W': + pt = _conv((t->tm_yday + 7 - + (t->tm_wday ? + (t->tm_wday - 1) : 6)) / 7, + "%02d", pt, ptlim); + continue; + case 'w': + pt = _conv(t->tm_wday, "%d", pt, ptlim); + continue; + case 'X': + pt = _fmt(Locale->X_fmt, t, pt, ptlim); + continue; + case 'x': + pt = _fmt(Locale->x_fmt, t, pt, ptlim); + continue; + case 'y': + pt = _conv((t->tm_year + TM_YEAR_BASE) % 100, + "%02d", pt, ptlim); + continue; + case 'Y': + pt = _conv(t->tm_year + TM_YEAR_BASE, "%04d", + pt, ptlim); + continue; + case 'Z': + if (t->tm_zone != NULL) + pt = _add(t->tm_zone, pt, ptlim); + else + if (t->tm_isdst == 0 || t->tm_isdst == 1) { + pt = _add(tzname[t->tm_isdst], + pt, ptlim); + } else pt = _add("?", pt, ptlim); + continue; + case 'z': + { + long absoff; + if (t->tm_gmtoff >= 0) { + absoff = t->tm_gmtoff; + pt = _add("+", pt, ptlim); + } else { + absoff = -t->tm_gmtoff; + pt = _add("-", pt, ptlim); + } + pt = _conv(absoff / 3600, "%02d", + pt, ptlim); + pt = _conv((absoff % 3600) / 60, "%02d", + pt, ptlim); + }; + continue; + case '+': + pt = _fmt(Locale->date_fmt, t, pt, ptlim); + continue; + case '%': + /* + * X311J/88-090 (4.12.3.5): if conversion char is + * undefined, behavior is undefined. Print out the + * character itself as printf(3) also does. + */ + default: + break; + } + } + if (pt == ptlim) + break; + *pt++ = *format; + } + return pt; +} + +static char * +_conv(n, format, pt, ptlim) + const int n; + const char *const format; + char *const pt; + const char *const ptlim; +{ + char buf[INT_STRLEN_MAXIMUM(int) + 1]; + + (void) sprintf(buf, format, n); + return _add(buf, pt, ptlim); +} + +static char * +_add(str, pt, ptlim) + const char *str; + char *pt; + const char *const ptlim; +{ + while (pt < ptlim && (*pt = *str++) != '\0') + ++pt; + return pt; +} diff --git a/stdtime/strptime.3 b/stdtime/strptime.3 new file mode 100644 index 0000000..eedf7d1 --- /dev/null +++ b/stdtime/strptime.3 @@ -0,0 +1,139 @@ +.\" +.\" Copyright (c) 1997 Joerg Wunsch +.\" +.\" 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. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``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 DEVELOPERS 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. +.\" +.\" $FreeBSD: src/lib/libc/stdtime/strptime.3,v 1.9.2.7 2001/12/14 18:33:59 ru Exp $ +.\" " +.Dd May 8, 1997 +.Dt STRPTIME 3 +.Os +.Sh NAME +.Nm strptime +.Nd parse date and time string +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In time.h +.Ft char * +.Fn strptime "const char *buf" "const char *format" "struct tm *timeptr" +.Sh DESCRIPTION +The +.Fn strptime +function parses the string in the buffer +.Fa buf +according to the string pointed to by +.Fa format , +and fills in the elements of the structure pointed to by +.Fa timeptr . +The resulting values will be relative to the local time zone. +Thus, it can be considered the reverse operation of +.Xr strftime 3 . +.Pp +The +.Fa format +string consists of zero or more conversion specifications and +ordinary characters. +All ordinary characters are matched exactly with the buffer, where +white space in the format string will match any amount of white space +in the buffer. +All conversion specifications are identical to those described in +.Xr strftime 3 . +.Pp +Two-digit year values, including formats +.Fa %y +and +.Fa \&%D , +are now interpreted as beginning at 1969 per POSIX requirements. +Years 69-00 are interpreted in the 20th century (1969-2000), years +01-68 in the 21st century (2001-2068). +.Sh RETURN VALUES +Upon successful completion, +.Fn strptime +returns the pointer to the first character in +.Fa buf +that has not been required to satisfy the specified conversions in +.Fa format . +It returns +.Dv NULL +if one of the conversions failed. +.Sh SEE ALSO +.Xr date 1 , +.Xr scanf 3 , +.Xr strftime 3 +.Sh AUTHORS +The +.Fn strptime +function has been contributed by Powerdog Industries. +.Pp +This man page was written by +.An J\(:org Wunsch . +.Sh HISTORY +The +.Fn strptime +function appeared in +.Fx 3.0 . +.Sh BUGS +Both the +.Fa %e +and +.Fa %l +format specifiers may incorrectly scan one too many digits +if the intended values comprise only a single digit +and that digit is followed immediately by another digit. +Both specifiers accept zero-padded values, +even though they are both defined as taking unpadded values. +.Pp +The +.Fa %p +format specifier has no effect unless it is parsed +.Em after +hour-related specifiers. +Specifying +.Fa %l +without +.Fa %p +will produce undefined results. +Note that 12AM +(ante meridiem) +is taken as midnight +and 12PM +(post meridiem) +is taken as noon. +.Pp +The +.Fa %U +and +.Fa %W +format specifiers accept any value within the range 00 to 53 +without validating against other values supplied (like month +or day of the year, for example). +.Pp +The +.Fa %Z +format specifier only accepts time zone abbreviations of the local time zone, +or the value "GMT". +This limitation is because of ambiguity due to of the over loading of time +zone abbreviations. One such example is +.Fa EST +which is both Eastern Standard Time and Eastern Australia Summer Time. diff --git a/stdtime/strptime.c b/stdtime/strptime.c new file mode 100644 index 0000000..7b6c7f7 --- /dev/null +++ b/stdtime/strptime.c @@ -0,0 +1,560 @@ +/* + * Powerdog Industries kindly requests feedback from anyone modifying + * this function: + * + * Date: Thu, 05 Jun 1997 23:17:17 -0400 + * From: Kevin Ruddy + * To: James FitzGibbon + * Subject: Re: Use of your strptime(3) code (fwd) + * + * The reason for the "no mod" clause was so that modifications would + * come back and we could integrate them and reissue so that a wider + * audience could use it (thereby spreading the wealth). This has + * made it possible to get strptime to work on many operating systems. + * I'm not sure why that's "plain unacceptable" to the FreeBSD team. + * + * Anyway, you can change it to "with or without modification" as + * you see fit. Enjoy. + * + * Kevin Ruddy + * Powerdog Industries, Inc. + */ +/* + * Copyright (c) 1994 Powerdog Industries. 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. All advertising materials mentioning features or use of this + * software must display the following acknowledgement: + * This product includes software developed by Powerdog Industries. + * 4. The name of Powerdog Industries may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY POWERDOG INDUSTRIES ``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 POWERDOG INDUSTRIES 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. + */ + +#ifdef LIBC_RCS +static const char rcsid[] = + "$FreeBSD: src/lib/libc/stdtime/strptime.c,v 1.17.2.2 2001/07/31 00:06:24 dd Exp $"; +#endif + +#ifndef lint +#ifndef NOID +static char copyright[] = +"@(#) Copyright (c) 1994 Powerdog Industries. All rights reserved."; +static char sccsid[] = "@(#)strptime.c 0.1 (Powerdog) 94/03/27"; +#endif /* !defined NOID */ +#endif /* not lint */ + +#include +#include +#include +#include +#include +#ifdef _THREAD_SAFE +#include +#include "pthread_private.h" +#endif +#include "timelocal.h" + +static char * _strptime(const char *, const char *, struct tm *); + +#ifdef _THREAD_SAFE +static struct pthread_mutex _gotgmt_mutexd = PTHREAD_MUTEX_STATIC_INITIALIZER; +static pthread_mutex_t gotgmt_mutex = &_gotgmt_mutexd; +#endif +static int got_GMT; + +#define asizeof(a) (sizeof (a) / sizeof ((a)[0])) + +static char * +_strptime(const char *buf, const char *fmt, struct tm *tm) +{ + char c; + const char *ptr; + int i, + len; + int Ealternative, Oalternative; + + ptr = fmt; + while (*ptr != 0) { + if (*buf == 0) + break; + + c = *ptr++; + + if (c != '%') { + if (isspace((unsigned char)c)) + while (*buf != 0 && isspace((unsigned char)*buf)) + buf++; + else if (c != *buf++) + return 0; + continue; + } + + Ealternative = 0; + Oalternative = 0; +label: + c = *ptr++; + switch (c) { + case 0: + case '%': + if (*buf++ != '%') + return 0; + break; + + case '+': + buf = _strptime(buf, Locale->date_fmt, tm); + if (buf == 0) + return 0; + break; + + case 'C': + if (!isdigit((unsigned char)*buf)) + return 0; + + /* XXX This will break for 3-digit centuries. */ + len = 2; + for (i = 0; len && *buf != 0 && isdigit((unsigned char)*buf); buf++) { + i *= 10; + i += *buf - '0'; + len--; + } + if (i < 19) + return 0; + + tm->tm_year = i * 100 - 1900; + break; + + case 'c': + /* NOTE: c_fmt is intentionally ignored */ + buf = _strptime(buf, "%a %Ef %T %Y", tm); + if (buf == 0) + return 0; + break; + + case 'D': + buf = _strptime(buf, "%m/%d/%y", tm); + if (buf == 0) + return 0; + break; + + case 'E': + if (Ealternative || Oalternative) + break; + Ealternative++; + goto label; + + case 'O': + if (Ealternative || Oalternative) + break; + Oalternative++; + goto label; + + case 'F': + case 'f': + if (!Ealternative) + break; + buf = _strptime(buf, (c == 'f') ? Locale->Ef_fmt : Locale->EF_fmt, tm); + if (buf == 0) + return 0; + break; + + case 'R': + buf = _strptime(buf, "%H:%M", tm); + if (buf == 0) + return 0; + break; + + case 'r': + buf = _strptime(buf, "%I:%M:%S %p", tm); + if (buf == 0) + return 0; + break; + + case 'T': + buf = _strptime(buf, "%H:%M:%S", tm); + if (buf == 0) + return 0; + break; + + case 'X': + buf = _strptime(buf, Locale->X_fmt, tm); + if (buf == 0) + return 0; + break; + + case 'x': + buf = _strptime(buf, Locale->x_fmt, tm); + if (buf == 0) + return 0; + break; + + case 'j': + if (!isdigit((unsigned char)*buf)) + return 0; + + len = 3; + for (i = 0; len && *buf != 0 && isdigit((unsigned char)*buf); buf++) { + i *= 10; + i += *buf - '0'; + len--; + } + if (i < 1 || i > 366) + return 0; + + tm->tm_yday = i - 1; + break; + + case 'M': + case 'S': + if (*buf == 0 || isspace((unsigned char)*buf)) + break; + + if (!isdigit((unsigned char)*buf)) + return 0; + + len = 2; + for (i = 0; len && *buf != 0 && isdigit((unsigned char)*buf); buf++) { + i *= 10; + i += *buf - '0'; + len--; + } + + if (c == 'M') { + if (i > 59) + return 0; + tm->tm_min = i; + } else { + if (i > 60) + return 0; + tm->tm_sec = i; + } + + if (*buf != 0 && isspace((unsigned char)*buf)) + while (*ptr != 0 && !isspace((unsigned char)*ptr)) + ptr++; + break; + + case 'H': + case 'I': + case 'k': + case 'l': + /* + * Of these, %l is the only specifier explicitly + * documented as not being zero-padded. However, + * there is no harm in allowing zero-padding. + * + * XXX The %l specifier may gobble one too many + * digits if used incorrectly. + */ + if (!isdigit((unsigned char)*buf)) + return 0; + + len = 2; + for (i = 0; len && *buf != 0 && isdigit((unsigned char)*buf); buf++) { + i *= 10; + i += *buf - '0'; + len--; + } + if (c == 'H' || c == 'k') { + if (i > 23) + return 0; + } else if (i > 12) + return 0; + + tm->tm_hour = i; + + if (*buf != 0 && isspace((unsigned char)*buf)) + while (*ptr != 0 && !isspace((unsigned char)*ptr)) + ptr++; + break; + + case 'p': + /* + * XXX This is bogus if parsed before hour-related + * specifiers. + */ + len = strlen(Locale->am); + if (strncasecmp(buf, Locale->am, len) == 0) { + if (tm->tm_hour > 12) + return 0; + if (tm->tm_hour == 12) + tm->tm_hour = 0; + buf += len; + break; + } + + len = strlen(Locale->pm); + if (strncasecmp(buf, Locale->pm, len) == 0) { + if (tm->tm_hour > 12) + return 0; + if (tm->tm_hour != 12) + tm->tm_hour += 12; + buf += len; + break; + } + + return 0; + + case 'A': + case 'a': + for (i = 0; i < asizeof(Locale->weekday); i++) { + if (c == 'A') { + len = strlen(Locale->weekday[i]); + if (strncasecmp(buf, + Locale->weekday[i], + len) == 0) + break; + } else { + len = strlen(Locale->wday[i]); + if (strncasecmp(buf, + Locale->wday[i], + len) == 0) + break; + } + } + if (i == asizeof(Locale->weekday)) + return 0; + + tm->tm_wday = i; + buf += len; + break; + + case 'U': + case 'W': + /* + * XXX This is bogus, as we can not assume any valid + * information present in the tm structure at this + * point to calculate a real value, so just check the + * range for now. + */ + if (!isdigit((unsigned char)*buf)) + return 0; + + len = 2; + for (i = 0; len && *buf != 0 && isdigit((unsigned char)*buf); buf++) { + i *= 10; + i += *buf - '0'; + len--; + } + if (i > 53) + return 0; + + if (*buf != 0 && isspace((unsigned char)*buf)) + while (*ptr != 0 && !isspace((unsigned char)*ptr)) + ptr++; + break; + + case 'w': + if (!isdigit((unsigned char)*buf)) + return 0; + + i = *buf - '0'; + if (i > 6) + return 0; + + tm->tm_wday = i; + + if (*buf != 0 && isspace((unsigned char)*buf)) + while (*ptr != 0 && !isspace((unsigned char)*ptr)) + ptr++; + break; + + case 'd': + case 'e': + /* + * The %e specifier is explicitly documented as not + * being zero-padded but there is no harm in allowing + * such padding. + * + * XXX The %e specifier may gobble one too many + * digits if used incorrectly. + */ + if (!isdigit((unsigned char)*buf)) + return 0; + + len = 2; + for (i = 0; len && *buf != 0 && isdigit((unsigned char)*buf); buf++) { + i *= 10; + i += *buf - '0'; + len--; + } + if (i > 31) + return 0; + + tm->tm_mday = i; + + if (*buf != 0 && isspace((unsigned char)*buf)) + while (*ptr != 0 && !isspace((unsigned char)*ptr)) + ptr++; + break; + + case 'B': + case 'b': + case 'h': + for (i = 0; i < asizeof(Locale->month); i++) { + if (Oalternative) { + if (c == 'B') { + len = strlen(Locale->alt_month[i]); + if (strncasecmp(buf, + Locale->alt_month[i], + len) == 0) + break; + } + } else { + if (c == 'B') { + len = strlen(Locale->month[i]); + if (strncasecmp(buf, + Locale->month[i], + len) == 0) + break; + } else { + len = strlen(Locale->mon[i]); + if (strncasecmp(buf, + Locale->mon[i], + len) == 0) + break; + } + } + } + if (i == asizeof(Locale->month)) + return 0; + + tm->tm_mon = i; + buf += len; + break; + + case 'm': + if (!isdigit((unsigned char)*buf)) + return 0; + + len = 2; + for (i = 0; len && *buf != 0 && isdigit((unsigned char)*buf); buf++) { + i *= 10; + i += *buf - '0'; + len--; + } + if (i < 1 || i > 12) + return 0; + + tm->tm_mon = i - 1; + + if (*buf != 0 && isspace((unsigned char)*buf)) + while (*ptr != 0 && !isspace((unsigned char)*ptr)) + ptr++; + break; + + case 's': + { + char *cp; + time_t t; + + t = strtol(buf, &cp, 10); + if (t == LONG_MAX) + return 0; + buf = cp; + gmtime_r(&t, tm); + got_GMT = 1; + } + break; + + case 'Y': + case 'y': + if (*buf == 0 || isspace((unsigned char)*buf)) + break; + + if (!isdigit((unsigned char)*buf)) + return 0; + + len = (c == 'Y') ? 4 : 2; + for (i = 0; len && *buf != 0 && isdigit((unsigned char)*buf); buf++) { + i *= 10; + i += *buf - '0'; + len--; + } + if (c == 'Y') + i -= 1900; + if (c == 'y' && i < 69) + i += 100; + if (i < 0) + return 0; + + tm->tm_year = i; + + if (*buf != 0 && isspace((unsigned char)*buf)) + while (*ptr != 0 && !isspace((unsigned char)*ptr)) + ptr++; + break; + + case 'Z': + { + const char *cp; + char *zonestr; + + for (cp = buf; *cp && isupper((unsigned char)*cp); ++cp) {/*empty*/} + if (cp - buf) { + zonestr = alloca(cp - buf + 1); + strncpy(zonestr, buf, cp - buf); + zonestr[cp - buf] = '\0'; + tzset(); + if (0 == strcmp(zonestr, "GMT")) { + got_GMT = 1; + } else if (0 == strcmp(zonestr, tzname[0])) { + tm->tm_isdst = 0; + } else if (0 == strcmp(zonestr, tzname[1])) { + tm->tm_isdst = 1; + } else { + return 0; + } + buf += cp - buf; + } + } + break; + } + } + return (char *)buf; +} + + +char * +strptime(const char *buf, const char *fmt, struct tm *tm) +{ + char *ret; + +#ifdef _THREAD_SAFE + pthread_mutex_lock(&gotgmt_mutex); +#endif + + got_GMT = 0; + ret = _strptime(buf, fmt, tm); + if (ret && got_GMT) { + time_t t = timegm(tm); + localtime_r(&t, tm); + got_GMT = 0; + } + +#ifdef _THREAD_SAFE + pthread_mutex_unlock(&gotgmt_mutex); +#endif + + return ret; +} diff --git a/stdtime/time2posix.3 b/stdtime/time2posix.3 new file mode 100644 index 0000000..cc6bd49 --- /dev/null +++ b/stdtime/time2posix.3 @@ -0,0 +1,120 @@ +.\" $FreeBSD: src/lib/libc/stdtime/time2posix.3,v 1.9.2.4 2001/12/14 18:33:59 ru Exp $ +.\" +.Dd May 1, 1996 +.Dt TIME2POSIX 3 +.Os +.Sh NAME +.Nm time2posix , +.Nm posix2time +.Nd convert seconds since the Epoch +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In time.h +.Ft time_t +.Fn time2posix "const time_t *t" +.Ft time_t +.Fn posix2time "const time_t *t" +.Sh DESCRIPTION +.St -p1003.1-88 +legislates that a time_t value of +536457599 shall correspond to "Wed Dec 31 23:59:59 GMT 1986." +This effectively implies that POSIX time_t's cannot include leap +seconds and, +therefore, +that the system time must be adjusted as each leap occurs. +.Pp +If the time package is configured with leap-second support +enabled, +however, +no such adjustment is needed and +time_t values continue to increase over leap events +(as a true `seconds since...' value). +This means that these values will differ from those required by POSIX +by the net number of leap seconds inserted since the Epoch. +.Pp +Typically this is not a problem as the type time_t is intended +to be +(mostly) +opaque\(emtime_t values should only be obtained-from and +passed-to functions such as +.Xr time 3 , +.Xr localtime 3 , +.Xr mktime 3 +and +.Xr difftime 3 . +However, +.St -p1003.1-88 +gives an arithmetic +expression for directly computing a time_t value from a given date/time, +and the same relationship is assumed by some +(usually older) +applications. +Any programs creating/dissecting time_t's +using such a relationship will typically not handle intervals +over leap seconds correctly. +.Pp +The +.Fn time2posix +and +.Fn posix2time +functions are provided to address this time_t mismatch by converting +between local time_t values and their POSIX equivalents. +This is done by accounting for the number of time-base changes that +would have taken place on a POSIX system as leap seconds were inserted +or deleted. +These converted values can then be used in lieu of correcting the older +applications, +or when communicating with POSIX-compliant systems. +.Pp +The +.Fn time2posix +function is single-valued. +That is, +every local time_t +corresponds to a single POSIX time_t. +The +.Fn posix2time +function is less well-behaved: +for a positive leap second hit the result is not unique, +and for a negative leap second hit the corresponding +POSIX time_t doesn't exist so an adjacent value is returned. +Both of these are good indicators of the inferiority of the +POSIX representation. +.Pp +The following table summarizes the relationship between time_t +and its conversion to, +and back from, +the POSIX representation over the leap second inserted at the end of June, +1993. +.Bl -column "93/06/30" "23:59:59" "A+0" "X=time2posix(T)" +.It Sy "DATE TIME T X=time2posix(T) posix2time(X)" +.It "93/06/30 23:59:59 A+0 B+0 A+0" +.It "93/06/30 23:59:60 A+1 B+1 A+1 or A+2" +.It "93/07/01 00:00:00 A+2 B+1 A+1 or A+2" +.It "93/07/01 00:00:01 A+3 B+2 A+3" +.El +.Pp +A leap second deletion would look like... +.Bl -column "??/06/30" "23:59:58" "A+0" "X=time2posix(T)" +.It Sy "DATE TIME T X=time2posix(T) posix2time(X)" +.It "??/06/30 23:59:58 A+0 B+0 A+0" +.It "??/07/01 00:00:00 A+1 B+2 A+1" +.It "??/07/01 00:00:01 A+2 B+3 A+2" +.El +.Pp +.D1 No "[Note: posix2time(B+1) => A+0 or A+1]" +.Pp +If leap-second support is not enabled, +local time_t's and +POSIX time_t's are equivalent, +and both +.Fn time2posix +and +.Fn posix2time +degenerate to the identity function. +.Sh "SEE ALSO" +.Xr difftime 3 , +.Xr localtime 3 , +.Xr mktime 3 , +.Xr time 3 diff --git a/stdtime/timelocal.c b/stdtime/timelocal.c new file mode 100644 index 0000000..514d3f1 --- /dev/null +++ b/stdtime/timelocal.c @@ -0,0 +1,244 @@ +/*- + * Copyright (c) 1997 FreeBSD Inc. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + * $FreeBSD: src/lib/libc/stdtime/timelocal.c,v 1.8.2.2 2000/10/26 16:21:35 ache Exp $ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "setlocale.h" +#include "timelocal.h" + +static int split_lines(char *, const char *); +static void set_from_buf(const char *, int); + +struct lc_time_T _time_localebuf; +int _time_using_locale; + +#define LCTIME_SIZE_FULL (sizeof(struct lc_time_T) / sizeof(char *)) +#define LCTIME_SIZE_1 \ + (offsetof(struct lc_time_T, alt_month[0]) / sizeof(char *)) +#define LCTIME_SIZE_2 \ + (offsetof(struct lc_time_T, Ef_fmt) / sizeof(char *)) + +const struct lc_time_T _C_time_locale = { + { + "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" + }, + + /* X_fmt */ + "%H:%M:%S", + + /* + ** x_fmt + ** Since the C language standard calls for + ** "date, using locale's date format," anything goes. + ** Using just numbers (as here) makes Quakers happier; + ** it's also compatible with SVR4. + */ + "%m/%d/%y", + + /* + ** c_fmt (ctime-compatible) + ** Not used, just compatibility placeholder. + */ + NULL, + + /* am */ + "AM", + + /* pm */ + "PM", + + /* date_fmt */ + "%a %Ef %X %Z %Y", + + { + "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December" + }, + + /* Ef_fmt + ** To determine short months / day order + */ + "%b %e", + + /* EF_fmt + ** To determine long months / day order + */ + "%B %e" +}; + + +int +__time_load_locale(const char *name) +{ + static char * locale_buf; + static char locale_buf_C[] = "C"; + static int num_lines; + + int fd; + char * lbuf; + char * p; + const char * plim; + char filename[PATH_MAX]; + struct stat st; + size_t namesize; + size_t bufsize; + int save_using_locale; + + save_using_locale = _time_using_locale; + _time_using_locale = 0; + + if (name == NULL) + goto no_locale; + + if (!strcmp(name, "C") || !strcmp(name, "POSIX")) + return 0; + + /* + ** If the locale name is the same as our cache, use the cache. + */ + lbuf = locale_buf; + if (lbuf != NULL && strcmp(name, lbuf) == 0) { + set_from_buf(lbuf, num_lines); + _time_using_locale = 1; + return 0; + } + /* + ** Slurp the locale file into the cache. + */ + namesize = strlen(name) + 1; + + if (!_PathLocale) + goto no_locale; + /* Range checking not needed, 'name' size is limited */ + strcpy(filename, _PathLocale); + strcat(filename, "/"); + strcat(filename, name); + strcat(filename, "/LC_TIME"); + fd = open(filename, O_RDONLY); + if (fd < 0) + goto no_locale; + if (fstat(fd, &st) != 0) + goto bad_locale; + if (st.st_size <= 0) + goto bad_locale; + bufsize = namesize + st.st_size; + locale_buf = NULL; + lbuf = (lbuf == NULL || lbuf == locale_buf_C) ? + malloc(bufsize) : reallocf(lbuf, bufsize); + if (lbuf == NULL) + goto bad_locale; + (void) strcpy(lbuf, name); + p = lbuf + namesize; + plim = p + st.st_size; + if (read(fd, p, (size_t) st.st_size) != st.st_size) + goto bad_lbuf; + if (close(fd) != 0) + goto bad_lbuf; + /* + ** Parse the locale file into localebuf. + */ + if (plim[-1] != '\n') + goto bad_lbuf; + num_lines = split_lines(p, plim); + if (num_lines >= LCTIME_SIZE_FULL) + num_lines = LCTIME_SIZE_FULL; + else if (num_lines >= LCTIME_SIZE_2) + num_lines = LCTIME_SIZE_2; + else if (num_lines >= LCTIME_SIZE_1) + num_lines = LCTIME_SIZE_1; + else + goto reset_locale; + set_from_buf(lbuf, num_lines); + /* + ** Record the successful parse in the cache. + */ + locale_buf = lbuf; + + _time_using_locale = 1; + return 0; + +reset_locale: + /* + * XXX - This may not be the correct thing to do in this case. + * setlocale() assumes that we left the old locale alone. + */ + locale_buf = locale_buf_C; + _time_localebuf = _C_time_locale; + save_using_locale = 0; +bad_lbuf: + free(lbuf); +bad_locale: + (void)close(fd); +no_locale: + _time_using_locale = save_using_locale; + return -1; +} + +static int +split_lines(char *p, const char *plim) +{ + int i; + + for (i = 0; p < plim; i++) { + p = strchr(p, '\n'); + *p++ = '\0'; + } + return i; +} + +static void +set_from_buf(const char *p, int num_lines) +{ + const char **ap; + int i; + + for (ap = (const char **) &_time_localebuf, i = 0; + i < num_lines; ++ap, ++i) + *ap = p += strlen(p) + 1; + if (num_lines >= LCTIME_SIZE_2) + return; + for (i = 0; i < 12; i++) + _time_localebuf.alt_month[i] = _time_localebuf.month[i]; +} diff --git a/stdtime/timelocal.h b/stdtime/timelocal.h new file mode 100644 index 0000000..e1f9694 --- /dev/null +++ b/stdtime/timelocal.h @@ -0,0 +1,54 @@ +/*- + * Copyright (c) 1997 FreeBSD Inc. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + * $FreeBSD: src/lib/libc/stdtime/timelocal.h,v 1.5.2.1 2000/10/26 16:21:35 ache Exp $ + */ + +/* + * Private header file for the strftime and strptime localization + * stuff. + */ +struct lc_time_T { + const char * mon[12]; + const char * month[12]; + const char * wday[7]; + const char * weekday[7]; + const char * X_fmt; + const char * x_fmt; + const char * c_fmt; /* not used, just compatibility placeholder */ + const char * am; + const char * pm; + const char * date_fmt; + const char * alt_month[12]; + const char * Ef_fmt; + const char * EF_fmt; +}; + +extern struct lc_time_T _time_localebuf; +extern int _time_using_locale; +extern const struct lc_time_T _C_time_locale; + +#define Locale (_time_using_locale ? &_time_localebuf : &_C_time_locale) + diff --git a/stdtime/tzfile.5 b/stdtime/tzfile.5 new file mode 100644 index 0000000..25ad3e6 --- /dev/null +++ b/stdtime/tzfile.5 @@ -0,0 +1,138 @@ +.\" $FreeBSD: src/lib/libc/stdtime/tzfile.5,v 1.8.2.2 2001/08/17 15:42:43 ru Exp $ +.Dd September 13, 1994 +.Dt TZFILE 5 +.Os +.Sh NAME +.Nm tzfile +.Nd timezone information +.Sh SYNOPSIS +.Fd #include \&"/usr/src/lib/libc/stdtime/tzfile.h\&" +.Sh DESCRIPTION +The time zone information files used by +.Xr tzset 3 +begin with the magic characters +.Dq Li TZif +to identify them as +time zone information files, +followed by sixteen bytes reserved for future use, +followed by four four-byte values +written in a ``standard'' byte order +(the high-order byte of the value is written first). +These values are, +in order: +.Pp +.Bl -tag -compact -width tzh_ttisstdcnt +.It Va tzh_ttisgmtcnt +The number of UTC/local indicators stored in the file. +.It Va tzh_ttisstdcnt +The number of standard/wall indicators stored in the file. +.It Va tzh_leapcnt +The number of leap seconds for which data is stored in the file. +.It Va tzh_timecnt +The number of ``transition times'' for which data is stored +in the file. +.It Va tzh_typecnt +The number of ``local time types'' for which data is stored +in the file (must not be zero). +.It Va tzh_charcnt +The number of characters of ``time zone abbreviation strings'' +stored in the file. +.El +.Pp +The above header is followed by +.Va tzh_timecnt +four-byte values of type +.Fa long , +sorted in ascending order. +These values are written in ``standard'' byte order. +Each is used as a transition time (as returned by +.Xr time 3 ) +at which the rules for computing local time change. +Next come +.Va tzh_timecnt +one-byte values of type +.Fa "unsigned char" ; +each one tells which of the different types of ``local time'' types +described in the file is associated with the same-indexed transition time. +These values serve as indices into an array of +.Fa ttinfo +structures that appears next in the file; +these structures are defined as follows: +.Pp +.Bd -literal -offset indent +struct ttinfo { + long tt_gmtoff; + int tt_isdst; + unsigned int tt_abbrind; +}; +.Ed +.Pp +Each structure is written as a four-byte value for +.Va tt_gmtoff +of type +.Fa long , +in a standard byte order, followed by a one-byte value for +.Va tt_isdst +and a one-byte value for +.Va tt_abbrind . +In each structure, +.Va tt_gmtoff +gives the number of seconds to be added to UTC, +.Li tt_isdst +tells whether +.Li tm_isdst +should be set by +.Xr localtime 3 +and +.Va tt_abbrind +serves as an index into the array of time zone abbreviation characters +that follow the +.Li ttinfo +structure(s) in the file. +.Pp +Then there are +.Va tzh_leapcnt +pairs of four-byte values, written in standard byte order; +the first value of each pair gives the time +(as returned by +.Xr time 3 ) +at which a leap second occurs; +the second gives the +.Em total +number of leap seconds to be applied after the given time. +The pairs of values are sorted in ascending order by time. +.Pp +Then there are +.Va tzh_ttisstdcnt +standard/wall indicators, each stored as a one-byte value; +they tell whether the transition times associated with local time types +were specified as standard time or wall clock time, +and are used when a time zone file is used in handling POSIX-style +time zone environment variables. +.Pp +Finally there are +.Va tzh_ttisgmtcnt +UTC/local indicators, each stored as a one-byte value; +they tell whether the transition times associated with local time types +were specified as UTC or local time, +and are used when a time zone file is used in handling POSIX-style +time zone environment variables. +.Pp +.Nm localtime +uses the first standard-time +.Li ttinfo +structure in the file +(or simply the first +.Li ttinfo +structure in the absence of a standard-time structure) +if either +.Li tzh_timecnt +is zero or the time argument is less than the first transition time recorded +in the file. +.Sh SEE ALSO +.Xr ctime 3 , +.Xr time2posix 3 , +.Xr zic 8 +.\" @(#)tzfile.5 7.2 +.\" This file is in the public domain, so clarified as of +.\" 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). diff --git a/stdtime/tzfile.h b/stdtime/tzfile.h new file mode 100644 index 0000000..c1b27ea --- /dev/null +++ b/stdtime/tzfile.h @@ -0,0 +1,190 @@ +#ifndef TZFILE_H + +#define TZFILE_H + +/* +** This file is in the public domain, so clarified as of +** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). +*/ + +/* +** This header is for use ONLY with the time conversion code. +** There is no guarantee that it will remain unchanged, +** or that it will remain at all. +** Do NOT copy it to any system include directory. +** Thank you! +*/ + +/* +** ID +*/ + +#ifndef lint +#ifndef NOID +/* +static char tzfilehid[] = "@(#)tzfile.h 7.14"; +*/ +#endif /* !defined NOID */ +#endif /* !defined lint */ + +/* +** Information about time zone files. +*/ + +#ifndef TZDIR +#define TZDIR "/usr/share/zoneinfo" /* Time zone object file directory */ +#endif /* !defined TZDIR */ + +#ifndef TZDEFAULT +#define TZDEFAULT "/etc/localtime" +#endif /* !defined TZDEFAULT */ + +#ifndef TZDEFRULES +#define TZDEFRULES "posixrules" +#endif /* !defined TZDEFRULES */ + +/* +** Each file begins with. . . +*/ + +#define TZ_MAGIC "TZif" + +struct tzhead { + char tzh_magic[4]; /* TZ_MAGIC */ + char tzh_reserved[16]; /* reserved for future use */ + char tzh_ttisgmtcnt[4]; /* coded number of trans. time flags */ + char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */ + char tzh_leapcnt[4]; /* coded number of leap seconds */ + char tzh_timecnt[4]; /* coded number of transition times */ + char tzh_typecnt[4]; /* coded number of local time types */ + char tzh_charcnt[4]; /* coded number of abbr. chars */ +}; + +/* +** . . .followed by. . . +** +** tzh_timecnt (char [4])s coded transition times a la time(2) +** tzh_timecnt (unsigned char)s types of local time starting at above +** tzh_typecnt repetitions of +** one (char [4]) coded UTC offset in seconds +** one (unsigned char) used to set tm_isdst +** one (unsigned char) that's an abbreviation list index +** tzh_charcnt (char)s '\0'-terminated zone abbreviations +** tzh_leapcnt repetitions of +** one (char [4]) coded leap second transition times +** one (char [4]) total correction after above +** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition +** time is standard time, if FALSE, +** transition time is wall clock time +** if absent, transition times are +** assumed to be wall clock time +** tzh_ttisgmtcnt (char)s indexed by type; if TRUE, transition +** time is UTC, if FALSE, +** transition time is local time +** if absent, transition times are +** assumed to be local time +*/ + +/* +** In the current implementation, "tzset()" refuses to deal with files that +** exceed any of the limits below. +*/ + +#ifndef TZ_MAX_TIMES +/* +** The TZ_MAX_TIMES value below is enough to handle a bit more than a +** year's worth of solar time (corrected daily to the nearest second) or +** 138 years of Pacific Presidential Election time +** (where there are three time zone transitions every fourth year). +*/ +#define TZ_MAX_TIMES 370 +#endif /* !defined TZ_MAX_TIMES */ + +#ifndef TZ_MAX_TYPES +#ifndef NOSOLAR +#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */ +#endif /* !defined NOSOLAR */ +#ifdef NOSOLAR +/* +** Must be at least 14 for Europe/Riga as of Jan 12 1995, +** as noted by Earl Chew . +*/ +#define TZ_MAX_TYPES 20 /* Maximum number of local time types */ +#endif /* !defined NOSOLAR */ +#endif /* !defined TZ_MAX_TYPES */ + +#ifndef TZ_MAX_CHARS +#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */ + /* (limited by what unsigned chars can hold) */ +#endif /* !defined TZ_MAX_CHARS */ + +#ifndef TZ_MAX_LEAPS +#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */ +#endif /* !defined TZ_MAX_LEAPS */ + +#define SECSPERMIN 60 +#define MINSPERHOUR 60 +#define HOURSPERDAY 24 +#define DAYSPERWEEK 7 +#define DAYSPERNYEAR 365 +#define DAYSPERLYEAR 366 +#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR) +#define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY) +#define MONSPERYEAR 12 + +#define TM_SUNDAY 0 +#define TM_MONDAY 1 +#define TM_TUESDAY 2 +#define TM_WEDNESDAY 3 +#define TM_THURSDAY 4 +#define TM_FRIDAY 5 +#define TM_SATURDAY 6 + +#define TM_JANUARY 0 +#define TM_FEBRUARY 1 +#define TM_MARCH 2 +#define TM_APRIL 3 +#define TM_MAY 4 +#define TM_JUNE 5 +#define TM_JULY 6 +#define TM_AUGUST 7 +#define TM_SEPTEMBER 8 +#define TM_OCTOBER 9 +#define TM_NOVEMBER 10 +#define TM_DECEMBER 11 + +#define TM_YEAR_BASE 1900 + +#define EPOCH_YEAR 1970 +#define EPOCH_WDAY TM_THURSDAY + +/* +** Accurate only for the past couple of centuries; +** that will probably do. +*/ + +#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) + +#ifndef USG + +/* +** Use of the underscored variants may cause problems if you move your code to +** certain System-V-based systems; for maximum portability, use the +** underscore-free variants. The underscored variants are provided for +** backward compatibility only; they may disappear from future versions of +** this file. +*/ + +#define SECS_PER_MIN SECSPERMIN +#define MINS_PER_HOUR MINSPERHOUR +#define HOURS_PER_DAY HOURSPERDAY +#define DAYS_PER_WEEK DAYSPERWEEK +#define DAYS_PER_NYEAR DAYSPERNYEAR +#define DAYS_PER_LYEAR DAYSPERLYEAR +#define SECS_PER_HOUR SECSPERHOUR +#define SECS_PER_DAY SECSPERDAY +#define MONS_PER_YEAR MONSPERYEAR + +#endif /* !defined USG */ + +#endif /* !defined TZFILE_H */ diff --git a/string.subproj/Makefile b/string.subproj/Makefile deleted file mode 100644 index 85018cc..0000000 --- a/string.subproj/Makefile +++ /dev/null @@ -1,51 +0,0 @@ -# -# Generated by the NeXT Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = string - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -OTHERLINKED = strcmp.s - -CFILES = index.c memccpy.c memchr.c memcmp.c memset.c rindex.c\ - rindix.c strcasecmp.c strchr.c strcoll.c strcspn.c strdup.c\ - strerror.c strftime.c strmode.c strpbrk.c strsep.c strspn.c\ - strstr.c strtok.c strxfrm.c swab.c - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble - -OTHERLINKEDOFILES = strcmp.o - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - - - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/string.subproj/Makefile.postamble b/string.subproj/Makefile.postamble deleted file mode 100644 index 411cde6..0000000 --- a/string.subproj/Makefile.postamble +++ /dev/null @@ -1,100 +0,0 @@ -############################################################################### -# Makefile.postamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile, which is imported after all other makefiles, to -# override attributes for a project's Makefile environment. This allows you -# to take advantage of the environment set up by the other Makefiles. -# You can also define custom rules at the end of this file. -# -############################################################################### -# -# These variables are exported by the standard makefiles and can be -# used in any customizations you make. They are *outputs* of -# the Makefiles and should be used, not set. -# -# PRODUCTS: products to install. All of these products will be placed in -# the directory $(DSTROOT)$(INSTALLDIR) -# GLOBAL_RESOURCE_DIR: The directory to which resources are copied. -# LOCAL_RESOURCE_DIR: The directory to which localized resources are copied. -# OFILE_DIR: Directory into which .o object files are generated. -# DERIVED_SRC_DIR: Directory used for all other derived files -# -# ALL_CFLAGS: flags to pass when compiling .c files -# ALL_MFLAGS: flags to pass when compiling .m files -# ALL_CCFLAGS: flags to pass when compiling .cc, .cxx, and .C files -# ALL_MMFLAGS: flags to pass when compiling .mm, .mxx, and .M files -# ALL_PRECOMPFLAGS: flags to pass when precompiling .h files -# ALL_LDFLAGS: flags to pass when linking object files -# ALL_LIBTOOL_FLAGS: flags to pass when libtooling object files -# ALL_PSWFLAGS: flags to pass when processing .psw and .pswm (pswrap) files -# ALL_RPCFLAGS: flags to pass when processing .rpc (rpcgen) files -# ALL_YFLAGS: flags to pass when processing .y (yacc) files -# ALL_LFLAGS: flags to pass when processing .l (lex) files -# -# NAME: name of application, bundle, subproject, palette, etc. -# LANGUAGES: langages in which the project is written (default "English") -# English_RESOURCES: localized resources (e.g. nib's, images) of project -# GLOBAL_RESOURCES: non-localized resources of project -# -# SRCROOT: base directory in which to place the new source files -# SRCPATH: relative path from SRCROOT to present subdirectory -# -# INSTALLDIR: Directory the product will be installed into by 'install' target -# PUBLIC_HDR_INSTALLDIR: where to install public headers. Don't forget -# to prefix this with DSTROOT when you use it. -# PRIVATE_HDR_INSTALLDIR: where to install private headers. Don't forget -# to prefix this with DSTROOT when you use it. -# -# EXECUTABLE_EXT: Executable extension for the platform (i.e. .exe on Windows) -# -############################################################################### - -# Some compiler flags can be overridden here for certain build situations. -# -# WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost) -# DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults -# to -g) -# DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG) -# OPTIMIZE_BUILD_CFLAGS: flags passed during optimized builds (defaults -# to -O) -# PROFILE_BUILD_CFLAGS: flags passed during profile builds (defaults -# to -pg -DPROFILE) -# LOCAL_DIR_INCLUDE_DIRECTIVE: flag used to add current directory to -# the include path (defaults to -I.) -# DEBUG_BUILD_LDFLAGS, OPTIMIZE_BUILD_LDFLAGS, PROFILE_BUILD_LDFLAGS: flags -# passed to ld/libtool (defaults to nothing) - - -# Library and Framework projects only: -# INSTALL_NAME_DIRECTIVE: This directive ensures that executables linked -# against the framework will run against the correct version even if -# the current version of the framework changes. You may override this -# to "" as an alternative to using the DYLD_LIBRARY_PATH during your -# development cycle, but be sure to restore it before installing. - - -# Ownership and permissions of files installed by 'install' target - -#INSTALL_AS_USER = root - # User/group ownership -#INSTALL_AS_GROUP = wheel - # (probably want to set both of these) -#INSTALL_PERMISSIONS = - # If set, 'install' chmod's executable to this - - -# Options to strip. Note: -S strips debugging symbols (executables can be stripped -# down further with -x or, if they load no bundles, with no options at all). - -#STRIPFLAGS = -S - - -######################################################################### -# Put rules to extend the behavior of the standard Makefiles here. Include them in -# the dependency tree via cvariables like AFTER_INSTALL in the Makefile.preamble. -# -# You should avoid redefining things like "install" or "app", as they are -# owned by the top-level Makefile API and no context has been set up for where -# derived files should go. -# diff --git a/string.subproj/Makefile.preamble b/string.subproj/Makefile.preamble deleted file mode 100644 index c1624b4..0000000 --- a/string.subproj/Makefile.preamble +++ /dev/null @@ -1,137 +0,0 @@ -############################################################################### -# Makefile.preamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile for configuring the standard application makefiles -# associated with ProjectBuilder. It is included before the main makefile. -# In Makefile.preamble you set attributes for a project, so they are available -# to the project's makefiles. In contrast, you typically write additional rules or -# override built-in behavior in the Makefile.postamble. -# -# Each directory in a project tree (main project plus subprojects) should -# have its own Makefile.preamble and Makefile.postamble. -############################################################################### -# -# Before the main makefile is included for this project, you may set: -# -# MAKEFILEDIR: Directory in which to find $(MAKEFILE) -# MAKEFILE: Top level mechanism Makefile (e.g., app.make, bundle.make) - -# Compiler/linker flags added to the defaults: The OTHER_* variables will be -# inherited by all nested sub-projects, but the LOCAL_ versions of the same -# variables will not. Put your -I, -D, -U, and -L flags in ProjectBuilder's -# Build Attributes inspector if at all possible. To override the default flags -# that get passed to ${CC} (e.g. change -O to -O2), see Makefile.postamble. The -# variables below are *inputs* to the build process and distinct from the override -# settings done (less often) in the Makefile.postamble. -# -# OTHER_CFLAGS, LOCAL_CFLAGS: additional flags to pass to the compiler -# Note that $(OTHER_CFLAGS) and $(LOCAL_CFLAGS) are used for .h, ...c, .m, -# .cc, .cxx, .C, and .M files. There is no need to respecify the -# flags in OTHER_MFLAGS, etc. -# OTHER_MFLAGS, LOCAL_MFLAGS: additional flags for .m files -# OTHER_CCFLAGS, LOCAL_CCFLAGS: additional flags for .cc, .cxx, and ...C files -# OTHER_MMFLAGS, LOCAL_MMFLAGS: additional flags for .mm and .M files -# OTHER_PRECOMPFLAGS, LOCAL_PRECOMPFLAGS: additional flags used when -# precompiling header files -# OTHER_LDFLAGS, LOCAL_LDFLAGS: additional flags passed to ld and libtool -# OTHER_PSWFLAGS, LOCAL_PSWFLAGS: additional flags passed to pswrap -# OTHER_RPCFLAGS, LOCAL_RPCFLAGS: additional flags passed to rpcgen -# OTHER_YFLAGS, LOCAL_YFLAGS: additional flags passed to yacc -# OTHER_LFLAGS, LOCAL_LFLAGS: additional flags passed to lex - -# These variables provide hooks enabling you to add behavior at almost every -# stage of the make: -# -# BEFORE_PREBUILD: targets to build before installing headers for a subproject -# AFTER_PREBUILD: targets to build after installing headers for a subproject -# BEFORE_BUILD_RECURSION: targets to make before building subprojects -# BEFORE_BUILD: targets to make before a build, but after subprojects -# AFTER_BUILD: targets to make after a build -# -# BEFORE_INSTALL: targets to build before installing the product -# AFTER_INSTALL: targets to build after installing the product -# BEFORE_POSTINSTALL: targets to build before postinstalling every subproject -# AFTER_POSTINSTALL: targts to build after postinstalling every subproject -# -# BEFORE_INSTALLHDRS: targets to build before installing headers for a -# subproject -# AFTER_INSTALLHDRS: targets to build after installing headers for a subproject -# BEFORE_INSTALLSRC: targets to build before installing source for a subproject -# AFTER_INSTALLSRC: targets to build after installing source for a subproject -# -# BEFORE_DEPEND: targets to build before building dependencies for a -# subproject -# AFTER_DEPEND: targets to build after building dependencies for a -# subproject -# -# AUTOMATIC_DEPENDENCY_INFO: if YES, then the dependency file is -# updated every time the project is built. If NO, the dependency -# file is only built when the depend target is invoked. - -# Framework-related variables: -# FRAMEWORK_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the framework's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables - -# Library-related variables: -# PUBLIC_HEADER_DIR: Determines where public exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. For library projects you should -# set this to something like /Developer/Headers/$(NAME). Do not set -# this variable for framework projects unless you do not want the -# header files included in the framework. -# PRIVATE_HEADER_DIR: Determines where private exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. -# LIBRARY_STYLE: This may be either STATIC or DYNAMIC, and determines -# whether the libraries produced are statically linked when they -# are used or if they are dynamically loadable. This defaults to -# DYNAMIC. -# LIBRARY_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the library's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables -# -# INSTALL_AS_USER: owner of the intalled products (default root) -# INSTALL_AS_GROUP: group of the installed products (default wheel) -# INSTALL_PERMISSIONS: permissions of the installed product (default o+rX) -# -# OTHER_RECURSIVE_VARIABLES: The names of variables which you want to be -# passed on the command line to recursive invocations of make. Note that -# the values in OTHER_*FLAGS are inherited by subprojects automatically -- -# you do not have to (and shouldn't) add OTHER_*FLAGS to -# OTHER_RECURSIVE_VARIABLES. - -# Additional headers to export beyond those in the PB.project: -# OTHER_PUBLIC_HEADERS -# OTHER_PROJECT_HEADERS -# OTHER_PRIVATE_HEADERS - -# Additional files for the project's product: <> -# OTHER_RESOURCES: (non-localized) resources for this project -# OTHER_OFILES: relocatables to be linked into this project -# OTHER_LIBS: more libraries to link against -# OTHER_PRODUCT_DEPENDS: other dependencies of this project -# OTHER_SOURCEFILES: other source files maintained by .pre/postamble -# OTHER_GARBAGE: additional files to be removed by `make clean' - -# Set this to YES if you don't want a final libtool call for a library/framework. -# BUILD_OFILES_LIST_ONLY - -# To include a version string, project source must exist in a directory named -# $(NAME).%d[.%d][.%d] and the following line must be uncommented. -# OTHER_GENERATED_OFILES = $(VERS_OFILE) - -# This definition will suppress stripping of debug symbols when an executable -# is installed. By default it is YES. -# STRIP_ON_INSTALL = NO - -# Uncomment to suppress generation of a KeyValueCoding index when installing -# frameworks (This index is used by WOB and IB to determine keys available -# for an object). Set to YES by default. -# PREINDEX_FRAMEWORK = NO - -# Change this definition to install projects somewhere other than the -# standard locations. NEXT_ROOT defaults to "C:/Apple" on Windows systems -# and "" on other systems. -DSTROOT = $(HOME) diff --git a/string.subproj/PB.project b/string.subproj/PB.project deleted file mode 100644 index 78cb76d..0000000 --- a/string.subproj/PB.project +++ /dev/null @@ -1,47 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - H_FILES = (); - OTHER_LINKED = ( - index.c, - memccpy.c, - memchr.c, - memcmp.c, - memset.c, - rindex.c, - rindix.c, - strcasecmp.c, - strchr.c, - strcmp.s, - strcoll.c, - strcspn.c, - strdup.c, - strerror.c, - strftime.c, - strmode.c, - strpbrk.c, - strsep.c, - strspn.c, - strstr.c, - strtok.c, - strxfrm.c, - swab.c - ); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble); - SUBPROJECTS = (); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = string; - PROJECTTYPE = Component; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/string/Makefile.inc b/string/Makefile.inc new file mode 100644 index 0000000..0ac7762 --- /dev/null +++ b/string/Makefile.inc @@ -0,0 +1,47 @@ +# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 +# $FreeBSD: src/lib/libc/string/Makefile.inc,v 1.25 2001/10/10 02:17:35 ache Exp $ + +.PATH: ${.CURDIR}/${MACHINE_ARCH}/string ${.CURDIR}/string + +CFLAGS+= -I${.CURDIR}/locale + +# machine-independent string sources +MISRCS+=index.c rindex.c strcspn.c strpbrk.c strxfrm.c \ + memccpy.c rindix.c strdup.c strsep.c swab.c \ + memchr.c strcasecmp.c strerror.c strspn.c \ + memcmp.c strchr.c strftime.c strstr.c \ + memset.c strcoll.c strmode.c strtok.c \ + strlcat.c strlcpy.c + +# machine-dependent string sources +.if exists(${.CURDIR}/${MACHINE_ARCH}/string/Makefile.inc) +.include "${.CURDIR}/${MACHINE_ARCH}/string/Makefile.inc" +.endif + +.if ${LIB} == "c" +MAN3+= bcmp.3 bcopy.3 bstring.3 bzero.3 ffs.3 index.3 memccpy.3 memchr.3 \ + memcmp.3 memcpy.3 memmove.3 memset.3 rindex.3 strcasecmp.3 strcat.3 \ + strchr.3 strcmp.3 strcoll.3 strcpy.3 strcspn.3 strdup.3 strerror.3 \ + string.3 strlcpy.3 strlen.3 strmode.3 strpbrk.3 strrchr.3 strsep.3 \ + strspn.3 strstr.3 strtok.3 strxfrm.3 swab.3 wmemchr.3 + +MLINKS+=strcasecmp.3 strncasecmp.3 +MLINKS+=strcat.3 strncat.3 +MLINKS+=strcmp.3 strncmp.3 +MLINKS+=strcpy.3 strncpy.3 +MLINKS+=strerror.3 perror.3 strerror.3 sys_errlist.3 strerror.3 sys_nerr.3 +MLINKS+=strlcpy.3 strlcat.3 +MLINKS+=strtok.3 strtok_r.3 +MLINKS+=strstr.3 strcasestr.3 +MLINKS+=strstr.3 strnstr.3 +MLINKS+=wmemchr.3 wmemcmp.3 wmemchr.3 wmemcpy.3 \ + wmemchr.3 wmemmove.3 wmemchr.3 wmemset.3 \ + wmemchr.3 wcscat.3 wmemchr.3 wcschr.3 \ + wmemchr.3 wcscmp.3 wmemchr.3 wcscpy.3 \ + wmemchr.3 wcscspn.3 wmemchr.3 wcslcat.3 \ + wmemchr.3 wcslcpy.3 wmemchr.3 wcslen.3 \ + wmemchr.3 wcsncat.3 wmemchr.3 wcsncmp.3 \ + wmemchr.3 wcsncpy.3 wmemchr.3 wcspbrk.3 \ + wmemchr.3 wcsrchr.3 wmemchr.3 wcsspn.3 \ + wmemchr.3 wcsstr.3 +.endif diff --git a/string/bcmp.3 b/string/bcmp.3 new file mode 100644 index 0000000..60bd887 --- /dev/null +++ b/string/bcmp.3 @@ -0,0 +1,74 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek. +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)bcmp.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/string/bcmp.3,v 1.8 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt BCMP 3 +.Os +.Sh NAME +.Nm bcmp +.Nd compare byte string +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft int +.Fn bcmp "const void *b1" "const void *b2" "size_t len" +.Sh DESCRIPTION +The +.Fn bcmp +function +compares byte string +.Fa b1 +against byte string +.Fa b2 , +returning zero if they are identical, non-zero otherwise. +Both strings are assumed to be +.Fa len +bytes long. +Zero-length strings are always identical. +.Pp +The strings may overlap. +.Sh SEE ALSO +.Xr memcmp 3 , +.Xr strcasecmp 3 , +.Xr strcmp 3 , +.Xr strcoll 3 , +.Xr strxfrm 3 +.Sh HISTORY +A +.Fn bcmp +function first appeared in +.Bx 4.2 . diff --git a/string/bcopy.3 b/string/bcopy.3 new file mode 100644 index 0000000..a239409 --- /dev/null +++ b/string/bcopy.3 @@ -0,0 +1,74 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)bcopy.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/string/bcopy.3,v 1.7 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt BCOPY 3 +.Os +.Sh NAME +.Nm bcopy +.Nd copy byte string +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft void +.Fn bcopy "const void *src" "void *dst" "size_t len" +.Sh DESCRIPTION +The +.Fn bcopy +function +copies +.Fa len +bytes from string +.Fa src +to string +.Fa dst . +The two strings may overlap. +If +.Fa len +is zero, no bytes are copied. +.Sh SEE ALSO +.Xr memccpy 3 , +.Xr memcpy 3 , +.Xr memmove 3 , +.Xr strcpy 3 , +.Xr strncpy 3 +.Sh HISTORY +A +.Fn bcopy +function appeared in +.Bx 4.2 . diff --git a/string/bstring.3 b/string/bstring.3 new file mode 100644 index 0000000..3629a3e --- /dev/null +++ b/string/bstring.3 @@ -0,0 +1,112 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek. +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)bstring.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/string/bstring.3,v 1.7 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt BSTRING 3 +.Os +.Sh NAME +.Nm bcmp , +.Nm bcopy , +.Nm bzero , +.Nm memccpy , +.Nm memchr , +.Nm memcmp , +.Nm memcpy , +.Nm memmove , +.Nm memset +.Nd byte string operations +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft int +.Fn bcmp "const void *b1" "const void *b2" "size_t len" +.Ft void +.Fn bcopy "const void *src" "void *dst" "size_t len" +.Ft void +.Fn bzero "void *b" "size_t len" +.Ft void * +.Fn memchr "const void *b" "int c" "size_t len" +.Ft int +.Fn memcmp "const void *b1" "const void *b2" "size_t len" +.Ft void * +.Fn memccpy "void *dst" "const void *src" "int c" "size_t len" +.Ft void * +.Fn memcpy "void *dst" "const void *src" "size_t len" +.Ft void * +.Fn memmove "void *dst" "const void *src" "size_t len" +.Ft void * +.Fn memset "void *b" "int c" "size_t len" +.Sh DESCRIPTION +These functions operate on variable length strings of bytes. +They do not check for terminating null bytes as the routines +listed in +.Xr string 3 +do. +.Pp +See the specific manual pages for more information. +.Sh SEE ALSO +.Xr bcmp 3 , +.Xr bcopy 3 , +.Xr bzero 3 , +.Xr memccpy 3 , +.Xr memchr 3 , +.Xr memcmp 3 , +.Xr memcpy 3 , +.Xr memmove 3 , +.Xr memset 3 +.Sh STANDARDS +The functions +.Fn memchr , +.Fn memcmp , +.Fn memcpy , +.Fn memmove , +and +.Fn memset +conform to +.St -isoC . +.Sh HISTORY +The functions +.Fn bzero +and +.Fn memccpy +appeared in +.Bx 4.3 ; +the functions +.Fn bcmp , +.Fn bcopy , +appeared in +.Bx 4.2 . diff --git a/string/bzero.3 b/string/bzero.3 new file mode 100644 index 0000000..faa16fe --- /dev/null +++ b/string/bzero.3 @@ -0,0 +1,71 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)bzero.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/string/bzero.3,v 1.7 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt BZERO 3 +.Os +.Sh NAME +.Nm bzero +.Nd write zeroes to a byte string +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft void +.Fn bzero "void *b" "size_t len" +.Sh DESCRIPTION +The +.Fn bzero +function +writes +.Fa len +zero bytes to the string +.Fa b . +If +.Fa len +is zero, +.Fn bzero +does nothing. +.Sh SEE ALSO +.Xr memset 3 , +.Xr swab 3 +.Sh HISTORY +A +.Fn bzero +function +appeared in +.Bx 4.3 . diff --git a/string/ffs.3 b/string/ffs.3 new file mode 100644 index 0000000..665d9da --- /dev/null +++ b/string/ffs.3 @@ -0,0 +1,64 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek. +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)ffs.3 8.2 (Berkeley) 4/19/94 +.\" $FreeBSD: src/lib/libc/string/ffs.3,v 1.5 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd April 19, 1994 +.Dt FFS 3 +.Os +.Sh NAME +.Nm ffs +.Nd find first bit set in a bit string +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft int +.Fn ffs "int value" +.Sh DESCRIPTION +The +.Fn ffs +function finds the first bit set in +.Fa value +and returns the index of that bit. +Bits are numbered starting from 1, starting at the right-most +bit. +A return value of 0 means that the argument was zero. +.Sh SEE ALSO +.Xr bitstring 3 +.Sh HISTORY +The +.Fn ffs +function appeared in +.Bx 4.3 . diff --git a/string/index.3 b/string/index.3 new file mode 100644 index 0000000..309a39c --- /dev/null +++ b/string/index.3 @@ -0,0 +1,83 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek. +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)index.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/string/index.3,v 1.6 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt INDEX 3 +.Os +.Sh NAME +.Nm index +.Nd locate character in string +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft char * +.Fn index "const char *s" "int c" +.Sh DESCRIPTION +The +.Fn index +function +locates the first character matching +.Fa c +(converted to a +.Em char ) +in the null-terminated string +.Fa s . +.Sh RETURN VALUES +A pointer to the character is returned if it is found; otherwise +.Dv NULL +is returned. +If +.Fa c +is '\e0', +.Fn index +locates the terminating '\e0'. +.Sh SEE ALSO +.Xr memchr 3 , +.Xr rindex 3 , +.Xr strchr 3 , +.Xr strcspn 3 , +.Xr strpbrk 3 , +.Xr strrchr 3 , +.Xr strsep 3 , +.Xr strspn 3 , +.Xr strstr 3 , +.Xr strtok 3 +.Sh HISTORY +A +.Fn index +function appeared in +.At v6 . diff --git a/string.subproj/index.c b/string/index.c similarity index 100% rename from string.subproj/index.c rename to string/index.c diff --git a/string/memccpy.3 b/string/memccpy.3 new file mode 100644 index 0000000..44a457f --- /dev/null +++ b/string/memccpy.3 @@ -0,0 +1,76 @@ +.\" Copyright (c) 1990, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)memccpy.3 8.1 (Berkeley) 6/9/93 +.\" $FreeBSD: src/lib/libc/string/memccpy.3,v 1.6 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd June 9, 1993 +.Dt MEMCCPY 3 +.Os +.Sh NAME +.Nm memccpy +.Nd copy string until character found +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft void * +.Fn memccpy "void *dst" "const void *src" "int c" "size_t len" +.Sh DESCRIPTION +The +.Fn memccpy +function +copies bytes from string +.Fa src +to string +.Fa dst . +If the character +.Fa c +(as converted to an unsigned char) occurs in the string +.Fa src , +the copy stops and a pointer to the byte after the copy of +.Fa c +in the string +.Fa dst +is returned. +Otherwise, +.Fa len +bytes are copied, and a NULL pointer is returned. +.Sh SEE ALSO +.Xr bcopy 3 , +.Xr memcpy 3 , +.Xr memmove 3 , +.Xr strcpy 3 +.Sh HISTORY +The +.Fn memccpy +function first appeared in +.Bx 4.4 . diff --git a/string.subproj/memccpy.c b/string/memccpy.c similarity index 100% rename from string.subproj/memccpy.c rename to string/memccpy.c diff --git a/string/memchr.3 b/string/memchr.3 new file mode 100644 index 0000000..b363185 --- /dev/null +++ b/string/memchr.3 @@ -0,0 +1,82 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)memchr.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/string/memchr.3,v 1.7 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt MEMCHR 3 +.Os +.Sh NAME +.Nm memchr +.Nd locate byte in byte string +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft void * +.Fn memchr "const void *b" "int c" "size_t len" +.Sh DESCRIPTION +The +.Fn memchr +function +locates the first occurrence of +.Fa c +(converted to an unsigned char) +in string +.Fa b . +.Sh RETURN VALUES +The +.Fn memchr +function +returns a pointer to the byte located, +or NULL if no such byte exists within +.Fa len +bytes. +.Sh SEE ALSO +.Xr strchr 3 , +.Xr strcspn 3 , +.Xr strpbrk 3 , +.Xr strrchr 3 , +.Xr strsep 3 , +.Xr strspn 3 , +.Xr strstr 3 , +.Xr strtok 3 +.Sh STANDARDS +The +.Fn memchr +function +conforms to +.St -isoC . diff --git a/string.subproj/memchr.c b/string/memchr.c similarity index 100% rename from string.subproj/memchr.c rename to string/memchr.c diff --git a/string/memcmp.3 b/string/memcmp.3 new file mode 100644 index 0000000..980af28 --- /dev/null +++ b/string/memcmp.3 @@ -0,0 +1,85 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)memcmp.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/string/memcmp.3,v 1.8 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt MEMCMP 3 +.Os +.Sh NAME +.Nm memcmp +.Nd compare byte string +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft int +.Fn memcmp "const void *b1" "const void *b2" "size_t len" +.Sh DESCRIPTION +The +.Fn memcmp +function +compares byte string +.Fa b1 +against byte string +.Fa b2 . +Both strings are assumed to be +.Fa len +bytes long. +.Sh RETURN VALUES +The +.Fn memcmp +function +returns zero if the two strings are identical, +otherwise returns the difference between the first two differing bytes +(treated as unsigned char values, so that +.Sq Li \e200 +is greater than +.Sq Li \&\e0 , +for example). +Zero-length strings are always identical. +.Sh SEE ALSO +.Xr bcmp 3 , +.Xr strcasecmp 3 , +.Xr strcmp 3 , +.Xr strcoll 3 , +.Xr strxfrm 3 +.Sh STANDARDS +The +.Fn memcmp +function +conforms to +.St -isoC . diff --git a/string.subproj/memcmp.c b/string/memcmp.c similarity index 100% rename from string.subproj/memcmp.c rename to string/memcmp.c diff --git a/string/memcpy.3 b/string/memcpy.3 new file mode 100644 index 0000000..311fbec --- /dev/null +++ b/string/memcpy.3 @@ -0,0 +1,86 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)memcpy.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/string/memcpy.3,v 1.6 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt MEMCPY 3 +.Os +.Sh NAME +.Nm memcpy +.Nd copy byte string +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft void * +.Fn memcpy "void *dst" "const void *src" "size_t len" +.Sh DESCRIPTION +The +.Fn memcpy +function +copies +.Fa len +bytes from string +.Fa src +to string +.Fa dst . +.Sh RETURN VALUES +The +.Fn memcpy +function +returns the original value of +.Fa dst . +.Sh SEE ALSO +.Xr bcopy 3 , +.Xr memccpy 3 , +.Xr memmove 3 , +.Xr strcpy 3 +.Sh STANDARDS +The +.Fn memcpy +function +conforms to +.St -isoC . +.Sh BUGS +In this implementation +.Fn memcpy +is implemented using +.Xr bcopy 3 , +and therefore the strings may overlap. +On other systems, copying overlapping strings may produce surprises. +A simpler solution is to not use +.Fn memcpy . diff --git a/string/memmove.3 b/string/memmove.3 new file mode 100644 index 0000000..8f4f2cc --- /dev/null +++ b/string/memmove.3 @@ -0,0 +1,78 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)memmove.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/string/memmove.3,v 1.6 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt MEMMOVE 3 +.Os +.Sh NAME +.Nm memmove +.Nd copy byte string +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft void * +.Fn memmove "void *dst" "const void *src" "size_t len" +.Sh DESCRIPTION +The +.Fn memmove +function +copies +.Fa len +bytes from string +.Fa src +to string +.Fa dst . +The two strings may overlap; +the copy is always done in a non-destructive manner. +.Sh RETURN VALUES +The +.Fn memmove +function returns the original value of +.Fa dst . +.Sh SEE ALSO +.Xr bcopy 3 , +.Xr memccpy 3 , +.Xr memcpy 3 , +.Xr strcpy 3 +.Sh STANDARDS +The +.Fn memmove +function +conforms to +.St -isoC . diff --git a/string/memset.3 b/string/memset.3 new file mode 100644 index 0000000..3f1ba5e --- /dev/null +++ b/string/memset.3 @@ -0,0 +1,73 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)memset.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/string/memset.3,v 1.7 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt MEMSET 3 +.Os +.Sh NAME +.Nm memset +.Nd write a byte to byte string +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft void * +.Fn memset "void *b" "int c" "size_t len" +.Sh DESCRIPTION +The +.Fn memset +function +writes +.Fa len +bytes of value +.Fa c +(converted to an unsigned char) to the string +.Fa b . +.Sh RETURN VALUES +The +.Fn memset +function returns its first argument. +.Sh SEE ALSO +.Xr bzero 3 , +.Xr swab 3 +.Sh STANDARDS +The +.Fn memset +function +conforms to +.St -isoC . diff --git a/string.subproj/memset.c b/string/memset.c similarity index 99% rename from string.subproj/memset.c rename to string/memset.c index 6b0b3d8..1343d88 100644 --- a/string.subproj/memset.c +++ b/string/memset.c @@ -67,6 +67,8 @@ static char sccsid[] = "@(#)memset.c 8.1 (Berkeley) 6/4/93"; #define wsize sizeof(u_int) #define wmask (wsize - 1) +#ifndef __ppc__ + #ifdef BZERO #define RETURN return #define VAL 0 @@ -149,3 +151,4 @@ memset(dst0, c0, length) } while (--t != 0); RETURN; } +#endif /* __ppc__ */ diff --git a/string/rindex.3 b/string/rindex.3 new file mode 100644 index 0000000..d7e5d89 --- /dev/null +++ b/string/rindex.3 @@ -0,0 +1,85 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek. +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)rindex.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/string/rindex.3,v 1.6 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt RINDEX 3 +.Os +.Sh NAME +.Nm rindex +.Nd locate character in string +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft char * +.Fn rindex "const char *s" "int c" +.Sh DESCRIPTION +The +.Fn rindex +function +locates the last character +matching +.Fa c +(converted to a +.Em char ) +in the null-terminated string +.Fa s . +.Sh RETURN VALUES +A pointer to the character is returned if it is found; otherwise +NULL is returned. +If +.Fa c +is +.Ql \e0 , +.Fn rindex +locates the terminating +.Ql \e0 . +.Sh SEE ALSO +.Xr index 3 , +.Xr memchr 3 , +.Xr strchr 3 , +.Xr strcspn 3 , +.Xr strpbrk 3 , +.Xr strrchr 3 , +.Xr strsep 3 , +.Xr strspn 3 , +.Xr strstr 3 , +.Xr strtok 3 +.Sh HISTORY +A +.Fn rindex +function appeared in +.At v6 . diff --git a/string.subproj/rindex.c b/string/rindex.c similarity index 100% rename from string.subproj/rindex.c rename to string/rindex.c diff --git a/string.subproj/rindix.c b/string/rindix.c similarity index 100% rename from string.subproj/rindix.c rename to string/rindix.c diff --git a/string/strcasecmp.3 b/string/strcasecmp.3 new file mode 100644 index 0000000..f50cd5c --- /dev/null +++ b/string/strcasecmp.3 @@ -0,0 +1,97 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek. +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)strcasecmp.3 8.1 (Berkeley) 6/9/93 +.\" $FreeBSD: src/lib/libc/string/strcasecmp.3,v 1.9 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd June 9, 1993 +.Dt STRCASECMP 3 +.Os +.Sh NAME +.Nm strcasecmp , +.Nm strncasecmp +.Nd compare strings, ignoring case +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft int +.Fn strcasecmp "const char *s1" "const char *s2" +.Ft int +.Fn strncasecmp "const char *s1" "const char *s2" "size_t len" +.Sh DESCRIPTION +The +.Fn strcasecmp +and +.Fn strncasecmp +functions +compare the null-terminated strings +.Fa s1 +and +.Fa s2 . +.Pp +The +.Fn strncasecmp +compares at most +.Fa len +characters. +.Sh RETURN VALUES +The +.Fn strcasecmp +and +.Fn strncasecmp +return an integer greater than, equal to, or less than 0, +according as +.Fa s1 +is lexicographically greater than, equal to, or less than +.Fa s2 +after translation of each corresponding character to lower-case. +The strings themselves are not modified. +The comparison is done using unsigned characters, so that +.Sq Li \e200 +is greater than +.Ql \e0 . +.Sh SEE ALSO +.Xr bcmp 3 , +.Xr memcmp 3 , +.Xr strcmp 3 , +.Xr strcoll 3 , +.Xr strxfrm 3 , +.Xr tolower 3 +.Sh HISTORY +The +.Fn strcasecmp +and +.Fn strncasecmp +functions first appeared in +.Bx 4.4 . diff --git a/string.subproj/strcasecmp.c b/string/strcasecmp.c similarity index 100% rename from string.subproj/strcasecmp.c rename to string/strcasecmp.c diff --git a/string/strcat.3 b/string/strcat.3 new file mode 100644 index 0000000..e6e9b51 --- /dev/null +++ b/string/strcat.3 @@ -0,0 +1,101 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)strcat.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/string/strcat.3,v 1.9 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt STRCAT 3 +.Os +.Sh NAME +.Nm strcat +.Nd concatenate strings +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft char * +.Fn strcat "char *s" "const char *append" +.Ft char * +.Fn strncat "char *s" "const char *append" "size_t count" +.Sh DESCRIPTION +The +.Fn strcat +and +.Fn strncat +functions +append a copy of the null-terminated string +.Fa append +to the end of the null-terminated string +.Fa s , +then add a terminating +.Ql \e0 . +The string +.Fa s +must have sufficient space to hold the result. +.Pp +The +.Fn strncat +function +appends not more than +.Fa count +characters from +.Fa append , +and then adds a terminating +.Ql \e0 . +.Sh RETURN VALUES +The +.Fn strcat +and +.Fn strncat +functions +return the pointer +.Fa s . +.Sh SEE ALSO +.Xr bcopy 3 , +.Xr memccpy 3 , +.Xr memcpy 3 , +.Xr memmove 3 , +.Xr strcpy 3 , +.Xr strlcat 3 , +.Xr strlcpy 3 +.Sh STANDARDS +The +.Fn strcat +and +.Fn strncat +functions +conform to +.St -isoC . diff --git a/string/strchr.3 b/string/strchr.3 new file mode 100644 index 0000000..97be859 --- /dev/null +++ b/string/strchr.3 @@ -0,0 +1,88 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)strchr.3 8.2 (Berkeley) 4/19/94 +.\" $FreeBSD: src/lib/libc/string/strchr.3,v 1.8 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd April 19, 1994 +.Dt STRCHR 3 +.Os +.Sh NAME +.Nm strchr +.Nd locate character in string +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft char * +.Fn strchr "const char *s" "int c" +.Sh DESCRIPTION +The +.Fn strchr +function locates the first occurrence of +.Ar c +in the string pointed to by +.Ar s . +The terminating +.Dv NUL +character is considered part of the string. +If +.Fa c +is +.Ql \e0 , +.Fn strchr +locates the terminating +.Ql \e0 . +.Sh RETURN VALUES +The function +.Fn strchr +returns a pointer to the located character, or +.Dv NULL +if the character does not appear in the string. +.Sh SEE ALSO +.Xr memchr 3 , +.Xr strcspn 3 , +.Xr strpbrk 3 , +.Xr strrchr 3 , +.Xr strsep 3 , +.Xr strspn 3 , +.Xr strstr 3 , +.Xr strtok 3 +.Sh STANDARDS +The +.Fn strchr +function +conforms to +.St -isoC . diff --git a/string.subproj/strchr.c b/string/strchr.c similarity index 100% rename from string.subproj/strchr.c rename to string/strchr.c diff --git a/string/strcmp.3 b/string/strcmp.3 new file mode 100644 index 0000000..101d71b --- /dev/null +++ b/string/strcmp.3 @@ -0,0 +1,104 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)strcmp.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/string/strcmp.3,v 1.10 2001/10/11 17:02:44 mike Exp $ +.\" +.Dd October 11, 2001 +.Dt STRCMP 3 +.Os +.Sh NAME +.Nm strcmp , +.Nm strncmp +.Nd compare strings +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft int +.Fn strcmp "const char *s1" "const char *s2" +.Ft int +.Fn strncmp "const char *s1" "const char *s2" "size_t len" +.Sh DESCRIPTION +The +.Fn strcmp +and +.Fn strncmp +functions +lexicographically compare the null-terminated strings +.Fa s1 +and +.Fa s2 . +.Pp +The +.Fn strncmp +function +compares not more than +.Fa len +characters. +Because +.Fn strncmp +is designed for comparing strings rather than binary data, +characters that appear after a +.Ql \e0 +character are not compared. +.Sh RETURN VALUES +The +.Fn strcmp +and +.Fn strncmp +return an integer greater than, equal to, or less than 0, according +as the string +.Fa s1 +is greater than, equal to, or less than the string +.Fa s2 . +The comparison is done using unsigned characters, so that +.Ql \e200 +is greater than +.Ql \e0 . +.Sh SEE ALSO +.Xr bcmp 3 , +.Xr memcmp 3 , +.Xr strcasecmp 3 , +.Xr strcoll 3 , +.Xr strxfrm 3 +.Sh STANDARDS +The +.Fn strcmp +and +.Fn strncmp +functions +conform to +.St -isoC . diff --git a/string.subproj/strcmp.s b/string/strcmp.s similarity index 100% rename from string.subproj/strcmp.s rename to string/strcmp.s diff --git a/string/strcoll.3 b/string/strcoll.3 new file mode 100644 index 0000000..7617184 --- /dev/null +++ b/string/strcoll.3 @@ -0,0 +1,75 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)strcoll.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/string/strcoll.3,v 1.11 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt STRCOLL 3 +.Os +.Sh NAME +.Nm strcoll +.Nd compare strings according to current collation +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft int +.Fn strcoll "const char *s1" "const char *s2" +.Sh DESCRIPTION +The +.Fn strcoll +function +lexicographically compares the null-terminated strings +.Fa s1 +and +.Fa s2 +according to the current locale collation if any, otherwise call +.Fa strcmp , +and returns an integer greater than, equal to, or less than 0, +according as +.Fa s1 +is greater than, equal to, or less than +.Fa s2 . +.Sh SEE ALSO +.Xr setlocale 3 , +.Xr strcmp 3 , +.Xr strxfrm 3 +.Sh STANDARDS +The +.Fn strcoll +function +conforms to +.St -isoC . diff --git a/string.subproj/strcoll.c b/string/strcoll.c similarity index 100% rename from string.subproj/strcoll.c rename to string/strcoll.c diff --git a/string/strcpy.3 b/string/strcpy.3 new file mode 100644 index 0000000..2a06447 --- /dev/null +++ b/string/strcpy.3 @@ -0,0 +1,165 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)strcpy.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/string/strcpy.3,v 1.11 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd August 9, 2001 +.Dt STRCPY 3 +.Os +.Sh NAME +.Nm strcpy , strncpy +.Nd copy strings +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft char * +.Fn strcpy "char *dst" "const char *src" +.Ft char * +.Fn strncpy "char *dst" "const char *src" "size_t len" +.Sh DESCRIPTION +The +.Fn strcpy +function +copies the string +.Fa src +to +.Fa dst +(including the terminating +.Ql \e0 +character). +.Pp +The +.Fn strncpy +function copies not more than +.Fa len +characters from +.Fa src +into +.Fa dst , +appending +.Ql \e0 +characters if +.Fa src +is less than +.Fa len +characters long, and +.Em not +terminating +.Fa dst +otherwise. +.Sh RETURN VALUES +The +.Fn strcpy +and +.Fn strncpy +functions +return +.Fa dst . +.Sh EXAMPLES +The following sets +.Va chararray +to +.Dq Li abc\e0\e0\e0 : +.Bd -literal -offset indent +char chararray[6]; + +(void)strncpy(chararray, "abc", sizeof(chararray)); +.Ed +.Pp +The following sets +.Va chararray +to +.Dq Li abcdef : +.Bd -literal -offset indent +char chararray[6]; + +(void)strncpy(chararray, "abcdefgh", sizeof(chararray)); +.Ed +.Pp +Note that it does +.Em not +.Tn NUL +terminate +.Va chararray +because the length of the source string is greater than or equal +to the length parameter. +.Pp +The following copies as many characters from +.Va input +to +.Va buf +as will fit and +.Tn NUL +terminates the result. +Because +.Fn strncpy +does +.Em not +guarantee to +.Tn NUL +terminate the string itself, this must be done explicitly. +.Bd -literal -offset indent +char buf[1024]; + +(void)strncpy(buf, input, sizeof(buf) - 1); +buf[sizeof(buf) - 1] = '\e0'; +.Ed +.Pp +This could be better achieved using +.Xr strlcpy 3 , +as shown in the following example: +.Pp +.Dl "(void)strlcpy(buf, input, sizeof(buf));" +.Pp +Note that because +.Xr strlcpy 3 +is not defined in any standards, it should +only be used when portability is not a concern. +.Sh SEE ALSO +.Xr bcopy 3 , +.Xr memccpy 3 , +.Xr memcpy 3 , +.Xr memmove 3 , +.Xr strlcpy 3 +.Sh STANDARDS +The +.Fn strcpy +and +.Fn strncpy +functions +conform to +.St -isoC . diff --git a/string/strcspn.3 b/string/strcspn.3 new file mode 100644 index 0000000..c105c12 --- /dev/null +++ b/string/strcspn.3 @@ -0,0 +1,85 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)strcspn.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/string/strcspn.3,v 1.7 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt STRCSPN 3 +.Os +.Sh NAME +.Nm strcspn +.Nd span the complement of a string +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft size_t +.Fn strcspn "const char *s" "const char *charset" +.Sh DESCRIPTION +The +.Fn strcspn +function +spans the initial part of the null-terminated string +.Fa s +as long as the characters from +.Fa s +do not occur in string +.Fa charset +(it +spans the +.Em complement +of +.Fa charset ) . +.Sh RETURN VALUES +The +.Fn strcspn +function +returns the number of characters spanned. +.Sh SEE ALSO +.Xr memchr 3 , +.Xr strchr 3 , +.Xr strpbrk 3 , +.Xr strrchr 3 , +.Xr strsep 3 , +.Xr strspn 3 , +.Xr strstr 3 , +.Xr strtok 3 +.Sh STANDARDS +The +.Fn strcspn +function +conforms to +.St -isoC . diff --git a/string.subproj/strcspn.c b/string/strcspn.c similarity index 100% rename from string.subproj/strcspn.c rename to string/strcspn.c diff --git a/string/strdup.3 b/string/strdup.3 new file mode 100644 index 0000000..3bb2516 --- /dev/null +++ b/string/strdup.3 @@ -0,0 +1,70 @@ +.\" Copyright (c) 1990, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)strdup.3 8.1 (Berkeley) 6/9/93 +.\" $FreeBSD: src/lib/libc/string/strdup.3,v 1.10 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd June 9, 1993 +.Dt STRDUP 3 +.Os +.Sh NAME +.Nm strdup +.Nd save a copy of a string +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft char * +.Fn strdup "const char *str" +.Sh DESCRIPTION +The +.Fn strdup +function +allocates sufficient memory for a copy +of the string +.Fa str , +does the copy, and returns a pointer to it. +The pointer may subsequently be used as an +argument to the function +.Xr free 3 . +.Pp +If insufficient memory is available, NULL is returned and +.Va errno +is set to +.Er ENOMEM . +.Sh SEE ALSO +.Xr free 3 , +.Xr malloc 3 +.Sh HISTORY +The +.Fn strdup +function first appeared in +.Bx 4.4 . diff --git a/string.subproj/strdup.c b/string/strdup.c similarity index 100% rename from string.subproj/strdup.c rename to string/strdup.c diff --git a/string/strerror.3 b/string/strerror.3 new file mode 100644 index 0000000..c82aebf --- /dev/null +++ b/string/strerror.3 @@ -0,0 +1,130 @@ +.\" Copyright (c) 1980, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)strerror.3 8.1 (Berkeley) 6/9/93 +.\" $FreeBSD: src/lib/libc/string/strerror.3,v 1.12 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd June 9, 1993 +.Dt STRERROR 3 +.Os +.Sh NAME +.Nm perror , +.Nm strerror , +.Nm sys_errlist , +.Nm sys_nerr +.Nd system error messages +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In stdio.h +.Ft void +.Fn perror "const char *string" +.Vt extern const char * const sys_errlist[] ; +.Vt extern const int sys_nerr ; +.In string.h +.Ft char * +.Fn strerror "int errnum" +.Sh DESCRIPTION +The +.Fn strerror +and +.Fn perror +functions look up the error message string corresponding to an +error number. +.Pp +The +.Fn strerror +function accepts an error number argument +.Fa errnum +and +returns a pointer to the corresponding +message string. +.Pp +The +.Fn perror +function finds the error message corresponding to the current +value of the global variable +.Va errno +.Pq Xr intro 2 +and writes it, followed by a newline, to the +standard error file descriptor. +If the argument +.Fa string +is +.Pf non- Dv NULL +and does not point to the null character, +this string is prepended to the message +string and separated from it by +a colon and space +.Pq Ql \&:\ \& ; +otherwise, only the error message string is printed. +.Pp +If +.Fa errnum +is not a recognized error number, +the error message string will contain +.Dq Li "Unknown error:\ " +followed by the error number in decimal. +.Pp +The message strings can be accessed directly using the external +array +.Va sys_errlist . +The external value +.Va sys_nerr +contains a count of the messages in +.Va sys_errlist . +The use of these variables is deprecated; +.Fn strerror +should be used instead. +.Sh SEE ALSO +.Xr intro 2 , +.Xr psignal 3 +.Sh HISTORY +The +.Fn strerror +and +.Fn perror +functions first appeared in +.Bx 4.4 . +.Sh BUGS +For unknown error numbers, the +.Fn strerror +function will return its result in a static buffer which +may be overwritten by subsequent calls. +.Pp +Programs that use the deprecated +.Va sys_errlist +variable often fail to compile because they declare it +inconsistently. diff --git a/string.subproj/strerror.c b/string/strerror.c similarity index 100% rename from string.subproj/strerror.c rename to string/strerror.c diff --git a/string.subproj/strftime.c b/string/strftime.c similarity index 100% rename from string.subproj/strftime.c rename to string/strftime.c diff --git a/string/string.3 b/string/string.3 new file mode 100644 index 0000000..04e84bb --- /dev/null +++ b/string/string.3 @@ -0,0 +1,158 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek. +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)string.3 8.2 (Berkeley) 12/11/93 +.\" $FreeBSD: src/lib/libc/string/string.3,v 1.11 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd December 11, 1993 +.Dt STRING 3 +.Os +.Sh NAME +.Nm strcat , +.Nm strncat , +.Nm strchr , +.Nm strrchr , +.Nm strcmp , +.Nm strncmp , +.Nm strcasecmp , +.Nm strncasecmp , +.Nm strcpy , +.Nm strncpy , +.Nm strerror , +.Nm strlen , +.Nm strpbrk , +.Nm strsep , +.Nm strspn , +.Nm strcspn , +.Nm strstr , +.Nm strtok , +.Nm index , +.Nm rindex +.Nd string specific functions +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft char * +.Fn strcat "char *s" "const char * append" +.Ft char * +.Fn strncat "char *s" "const char *append" "size_t count" +.Ft char * +.Fn strchr "const char *s" "int c" +.Ft char * +.Fn strrchr "const char *s" "int c" +.Ft int +.Fn strcmp "const char *s1" "const char *s2" +.Ft int +.Fn strncmp "const char *s1" "const char *s2" "size_t count" +.Ft int +.Fn strcasecmp "const char *s1" "const char *s2" +.Ft int +.Fn strncasecmp "const char *s1" "const char *s2" "size_t count" +.Ft char * +.Fn strcpy "char *dst" "const char *src" +.Ft char * +.Fn strncpy "char *dst" "const char *src" "size_t count" +.Ft char * +.Fn strerror "int errno" +.Ft size_t +.Fn strlen "const char *s" +.Ft char * +.Fn strpbrk "const char *s" "const char *charset" +.Ft char * +.Fn strsep "char **stringp" "const char *delim" +.Ft size_t +.Fn strspn "const char *s" "const char *charset" +.Ft size_t +.Fn strcspn "const char *s" "const char *charset" +.Ft char * +.Fn strstr "const char *big" "const char *little" +.Ft char * +.Fn strtok "char *s" "const char *delim" +.Ft char * +.Fn index "const char *s" "int c" +.Ft char * +.Fn rindex "const char *s" "int c" +.Sh DESCRIPTION +The string +functions manipulate strings terminated by a +null byte. +.Pp +See the specific manual pages for more information. +For manipulating variable length generic objects as byte +strings (without the null byte check), see +.Xr bstring 3 . +.Pp +Except as noted in their specific manual pages, +the string functions do not test the destination +for size limitations. +.Sh SEE ALSO +.Xr bstring 3 , +.Xr index 3 , +.Xr rindex 3 , +.Xr strcasecmp 3 , +.Xr strcat 3 , +.Xr strchr 3 , +.Xr strcmp 3 , +.Xr strcpy 3 , +.Xr strcspn 3 , +.Xr strerror 3 , +.Xr strlen 3 , +.Xr strpbrk 3 , +.Xr strrchr 3 , +.Xr strsep 3 , +.Xr strspn 3 , +.Xr strstr 3 , +.Xr strtok 3 +.Sh STANDARDS +The +.Fn strcat , +.Fn strncat , +.Fn strchr , +.Fn strrchr , +.Fn strcmp , +.Fn strncmp , +.Fn strcpy , +.Fn strncpy , +.Fn strerror , +.Fn strlen , +.Fn strpbrk , +.Fn strsep , +.Fn strspn , +.Fn strcspn , +.Fn strstr , +and +.Fn strtok +functions +conform to +.St -isoC . diff --git a/string/strlcat.c b/string/strlcat.c new file mode 100644 index 0000000..7ec53b1 --- /dev/null +++ b/string/strlcat.c @@ -0,0 +1,74 @@ +/* + * Copyright (c) 1998 Todd C. Miller + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char *rcsid = "$OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp $"; +#endif /* LIBC_SCCS and not lint */ +#ifndef lint +static const char rcsid[] = + "$FreeBSD: src/lib/libc/string/strlcat.c,v 1.2.4.2 2001/07/09 23:30:06 obrien Exp $"; +#endif + +#include +#include + +/* + * Appends src to string dst of size siz (unlike strncat, siz is the + * full size of dst, not space left). At most siz-1 characters + * will be copied. Always NUL terminates (unless siz <= strlen(dst)). + * Returns strlen(initial dst) + strlen(src); if retval >= siz, + * truncation occurred. + */ +size_t strlcat(dst, src, siz) + char *dst; + const char *src; + size_t siz; +{ + register char *d = dst; + register const char *s = src; + register size_t n = siz; + size_t dlen; + + /* Find the end of dst and adjust bytes left but don't go past end */ + while (n-- != 0 && *d != '\0') + d++; + dlen = d - dst; + n = siz - dlen; + + if (n == 0) + return(dlen + strlen(s)); + while (*s != '\0') { + if (n != 1) { + *d++ = *s; + n--; + } + s++; + } + *d = '\0'; + + return(dlen + (s - src)); /* count does not include NUL */ +} diff --git a/string/strlcpy.3 b/string/strlcpy.3 new file mode 100644 index 0000000..60bb36b --- /dev/null +++ b/string/strlcpy.3 @@ -0,0 +1,201 @@ +.\" $OpenBSD: strlcpy.3,v 1.5 1999/06/06 15:17:32 aaron Exp $ +.\" +.\" Copyright (c) 1998 Todd C. Miller +.\" 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. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +.\" AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +.\" THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +.\" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +.\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +.\" OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" $FreeBSD: src/lib/libc/string/strlcpy.3,v 1.11 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd June 22, 1998 +.Dt STRLCPY 3 +.Os +.Sh NAME +.Nm strlcpy , +.Nm strlcat +.Nd size-bounded string copying and concatenation +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft size_t +.Fn strlcpy "char *dst" "const char *src" "size_t size" +.Ft size_t +.Fn strlcat "char *dst" "const char *src" "size_t size" +.Sh DESCRIPTION +The +.Fn strlcpy +and +.Fn strlcat +functions copy and concatenate strings respectively. They are designed +to be safer, more consistent, and less error prone replacements for +.Xr strncpy 3 +and +.Xr strncat 3 . +Unlike those functions, +.Fn strlcpy +and +.Fn strlcat +take the full size of the buffer (not just the length) and guarantee to +NUL-terminate the result (as long as +.Fa size +is larger than 0 or, in the case of +.Fn strlcat , +as long as there is at least one byte free in +.Fa dst ) . +Note that you should include a byte for the NUL in +.Fa size . +Also note that +.Fn strlcpy +and +.Fn strlcat +only operate on true +.Dq C +strings. +This means that for +.Fn strlcpy +.Fa src +must be NUL-terminated and for +.Fn strlcat +both +.Fa src +and +.Fa dst +must be NUL-terminated. +.Pp +The +.Fn strlcpy +function copies up to +.Fa size +- 1 characters from the NUL-terminated string +.Fa src +to +.Fa dst , +NUL-terminating the result. +.Pp +The +.Fn strlcat +function appends the NUL-terminated string +.Fa src +to the end of +.Fa dst . +It will append at most +.Fa size +- strlen(dst) - 1 bytes, NUL-terminating the result. +.Sh RETURN VALUES +The +.Fn strlcpy +and +.Fn strlcat +functions return the total length of the string they tried to +create. For +.Fn strlcpy +that means the length of +.Fa src . +For +.Fn strlcat +that means the initial length of +.Fa dst +plus +the length of +.Fa src . +While this may seem somewhat confusing it was done to make +truncation detection simple. +.Pp +Note however, that if +.Fn strlcat +traverses +.Fa size +characters without finding a NUL, the length of the string is considered +to be +.Fa size +and the destination string will not be NUL-terminated (since there was +no space for the NUL). +This keeps +.Fn strlcat +from running off the end of a string. +In practice this should not happen (as it means that either +.Fa size +is incorrect or that +.Fa dst +is not a proper +.Dq C +string). +The check exists to prevent potential security problems in incorrect code. +.Sh EXAMPLES +The following code fragment illustrates the simple case: +.Bd -literal -offset indent +char *s, *p, buf[BUFSIZ]; + +\&... + +(void)strlcpy(buf, s, sizeof(buf)); +(void)strlcat(buf, p, sizeof(buf)); +.Ed +.Pp +To detect truncation, perhaps while building a pathname, something +like the following might be used: +.Bd -literal -offset indent +char *dir, *file, pname[MAXPATHLEN]; + +\&... + +if (strlcpy(pname, dir, sizeof(pname)) >= sizeof(pname)) + goto toolong; +if (strlcat(pname, file, sizeof(pname)) >= sizeof(pname)) + goto toolong; +.Ed +.Pp +Since we know how many characters we copied the first time, we can +speed things up a bit by using a copy instead of an append: +.Bd -literal -offset indent +char *dir, *file, pname[MAXPATHLEN]; +size_t n; + +\&... + +n = strlcpy(pname, dir, sizeof(pname)); +if (n >= sizeof(pname)) + goto toolong; +if (strlcpy(pname + n, file, sizeof(pname) - n) >= sizeof(pname) - n) + goto toolong; +.Ed +.Pp +However, one may question the validity of such optimizations, as they +defeat the whole purpose of +.Fn strlcpy +and +.Fn strlcat . +As a matter of fact, the first version of this manual page got it wrong. +.Sh SEE ALSO +.Xr snprintf 3 , +.Xr strncat 3 , +.Xr strncpy 3 +.Sh HISTORY +.Fn strlcpy +and +.Fn strlcat +functions first appeared in +.Ox 2.4 , +and made their appearance in +.Fx 3.3 . diff --git a/string/strlcpy.c b/string/strlcpy.c new file mode 100644 index 0000000..9de9d32 --- /dev/null +++ b/string/strlcpy.c @@ -0,0 +1,74 @@ +/* $OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $ */ + +/* + * Copyright (c) 1998 Todd C. Miller + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +#if 0 +static char *rcsid = "$OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $"; +#endif +#endif /* LIBC_SCCS and not lint */ +#ifndef lint +static const char rcsid[] = + "$FreeBSD: src/lib/libc/string/strlcpy.c,v 1.2.4.1 2001/07/09 23:30:06 obrien Exp $"; +#endif + +#include +#include + +/* + * Copy src to string dst of size siz. At most siz-1 characters + * will be copied. Always NUL terminates (unless siz == 0). + * Returns strlen(src); if retval >= siz, truncation occurred. + */ +size_t strlcpy(dst, src, siz) + char *dst; + const char *src; + size_t siz; +{ + register char *d = dst; + register const char *s = src; + register size_t n = siz; + + /* Copy as many bytes as will fit */ + if (n != 0 && --n != 0) { + do { + if ((*d++ = *s++) == 0) + break; + } while (--n != 0); + } + + /* Not enough room in dst, add NUL and traverse rest of src */ + if (n == 0) { + if (siz != 0) + *d = '\0'; /* NUL-terminate dst */ + while (*s++) + ; + } + + return(s - src - 1); /* count does not include NUL */ +} diff --git a/string/strlen.3 b/string/strlen.3 new file mode 100644 index 0000000..b490ced --- /dev/null +++ b/string/strlen.3 @@ -0,0 +1,73 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)strlen.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/string/strlen.3,v 1.6 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt STRLEN 3 +.Os +.Sh NAME +.Nm strlen +.Nd find length of string +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft size_t +.Fn strlen "const char *s" +.Sh DESCRIPTION +The +.Fn strlen +function +computes the length of the string +.Fa s . +.Sh RETURN VALUES +The +.Fn strlen +function +returns +the number of characters that precede the +terminating +.Dv NUL +character. +.Sh SEE ALSO +.Xr string 3 +.Sh STANDARDS +The +.Fn strlen +function +conforms to +.St -isoC . diff --git a/string/strmode.3 b/string/strmode.3 new file mode 100644 index 0000000..b72171b --- /dev/null +++ b/string/strmode.3 @@ -0,0 +1,153 @@ +.\" Copyright (c) 1990, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)strmode.3 8.3 (Berkeley) 7/28/94 +.\" $FreeBSD: src/lib/libc/string/strmode.3,v 1.8 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd July 28, 1994 +.Dt STRMODE 3 +.Os +.Sh NAME +.Nm strmode +.Nd convert inode status information into a symbolic string +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft void +.Fn strmode "mode_t mode" "char *bp" +.Sh DESCRIPTION +The +.Fn strmode +function +converts a file +.Fa mode +(the type and permission information associated with an inode, see +.Xr stat 2 ) +into a symbolic string which is stored in the location referenced by +.Fa bp . +This stored string is eleven characters in length plus a trailing +.Dv NUL . +.Pp +The first character is the inode type, and will be one of the following: +.Pp +.Bl -tag -width flag -offset indent -compact +.It \- +regular file +.It b +block special +.It c +character special +.It d +directory +.It l +symbolic link +.It p +fifo +.It s +socket +.It w +whiteout +.It ? +unknown inode type +.El +.Pp +The next nine characters encode three sets of permissions, in three +characters each. +The first three characters are the permissions for the owner of the +file, the second three for the group the file belongs to, and the +third for the ``other'', or default, set of users. +.Pp +Permission checking is done as specifically as possible. +If read permission is denied to the owner of a file in the first set +of permissions, the owner of the file will not be able to read the file. +This is true even if the owner is in the file's group and the group +permissions allow reading or the ``other'' permissions allow reading. +.Pp +If the first character of the three character set is an ``r'', the file is +readable for that set of users; if a dash ``\-'', it is not readable. +.Pp +If the second character of the three character set is a ``w'', the file is +writable for that set of users; if a dash ``\-'', it is not writable. +.Pp +The third character is the first of the following characters that apply: +.Bl -tag -width xxxx +.It S +If the character is part of the owner permissions and the file is not +executable or the directory is not searchable by the owner, and the +set-user-id bit is set. +.It S +If the character is part of the group permissions and the file is not +executable or the directory is not searchable by the group, and the +set-group-id bit is set. +.It T +If the character is part of the other permissions and the file is not +executable or the directory is not searchable by others, and the ``sticky'' +.Pq Dv S_ISVTX +bit is set. +.It s +If the character is part of the owner permissions and the file is +executable or the directory searchable by the owner, and the set-user-id +bit is set. +.It s +If the character is part of the group permissions and the file is +executable or the directory searchable by the group, and the set-group-id +bit is set. +.It t +If the character is part of the other permissions and the file is +executable or the directory searchable by others, and the ``sticky'' +.Pq Dv S_ISVTX +bit is set. +.It x +The file is executable or the directory is searchable. +.It \- +None of the above apply. +.El +.Pp +The last character is a plus sign ``+'' if any there are any alternate +or additional access control methods associated with the inode, otherwise +it will be a space. +.Sh RETURN VALUES +The +.Fn strmode +function +always returns 0. +.Sh SEE ALSO +.Xr chmod 1 , +.Xr find 1 , +.Xr stat 2 , +.Xr getmode 3 , +.Xr setmode 3 +.Sh HISTORY +The +.Fn strmode +function first appeared in +.Bx 4.4 . diff --git a/string.subproj/strmode.c b/string/strmode.c similarity index 100% rename from string.subproj/strmode.c rename to string/strmode.c diff --git a/string/strpbrk.3 b/string/strpbrk.3 new file mode 100644 index 0000000..715bb71 --- /dev/null +++ b/string/strpbrk.3 @@ -0,0 +1,80 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)strpbrk.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/string/strpbrk.3,v 1.7 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt STRPBRK 3 +.Os +.Sh NAME +.Nm strpbrk +.Nd locate multiple characters in string +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft char * +.Fn strpbrk "const char *s" "const char *charset" +.Sh DESCRIPTION +The +.Fn strpbrk +function +locates in the null-terminated string +.Fa s +the first occurrence of any character in the string +.Fa charset +and returns a pointer to this character. +If no characters from +.Fa charset +occur anywhere in +.Fa s +.Fn strpbrk +returns NULL. +.Sh SEE ALSO +.Xr memchr 3 , +.Xr strchr 3 , +.Xr strcspn 3 , +.Xr strrchr 3 , +.Xr strsep 3 , +.Xr strspn 3 , +.Xr strstr 3 , +.Xr strtok 3 +.Sh STANDARDS +The +.Fn strpbrk +function +conforms to +.St -isoC . diff --git a/string.subproj/strpbrk.c b/string/strpbrk.c similarity index 100% rename from string.subproj/strpbrk.c rename to string/strpbrk.c diff --git a/string/strrchr.3 b/string/strrchr.3 new file mode 100644 index 0000000..785cbbf --- /dev/null +++ b/string/strrchr.3 @@ -0,0 +1,91 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)strrchr.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/string/strrchr.3,v 1.9 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt STRRCHR 3 +.Os +.Sh NAME +.Nm strrchr +.Nd locate character in string +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft char * +.Fn strrchr "const char *s" "int c" +.Sh DESCRIPTION +The +.Fn strrchr +function +locates the last occurrence of +.Fa c +(converted to a char) +in the string +.Fa s . +If +.Fa c +is +.Ql \e0 , +.Fn strrchr +locates the terminating +.Ql \e0 . +.Sh RETURN VALUES +The +.Fn strrchr +function +returns a pointer to the character, +or a null +pointer if +.Fa c +does not occur anywhere in +.Fa s . +.Sh SEE ALSO +.Xr memchr 3 , +.Xr strchr 3 , +.Xr strcspn 3 , +.Xr strpbrk 3 , +.Xr strsep 3 , +.Xr strspn 3 , +.Xr strstr 3 , +.Xr strtok 3 +.Sh STANDARDS +The +.Fn strrchr +function +conforms to +.St -isoC . diff --git a/string/strsep.3 b/string/strsep.3 new file mode 100644 index 0000000..3b5e3bc --- /dev/null +++ b/string/strsep.3 @@ -0,0 +1,121 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)strsep.3 8.1 (Berkeley) 6/9/93 +.\" $FreeBSD: src/lib/libc/string/strsep.3,v 1.11 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd June 9, 1993 +.Dt STRSEP 3 +.Os +.Sh NAME +.Nm strsep +.Nd separate strings +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft char * +.Fn strsep "char **stringp" "const char *delim" +.Sh DESCRIPTION +The +.Fn strsep +function locates, in the string referenced by +.Fa *stringp , +the first occurrence of any character in the string +.Fa delim +(or the terminating +.Ql \e0 +character) and replaces it with a +.Ql \e0 . +The location of the next character after the delimiter character +(or NULL, if the end of the string was reached) is stored in +.Fa *stringp . +The original value of +.Fa *stringp +is returned. +.Pp +An ``empty'' field, i.e. one caused by two adjacent delimiter characters, +can be detected by comparing the location referenced by the pointer returned +in +.Fa *stringp +to +.Ql \e0 . +.Pp +If +.Fa *stringp +is initially +.Dv NULL , +.Fn strsep +returns +.Dv NULL . +.Sh EXAMPLES +The following uses +.Fn strsep +to parse a string, containing tokens delimited by white space, into an +argument vector: +.Bd -literal -offset indent +char **ap, *argv[10], *inputstring; + +for (ap = argv; (*ap = strsep(&inputstring, " \et")) != NULL;) + if (**ap != '\e0') + if (++ap >= &argv[10]) + break; +.Ed +.Sh SEE ALSO +.Xr memchr 3 , +.Xr strchr 3 , +.Xr strcspn 3 , +.Xr strpbrk 3 , +.Xr strrchr 3 , +.Xr strspn 3 , +.Xr strstr 3 , +.Xr strtok 3 +.Sh HISTORY +The +.Fn strsep +function +is intended as a replacement for the +.Fn strtok +function. +While the +.Fn strtok +function should be preferred for portability reasons (it conforms to +.St -isoC ) +it is unable to handle empty fields, i.e. detect fields delimited by +two adjacent delimiter characters, or to be used for more than a single +string at a time. +The +.Fn strsep +function first appeared in +.Bx 4.4 . diff --git a/string.subproj/strsep.c b/string/strsep.c similarity index 100% rename from string.subproj/strsep.c rename to string/strsep.c diff --git a/string/strspn.3 b/string/strspn.3 new file mode 100644 index 0000000..b55b12c --- /dev/null +++ b/string/strspn.3 @@ -0,0 +1,80 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)strspn.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/string/strspn.3,v 1.8 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt STRSPN 3 +.Os +.Sh NAME +.Nm strspn +.Nd span a string +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft size_t +.Fn strspn "const char *s" "const char *charset" +.Sh DESCRIPTION +The +.Fn strspn +function +spans the initial part of the null-terminated string +.Fa s +as long as the characters from +.Fa s +occur in string +.Fa charset . +.Sh RETURN VALUES +The +.Fn strspn +function +returns the number of characters spanned. +.Sh SEE ALSO +.Xr memchr 3 , +.Xr strchr 3 , +.Xr strcspn 3 , +.Xr strpbrk 3 , +.Xr strrchr 3 , +.Xr strsep 3 , +.Xr strstr 3 , +.Xr strtok 3 +.Sh STANDARDS +The +.Fn strspn +function +conforms to +.St -isoC . diff --git a/string.subproj/strspn.c b/string/strspn.c similarity index 100% rename from string.subproj/strspn.c rename to string/strspn.c diff --git a/string/strstr.3 b/string/strstr.3 new file mode 100644 index 0000000..433f26c --- /dev/null +++ b/string/strstr.3 @@ -0,0 +1,144 @@ +.\" Copyright (c) 2001 Mike Barcroft +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)strstr.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/string/strstr.3,v 1.11 2001/10/11 15:49:06 mike Exp $ +.\" +.Dd October 11, 2001 +.Dt STRSTR 3 +.Os +.Sh NAME +.Nm strstr , strcasestr , strnstr +.Nd locate a substring in a string +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft char * +.Fn strstr "const char *big" "const char *little" +.Ft char * +.Fn strcasestr "const char *big" "const char *little" +.Ft char * +.Fn strnstr "const char *big" "const char *little" "size_t len" +.Sh DESCRIPTION +The +.Fn strstr +function +locates the first occurrence of the null-terminated string +.Fa little +in the null-terminated string +.Fa big . +.Pp +The +.Fn strcasestr +function is similar to +.Fn strstr , +but ignores the case of both strings. +.Pp +The +.Fn strnstr +function +locates the first occurrence of the null-terminated string +.Fa little +in the string +.Fa big , +where not more than +.Fa len +characters are searched. +Characters that appear after a +.Ql \e0 +character are not searched. +Since the +.Fn strnstr +function is a +.Fx +specific API, it should only be used when portablility is not a concern. +.Sh RETURN VALUES +If +.Fa little +is an empty string, +.Fa big +is returned; +if +.Fa little +occurs nowhere in +.Fa big , +NULL is returned; +otherwise a pointer to the first character of the first occurrence of +.Fa little +is returned. +.Sh EXAMPLES +The following sets the pointer +.Va ptr +to the +.Dq Li Bar Baz +portion of +.Va largestring : +.Bd -literal -offset indent +const char *largestring = "Foo Bar Baz"; +const char *smallstring = "Bar"; +char *ptr; + +ptr = strstr(largestring, smallstring); +.Ed +.Pp +The following sets the pointer +.Va ptr +to NULL, because only the first 4 characters of +.Va largestring +are searched: +.Bd -literal -offset indent +const char *largestring = "Foo Bar Baz"; +const char *smallstring = "Bar"; +char *ptr; + +ptr = strnstr(largestring, smallstring, 4); +.Ed +.Sh SEE ALSO +.Xr memchr 3 , +.Xr strchr 3 , +.Xr strcspn 3 , +.Xr strpbrk 3 , +.Xr strrchr 3 , +.Xr strsep 3 , +.Xr strspn 3 , +.Xr strtok 3 +.Sh STANDARDS +The +.Fn strstr +function +conforms to +.St -isoC . diff --git a/string.subproj/strstr.c b/string/strstr.c similarity index 100% rename from string.subproj/strstr.c rename to string/strstr.c diff --git a/string/strtok.3 b/string/strtok.3 new file mode 100644 index 0000000..bc90987 --- /dev/null +++ b/string/strtok.3 @@ -0,0 +1,175 @@ +.\" Copyright (c) 1998 Softweyr LLC. All rights reserved. +.\" +.\" strtok_r, from Berkeley strtok +.\" Oct 13, 1998 by Wes Peters +.\" +.\" Copyright (c) 1988, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" 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 +.\" notices, this list of conditions and the following disclaimer. +.\" +.\" 2. Redistributions in binary form must reproduce the above +.\" copyright notices, this list of conditions and the following +.\" disclaimer in the documentation and/or other materials provided +.\" with the distribution. +.\" +.\" 3. All advertising materials mentioning features or use of this +.\" software must display the following acknowledgement: +.\" +.\" This product includes software developed by Softweyr LLC, the +.\" University of California, Berkeley, and its contributors. +.\" +.\" 4. Neither the name of Softweyr LLC, 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 SOFTWEYR LLC, 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 SOFTWEYR LLC, 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. +.\" +.\" @(#)strtok.3 8.2 (Berkeley) 2/3/94 +.\" $FreeBSD: src/lib/libc/string/strtok.3,v 1.22 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd November 27, 1998 +.Dt STRTOK 3 +.Os +.Sh NAME +.Nm strtok , strtok_r +.Nd string tokens +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft char * +.Fn strtok "char *str" "const char *sep" +.Ft char * +.Fn strtok_r "char *str" "const char *sep" "char **last" +.Sh DESCRIPTION +.Bf -symbolic +This interface is obsoleted by +.Xr strsep 3 . +.Ef +.Pp +The +.Fn strtok +function +is used to isolate sequential tokens in a null-terminated string, +.Fa str . +These tokens are separated in the string by at least one of the +characters in +.Fa sep . +The first time that +.Fn strtok +is called, +.Fa str +should be specified; subsequent calls, wishing to obtain further tokens +from the same string, should pass a null pointer instead. +The separator string, +.Fa sep , +must be supplied each time, and may change between calls. +.Pp +The implementation will behave as if no library function calls +.Fn strtok . +.Pp +The +.Fn strtok_r +function is a reentrant version of +.Fn strtok . +The context pointer +.Fa last +must be provided on each call. +.Fn strtok_r +may also be used to nest two parsing loops within one another, as +long as separate context pointers are used. +.Pp +The +.Fn strtok +and +.Fn strtok_r +functions +return a pointer to the beginning of each subsequent token in the string, +after replacing the token itself with a +.Dv NUL +character. +When no more tokens remain, a null pointer is returned. +.Sh EXAMPLES +The following uses +.Fn strtok_r +to parse two strings using separate contexts: +.Bd -literal +char test[80], blah[80]; +char *sep = "\e\e/:;=-"; +char *word, *phrase, *brkt, *brkb; + +strcpy(test, "This;is.a:test:of=the/string\e\etokenizer-function."); + +for (word = strtok_r(test, sep, &brkt); + word; + word = strtok_r(NULL, sep, &brkt)) +{ + strcpy(blah, "blah:blat:blab:blag"); + + for (phrase = strtok_r(blah, sep, &brkb); + phrase; + phrase = strtok_r(NULL, sep, &brkb)) + { + printf("So far we're at %s:%s\en", word, phrase); + } +} +.Ed +.Sh SEE ALSO +.Xr memchr 3 , +.Xr strchr 3 , +.Xr strcspn 3 , +.Xr strpbrk 3 , +.Xr strrchr 3 , +.Xr strsep 3 , +.Xr strspn 3 , +.Xr strstr 3 +.Sh STANDARDS +The +.Fn strtok +function +conforms to +.St -isoC . +.Sh BUGS +The System V +.Fn strtok , +if handed a string containing only delimiter characters, +will not alter the next starting point, so that a call to +.Fn strtok +with a different (or empty) delimiter string +may return a +.Pf non- Dv NULL +value. +Since this implementation always alters the next starting point, +such a sequence of calls would always return +.Dv NULL . +.Sh AUTHORS +.An Wes Peters , +Softweyr LLC: +.Aq wes@softweyr.com +.Pp +Based on the +.Fx 3.0 +implementation. diff --git a/string/strtok.c b/string/strtok.c new file mode 100644 index 0000000..1dfa6ad --- /dev/null +++ b/string/strtok.c @@ -0,0 +1,168 @@ +/* + * Copyright (c) 1998 Softweyr LLC. All rights reserved. + * + * strtok_r, from Berkeley strtok + * Oct 13, 1998 by Wes Peters + * + * Copyright (c) 1988, 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 + * notices, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notices, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * + * This product includes software developed by Softweyr LLC, the + * University of California, Berkeley, and its contributors. + * + * 4. 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 SOFTWEYR LLC, 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 SOFTWEYR LLC, 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 const char rcsid[] = + "$FreeBSD: src/lib/libc/string/strtok.c,v 1.2.6.1 2001/07/09 23:30:07 obrien Exp $"; +#endif + +#include +#include + +char * +strtok_r(char *s, const char *delim, char **last) +{ + char *spanp; + int c, sc; + char *tok; + + if (s == NULL && (s = *last) == NULL) + { + return NULL; + } + + /* + * Skip (span) leading delimiters (s += strspn(s, delim), sort of). + */ +cont: + c = *s++; + for (spanp = (char *)delim; (sc = *spanp++) != 0; ) + { + if (c == sc) + { + goto cont; + } + } + + if (c == 0) /* no non-delimiter characters */ + { + *last = NULL; + return NULL; + } + tok = s - 1; + + /* + * Scan token (scan for delimiters: s += strcspn(s, delim), sort of). + * Note that delim must have one NUL; we stop if we see that, too. + */ + for (;;) + { + c = *s++; + spanp = (char *)delim; + do + { + if ((sc = *spanp++) == c) + { + if (c == 0) + { + s = NULL; + } + else + { + char *w = s - 1; + *w = '\0'; + } + *last = s; + return tok; + } + } + while (sc != 0); + } + /* NOTREACHED */ +} + + +char * +strtok(char *s, const char *delim) +{ + static char *last; + + return strtok_r(s, delim, &last); +} + + +#if defined(DEBUG_STRTOK) + +/* + * Test the tokenizer. + */ +int +main() +{ + char test[80], blah[80]; + char *sep = "\\/:;=-"; + char *word, *phrase, *brkt, *brkb; + + printf("String tokenizer test:\n"); + + strcpy(test, "This;is.a:test:of=the/string\\tokenizer-function."); + + for (word = strtok(test, sep); + word; + word = strtok(NULL, sep)) + { + printf("Next word is \"%s\".\n", word); + } + + phrase = "foo"; + + strcpy(test, "This;is.a:test:of=the/string\\tokenizer-function."); + + for (word = strtok_r(test, sep, &brkt); + word; + word = strtok_r(NULL, sep, &brkt)) + { + strcpy(blah, "blah:blat:blab:blag"); + + for (phrase = strtok_r(blah, sep, &brkb); + phrase; + phrase = strtok_r(NULL, sep, &brkb)) + { + printf("So far we're at %s:%s\n", word, phrase); + } + } + + return 0; +} + +#endif /* DEBUG_STRTOK */ diff --git a/string/strxfrm.3 b/string/strxfrm.3 new file mode 100644 index 0000000..f291222 --- /dev/null +++ b/string/strxfrm.3 @@ -0,0 +1,99 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)strxfrm.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/string/strxfrm.3,v 1.14 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt STRXFRM 3 +.Os +.Sh NAME +.Nm strxfrm +.Nd transform a string under locale +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft size_t +.Fn strxfrm "char *dst" "const char *src" "size_t n" +.Sh DESCRIPTION +The +.Fn strxfrm +function transforms a null-terminated string pointed to by +.Fa src +according to the current locale collation if any, +then copies the transformed string +into +.Fa dst . +Not more than +.Fa n +characters are copied into +.Fa dst , +including the terminating null character added. +If +.Fa n +is set to 0 +(it helps to determine an actual size needed +for transformation), +.Fa dst +is permitted to be a NULL pointer. +.Pp +Comparing two strings using +.Fn strcmp +after +.Fn strxfrm +is equal to comparing +two original strings with +.Fn strcoll . +.Sh RETURN VALUES +Upon successful completion, +.Fn strxfrm +returns the length of the transformed string not including +the terminating null character. +If this value is +.Fa n +or more, the contents of +.Fa dst +are indeterminate. +.Sh SEE ALSO +.Xr setlocale 3 , +.Xr strcmp 3 , +.Xr strcoll 3 +.Sh STANDARDS +The +.Fn strxfrm +function +conforms to +.St -isoC . diff --git a/string.subproj/strxfrm.c b/string/strxfrm.c similarity index 100% rename from string.subproj/strxfrm.c rename to string/strxfrm.c diff --git a/string/swab.3 b/string/swab.3 new file mode 100644 index 0000000..fffd7cd --- /dev/null +++ b/string/swab.3 @@ -0,0 +1,68 @@ +.\" Copyright (c) 1990, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)swab.3 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/string/swab.3,v 1.6 2001/10/01 16:09:00 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt SWAB 3 +.Os +.Sh NAME +.Nm swab +.Nd swap adjacent bytes +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In string.h +.Ft void +.Fn swab "const void *src" "void *dst" "size_t len" +.Sh DESCRIPTION +The function +.Fn swab +copies +.Fa len +bytes from the location referenced by +.Fa src +to the location referenced by +.Fa dst , +swapping adjacent bytes. +.Pp +The argument +.Fa len +must be an even number. +.Sh SEE ALSO +.Xr bzero 3 , +.Xr memset 3 +.Sh HISTORY +A +.Fn swab +function appeared in +.At v7 . diff --git a/string.subproj/swab.c b/string/swab.c similarity index 100% rename from string.subproj/swab.c rename to string/swab.c diff --git a/string/wmemchr.3 b/string/wmemchr.3 new file mode 100644 index 0000000..cb41fc2 --- /dev/null +++ b/string/wmemchr.3 @@ -0,0 +1,145 @@ +.\" $NetBSD: wmemchr.3,v 1.4 2001/01/02 11:26:23 itojun Exp $ +.\" +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" from: @(#)strcpy.3 8.1 (Berkeley) 6/4/93 +.\" +.\" $FreeBSD: src/lib/libc/string/wmemchr.3,v 1.5 2001/10/03 05:19:47 bde Exp $ +.\" +.Dd December 22, 2000 +.Dt WMEMCHR 3 +.Os +.Sh NAME +.Nm wmemchr , +.Nm wmemcmp , +.Nm wmemcpy , +.Nm wmemmove , +.Nm wmemset , +.Nm wcscat , +.Nm wcschr , +.Nm wcscmp , +.Nm wcscpy , +.Nm wcscspn , +.Nm wcslcat , +.Nm wcslcpy , +.Nm wcslen , +.Nm wcsncat , +.Nm wcsncmp , +.Nm wcsncpy , +.Nm wcspbrk , +.Nm wcsrchr , +.Nm wcsspn , +.Nm wcsstr +.Nd wide character string manipulation operations +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In wchar.h +.Ft wchar_t * +.Fn wmemchr "const wchar_t *s" "wchar_t c" "size_t n" +.Ft int +.Fn wmemcmp "const wchar_t *s1" "const wchar_t *s2" "size_t n" +.Ft wchar_t * +.Fn wmemcpy "wchar_t *s1" "const wchar_t *s2" "size_t n" +.Ft wchar_t * +.Fn wmemmove "wchar_t *s1" "const wchar_t *s2" "size_t n" +.Ft wchar_t * +.Fn wmemset "wchar_t *s" "wchar_t c" "size_t n" +.Ft wchar_t * +.Fn wcscat "wchar_t *s1" "const wchar_t *s2" +.Ft wchar_t * +.Fn wcschr "const wchar_t *s" "wchar_t c" +.Ft int +.Fn wcscmp "const wchar_t *s1" "const wchar_t *s2" +.Ft wchar_t * +.Fn wcscpy "wchar_t *s1" "const wchar_t *s2" +.Ft size_t +.Fn wcscspn "const wchar_t *s1" "const wchar_t *s2" +.Ft size_t +.Fn wcslcat "wchar_t *s1" "const wchar_t *s2" "size_t n" +.Ft size_t +.Fn wcslcpy "wchar_t *s1" "const wchar_t *s2" "size_t n" +.Ft size_t +.Fn wcslen "const wchar_t *s" +.Ft wchar_t * +.Fn wcsncat "wchar_t *s1" "const wchar_t *s2" "size_t n" +.Ft int +.Fn wcsncmp "const wchar_t *s1" "const wchar_t * s2" "size_t n" +.Ft wchar_t * +.Fn wcsncpy "wchar_t *s1" "const wchar_t *s2" "size_t n" +.Ft wchar_t * +.Fn wcspbrk "const wchar_t *s1" "const wchar_t *s2" +.Ft wchar_t * +.Fn wcsrchr "const wchar_t *s" "wchar_t c" +.Ft size_t +.Fn wcsspn "const wchar_t *s1" "const wchar_t *s2" +.Ft wchar_t * +.Fn wcsstr "const wchar_t *s1" "const wchar_t *s2" +.Sh DESCRIPTION +The functions implement string manipulation operations over wide character +strings. +For a detailed description, refer to documents for the respective single-byte +counterpart, such as +.Xr memchr 3 . +.Sh SEE ALSO +.Xr memchr 3 , +.Xr memcmp 3 , +.Xr memcpy 3 , +.Xr memmove 3 , +.Xr memset 3 , +.Xr strcat 3 , +.Xr strchr 3 , +.Xr strcmp 3 , +.Xr strcpy 3 , +.Xr strcspn 3 , +.Xr strlcat 3 , +.Xr strlcpy 3 , +.Xr strlen 3 , +.Xr strncat 3 , +.Xr strncmp 3 , +.Xr strncpy 3 , +.Xr strpbrk 3 , +.Xr strrchr 3 , +.Xr strspn 3 , +.Xr strstr 3 +.Sh STANDARDS +These functions conform to +.St -isoC-99 , +with the exception of +.Fn wcslcat +and +.Fn wcslcpy , +which are extensions. diff --git a/sys.subproj/Makefile b/sys.subproj/Makefile deleted file mode 100644 index 705fdfa..0000000 --- a/sys.subproj/Makefile +++ /dev/null @@ -1,52 +0,0 @@ -# -# Generated by the Apple Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = sys - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -HFILES = sigcatch.h - -CFILES = errno.c getdtablesize.c gettimeofday.c sigaction.c sigcatch.c\ - sigprocmask.c sigsuspend.c sigtramp.c - -SUBPROJECTS = i386.subproj ppc.subproj - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble msync.2\ - sem_close.2 sem_open.2 sem_post.2 sem_trywait.2\ - sem_unlink.2 sem_wait.2 shm_open.2 shm_unlink.2 - - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - - - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/sys.subproj/Makefile.postamble b/sys.subproj/Makefile.postamble deleted file mode 100644 index 6b33f70..0000000 --- a/sys.subproj/Makefile.postamble +++ /dev/null @@ -1,106 +0,0 @@ -############################################################################### -# Makefile.postamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile, which is imported after all other makefiles, to -# override attributes for a project's Makefile environment. This allows you -# to take advantage of the environment set up by the other Makefiles. -# You can also define custom rules at the end of this file. -# -############################################################################### -# -# These variables are exported by the standard makefiles and can be -# used in any customizations you make. They are *outputs* of -# the Makefiles and should be used, not set. -# -# PRODUCTS: products to install. All of these products will be placed in -# the directory $(DSTROOT)$(INSTALLDIR) -# GLOBAL_RESOURCE_DIR: The directory to which resources are copied. -# LOCAL_RESOURCE_DIR: The directory to which localized resources are copied. -# OFILE_DIR: Directory into which .o object files are generated. -# DERIVED_SRC_DIR: Directory used for all other derived files -# -# ALL_CFLAGS: flags to pass when compiling .c files -# ALL_MFLAGS: flags to pass when compiling .m files -# ALL_CCFLAGS: flags to pass when compiling .cc, .cxx, and .C files -# ALL_MMFLAGS: flags to pass when compiling .mm, .mxx, and .M files -# ALL_PRECOMPFLAGS: flags to pass when precompiling .h files -# ALL_LDFLAGS: flags to pass when linking object files -# ALL_LIBTOOL_FLAGS: flags to pass when libtooling object files -# ALL_PSWFLAGS: flags to pass when processing .psw and .pswm (pswrap) files -# ALL_RPCFLAGS: flags to pass when processing .rpc (rpcgen) files -# ALL_YFLAGS: flags to pass when processing .y (yacc) files -# ALL_LFLAGS: flags to pass when processing .l (lex) files -# -# NAME: name of application, bundle, subproject, palette, etc. -# LANGUAGES: langages in which the project is written (default "English") -# English_RESOURCES: localized resources (e.g. nib's, images) of project -# GLOBAL_RESOURCES: non-localized resources of project -# -# SRCROOT: base directory in which to place the new source files -# SRCPATH: relative path from SRCROOT to present subdirectory -# -# INSTALLDIR: Directory the product will be installed into by 'install' target -# PUBLIC_HDR_INSTALLDIR: where to install public headers. Don't forget -# to prefix this with DSTROOT when you use it. -# PRIVATE_HDR_INSTALLDIR: where to install private headers. Don't forget -# to prefix this with DSTROOT when you use it. -# -# EXECUTABLE_EXT: Executable extension for the platform (i.e. .exe on Windows) -# -############################################################################### - -# Some compiler flags can be overridden here for certain build situations. -# -# WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost) -# DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults -# to -g) -# DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG) -# OPTIMIZE_BUILD_CFLAGS: flags passed during optimized builds (defaults -# to -O) -# PROFILE_BUILD_CFLAGS: flags passed during profile builds (defaults -# to -pg -DPROFILE) -# LOCAL_DIR_INCLUDE_DIRECTIVE: flag used to add current directory to -# the include path (defaults to -I.) -# DEBUG_BUILD_LDFLAGS, OPTIMIZE_BUILD_LDFLAGS, PROFILE_BUILD_LDFLAGS: flags -# passed to ld/libtool (defaults to nothing) - - -# Library and Framework projects only: -# INSTALL_NAME_DIRECTIVE: This directive ensures that executables linked -# against the framework will run against the correct version even if -# the current version of the framework changes. You may override this -# to "" as an alternative to using the DYLD_LIBRARY_PATH during your -# development cycle, but be sure to restore it before installing. - - -# Ownership and permissions of files installed by 'install' target - -#INSTALL_AS_USER = root - # User/group ownership -#INSTALL_AS_GROUP = wheel - # (probably want to set both of these) -#INSTALL_PERMISSIONS = - # If set, 'install' chmod's executable to this - - -# Options to strip. Note: -S strips debugging symbols (executables can be stripped -# down further with -x or, if they load no bundles, with no options at all). - -#STRIPFLAGS = -S - - -######################################################################### -# Put rules to extend the behavior of the standard Makefiles here. Include them in -# the dependency tree via cvariables like AFTER_INSTALL in the Makefile.preamble. -# -# You should avoid redefining things like "install" or "app", as they are -# owned by the top-level Makefile API and no context has been set up for where -# derived files should go. -# - -MAN2DIR=/usr/share/man/man2 - -install-man: - install -m 755 -d $(DSTROOT)$(MAN2DIR) - install -m 444 -c *.2 $(DSTROOT)$(MAN2DIR) diff --git a/sys.subproj/Makefile.preamble b/sys.subproj/Makefile.preamble deleted file mode 100644 index eda7efc..0000000 --- a/sys.subproj/Makefile.preamble +++ /dev/null @@ -1,139 +0,0 @@ -############################################################################### -# Makefile.preamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile for configuring the standard application makefiles -# associated with ProjectBuilder. It is included before the main makefile. -# In Makefile.preamble you set attributes for a project, so they are available -# to the project's makefiles. In contrast, you typically write additional rules or -# override built-in behavior in the Makefile.postamble. -# -# Each directory in a project tree (main project plus subprojects) should -# have its own Makefile.preamble and Makefile.postamble. -############################################################################### -# -# Before the main makefile is included for this project, you may set: -# -# MAKEFILEDIR: Directory in which to find $(MAKEFILE) -# MAKEFILE: Top level mechanism Makefile (e.g., app.make, bundle.make) - -# Compiler/linker flags added to the defaults: The OTHER_* variables will be -# inherited by all nested sub-projects, but the LOCAL_ versions of the same -# variables will not. Put your -I, -D, -U, and -L flags in ProjectBuilder's -# Build Attributes inspector if at all possible. To override the default flags -# that get passed to ${CC} (e.g. change -O to -O2), see Makefile.postamble. The -# variables below are *inputs* to the build process and distinct from the override -# settings done (less often) in the Makefile.postamble. -# -# OTHER_CFLAGS, LOCAL_CFLAGS: additional flags to pass to the compiler -# Note that $(OTHER_CFLAGS) and $(LOCAL_CFLAGS) are used for .h, ...c, .m, -# .cc, .cxx, .C, and .M files. There is no need to respecify the -# flags in OTHER_MFLAGS, etc. -# OTHER_MFLAGS, LOCAL_MFLAGS: additional flags for .m files -# OTHER_CCFLAGS, LOCAL_CCFLAGS: additional flags for .cc, .cxx, and ...C files -# OTHER_MMFLAGS, LOCAL_MMFLAGS: additional flags for .mm and .M files -# OTHER_PRECOMPFLAGS, LOCAL_PRECOMPFLAGS: additional flags used when -# precompiling header files -# OTHER_LDFLAGS, LOCAL_LDFLAGS: additional flags passed to ld and libtool -# OTHER_PSWFLAGS, LOCAL_PSWFLAGS: additional flags passed to pswrap -# OTHER_RPCFLAGS, LOCAL_RPCFLAGS: additional flags passed to rpcgen -# OTHER_YFLAGS, LOCAL_YFLAGS: additional flags passed to yacc -# OTHER_LFLAGS, LOCAL_LFLAGS: additional flags passed to lex - -# These variables provide hooks enabling you to add behavior at almost every -# stage of the make: -# -# BEFORE_PREBUILD: targets to build before installing headers for a subproject -# AFTER_PREBUILD: targets to build after installing headers for a subproject -# BEFORE_BUILD_RECURSION: targets to make before building subprojects -# BEFORE_BUILD: targets to make before a build, but after subprojects -# AFTER_BUILD: targets to make after a build -# -# BEFORE_INSTALL: targets to build before installing the product -# AFTER_INSTALL: targets to build after installing the product -# BEFORE_POSTINSTALL: targets to build before postinstalling every subproject -# AFTER_POSTINSTALL: targts to build after postinstalling every subproject -# -# BEFORE_INSTALLHDRS: targets to build before installing headers for a -# subproject -# AFTER_INSTALLHDRS: targets to build after installing headers for a subproject -# BEFORE_INSTALLSRC: targets to build before installing source for a subproject -# AFTER_INSTALLSRC: targets to build after installing source for a subproject -# -# BEFORE_DEPEND: targets to build before building dependencies for a -# subproject -# AFTER_DEPEND: targets to build after building dependencies for a -# subproject -# -# AUTOMATIC_DEPENDENCY_INFO: if YES, then the dependency file is -# updated every time the project is built. If NO, the dependency -# file is only built when the depend target is invoked. - -AFTER_POSTINSTALL = install-man - -# Framework-related variables: -# FRAMEWORK_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the framework's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables - -# Library-related variables: -# PUBLIC_HEADER_DIR: Determines where public exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. For library projects you should -# set this to something like /Developer/Headers/$(NAME). Do not set -# this variable for framework projects unless you do not want the -# header files included in the framework. -# PRIVATE_HEADER_DIR: Determines where private exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. -# LIBRARY_STYLE: This may be either STATIC or DYNAMIC, and determines -# whether the libraries produced are statically linked when they -# are used or if they are dynamically loadable. This defaults to -# DYNAMIC. -# LIBRARY_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the library's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables -# -# INSTALL_AS_USER: owner of the intalled products (default root) -# INSTALL_AS_GROUP: group of the installed products (default wheel) -# INSTALL_PERMISSIONS: permissions of the installed product (default o+rX) -# -# OTHER_RECURSIVE_VARIABLES: The names of variables which you want to be -# passed on the command line to recursive invocations of make. Note that -# the values in OTHER_*FLAGS are inherited by subprojects automatically -- -# you do not have to (and shouldn't) add OTHER_*FLAGS to -# OTHER_RECURSIVE_VARIABLES. - -# Additional headers to export beyond those in the PB.project: -# OTHER_PUBLIC_HEADERS -# OTHER_PROJECT_HEADERS -# OTHER_PRIVATE_HEADERS - -# Additional files for the project's product: <> -# OTHER_RESOURCES: (non-localized) resources for this project -# OTHER_OFILES: relocatables to be linked into this project -# OTHER_LIBS: more libraries to link against -# OTHER_PRODUCT_DEPENDS: other dependencies of this project -# OTHER_SOURCEFILES: other source files maintained by .pre/postamble -# OTHER_GARBAGE: additional files to be removed by `make clean' - -# Set this to YES if you don't want a final libtool call for a library/framework. -# BUILD_OFILES_LIST_ONLY - -# To include a version string, project source must exist in a directory named -# $(NAME).%d[.%d][.%d] and the following line must be uncommented. -# OTHER_GENERATED_OFILES = $(VERS_OFILE) - -# This definition will suppress stripping of debug symbols when an executable -# is installed. By default it is YES. -# STRIP_ON_INSTALL = NO - -# Uncomment to suppress generation of a KeyValueCoding index when installing -# frameworks (This index is used by WOB and IB to determine keys available -# for an object). Set to YES by default. -# PREINDEX_FRAMEWORK = NO - -# Change this definition to install projects somewhere other than the -# standard locations. NEXT_ROOT defaults to "C:/Apple" on Windows systems -# and "" on other systems. -DSTROOT = $(HOME) diff --git a/sys.subproj/PB.project b/sys.subproj/PB.project deleted file mode 100644 index d57c398..0000000 --- a/sys.subproj/PB.project +++ /dev/null @@ -1,45 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - H_FILES = (sigcatch.h); - OTHER_LINKED = ( - errno.c, - getdtablesize.c, - gettimeofday.c, - sigaction.c, - sigcatch.c, - sigprocmask.c, - sigsuspend.c, - sigtramp.c - ); - OTHER_SOURCES = ( - Makefile.preamble, - Makefile, - Makefile.postamble, - msync.2, - sem_close.2, - sem_open.2, - sem_post.2, - sem_trywait.2, - sem_unlink.2, - sem_wait.2, - shm_open.2, - shm_unlink.2 - ); - SUBPROJECTS = (i386.subproj, ppc.subproj); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = sys; - PROJECTTYPE = Component; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/sys.subproj/i386.subproj/Makefile b/sys.subproj/i386.subproj/Makefile deleted file mode 100644 index fd962c5..0000000 --- a/sys.subproj/i386.subproj/Makefile +++ /dev/null @@ -1,127 +0,0 @@ -# -# Generated by the Apple Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = i386 - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -HFILES = SYS.h - -OTHERLINKED = ATsocket.s ATgetmsg.s ATputmsg.s ATPsndreq.s ATPsndrsp.s\ - ATPgetreq.s ATPgetrsp.s accept.s access.s acct.s\ - add_profil.s adjtime.s bind.s cerror.s chdir.s\ - checkuseraccess.s chflags.s chmod.s chown.s chroot.s\ - close.s connect.s dup.s dup2.s exchangedata.s execve.s\ - _exit.s fchdir.s fchflags.s fchmod.s fchown.s fcntl.s\ - flock.s fork.s fpathconf.s fstat.s fstatfs.s fstatv.s\ - fsync.s ftruncate.s getattrlist.s getdirentries.s\ - getdirentriesattr.s getegid.s geteuid.s getfh.s\ - getfsstat.s getgid.s getgroups.s getitimer.s _getlogin.s\ - getpeername.s getpgrp.s getpid.s getppid.s getpriority.s\ - getrlimit.s getrusage.s getsockname.s getsockopt.s\ - getuid.s ioctl.s kill.s ktrace.s lfs_bmapv.s\ - lfs_markv.s lfs_segclean.s lfs_segwait.s link.s listen.s\ - lseek.s lstat.s lstatv.s madvise.s mincore.s minherit.s\ - mkcomplex.s mkdir.s mkfifo.s mknod.s mlock.s mlockall.s\ - mmap.s mount.s mprotect.s msgctl.s msgget.s msgrcv.s\ - msgsnd.s msgsys.s msync.s munlock.s munlockall.s\ - munmap.s nfssvc.s open.s pathconf.s pipe.s profil.s\ - ptrace.s quota.s quotactl.s read.s readlink.s readv.s\ - reboot.s recvfrom.s recvmsg.s rename.s revoke.s rmdir.s\ - searchfs.s select.s semconfig.s semctl.s semget.s\ - semop.s semsys.s sendmsg.s sendto.s setattrlist.s\ - setegid.s seteuid.s setgid.s setgroups.s setitimer.s\ - setjmp.s _setjmp.s _setlogin.s setpgid.s setpriority.s\ - setprivexec.s setquota.s setrlimit.s setsid.s\ - setsockopt.s settimeofday.s setuid.s shmat.s shmctl.s\ - shmdt.s shmget.s shmsys.s shm_open.s shm_unlink.s\ - shutdown.s sigaltstack.s sigpending.s sigreturn.s\ - socket.s socketpair.s stat.s statfs.s statv.s swapon.s\ - symlink.s sync.s syscall.s _sysctl.s table.s truncate.s\ - umask.s undelete.s unlink.s unmount.s utimes.s vfork.s\ - wait4.s write.s writev.s sem_close.s sem_destroy.s\ - sem_getvalue.s sem_init.s sem_open.s sem_post.s\ - sem_trywait.s sem_unlink.s sem_wait.s load_shared_file.s\ - reset_shared_file.s - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble - -OTHERLINKEDOFILES = ATsocket.o ATgetmsg.o ATputmsg.o ATPsndreq.o\ - ATPsndrsp.o ATPgetreq.o ATPgetrsp.o accept.o\ - access.o acct.o add_profil.o adjtime.o bind.o\ - cerror.o chdir.o checkuseraccess.o chflags.o\ - chmod.o chown.o chroot.o close.o connect.o dup.o\ - dup2.o exchangedata.o execve.o _exit.o fchdir.o\ - fchflags.o fchmod.o fchown.o fcntl.o flock.o\ - fork.o fpathconf.o fstat.o fstatfs.o fstatv.o\ - fsync.o ftruncate.o getattrlist.o getdirentries.o\ - getdirentriesattr.o getegid.o geteuid.o getfh.o\ - getfsstat.o getgid.o getgroups.o getitimer.o\ - _getlogin.o getpeername.o getpgrp.o getpid.o\ - getppid.o getpriority.o getrlimit.o getrusage.o\ - getsockname.o getsockopt.o getuid.o ioctl.o kill.o\ - ktrace.o lfs_bmapv.o lfs_markv.o lfs_segclean.o\ - lfs_segwait.o link.o listen.o lseek.o lstat.o\ - lstatv.o madvise.o mincore.o minherit.o\ - mkcomplex.o mkdir.o mkfifo.o mknod.o mlock.o\ - mlockall.o mmap.o mount.o mprotect.o msgctl.o\ - msgget.o msgrcv.o msgsnd.o msgsys.o msync.o\ - munlock.o munlockall.o munmap.o nfssvc.o open.o\ - pathconf.o pipe.o profil.o ptrace.o quota.o\ - quotactl.o read.o readlink.o readv.o reboot.o\ - recvfrom.o recvmsg.o rename.o revoke.o rmdir.o\ - searchfs.o select.o semconfig.o semctl.o semget.o\ - semop.o semsys.o sendmsg.o sendto.o setattrlist.o\ - setegid.o seteuid.o setgid.o setgroups.o\ - setitimer.o setjmp.o _setjmp.o _setlogin.o\ - setpgid.o setpriority.o setprivexec.o setquota.o\ - setrlimit.o setsid.o setsockopt.o settimeofday.o\ - setuid.o shmat.o shmctl.o shmdt.o shmget.o\ - shmsys.o shm_open.o shm_unlink.o shutdown.o\ - sigaltstack.o sigpending.o sigreturn.o socket.o\ - socketpair.o stat.o statfs.o statv.o swapon.o\ - symlink.o sync.o syscall.o _sysctl.o table.o\ - truncate.o umask.o undelete.o unlink.o unmount.o\ - utimes.o vfork.o wait4.o write.o writev.o\ - sem_close.o sem_destroy.o sem_getvalue.o sem_init.o\ - sem_open.o sem_post.o sem_trywait.o sem_unlink.o\ - sem_wait.o load_shared_file.o reset_shared_file.o - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -NEXTSTEP_INSTALLDIR = /Local/Developer/System -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - - - -NEXTSTEP_BUILD_OUTPUT_DIR = /Local/Public/SandBox/$(USER)/BUILD/$(NAME) - -NEXTSTEP_PUBLIC_HEADERS_DIR = /usr/include - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/sys.subproj/i386.subproj/Makefile.postamble b/sys.subproj/i386.subproj/Makefile.postamble deleted file mode 100644 index 411cde6..0000000 --- a/sys.subproj/i386.subproj/Makefile.postamble +++ /dev/null @@ -1,100 +0,0 @@ -############################################################################### -# Makefile.postamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile, which is imported after all other makefiles, to -# override attributes for a project's Makefile environment. This allows you -# to take advantage of the environment set up by the other Makefiles. -# You can also define custom rules at the end of this file. -# -############################################################################### -# -# These variables are exported by the standard makefiles and can be -# used in any customizations you make. They are *outputs* of -# the Makefiles and should be used, not set. -# -# PRODUCTS: products to install. All of these products will be placed in -# the directory $(DSTROOT)$(INSTALLDIR) -# GLOBAL_RESOURCE_DIR: The directory to which resources are copied. -# LOCAL_RESOURCE_DIR: The directory to which localized resources are copied. -# OFILE_DIR: Directory into which .o object files are generated. -# DERIVED_SRC_DIR: Directory used for all other derived files -# -# ALL_CFLAGS: flags to pass when compiling .c files -# ALL_MFLAGS: flags to pass when compiling .m files -# ALL_CCFLAGS: flags to pass when compiling .cc, .cxx, and .C files -# ALL_MMFLAGS: flags to pass when compiling .mm, .mxx, and .M files -# ALL_PRECOMPFLAGS: flags to pass when precompiling .h files -# ALL_LDFLAGS: flags to pass when linking object files -# ALL_LIBTOOL_FLAGS: flags to pass when libtooling object files -# ALL_PSWFLAGS: flags to pass when processing .psw and .pswm (pswrap) files -# ALL_RPCFLAGS: flags to pass when processing .rpc (rpcgen) files -# ALL_YFLAGS: flags to pass when processing .y (yacc) files -# ALL_LFLAGS: flags to pass when processing .l (lex) files -# -# NAME: name of application, bundle, subproject, palette, etc. -# LANGUAGES: langages in which the project is written (default "English") -# English_RESOURCES: localized resources (e.g. nib's, images) of project -# GLOBAL_RESOURCES: non-localized resources of project -# -# SRCROOT: base directory in which to place the new source files -# SRCPATH: relative path from SRCROOT to present subdirectory -# -# INSTALLDIR: Directory the product will be installed into by 'install' target -# PUBLIC_HDR_INSTALLDIR: where to install public headers. Don't forget -# to prefix this with DSTROOT when you use it. -# PRIVATE_HDR_INSTALLDIR: where to install private headers. Don't forget -# to prefix this with DSTROOT when you use it. -# -# EXECUTABLE_EXT: Executable extension for the platform (i.e. .exe on Windows) -# -############################################################################### - -# Some compiler flags can be overridden here for certain build situations. -# -# WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost) -# DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults -# to -g) -# DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG) -# OPTIMIZE_BUILD_CFLAGS: flags passed during optimized builds (defaults -# to -O) -# PROFILE_BUILD_CFLAGS: flags passed during profile builds (defaults -# to -pg -DPROFILE) -# LOCAL_DIR_INCLUDE_DIRECTIVE: flag used to add current directory to -# the include path (defaults to -I.) -# DEBUG_BUILD_LDFLAGS, OPTIMIZE_BUILD_LDFLAGS, PROFILE_BUILD_LDFLAGS: flags -# passed to ld/libtool (defaults to nothing) - - -# Library and Framework projects only: -# INSTALL_NAME_DIRECTIVE: This directive ensures that executables linked -# against the framework will run against the correct version even if -# the current version of the framework changes. You may override this -# to "" as an alternative to using the DYLD_LIBRARY_PATH during your -# development cycle, but be sure to restore it before installing. - - -# Ownership and permissions of files installed by 'install' target - -#INSTALL_AS_USER = root - # User/group ownership -#INSTALL_AS_GROUP = wheel - # (probably want to set both of these) -#INSTALL_PERMISSIONS = - # If set, 'install' chmod's executable to this - - -# Options to strip. Note: -S strips debugging symbols (executables can be stripped -# down further with -x or, if they load no bundles, with no options at all). - -#STRIPFLAGS = -S - - -######################################################################### -# Put rules to extend the behavior of the standard Makefiles here. Include them in -# the dependency tree via cvariables like AFTER_INSTALL in the Makefile.preamble. -# -# You should avoid redefining things like "install" or "app", as they are -# owned by the top-level Makefile API and no context has been set up for where -# derived files should go. -# diff --git a/sys.subproj/i386.subproj/Makefile.preamble b/sys.subproj/i386.subproj/Makefile.preamble deleted file mode 100644 index 6544e5f..0000000 --- a/sys.subproj/i386.subproj/Makefile.preamble +++ /dev/null @@ -1,137 +0,0 @@ -############################################################################### -# Makefile.preamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile for configuring the standard application makefiles -# associated with ProjectBuilder. It is included before the main makefile. -# In Makefile.preamble you set attributes for a project, so they are available -# to the project's makefiles. In contrast, you typically write additional rules or -# override built-in behavior in the Makefile.postamble. -# -# Each directory in a project tree (main project plus subprojects) should -# have its own Makefile.preamble and Makefile.postamble. -############################################################################### -# -# Before the main makefile is included for this project, you may set: -# -# MAKEFILEDIR: Directory in which to find $(MAKEFILE) -# MAKEFILE: Top level mechanism Makefile (e.g., app.make, bundle.make) - -# Compiler/linker flags added to the defaults: The OTHER_* variables will be -# inherited by all nested sub-projects, but the LOCAL_ versions of the same -# variables will not. Put your -I, -D, -U, and -L flags in ProjectBuilder's -# Build Attributes inspector if at all possible. To override the default flags -# that get passed to ${CC} (e.g. change -O to -O2), see Makefile.postamble. The -# variables below are *inputs* to the build process and distinct from the override -# settings done (less often) in the Makefile.postamble. -# -# OTHER_CFLAGS, LOCAL_CFLAGS: additional flags to pass to the compiler -# Note that $(OTHER_CFLAGS) and $(LOCAL_CFLAGS) are used for .h, ...c, .m, -# .cc, .cxx, .C, and .M files. There is no need to respecify the -# flags in OTHER_MFLAGS, etc. -# OTHER_MFLAGS, LOCAL_MFLAGS: additional flags for .m files -# OTHER_CCFLAGS, LOCAL_CCFLAGS: additional flags for .cc, .cxx, and ...C files -# OTHER_MMFLAGS, LOCAL_MMFLAGS: additional flags for .mm and .M files -# OTHER_PRECOMPFLAGS, LOCAL_PRECOMPFLAGS: additional flags used when -# precompiling header files -# OTHER_LDFLAGS, LOCAL_LDFLAGS: additional flags passed to ld and libtool -# OTHER_PSWFLAGS, LOCAL_PSWFLAGS: additional flags passed to pswrap -# OTHER_RPCFLAGS, LOCAL_RPCFLAGS: additional flags passed to rpcgen -# OTHER_YFLAGS, LOCAL_YFLAGS: additional flags passed to yacc -# OTHER_LFLAGS, LOCAL_LFLAGS: additional flags passed to lex - -# These variables provide hooks enabling you to add behavior at almost every -# stage of the make: -# -# BEFORE_PREBUILD: targets to build before installing headers for a subproject -# AFTER_PREBUILD: targets to build after installing headers for a subproject -# BEFORE_BUILD_RECURSION: targets to make before building subprojects -# BEFORE_BUILD: targets to make before a build, but after subprojects -# AFTER_BUILD: targets to make after a build -# -# BEFORE_INSTALL: targets to build before installing the product -# AFTER_INSTALL: targets to build after installing the product -# BEFORE_POSTINSTALL: targets to build before postinstalling every subproject -# AFTER_POSTINSTALL: targts to build after postinstalling every subproject -# -# BEFORE_INSTALLHDRS: targets to build before installing headers for a -# subproject -# AFTER_INSTALLHDRS: targets to build after installing headers for a subproject -# BEFORE_INSTALLSRC: targets to build before installing source for a subproject -# AFTER_INSTALLSRC: targets to build after installing source for a subproject -# -# BEFORE_DEPEND: targets to build before building dependencies for a -# subproject -# AFTER_DEPEND: targets to build after building dependencies for a -# subproject -# -# AUTOMATIC_DEPENDENCY_INFO: if YES, then the dependency file is -# updated every time the project is built. If NO, the dependency -# file is only built when the depend target is invoked. - -# Framework-related variables: -# FRAMEWORK_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the framework's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables - -# Library-related variables: -# PUBLIC_HEADER_DIR: Determines where public exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. For library projects you should -# set this to something like /Developer/Headers/$(NAME). Do not set -# this variable for framework projects unless you do not want the -# header files included in the framework. -# PRIVATE_HEADER_DIR: Determines where private exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. -# LIBRARY_STYLE: This may be either STATIC or DYNAMIC, and determines -# whether the libraries produced are statically linked when they -# are used or if they are dynamically loadable. This defaults to -# DYNAMIC. -# LIBRARY_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the library's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables -# -# INSTALL_AS_USER: owner of the intalled products (default root) -# INSTALL_AS_GROUP: group of the installed products (default wheel) -# INSTALL_PERMISSIONS: permissions of the installed product (default o+rX) -# -# OTHER_RECURSIVE_VARIABLES: The names of variables which you want to be -# passed on the command line to recursive invocations of make. Note that -# the values in OTHER_*FLAGS are inherited by subprojects automatically -- -# you do not have to (and shouldn't) add OTHER_*FLAGS to -# OTHER_RECURSIVE_VARIABLES. - -# Additional headers to export beyond those in the PB.project: -# OTHER_PUBLIC_HEADERS -# OTHER_PROJECT_HEADERS -# OTHER_PRIVATE_HEADERS - -# Additional files for the project's product: <> -# OTHER_RESOURCES: (non-localized) resources for this project -# OTHER_OFILES: relocatables to be linked into this project -# OTHER_LIBS: more libraries to link against -# OTHER_PRODUCT_DEPENDS: other dependencies of this project -# OTHER_SOURCEFILES: other source files maintained by .pre/postamble -# OTHER_GARBAGE: additional files to be removed by `make clean' - -# Set this to YES if you don't want a final libtool call for a library/framework. -# BUILD_OFILES_LIST_ONLY - -# To include a version string, project source must exist in a directory named -# $(NAME).%d[.%d][.%d] and the following line must be uncommented. -# OTHER_GENERATED_OFILES = $(VERS_OFILE) - -# This definition will suppress stripping of debug symbols when an executable -# is installed. By default it is YES. -# STRIP_ON_INSTALL = NO - -# Uncomment to suppress generation of a KeyValueCoding index when installing -# frameworks (This index is used by WOB and IB to determine keys available -# for an object). Set to YES by default. -# PREINDEX_FRAMEWORK = NO - -# Change this definition to install projects somewhere other than the -# standard locations. NEXT_ROOT defaults to "C:/Apple" on Windows systems -# and "" on other systems. -INCLUDED_ARCHS = i386 diff --git a/sys.subproj/i386.subproj/PB.project b/sys.subproj/i386.subproj/PB.project deleted file mode 100644 index 2e0da04..0000000 --- a/sys.subproj/i386.subproj/PB.project +++ /dev/null @@ -1,211 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - H_FILES = (SYS.h); - OTHER_LINKED = ( - ATsocket.s, - ATgetmsg.s, - ATputmsg.s, - ATPsndreq.s, - ATPsndrsp.s, - ATPgetreq.s, - ATPgetrsp.s, - accept.s, - access.s, - acct.s, - add_profil.s, - adjtime.s, - bind.s, - cerror.s, - chdir.s, - checkuseraccess.s, - chflags.s, - chmod.s, - chown.s, - chroot.s, - close.s, - connect.s, - dup.s, - dup2.s, - exchangedata.s, - execve.s, - _exit.s, - fchdir.s, - fchflags.s, - fchmod.s, - fchown.s, - fcntl.s, - flock.s, - fork.s, - fpathconf.s, - fstat.s, - fstatfs.s, - fstatv.s, - fsync.s, - ftruncate.s, - getattrlist.s, - getdirentries.s, - getdirentriesattr.s, - getegid.s, - geteuid.s, - getfh.s, - getfsstat.s, - getgid.s, - getgroups.s, - getitimer.s, - _getlogin.s, - getpeername.s, - getpgrp.s, - getpid.s, - getppid.s, - getpriority.s, - getrlimit.s, - getrusage.s, - getsockname.s, - getsockopt.s, - getuid.s, - ioctl.s, - kill.s, - ktrace.s, - lfs_bmapv.s, - lfs_markv.s, - lfs_segclean.s, - lfs_segwait.s, - link.s, - listen.s, - lseek.s, - lstat.s, - lstatv.s, - madvise.s, - mincore.s, - minherit.s, - mkcomplex.s, - mkdir.s, - mkfifo.s, - mknod.s, - mlock.s, - mlockall.s, - mmap.s, - mount.s, - mprotect.s, - msgctl.s, - msgget.s, - msgrcv.s, - msgsnd.s, - msgsys.s, - msync.s, - munlock.s, - munlockall.s, - munmap.s, - nfssvc.s, - open.s, - pathconf.s, - pipe.s, - profil.s, - ptrace.s, - quota.s, - quotactl.s, - read.s, - readlink.s, - readv.s, - reboot.s, - recvfrom.s, - recvmsg.s, - rename.s, - revoke.s, - rmdir.s, - searchfs.s, - select.s, - semconfig.s, - semctl.s, - semget.s, - semop.s, - semsys.s, - sendmsg.s, - sendto.s, - setattrlist.s, - setegid.s, - seteuid.s, - setgid.s, - setgroups.s, - setitimer.s, - setjmp.s, - _setjmp.s, - _setlogin.s, - setpgid.s, - setpriority.s, - setprivexec.s, - setquota.s, - setrlimit.s, - setsid.s, - setsockopt.s, - settimeofday.s, - setuid.s, - shmat.s, - shmctl.s, - shmdt.s, - shmget.s, - shmsys.s, - shm_open.s, - shm_unlink.s, - shutdown.s, - sigaltstack.s, - sigpending.s, - sigreturn.s, - socket.s, - socketpair.s, - stat.s, - statfs.s, - statv.s, - swapon.s, - symlink.s, - sync.s, - syscall.s, - _sysctl.s, - table.s, - truncate.s, - umask.s, - undelete.s, - unlink.s, - unmount.s, - utimes.s, - vfork.s, - wait4.s, - write.s, - writev.s, - sem_close.s, - sem_destroy.s, - sem_getvalue.s, - sem_init.s, - sem_open.s, - sem_post.s, - sem_trywait.s, - sem_unlink.s, - sem_wait.s, - load_shared_file.s, - reset_shared_file.s - ); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble); - PRECOMPILED_HEADERS = (); - PROJECT_HEADERS = (); - PUBLIC_HEADERS = (); - SUBPROJECTS = (); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDDIR = "/Local/Public/SandBox/$(USER)/BUILD/$(NAME)"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_INSTALLDIR = /Local/Developer/System; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - NEXTSTEP_PUBLICHEADERSDIR = /usr/include; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = i386; - PROJECTTYPE = Component; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/sys.subproj/ppc.subproj/Makefile b/sys.subproj/ppc.subproj/Makefile deleted file mode 100644 index 633178e..0000000 --- a/sys.subproj/ppc.subproj/Makefile +++ /dev/null @@ -1,132 +0,0 @@ -# -# Generated by the Apple Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = ppc - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -HFILES = assym.h genassym.h _setjmp.h SYS.h processor_facilities.h - -OTHERLINKED = ATsocket.s ATgetmsg.s ATputmsg.s ATPsndreq.s ATPsndrsp.s\ - ATPgetreq.s ATPgetrsp.s accept.s access.s acct.s\ - add_profil.s adjtime.s bind.s cerror.s chdir.s\ - checkuseraccess.s chflags.s chmod.s chown.s chroot.s\ - close.s connect.s cthread.s dup.s dup2.s exchangedata.s\ - execve.s _exit.s fchdir.s fchflags.s fchmod.s fchown.s\ - fcntl.s flock.s fork.s fpathconf.s fstat.s fstatfs.s\ - fstatv.s fsync.s ftruncate.s getattrlist.s\ - getdirentries.s getdirentriesattr.s getegid.s geteuid.s\ - getfh.s getfsstat.s getgid.s getgroups.s getitimer.s\ - _getlogin.s getpeername.s getpgrp.s getpid.s getppid.s\ - getpriority.s getrlimit.s getrusage.s getsockname.s\ - getsockopt.s getuid.s ioctl.s kill.s ktrace.s\ - lfs_bmapv.s lfs_markv.s lfs_segclean.s lfs_segwait.s\ - link.s listen.s longjmp.s _longjmp.s lseek.s lstat.s\ - lstatv.s madvise.s mincore.s minherit.s mkcomplex.s\ - mkdir.s mkfifo.s mknod.s mlock.s mlockall.s mmap.s\ - mount.s mprotect.s msgctl.s msgget.s msgrcv.s msgsnd.s\ - msgsys.s msync.s munlock.s munlockall.s munmap.s\ - nfssvc.s open.s pathconf.s pipe.s profil.s ptrace.s\ - quota.s quotactl.s read.s readlink.s readv.s reboot.s\ - recvfrom.s recvmsg.s rename.s revoke.s rmdir.s\ - searchfs.s select.s semconfig.s semctl.s semget.s\ - semop.s semsys.s sendmsg.s sendto.s setattrlist.s\ - setegid.s seteuid.s setgid.s setgroups.s setitimer.s\ - setjmp.s _setjmp.s _setlogin.s setpgid.s setpriority.s\ - setprivexec.s setquota.s setrlimit.s setsid.s\ - setsockopt.s settimeofday.s setuid.s shmat.s shmctl.s\ - shmdt.s shmget.s shmsys.s shm_open.s shm_unlink.s\ - shutdown.s sigaltstack.s sigpending.s sigreturn.s\ - socket.s socketpair.s stat.s statfs.s statv.s swapon.s\ - symlink.s sync.s syscall.s _sysctl.s table.s truncate.s\ - umask.s undelete.s unlink.s unmount.s ur_cthread.s\ - utimes.s vfork.s wait4.s write.s writev.s sem_close.s\ - sem_destroy.s sem_getvalue.s sem_init.s sem_open.s\ - sem_post.s sem_trywait.s sem_unlink.s sem_wait.s\ - processor_facilities.s load_shared_file.s reset_shared_file.s - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble - -OTHERLINKEDOFILES = ATsocket.o ATgetmsg.o ATputmsg.o ATPsndreq.o\ - ATPsndrsp.o ATPgetreq.o ATPgetrsp.o accept.o\ - access.o acct.o add_profil.o adjtime.o bind.o\ - cerror.o chdir.o checkuseraccess.o chflags.o\ - chmod.o chown.o chroot.o close.o connect.o\ - cthread.o dup.o dup2.o exchangedata.o execve.o\ - _exit.o fchdir.o fchflags.o fchmod.o fchown.o\ - fcntl.o flock.o fork.o fpathconf.o fstat.o\ - fstatfs.o fstatv.o fsync.o ftruncate.o\ - getattrlist.o getdirentries.o getdirentriesattr.o\ - getegid.o geteuid.o getfh.o getfsstat.o getgid.o\ - getgroups.o getitimer.o _getlogin.o getpeername.o\ - getpgrp.o getpid.o getppid.o getpriority.o\ - getrlimit.o getrusage.o getsockname.o getsockopt.o\ - getuid.o ioctl.o kill.o ktrace.o lfs_bmapv.o\ - lfs_markv.o lfs_segclean.o lfs_segwait.o link.o\ - listen.o longjmp.o _longjmp.o lseek.o lstat.o\ - lstatv.o madvise.o mincore.o minherit.o\ - mkcomplex.o mkdir.o mkfifo.o mknod.o mlock.o\ - mlockall.o mmap.o mount.o mprotect.o msgctl.o\ - msgget.o msgrcv.o msgsnd.o msgsys.o msync.o\ - munlock.o munlockall.o munmap.o nfssvc.o open.o\ - pathconf.o pipe.o profil.o ptrace.o quota.o\ - quotactl.o read.o readlink.o readv.o reboot.o\ - recvfrom.o recvmsg.o rename.o revoke.o rmdir.o\ - searchfs.o select.o semconfig.o semctl.o semget.o\ - semop.o semsys.o sendmsg.o sendto.o setattrlist.o\ - setegid.o seteuid.o setgid.o setgroups.o\ - setitimer.o setjmp.o _setjmp.o _setlogin.o\ - setpgid.o setpriority.o setprivexec.o setquota.o\ - setrlimit.o setsid.o setsockopt.o settimeofday.o\ - setuid.o shmat.o shmctl.o shmdt.o shmget.o\ - shmsys.o shm_open.o shm_unlink.o shutdown.o\ - sigaltstack.o sigpending.o sigreturn.o socket.o\ - socketpair.o stat.o statfs.o statv.o swapon.o\ - symlink.o sync.o syscall.o _sysctl.o table.o\ - truncate.o umask.o undelete.o unlink.o unmount.o\ - ur_cthread.o utimes.o vfork.o wait4.o write.o\ - writev.o sem_close.o sem_destroy.o sem_getvalue.o\ - sem_init.o sem_open.o sem_post.o sem_trywait.o\ - sem_unlink.o sem_wait.o processor_facilities.o\ - load_shared_file.o reset_shared_file.o - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -NEXTSTEP_INSTALLDIR = /AppleInternal/Developer/System -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - -PUBLIC_HEADERS = processor_facilities.h - - - -NEXTSTEP_BUILD_OUTPUT_DIR = /Local/Public/SandBox/$(USER)/BUILD/$(NAME) - -NEXTSTEP_PUBLIC_HEADERS_DIR = /usr/include - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/sys.subproj/ppc.subproj/Makefile.postamble b/sys.subproj/ppc.subproj/Makefile.postamble deleted file mode 100644 index 411cde6..0000000 --- a/sys.subproj/ppc.subproj/Makefile.postamble +++ /dev/null @@ -1,100 +0,0 @@ -############################################################################### -# Makefile.postamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile, which is imported after all other makefiles, to -# override attributes for a project's Makefile environment. This allows you -# to take advantage of the environment set up by the other Makefiles. -# You can also define custom rules at the end of this file. -# -############################################################################### -# -# These variables are exported by the standard makefiles and can be -# used in any customizations you make. They are *outputs* of -# the Makefiles and should be used, not set. -# -# PRODUCTS: products to install. All of these products will be placed in -# the directory $(DSTROOT)$(INSTALLDIR) -# GLOBAL_RESOURCE_DIR: The directory to which resources are copied. -# LOCAL_RESOURCE_DIR: The directory to which localized resources are copied. -# OFILE_DIR: Directory into which .o object files are generated. -# DERIVED_SRC_DIR: Directory used for all other derived files -# -# ALL_CFLAGS: flags to pass when compiling .c files -# ALL_MFLAGS: flags to pass when compiling .m files -# ALL_CCFLAGS: flags to pass when compiling .cc, .cxx, and .C files -# ALL_MMFLAGS: flags to pass when compiling .mm, .mxx, and .M files -# ALL_PRECOMPFLAGS: flags to pass when precompiling .h files -# ALL_LDFLAGS: flags to pass when linking object files -# ALL_LIBTOOL_FLAGS: flags to pass when libtooling object files -# ALL_PSWFLAGS: flags to pass when processing .psw and .pswm (pswrap) files -# ALL_RPCFLAGS: flags to pass when processing .rpc (rpcgen) files -# ALL_YFLAGS: flags to pass when processing .y (yacc) files -# ALL_LFLAGS: flags to pass when processing .l (lex) files -# -# NAME: name of application, bundle, subproject, palette, etc. -# LANGUAGES: langages in which the project is written (default "English") -# English_RESOURCES: localized resources (e.g. nib's, images) of project -# GLOBAL_RESOURCES: non-localized resources of project -# -# SRCROOT: base directory in which to place the new source files -# SRCPATH: relative path from SRCROOT to present subdirectory -# -# INSTALLDIR: Directory the product will be installed into by 'install' target -# PUBLIC_HDR_INSTALLDIR: where to install public headers. Don't forget -# to prefix this with DSTROOT when you use it. -# PRIVATE_HDR_INSTALLDIR: where to install private headers. Don't forget -# to prefix this with DSTROOT when you use it. -# -# EXECUTABLE_EXT: Executable extension for the platform (i.e. .exe on Windows) -# -############################################################################### - -# Some compiler flags can be overridden here for certain build situations. -# -# WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost) -# DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults -# to -g) -# DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG) -# OPTIMIZE_BUILD_CFLAGS: flags passed during optimized builds (defaults -# to -O) -# PROFILE_BUILD_CFLAGS: flags passed during profile builds (defaults -# to -pg -DPROFILE) -# LOCAL_DIR_INCLUDE_DIRECTIVE: flag used to add current directory to -# the include path (defaults to -I.) -# DEBUG_BUILD_LDFLAGS, OPTIMIZE_BUILD_LDFLAGS, PROFILE_BUILD_LDFLAGS: flags -# passed to ld/libtool (defaults to nothing) - - -# Library and Framework projects only: -# INSTALL_NAME_DIRECTIVE: This directive ensures that executables linked -# against the framework will run against the correct version even if -# the current version of the framework changes. You may override this -# to "" as an alternative to using the DYLD_LIBRARY_PATH during your -# development cycle, but be sure to restore it before installing. - - -# Ownership and permissions of files installed by 'install' target - -#INSTALL_AS_USER = root - # User/group ownership -#INSTALL_AS_GROUP = wheel - # (probably want to set both of these) -#INSTALL_PERMISSIONS = - # If set, 'install' chmod's executable to this - - -# Options to strip. Note: -S strips debugging symbols (executables can be stripped -# down further with -x or, if they load no bundles, with no options at all). - -#STRIPFLAGS = -S - - -######################################################################### -# Put rules to extend the behavior of the standard Makefiles here. Include them in -# the dependency tree via cvariables like AFTER_INSTALL in the Makefile.preamble. -# -# You should avoid redefining things like "install" or "app", as they are -# owned by the top-level Makefile API and no context has been set up for where -# derived files should go. -# diff --git a/sys.subproj/ppc.subproj/Makefile.preamble b/sys.subproj/ppc.subproj/Makefile.preamble deleted file mode 100644 index e7c0be7..0000000 --- a/sys.subproj/ppc.subproj/Makefile.preamble +++ /dev/null @@ -1,138 +0,0 @@ -############################################################################### -# Makefile.preamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile for configuring the standard application makefiles -# associated with ProjectBuilder. It is included before the main makefile. -# In Makefile.preamble you set attributes for a project, so they are available -# to the project's makefiles. In contrast, you typically write additional rules or -# override built-in behavior in the Makefile.postamble. -# -# Each directory in a project tree (main project plus subprojects) should -# have its own Makefile.preamble and Makefile.postamble. -############################################################################### -# -# Before the main makefile is included for this project, you may set: -# -# MAKEFILEDIR: Directory in which to find $(MAKEFILE) -# MAKEFILE: Top level mechanism Makefile (e.g., app.make, bundle.make) - -# Compiler/linker flags added to the defaults: The OTHER_* variables will be -# inherited by all nested sub-projects, but the LOCAL_ versions of the same -# variables will not. Put your -I, -D, -U, and -L flags in ProjectBuilder's -# Build Attributes inspector if at all possible. To override the default flags -# that get passed to ${CC} (e.g. change -O to -O2), see Makefile.postamble. The -# variables below are *inputs* to the build process and distinct from the override -# settings done (less often) in the Makefile.postamble. -# -# OTHER_CFLAGS, LOCAL_CFLAGS: additional flags to pass to the compiler -# Note that $(OTHER_CFLAGS) and $(LOCAL_CFLAGS) are used for .h, ...c, .m, -# .cc, .cxx, .C, and .M files. There is no need to respecify the -# flags in OTHER_MFLAGS, etc. -# OTHER_MFLAGS, LOCAL_MFLAGS: additional flags for .m files -# OTHER_CCFLAGS, LOCAL_CCFLAGS: additional flags for .cc, .cxx, and ...C files -# OTHER_MMFLAGS, LOCAL_MMFLAGS: additional flags for .mm and .M files -# OTHER_PRECOMPFLAGS, LOCAL_PRECOMPFLAGS: additional flags used when -# precompiling header files -# OTHER_LDFLAGS, LOCAL_LDFLAGS: additional flags passed to ld and libtool -# OTHER_PSWFLAGS, LOCAL_PSWFLAGS: additional flags passed to pswrap -# OTHER_RPCFLAGS, LOCAL_RPCFLAGS: additional flags passed to rpcgen -# OTHER_YFLAGS, LOCAL_YFLAGS: additional flags passed to yacc -# OTHER_LFLAGS, LOCAL_LFLAGS: additional flags passed to lex - -# These variables provide hooks enabling you to add behavior at almost every -# stage of the make: -# -# BEFORE_PREBUILD: targets to build before installing headers for a subproject -# AFTER_PREBUILD: targets to build after installing headers for a subproject -# BEFORE_BUILD_RECURSION: targets to make before building subprojects -# BEFORE_BUILD: targets to make before a build, but after subprojects -# AFTER_BUILD: targets to make after a build -# -# BEFORE_INSTALL: targets to build before installing the product -# AFTER_INSTALL: targets to build after installing the product -# BEFORE_POSTINSTALL: targets to build before postinstalling every subproject -# AFTER_POSTINSTALL: targts to build after postinstalling every subproject -# -# BEFORE_INSTALLHDRS: targets to build before installing headers for a -# subproject -# AFTER_INSTALLHDRS: targets to build after installing headers for a subproject -# BEFORE_INSTALLSRC: targets to build before installing source for a subproject -# AFTER_INSTALLSRC: targets to build after installing source for a subproject -# -# BEFORE_DEPEND: targets to build before building dependencies for a -# subproject -# AFTER_DEPEND: targets to build after building dependencies for a -# subproject -# -# AUTOMATIC_DEPENDENCY_INFO: if YES, then the dependency file is -# updated every time the project is built. If NO, the dependency -# file is only built when the depend target is invoked. - -# Framework-related variables: -# FRAMEWORK_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the framework's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables - -# Library-related variables: -# PUBLIC_HEADER_DIR: Determines where public exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. For library projects you should -# set this to something like /Developer/Headers/$(NAME). Do not set -# this variable for framework projects unless you do not want the -# header files included in the framework. -PUBLIC_HEADER_DIR := $(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/Versions/B/PrivateHeaders/architecture/ppc -# PRIVATE_HEADER_DIR: Determines where private exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. -# LIBRARY_STYLE: This may be either STATIC or DYNAMIC, and determines -# whether the libraries produced are statically linked when they -# are used or if they are dynamically loadable. This defaults to -# DYNAMIC. -# LIBRARY_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the library's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables -# -# INSTALL_AS_USER: owner of the intalled products (default root) -# INSTALL_AS_GROUP: group of the installed products (default wheel) -# INSTALL_PERMISSIONS: permissions of the installed product (default o+rX) -# -# OTHER_RECURSIVE_VARIABLES: The names of variables which you want to be -# passed on the command line to recursive invocations of make. Note that -# the values in OTHER_*FLAGS are inherited by subprojects automatically -- -# you do not have to (and shouldn't) add OTHER_*FLAGS to -# OTHER_RECURSIVE_VARIABLES. - -# Additional headers to export beyond those in the PB.project: -# OTHER_PUBLIC_HEADERS -# OTHER_PROJECT_HEADERS -# OTHER_PRIVATE_HEADERS - -# Additional files for the project's product: <> -# OTHER_RESOURCES: (non-localized) resources for this project -# OTHER_OFILES: relocatables to be linked into this project -# OTHER_LIBS: more libraries to link against -# OTHER_PRODUCT_DEPENDS: other dependencies of this project -# OTHER_SOURCEFILES: other source files maintained by .pre/postamble -# OTHER_GARBAGE: additional files to be removed by `make clean' - -# Set this to YES if you don't want a final libtool call for a library/framework. -# BUILD_OFILES_LIST_ONLY - -# To include a version string, project source must exist in a directory named -# $(NAME).%d[.%d][.%d] and the following line must be uncommented. -# OTHER_GENERATED_OFILES = $(VERS_OFILE) - -# This definition will suppress stripping of debug symbols when an executable -# is installed. By default it is YES. -# STRIP_ON_INSTALL = NO - -# Uncomment to suppress generation of a KeyValueCoding index when installing -# frameworks (This index is used by WOB and IB to determine keys available -# for an object). Set to YES by default. -# PREINDEX_FRAMEWORK = NO - -# Change this definition to install projects somewhere other than the -# standard locations. NEXT_ROOT defaults to "C:/Apple" on Windows systems -# and "" on other systems. -INCLUDED_ARCHS = ppc diff --git a/sys.subproj/ppc.subproj/PB.project b/sys.subproj/ppc.subproj/PB.project deleted file mode 100644 index 2359ad6..0000000 --- a/sys.subproj/ppc.subproj/PB.project +++ /dev/null @@ -1,216 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - H_FILES = (assym.h, genassym.h, _setjmp.h, SYS.h, processor_facilities.h); - OTHER_LINKED = ( - ATsocket.s, - ATgetmsg.s, - ATputmsg.s, - ATPsndreq.s, - ATPsndrsp.s, - ATPgetreq.s, - ATPgetrsp.s, - accept.s, - access.s, - acct.s, - add_profil.s, - adjtime.s, - bind.s, - cerror.s, - chdir.s, - checkuseraccess.s, - chflags.s, - chmod.s, - chown.s, - chroot.s, - close.s, - connect.s, - cthread.s, - dup.s, - dup2.s, - exchangedata.s, - execve.s, - _exit.s, - fchdir.s, - fchflags.s, - fchmod.s, - fchown.s, - fcntl.s, - flock.s, - fork.s, - fpathconf.s, - fstat.s, - fstatfs.s, - fstatv.s, - fsync.s, - ftruncate.s, - getattrlist.s, - getdirentries.s, - getdirentriesattr.s, - getegid.s, - geteuid.s, - getfh.s, - getfsstat.s, - getgid.s, - getgroups.s, - getitimer.s, - _getlogin.s, - getpeername.s, - getpgrp.s, - getpid.s, - getppid.s, - getpriority.s, - getrlimit.s, - getrusage.s, - getsockname.s, - getsockopt.s, - getuid.s, - ioctl.s, - kill.s, - ktrace.s, - lfs_bmapv.s, - lfs_markv.s, - lfs_segclean.s, - lfs_segwait.s, - link.s, - listen.s, - longjmp.s, - _longjmp.s, - lseek.s, - lstat.s, - lstatv.s, - madvise.s, - mincore.s, - minherit.s, - mkcomplex.s, - mkdir.s, - mkfifo.s, - mknod.s, - mlock.s, - mlockall.s, - mmap.s, - mount.s, - mprotect.s, - msgctl.s, - msgget.s, - msgrcv.s, - msgsnd.s, - msgsys.s, - msync.s, - munlock.s, - munlockall.s, - munmap.s, - nfssvc.s, - open.s, - pathconf.s, - pipe.s, - profil.s, - ptrace.s, - quota.s, - quotactl.s, - read.s, - readlink.s, - readv.s, - reboot.s, - recvfrom.s, - recvmsg.s, - rename.s, - revoke.s, - rmdir.s, - searchfs.s, - select.s, - semconfig.s, - semctl.s, - semget.s, - semop.s, - semsys.s, - sendmsg.s, - sendto.s, - setattrlist.s, - setegid.s, - seteuid.s, - setgid.s, - setgroups.s, - setitimer.s, - setjmp.s, - _setjmp.s, - _setlogin.s, - setpgid.s, - setpriority.s, - setprivexec.s, - setquota.s, - setrlimit.s, - setsid.s, - setsockopt.s, - settimeofday.s, - setuid.s, - shmat.s, - shmctl.s, - shmdt.s, - shmget.s, - shmsys.s, - shm_open.s, - shm_unlink.s, - shutdown.s, - sigaltstack.s, - sigpending.s, - sigreturn.s, - socket.s, - socketpair.s, - stat.s, - statfs.s, - statv.s, - swapon.s, - symlink.s, - sync.s, - syscall.s, - _sysctl.s, - table.s, - truncate.s, - umask.s, - undelete.s, - unlink.s, - unmount.s, - ur_cthread.s, - utimes.s, - vfork.s, - wait4.s, - write.s, - writev.s, - sem_close.s, - sem_destroy.s, - sem_getvalue.s, - sem_init.s, - sem_open.s, - sem_post.s, - sem_trywait.s, - sem_unlink.s, - sem_wait.s, - processor_facilities.s, - load_shared_file.s, - reset_shared_file.s - ); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble); - PRECOMPILED_HEADERS = (); - PROJECT_HEADERS = (); - PUBLIC_HEADERS = (processor_facilities.h); - SUBPROJECTS = (); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDDIR = "/Local/Public/SandBox/$(USER)/BUILD/$(NAME)"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_INSTALLDIR = /AppleInternal/Developer/System; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - NEXTSTEP_PUBLICHEADERSDIR = /usr/include; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = ppc; - PROJECTTYPE = Component; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/sys.subproj/sigprocmask.c b/sys.subproj/sigprocmask.c deleted file mode 100644 index 2407eb6..0000000 --- a/sys.subproj/sigprocmask.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ -/* @(#)sigprocmask.c 1.0 9/26/95 (c) 1995 NeXT */ - -#include -#include -#include -#include - -/* - * Translate sigprocmask call to system call interface. - */ - -int sigprocmask ( - int how, - const sigset_t *nsm, - sigset_t *osm) -{ - sigset_t mask; - - if (nsm == 0) { - how = SIG_BLOCK; - sigemptyset(&mask); - } else { - mask = *nsm; - } - mask = (sigset_t) syscall(SYS_sigprocmask, how, mask); - /* syscall will call cerror if there is an error */ - if (osm) - *osm = mask; - return 0; -} diff --git a/sys/CLIB-LIST b/sys/CLIB-LIST new file mode 100644 index 0000000..7b30a40 --- /dev/null +++ b/sys/CLIB-LIST @@ -0,0 +1,679 @@ +CIRCLEQ_ENTRY M +CIRCLEQ_HEAD M +CIRCLEQ_INIT M +CIRCLEQ_INSERT_AFTER M +CIRCLEQ_INSERT_BEFORE M +CIRCLEQ_INSERT_HEAD M +CIRCLEQ_INSERT_TAIL M +CIRCLEQ_REMOVE M +LIST_ENTRY M +LIST_HEAD M +LIST_INIT M +LIST_INSERT_AFTER M +LIST_REMOVE M +TAILQ_ENTRY M +TAILQ_HEAD M +TAILQ_INIT M +TAILQ_INSERT_AFTER M +TAILQ_INSERT_HEAD M +TAILQ_INSERT_TAIL M +TAILQ_REMOVE M +_longjmp +_setjmp +abort +abs +acl_add +acl_canocicalize_principal +acl_check +acl_delete +acl_exact_match +acl_initialize +acos +acosh +addch +addstr +alarm +alloca +alphasort +arc +asctime +asin +asinh +assert +atan +atan2 +atanh +atexit +atof +atoi +atol +bcmp +bcopy +bit_alloc M +bit_clear M +bit_decl M +bit_ffc M +bit_ffs M +bit_nclear M +bit_nset M +bit_test M +bitstr_size M +box +bsearch +bypot +bzero +cabs +calloc +cbreak +cbrt +ceil +cfgetispeed +cfgetospeed +cfmakeraw +cfsetispeed +cfsetospeed +cfsetspeed +cgetcap +cgetclose +cgetent +cgetfirst +cgetmatch +cgetnext +cgetnum +cgetset +cgetstr +cgetustr +circle +clear +clearerr +clearok +clock +closedir +closelog +closepl +clrtobot +clrtoeol +confstr +cont +copysign +cos +cosh +crypt +ctermid +ctime +daemon +dbopen +delch +delwin +des_cbc_cksum +des_cbc_encrypt +des_cipher +des_ecb_encrypt +des_pcbc_encrypt +des_quad_cksum +des_random_key +des_read_password +des_set_key +des_setkey +des_string_to_key +devanme +diffti8me +dirfd +div +dleteln +dn_comp +dn_expand +drem +echo +ectv +edata +encrypt +end +endfsent +endgrent +endhostent +endnetent +endnetgrent +endprotoent +endpwent +endservent +endttyent +endusershell +endwin +er +erase +erf +erfc +err +errx +etext +etfc +execl +execle +execlp +exect +execv +execvp +exit +exp +expm1 +fabs +fclose +fctv +fdopen +feof +ferror +fflush +ffs +fgetc +fgetline +fgetln +fgetpos +fgets +fileno +finite +floor +flusok +fmin MP +fmod +fmount MP +fnmatch +fopen +fprintf +fpurge +fputc +fputs +fread +free +freopen +frexp +fropen +fscanf +fseek +fsetpos +ftell +ftime +fts_children +fts_close +fts_open +fts_read +fts_set +funopen +fwopen +fwrite +gamma +gcd MP +gctv +getbsize +getc +getcap +getch +getchar +getcwd +getdiskbyname +getenv +getfsent +getfsfile +getfsspec +getgrent +getgrgid +getgrnam +getgrouplist +gethostbyaddr +gethostbyname +gethostent +gethostid +gethostname +getloadavg +getmntinfo +getmntopts +getmode +getnetbyaddr +getnetbyname +getnetent +getnetgrent +getopt +getpagesize +getpass +getprotobyname +getprotobynumber +getprotoent +getpw +getpwent +getpwnam +getpwuid +gets +getservbyname +getservbyport +getservent +getstr +getsubopt +gettmode +getttyent +getttynam +getusershell +getw +getwd +getyx +glob +globfree +gmtime +group_from_gid +gtty +heapsort +herror +htonl +htons +hypot +inch +index +inet_addr +inet_aton +inet_lnaof +inet_makeaddr +inet_netof +inet_network +inet_ntoa +infnan +initgroups +initscr +initstate +innetgr +insch +insetln +insque +invert MP +isalnum +isalpha +isascii +isatty +isblank +iscntrl +isdigit +isgraph +isinf +islower +isnan +iso_addr +iso_ntoa +isprint +ispunct +isspace +isupper +isxdigit +itom MP +j0 +j1 +jn +krb_err_txt +krb_get_admhst +krb_get_cred +krb_get_krbhst +krb_get_lrealm +krb_get_phost +krb_kntoln +krb_mk_err +krb_mk_priv +krb_mk_req +krb_mk_safe +krb_net_read +krb_net_write +krb_rd_err +krb_rd_priv +krb_rd_req +krb_rd_safe +krb_realmofhost +krb_recvauth +krb_sendauth +krb_set_key +krb_set_tkt_string +kuserok +kvm_close +kvm_getargv +kvm_getenvv +kvm_geterr +kvm_getfiles +kvm_getloadavg +kvm_getprocs +kvm_nlist +kvm_open +kvm_openfiles +kvm_read +kvm_write +label +labs +ldexp +ldiv +leaveok +lfind +lgamma +line +linemod +link_addr +link_ntoa +localeconv +localtime +log +log10 +log1p +logb +longjmp +longjmperror +longname +lsearch +m_in MP +m_out MP +madd MP +malloc +mamcpy +mblen +mbmb +mbrrune +mbrune +mbstowcs +mbtowc +mcmp MP +mdiv MP +memccpy +memchr +memcmp +memcpy +memmove +memset +mergesort +min MP +mkstemp +mktemp +mktime +modf +moncontrol +monstartup +mount MP +move +move MP +mpool_close +mpool_filter +mpool_get +mpool_new +mpool_open +mpool_put +mpool_sync +msqrt MP +msub MP +mult MP +mvcur +newein +nice +nl +nlist +nocbreak +noecho +nonl +noraw +ns_addr +ns_ntoa +ntohl +ntohs +omin MP +omount MP +opendir +openlog +openpl +optarg +opterr +optind +optopt +optreset +overlay +overwrite +pause +pclose +perror +point +popen +pow +pow MP +printf +printw +psignal +putc +putchar +putenv +puts +putw +qsort +radixsort +raise +rand +random +raw +rcmd +re_comp +re_exec +readdir +realloc +realpath +refresh +regcomp +regerror +regexec +regfree +regsub +remove +remque +res_init +res_mkquery +res_query +res_send +res_serach +resetty +rewind +rewinddir +rexec +rindex +rint +rpow MP +rresvport +ruserok +savetty +scalb +scandir +scanf +scanw +scroll +scrollok +sdiv MP +seekdir +setbuf +setbuffer +setenv +setfsent +setgrent +setgroupent +sethostent +sethostid +sethostname +setinvalidrunt +setjmp +setkey +setlinebuf +setlocale +setlogmask +setmode +setnetent +setnetgrent +setpassent +setprotoent +setpwent +setrgid +setruid +setrunelocale +setservent +setstate +setterm +setttyent +setusershell +setvbuf +sgetrune +sigaddset +sigdelset +sigemptyset +sigfillset +siginterrupt +sigismember +siglongjmp +signal +signgam +sigsetjmp +sin +sinh +sleep +snprintf +space +sprintf +sputrune +sqrt +sradixsort +srand +sreandom +sscanf +standend +standout +stderr +stdin +stdout +strcasecmp +strcat +strchr +strcmp +strcoll +strcpy +strcspn +strdup +strerror +strftime +strlen +strmode +strncasecmp +strncat +strncmp +strncpy +strpbrk +strrchr +strsep +strspc +strspn +strstr +strtod +strtok +strtol +strtoq +strtoul +strtouq +strunvis +strvis +strvisx +strxfrm +stty +subwin +swab +sys_errlist +sys_nerr +sys_siglist +sys_signame +sysconf +sysctl +syslog +system +tan +tanh +tcdrain +tcflow +tcflush +tcgetattr +tcgetpgrp +tcsendbreak +tcsetattr +tcsetpgrp +telldir +tempnam +tf_close +tf_get_cred +tf_get_pinst +tf_get_pname +tf_init +tgetent +tgetflag +tgetnum +tgetstr +tgoto +time +times +timezone +tmpfile +tmpnam +toascii +tolower +touchline +touchoverlap +touchwin +toupper +tputs +ttynam +ttyslot +tzset +tzsetwall +ualarm +uname +unctrl +ungetc +unsetenv +unvis +user_from_uid +usleep +utime +va_arg M +va_end M +va_start M +valloc +verr +verrx +vfprintf +vfscanf +vis +vlimit +vprintf +vscanf +vsnprintf +vsprintf +vsscanf +vsyslog +vtimes +vwarn +vwarnx +waddch +waddstr +warn +warnx +wclear +wclreol +wclrtobot +wcstombs +wctomb +wdelch +wdeleteln +werase +wgetch +wgetstr +winch +winsch +winsertln +wmove +wprintw +wrefreash +wscanw +wstandend +wstandout +y0 +y1 +yn diff --git a/sys/MISSING-MANPAGE b/sys/MISSING-MANPAGE new file mode 100644 index 0000000..6aa16bd --- /dev/null +++ b/sys/MISSING-MANPAGE @@ -0,0 +1,9 @@ +creat (obsoleted by open) +killpg +ptarce +setregid +setreuid +sigblock (obsoleted by sigprocmask) +sigpause (obsoleted by sigsuspend) +sigsetmask (obsoleted by sigprocmask) +sigvec (obsoleted by sigaction) diff --git a/sys/MISSING_SYSCALLS b/sys/MISSING_SYSCALLS new file mode 100644 index 0000000..2cb3246 --- /dev/null +++ b/sys/MISSING_SYSCALLS @@ -0,0 +1,8 @@ +madvise UNIX +mincore UNIX +mlock UNIX +mprotect UNIX +msync UNIX +munlock UNIX +sigpending POSIX +sigstack compat[sigaltstack] diff --git a/sys/Makefile.inc b/sys/Makefile.inc new file mode 100644 index 0000000..bafd300 --- /dev/null +++ b/sys/Makefile.inc @@ -0,0 +1,150 @@ +# @(#)Makefile.inc 8.3 (Berkeley) 10/24/94 +# $FreeBSD: src/lsys/Makefile.inc,v 1.91 2001/09/21 21:35:22 rwatson Exp $ + +# sys sources +.PATH: ${.CURDIR}/${MACHINE_ARCH}/sys ${.CURDIR}/sys + +# Include the generated makefile containing the *complete* list +# of syscall names in MIASM. +#.include "${.CURDIR}/../../sys/sys/syscall.mk" + +# Include machine dependent definitions. +# +# MDASM names override the default syscall names in MIASM. +# NOASM will prevent the default syscall code from being generated. +# +.if exists(${.CURDIR}/${MACHINE_ARCH}/sys/Makefile.inc) +.include "${.CURDIR}/${MACHINE_ARCH}/sys/Makefile.inc" +.endif + +# Sources common to both syscall interfaces: +SRCS+= errno.c gettimeofday.c sigcatch.c sigsuspend.c getdtablesize.c \ + sigaction.c sigtramp.c crt_externs.c + + +# Add machine dependent asm sources: +SRCS+=${MDASM} + +# Look though the complete list of syscalls (MIASM) for names that are +# not defined with machine dependent implementations (MDASM) and are +# not declared for no generation of default code (NOASM). Add each +# syscall that satisfies these conditions to the ASM list. +.for _asm in ${MIASM} +.if (${MDASM:R:M${_asm:R}} == "") +.if (${NOASM:R:M${_asm:R}} == "") +ASM+=$(_asm) +.endif +.endif +.endfor + +OBJS+= ${ASM} ${PSEUDO} + +SASM= ${ASM:S/.o/.S/} + +SPSEUDO= ${PSEUDO:S/.o/.S/} + +SRCS+= ${SASM} ${SPSEUDO} + +# Generated files +CLEANFILES+= ${SASM} ${SPSEUDO} + +${SASM}: + printf '#include "SYS.h"\nRSYSCALL(${.PREFIX})\n' > ${.TARGET} + +${SPSEUDO}: + printf '#include "SYS.h"\nPSEUDO(${.PREFIX:S/_//})\n' \ + > ${.TARGET} + +.if ${LIB} == "c" +MAN2+= pthread_kill.2 pthread_sigmask.2 \ + sem_close.2 sem_open.2 sem_post.2 sem_trywait.2 \ + sem_unlink.2 sem_wait.2 shm_open.2 shm_unlink.2 \ + sigwait.2 getdtablesize.2 setreuid.2 setregid.2 \ + nanosleep.2 +#MAN+= _exit.2 accept.2 access.2 acct.2 adjtime.2 \ +# aio_cancel.2 aio_error.2 aio_read.2 aio_return.2 \ +# aio_suspend.2 aio_waitcomplete.2 aio_write.2 \ +# bind.2 brk.2 chdir.2 chflags.2 \ +# chmod.2 chown.2 chroot.2 clock_gettime.2 close.2 \ +# connect.2 dup.2 execve.2 extattr_get_file.2 \ +# fcntl.2 fhopen.2 flock.2 fork.2 fsync.2 \ +# getdirentries.2 getdtablesize.2 \ +# getfh.2 getfsstat.2 getgid.2 getgroups.2 getitimer.2 getlogin.2 \ +# getpeername.2 getpgrp.2 getpid.2 getpriority.2 getrlimit.2 \ +# getrusage.2 getsid.2 getsockname.2 \ +# getsockopt.2 gettimeofday.2 getuid.2 \ +# intro.2 ioctl.2 issetugid.2 jail.2 kill.2 \ +# kldfind.2 kldfirstmod.2 kldload.2 kldnext.2 kldstat.2 kldsym.2 \ +# kldunload.2 ktrace.2 kqueue.2 link.2 listen.2 lseek.2 \ +# madvise.2 mincore.2 minherit.2 mkdir.2 mkfifo.2 mknod.2 mlock.2 mmap.2 \ +# modfind.2 modnext.2 modstat.2 \ +# mount.2 mprotect.2 msync.2 munmap.2 nanosleep.2 \ +# nfssvc.2 open.2 pathconf.2 pipe.2 poll.2 profil.2 ptrace.2 quotactl.2 \ +# read.2 readlink.2 reboot.2 recv.2 rename.2 revoke.2 rfork.2 rmdir.2 \ +# rtprio.2 select.2 semctl.2 semget.2 semop.2 send.2 sendfile.2 \ +# setgroups.2 setpgid.2 setregid.2 setresuid.2 setreuid.2 setsid.2 \ +# setuid.2 shmat.2 shmctl.2 shmget.2 shutdown.2 \ +# sigaction.2 sigaltstack.2 sigpending.2 sigprocmask.2 sigreturn.2 \ +# sigstack.2 sigsuspend.2 socket.2 socketpair.2 stat.2 statfs.2 \ +# swapon.2 symlink.2 sync.2 sysarch.2 syscall.2 \ +# truncate.2 umask.2 undelete.2 \ +# unlink.2 utimes.2 vfork.2 wait.2 write.2 +#.if !defined(NO_P1003_1B) +#MAN+= sched_get_priority_max.2 sched_setparam.2 \ +# sched_setscheduler.2 sched_yield.2 +#.endif + +#MLINKS+=access.2 eaccess.2 +#MLINKS+=brk.2 sbrk.2 +#MLINKS+=chdir.2 fchdir.2 +#MLINKS+=chflags.2 fchflags.2 +#MLINKS+=chmod.2 fchmod.2 chmod.2 lchmod.2 +#MLINKS+=chown.2 fchown.2 chown.2 lchown.2 +#MLINKS+=clock_gettime.2 clock_getres.2 clock_gettime.2 clock_settime.2 +#MLINKS+=dup.2 dup2.2 +#MLINKS+=extattr_get_file.2 extattr_set_file.2 \ +# extattr_get_file.2 extattr_delete_file.2 \ +# extattr_get_file.2 extattr_get_fd.2 \ +# extattr_get_file.2 extattr_set_fd.2 \ +# extattr_get_file.2 extattr_delete_fd.2 \ +# extattr_get_file.2 extattr.2 +#MLINKS+=fhopen.2 fhstat.2 fhopen.2 fhstatfs.2 +#MLINKS+=getdirentries.2 getdents.2 +#MLINKS+=getgid.2 getegid.2 +#MLINKS+=getitimer.2 setitimer.2 +#MLINKS+=getlogin.2 getlogin_r.3 +#MLINKS+=getlogin.2 setlogin.2 +#MLINKS+=getpgrp.2 getpgid.2 +#MLINKS+=getpid.2 getppid.2 +#MLINKS+=getpriority.2 setpriority.2 +#MLINKS+=getrlimit.2 setrlimit.2 +#MLINKS+=getsockopt.2 setsockopt.2 +#MLINKS+=gettimeofday.2 settimeofday.2 +#MLINKS+=getuid.2 geteuid.2 +#MLINKS+=intro.2 errno.2 +#MLINKS+=kqueue.2 kevent.2 +#MLINKS+=mlock.2 munlock.2 +#MLINKS+=modnext.2 modfnext.2 +#MLINKS+=mount.2 unmount.2 +#MLINKS+=pathconf.2 fpathconf.2 +#MLINKS+=read.2 pread.2 read.2 readv.2 +#MLINKS+=recv.2 recvfrom.2 recv.2 recvmsg.2 +#MLINKS+=send.2 sendmsg.2 send.2 sendto.2 +#MLINKS+=setpgid.2 setpgrp.2 +#MLINKS+=setresuid.2 setresgid.2 setresuid.2 getresuid.2 setresuid.2 getresgid.2 +#MLINKS+=setuid.2 setegid.2 setuid.2 seteuid.2 setuid.2 setgid.2 +#MLINKS+=shmat.2 shmdt.2 +#MLINKS+=stat.2 fstat.2 stat.2 lstat.2 +#MLINKS+=statfs.2 fstatfs.2 +#MLINKS+=syscall.2 __syscall.2 +#MLINKS+=truncate.2 ftruncate.2 +#MLINKS+=utimes.2 futimes.2 utimes.2 lutimes.2 +#MLINKS+=wait.2 wait3.2 wait.2 wait4.2 wait.2 waitpid.2 +#MLINKS+=write.2 pwrite.2 write.2 writev.2 +#.if !defined(NO_P1003_1B) +#MLINKS+=sched_get_priority_max.2 sched_get_priority_min.2 \ +# sched_get_priority_max.2 sched_rr_get_interval.2 +#MLINKS+=sched_setparam.2 sched_getparam.2 +#MLINKS+=sched_setscheduler.2 sched_getscheduler.2 +#.endif +.endif diff --git a/sys/REQUIRED-MACROS b/sys/REQUIRED-MACROS new file mode 100644 index 0000000..4482b7a --- /dev/null +++ b/sys/REQUIRED-MACROS @@ -0,0 +1,3 @@ +sigmask +WCOREDUMP + diff --git a/sys/SYSCALL-LIST b/sys/SYSCALL-LIST new file mode 100644 index 0000000..e49e492 --- /dev/null +++ b/sys/SYSCALL-LIST @@ -0,0 +1,145 @@ +accept +access +acct +adjtime +bind +brk +sbrk +chdir +fchdir +chflags +creat +fchflags +chmod +fchmod +chown +fchown +chroot +close +connect +dup +dup2 +execve +_exit +fcntl +flock +fork +fsync +getdirentries +getdtablesize +getfh +getfsstat +getgid +getegid +getgroups +getitimer +setitimer +getlogin +setlogin +getpeername +getpgrp +getpid +getppid +getpriority +setpriority +getrlimit +setrlimit +getrusage +getsockname +getsockopt +setsockopt +gettimeofday +settimeofday +getuid +geteuid +ioctl +kill +killpg +ktrace +link +listen +lseek +madvise +mincore +mkdir +mkfifo +mknod +mlock +munlock +mmap +mount +unmount +mprotect +msync +munmap +nfssvc +open +pathconf +fpathconf +pipe +profil +pthread_kill +pthread_sigmask +ptrace +quotactl +read +readv +readlink +reboot +recv +recvfrom +recvmsg +rename +revoke +rmdir +select +send +sendto +sendmsg +setgroups +setpgid +setpgrp +setregid +setreuid +setsid +setuid +seteuid +setgid +setegid +shutdown +sigaction +sigaltstack +sigblock +sigpause +sigpending +sigprocmask +sigreturn +sigsetmask +sigstack +sigsuspend +sigvec +sigwait +socket +socketpair +stat +lstat +fstat +statfs +fstatfs +swapon +symlink +sync +syscall +__syscall +truncate +ftruncate +umask +unlink +utimes +vfork +wait +waitpid +wait3 +wait4 +write +writev diff --git a/crt_externs.c b/sys/crt_externs.c similarity index 96% rename from crt_externs.c rename to sys/crt_externs.c index 04ec529..41c6c3c 100644 --- a/crt_externs.c +++ b/sys/crt_externs.c @@ -61,6 +61,12 @@ char ***_NSGetEnviron(void) { return(USE_VAR(environ)); } +char **_NSGetProgname(void) { + DECLARE_VAR(__progname, char *); + SETUP_VAR(__progname); + return(USE_VAR(__progname)); +} + struct mach_header *_NSGetMachExecuteHeader(void) { DECLARE_VAR(_mh_execute_header, struct mach_header); SETUP_VAR(_mh_execute_header); diff --git a/sys.subproj/errno.c b/sys/errno.c similarity index 97% rename from sys.subproj/errno.c rename to sys/errno.c index 9539d89..87b8da6 100644 --- a/sys.subproj/errno.c +++ b/sys/errno.c @@ -34,7 +34,7 @@ extern int errno; int *__error(void) { pthread_t self = pthread_self(); /* If we're not a detached pthread, just return the global errno */ - if ((self == (pthread_t)0) || (self->sig != _PTHREAD_SIG) || (self->detached == _PTHREAD_CREATE_PARENT)) { + if ((self == (pthread_t)0) || (self->sig != _PTHREAD_SIG) || (self->detached & _PTHREAD_CREATE_PARENT)) { return &errno; } return &self->err_no; diff --git a/sys/getdtablesize.2 b/sys/getdtablesize.2 new file mode 100644 index 0000000..7465f9a --- /dev/null +++ b/sys/getdtablesize.2 @@ -0,0 +1,63 @@ +.\" Copyright (c) 1983, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)getdtablesize.2 8.1 (Berkeley) 6/4/93 +.\" $FreeBSD: src/lib/libc/sys/getdtablesize.2,v 1.4.2.3 2001/12/14 18:34:00 ru Exp $ +.\" +.Dd June 4, 1993 +.Dt GETDTABLESIZE 2 +.Os +.Sh NAME +.Nm getdtablesize +.Nd get descriptor table size +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft int +.Fn getdtablesize void +.Sh DESCRIPTION +Each process has a fixed size descriptor table, +which is guaranteed to have at least 20 slots. The entries in +the descriptor table are numbered with small integers starting at 0. +The call +.Fn getdtablesize +returns the size of this table. +.Sh SEE ALSO +.Xr close 2 , +.Xr dup 2 , +.Xr open 2 , +.Xr select 2 +.Sh HISTORY +The +.Fn getdtablesize +function call appeared in +.Bx 4.2 . diff --git a/sys.subproj/getdtablesize.c b/sys/getdtablesize.c similarity index 100% rename from sys.subproj/getdtablesize.c rename to sys/getdtablesize.c diff --git a/sys.subproj/gettimeofday.c b/sys/gettimeofday.c similarity index 92% rename from sys.subproj/gettimeofday.c rename to sys/gettimeofday.c index 8aa14ac..07ad5f0 100644 --- a/sys.subproj/gettimeofday.c +++ b/sys/gettimeofday.c @@ -37,14 +37,22 @@ int gettimeofday (struct timeval *tp, struct timezone *tzp) static int validtz = 0; static struct timezone cached_tz = {0}; struct timeval localtv; +#ifdef __ppc__ + extern __ppc_gettimeofday(struct timeval *, struct timezone *); +#endif if (tzp && (tp == NULL) && (validtz == 0)) { tp = &localtv; } +#ifdef __ppc__ + if(__ppc_gettimeofday(tp, tzp)) + return(-1); +#else if (syscall (SYS_gettimeofday, tp, tzp) < 0) { return (-1); } +#endif if (tzp) { if (validtz == 0) { struct tm *localtm = localtime ((time_t *)&tp->tv_sec); diff --git a/sys.subproj/msync.2 b/sys/msync.2 similarity index 100% rename from sys.subproj/msync.2 rename to sys/msync.2 diff --git a/sys/nanosleep.2 b/sys/nanosleep.2 new file mode 100644 index 0000000..a0db6d6 --- /dev/null +++ b/sys/nanosleep.2 @@ -0,0 +1,104 @@ +.\" $FreeBSD: src/lib/libc/sys/nanosleep.2,v 1.8.2.4 2001/12/14 18:34:01 ru Exp $ +.\" $OpenBSD: nanosleep.2,v 1.1 1997/04/20 20:56:20 tholo Exp $ +.\" $NetBSD: nanosleep.2,v 1.1 1997/04/17 18:12:02 jtc Exp $ +.\" +.\" Copyright (c) 1986, 1991, 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)sleep.3 8.1 (Berkeley) 6/4/93 +.\" +.Dd April 17, 1997 +.Dt NANOSLEEP 2 +.Os +.Sh NAME +.Nm nanosleep +.Nd suspend process execution for an interval measured in nanoseconds +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In time.h +.Ft int +.Fn nanosleep "const struct timespec *rqtp" "struct timespec *rmtp" +.Sh DESCRIPTION +.Fn Nanosleep +causes the process to sleep for the specified time. An unmasked signal will +cause it to terminate the sleep early, regardless of the +.Dv SA_RESTART +value on the interrupting signal. +.Sh RETURN VALUES +If the +.Fn nanosleep +function returns because the requested time has elapsed, the value +returned will be zero. +.Pp +If the +.Fn nanosleep +function returns due to the delivery of a signal, the value returned +will be the -1, and the global variable +.Va errno +will be set to indicate the interruption. +If +.Fa rmtp +is +.Pf non- Dv NULL , +the timespec structure it references is updated to contain the +unslept amount (the request time minus the time actually slept). +.Sh ERRORS +The +.Fn nanosleep +call fails if: +.Bl -tag -width Er +.It Bq Er EFAULT +Either +.Fa rqtp +or +.Fa rmtp +points to memory that is not a valid part of the process +address space. +.It Bq Er EINTR +.Fn nanosleep +was interrupted by the delivery of a signal. +.It Bq Er EINVAL +.Fa rqtp +specified a nanosecond value less than zero +or greater than or equal to 1000 million. +.It Bq Er ENOSYS +.Fn nanosleep +is not supported by this implementation. +.El +.Sh SEE ALSO +.Xr sigsuspend 2 , +.Xr sleep 3 +.Sh STANDARDS +The +.Fn nanosleep +function conforms to +.St -p1003.1b-93 . diff --git a/sys/pthread_kill.2 b/sys/pthread_kill.2 new file mode 100644 index 0000000..068b23e --- /dev/null +++ b/sys/pthread_kill.2 @@ -0,0 +1,75 @@ +.\" Darwin +.\" +.\" Copyright (C) 2000 Jason Evans . +.\" 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(s), this list of conditions and the following disclaimer as +.\" the first lines of this file unmodified other than the possible +.\" addition of one or more copyright notices. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice(s), this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_kill.3,v 1.8 2001/10/01 16:09:09 ru Exp $ +.Dd Feb 05, 2002 +.Dt PTHREAD_KILL 2 +.Os +.Sh NAME +.Nm pthread_kill +.Nd send a signal to a specified thread +.Sh SYNOPSIS +.In pthread.h +.In signal.h +.Ft int +.Fn pthread_kill "pthread_t thread" "int sig" +.Sh DESCRIPTION +The +.Fn pthread_kill +function sends a signal, specified by +.Fa sig , +to a thread, specified by +.Fa thread . +If +.Fa sig +is 0, error checking is performed, but no signal is actually sent. +.Sh RETURN VALUES +If successful, +.Fn pthread_kill +returns 0. +Otherwise, an error number is returned. +.Sh ERRORS +.Fn pthread_kill +will fail if: +.Bl -tag -width Er +.It Bq Er ESRCH +.Fa thread +is an invalid thread ID. +.It Bq Er EINVAL +.Fa sig +is an invalid or unsupported signal number. +.El +.Sh SEE ALSO +.Xr kill 2 , +.Xr pthread_self 3 , +.Xr raise 3 +.Sh STANDARDS +.Fn pthread_kill +conforms to ISO/IEC 9945-1:1996 (``POSIX.1'') + diff --git a/sys/pthread_sigmask.2 b/sys/pthread_sigmask.2 new file mode 100644 index 0000000..f961512 --- /dev/null +++ b/sys/pthread_sigmask.2 @@ -0,0 +1,94 @@ +.\" Copyright (C) 2000 Jason Evans . +.\" 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(s), this list of conditions and the following disclaimer as +.\" the first lines of this file unmodified other than the possible +.\" addition of one or more copyright notices. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice(s), this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/pthread_sigmask.3,v 1.9 2001/10/01 16:09:09 ru Exp $ +.Dd April 27, 2000 +.Dt PTHREAD_SIGMASK 2 +.Os +.Sh NAME +.Nm pthread_sigmask +.Nd examine and/or change a thread's signal mask +.Sh SYNOPSIS +.In pthread.h +.In signal.h +.Ft int +.Fn pthread_sigmask "int how" "const sigset_t *set" "sigset_t *oset" +.Sh DESCRIPTION +The +.Fn pthread_sigmask +function examines and/or changes the calling thread's signal mask. +.Pp +If +.Fa set +is not +.Dv NULL , +it specifies a set of signals to be modified, and +.Fa how +specifies what to set the signal mask to: +.Bl -tag -width SIG_UNBLOCK +.It Dv SIG_BLOCK +Union of the current mask and +.Fa set . +.It Dv SIG_UNBLOCK +Intersection of the current mask and the complement of +.Fa set . +.It Dv SIG_SETMASK +.Fa set . +.El +.Pp +If +.Fa oset +is not NULL, the previous signal mask is stored in the location pointed to by +.Fa oset . +.Pp +.Dv SIGKILL +and +.Dv SIGSTOP +cannot be blocked, and will be silently ignored if included in the signal mask. +.Sh RETURN VALUES +If successful, +.Fn pthread_sigmask +returns 0. +Otherwise, an error is returned. +.Sh ERRORS +.Fn pthread_sigmask +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +.Fa how +is not one of the defined values. +.El +.Sh SEE ALSO +.Xr sigaction 2 , +.Xr sigpending 2 , +.Xr sigprocmask 2 , +.Xr sigsuspend 2 , +.Xr sigsetops 3 +.Sh STANDARDS +.Fn pthread_sigmask +conforms to ISO/IEC 9945-1:1996 (``POSIX.1'') + diff --git a/sys.subproj/sem_close.2 b/sys/sem_close.2 similarity index 93% rename from sys.subproj/sem_close.2 rename to sys/sem_close.2 index 9d09d20..60fc5b6 100644 --- a/sys.subproj/sem_close.2 +++ b/sys/sem_close.2 @@ -1,7 +1,6 @@ .\" $Darwin$ .\" -.\" Wilfredo Sanchez, wsanchez@apple.com -.\" Copyright (c) 2000 Apple Computer, Inc. All rights reserved. +.\" Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. .\" .\" @APPLE_LICENSE_HEADER_START@ .\" diff --git a/sys.subproj/sem_open.2 b/sys/sem_open.2 similarity index 97% rename from sys.subproj/sem_open.2 rename to sys/sem_open.2 index 582bb25..5f4d923 100644 --- a/sys.subproj/sem_open.2 +++ b/sys/sem_open.2 @@ -1,7 +1,6 @@ .\" $Darwin$ .\" -.\" Wilfredo Sanchez, wsanchez@apple.com -.\" Copyright (c) 2000 Apple Computer, Inc. All rights reserved. +.\" Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. .\" .\" @APPLE_LICENSE_HEADER_START@ .\" diff --git a/sys.subproj/sem_post.2 b/sys/sem_post.2 similarity index 94% rename from sys.subproj/sem_post.2 rename to sys/sem_post.2 index 8f2b285..d5afd23 100644 --- a/sys.subproj/sem_post.2 +++ b/sys/sem_post.2 @@ -1,7 +1,6 @@ .\" $Darwin$ .\" -.\" Wilfredo Sanchez, wsanchez@apple.com -.\" Copyright (c) 2000 Apple Computer, Inc. All rights reserved. +.\" Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. .\" .\" @APPLE_LICENSE_HEADER_START@ .\" diff --git a/sys.subproj/sem_trywait.2 b/sys/sem_trywait.2 similarity index 100% rename from sys.subproj/sem_trywait.2 rename to sys/sem_trywait.2 diff --git a/sys.subproj/sem_unlink.2 b/sys/sem_unlink.2 similarity index 95% rename from sys.subproj/sem_unlink.2 rename to sys/sem_unlink.2 index 785862d..213628a 100644 --- a/sys.subproj/sem_unlink.2 +++ b/sys/sem_unlink.2 @@ -1,7 +1,6 @@ .\" $Darwin$ .\" -.\" Wilfredo Sanchez, wsanchez@apple.com -.\" Copyright (c) 2000 Apple Computer, Inc. All rights reserved. +.\" Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. .\" .\" @APPLE_LICENSE_HEADER_START@ .\" diff --git a/sys.subproj/sem_wait.2 b/sys/sem_wait.2 similarity index 96% rename from sys.subproj/sem_wait.2 rename to sys/sem_wait.2 index db5a1b8..feeff3b 100644 --- a/sys.subproj/sem_wait.2 +++ b/sys/sem_wait.2 @@ -1,7 +1,6 @@ .\" $Darwin$ .\" -.\" Wilfredo Sanchez, wsanchez@apple.com -.\" Copyright (c) 2000 Apple Computer, Inc. All rights reserved. +.\" Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. .\" .\" @APPLE_LICENSE_HEADER_START@ .\" diff --git a/sys/setregid.2 b/sys/setregid.2 new file mode 100644 index 0000000..39f95d8 --- /dev/null +++ b/sys/setregid.2 @@ -0,0 +1,92 @@ +.\" Copyright (c) 1980, 1991, 1993, 1994 +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)setregid.2 8.2 (Berkeley) 4/16/94 +.\" $FreeBSD: src/lib/libc/sys/setregid.2,v 1.6.2.4 2001/12/14 18:34:01 ru Exp $ +.\" +.Dd April 16, 1994 +.Dt SETREGID 2 +.Os +.Sh NAME +.Nm setregid +.Nd set real and effective group ID +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft int +.Fn setregid "gid_t rgid" "gid_t egid" +.Sh DESCRIPTION +The real and effective group ID's of the current process +are set to the arguments. +Unprivileged users may change the real group +ID to the effective group ID and vice-versa; only the super-user may +make other changes. +.Pp +Supplying a value of -1 for either the real or effective +group ID forces the system to substitute the current +ID in place of the -1 parameter. +.Pp +The +.Fn setregid +function was intended to allow swapping +the real and effective group IDs +in set-group-ID programs to temporarily relinquish the set-group-ID value. +This function did not work correctly, +and its purpose is now better served by the use of the +.Fn setegid +function (see +.Xr setuid 2 ) . +.Pp +When setting the real and effective group IDs to the same value, +the standard +.Fn setgid +function is preferred. +.Sh RETURN VALUES +.Rv -std setregid +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er EPERM +The current process is not the super-user and a change +other than changing the effective group-id to the real group-id +was specified. +.El +.Sh SEE ALSO +.Xr getgid 2 , +.Xr issetugid 2 , +.Xr setegid 2 , +.Xr setgid 2 , +.Xr setuid 2 +.Sh HISTORY +The +.Fn setregid +system call appeared in +.Bx 4.2 . diff --git a/sys/setreuid.2 b/sys/setreuid.2 new file mode 100644 index 0000000..1215a59 --- /dev/null +++ b/sys/setreuid.2 @@ -0,0 +1,90 @@ +.\" Copyright (c) 1980, 1991, 1993, 1994 +.\" 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)setreuid.2 8.2 (Berkeley) 4/16/94 +.\" $FreeBSD: src/lib/libc/sys/setreuid.2,v 1.6.2.6 2001/12/14 18:34:01 ru Exp $ +.\" +.Dd February 8, 2001 +.Dt SETREUID 2 +.Os +.Sh NAME +.Nm setreuid +.Nd set real and effective user ID's +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft int +.Fn setreuid "uid_t ruid" "uid_t euid" +.Sh DESCRIPTION +The real and effective user IDs of the +current process are set according to the arguments. +If +.Fa ruid +or +.Fa euid +is -1, the current uid is filled in by the system. +Unprivileged users may change the real user +ID to the effective user ID and vice-versa; only the super-user may +make other changes. +.Pp +The +.Fn setreuid +function has been used to swap the real and effective user IDs +in set-user-ID programs to temporarily relinquish the set-user-ID value. +This purpose is now better served by the use of the +.Fn seteuid +function (see +.Xr setuid 2 ) . +.Pp +When setting the real and effective user IDs to the same value, +the standard +.Fn setuid +function is preferred. +.Sh RETURN VALUES +.Rv -std setreuid +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er EPERM +The current process is not the super-user and a change +other than changing the effective user-id to the real user-id +was specified. +.El +.Sh SEE ALSO +.Xr getuid 2 , +.Xr issetugid 2 , +.Xr seteuid 2 , +.Xr setuid 2 +.Sh HISTORY +The +.Fn setreuid +system call appeared in +.Bx 4.2 . diff --git a/sys.subproj/shm_open.2 b/sys/shm_open.2 similarity index 97% rename from sys.subproj/shm_open.2 rename to sys/shm_open.2 index 24dac52..ebf2fd3 100644 --- a/sys.subproj/shm_open.2 +++ b/sys/shm_open.2 @@ -1,7 +1,6 @@ .\" $Darwin$ .\" -.\" Wilfredo Sanchez, wsanchez@apple.com -.\" Copyright (c) 1999 Apple Computer, Inc. All rights reserved. +.\" Copyright (c) 1999-2002 Apple Computer, Inc. All rights reserved. .\" .\" @APPLE_LICENSE_HEADER_START@ .\" diff --git a/sys.subproj/shm_unlink.2 b/sys/shm_unlink.2 similarity index 95% rename from sys.subproj/shm_unlink.2 rename to sys/shm_unlink.2 index a2a2191..0d85afd 100644 --- a/sys.subproj/shm_unlink.2 +++ b/sys/shm_unlink.2 @@ -1,7 +1,6 @@ .\" $Darwin$ .\" -.\" Wilfredo Sanchez, wsanchez@apple.com -.\" Copyright (c) 1999 Apple Computer, Inc. All rights reserved. +.\" Copyright (c) 1999-2002 Apple Computer, Inc. All rights reserved. .\" .\" @APPLE_LICENSE_HEADER_START@ .\" diff --git a/sys.subproj/sigaction.c b/sys/sigaction.c similarity index 84% rename from sys.subproj/sigaction.c rename to sys/sigaction.c index 5f57366..1c3709e 100644 --- a/sys.subproj/sigaction.c +++ b/sys/sigaction.c @@ -36,7 +36,6 @@ * from sigvec in sys/kern_sig.c. */ -extern void (*sigcatch[NSIG])(); #if defined(__DYNAMIC__) extern int __in_sigtramp; #endif @@ -50,29 +49,30 @@ sigaction__ (sig, nsv, osv, bind) struct sigaction vec; void (*prevsig)(); extern void _sigtramp(); + struct __sigaction sa; + struct __sigaction *sap; if (sig <= 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP) { errno = EINVAL; return (-1); } - prevsig = sigcatch[sig]; + sap = (struct __sigaction *)0; if (nsv) { - sigcatch[sig] = nsv->sa_handler; - vec = *nsv; nsv = &vec; + sa.sa_handler = nsv->sa_handler; + sa.sa_tramp = _sigtramp; + sa.sa_mask = nsv->sa_mask; + sa.sa_flags = nsv->sa_flags; + sap = &sa; if (nsv->sa_handler != (void (*)())SIG_DFL && nsv->sa_handler != (void (*)())SIG_IGN) { - nsv->sa_handler = _sigtramp; #ifdef __DYNAMIC__ if (bind && (__in_sigtramp == 0)) // XXX - _dyld_bind_fully_image_containing_address(sigcatch[sig]); + _dyld_bind_fully_image_containing_address(nsv->sa_handler); #endif } } - if (syscall (SYS_sigaction, sig, nsv, osv) < 0) { - sigcatch[sig] = prevsig; + if (syscall (SYS_sigaction, sig, sap, osv) < 0) { return (-1); } - if (osv && prevsig) - osv->sa_handler = prevsig; return (0); } diff --git a/sys.subproj/sigcatch.c b/sys/sigcatch.c similarity index 100% rename from sys.subproj/sigcatch.c rename to sys/sigcatch.c diff --git a/sys.subproj/sigcatch.h b/sys/sigcatch.h similarity index 100% rename from sys.subproj/sigcatch.h rename to sys/sigcatch.h diff --git a/sys.subproj/sigsuspend.c b/sys/sigsuspend.c similarity index 100% rename from sys.subproj/sigsuspend.c rename to sys/sigsuspend.c diff --git a/sys.subproj/sigtramp.c b/sys/sigtramp.c similarity index 83% rename from sys.subproj/sigtramp.c rename to sys/sigtramp.c index 407add5..0ab0ece 100644 --- a/sys.subproj/sigtramp.c +++ b/sys/sigtramp.c @@ -25,6 +25,7 @@ #import "sigcatch.h" #import #import +#import /* * sigvec registers _sigtramp as the handler for any signal requiring @@ -39,19 +40,25 @@ int __in_sigtramp = 0; void _sigtramp( - int code, - int subcode, - struct sigcontext *scp + union __sigaction_u __sigaction_u, + int sigstyle, + int sig, + siginfo_t *sinfo, + struct ucontext *uctx ) { - sigcatch_t catcher; - catcher = sigcatch[code]; #if defined(__DYNAMIC__) __in_sigtramp++; #endif - catcher(code, subcode, scp); + if (sigstyle == 1) + sa_handler(sig); +#ifdef __ppc__ + else + sa_sigaction(sig, sinfo, uctx); +#endif /* __ppc__ */ + #if defined(__DYNAMIC__) __in_sigtramp--; #endif - sigreturn(scp); + sigreturn(uctx); } diff --git a/sys/sigwait.2 b/sys/sigwait.2 new file mode 100644 index 0000000..5309a79 --- /dev/null +++ b/sys/sigwait.2 @@ -0,0 +1,82 @@ +.\" Copyright (C) 2000 Jason Evans . +.\" 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(s), this list of conditions and the following disclaimer as +.\" the first lines of this file unmodified other than the possible +.\" addition of one or more copyright notices. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice(s), this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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. +.\" +.\" $FreeBSD: src/lib/libc_r/man/sigwait.3,v 1.7 2001/10/01 16:09:09 ru Exp $ +.Dd April 27, 2000 +.Dt SIGWAIT 2 +.Os +.Sh NAME +.Nm sigwait +.Nd select a set of signals +.Sh SYNOPSIS +.In signal.h +.Ft int +.Fn sigwait "const sigset_t *set" "int *sig" +.Sh DESCRIPTION +The +.Fn sigwait +function selects a set of signals, specified by +.Fa set . +If none of the selected signals are pending, +.Fn sigwait +waits until one or more of the selected signals has been generated. +Then +.Fn sigwait +atomically clears one of the selected signals from the set of pending signals +for the process and sets the location pointed to by +.Fa sig +to the signal number that was cleared. +.Pp +The signals specified by +.Fa set +should be blocked at the time of the call to +.Fn sigwait . +.Sh RETURN VALUES +If successful, +.Fn sigwait +returns 0 and sets the location pointed to by +.Fa sig +to the cleared signal number. +Otherwise, an error number is returned. +.Sh ERRORS +.Fn sigwait +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +.Fa set +specifies one or more invalid signal numbers. +.El +.Sh SEE ALSO +.Xr sigaction 2 , +.Xr sigpending 2 , +.Xr sigsuspend 2 , +.Xr pause 3 , +.Xr pthread_sigmask 2 +.Sh STANDARDS +.Fn sigwait +conforms to ISO/IEC 9945-1:1996 (``POSIX.1'') + diff --git a/threads.subproj/Makefile b/threads.subproj/Makefile deleted file mode 100644 index a61e757..0000000 --- a/threads.subproj/Makefile +++ /dev/null @@ -1,57 +0,0 @@ -# -# Generated by the NeXT Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = threads - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -HFILES = cthread_internals.h cthreads.h - -CFILES = cprocs.c cthreads.c lu_utils.c mig_support.c - -SUBPROJECTS = i386.subproj ppc.subproj - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble - - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -NEXTSTEP_INSTALLDIR = /Local/Developer/System -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - -NEXTSTEP_PB_CFLAGS = -D__POSIX_LIB__ -PROJECT_HEADERS = cthread_internals.h cthreads.h - - - -NEXTSTEP_BUILD_OUTPUT_DIR = /Local/Public/Sandbox/$(USER)/BUILD/$(NAME) - -NEXTSTEP_PUBLIC_HEADERS_DIR = /usr/include - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/threads.subproj/Makefile.postamble b/threads.subproj/Makefile.postamble deleted file mode 100644 index 411cde6..0000000 --- a/threads.subproj/Makefile.postamble +++ /dev/null @@ -1,100 +0,0 @@ -############################################################################### -# Makefile.postamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile, which is imported after all other makefiles, to -# override attributes for a project's Makefile environment. This allows you -# to take advantage of the environment set up by the other Makefiles. -# You can also define custom rules at the end of this file. -# -############################################################################### -# -# These variables are exported by the standard makefiles and can be -# used in any customizations you make. They are *outputs* of -# the Makefiles and should be used, not set. -# -# PRODUCTS: products to install. All of these products will be placed in -# the directory $(DSTROOT)$(INSTALLDIR) -# GLOBAL_RESOURCE_DIR: The directory to which resources are copied. -# LOCAL_RESOURCE_DIR: The directory to which localized resources are copied. -# OFILE_DIR: Directory into which .o object files are generated. -# DERIVED_SRC_DIR: Directory used for all other derived files -# -# ALL_CFLAGS: flags to pass when compiling .c files -# ALL_MFLAGS: flags to pass when compiling .m files -# ALL_CCFLAGS: flags to pass when compiling .cc, .cxx, and .C files -# ALL_MMFLAGS: flags to pass when compiling .mm, .mxx, and .M files -# ALL_PRECOMPFLAGS: flags to pass when precompiling .h files -# ALL_LDFLAGS: flags to pass when linking object files -# ALL_LIBTOOL_FLAGS: flags to pass when libtooling object files -# ALL_PSWFLAGS: flags to pass when processing .psw and .pswm (pswrap) files -# ALL_RPCFLAGS: flags to pass when processing .rpc (rpcgen) files -# ALL_YFLAGS: flags to pass when processing .y (yacc) files -# ALL_LFLAGS: flags to pass when processing .l (lex) files -# -# NAME: name of application, bundle, subproject, palette, etc. -# LANGUAGES: langages in which the project is written (default "English") -# English_RESOURCES: localized resources (e.g. nib's, images) of project -# GLOBAL_RESOURCES: non-localized resources of project -# -# SRCROOT: base directory in which to place the new source files -# SRCPATH: relative path from SRCROOT to present subdirectory -# -# INSTALLDIR: Directory the product will be installed into by 'install' target -# PUBLIC_HDR_INSTALLDIR: where to install public headers. Don't forget -# to prefix this with DSTROOT when you use it. -# PRIVATE_HDR_INSTALLDIR: where to install private headers. Don't forget -# to prefix this with DSTROOT when you use it. -# -# EXECUTABLE_EXT: Executable extension for the platform (i.e. .exe on Windows) -# -############################################################################### - -# Some compiler flags can be overridden here for certain build situations. -# -# WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost) -# DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults -# to -g) -# DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG) -# OPTIMIZE_BUILD_CFLAGS: flags passed during optimized builds (defaults -# to -O) -# PROFILE_BUILD_CFLAGS: flags passed during profile builds (defaults -# to -pg -DPROFILE) -# LOCAL_DIR_INCLUDE_DIRECTIVE: flag used to add current directory to -# the include path (defaults to -I.) -# DEBUG_BUILD_LDFLAGS, OPTIMIZE_BUILD_LDFLAGS, PROFILE_BUILD_LDFLAGS: flags -# passed to ld/libtool (defaults to nothing) - - -# Library and Framework projects only: -# INSTALL_NAME_DIRECTIVE: This directive ensures that executables linked -# against the framework will run against the correct version even if -# the current version of the framework changes. You may override this -# to "" as an alternative to using the DYLD_LIBRARY_PATH during your -# development cycle, but be sure to restore it before installing. - - -# Ownership and permissions of files installed by 'install' target - -#INSTALL_AS_USER = root - # User/group ownership -#INSTALL_AS_GROUP = wheel - # (probably want to set both of these) -#INSTALL_PERMISSIONS = - # If set, 'install' chmod's executable to this - - -# Options to strip. Note: -S strips debugging symbols (executables can be stripped -# down further with -x or, if they load no bundles, with no options at all). - -#STRIPFLAGS = -S - - -######################################################################### -# Put rules to extend the behavior of the standard Makefiles here. Include them in -# the dependency tree via cvariables like AFTER_INSTALL in the Makefile.preamble. -# -# You should avoid redefining things like "install" or "app", as they are -# owned by the top-level Makefile API and no context has been set up for where -# derived files should go. -# diff --git a/threads.subproj/Makefile.preamble b/threads.subproj/Makefile.preamble deleted file mode 100644 index c1624b4..0000000 --- a/threads.subproj/Makefile.preamble +++ /dev/null @@ -1,137 +0,0 @@ -############################################################################### -# Makefile.preamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile for configuring the standard application makefiles -# associated with ProjectBuilder. It is included before the main makefile. -# In Makefile.preamble you set attributes for a project, so they are available -# to the project's makefiles. In contrast, you typically write additional rules or -# override built-in behavior in the Makefile.postamble. -# -# Each directory in a project tree (main project plus subprojects) should -# have its own Makefile.preamble and Makefile.postamble. -############################################################################### -# -# Before the main makefile is included for this project, you may set: -# -# MAKEFILEDIR: Directory in which to find $(MAKEFILE) -# MAKEFILE: Top level mechanism Makefile (e.g., app.make, bundle.make) - -# Compiler/linker flags added to the defaults: The OTHER_* variables will be -# inherited by all nested sub-projects, but the LOCAL_ versions of the same -# variables will not. Put your -I, -D, -U, and -L flags in ProjectBuilder's -# Build Attributes inspector if at all possible. To override the default flags -# that get passed to ${CC} (e.g. change -O to -O2), see Makefile.postamble. The -# variables below are *inputs* to the build process and distinct from the override -# settings done (less often) in the Makefile.postamble. -# -# OTHER_CFLAGS, LOCAL_CFLAGS: additional flags to pass to the compiler -# Note that $(OTHER_CFLAGS) and $(LOCAL_CFLAGS) are used for .h, ...c, .m, -# .cc, .cxx, .C, and .M files. There is no need to respecify the -# flags in OTHER_MFLAGS, etc. -# OTHER_MFLAGS, LOCAL_MFLAGS: additional flags for .m files -# OTHER_CCFLAGS, LOCAL_CCFLAGS: additional flags for .cc, .cxx, and ...C files -# OTHER_MMFLAGS, LOCAL_MMFLAGS: additional flags for .mm and .M files -# OTHER_PRECOMPFLAGS, LOCAL_PRECOMPFLAGS: additional flags used when -# precompiling header files -# OTHER_LDFLAGS, LOCAL_LDFLAGS: additional flags passed to ld and libtool -# OTHER_PSWFLAGS, LOCAL_PSWFLAGS: additional flags passed to pswrap -# OTHER_RPCFLAGS, LOCAL_RPCFLAGS: additional flags passed to rpcgen -# OTHER_YFLAGS, LOCAL_YFLAGS: additional flags passed to yacc -# OTHER_LFLAGS, LOCAL_LFLAGS: additional flags passed to lex - -# These variables provide hooks enabling you to add behavior at almost every -# stage of the make: -# -# BEFORE_PREBUILD: targets to build before installing headers for a subproject -# AFTER_PREBUILD: targets to build after installing headers for a subproject -# BEFORE_BUILD_RECURSION: targets to make before building subprojects -# BEFORE_BUILD: targets to make before a build, but after subprojects -# AFTER_BUILD: targets to make after a build -# -# BEFORE_INSTALL: targets to build before installing the product -# AFTER_INSTALL: targets to build after installing the product -# BEFORE_POSTINSTALL: targets to build before postinstalling every subproject -# AFTER_POSTINSTALL: targts to build after postinstalling every subproject -# -# BEFORE_INSTALLHDRS: targets to build before installing headers for a -# subproject -# AFTER_INSTALLHDRS: targets to build after installing headers for a subproject -# BEFORE_INSTALLSRC: targets to build before installing source for a subproject -# AFTER_INSTALLSRC: targets to build after installing source for a subproject -# -# BEFORE_DEPEND: targets to build before building dependencies for a -# subproject -# AFTER_DEPEND: targets to build after building dependencies for a -# subproject -# -# AUTOMATIC_DEPENDENCY_INFO: if YES, then the dependency file is -# updated every time the project is built. If NO, the dependency -# file is only built when the depend target is invoked. - -# Framework-related variables: -# FRAMEWORK_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the framework's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables - -# Library-related variables: -# PUBLIC_HEADER_DIR: Determines where public exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. For library projects you should -# set this to something like /Developer/Headers/$(NAME). Do not set -# this variable for framework projects unless you do not want the -# header files included in the framework. -# PRIVATE_HEADER_DIR: Determines where private exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. -# LIBRARY_STYLE: This may be either STATIC or DYNAMIC, and determines -# whether the libraries produced are statically linked when they -# are used or if they are dynamically loadable. This defaults to -# DYNAMIC. -# LIBRARY_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the library's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables -# -# INSTALL_AS_USER: owner of the intalled products (default root) -# INSTALL_AS_GROUP: group of the installed products (default wheel) -# INSTALL_PERMISSIONS: permissions of the installed product (default o+rX) -# -# OTHER_RECURSIVE_VARIABLES: The names of variables which you want to be -# passed on the command line to recursive invocations of make. Note that -# the values in OTHER_*FLAGS are inherited by subprojects automatically -- -# you do not have to (and shouldn't) add OTHER_*FLAGS to -# OTHER_RECURSIVE_VARIABLES. - -# Additional headers to export beyond those in the PB.project: -# OTHER_PUBLIC_HEADERS -# OTHER_PROJECT_HEADERS -# OTHER_PRIVATE_HEADERS - -# Additional files for the project's product: <> -# OTHER_RESOURCES: (non-localized) resources for this project -# OTHER_OFILES: relocatables to be linked into this project -# OTHER_LIBS: more libraries to link against -# OTHER_PRODUCT_DEPENDS: other dependencies of this project -# OTHER_SOURCEFILES: other source files maintained by .pre/postamble -# OTHER_GARBAGE: additional files to be removed by `make clean' - -# Set this to YES if you don't want a final libtool call for a library/framework. -# BUILD_OFILES_LIST_ONLY - -# To include a version string, project source must exist in a directory named -# $(NAME).%d[.%d][.%d] and the following line must be uncommented. -# OTHER_GENERATED_OFILES = $(VERS_OFILE) - -# This definition will suppress stripping of debug symbols when an executable -# is installed. By default it is YES. -# STRIP_ON_INSTALL = NO - -# Uncomment to suppress generation of a KeyValueCoding index when installing -# frameworks (This index is used by WOB and IB to determine keys available -# for an object). Set to YES by default. -# PREINDEX_FRAMEWORK = NO - -# Change this definition to install projects somewhere other than the -# standard locations. NEXT_ROOT defaults to "C:/Apple" on Windows systems -# and "" on other systems. -DSTROOT = $(HOME) diff --git a/threads.subproj/PB.project b/threads.subproj/PB.project deleted file mode 100644 index e63fd07..0000000 --- a/threads.subproj/PB.project +++ /dev/null @@ -1,28 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - H_FILES = (cthread_internals.h, cthreads.h); - OTHER_LINKED = (cprocs.c, cthreads.c, lu_utils.c, mig_support.c); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble); - PROJECT_HEADERS = (cthread_internals.h, cthreads.h); - SUBPROJECTS = (i386.subproj, ppc.subproj); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDDIR = "/Local/Public/Sandbox/$(USER)/BUILD/$(NAME)"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_COMPILEROPTIONS = "-D__POSIX_LIB__"; - NEXTSTEP_INSTALLDIR = /Local/Developer/System; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - NEXTSTEP_PUBLICHEADERSDIR = /usr/include; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = threads; - PROJECTTYPE = Component; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/threads.subproj/i386.subproj/Makefile b/threads.subproj/i386.subproj/Makefile deleted file mode 100644 index 9a10ba3..0000000 --- a/threads.subproj/i386.subproj/Makefile +++ /dev/null @@ -1,45 +0,0 @@ -# -# Generated by the NeXT Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = i386 - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -CFILES = thread.c - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble - - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - - - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/threads.subproj/i386.subproj/Makefile.postamble b/threads.subproj/i386.subproj/Makefile.postamble deleted file mode 100644 index 411cde6..0000000 --- a/threads.subproj/i386.subproj/Makefile.postamble +++ /dev/null @@ -1,100 +0,0 @@ -############################################################################### -# Makefile.postamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile, which is imported after all other makefiles, to -# override attributes for a project's Makefile environment. This allows you -# to take advantage of the environment set up by the other Makefiles. -# You can also define custom rules at the end of this file. -# -############################################################################### -# -# These variables are exported by the standard makefiles and can be -# used in any customizations you make. They are *outputs* of -# the Makefiles and should be used, not set. -# -# PRODUCTS: products to install. All of these products will be placed in -# the directory $(DSTROOT)$(INSTALLDIR) -# GLOBAL_RESOURCE_DIR: The directory to which resources are copied. -# LOCAL_RESOURCE_DIR: The directory to which localized resources are copied. -# OFILE_DIR: Directory into which .o object files are generated. -# DERIVED_SRC_DIR: Directory used for all other derived files -# -# ALL_CFLAGS: flags to pass when compiling .c files -# ALL_MFLAGS: flags to pass when compiling .m files -# ALL_CCFLAGS: flags to pass when compiling .cc, .cxx, and .C files -# ALL_MMFLAGS: flags to pass when compiling .mm, .mxx, and .M files -# ALL_PRECOMPFLAGS: flags to pass when precompiling .h files -# ALL_LDFLAGS: flags to pass when linking object files -# ALL_LIBTOOL_FLAGS: flags to pass when libtooling object files -# ALL_PSWFLAGS: flags to pass when processing .psw and .pswm (pswrap) files -# ALL_RPCFLAGS: flags to pass when processing .rpc (rpcgen) files -# ALL_YFLAGS: flags to pass when processing .y (yacc) files -# ALL_LFLAGS: flags to pass when processing .l (lex) files -# -# NAME: name of application, bundle, subproject, palette, etc. -# LANGUAGES: langages in which the project is written (default "English") -# English_RESOURCES: localized resources (e.g. nib's, images) of project -# GLOBAL_RESOURCES: non-localized resources of project -# -# SRCROOT: base directory in which to place the new source files -# SRCPATH: relative path from SRCROOT to present subdirectory -# -# INSTALLDIR: Directory the product will be installed into by 'install' target -# PUBLIC_HDR_INSTALLDIR: where to install public headers. Don't forget -# to prefix this with DSTROOT when you use it. -# PRIVATE_HDR_INSTALLDIR: where to install private headers. Don't forget -# to prefix this with DSTROOT when you use it. -# -# EXECUTABLE_EXT: Executable extension for the platform (i.e. .exe on Windows) -# -############################################################################### - -# Some compiler flags can be overridden here for certain build situations. -# -# WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost) -# DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults -# to -g) -# DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG) -# OPTIMIZE_BUILD_CFLAGS: flags passed during optimized builds (defaults -# to -O) -# PROFILE_BUILD_CFLAGS: flags passed during profile builds (defaults -# to -pg -DPROFILE) -# LOCAL_DIR_INCLUDE_DIRECTIVE: flag used to add current directory to -# the include path (defaults to -I.) -# DEBUG_BUILD_LDFLAGS, OPTIMIZE_BUILD_LDFLAGS, PROFILE_BUILD_LDFLAGS: flags -# passed to ld/libtool (defaults to nothing) - - -# Library and Framework projects only: -# INSTALL_NAME_DIRECTIVE: This directive ensures that executables linked -# against the framework will run against the correct version even if -# the current version of the framework changes. You may override this -# to "" as an alternative to using the DYLD_LIBRARY_PATH during your -# development cycle, but be sure to restore it before installing. - - -# Ownership and permissions of files installed by 'install' target - -#INSTALL_AS_USER = root - # User/group ownership -#INSTALL_AS_GROUP = wheel - # (probably want to set both of these) -#INSTALL_PERMISSIONS = - # If set, 'install' chmod's executable to this - - -# Options to strip. Note: -S strips debugging symbols (executables can be stripped -# down further with -x or, if they load no bundles, with no options at all). - -#STRIPFLAGS = -S - - -######################################################################### -# Put rules to extend the behavior of the standard Makefiles here. Include them in -# the dependency tree via cvariables like AFTER_INSTALL in the Makefile.preamble. -# -# You should avoid redefining things like "install" or "app", as they are -# owned by the top-level Makefile API and no context has been set up for where -# derived files should go. -# diff --git a/threads.subproj/i386.subproj/Makefile.preamble b/threads.subproj/i386.subproj/Makefile.preamble deleted file mode 100644 index 6544e5f..0000000 --- a/threads.subproj/i386.subproj/Makefile.preamble +++ /dev/null @@ -1,137 +0,0 @@ -############################################################################### -# Makefile.preamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile for configuring the standard application makefiles -# associated with ProjectBuilder. It is included before the main makefile. -# In Makefile.preamble you set attributes for a project, so they are available -# to the project's makefiles. In contrast, you typically write additional rules or -# override built-in behavior in the Makefile.postamble. -# -# Each directory in a project tree (main project plus subprojects) should -# have its own Makefile.preamble and Makefile.postamble. -############################################################################### -# -# Before the main makefile is included for this project, you may set: -# -# MAKEFILEDIR: Directory in which to find $(MAKEFILE) -# MAKEFILE: Top level mechanism Makefile (e.g., app.make, bundle.make) - -# Compiler/linker flags added to the defaults: The OTHER_* variables will be -# inherited by all nested sub-projects, but the LOCAL_ versions of the same -# variables will not. Put your -I, -D, -U, and -L flags in ProjectBuilder's -# Build Attributes inspector if at all possible. To override the default flags -# that get passed to ${CC} (e.g. change -O to -O2), see Makefile.postamble. The -# variables below are *inputs* to the build process and distinct from the override -# settings done (less often) in the Makefile.postamble. -# -# OTHER_CFLAGS, LOCAL_CFLAGS: additional flags to pass to the compiler -# Note that $(OTHER_CFLAGS) and $(LOCAL_CFLAGS) are used for .h, ...c, .m, -# .cc, .cxx, .C, and .M files. There is no need to respecify the -# flags in OTHER_MFLAGS, etc. -# OTHER_MFLAGS, LOCAL_MFLAGS: additional flags for .m files -# OTHER_CCFLAGS, LOCAL_CCFLAGS: additional flags for .cc, .cxx, and ...C files -# OTHER_MMFLAGS, LOCAL_MMFLAGS: additional flags for .mm and .M files -# OTHER_PRECOMPFLAGS, LOCAL_PRECOMPFLAGS: additional flags used when -# precompiling header files -# OTHER_LDFLAGS, LOCAL_LDFLAGS: additional flags passed to ld and libtool -# OTHER_PSWFLAGS, LOCAL_PSWFLAGS: additional flags passed to pswrap -# OTHER_RPCFLAGS, LOCAL_RPCFLAGS: additional flags passed to rpcgen -# OTHER_YFLAGS, LOCAL_YFLAGS: additional flags passed to yacc -# OTHER_LFLAGS, LOCAL_LFLAGS: additional flags passed to lex - -# These variables provide hooks enabling you to add behavior at almost every -# stage of the make: -# -# BEFORE_PREBUILD: targets to build before installing headers for a subproject -# AFTER_PREBUILD: targets to build after installing headers for a subproject -# BEFORE_BUILD_RECURSION: targets to make before building subprojects -# BEFORE_BUILD: targets to make before a build, but after subprojects -# AFTER_BUILD: targets to make after a build -# -# BEFORE_INSTALL: targets to build before installing the product -# AFTER_INSTALL: targets to build after installing the product -# BEFORE_POSTINSTALL: targets to build before postinstalling every subproject -# AFTER_POSTINSTALL: targts to build after postinstalling every subproject -# -# BEFORE_INSTALLHDRS: targets to build before installing headers for a -# subproject -# AFTER_INSTALLHDRS: targets to build after installing headers for a subproject -# BEFORE_INSTALLSRC: targets to build before installing source for a subproject -# AFTER_INSTALLSRC: targets to build after installing source for a subproject -# -# BEFORE_DEPEND: targets to build before building dependencies for a -# subproject -# AFTER_DEPEND: targets to build after building dependencies for a -# subproject -# -# AUTOMATIC_DEPENDENCY_INFO: if YES, then the dependency file is -# updated every time the project is built. If NO, the dependency -# file is only built when the depend target is invoked. - -# Framework-related variables: -# FRAMEWORK_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the framework's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables - -# Library-related variables: -# PUBLIC_HEADER_DIR: Determines where public exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. For library projects you should -# set this to something like /Developer/Headers/$(NAME). Do not set -# this variable for framework projects unless you do not want the -# header files included in the framework. -# PRIVATE_HEADER_DIR: Determines where private exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. -# LIBRARY_STYLE: This may be either STATIC or DYNAMIC, and determines -# whether the libraries produced are statically linked when they -# are used or if they are dynamically loadable. This defaults to -# DYNAMIC. -# LIBRARY_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the library's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables -# -# INSTALL_AS_USER: owner of the intalled products (default root) -# INSTALL_AS_GROUP: group of the installed products (default wheel) -# INSTALL_PERMISSIONS: permissions of the installed product (default o+rX) -# -# OTHER_RECURSIVE_VARIABLES: The names of variables which you want to be -# passed on the command line to recursive invocations of make. Note that -# the values in OTHER_*FLAGS are inherited by subprojects automatically -- -# you do not have to (and shouldn't) add OTHER_*FLAGS to -# OTHER_RECURSIVE_VARIABLES. - -# Additional headers to export beyond those in the PB.project: -# OTHER_PUBLIC_HEADERS -# OTHER_PROJECT_HEADERS -# OTHER_PRIVATE_HEADERS - -# Additional files for the project's product: <> -# OTHER_RESOURCES: (non-localized) resources for this project -# OTHER_OFILES: relocatables to be linked into this project -# OTHER_LIBS: more libraries to link against -# OTHER_PRODUCT_DEPENDS: other dependencies of this project -# OTHER_SOURCEFILES: other source files maintained by .pre/postamble -# OTHER_GARBAGE: additional files to be removed by `make clean' - -# Set this to YES if you don't want a final libtool call for a library/framework. -# BUILD_OFILES_LIST_ONLY - -# To include a version string, project source must exist in a directory named -# $(NAME).%d[.%d][.%d] and the following line must be uncommented. -# OTHER_GENERATED_OFILES = $(VERS_OFILE) - -# This definition will suppress stripping of debug symbols when an executable -# is installed. By default it is YES. -# STRIP_ON_INSTALL = NO - -# Uncomment to suppress generation of a KeyValueCoding index when installing -# frameworks (This index is used by WOB and IB to determine keys available -# for an object). Set to YES by default. -# PREINDEX_FRAMEWORK = NO - -# Change this definition to install projects somewhere other than the -# standard locations. NEXT_ROOT defaults to "C:/Apple" on Windows systems -# and "" on other systems. -INCLUDED_ARCHS = i386 diff --git a/threads.subproj/i386.subproj/PB.project b/threads.subproj/i386.subproj/PB.project deleted file mode 100644 index a77b649..0000000 --- a/threads.subproj/i386.subproj/PB.project +++ /dev/null @@ -1,23 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - H_FILES = (); - OTHER_LINKED = (thread.c); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble); - SUBPROJECTS = (); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = i386; - PROJECTTYPE = Component; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/threads.subproj/ppc.subproj/Makefile b/threads.subproj/ppc.subproj/Makefile deleted file mode 100644 index 62e6941..0000000 --- a/threads.subproj/ppc.subproj/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -# -# Generated by the NeXT Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = ppc - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble - - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - - - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/threads.subproj/ppc.subproj/Makefile.postamble b/threads.subproj/ppc.subproj/Makefile.postamble deleted file mode 100644 index 411cde6..0000000 --- a/threads.subproj/ppc.subproj/Makefile.postamble +++ /dev/null @@ -1,100 +0,0 @@ -############################################################################### -# Makefile.postamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile, which is imported after all other makefiles, to -# override attributes for a project's Makefile environment. This allows you -# to take advantage of the environment set up by the other Makefiles. -# You can also define custom rules at the end of this file. -# -############################################################################### -# -# These variables are exported by the standard makefiles and can be -# used in any customizations you make. They are *outputs* of -# the Makefiles and should be used, not set. -# -# PRODUCTS: products to install. All of these products will be placed in -# the directory $(DSTROOT)$(INSTALLDIR) -# GLOBAL_RESOURCE_DIR: The directory to which resources are copied. -# LOCAL_RESOURCE_DIR: The directory to which localized resources are copied. -# OFILE_DIR: Directory into which .o object files are generated. -# DERIVED_SRC_DIR: Directory used for all other derived files -# -# ALL_CFLAGS: flags to pass when compiling .c files -# ALL_MFLAGS: flags to pass when compiling .m files -# ALL_CCFLAGS: flags to pass when compiling .cc, .cxx, and .C files -# ALL_MMFLAGS: flags to pass when compiling .mm, .mxx, and .M files -# ALL_PRECOMPFLAGS: flags to pass when precompiling .h files -# ALL_LDFLAGS: flags to pass when linking object files -# ALL_LIBTOOL_FLAGS: flags to pass when libtooling object files -# ALL_PSWFLAGS: flags to pass when processing .psw and .pswm (pswrap) files -# ALL_RPCFLAGS: flags to pass when processing .rpc (rpcgen) files -# ALL_YFLAGS: flags to pass when processing .y (yacc) files -# ALL_LFLAGS: flags to pass when processing .l (lex) files -# -# NAME: name of application, bundle, subproject, palette, etc. -# LANGUAGES: langages in which the project is written (default "English") -# English_RESOURCES: localized resources (e.g. nib's, images) of project -# GLOBAL_RESOURCES: non-localized resources of project -# -# SRCROOT: base directory in which to place the new source files -# SRCPATH: relative path from SRCROOT to present subdirectory -# -# INSTALLDIR: Directory the product will be installed into by 'install' target -# PUBLIC_HDR_INSTALLDIR: where to install public headers. Don't forget -# to prefix this with DSTROOT when you use it. -# PRIVATE_HDR_INSTALLDIR: where to install private headers. Don't forget -# to prefix this with DSTROOT when you use it. -# -# EXECUTABLE_EXT: Executable extension for the platform (i.e. .exe on Windows) -# -############################################################################### - -# Some compiler flags can be overridden here for certain build situations. -# -# WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost) -# DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults -# to -g) -# DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG) -# OPTIMIZE_BUILD_CFLAGS: flags passed during optimized builds (defaults -# to -O) -# PROFILE_BUILD_CFLAGS: flags passed during profile builds (defaults -# to -pg -DPROFILE) -# LOCAL_DIR_INCLUDE_DIRECTIVE: flag used to add current directory to -# the include path (defaults to -I.) -# DEBUG_BUILD_LDFLAGS, OPTIMIZE_BUILD_LDFLAGS, PROFILE_BUILD_LDFLAGS: flags -# passed to ld/libtool (defaults to nothing) - - -# Library and Framework projects only: -# INSTALL_NAME_DIRECTIVE: This directive ensures that executables linked -# against the framework will run against the correct version even if -# the current version of the framework changes. You may override this -# to "" as an alternative to using the DYLD_LIBRARY_PATH during your -# development cycle, but be sure to restore it before installing. - - -# Ownership and permissions of files installed by 'install' target - -#INSTALL_AS_USER = root - # User/group ownership -#INSTALL_AS_GROUP = wheel - # (probably want to set both of these) -#INSTALL_PERMISSIONS = - # If set, 'install' chmod's executable to this - - -# Options to strip. Note: -S strips debugging symbols (executables can be stripped -# down further with -x or, if they load no bundles, with no options at all). - -#STRIPFLAGS = -S - - -######################################################################### -# Put rules to extend the behavior of the standard Makefiles here. Include them in -# the dependency tree via cvariables like AFTER_INSTALL in the Makefile.preamble. -# -# You should avoid redefining things like "install" or "app", as they are -# owned by the top-level Makefile API and no context has been set up for where -# derived files should go. -# diff --git a/threads.subproj/ppc.subproj/Makefile.preamble b/threads.subproj/ppc.subproj/Makefile.preamble deleted file mode 100644 index 7211b2b..0000000 --- a/threads.subproj/ppc.subproj/Makefile.preamble +++ /dev/null @@ -1,137 +0,0 @@ -############################################################################### -# Makefile.preamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile for configuring the standard application makefiles -# associated with ProjectBuilder. It is included before the main makefile. -# In Makefile.preamble you set attributes for a project, so they are available -# to the project's makefiles. In contrast, you typically write additional rules or -# override built-in behavior in the Makefile.postamble. -# -# Each directory in a project tree (main project plus subprojects) should -# have its own Makefile.preamble and Makefile.postamble. -############################################################################### -# -# Before the main makefile is included for this project, you may set: -# -# MAKEFILEDIR: Directory in which to find $(MAKEFILE) -# MAKEFILE: Top level mechanism Makefile (e.g., app.make, bundle.make) - -# Compiler/linker flags added to the defaults: The OTHER_* variables will be -# inherited by all nested sub-projects, but the LOCAL_ versions of the same -# variables will not. Put your -I, -D, -U, and -L flags in ProjectBuilder's -# Build Attributes inspector if at all possible. To override the default flags -# that get passed to ${CC} (e.g. change -O to -O2), see Makefile.postamble. The -# variables below are *inputs* to the build process and distinct from the override -# settings done (less often) in the Makefile.postamble. -# -# OTHER_CFLAGS, LOCAL_CFLAGS: additional flags to pass to the compiler -# Note that $(OTHER_CFLAGS) and $(LOCAL_CFLAGS) are used for .h, ...c, .m, -# .cc, .cxx, .C, and .M files. There is no need to respecify the -# flags in OTHER_MFLAGS, etc. -# OTHER_MFLAGS, LOCAL_MFLAGS: additional flags for .m files -# OTHER_CCFLAGS, LOCAL_CCFLAGS: additional flags for .cc, .cxx, and ...C files -# OTHER_MMFLAGS, LOCAL_MMFLAGS: additional flags for .mm and .M files -# OTHER_PRECOMPFLAGS, LOCAL_PRECOMPFLAGS: additional flags used when -# precompiling header files -# OTHER_LDFLAGS, LOCAL_LDFLAGS: additional flags passed to ld and libtool -# OTHER_PSWFLAGS, LOCAL_PSWFLAGS: additional flags passed to pswrap -# OTHER_RPCFLAGS, LOCAL_RPCFLAGS: additional flags passed to rpcgen -# OTHER_YFLAGS, LOCAL_YFLAGS: additional flags passed to yacc -# OTHER_LFLAGS, LOCAL_LFLAGS: additional flags passed to lex - -# These variables provide hooks enabling you to add behavior at almost every -# stage of the make: -# -# BEFORE_PREBUILD: targets to build before installing headers for a subproject -# AFTER_PREBUILD: targets to build after installing headers for a subproject -# BEFORE_BUILD_RECURSION: targets to make before building subprojects -# BEFORE_BUILD: targets to make before a build, but after subprojects -# AFTER_BUILD: targets to make after a build -# -# BEFORE_INSTALL: targets to build before installing the product -# AFTER_INSTALL: targets to build after installing the product -# BEFORE_POSTINSTALL: targets to build before postinstalling every subproject -# AFTER_POSTINSTALL: targts to build after postinstalling every subproject -# -# BEFORE_INSTALLHDRS: targets to build before installing headers for a -# subproject -# AFTER_INSTALLHDRS: targets to build after installing headers for a subproject -# BEFORE_INSTALLSRC: targets to build before installing source for a subproject -# AFTER_INSTALLSRC: targets to build after installing source for a subproject -# -# BEFORE_DEPEND: targets to build before building dependencies for a -# subproject -# AFTER_DEPEND: targets to build after building dependencies for a -# subproject -# -# AUTOMATIC_DEPENDENCY_INFO: if YES, then the dependency file is -# updated every time the project is built. If NO, the dependency -# file is only built when the depend target is invoked. - -# Framework-related variables: -# FRAMEWORK_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the framework's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables - -# Library-related variables: -# PUBLIC_HEADER_DIR: Determines where public exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. For library projects you should -# set this to something like /Developer/Headers/$(NAME). Do not set -# this variable for framework projects unless you do not want the -# header files included in the framework. -# PRIVATE_HEADER_DIR: Determines where private exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. -# LIBRARY_STYLE: This may be either STATIC or DYNAMIC, and determines -# whether the libraries produced are statically linked when they -# are used or if they are dynamically loadable. This defaults to -# DYNAMIC. -# LIBRARY_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the library's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables -# -# INSTALL_AS_USER: owner of the intalled products (default root) -# INSTALL_AS_GROUP: group of the installed products (default wheel) -# INSTALL_PERMISSIONS: permissions of the installed product (default o+rX) -# -# OTHER_RECURSIVE_VARIABLES: The names of variables which you want to be -# passed on the command line to recursive invocations of make. Note that -# the values in OTHER_*FLAGS are inherited by subprojects automatically -- -# you do not have to (and shouldn't) add OTHER_*FLAGS to -# OTHER_RECURSIVE_VARIABLES. - -# Additional headers to export beyond those in the PB.project: -# OTHER_PUBLIC_HEADERS -# OTHER_PROJECT_HEADERS -# OTHER_PRIVATE_HEADERS - -# Additional files for the project's product: <> -# OTHER_RESOURCES: (non-localized) resources for this project -# OTHER_OFILES: relocatables to be linked into this project -# OTHER_LIBS: more libraries to link against -# OTHER_PRODUCT_DEPENDS: other dependencies of this project -# OTHER_SOURCEFILES: other source files maintained by .pre/postamble -# OTHER_GARBAGE: additional files to be removed by `make clean' - -# Set this to YES if you don't want a final libtool call for a library/framework. -# BUILD_OFILES_LIST_ONLY - -# To include a version string, project source must exist in a directory named -# $(NAME).%d[.%d][.%d] and the following line must be uncommented. -# OTHER_GENERATED_OFILES = $(VERS_OFILE) - -# This definition will suppress stripping of debug symbols when an executable -# is installed. By default it is YES. -# STRIP_ON_INSTALL = NO - -# Uncomment to suppress generation of a KeyValueCoding index when installing -# frameworks (This index is used by WOB and IB to determine keys available -# for an object). Set to YES by default. -# PREINDEX_FRAMEWORK = NO - -# Change this definition to install projects somewhere other than the -# standard locations. NEXT_ROOT defaults to "C:/Apple" on Windows systems -# and "" on other systems. -INCLUDED_ARCHS = ppc diff --git a/threads.subproj/ppc.subproj/PB.project b/threads.subproj/ppc.subproj/PB.project deleted file mode 100644 index 49e45ce..0000000 --- a/threads.subproj/ppc.subproj/PB.project +++ /dev/null @@ -1,23 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - H_FILES = (); - OTHER_LINKED = (); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble); - SUBPROJECTS = (); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = ppc; - PROJECTTYPE = Component; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/threads/Makefile.inc b/threads/Makefile.inc new file mode 100644 index 0000000..0f81896 --- /dev/null +++ b/threads/Makefile.inc @@ -0,0 +1,7 @@ +.PATH: ${.CURDIR}/${MACHINE_ARCH}/threads ${.CURDIR}/threads + +.if exists(${.CURDIR}/${MACHINE_ARCH}/threads/Makefile.inc) +.include "${.CURDIR}/${MACHINE_ARCH}/threads/Makefile.inc" +.endif + +SRCS += cprocs.c cthreads.c lu_utils.c mig_support.c diff --git a/threads.subproj/cprocs.c b/threads/cprocs.c similarity index 100% rename from threads.subproj/cprocs.c rename to threads/cprocs.c diff --git a/threads.subproj/cthread_internals.h b/threads/cthread_internals.h similarity index 100% rename from threads.subproj/cthread_internals.h rename to threads/cthread_internals.h diff --git a/threads.subproj/cthreads.c b/threads/cthreads.c similarity index 96% rename from threads.subproj/cthreads.c rename to threads/cthreads.c index 5bd7035..bad453f 100644 --- a/threads.subproj/cthreads.c +++ b/threads/cthreads.c @@ -87,7 +87,7 @@ void _cthread_fork_prepare() { _spin_lock(&psaved_self_global_lock); psaved_self = pthread_self(); - _spin_lock(&psaved_self->lock); + _spin_lock(&psaved_self->lock); _malloc_fork_prepare(); } @@ -123,9 +123,8 @@ void _cthread_fork_child() p->mutexes = NULL; p->cleanup_stack = NULL; p->death = MACH_PORT_NULL; - p->joiners = MACH_PORT_NULL; - p->num_joiners = 0; - p->detached = _PTHREAD_CREATE_PARENT; + p->joiner = NULL; + p->detached |= _PTHREAD_CREATE_PARENT; _spin_unlock(&p->lock); _cproc_fork_child(); @@ -135,6 +134,7 @@ void _cthread_fork_child() _pthread_fork_child(); __is_threaded = 0; + mig_init(1); /* enable multi-threaded mig interfaces */ } diff --git a/threads.subproj/cthreads.h b/threads/cthreads.h similarity index 100% rename from threads.subproj/cthreads.h rename to threads/cthreads.h diff --git a/threads.subproj/lu_utils.c b/threads/lu_utils.c similarity index 97% rename from threads.subproj/lu_utils.c rename to threads/lu_utils.c index 65a60a4..090f2e9 100644 --- a/threads.subproj/lu_utils.c +++ b/threads/lu_utils.c @@ -13,7 +13,7 @@ #include mach_port_t _lu_port = MACH_PORT_NULL; -static name_t LOOKUP_NAME = "lookup daemon"; +static name_t LOOKUP_NAME = "lookup daemon v2"; mach_port_t _lookupd_port(mach_port_t port) { if (port != MACH_PORT_NULL) { diff --git a/threads.subproj/mig_support.c b/threads/mig_support.c similarity index 100% rename from threads.subproj/mig_support.c rename to threads/mig_support.c diff --git a/util.subproj/Makefile b/util.subproj/Makefile deleted file mode 100644 index f9b0874..0000000 --- a/util.subproj/Makefile +++ /dev/null @@ -1,45 +0,0 @@ -# -# Generated by the NeXT Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = util - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Component - -CFILES = login.c login_tty.c logout.c logwtmp.c pty.c - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble - - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = subproj.make -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - - - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(JDKBINDIR)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/util.subproj/Makefile.postamble b/util.subproj/Makefile.postamble deleted file mode 100644 index 411cde6..0000000 --- a/util.subproj/Makefile.postamble +++ /dev/null @@ -1,100 +0,0 @@ -############################################################################### -# Makefile.postamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile, which is imported after all other makefiles, to -# override attributes for a project's Makefile environment. This allows you -# to take advantage of the environment set up by the other Makefiles. -# You can also define custom rules at the end of this file. -# -############################################################################### -# -# These variables are exported by the standard makefiles and can be -# used in any customizations you make. They are *outputs* of -# the Makefiles and should be used, not set. -# -# PRODUCTS: products to install. All of these products will be placed in -# the directory $(DSTROOT)$(INSTALLDIR) -# GLOBAL_RESOURCE_DIR: The directory to which resources are copied. -# LOCAL_RESOURCE_DIR: The directory to which localized resources are copied. -# OFILE_DIR: Directory into which .o object files are generated. -# DERIVED_SRC_DIR: Directory used for all other derived files -# -# ALL_CFLAGS: flags to pass when compiling .c files -# ALL_MFLAGS: flags to pass when compiling .m files -# ALL_CCFLAGS: flags to pass when compiling .cc, .cxx, and .C files -# ALL_MMFLAGS: flags to pass when compiling .mm, .mxx, and .M files -# ALL_PRECOMPFLAGS: flags to pass when precompiling .h files -# ALL_LDFLAGS: flags to pass when linking object files -# ALL_LIBTOOL_FLAGS: flags to pass when libtooling object files -# ALL_PSWFLAGS: flags to pass when processing .psw and .pswm (pswrap) files -# ALL_RPCFLAGS: flags to pass when processing .rpc (rpcgen) files -# ALL_YFLAGS: flags to pass when processing .y (yacc) files -# ALL_LFLAGS: flags to pass when processing .l (lex) files -# -# NAME: name of application, bundle, subproject, palette, etc. -# LANGUAGES: langages in which the project is written (default "English") -# English_RESOURCES: localized resources (e.g. nib's, images) of project -# GLOBAL_RESOURCES: non-localized resources of project -# -# SRCROOT: base directory in which to place the new source files -# SRCPATH: relative path from SRCROOT to present subdirectory -# -# INSTALLDIR: Directory the product will be installed into by 'install' target -# PUBLIC_HDR_INSTALLDIR: where to install public headers. Don't forget -# to prefix this with DSTROOT when you use it. -# PRIVATE_HDR_INSTALLDIR: where to install private headers. Don't forget -# to prefix this with DSTROOT when you use it. -# -# EXECUTABLE_EXT: Executable extension for the platform (i.e. .exe on Windows) -# -############################################################################### - -# Some compiler flags can be overridden here for certain build situations. -# -# WARNING_CFLAGS: flag used to set warning level (defaults to -Wmost) -# DEBUG_SYMBOLS_CFLAGS: debug-symbol flag passed to all builds (defaults -# to -g) -# DEBUG_BUILD_CFLAGS: flags passed during debug builds (defaults to -DDEBUG) -# OPTIMIZE_BUILD_CFLAGS: flags passed during optimized builds (defaults -# to -O) -# PROFILE_BUILD_CFLAGS: flags passed during profile builds (defaults -# to -pg -DPROFILE) -# LOCAL_DIR_INCLUDE_DIRECTIVE: flag used to add current directory to -# the include path (defaults to -I.) -# DEBUG_BUILD_LDFLAGS, OPTIMIZE_BUILD_LDFLAGS, PROFILE_BUILD_LDFLAGS: flags -# passed to ld/libtool (defaults to nothing) - - -# Library and Framework projects only: -# INSTALL_NAME_DIRECTIVE: This directive ensures that executables linked -# against the framework will run against the correct version even if -# the current version of the framework changes. You may override this -# to "" as an alternative to using the DYLD_LIBRARY_PATH during your -# development cycle, but be sure to restore it before installing. - - -# Ownership and permissions of files installed by 'install' target - -#INSTALL_AS_USER = root - # User/group ownership -#INSTALL_AS_GROUP = wheel - # (probably want to set both of these) -#INSTALL_PERMISSIONS = - # If set, 'install' chmod's executable to this - - -# Options to strip. Note: -S strips debugging symbols (executables can be stripped -# down further with -x or, if they load no bundles, with no options at all). - -#STRIPFLAGS = -S - - -######################################################################### -# Put rules to extend the behavior of the standard Makefiles here. Include them in -# the dependency tree via cvariables like AFTER_INSTALL in the Makefile.preamble. -# -# You should avoid redefining things like "install" or "app", as they are -# owned by the top-level Makefile API and no context has been set up for where -# derived files should go. -# diff --git a/util.subproj/Makefile.preamble b/util.subproj/Makefile.preamble deleted file mode 100644 index c1624b4..0000000 --- a/util.subproj/Makefile.preamble +++ /dev/null @@ -1,137 +0,0 @@ -############################################################################### -# Makefile.preamble -# Copyright 1997, Apple Computer, Inc. -# -# Use this makefile for configuring the standard application makefiles -# associated with ProjectBuilder. It is included before the main makefile. -# In Makefile.preamble you set attributes for a project, so they are available -# to the project's makefiles. In contrast, you typically write additional rules or -# override built-in behavior in the Makefile.postamble. -# -# Each directory in a project tree (main project plus subprojects) should -# have its own Makefile.preamble and Makefile.postamble. -############################################################################### -# -# Before the main makefile is included for this project, you may set: -# -# MAKEFILEDIR: Directory in which to find $(MAKEFILE) -# MAKEFILE: Top level mechanism Makefile (e.g., app.make, bundle.make) - -# Compiler/linker flags added to the defaults: The OTHER_* variables will be -# inherited by all nested sub-projects, but the LOCAL_ versions of the same -# variables will not. Put your -I, -D, -U, and -L flags in ProjectBuilder's -# Build Attributes inspector if at all possible. To override the default flags -# that get passed to ${CC} (e.g. change -O to -O2), see Makefile.postamble. The -# variables below are *inputs* to the build process and distinct from the override -# settings done (less often) in the Makefile.postamble. -# -# OTHER_CFLAGS, LOCAL_CFLAGS: additional flags to pass to the compiler -# Note that $(OTHER_CFLAGS) and $(LOCAL_CFLAGS) are used for .h, ...c, .m, -# .cc, .cxx, .C, and .M files. There is no need to respecify the -# flags in OTHER_MFLAGS, etc. -# OTHER_MFLAGS, LOCAL_MFLAGS: additional flags for .m files -# OTHER_CCFLAGS, LOCAL_CCFLAGS: additional flags for .cc, .cxx, and ...C files -# OTHER_MMFLAGS, LOCAL_MMFLAGS: additional flags for .mm and .M files -# OTHER_PRECOMPFLAGS, LOCAL_PRECOMPFLAGS: additional flags used when -# precompiling header files -# OTHER_LDFLAGS, LOCAL_LDFLAGS: additional flags passed to ld and libtool -# OTHER_PSWFLAGS, LOCAL_PSWFLAGS: additional flags passed to pswrap -# OTHER_RPCFLAGS, LOCAL_RPCFLAGS: additional flags passed to rpcgen -# OTHER_YFLAGS, LOCAL_YFLAGS: additional flags passed to yacc -# OTHER_LFLAGS, LOCAL_LFLAGS: additional flags passed to lex - -# These variables provide hooks enabling you to add behavior at almost every -# stage of the make: -# -# BEFORE_PREBUILD: targets to build before installing headers for a subproject -# AFTER_PREBUILD: targets to build after installing headers for a subproject -# BEFORE_BUILD_RECURSION: targets to make before building subprojects -# BEFORE_BUILD: targets to make before a build, but after subprojects -# AFTER_BUILD: targets to make after a build -# -# BEFORE_INSTALL: targets to build before installing the product -# AFTER_INSTALL: targets to build after installing the product -# BEFORE_POSTINSTALL: targets to build before postinstalling every subproject -# AFTER_POSTINSTALL: targts to build after postinstalling every subproject -# -# BEFORE_INSTALLHDRS: targets to build before installing headers for a -# subproject -# AFTER_INSTALLHDRS: targets to build after installing headers for a subproject -# BEFORE_INSTALLSRC: targets to build before installing source for a subproject -# AFTER_INSTALLSRC: targets to build after installing source for a subproject -# -# BEFORE_DEPEND: targets to build before building dependencies for a -# subproject -# AFTER_DEPEND: targets to build after building dependencies for a -# subproject -# -# AUTOMATIC_DEPENDENCY_INFO: if YES, then the dependency file is -# updated every time the project is built. If NO, the dependency -# file is only built when the depend target is invoked. - -# Framework-related variables: -# FRAMEWORK_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the framework's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables - -# Library-related variables: -# PUBLIC_HEADER_DIR: Determines where public exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. For library projects you should -# set this to something like /Developer/Headers/$(NAME). Do not set -# this variable for framework projects unless you do not want the -# header files included in the framework. -# PRIVATE_HEADER_DIR: Determines where private exported header files -# should be installed. Do not include $(DSTROOT) in this value -- -# it is prefixed automatically. -# LIBRARY_STYLE: This may be either STATIC or DYNAMIC, and determines -# whether the libraries produced are statically linked when they -# are used or if they are dynamically loadable. This defaults to -# DYNAMIC. -# LIBRARY_DLL_INSTALLDIR: On Windows platforms, this variable indicates -# where to put the library's DLL. This variable defaults to -# $(INSTALLDIR)/../Executables -# -# INSTALL_AS_USER: owner of the intalled products (default root) -# INSTALL_AS_GROUP: group of the installed products (default wheel) -# INSTALL_PERMISSIONS: permissions of the installed product (default o+rX) -# -# OTHER_RECURSIVE_VARIABLES: The names of variables which you want to be -# passed on the command line to recursive invocations of make. Note that -# the values in OTHER_*FLAGS are inherited by subprojects automatically -- -# you do not have to (and shouldn't) add OTHER_*FLAGS to -# OTHER_RECURSIVE_VARIABLES. - -# Additional headers to export beyond those in the PB.project: -# OTHER_PUBLIC_HEADERS -# OTHER_PROJECT_HEADERS -# OTHER_PRIVATE_HEADERS - -# Additional files for the project's product: <> -# OTHER_RESOURCES: (non-localized) resources for this project -# OTHER_OFILES: relocatables to be linked into this project -# OTHER_LIBS: more libraries to link against -# OTHER_PRODUCT_DEPENDS: other dependencies of this project -# OTHER_SOURCEFILES: other source files maintained by .pre/postamble -# OTHER_GARBAGE: additional files to be removed by `make clean' - -# Set this to YES if you don't want a final libtool call for a library/framework. -# BUILD_OFILES_LIST_ONLY - -# To include a version string, project source must exist in a directory named -# $(NAME).%d[.%d][.%d] and the following line must be uncommented. -# OTHER_GENERATED_OFILES = $(VERS_OFILE) - -# This definition will suppress stripping of debug symbols when an executable -# is installed. By default it is YES. -# STRIP_ON_INSTALL = NO - -# Uncomment to suppress generation of a KeyValueCoding index when installing -# frameworks (This index is used by WOB and IB to determine keys available -# for an object). Set to YES by default. -# PREINDEX_FRAMEWORK = NO - -# Change this definition to install projects somewhere other than the -# standard locations. NEXT_ROOT defaults to "C:/Apple" on Windows systems -# and "" on other systems. -DSTROOT = $(HOME) diff --git a/util.subproj/PB.project b/util.subproj/PB.project deleted file mode 100644 index 87e4046..0000000 --- a/util.subproj/PB.project +++ /dev/null @@ -1,23 +0,0 @@ -{ - DYNAMIC_CODE_GEN = YES; - FILESTABLE = { - H_FILES = (); - OTHER_LINKED = (login.c, login_tty.c, logout.c, logwtmp.c, pty.c); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble); - SUBPROJECTS = (); - }; - LANGUAGE = English; - MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; - NEXTSTEP_BUILDTOOL = /bin/gnumake; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; - PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = util; - PROJECTTYPE = Component; - PROJECTVERSION = 2.8; - WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/util/Makefile.inc b/util/Makefile.inc new file mode 100644 index 0000000..8151c6b --- /dev/null +++ b/util/Makefile.inc @@ -0,0 +1,3 @@ +.PATH: ${.CURDIR}/${MACHINE_ARCH}/util ${.CURDIR}/util + +SRCS += login.c login_tty.c logout.c logwtmp.c pty.c diff --git a/util.subproj/login.c b/util/login.c similarity index 100% rename from util.subproj/login.c rename to util/login.c diff --git a/util.subproj/login_tty.c b/util/login_tty.c similarity index 100% rename from util.subproj/login_tty.c rename to util/login_tty.c diff --git a/util.subproj/logout.c b/util/logout.c similarity index 100% rename from util.subproj/logout.c rename to util/logout.c diff --git a/util.subproj/logwtmp.c b/util/logwtmp.c similarity index 100% rename from util.subproj/logwtmp.c rename to util/logwtmp.c diff --git a/util.subproj/pty.c b/util/pty.c similarity index 100% rename from util.subproj/pty.c rename to util/pty.c diff --git a/xdr/Makefile.inc b/xdr/Makefile.inc new file mode 100644 index 0000000..6ca6859 --- /dev/null +++ b/xdr/Makefile.inc @@ -0,0 +1,52 @@ +# @(#)Makefile 5.11 (Berkeley) 9/6/90 +# $FreeBSD: src/lib/libc/xdr/Makefile.inc,v 1.12 2001/03/27 17:26:57 ru Exp $ + +.PATH: ${.CURDIR}/../libc/xdr ${.CURDIR}/. +SRCS+= xdr.c xdr_array.c xdr_float.c xdr_mem.c \ + xdr_rec.c xdr_reference.c xdr_stdio.c + +.if ${LIB} == "c" +MAN+= xdr.3 + +MLINKS+= rpc_xdr.3 xdr_accepted_reply.3 \ + rpc_xdr.3 xdr_authsys_parms.3 \ + rpc_xdr.3 xdr_callhdr.3 \ + rpc_xdr.3 xdr_callmsg.3 \ + rpc_xdr.3 xdr_opaque_auth.3 \ + rpc_xdr.3 xdr_rejected_reply.3 \ + rpc_xdr.3 xdr_replymsg.3 \ + xdr.3 xdr_array.3 \ + xdr.3 xdr_bool.3 \ + xdr.3 xdr_bytes.3 \ + xdr.3 xdr_char.3 \ + xdr.3 xdr_destroy.3 \ + xdr.3 xdr_double.3 \ + xdr.3 xdr_enum.3 \ + xdr.3 xdr_float.3 \ + xdr.3 xdr_free.3 \ + xdr.3 xdr_getpos.3 \ + xdr.3 xdr_inline.3 \ + xdr.3 xdr_int.3 \ + xdr.3 xdr_long.3 \ + xdr.3 xdrmem_create.3 \ + xdr.3 xdr_opaque.3 \ + xdr.3 xdr_pointer.3 \ + xdr.3 xdrrec_create.3 \ + xdr.3 xdrrec_endofrecord.3 \ + xdr.3 xdrrec_eof.3 \ + xdr.3 xdrrec_skiprecord.3 \ + xdr.3 xdr_reference.3 \ + xdr.3 xdr_setpos.3 \ + xdr.3 xdr_short.3 \ + xdr.3 xdrstdio_create.3 \ + xdr.3 xdr_short.3 \ + xdr.3 xdrstdio_create.3 \ + xdr.3 xdr_string.3 \ + xdr.3 xdr_u_char.3 \ + xdr.3 xdr_u_long.3 \ + xdr.3 xdr_u_short.3 \ + xdr.3 xdr_union.3 \ + xdr.3 xdr_vector.3 \ + xdr.3 xdr_void.3 \ + xdr.3 xdr_wrapstring.3 +.endif diff --git a/yp/Makefile.inc b/yp/Makefile.inc new file mode 100644 index 0000000..1f0668c --- /dev/null +++ b/yp/Makefile.inc @@ -0,0 +1,17 @@ +# from: @(#)Makefile.inc 5.3 (Berkeley) 2/20/91 +# $FreeBSD: src/lib/libc/yp/Makefile.inc,v 1.8 1999/08/28 00:02:58 peter Exp $ + +# yp sources +.PATH: ${.CURDIR}/../libc/yp + +SRCS+= xdryp.c yp.h yp_xdr.c yplib.c +CLEANFILES+= yp.h yp_xdr.c + +RPCSRC= ${DESTDIR}/usr/include/rpcsvc/yp.x +RPCGEN= rpcgen -C + +yp_xdr.c: ${RPCSRC} + ${RPCGEN} -c -o ${.TARGET} ${RPCSRC} + +yp.h: ${RPCSRC} + ${RPCGEN} -h -o ${.TARGET} ${RPCSRC} -- 2.45.2