Annotation of researchv10dc/cmd/odist/pax/ship/libx/910208/base, revision 1.1

1.1     ! root        1: 0707070000000000011006440044230044230000010000000475416516000002400000006446MakefileUgsfGgsf/*
        !             2:  * libx make
        !             3:  */
        !             4: 
        !             5: VERSION = 3.0
        !             6: 
        !             7: .SOURCE : comp dir hash man misc port preroot re \
        !             8:                sfio stdio string tm vec
        !             9: 
        !            10: .SOURCE.h : include
        !            11: 
        !            12: DEBUG ==
        !            13: LIBX == 1
        !            14: 
        !            15: HEADERSRC = error.h ftwalk.h hash.h hashpart.h ls.h namval.h \
        !            16:        option.h re.h sfio.h stack.h stak.h stdio.h swap.h tar.h tm.h
        !            17: 
        !            18: HEADERGEN = align.h dirent.h fsinfo.h limits.h sigdata.h
        !            19: 
        !            20: HEADERMK = lcldirent.h lcllimits.h lclparam.h lclstdio.h \
        !            21:        preroot.h sig.h ttyinfo.h
        !            22: 
        !            23: x $(VERSION) :LIBRARY: README hash.3 ftwalk.3 re.3 sfio.3 stak.3 tm.3 \
        !            24:        $(HEADERSRC) \
        !            25:        dirlib.h opendir.c readdir.c rewinddir.c seekdir.c telldir.c \
        !            26:        getcwd.c setcwd.c getshell.c \
        !            27:        hashlib.h hashalloc.c hashdump.c hashfree.c hashlook.c \
        !            28:        hashscan.c hashsize.c hashwalk.c \
        !            29:        memhash.c memsum.c strhash.c strsum.c \
        !            30:        cvtatoe.c cvtetoa.c \
        !            31:        chresc.c ctoi.c streval.c strmatch.c strcopy.c \
        !            32:        modelib.h strmode.c \
        !            33:        stresc.c stropt.c strtape.c tok.c \
        !            34:        pathaccess.c pathcanon.c pathcheck.c pathpath.c \
        !            35:        pathkey.c pathprobe.c pathtemp.c \
        !            36:        cmdargs.c fs3d.c ftwalk.c perror.c putenv.c calloc.c malloc.c \
        !            37:        getnamval.c optget.c hsort.c query.c \
        !            38:        error.c liberror.c strerror.c strsignal.c \
        !            39:        fmtelapsed.c fmtls.c fmtmode.c fmtperm.c fmtuid.c fmtgid.c \
        !            40:        strelapsed.c strperm.c struid.c strgid.c stack.c stak.c \
        !            41:        memswap.c gethalf.c getlong.c puthalf.c putlong.c \
        !            42:        fgetline.c sigcrit.c sigunblock.c \
        !            43:        cmdlib.h cmdopen.c cmdclose.c cmdrun.c cmdwait.c cmdkill.c \
        !            44:        relib.h recomp.c reerror.c reexec.c resub.c \
        !            45:        tmdate.c tmfix.c tmform.c tmgoff.c \
        !            46:        tminit.c tmleap.c tmlex.c tmmake.c tmpoff.c \
        !            47:        tmtime.c tmtype.c tmword.c tmzone.c \
        !            48:        vecargs.c vecfile.c vecfree.c vecload.c vecstring.c \
        !            49:        getsymlink.c putsymlink.c univlib.h univdata.c getuniv.c setuniv.c \
        !            50:        winsize.c fclex.c sigdata.c touch.c lpstat.c \
        !            51:        memcmp.c memcpy.c memdup.c memset.c \
        !            52:        mkdir.c rmdir.c remove.c rename.c link.c unlink.c \
        !            53:        strtok.c strspn.c strpbrk.c strdup.c strchr.c strrchr.c \
        !            54:        strtod.c strtol.c strton.c sigsetmask.c mktemp.c tmpnam.c \
        !            55:        vfork.c killpg.c lstat.c readlink.c symlink.c setpgid.c \
        !            56:        atexit.c getdents.c getwd.c copy.c dup2.c errno.c sgetl.c sputl.c \
        !            57:        getpreroot.c ispreroot.c realopen.c setpreroot.c \
        !            58:        mount.c popen.c system.c iblocks.c \
        !            59:        modedata.c tmdata.c \
        !            60:        sfhdr.h sfclose.c sfclrlock.c sfcvt.c sfdlen.c sfdopen.c \
        !            61:        sfexcept.c sfextern.c sffilbuf.c sfflsbuf.c sfgetd.c sfgetl.c \
        !            62:        sfgets.c sfgetu.c sfllen.c sfmode.c sfmove.c sfnew.c sfnotify.c \
        !            63:        sfnputc.c sfopen.c sfpeek.c sfpool.c sfpopen.c sfprintf.c sfputd.c \
        !            64:        sfputl.c sfputs.c sfputu.c sfread.c sfscanf.c sfseek.c \
        !            65:        sfsetbuf.c sfsetdisc.c sfset.c sfstack.c sfstrtod.c \
        !            66:        sfsync.c sftable.c sftell.c sftmpfile.c sfungetc.c sfvprintf.c \
        !            67:        sfvscanf.c sfwrite.c \
        !            68:        _sfhdr.h _sfclearerr.c _sffileno.c _sforigin.c _sfputl.c _sftmp.c \
        !            69:        _sfecvt.c _sfgetc.c _sfpeek.c _sfputu.c _sfulen.c _sfeof.c _sfgetl.c \
        !            70:        _sfpushed.c _sfslen.c _sferror.c _sfgetu.c _sfputc.c _sffcvt.c \
        !            71:        _sfputd.c _sfsync.c \
        !            72:        stdgets.c stdprintf.c stdscanf.c stdsetvbuf.c stdsprintf.c \
        !            73:        stdvsprintf.c stdvsscanf.c sprintf.c vsprintf.c
        !            74: 
        !            75: :READONLY: modedata.c sftable.c sigdata.c tmdata.c univdata.c
        !            76: 
        !            77: $(INCLUDEDIR) :INSTALLDIR: $(HEADERSRC) $(HEADERGEN) $(HEADERMK)
        !            78: 
        !            79: :INSTALLDIR: mkhdr genhdr
        !            80: 
        !            81: mkhdr :: mkhdr.sh
        !            82: 
        !            83: genhdr :: genhdr.c
        !            84: 
        !            85: $(HEADERGEN) : mkhdr genhdr
        !            86:        $(*:N=*mkhdr) $(<:B) "$(TARGET:/\\\\/\\/G) $(*:N=*genhdr)" "$(CC)" $(CCFLAGS) > $(<)
        !            87: 
        !            88: $(HEADERMK) : mkhdr
        !            89:        $(*) $(<:B) "" "$(CC)" $(CCFLAGS) > $(<)
        !            90: 0707070000000000021006440044230044230000010000000441571252600002200000006712READMEUgsfGgsfThe advanced software department has been collecting useful C routines
        !            91: in a single library called libx.  libx is used by nmake, the nmake cpp
        !            92: (which is mainly based on another library (libpp)), CIA
        !            93: (C information abstractor from Yih-Farn Chen), and a collection
        !            94: of other /bin and /usr/bin commands that benefit from
        !            95: concentrating functionality in libx.
        !            96: 
        !            97: More detail is available in the man pages.  libx contains:
        !            98: 
        !            99:   (1)  routines to support a generic environment for
        !           100:        a variety of UNIX operating system variants
        !           101: 
        !           102:   (2)  routines that update standard libc routines
        !           103: 
        !           104:   (3)  routines shared between several commands
        !           105: 
        !           106: If you already have nmake 2.0 or newer installed then use
        !           107: `nmake install' from this directory, otherwise use
        !           108: ship/shipin from the root of the distribution directory tree.
        !           109: 
        !           110: Some of the routines not found in section 3:
        !           111: 
        !           112: hash:                  generic, scoped hash table support
        !           113: 
        !           114:        hashalloc       create a hash table or push new scope
        !           115:        hashdump        debug dump of one or all hash tables
        !           116:        hashfree        free a hashalloc()'d table
        !           117:        hashlook        low level name lookup
        !           118:        hashscan        entry generator for scoped table scan
        !           119:        hashsize        explicitly change table size (usually automatic)
        !           120:        hashwalk        apply function to each table entry
        !           121:        memhash         return hash code for n-char chunk of memory
        !           122:        strhash         return hash code for null terminated string
        !           123: 
        !           124: include:               libx support headers
        !           125: 
        !           126:        align.h         compile time type alignmnent support
        !           127:        dirent.h        POSIX directory(3) interface definitions
        !           128:        error.h         error() interface definitions
        !           129:        ftw.h           ftwalk() interface definitions
        !           130:        hash.h          hash*() interface definitions
        !           131:        ls.h            strls() interface definitions
        !           132:        re.h            re*() interface definitions
        !           133:        tar.h           POSIX ustar format interface definitions
        !           134:        tm.h            tm*() interface definitions
        !           135: 
        !           136: misc:
        !           137: 
        !           138:        cmdargs         apply a sequence of cmd line option parsers
        !           139:        cmdopen         like popen() but stdin and stdout are specified
        !           140:        cvtatoe         convert ASCII to EBCDIC
        !           141:        cvtetoa         convert EBCDIC to ASCII
        !           142:        error           output generic error and trace messages
        !           143:        ftwalk          an ftw(3) that works -- used in new tw(1)
        !           144:        getcwd          uses $PWD if ok, doesn't use /bin/pwd
        !           145:        getshell        return full path of shell for cmdopen()
        !           146:        ooptget         optget() for obsolete ar(1) and tar(1) options
        !           147:        optget          YA getopt(3) but no argc or error message output
        !           148:        pathaccess      find file with specific acces on list of dirs
        !           149:        pathcanon       canonicalize path name in place
        !           150:        pathcmd         return full path name of executable using $PATH
        !           151:        pathroot        determine `related root' directory for command
        !           152:        perror          uses strerror()
        !           153:        readargs        append each line of file to argv[0]
        !           154: 
        !           155: re:                    egrep(1) and ed(1) style re's from V9
        !           156:                        (not the good awk(1) algorithm)
        !           157: 
        !           158:        recomp          compile re pattern
        !           159:        reerror         report re*() errors
        !           160:        reexec          match string using compiled re
        !           161:        resub           ed(1) style substitute using last reexec()
        !           162: 
        !           163: string:
        !           164: 
        !           165:        chresc          return next char in string converting \ sequences
        !           166:        ctoi            convert char constant string to int
        !           167:        strcopy         like strcpy(3) but returns end of destination
        !           168:        strdup          malloc(3) and strcpy(3) smashed together
        !           169:        strerror        return error message string given errno
        !           170:        stresc          convert \ sequences in string in place
        !           171:        streval         evaluate C expression in string
        !           172:        strls           ls -l format support
        !           173:        strmatch        Korn shell file pattern match
        !           174:        strmode         return ls -l style output given st.st_mode
        !           175:        strsignal       return signal id string given SIG* number
        !           176:        strtape         convert generic tape unit to /dev/* file
        !           177:        token           generate space separated tokens in string
        !           178: 
        !           179: tm:                    time conversion support
        !           180: 
        !           181:        tmdate          convert date string to time_t
        !           182:        tmform          format time_t to date string
        !           183:        tmmake          return current time_t
        !           184:        tmtime          convert struct tm to time_t
        !           185: 0707070000000000031006440044230044230000010000000471771066600003100000001610comp/atexit.cUgsfGgsf/*
        !           186:  * ANSI C atexit()
        !           187:  * arrange for func to be called LIFO on exit()
        !           188:  */
        !           189: 
        !           190: #include "FEATURE/atexit"
        !           191: 
        !           192: #ifdef _lib_atexit
        !           193: 
        !           194: int    _lib_dummy;
        !           195: 
        !           196: #else
        !           197: 
        !           198: typedef void (*PFV)();
        !           199: 
        !           200: #include "FEATURE/onexit"
        !           201: 
        !           202: #ifdef _lib_onexit
        !           203: 
        !           204: int
        !           205: atexit(func)
        !           206: PFV    func;
        !           207: {
        !           208:        return(onexit(func));
        !           209: }
        !           210: 
        !           211: #else
        !           212: 
        !           213: #include "FEATURE/on_exit"
        !           214: 
        !           215: #ifdef _lib_on_exit
        !           216: 
        !           217: int
        !           218: atexit(func)
        !           219: PFV    func;
        !           220: {
        !           221:        return(on_exit(func));
        !           222: }
        !           223: 
        !           224: #else
        !           225: 
        !           226: #include "FEATURE/_cleanup"
        !           227: 
        !           228: struct list
        !           229: {
        !           230:        struct list*    next;
        !           231:        PFV             func;
        !           232: };
        !           233: 
        !           234: static struct list*    funclist;
        !           235: 
        !           236: extern char*           malloc();
        !           237: 
        !           238: int
        !           239: atexit(func)
        !           240: PFV    func;
        !           241: {
        !           242:        register struct list*   p;
        !           243: 
        !           244:        if (!(p = (struct list*)malloc(sizeof(struct list)))) return(-1);
        !           245:        p->func = func;
        !           246:        p->next = funclist;
        !           247:        funclist = p;
        !           248:        return(0);
        !           249: }
        !           250: 
        !           251: int
        !           252: exit(code)
        !           253: int    code;
        !           254: {
        !           255:        register struct list*   p;
        !           256: 
        !           257:        for (p = funclist; p; p = p->next)
        !           258:                (*p->func)();
        !           259: #ifdef _lib__cleanup
        !           260:        _cleanup();
        !           261: #endif
        !           262:        _exit(code);
        !           263: }
        !           264: 
        !           265: #endif
        !           266: 
        !           267: #endif
        !           268: 
        !           269: #endif
        !           270: 0707070000000000041006440044230044230000010000000441570075300002700000000512comp/dup2.cUgsfGgsf#include "FEATURE/dup2"
        !           271: 
        !           272: #ifdef _lib_dup2
        !           273: 
        !           274: int    _lib_dummy;
        !           275: 
        !           276: #else
        !           277: 
        !           278: #include <fcntl.h>
        !           279: 
        !           280: extern int     errno;
        !           281: 
        !           282: extern int     close();
        !           283: extern int     fcntl();
        !           284: 
        !           285: int
        !           286: dup2(d1, d2)
        !           287: int    d1;
        !           288: int    d2;
        !           289: {
        !           290:        int     save_errno;
        !           291: 
        !           292:        if (d1 == d2) return(d1);
        !           293:        save_errno = errno;
        !           294:        (void)close(d2);
        !           295:        errno = save_errno;
        !           296:        return(fcntl(d1, F_DUPFD, d2));
        !           297: }
        !           298: 
        !           299: #endif
        !           300: 0707070000000000051006440044230044230000010000000461342262600003000000000220comp/errno.cUgsfGgsf/*
        !           301:  * this avoids multiple definitions with some libc's
        !           302:  * that define both a libx supplied routine and errno
        !           303:  * in the same .o
        !           304:  */
        !           305: 
        !           306: int    errno;
        !           307: 0707070000000000061006440044230044230000010000000474436324700003300000007014comp/getdents.cUgsfGgsf#include "FEATURE/getdents"
        !           308: #ifdef _lib_getdents
        !           309: 
        !           310: int    _lib_dummy;
        !           311: 
        !           312: #else
        !           313: 
        !           314: /*
        !           315:  * getdents
        !           316:  *
        !           317:  * read directory entries into directory block
        !           318:  *
        !           319:  * NOTE: directory entries must fit within DIRBLKSIZ boundaries
        !           320:  */
        !           321: 
        !           322: #include <fsinfo.h>
        !           323: #include <dirent.h>
        !           324: #include <errno.h>
        !           325: 
        !           326: #define round(x,y)     (((x)+((y)-1))&~((y)-1))
        !           327: 
        !           328: #ifndef        DIRBLKSIZ
        !           329: #ifdef DIRBLK
        !           330: #define DIRBLKSIZ      DIRBLK
        !           331: #else
        !           332: #ifdef DIRBUF
        !           333: #define DIRBLKSIZ      DIRBUF
        !           334: #else
        !           335: #ifdef DEV_BSIZE
        !           336: #define DIRBLKSIZ      DEV_BSIZE
        !           337: #else
        !           338: #define DIRBLKSIZ      4096
        !           339: #endif
        !           340: #endif
        !           341: #endif
        !           342: #endif
        !           343: 
        !           344: #ifndef MAXNAMLEN
        !           345: #define MAXNAMLEN      255
        !           346: #endif
        !           347: 
        !           348: int
        !           349: getdents(fd, buf, siz)
        !           350: int    fd;
        !           351: char*  buf;
        !           352: int    siz;
        !           353: {
        !           354:        struct stat             st;
        !           355: 
        !           356:        extern int              errno;
        !           357:        
        !           358:        extern int              fstat();
        !           359: 
        !           360:        if (siz < DIRBLKSIZ)
        !           361:        {
        !           362:                errno = EINVAL;
        !           363:                return(-1);
        !           364:        }
        !           365:        if (fstat(fd, &st)) return(-1);
        !           366:        if ((st.st_mode & S_IFMT) != S_IFDIR)
        !           367:        {
        !           368: #ifdef ENOTDIR
        !           369:                errno = ENOTDIR;
        !           370: #else
        !           371:                errno = EBADF;
        !           372: #endif
        !           373:                return(-1);
        !           374:        }
        !           375: #include "FEATURE/getdirentries"
        !           376: #ifdef _lib_getdirentries
        !           377:        {
        !           378:                long            off;
        !           379: 
        !           380:                extern int      getdirentries();
        !           381: 
        !           382:                return(getdirentries(fd, buf, siz, &off));
        !           383:        }
        !           384: #else
        !           385: #include "FEATURE/dirread"
        !           386: #ifdef _lib_dirread
        !           387:        {
        !           388:                register char*          sp;     /* system */
        !           389:                register struct dirent* up;     /* user */
        !           390:                char*                   u;
        !           391:                int                     n;
        !           392:                int                     m;
        !           393:                int                     i;
        !           394: 
        !           395:                extern int              dirread();
        !           396: 
        !           397:                m = (siz * 6) / 10;
        !           398:                m = round(m, 8);
        !           399:                sp = buf + siz - m - 1;
        !           400:                if (!(n = dirread(fd, sp, m))) return(0);
        !           401:                if (n > 0)
        !           402:                {
        !           403:                        up = (struct dirent*)buf;
        !           404:                        sp[n] = 0;
        !           405:                        while (sp < buf + siz - m + n)
        !           406:                        {
        !           407:                                i = 0;
        !           408:                                while (*sp >= '0' && *sp <= '9')
        !           409:                                        i = 10 * i + *sp++ - '0';
        !           410:                                while (*sp && *sp != '\t') sp++;
        !           411:                                if (*sp++)
        !           412:                                {
        !           413:                                        up->d_ino = i;
        !           414:                                        u = up->d_name;
        !           415:                                        while ((*u = *sp++) && u < up->d_name + MAXNAMLEN) u++;
        !           416:                                        *u = 0;
        !           417:                                        up->d_reclen = sizeof(struct dirent) - sizeof(up->d_name) + (
        !           418: #if defined(d_fileno) || defined(d_ino)
        !           419:                                                up->d_namlen =
        !           420: #endif
        !           421:                                                u - up->d_name) + 1;
        !           422:                                        up->d_reclen = round(up->d_reclen, 8);
        !           423:                                        up = (struct dirent*)((char*)up + up->d_reclen);
        !           424:                                }
        !           425:                        }
        !           426:                        return((char*)up - buf);
        !           427:                }
        !           428:        }
        !           429: #endif
        !           430:        {
        !           431: #ifndef _dir_fixed
        !           432: #include "FEATURE/readdir"
        !           433: #ifndef _lib_readdir
        !           434: #define _dir_fixed
        !           435: #endif
        !           436: #endif
        !           437: 
        !           438: #ifdef _dir_fixed
        !           439: #ifndef DIRSIZ
        !           440: #include "FEATURE/dir"
        !           441: #ifdef _sys_dir
        !           442: #include <sys/dir.h>
        !           443: #endif
        !           444: #endif
        !           445: 
        !           446: #define MAXREC round(sizeof(*up)-sizeof(up->d_name)+sizeof(sp->d_name)+1,8)
        !           447: 
        !           448:                register struct direct* sp;     /* system */
        !           449:                register struct dirent* up;     /* user */
        !           450:                register char*          s;
        !           451:                register char*          u;
        !           452:                int                     n;
        !           453:                int                     m;
        !           454:                char                    tmp[sizeof(sp->d_name) + 1];
        !           455: 
        !           456:                extern int              read();
        !           457:                extern int              strcpy();
        !           458:        
        !           459:                /*
        !           460:                 * we assume sizeof(struct dirent) > sizeof(struct direct)
        !           461:                 */
        !           462: 
        !           463:                up = (struct dirent*)buf;
        !           464:                n = (siz / MAXREC) * sizeof(struct direct);
        !           465:                if ((!(m = n & ~511) || m < MAXREC) && (!(m = n & ~255) || m < MAXREC)) m = n;
        !           466:                do
        !           467:                {
        !           468:                        if ((n = read(fd, buf + siz - m, m)) <= 0) break;
        !           469:                        sp = (struct direct*)(buf + siz - m);
        !           470:                        while (sp < (struct direct*)(buf + siz - m + n))
        !           471:                        {
        !           472:                                if (sp->d_ino)
        !           473:                                {
        !           474:                                        up->d_ino = sp->d_ino;
        !           475:                                        s = sp->d_name;
        !           476:                                        u = tmp;
        !           477:                                        while (s < sp->d_name + sizeof(sp->d_name) && *s)
        !           478:                                                *u++ = *s++;
        !           479:                                        *u = 0;
        !           480:                                        (void)strcpy(up->d_name, tmp);
        !           481:                                        up->d_reclen = sizeof(struct dirent) - sizeof(up->d_name) + (
        !           482: #if defined(d_fileno) || defined(d_ino)
        !           483:                                                up->d_namlen =
        !           484: #endif
        !           485:                                                u - tmp) + 1;
        !           486:                                        up->d_reclen = round(up->d_reclen, 8);
        !           487:                                        up = (struct dirent*)((char*)up + up->d_reclen);
        !           488:                                }
        !           489:                                sp++;
        !           490:                        }
        !           491:                } while (up == (struct dirent*)buf);
        !           492:                return((char*)up - buf);
        !           493: #else
        !           494:                extern int              read();
        !           495: 
        !           496:                return(read(fd, buf, siz));
        !           497: #endif
        !           498:        }
        !           499: #endif
        !           500: }
        !           501: 
        !           502: #endif
        !           503: 0707070000000000071006440044230044230000010000000441570077400003100000000234comp/killpg.cUgsfGgsf#include "FEATURE/killpg"
        !           504: 
        !           505: #ifdef _lib_killpg
        !           506: 
        !           507: int    _lib_dummy;
        !           508: 
        !           509: #else
        !           510: 
        !           511: extern int     kill();
        !           512: 
        !           513: int
        !           514: killpg(g, s)
        !           515: int    g;
        !           516: int    s;
        !           517: {
        !           518:        return(kill(-g, s));
        !           519: }
        !           520: 
        !           521: #endif
        !           522: 0707070000000000101006440044230044230000010000000472226401000002700000000275comp/link.cUgsfGgsf#include "FEATURE/link"
        !           523: 
        !           524: #ifdef _lib_link
        !           525: 
        !           526: int    _lib_dummy;
        !           527: 
        !           528: #else
        !           529: 
        !           530: #include <errno.h>
        !           531: 
        !           532: extern int     errno;
        !           533: 
        !           534: int
        !           535: link(from, to)
        !           536: char*  from;
        !           537: char*  to;
        !           538: {
        !           539:        errno = EINVAL;
        !           540:        return(-1);
        !           541: }
        !           542: 
        !           543: #endif
        !           544: 0707070000000000111006440044230044230000010000000472226261100003000000000336comp/lstat.cUgsfGgsf#include "FEATURE/lstat"
        !           545: 
        !           546: #ifdef _lib_lstat
        !           547: 
        !           548: int    _lib_dummy;
        !           549: 
        !           550: #else
        !           551: 
        !           552: #include <sys/types.h>
        !           553: #include <sys/stat.h>
        !           554: 
        !           555: extern int     stat();
        !           556: 
        !           557: int
        !           558: lstat(path, st)
        !           559: char*          path;
        !           560: struct stat*   st;
        !           561: {
        !           562:        return(stat(path, st));
        !           563: }
        !           564: 
        !           565: #endif
        !           566: 0707070000000000121006440044230044230000010000000441570100700003100000000450comp/memcmp.cUgsfGgsf#include "FEATURE/memcmp"
        !           567: 
        !           568: #ifdef _lib_memcmp
        !           569: 
        !           570: int    _lib_dummy;
        !           571: 
        !           572: #else
        !           573: 
        !           574: int
        !           575: memcmp(b1, b2, n)
        !           576: register unsigned char*        b1;
        !           577: register unsigned char*        b2;
        !           578: unsigned int           n;
        !           579: {
        !           580:        register unsigned char* e;
        !           581: 
        !           582:        e = b1 + n;
        !           583:        while (b1 < e)
        !           584:                if (*b1++ != *b2++)
        !           585:                        return(*--b1 - *--b2);
        !           586:        return(0);
        !           587: }
        !           588: 
        !           589: #endif
        !           590: 0707070000000000131006440044230044230000010000000455540707300003100000000627comp/memcpy.cUgsfGgsf#include "FEATURE/memcpy"
        !           591: 
        !           592: #ifdef _lib_memcpy
        !           593: 
        !           594: int    _lib_dummy;
        !           595: 
        !           596: #else
        !           597: 
        !           598: #include "FEATURE/bcopy"
        !           599: 
        !           600: #ifdef _lib_bcopy
        !           601: 
        !           602: extern void    bcopy();
        !           603: 
        !           604: char*
        !           605: memcpy(s1, s2, n)
        !           606: char*  s1;
        !           607: char*  s2;
        !           608: int    n;
        !           609: {
        !           610:        bcopy(s2, s1, n);
        !           611:        return(s1);
        !           612: }
        !           613: 
        !           614: #else
        !           615: 
        !           616: char*
        !           617: memcpy(s1, s2, n)
        !           618: register char* s1;
        !           619: register char* s2;
        !           620: register int   n;
        !           621: {
        !           622:        register char*  os1 = s1;
        !           623: 
        !           624:        while (--n >= 0)
        !           625:                *s1++ = *s2++;
        !           626:        return(os1);
        !           627: }
        !           628: 
        !           629: #endif
        !           630: 
        !           631: #endif
        !           632: 0707070000000000141006440044230044230000010000000472226263000003100000000331comp/memset.cUgsfGgsf#include "FEATURE/memset"
        !           633: 
        !           634: #ifdef _lib_memset
        !           635: 
        !           636: int    _lib_dummy;
        !           637: 
        !           638: #else
        !           639: 
        !           640: char*
        !           641: memset(sp, c, n)
        !           642: register char *sp, c;
        !           643: register int n;
        !           644: {
        !           645:        register char *sp0 = sp;
        !           646: 
        !           647:        while (--n >= 0)
        !           648:                *sp++ = c;
        !           649:        return (sp0);
        !           650: }
        !           651: 
        !           652: #endif
        !           653: 0707070000000000151006440044230044230000010000000472226263600003000000001270comp/mkdir.cUgsfGgsf#include "FEATURE/mkdir"
        !           654: 
        !           655: #ifdef _lib_mkdir
        !           656: 
        !           657: int    _lib_dummy;
        !           658: 
        !           659: #else
        !           660: 
        !           661: #include <errno.h>
        !           662: 
        !           663: extern int     errno;
        !           664: 
        !           665: extern int     _exit();
        !           666: extern int     access();
        !           667: extern int     chmod();
        !           668: extern int     execl();
        !           669: extern int     fork();
        !           670: extern int     wait();
        !           671: 
        !           672: int
        !           673: mkdir(path, mode)
        !           674: char*  path;
        !           675: int    mode;
        !           676: {
        !           677:        register int    n;
        !           678:        register int    pid;
        !           679: 
        !           680:        n = errno;
        !           681:        if (!access(path, 0))
        !           682:        {
        !           683:                errno = EEXIST;
        !           684:                return(-1);
        !           685:        }
        !           686:        if (errno != ENOENT) return(-1);
        !           687:        errno = n;
        !           688:        switch (pid = fork())
        !           689:        {
        !           690:        case -1:
        !           691:                return(-1);
        !           692:        case 0:
        !           693:                execl("/bin/mkdir", "mkdir", path, 0);
        !           694:                execl("/usr/5bin/mkdir", "mkdir", path, 0);
        !           695:                _exit(1);
        !           696:        default:
        !           697:                while ((n = wait((int*)0)) >= 0 && n != pid);
        !           698:                break;
        !           699:        }
        !           700:        return(chmod(path, mode));
        !           701: }
        !           702: 
        !           703: #endif
        !           704: 0707070000000000161006440044230044230000010000000441570103400003100000002030comp/mktemp.cUgsfGgsf#include "FEATURE/mktemp"
        !           705: 
        !           706: #ifdef _lib_mktemp
        !           707: 
        !           708: int    _lib_dummy;
        !           709: 
        !           710: #else
        !           711: 
        !           712: /* @(#)mktemp.c        1.2 9/24/85 19:52:37 */
        !           713: /*LINTLIBRARY*/
        !           714: /****************************************************************
        !           715:  *     Routine expects a string of length at least 6, with
        !           716:  *     six trailing 'X's.  These will be overlaid with a
        !           717:  *     letter and the last (5) digigts of the proccess ID.
        !           718:  *     If every letter (a thru z) thus inserted leads to
        !           719:  *     an existing file name, your string is shortened to
        !           720:  *     length zero upon return (first character set to '\0').
        !           721:  ***************************************************************/
        !           722: extern int strlen(), access(), getpid();
        !           723: 
        !           724: char *
        !           725: mktemp(as)
        !           726: char *as;
        !           727: {
        !           728:        register char *s=as;
        !           729:        register unsigned pid;
        !           730: 
        !           731:        pid = getpid();
        !           732:        s += strlen(as);        /* point at the terminal null */
        !           733:        while(*--s == 'X') {
        !           734:                *s = (pid%10) + '0';
        !           735:                pid /= 10;
        !           736:        }
        !           737:        if(*++s) {              /* maybe there were no 'X's */
        !           738:                *s = 'a';
        !           739:                while(access(as, 0) == 0) {
        !           740:                        if(++*s > 'z') {
        !           741:                                *as = '\0';
        !           742:                                break;
        !           743:                        }
        !           744:                }
        !           745:        } else
        !           746:                if(access(as, 0) == 0)
        !           747:                        *as = '\0';
        !           748:        return(as);
        !           749: }
        !           750: 
        !           751: #endif
        !           752: 0707070000000000171006440044230044230000010000000471605023500003000000000317comp/mount.cUgsfGgsf#include "FEATURE/mount"
        !           753: 
        !           754: #ifdef _lib_mount
        !           755: 
        !           756: int    _lib_dummy;
        !           757: 
        !           758: #else
        !           759: 
        !           760: #include <errno.h>
        !           761: 
        !           762: extern int     errno;
        !           763: 
        !           764: /*ARGSUSED*/
        !           765: int
        !           766: mount(a, b, c)
        !           767: char*  a;
        !           768: char*  b;
        !           769: int    c;
        !           770: {
        !           771:        errno = EINVAL;
        !           772:        return(-1);
        !           773: }
        !           774: 
        !           775: #endif
        !           776: 0707070000000000201006440044230044230000010000000475446255100003000000001136comp/popen.cUgsfGgsf/*
        !           777:  * libx popen(3)
        !           778:  */
        !           779: 
        !           780: #include <stdio.h>
        !           781: 
        !           782: #undef popen
        !           783: #undef pclose
        !           784: 
        !           785: extern int     cmdopen();
        !           786: extern int     cmdclose();
        !           787: 
        !           788: #if __STDC__
        !           789: #ifndef fdopen
        !           790: extern FILE*   fdopen(int, char*);
        !           791: #endif
        !           792: #endif
        !           793: 
        !           794: FILE*
        !           795: popen(cmd, mode)
        !           796: char*  cmd;
        !           797: char*  mode;
        !           798: {
        !           799:        int     fd;
        !           800:        FILE*   fp;
        !           801:        char*   sh[4];
        !           802: 
        !           803:        sh[0] = "sh";
        !           804:        sh[1] = "-c";
        !           805:        sh[2] = cmd;
        !           806:        sh[3] = 0;
        !           807:        if ((fd = cmdopen((char*)0, sh, (char**)0, (int**)0, mode)) < 0)
        !           808:                return(0);
        !           809:        if (!(fp = fdopen(fd, mode)))
        !           810:                (void)cmdclose(fd);
        !           811:        return(fp);
        !           812: }
        !           813: 
        !           814: int
        !           815: pclose(fp)
        !           816: FILE*  fp;
        !           817: {
        !           818:        int     fd;
        !           819: 
        !           820:        if (fp)
        !           821:        {
        !           822:                fd = fileno(fp);
        !           823:                fclose(fp);
        !           824:                return(cmdclose(fd));
        !           825:        }
        !           826:        return(-1);
        !           827: }
        !           828: 0707070000000000211006440044230044230000010000000451516406000003300000000346comp/readlink.cUgsfGgsf#include "FEATURE/readlink"
        !           829: 
        !           830: #ifdef _lib_readlink
        !           831: 
        !           832: int    _lib_dummy;
        !           833: 
        !           834: #else
        !           835: 
        !           836: #include <errno.h>
        !           837: 
        !           838: extern int     errno;
        !           839: 
        !           840: /*ARGSUSED*/
        !           841: int
        !           842: readlink(path, buf, siz)
        !           843: char*  path;
        !           844: char*  buf;
        !           845: int    siz;
        !           846: {
        !           847:        errno = EINVAL;
        !           848:        return(-1);
        !           849: }
        !           850: 
        !           851: #endif
        !           852: 0707070000000000221006440044230044230000010000000472227245200003100000000235comp/remove.cUgsfGgsf#include "FEATURE/remove"
        !           853: 
        !           854: #ifdef _lib_remove
        !           855: 
        !           856: int    _lib_dummy;
        !           857: 
        !           858: #else
        !           859: 
        !           860: extern int     unlink();
        !           861: 
        !           862: int
        !           863: remove(path)
        !           864: char*  path;
        !           865: {
        !           866:        return(unlink(path));
        !           867: }
        !           868: 
        !           869: #endif
        !           870: 0707070000000000231006440044230044230000010000000472226252400003100000000354comp/rename.cUgsfGgsf#include "FEATURE/rename"
        !           871: 
        !           872: #ifdef _lib_rename
        !           873: 
        !           874: int    _lib_dummy;
        !           875: 
        !           876: #else
        !           877: 
        !           878: extern int     link();
        !           879: extern int     unlink();
        !           880: 
        !           881: int
        !           882: rename(from, to)
        !           883: char*  from;
        !           884: char*  to;
        !           885: {
        !           886:        int     n;
        !           887: 
        !           888:        if (!(n = link(from, to))) (void)unlink(from);
        !           889:        return(n);
        !           890: }
        !           891: 
        !           892: #endif
        !           893: 0707070000000000241006440044230044230000010000000472226265000003000000001475comp/rmdir.cUgsfGgsf#include "FEATURE/rmdir"
        !           894: 
        !           895: #ifdef _lib_rmdir
        !           896: 
        !           897: int    _lib_dummy;
        !           898: 
        !           899: #else
        !           900: 
        !           901: #include <sys/types.h>
        !           902: #include <sys/stat.h>
        !           903: #include <errno.h>
        !           904: 
        !           905: extern int     errno;
        !           906: 
        !           907: extern int     _exit();
        !           908: extern int     access();
        !           909: extern int     chmod();
        !           910: extern int     execl();
        !           911: extern int     fork();
        !           912: extern int     stat();
        !           913: extern int     wait();
        !           914: 
        !           915: int
        !           916: rmdir(path)
        !           917: char*  path;
        !           918: {
        !           919:        register int    n;
        !           920:        register int    pid;
        !           921:        struct stat     st;
        !           922: 
        !           923:        if (stat(path, &st) < 0) return(-1);
        !           924:        if ((st.st_mode & S_IFMT) != S_IFDIR)
        !           925:        {
        !           926:                errno = ENOTDIR;
        !           927:                return(-1);
        !           928:        }
        !           929:        switch (pid = fork())
        !           930:        {
        !           931:        case -1:
        !           932:                return(-1);
        !           933:        case 0:
        !           934:                execl("/bin/rmdir", "rmdir", path, 0);
        !           935:                execl("/usr/5bin/rmdir", "rmdir", path, 0);
        !           936:                _exit(1);
        !           937:        default:
        !           938:                while ((n = wait((int*)0)) >= 0 && n != pid);
        !           939:                break;
        !           940:        }
        !           941:        n = errno;
        !           942:        if (access(path, 0) < 0)
        !           943:        {
        !           944:                errno = n;
        !           945:                return(0);
        !           946:        }
        !           947:        errno = EPERM;
        !           948:        return(-1);
        !           949: }
        !           950: 
        !           951: #endif
        !           952: 0707070000000000251006440044230044230000010000000441570106000003200000000263comp/setpgid.cUgsfGgsf#include "FEATURE/setpgid"
        !           953: 
        !           954: #ifdef _lib_setpgid
        !           955: 
        !           956: int    _lib_dummy;
        !           957: 
        !           958: #else
        !           959: 
        !           960: extern int     setpgrp();
        !           961: 
        !           962: int
        !           963: setpgid(pid, pgid)
        !           964: int    pid;
        !           965: int    pgid;
        !           966: {
        !           967:        return(setpgrp(pid, pgid));
        !           968: }
        !           969: 
        !           970: #endif
        !           971: 0707070000000000261006440044230044230000010000000441570106600003000000001045comp/sgetl.cUgsfGgsf#include "FEATURE/sgetl"
        !           972: 
        !           973: #ifdef _lib_sgetl
        !           974: 
        !           975: int    _lib_dummy;
        !           976: 
        !           977: #else
        !           978: 
        !           979: /*
        !           980:  * The intent here is to provide a means to make the value of
        !           981:  * bytes in an io-buffer correspond to the value of a long
        !           982:  * in the memory while doing the io a `long' at a time.
        !           983:  * Files written and read in this way are machine-independent.
        !           984:  */
        !           985: 
        !           986: #include <limits.h>
        !           987: 
        !           988: long
        !           989: sgetl(buffer)
        !           990: register char *buffer;
        !           991: {
        !           992:        register long w = 0;
        !           993:        register int i = CHAR_BIT * sizeof(long);
        !           994: 
        !           995:        while ((i -= CHAR_BIT) >= 0)
        !           996:                w |= (long) ((unsigned char) *buffer++) << i;
        !           997:        return (w);
        !           998: }
        !           999: 
        !          1000: #endif
        !          1001: 0707070000000000271006440044230044230000010000000441570107200003500000000206comp/sigsetmask.cUgsfGgsf#include "FEATURE/sigsetmask"
        !          1002: 
        !          1003: #ifdef _lib_sigsetmask
        !          1004: 
        !          1005: int    _lib_dummy;
        !          1006: 
        !          1007: #else
        !          1008: 
        !          1009: int
        !          1010: sigsetmask(mask)
        !          1011: int    mask;
        !          1012: {
        !          1013:        return(0);
        !          1014: }
        !          1015: 
        !          1016: #endif
        !          1017: 0707070000000000301006440044230044230000010000000471770567300003500000000270comp/sigunblock.cUgsfGgsf#include "FEATURE/sigunblock"
        !          1018: 
        !          1019: #ifdef _lib_sigunblock
        !          1020: 
        !          1021: int    _lib_dummy;
        !          1022: 
        !          1023: #else
        !          1024: 
        !          1025: #include <sig.h>
        !          1026: 
        !          1027: int
        !          1028: sigunblock(s)
        !          1029: int    s;
        !          1030: {
        !          1031:        return(sigsetmask(sigsetmask(0) & ~sigmask(s)));
        !          1032: }
        !          1033: 
        !          1034: #endif
        !          1035: 0707070000000000311006440044230044230000010000000441570110500003000000001007comp/sputl.cUgsfGgsf#include "FEATURE/sputl"
        !          1036: 
        !          1037: #ifdef _lib_sputl
        !          1038: 
        !          1039: int    _lib_dummy;
        !          1040: 
        !          1041: #else
        !          1042: 
        !          1043: /*
        !          1044:  * The intent here is to provide a means to make the value of
        !          1045:  * bytes in an io-stream correspond to the value of the long
        !          1046:  * in the memory while doing the io a `long' at a time.
        !          1047:  * Files written and read in this way are machine-independent.
        !          1048:  */
        !          1049: 
        !          1050: #include <limits.h>
        !          1051: 
        !          1052: void
        !          1053: sputl(w, buffer)
        !          1054: register long w;
        !          1055: register char *buffer;
        !          1056: {
        !          1057:        register int i = CHAR_BIT * sizeof(long);
        !          1058: 
        !          1059:        while ((i -= CHAR_BIT) >= 0)
        !          1060:                *buffer++ = (char) (w >> i);
        !          1061: }
        !          1062: 
        !          1063: #endif
        !          1064: 0707070000000000321006440044230044230000010000000472226266100003100000000516comp/strchr.cUgsfGgsf#include "FEATURE/strchr"
        !          1065: 
        !          1066: #ifdef _lib_strchr
        !          1067: 
        !          1068: int    _lib_dummy;
        !          1069: 
        !          1070: #else
        !          1071: 
        !          1072: #include "FEATURE/index"
        !          1073: 
        !          1074: #ifdef _lib_index
        !          1075: 
        !          1076: extern char*   index();
        !          1077: 
        !          1078: char*
        !          1079: strchr(s, c)
        !          1080: char*  s;
        !          1081: int    c;
        !          1082: {
        !          1083:        return(index(s, c));
        !          1084: }
        !          1085: 
        !          1086: #else
        !          1087: 
        !          1088: char*
        !          1089: strchr(s, c)
        !          1090: register char* s;
        !          1091: register int   c;
        !          1092: {
        !          1093:        do if (*s == c) return(s); while(*s++);
        !          1094:        return(0);
        !          1095: }
        !          1096: 
        !          1097: #endif
        !          1098: 
        !          1099: #endif
        !          1100: 0707070000000000331006440044230044230000010000000441570112000003200000000645comp/strpbrk.cUgsfGgsf#include "FEATURE/strpbrk"
        !          1101: 
        !          1102: #ifdef _lib_strpbrk
        !          1103: 
        !          1104: int    _lib_dummy;
        !          1105: 
        !          1106: #else
        !          1107: 
        !          1108: /*
        !          1109:  * Return ptr to first occurance of any character from `brkset'
        !          1110:  * in the character string `string'; 0 if none exists.
        !          1111:  */
        !          1112: 
        !          1113: char*
        !          1114: strpbrk(string, brkset)
        !          1115: register char* string;
        !          1116: register char* brkset;
        !          1117: {
        !          1118:        register char*  p;
        !          1119: 
        !          1120:        do
        !          1121:        {
        !          1122:                for (p = brkset; *p && *p != *string; p++);
        !          1123:                if (*p) return(string);
        !          1124:        } while (*string++);
        !          1125:        return(0);
        !          1126: }
        !          1127: 
        !          1128: #endif
        !          1129: 0707070000000000341006440044230044230000010000000441570112600003200000000556comp/strrchr.cUgsfGgsf#include "FEATURE/strrchr"
        !          1130: 
        !          1131: #ifdef _lib_strrchr
        !          1132: 
        !          1133: int    _lib_dummy;
        !          1134: 
        !          1135: #else
        !          1136: 
        !          1137: #include "FEATURE/rindex"
        !          1138: 
        !          1139: #ifdef _lib_rindex
        !          1140: 
        !          1141: extern char*   rindex();
        !          1142: 
        !          1143: char*
        !          1144: strrchr(s, c)
        !          1145: char*  s;
        !          1146: int    c;
        !          1147: {
        !          1148:        return(rindex(s, c));
        !          1149: }
        !          1150: 
        !          1151: #else
        !          1152: 
        !          1153: char*
        !          1154: strrchr(s, c)
        !          1155: register char* s;
        !          1156: register int   c;
        !          1157: {
        !          1158:        register char*  r;
        !          1159: 
        !          1160:        r = 0;
        !          1161:        do if (*s == c) r = s; while(*s++);
        !          1162:        return(r);
        !          1163: }
        !          1164: 
        !          1165: #endif
        !          1166: 
        !          1167: #endif
        !          1168: 0707070000000000351006440044230044230000010000000441570113300003100000000670comp/strspn.cUgsfGgsf#include "FEATURE/strspn"
        !          1169: 
        !          1170: #ifdef _lib_strspn
        !          1171: 
        !          1172: int    _lib_dummy;
        !          1173: 
        !          1174: #else
        !          1175: 
        !          1176: /*
        !          1177:  * Return the number of characters in the maximum leading segment
        !          1178:  * of string which consists solely of characters from charset.
        !          1179:  */
        !          1180: 
        !          1181: int
        !          1182: strspn(string, charset)
        !          1183: char*          string;
        !          1184: register char* charset;
        !          1185: {
        !          1186:        register char*  p;
        !          1187:        register char*  q;
        !          1188: 
        !          1189:        for (q = string; *q; q++)
        !          1190:        {
        !          1191:                for (p = charset; *p && *p != *q; p++);
        !          1192:                if (!*p) break;
        !          1193:        }
        !          1194:        return(q - string);
        !          1195: }
        !          1196: 
        !          1197: #endif
        !          1198: 0707070000000000361006440044230044230000010000000441570114000003100000000726comp/strtod.cUgsfGgsf#include "FEATURE/strtod"
        !          1199: 
        !          1200: #ifdef _lib_strtod
        !          1201: 
        !          1202: int    _lib_dummy;
        !          1203: 
        !          1204: #else
        !          1205: 
        !          1206: #include <ctype.h>
        !          1207: 
        !          1208: extern double  atof();
        !          1209: 
        !          1210: double
        !          1211: strtod(s, e)
        !          1212: register char* s;
        !          1213: char**         e;
        !          1214: {
        !          1215:        double  n;
        !          1216: 
        !          1217:        n = atof(s);
        !          1218:        if (e)
        !          1219:        {
        !          1220:                while (isspace(*s)) s++;
        !          1221:                if (*s == '-' || *s == '+') s++;
        !          1222:                while (isdigit(*s)) s++;
        !          1223:                if (*s == '.') while (isdigit(*++s));
        !          1224:                if (*s == 'e' || *s == 'E')
        !          1225:                {
        !          1226:                        if (*++s == '-' || *s == '+') s++;
        !          1227:                        while (isdigit(*s)) s++;
        !          1228:                }
        !          1229:                *e = s;
        !          1230:        }
        !          1231:        return(n);
        !          1232: }
        !          1233: 
        !          1234: #endif
        !          1235: 0707070000000000371006440044230044230000010000000472226272700003100000001520comp/strtok.cUgsfGgsf#include "FEATURE/strtok"
        !          1236: 
        !          1237: #ifdef _lib_strtok
        !          1238: 
        !          1239: int    _lib_dummy;
        !          1240: 
        !          1241: #else
        !          1242: 
        !          1243: /*
        !          1244:  * uses strpbrk and strspn to break string into tokens on
        !          1245:  * sequentially subsequent calls.  returns 0 when no
        !          1246:  * non-separator characters remain.
        !          1247:  * `subsequent' calls are calls with first argument 0.
        !          1248:  */
        !          1249: 
        !          1250: extern int     strspn();
        !          1251: extern char*   strpbrk();
        !          1252: 
        !          1253: char*
        !          1254: strtok(string, sepset)
        !          1255: char*  string
        !          1256: char*  sepset;
        !          1257: {
        !          1258:        register char*  p;
        !          1259:        register char*  q;
        !          1260:        register char*  r;
        !          1261:        static char*    savept;
        !          1262: 
        !          1263:        /*first or subsequent call*/
        !          1264:        /* return if no tokens remaining */
        !          1265:        if (!(p = string ? string : savept)) return(0);
        !          1266:        /* skip leading separators */
        !          1267:        /* return if no tokens remaining */
        !          1268:        if (!*(q = p + strspn(p, sepset))) return(0);
        !          1269:        /* move past token */
        !          1270:        if (!(r = strpbrk(q, sepset))) savept = 0;      /* this is last token */
        !          1271:        else
        !          1272:        {
        !          1273:                *r = 0;
        !          1274:                savept = ++r;
        !          1275:        }
        !          1276:        return(q);
        !          1277: }
        !          1278: 
        !          1279: #endif
        !          1280: 0707070000000000401006440044230044230000010000000472226275000003100000002577comp/strtol.cUgsfGgsf#include "FEATURE/strtol"
        !          1281: 
        !          1282: #ifdef _lib_strtol
        !          1283: 
        !          1284: int    _lib_dummy;
        !          1285: 
        !          1286: #else
        !          1287: 
        !          1288: /*     @(#)strtol.c    2.1     */
        !          1289: /*LINTLIBRARY*/
        !          1290: #include <ctype.h>
        !          1291: #define DIGIT(x)       (isdigit(x) ? (x) - '0' : \
        !          1292:                        islower(x) ? (x) + 10 - 'a' : (x) + 10 - 'A')
        !          1293: #define MBASE  ('z' - 'a' + 1 + 10)
        !          1294: 
        !          1295: long
        !          1296: strtol(str, ptr, base)
        !          1297: register char* str;
        !          1298: char**         ptr;
        !          1299: register int   base;
        !          1300: {
        !          1301:        register long val;
        !          1302:        register int c;
        !          1303:        int xx, neg = 0;
        !          1304: 
        !          1305:        if (ptr != (char **)0)
        !          1306:                *ptr = str; /* in case no number is formed */
        !          1307:        if (base < 0 || base > MBASE)
        !          1308:                return (0); /* base is invalid -- should be a fatal error */
        !          1309:        if (!isalnum(c = *str)) {
        !          1310:                while (isspace(c))
        !          1311:                        c = *++str;
        !          1312:                switch (c) {
        !          1313:                case '-':
        !          1314:                        neg++;
        !          1315:                case '+': /* fall-through */
        !          1316:                        c = *++str;
        !          1317:                }
        !          1318:        }
        !          1319:        if (base == 0)
        !          1320:                if (c != '0')
        !          1321:                        base = 10;
        !          1322:                else if (str[1] == 'x' || str[1] == 'X')
        !          1323:                        base = 16;
        !          1324:                else
        !          1325:                        base = 8;
        !          1326:        /*
        !          1327:         * for any base > 10, the digits incrementally following
        !          1328:         *      9 are assumed to be "abc...z" or "ABC...Z"
        !          1329:         */
        !          1330:        if (!isalnum(c) || (xx = DIGIT(c)) >= base)
        !          1331:                return (0); /* no number formed */
        !          1332:        if (base == 16 && c == '0' && isxdigit(str[2]) &&
        !          1333:            (str[1] == 'x' || str[1] == 'X'))
        !          1334:                c = *(str += 2); /* skip over leading "0x" or "0X" */
        !          1335:        for (val = -DIGIT(c); isalnum(c = *++str) && (xx = DIGIT(c)) < base; )
        !          1336:                /* accumulate neg avoids surprises near MAXLONG */
        !          1337:                val = base * val - xx;
        !          1338:        if (ptr != (char **)0)
        !          1339:                *ptr = str;
        !          1340:        return (neg ? val : -val);
        !          1341: }
        !          1342: 
        !          1343: #endif
        !          1344: 0707070000000000411006440044230044230000010000000451516404100003200000000313comp/symlink.cUgsfGgsf#include "FEATURE/symlink"
        !          1345: 
        !          1346: #ifdef _lib_symlink
        !          1347: 
        !          1348: int    _lib_dummy;
        !          1349: 
        !          1350: #else
        !          1351: 
        !          1352: #include <errno.h>
        !          1353: 
        !          1354: extern int     errno;
        !          1355: 
        !          1356: /*ARGSUSED*/
        !          1357: int
        !          1358: symlink(a, b)
        !          1359: char*  a;
        !          1360: char*  b;
        !          1361: {
        !          1362:        errno = EINVAL;
        !          1363:        return(-1);
        !          1364: }
        !          1365: 
        !          1366: #endif
        !          1367: 0707070000000000421006440044230044230000010000000447445616000003100000000265comp/system.cUgsfGgsf/*
        !          1368:  * libx system(3)
        !          1369:  */
        !          1370: 
        !          1371: extern int     cmdrun();
        !          1372: 
        !          1373: int
        !          1374: system(cmd)
        !          1375: char*  cmd;
        !          1376: {
        !          1377:        char*   sh[4];
        !          1378: 
        !          1379:        sh[0] = "sh";
        !          1380:        sh[1] = "-c";
        !          1381:        sh[2] = cmd;
        !          1382:        sh[3] = 0;
        !          1383:        return(cmdrun((char*)0, sh));
        !          1384: }
        !          1385: 0707070000000000431006440044230044230000010000000441570116500003100000001051comp/tmpnam.cUgsfGgsf#include "FEATURE/tmpnam"
        !          1386: 
        !          1387: #ifdef _lib_tmpnam
        !          1388: 
        !          1389: int    _lib_dummy;
        !          1390: 
        !          1391: #else
        !          1392: 
        !          1393: #include <stdio.h>
        !          1394: 
        !          1395: #ifndef P_tmpdir
        !          1396: #define P_tmpdir       "/usr/tmp/"
        !          1397: #endif
        !          1398: 
        !          1399: #ifndef L_tmpnam
        !          1400: #define L_tmpnam       (sizeof(P_tmpdir)+10)
        !          1401: #endif
        !          1402: 
        !          1403: static char    buf[L_tmpnam];
        !          1404: static char    seed[] = { 'a', 'a', 'a', 0 };
        !          1405: 
        !          1406: extern char*   mktemp();
        !          1407: extern char*   strcopy();
        !          1408: 
        !          1409: 
        !          1410: char*
        !          1411: tmpnam(p)
        !          1412: register char* p;
        !          1413: {
        !          1414:        register char*  q;
        !          1415: 
        !          1416:        if (!p) p = buf;
        !          1417:        (void)strcopy(strcopy(strcopy(p, P_tmpdir), seed), "XXXXXX");
        !          1418:        q = seed;
        !          1419:        while (*q == 'z') *q++ = 'a';
        !          1420:        if (*q) ++*q;
        !          1421:        return(mktemp(p));
        !          1422: }
        !          1423: 
        !          1424: #endif
        !          1425: 0707070000000000441006440044230044230000010000000472226407000003100000000235comp/unlink.cUgsfGgsf#include "FEATURE/unlink"
        !          1426: 
        !          1427: #ifdef _lib_unlink
        !          1428: 
        !          1429: int    _lib_dummy;
        !          1430: 
        !          1431: #else
        !          1432: 
        !          1433: extern int     remove();
        !          1434: 
        !          1435: int
        !          1436: unlink(path)
        !          1437: char*  path;
        !          1438: {
        !          1439:        retrun(remove(path));
        !          1440: }
        !          1441: 
        !          1442: #endif
        !          1443: 0707070000000000451006440044230044230000010000000441570117100003000000000202comp/vfork.cUgsfGgsf#include "FEATURE/vfork"
        !          1444: 
        !          1445: #ifdef _lib_vfork
        !          1446: 
        !          1447: int    _lib_dummy;
        !          1448: 
        !          1449: #else
        !          1450: 
        !          1451: extern int     fork();
        !          1452: 
        !          1453: int
        !          1454: vfork()
        !          1455: {
        !          1456:        return(fork());
        !          1457: }
        !          1458: 
        !          1459: #endif
        !          1460: 0707070000000000461006440044230044230000010000000475152536600003000000003136dir/dirlib.hUgsfGgsf/*
        !          1461:  * AT&T Bell Laboratories
        !          1462:  *
        !          1463:  * directory stream access library private definitions
        !          1464:  * handles 3d and preroot file systems
        !          1465:  */
        !          1466: 
        !          1467: #include <preroot.h>
        !          1468: 
        !          1469: #undef DIR
        !          1470: #define DIR            _SYS_DIR_
        !          1471: 
        !          1472: #undef opendir
        !          1473: #define opendir                _SYS_opendir
        !          1474: 
        !          1475: #undef readdir
        !          1476: #define readdir                _SYS_readdir
        !          1477: 
        !          1478: #undef rewinddir
        !          1479: #define rewinddir      _SYS_rewinddir
        !          1480: 
        !          1481: #undef seekdir
        !          1482: #define seekdir                _SYS_seekdir
        !          1483: 
        !          1484: #undef telldir
        !          1485: #define telldir                _SYS_telldir
        !          1486: 
        !          1487: #undef closedir
        !          1488: #define closedir       _SYS_closedir
        !          1489: 
        !          1490: #define _dir_local     1
        !          1491: 
        !          1492: #include <lclparam.h>
        !          1493: #include <fsinfo.h>
        !          1494: #include <dirent.h>
        !          1495: #include <limits.h>
        !          1496: #include <hash.h>
        !          1497: 
        !          1498: #undef DIR
        !          1499: 
        !          1500: typedef struct
        !          1501: {
        !          1502:        int             dd_fd;          /* file descriptor              */
        !          1503:        int             dd_loc;         /* offset in block              */
        !          1504:        int             dd_size;        /* valid data in block          */
        !          1505:        char*           dd_buf;         /* directory block              */
        !          1506: 
        !          1507:        /* the rest are for 3d and preroot fs */
        !          1508: 
        !          1509:        unsigned char   covered[sizeof(int)*CHAR_BIT];
        !          1510:                                        /* covered directory fds        */
        !          1511:        ino_t           opaque;         /* opaque inode number          */
        !          1512:        HASHTABLE*      overlay;        /* directory overlay hash       */
        !          1513:        short           numfd;          /* number of covered fds        */
        !          1514:        short           nxtfd;          /* next covered fd index        */
        !          1515:        short           fs3d;           /* 3d in effect                 */
        !          1516: } DIR;                                 /* directory stream descriptor  */
        !          1517: 
        !          1518: #undef         opendir
        !          1519: extern DIR*    opendir();
        !          1520: 
        !          1521: #undef         readdir
        !          1522: extern struct dirent*  readdir();
        !          1523: 
        !          1524: #undef rewinddir
        !          1525: extern void    rewinddir();
        !          1526: 
        !          1527: #undef seekdir
        !          1528: extern void    seekdir();
        !          1529: 
        !          1530: #undef telldir
        !          1531: extern long    telldir();
        !          1532: 
        !          1533: #undef         closedir
        !          1534: extern void    closedir();
        !          1535: 
        !          1536: #ifndef        DIRBLKSIZ
        !          1537: #ifdef DIRBLK
        !          1538: #define DIRBLKSIZ      DIRBLK
        !          1539: #else
        !          1540: #ifdef DIRBUF
        !          1541: #define DIRBLKSIZ      DIRBUF
        !          1542: #else
        !          1543: #ifdef DEV_BSIZE
        !          1544: #define DIRBLKSIZ      DEV_BSIZE
        !          1545: #else
        !          1546: #define DIRBLKSIZ      4096
        !          1547: #endif
        !          1548: #endif
        !          1549: #endif
        !          1550: #endif
        !          1551: 0707070000000000471006440044230044230000010000000475137311700003100000004774dir/opendir.cUgsfGgsf/*
        !          1552:  * opendir, closedir
        !          1553:  *
        !          1554:  * open|close directory stream
        !          1555:  *
        !          1556:  * POSIX compatible directory stream access routines:
        !          1557:  *
        !          1558:  *     #include <sys/types.h>
        !          1559:  *     #include <dirent.h>
        !          1560:  *
        !          1561:  * NOTE: readdir() returns a pointer to struct dirent
        !          1562:  */
        !          1563: 
        !          1564: #include "dirlib.h"
        !          1565: 
        !          1566: #include <errno.h>
        !          1567: 
        !          1568: #if !lint
        !          1569: static char    id[] = "\n@(#)directory (AT&T Bell Laboratories) 04/01/90\0\n";
        !          1570: #endif
        !          1571: 
        !          1572: static DIR*    freedirp;               /* always keep one dirp */
        !          1573: 
        !          1574: extern int     errno;
        !          1575: 
        !          1576: extern char*   malloc();
        !          1577: extern char*   strcopy();
        !          1578: extern void    free();
        !          1579: extern int     open();
        !          1580: extern int     close();
        !          1581: extern int     fclex();
        !          1582: extern int     fstat();
        !          1583: 
        !          1584: DIR*
        !          1585: opendir(path)
        !          1586: register char* path;
        !          1587: {
        !          1588:        register DIR*   dirp = 0;
        !          1589:        register int    fd;
        !          1590:        dev_t           dev;
        !          1591:        ino_t           ino;
        !          1592:        struct stat     st;
        !          1593: 
        !          1594:        if ((fd = open(path, 0)) < 0) return(0);
        !          1595:        if (fstat(fd, &st) < 0 ||
        !          1596:           (st.st_mode & S_IFMT) != S_IFDIR && (errno = ENOTDIR) ||
        !          1597:           fclex(fd, 1) ||
        !          1598:           !(dirp = freedirp ? freedirp : (DIR*)malloc(sizeof(DIR) + DIRBLKSIZ)))
        !          1599:        {
        !          1600:                (void)close(fd);
        !          1601:                if (dirp)
        !          1602:                {
        !          1603:                        if (!freedirp) freedirp = dirp;
        !          1604:                        else free((char*)dirp);
        !          1605:                }
        !          1606:                return(0);
        !          1607:        }
        !          1608:        freedirp = 0;
        !          1609:        dirp->dd_fd = fd;
        !          1610:        dirp->dd_loc = dirp->dd_size = 0;       /* refill needed */
        !          1611:        dirp->dd_buf = (char*)dirp + sizeof(DIR);
        !          1612: 
        !          1613:        /*
        !          1614:         * handle 3d and preroot fs
        !          1615:         */
        !          1616: 
        !          1617:        dirp->numfd = dirp->nxtfd = 0;
        !          1618:        if (dirp->fs3d = fs3d(2))
        !          1619:        {
        !          1620:                char    buf[PATH_MAX];
        !          1621: 
        !          1622:                dirp->opaque = 0;
        !          1623:                path = strcopy(buf, path);
        !          1624:                while (dirp->numfd < sizeof(dirp->covered) / sizeof(dirp->covered[0]))
        !          1625:                {
        !          1626:                        path = strcopy(path, "/...");
        !          1627:                        if ((fd = open(buf, 0)) < 0) break;
        !          1628: 
        !          1629:                        /*
        !          1630:                         * check for non-dirs or dirs covered by virtual dir
        !          1631:                         */
        !          1632: 
        !          1633:                        dev = st.st_dev;
        !          1634:                        ino = st.st_ino;
        !          1635:                        if (fstat(fd, &st) || ino == st.st_ino && dev == st.st_dev) (void)close(fd);
        !          1636:                        else if ((st.st_mode & S_IFMT) != S_IFDIR)
        !          1637:                        {
        !          1638:                                (void)close(fd);
        !          1639:                                break;
        !          1640:                        }
        !          1641:                        else
        !          1642:                        {
        !          1643:                                fclex(fd, 1);
        !          1644:                                dirp->covered[dirp->numfd++] = fd;
        !          1645:                        }
        !          1646:                }
        !          1647:        }
        !          1648: #if defined(FS_PREROOT)
        !          1649:        else if ((fd = realopen(path, 0, 0)) >= 0)
        !          1650:        {
        !          1651:                dev = st.st_dev;
        !          1652:                ino = st.st_ino;
        !          1653:                if (fstat(fd, &st) || ino == st.st_ino && dev == st.st_dev || (st.st_mode & S_IFMT) != S_IFDIR) (void)close(fd);
        !          1654:                else
        !          1655:                {
        !          1656:                        fclex(fd, 1);
        !          1657:                        dirp->covered[dirp->numfd++] = fd;
        !          1658:                }
        !          1659:        }
        !          1660: #endif
        !          1661:        dirp->overlay = dirp->numfd ? hashalloc((HASHTABLE*)0, HASH_set, HASH_ALLOCATE, 0) : 0;
        !          1662:        return(dirp);
        !          1663: }
        !          1664: 
        !          1665: void
        !          1666: closedir(dirp)
        !          1667: register DIR*  dirp;
        !          1668: {
        !          1669:        if (dirp)
        !          1670:        {
        !          1671:                (void)close(dirp->dd_fd);
        !          1672:                while (dirp->nxtfd < dirp->numfd) (void)close(dirp->covered[dirp->nxtfd++]);
        !          1673:                if (dirp->overlay) hashfree(dirp->overlay);
        !          1674:                if (!freedirp) freedirp = dirp;
        !          1675:                else free((char*)dirp);
        !          1676:        }
        !          1677: }
        !          1678: 0707070000000000501006440044230044230000010000000471771071500003100000002357dir/readdir.cUgsfGgsf/*
        !          1679:  * readdir
        !          1680:  *
        !          1681:  * read from directory stream
        !          1682:  *
        !          1683:  * NOTE: directory entries must fit within DIRBLKSIZ boundaries
        !          1684:  */
        !          1685: 
        !          1686: #include "dirlib.h"
        !          1687: 
        !          1688: struct dirent*
        !          1689: readdir(dirp)
        !          1690: register DIR*  dirp;
        !          1691: {
        !          1692:        register struct dirent* dp;
        !          1693: 
        !          1694:        for (;;)
        !          1695:        {
        !          1696:                if (dirp->dd_loc >= dirp->dd_size)
        !          1697:                {
        !          1698:                        if (dirp->dd_size < 0) return(0);
        !          1699:                        dirp->dd_loc = 0;
        !          1700:                        if ((dirp->dd_size = getdents(dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ)) <= 0)
        !          1701:                        {
        !          1702:                        uncover:
        !          1703:                                if (dirp->nxtfd < dirp->numfd)
        !          1704:                                {
        !          1705:                                        (void)close(dirp->dd_fd);
        !          1706:                                        dirp->dd_fd = dirp->covered[dirp->nxtfd++];
        !          1707:                                        dirp->dd_loc = 0;
        !          1708:                                        dirp->opaque = 0;
        !          1709:                                        continue;
        !          1710:                                }
        !          1711:                                return(0);
        !          1712:                        }
        !          1713:                }
        !          1714:                dp = (struct dirent*)&dirp->dd_buf[dirp->dd_loc];
        !          1715:                if (dp->d_reclen <= 0) goto uncover;
        !          1716:                dirp->dd_loc += dp->d_reclen;
        !          1717:                if (dp->d_ino)
        !          1718:                {
        !          1719:                        if (dirp->fs3d)
        !          1720:                        {
        !          1721:                                register char*  s = dp->d_name;
        !          1722: 
        !          1723:                                /*
        !          1724:                                 * skip opaque and hidden entries
        !          1725:                                 */
        !          1726: 
        !          1727:                                if (*s++ == '.' && *s++ == '.' && *s++ == '.')
        !          1728:                                {
        !          1729:                                        if (!*s) dirp->opaque = dp->d_ino;
        !          1730:                                        continue;
        !          1731:                                }
        !          1732:                        }
        !          1733:                        if (dirp->overlay)
        !          1734:                        {
        !          1735:                                if (hashget(dirp->overlay, dp->d_name)) continue;
        !          1736:                                if (dirp->nxtfd < dirp->numfd) hashput(dirp->overlay, 0, (char*)1);
        !          1737:                        }
        !          1738:                        if (dp->d_ino == dirp->opaque) continue;
        !          1739:                        return(dp);
        !          1740:                }
        !          1741:        }
        !          1742:        /*NOTREACHED*/
        !          1743: }
        !          1744: 0707070000000000511006440044230044230000010000000445642251000003300000000277dir/rewinddir.cUgsfGgsf/*
        !          1745:  * rewinddir
        !          1746:  *
        !          1747:  * rewind directory stream
        !          1748:  * provided for POSIX compatibility
        !          1749:  */
        !          1750: 
        !          1751: #include "dirlib.h"
        !          1752: 
        !          1753: #undef rewinddir
        !          1754: 
        !          1755: void
        !          1756: rewinddir(dirp)
        !          1757: register DIR   *dirp;
        !          1758: {
        !          1759:        seekdir(dirp, 0L);
        !          1760: }
        !          1761: 0707070000000000521006440044230044230000010000000440504372400003100000001005dir/seekdir.cUgsfGgsf/*
        !          1762:  * seekdir
        !          1763:  *
        !          1764:  * seek on directory stream
        !          1765:  */
        !          1766: 
        !          1767: #include "dirlib.h"
        !          1768: 
        !          1769: extern long    lseek();
        !          1770: 
        !          1771: void
        !          1772: seekdir(dirp, loc)
        !          1773: register DIR   *dirp;
        !          1774: long           loc;
        !          1775: {
        !          1776:        long    base;           /* file location of block */
        !          1777:        long    offset;         /* offset within block */
        !          1778: 
        !          1779:        if (telldir(dirp) != loc)
        !          1780:        {
        !          1781:                offset = loc % DIRBLKSIZ;
        !          1782:                base = loc - offset;
        !          1783:                (void)lseek(dirp->dd_fd, base, 0);
        !          1784:                dirp->dd_loc = dirp->dd_size = 0;
        !          1785: 
        !          1786:                /*
        !          1787:                 * skip some entries
        !          1788:                 */
        !          1789: 
        !          1790:                while (dirp->dd_loc < offset)
        !          1791:                        if (!readdir(dirp))
        !          1792:                                break;  /* "can't happen" */
        !          1793:        }
        !          1794: }
        !          1795: 0707070000000000531006440044230044230000010000000440504373000003100000000334dir/telldir.cUgsfGgsf/*
        !          1796:  * telldir
        !          1797:  *
        !          1798:  * get offset of directory stream pointer
        !          1799:  */
        !          1800: 
        !          1801: #include "dirlib.h"
        !          1802: 
        !          1803: extern long    lseek();
        !          1804: 
        !          1805: long
        !          1806: telldir(dirp)
        !          1807: DIR    *dirp;
        !          1808: {
        !          1809:        return(lseek(dirp->dd_fd, 0L, 1) - (long)dirp->dd_size + (long)dirp->dd_loc);
        !          1810: }
        !          1811: 0707070000000000541006440044230044230000010000000472006660200003400000005102hash/hashalloc.cUgsfGgsf/*
        !          1812:  * G. S. Fowler
        !          1813:  * AT&T Bell Laboratories
        !          1814:  *
        !          1815:  * hash table library
        !          1816:  */
        !          1817: 
        !          1818: #if !lint
        !          1819: static char    id[] = "\n@(#)hash (AT&T Bell Laboratories) 11/11/90\0\n";
        !          1820: #endif
        !          1821: 
        !          1822: #include "hashlib.h"
        !          1823: 
        !          1824: #if !__STDC__
        !          1825: 
        !          1826: #include <varargs.h>
        !          1827: 
        !          1828: #endif
        !          1829: 
        !          1830: struct hashinfo        _hash_info_;
        !          1831: 
        !          1832: /*
        !          1833:  * create a new hash table
        !          1834:  */
        !          1835: 
        !          1836: #if __STDC__
        !          1837: 
        !          1838: HASHTABLE*
        !          1839: hashalloc(HASHTABLE* ref, ...)
        !          1840: 
        !          1841: #else
        !          1842: 
        !          1843: HASHTABLE*
        !          1844: hashalloc(va_alist)
        !          1845: va_dcl
        !          1846: 
        !          1847: #endif
        !          1848: 
        !          1849: {
        !          1850:        va_list                 ap;
        !          1851: #if !__STDC__
        !          1852:        register HASHTABLE*     ref;
        !          1853: #endif
        !          1854: 
        !          1855: #if __STDC__
        !          1856:        va_start(ap, ref);
        !          1857: #else
        !          1858:        va_start(ap);
        !          1859:        ref = va_arg(ap, HASHTABLE*);
        !          1860: #endif
        !          1861:        ref = hashvalloc(ref, ap);
        !          1862:        va_end(ap);
        !          1863:        return(ref);
        !          1864: }
        !          1865: 
        !          1866: /*
        !          1867:  * varargs interface to hashalloc()
        !          1868:  */
        !          1869: 
        !          1870: HASHTABLE*
        !          1871: hashvalloc(ref, ap)
        !          1872: register HASHTABLE*    ref;
        !          1873: va_list                        ap;
        !          1874: {
        !          1875:        register HASHTABLE*     tab;
        !          1876:        int                     internal;
        !          1877: 
        !          1878:        if (!(tab = (HASHTABLE*)calloc(1, sizeof(HASHTABLE)))) goto bad;
        !          1879:        if (ref)
        !          1880:        {
        !          1881:                tab->flags = ref->flags & ~HASH_RESET;
        !          1882:                tab->root = ref->root;
        !          1883:                internal = HASH_INTERNAL;
        !          1884:        }
        !          1885:        else
        !          1886:        {
        !          1887:                if (!(tab->root = (HASHROOT*)calloc(1, sizeof(HASHROOT)))) goto bad;
        !          1888:                tab->root->meanchain = HASHMEANCHAIN;
        !          1889:                internal = 0;
        !          1890:        }
        !          1891:        tab->size = HASHMINSIZE;
        !          1892:        for (;;) switch (va_arg(ap, int)) 
        !          1893:        {
        !          1894:        case HASH_alloc:
        !          1895:                if (ref) goto bad;
        !          1896:                tab->root->alloc = va_arg(ap, HASHPTR);
        !          1897:                break;
        !          1898:        case HASH_clear:
        !          1899:                tab->flags &= ~(va_arg(ap, int) & ~internal);
        !          1900:                break;
        !          1901:        case HASH_compare:
        !          1902:                if (ref) goto bad;
        !          1903:                tab->root->compare = va_arg(ap, HASHINT);
        !          1904:                break;
        !          1905:        case HASH_free:
        !          1906:                if (ref) goto bad;
        !          1907:                tab->root->free = va_arg(ap, HASHINT);
        !          1908:                break;
        !          1909:        case HASH_hash:
        !          1910:                if (ref) goto bad;
        !          1911:                tab->root->hash = va_arg(ap, HASHFUN);
        !          1912:                break;
        !          1913:        case HASH_meanchain:
        !          1914:                if (ref) goto bad;
        !          1915:                tab->root->meanchain = va_arg(ap, int);
        !          1916:                break;
        !          1917:        case HASH_name:
        !          1918:                tab->name = va_arg(ap, char*);
        !          1919:                break;
        !          1920:        case HASH_namesize:
        !          1921:                if (ref) goto bad;
        !          1922:                tab->root->namesize = va_arg(ap, int);
        !          1923:                break;
        !          1924:        case HASH_set:
        !          1925:                tab->flags |= (va_arg(ap, int) & ~internal);
        !          1926:                break;
        !          1927:        case HASH_size:
        !          1928:                tab->size = va_arg(ap, int);
        !          1929:                if (tab->size & (tab->size - 1)) tab->flags |= HASH_FIXED;
        !          1930:                break;
        !          1931:        case HASH_table:
        !          1932:                tab->table = va_arg(ap, HASHBUCKET**);
        !          1933:                tab->flags |= HASH_STATIC;
        !          1934:                break;
        !          1935:        case 0:
        !          1936:                if (tab->flags & HASH_SCOPE)
        !          1937:                {
        !          1938:                        if (!(tab->scope = ref)) goto bad;
        !          1939:                        ref->frozen++;
        !          1940:                }
        !          1941:                if (!tab->table && !(tab->table = (HASHBUCKET**)calloc(1, sizeof(HASHBUCKET*) * tab->size))) goto bad;
        !          1942:                if (!ref)
        !          1943:                {
        !          1944:                        tab->root->flags = tab->flags & HASH_INTERNAL;
        !          1945:                        tab->root->next = hash_info.list;
        !          1946:                        hash_info.list = tab->root;
        !          1947:                }
        !          1948:                tab->next = tab->root->references;
        !          1949:                tab->root->references = tab;
        !          1950:                return(tab);
        !          1951:        default:
        !          1952:                goto bad;
        !          1953:        }
        !          1954:  bad:
        !          1955:        (void)hashfree(tab);
        !          1956:        return(0);
        !          1957: }
        !          1958: 0707070000000000551006440044230044230000010000000467350644100003300000010352hash/hashdump.cUgsfGgsf/*
        !          1959:  * G. S. Fowler
        !          1960:  * AT&T Bell Laboratories
        !          1961:  *
        !          1962:  * hash table library
        !          1963:  */
        !          1964: 
        !          1965: #include <stdio.h>
        !          1966: 
        !          1967: #include "hashlib.h"
        !          1968: 
        !          1969: static void    dumproot();
        !          1970: static void    dumptable();
        !          1971: static void    dumpflags();
        !          1972: static void    dumpbucket();
        !          1973: 
        !          1974: /*
        !          1975:  * dump hash table accounting info
        !          1976:  * if tab is 0 then dump all tables in hash_info.list
        !          1977:  * flags are HASH_* flags that specifiy optional dump info
        !          1978:  */
        !          1979: 
        !          1980: void
        !          1981: hashdump(fp, tab, flags)
        !          1982: register FILE*         fp;
        !          1983: register HASHTABLE*    tab;
        !          1984: int                    flags;
        !          1985: {
        !          1986:        register HASHROOT*      root;
        !          1987: 
        !          1988:        fprintf(fp, "\nhash table information:\n\n");
        !          1989:        if (tab) dumproot(fp, tab->root, flags);
        !          1990:        else for (root = hash_info.list; root; root = root->next)
        !          1991:                dumproot(fp, root, flags);
        !          1992:        fflush(fp);
        !          1993: }
        !          1994: 
        !          1995: /*
        !          1996:  * dump hash table root info
        !          1997:  */
        !          1998: 
        !          1999: static void
        !          2000: dumproot(fp, root, flags)
        !          2001: register FILE*         fp;
        !          2002: register HASHROOT*     root;
        !          2003: register int           flags;
        !          2004: {
        !          2005:        register HASHTABLE*     tab;
        !          2006: 
        !          2007:        fprintf(fp, "    root\n");
        !          2008:        fprintf(fp, "        address:     0x%08lx\n", (unsigned long)root);
        !          2009:        fprintf(fp, "        flags:       ");
        !          2010:        dumpflags(fp, root->flags);
        !          2011:        if (root->namesize) fprintf(fp, "namesize=%d ", root->namesize);
        !          2012:        if (root->alloc) fprintf(fp, "alloc=0x%08lx ", (unsigned long)root->alloc);
        !          2013:        if (root->compare) fprintf(fp, "compare=0x%08lx ", (unsigned long)root->compare);
        !          2014:        if (root->free) fprintf(fp, "free=0x%08lx ", (unsigned long)root->free);
        !          2015:        if (root->hash) fprintf(fp, "hash=0x%08lx ", (unsigned long)root->hash);
        !          2016:        fprintf(fp, "\n");
        !          2017:        fprintf(fp, "        meanchain:   %d\n", root->meanchain);
        !          2018:        fprintf(fp, "        accesses:    %d\n", root->accesses);
        !          2019:        fprintf(fp, "        collisions:  %d\n", root->collisions);
        !          2020:        fprintf(fp, "\n");
        !          2021:        for (tab = root->references; tab; tab = tab->next)
        !          2022:                dumptable(fp, tab, flags);
        !          2023: }
        !          2024: 
        !          2025: /*
        !          2026:  * dump info on a single table
        !          2027:  */
        !          2028: 
        !          2029: static void
        !          2030: dumptable(fp, tab, flags)
        !          2031: register FILE*         fp;
        !          2032: register HASHTABLE*    tab;
        !          2033: register int           flags;
        !          2034: {
        !          2035:        HASHTABLE*      scope;
        !          2036:        int             level;
        !          2037: 
        !          2038:        fprintf(fp, "        name:        %s", tab->name ? tab->name : "*no name*");
        !          2039:        if (scope = tab->scope)
        !          2040:        {
        !          2041:                level = 1;
        !          2042:                while (scope = scope->scope) level++;
        !          2043:                fprintf(fp, " level %d scope on 0x%08lx", level, (unsigned long)tab->scope);
        !          2044:        }
        !          2045:        fprintf(fp, "\n");
        !          2046:        fprintf(fp, "        address:     0x%08lx\n", (unsigned long)tab);
        !          2047:        fprintf(fp, "        flags:       ");
        !          2048:        if (tab->frozen) fprintf(fp, "frozen=%d ", tab->frozen);
        !          2049:        dumpflags(fp, tab->flags);
        !          2050:        fprintf(fp, "\n");
        !          2051:        fprintf(fp, "        size:        %d\n", tab->size);
        !          2052:        fprintf(fp, "        buckets:     %d\n", tab->buckets);
        !          2053:        fprintf(fp, "\n");
        !          2054:        if ((flags | tab->flags) & HASH_BUCKET) dumpbucket(fp, tab, flags);
        !          2055: }
        !          2056: 
        !          2057: /*
        !          2058:  * dump HASH_* flags
        !          2059:  */
        !          2060: 
        !          2061: static void
        !          2062: dumpflags(fp, flags)
        !          2063: register FILE* fp;
        !          2064: register int   flags;
        !          2065: {
        !          2066:        if (flags & HASH_ALLOCATE) fprintf(fp, "allocate ");
        !          2067:        if (flags & HASH_BUCKET) fprintf(fp, "bucket ");
        !          2068:        if (flags & HASH_FIXED) fprintf(fp, "fixed ");
        !          2069:        if (flags & HASH_HASHED) fprintf(fp, "hashed ");
        !          2070:        if (flags & HASH_RESIZE) fprintf(fp, "resize ");
        !          2071:        if (flags & HASH_SCANNING) fprintf(fp, "scanning ");
        !          2072:        if (flags & HASH_STATIC) fprintf(fp, "static ");
        !          2073:        if (flags & HASH_VALUE) fprintf(fp, "value ");
        !          2074: }
        !          2075: 
        !          2076: /*
        !          2077:  * dump hash table bucket info
        !          2078:  */
        !          2079: 
        !          2080: /*ARGSUSED*/
        !          2081: static void
        !          2082: dumpbucket(fp, tab, flags)
        !          2083: register FILE*         fp;
        !          2084: register HASHTABLE*    tab;
        !          2085: int                    flags;
        !          2086: {
        !          2087:        register HASHBUCKET**   sp;
        !          2088:        register HASHBUCKET*    b;
        !          2089:        HASHBUCKET**            sx;
        !          2090:        int                     n;
        !          2091:        unsigned char*          s;
        !          2092: 
        !          2093:        sx = tab->table + tab->size;
        !          2094:        for (sp = tab->table; sp < sx; sp++)
        !          2095:        {
        !          2096:                n = 0;
        !          2097:                for (b = *sp; b; b = b->next)
        !          2098:                        if (!(b->hash & HASH_DELETED) && (!(tab->flags & HASH_VALUE) || b->value))
        !          2099:                                n++;
        !          2100:                if (n)
        !          2101:                {
        !          2102:                        fprintf(fp, "%5d %2d :", sp - tab->table, n);
        !          2103:                        for (b = *sp; b; b = b->next)
        !          2104:                                if (!(b->hash & HASH_DELETED) && (!(tab->flags & HASH_VALUE) || b->value))
        !          2105:                                {
        !          2106:                                        if (n = tab->root->namesize)
        !          2107:                                        {
        !          2108:                                                fprintf(fp, " 0x");
        !          2109:                                                s = (unsigned char*)hashname(b);
        !          2110:                                                while (n-- > 0)
        !          2111:                                                        fprintf(fp, "%02x", *s++);
        !          2112:                                        }
        !          2113:                                        else fprintf(fp, " %s", hashname(b));
        !          2114:                                        if (b->hash & HASH_FLAGS)
        !          2115:                                        {
        !          2116:                                                fprintf(fp, "|");
        !          2117:                                                if (b->hash & HASH_HIDES) fprintf(fp, "hides|");
        !          2118:                                                if (b->hash & HASH_HIDDEN) fprintf(fp, "hidden|");
        !          2119:                                                if (b->hash & HASH_KEEP) fprintf(fp, "keep|");
        !          2120:                                                if (b->hash & HASH_OPAQUED) fprintf(fp, "opaque|");
        !          2121:                                        }
        !          2122:                                        if (tab->flags & HASH_VALUE) fprintf(fp, "=0x%08lx", (long)b->value);
        !          2123:                                }
        !          2124:                        fprintf(fp, "\n");
        !          2125:                }
        !          2126:        }
        !          2127:        fprintf(fp, "\n");
        !          2128: }
        !          2129: 0707070000000000561006440044230044230000010000000467522022400003300000003204hash/hashfree.cUgsfGgsf/*
        !          2130:  * G. S. Fowler
        !          2131:  * AT&T Bell Laboratories
        !          2132:  *
        !          2133:  * hash table library
        !          2134:  */
        !          2135: 
        !          2136: #include "hashlib.h"
        !          2137: 
        !          2138: /*
        !          2139:  * free (remove) a hash table
        !          2140:  * can be called for partially constructed tables
        !          2141:  * scope covered table pointer is returned
        !          2142:  * root info freed when last reference freed
        !          2143:  */
        !          2144: 
        !          2145: HASHTABLE*
        !          2146: hashfree(tab)
        !          2147: register HASHTABLE*    tab;
        !          2148: {
        !          2149:        register HASHBUCKET**   sp;
        !          2150:        register HASHBUCKET*    b;
        !          2151:        register HASHBUCKET*    p;
        !          2152:        HASHBUCKET**            sx;
        !          2153:        HASHROOT*               rp;
        !          2154:        HASHTABLE*              tp;
        !          2155:        HASHINT                 freevalue;
        !          2156:        HASHINT                 freebucket;
        !          2157: 
        !          2158:        if (!tab) return(0);
        !          2159:        if (tab->table)
        !          2160:        {
        !          2161:                freebucket = (HASHINT)free;
        !          2162:                freevalue = 0;
        !          2163:                if (tab->root->free)
        !          2164:                {
        !          2165:                        if (tab->root->flags & HASH_BUCKET) freebucket = tab->root->free;
        !          2166:                        else freevalue = tab->root->free;
        !          2167:                }
        !          2168:                sx = &tab->table[tab->size];
        !          2169:                sp = &tab->table[0];
        !          2170:                while (sp < sx)
        !          2171:                {
        !          2172:                        b = *sp++;
        !          2173:                        while (b)
        !          2174:                        {
        !          2175:                                if (freevalue && b->value) (void)(*freevalue)(b->value);
        !          2176:                                p = b;
        !          2177:                                b = b->next;
        !          2178:                                if (!(p->hash & HASH_KEEP)) (*freebucket)(p);
        !          2179:                        }
        !          2180:                }
        !          2181:                if ((tab->flags & (HASH_RESIZE|HASH_STATIC)) != HASH_STATIC) free(tab->table);
        !          2182:        }
        !          2183:        if (tab->root)
        !          2184:        {
        !          2185:                /*
        !          2186:                 * remove from the table lists
        !          2187:                 */
        !          2188: 
        !          2189:                if ((tp = tab->root->references) != tab)
        !          2190:                {
        !          2191:                        for (; tp; tp = tp->next)
        !          2192:                                if (tp->next == tab)
        !          2193:                                {
        !          2194:                                        tp->next = tab->next;
        !          2195:                                        break;
        !          2196:                                }
        !          2197:                }
        !          2198:                else if (!(tab->root->references = tp->next))
        !          2199:                {
        !          2200:                        if ((rp = hash_info.list) != tab->root)
        !          2201:                        {
        !          2202:                                for (; rp; rp = rp->next)
        !          2203:                                        if (rp->next == tab->root)
        !          2204:                                        {
        !          2205:                                                rp->next = tab->root->next;
        !          2206:                                                break;
        !          2207:                                        }
        !          2208:                        }
        !          2209:                        else hash_info.list = rp->next;
        !          2210:                }
        !          2211:                if (!(tab->root->references)) free(tab->root);
        !          2212:        }
        !          2213:        if (tp = tab->scope) tp->frozen--;
        !          2214:        free(tab);
        !          2215:        return(tp);
        !          2216: }
        !          2217: 0707070000000000571006440044230044230000010000000475447420200003200000001474hash/hashlib.hUgsfGgsf/*
        !          2218:  * G. S. Fowler
        !          2219:  * AT&T Bell Laboratories
        !          2220:  *
        !          2221:  * hash table library private definitions
        !          2222:  */
        !          2223: 
        !          2224: #include <limits.h>
        !          2225: #include <hash.h>
        !          2226: 
        !          2227: #define HASHMINSIZE    (1<<4)          /* min table slots (power of 2) */
        !          2228: #define HASHMEANCHAIN  2               /* def resize mean chain len    */
        !          2229: 
        !          2230: #define HASHMOD(t,h)   (h &= (t->size - 1))
        !          2231: #define HASHVAL(x)     ((x)&~HASH_FLAGS)
        !          2232: 
        !          2233: #define HASH(r,n,h)    if (r->hash) h = r->namesize ? (*r->hash)(n, r->namesize) : (*r->hash)(n);\
        !          2234:                        else\
        !          2235:                        {\
        !          2236:                                register const char*    _hash_s1 = n;\
        !          2237:                                h = 0;\
        !          2238:                                if (r->namesize)\
        !          2239:                                {\
        !          2240:                                        register const char*    _hash_s2 = _hash_s1 + r->namesize;\
        !          2241:                                        while (_hash_s1 < _hash_s2) HASHPART(h, *_hash_s1++);\
        !          2242:                                }\
        !          2243:                                else while (*_hash_s1) HASHPART(h, *_hash_s1++);\
        !          2244:                        }
        !          2245: 
        !          2246: extern char*   calloc();
        !          2247: extern char*   malloc();
        !          2248: extern char*   memcpy();
        !          2249: 
        !          2250: extern int     strlen();
        !          2251: 
        !          2252: extern void    free();
        !          2253: 0707070000000000601006440044230044230000010000000475447433400003300000012052hash/hashlook.cUgsfGgsf/*
        !          2254:  * G. S. Fowler
        !          2255:  * AT&T Bell Laboratories
        !          2256:  *
        !          2257:  * hash table library
        !          2258:  */
        !          2259: 
        !          2260: #include "hashlib.h"
        !          2261: 
        !          2262: /*
        !          2263:  * hash table lookup
        !          2264:  */
        !          2265: 
        !          2266: #if __STDC__ || __cplusplus
        !          2267: char*
        !          2268: hashlook(register HASHTABLE* tab, const char* name, int flags, const char* value)
        !          2269: #else
        !          2270: #ifndef const
        !          2271: #define const
        !          2272: #endif
        !          2273: char*
        !          2274: hashlook(tab, name, flags, value)
        !          2275: register HASHTABLE*    tab;
        !          2276: char*                  name;
        !          2277: int                    flags;
        !          2278: char*                  value;
        !          2279: #endif
        !          2280: {
        !          2281:        register HASHBUCKET*    b;
        !          2282:        register unsigned int   n;
        !          2283:        HASHTABLE*              top;
        !          2284:        HASHBUCKET*             prev;
        !          2285:        unsigned int            i;
        !          2286: 
        !          2287:        static const char*      lastname;
        !          2288:        static unsigned int     lasthash;
        !          2289: 
        !          2290:        tab->root->accesses++;
        !          2291:        top = tab;
        !          2292:        if (name)
        !          2293:        {
        !          2294:                hash_info.table = tab;
        !          2295:                if (flags & (HASH_BUCKET|HASH_INSTALL))
        !          2296:                {
        !          2297:                        hash_info.last = (HASHBUCKET*)name;
        !          2298:                        name = hashname(hash_info.last);
        !          2299:                }
        !          2300:                else hash_info.last = 0;
        !          2301:                lastname = name;
        !          2302:                if (flags & HASH_BUCKET) n = hash_info.last->hash;
        !          2303:                else if (tab->flags & HASH_HASHED) n = ((unsigned int)name) >> 3;
        !          2304:                else HASH(tab->root, name, n);
        !          2305:                lasthash = i = HASHVAL(n);
        !          2306:                for (;;)
        !          2307:                {
        !          2308:                        HASHMOD(tab, n);
        !          2309:                        for (prev = 0, b = tab->table[n]; b; prev = b, b = b->next)
        !          2310:                        {
        !          2311:                                if (i == HASHVAL(b->hash) && ((b->hash & (HASH_DELETED|HASH_OPAQUED)) != HASH_DELETED || (flags & (HASH_CREATE|HASH_DELETE|HASH_INSTALL))))
        !          2312:                                {
        !          2313:                                        if (!tab->root->compare)
        !          2314:                                        {
        !          2315:                                                register char*          s1 = hashname(b);
        !          2316:                                                register const char*    s2 = name;
        !          2317: 
        !          2318:                                                if (tab->root->namesize)
        !          2319:                                                {
        !          2320:                                                        register char*  s3 = s1 + tab->root->namesize;
        !          2321: 
        !          2322:                                                        while (*s1++ == *s2++)
        !          2323:                                                                if (s1 >= s3) goto found;
        !          2324:                                                }
        !          2325:                                                else while (*s1 == *s2++)
        !          2326:                                                        if (!*s1++) goto found;
        !          2327:                                        }
        !          2328:                                        else if (tab->root->namesize)
        !          2329:                                        {
        !          2330:                                                if (!(*tab->root->compare)(hashname(b), name, tab->root->namesize)) goto found;
        !          2331:                                        }
        !          2332:                                        else if (!(*tab->root->compare)(hashname(b), name)) goto found;
        !          2333:                                }
        !          2334:                                tab->root->collisions++;
        !          2335:                        }
        !          2336:                        if (!tab->scope || (flags & (HASH_CREATE|HASH_INSTALL|HASH_NOSCOPE)) == HASH_NOSCOPE) break;
        !          2337:                        tab = tab->scope;
        !          2338:                        n = i;
        !          2339:                }
        !          2340:        }
        !          2341:        else
        !          2342:        {
        !          2343:                tab = hash_info.table;
        !          2344:                name = lastname;
        !          2345:                prev = 0;
        !          2346:                n = i = lasthash;
        !          2347:                HASHMOD(tab, n);
        !          2348:                if (b = hash_info.last)
        !          2349:                {
        !          2350:                        /*
        !          2351:                         * found the bucket
        !          2352:                         */
        !          2353:                
        !          2354:                found:
        !          2355:                        if (prev && !(tab->flags & HASH_SCANNING))
        !          2356:                        {
        !          2357:                                /*
        !          2358:                                 * migrate popular buckets to the front
        !          2359:                                 */
        !          2360:                
        !          2361:                                prev->next = b->next;
        !          2362:                                b->next = tab->table[n];
        !          2363:                                tab->table[n] = b;
        !          2364:                        }
        !          2365:                        switch (flags & (HASH_CREATE|HASH_DELETE|HASH_INSTALL))
        !          2366:                        {
        !          2367:                        case HASH_CREATE:
        !          2368:                        case HASH_INSTALL:
        !          2369:                                if (tab != top && !(flags & HASH_SCOPE)) break;
        !          2370:                                if (flags & HASH_OPAQUE) b->hash |= HASH_OPAQUED;
        !          2371:                                goto exists;
        !          2372: 
        !          2373:                        case HASH_DELETE:
        !          2374:                                value = 0;
        !          2375:                                if (tab == top || (flags & HASH_SCOPE))
        !          2376:                                {
        !          2377:                                        if (flags & HASH_OPAQUE) b->hash &= ~HASH_OPAQUED;
        !          2378:                                        else if (!(tab->root->flags & HASH_BUCKET))
        !          2379:                                        {
        !          2380:                                                if (tab->root->free && b->value)
        !          2381:                                                {
        !          2382:                                                        (*tab->root->free)(b->value);
        !          2383:                                                        b->value = 0;
        !          2384:                                                }
        !          2385:                                                else if (tab->flags & HASH_VALUE)
        !          2386:                                                {
        !          2387:                                                        value = b->value;
        !          2388:                                                        b->value = 0;
        !          2389:                                                }
        !          2390:                                        }
        !          2391:                                        if (tab->frozen || (b->hash & (HASH_KEEP|HASH_OPAQUED))) b->hash |= HASH_DELETED;
        !          2392:                                        else
        !          2393:                                        {
        !          2394:                                                tab->buckets--;
        !          2395:                                                tab->table[n] = b->next;
        !          2396:                                                if (tab->root->free && (tab->root->flags & HASH_BUCKET)) (*tab->root->free)(b);
        !          2397:                                                else free(b);
        !          2398:                                        }
        !          2399:                                }
        !          2400:                                return((char*)value);
        !          2401:                        default:
        !          2402:                                if (!(b->hash & HASH_DELETED)) goto exists;
        !          2403:                                return(0);
        !          2404:                        }
        !          2405:                }
        !          2406:        }
        !          2407:        if (!(flags & (HASH_CREATE|HASH_INSTALL))) return(0);
        !          2408: 
        !          2409:        /*
        !          2410:         * create a new bucket
        !          2411:         */
        !          2412: 
        !          2413:        if (tab == top) prev = 0;
        !          2414:        else
        !          2415:        {
        !          2416:                if (prev = b)
        !          2417:                {
        !          2418:                        name = (b->hash & HASH_HIDES) ? b->name : (char*)b;
        !          2419:                        i |= HASH_HIDES;
        !          2420:                }
        !          2421:                if (!(flags & HASH_SCOPE)) tab = top;
        !          2422:        }
        !          2423: 
        !          2424:        /*
        !          2425:         * check for table expansion
        !          2426:         */
        !          2427: 
        !          2428:        if (!tab->frozen && !(tab->flags & HASH_FIXED) && tab->buckets > tab->root->meanchain * tab->size) hashsize(tab, tab->size << 1);
        !          2429:        if (flags & HASH_INSTALL)
        !          2430:        {
        !          2431:                b = hash_info.last;
        !          2432:                i |= HASH_KEEP;
        !          2433:        }
        !          2434:        else
        !          2435:        {
        !          2436:                if (flags & HASH_VALUE)
        !          2437:                {
        !          2438:                        tab->flags |= HASH_VALUE;
        !          2439:                        n = sizeof(HASHBUCKET);
        !          2440:                }
        !          2441:                else if (!(flags & HASH_FIXED)) n = sizeof(HASHHEADER);
        !          2442:                else if ((n = (int)value) < sizeof(HASHHEADER)) n = sizeof(HASHHEADER);
        !          2443:                if (!prev && (tab->flags & HASH_ALLOCATE))
        !          2444:                {
        !          2445:                        int     m = tab->root->namesize ? tab->root->namesize : strlen(name) + 1;
        !          2446:                        if (!(b = (HASHBUCKET*)calloc(1, n + m))) return(0);
        !          2447:                        b->name = (char*)b + n;
        !          2448:                        (void)memcpy(b->name, name, m);
        !          2449:                }
        !          2450:                else
        !          2451:                {
        !          2452:                        if (!(b = (HASHBUCKET*)calloc(1, n))) return(0);
        !          2453:                        b->name = (char*)name;
        !          2454:                }
        !          2455:        }
        !          2456:        b->hash = n = i;
        !          2457:        HASHMOD(tab, n);
        !          2458:        b->next = tab->table[n];
        !          2459:        tab->table[n] = b;
        !          2460:        tab->buckets++;
        !          2461:        if (flags & HASH_OPAQUE)
        !          2462:        {
        !          2463:                b->hash |= HASH_DELETED|HASH_OPAQUED;
        !          2464:                return(0);
        !          2465:        }
        !          2466:  exists:
        !          2467: 
        !          2468:        /*
        !          2469:         * finally got the bucket
        !          2470:         */
        !          2471: 
        !          2472:        b->hash &= ~HASH_DELETED;
        !          2473:        hash_info.last = b;
        !          2474:        hash_info.table = tab;
        !          2475:        switch (flags & (HASH_CREATE|HASH_VALUE))
        !          2476:        {
        !          2477:        case HASH_CREATE|HASH_VALUE:
        !          2478:                if (tab->root->free && !(tab->root->flags & HASH_BUCKET) && b->value) (*tab->root->free)(b->value);
        !          2479:                if (value && tab->root->alloc) value = (*tab->root->alloc)(value);
        !          2480:                b->value = (char*)value;
        !          2481:                return((char*)hashname(b));
        !          2482:        case HASH_VALUE:
        !          2483:                return(b->value);
        !          2484:        default:
        !          2485:                return((char*)b);
        !          2486:        }
        !          2487: }
        !          2488: 0707070000000000611006440044230044230000010000000466426707700003300000004205hash/hashscan.cUgsfGgsf/*
        !          2489:  * G. S. Fowler
        !          2490:  * AT&T Bell Laboratories
        !          2491:  *
        !          2492:  * hash table library
        !          2493:  */
        !          2494: 
        !          2495: #include "hashlib.h"
        !          2496: 
        !          2497: /*
        !          2498:  * hash table sequential scan
        !          2499:  *
        !          2500:  *     HASHPOSITION    pos;
        !          2501:  *     HASHBUCKET*     b;
        !          2502:  *     hashscan(tab, flags, &pos);
        !          2503:  *     while (b = hashnext(&pos)) ...;
        !          2504:  *     hashdone(&pos);
        !          2505:  */
        !          2506: 
        !          2507: /*
        !          2508:  * initialize pos for scan on table
        !          2509:  */
        !          2510: 
        !          2511: void
        !          2512: hashscan(tab, flags, pos)
        !          2513: register HASHTABLE*    tab;
        !          2514: register int           flags;
        !          2515: register HASHPOSITION* pos;
        !          2516: {
        !          2517:        static HASHBUCKET       empty;
        !          2518: 
        !          2519:        pos->tab = pos->top = tab;
        !          2520:        pos->bucket = &empty;
        !          2521:        pos->slot = tab->table - 1;
        !          2522:        pos->limit = tab->table + tab->size;
        !          2523:        if (tab->scope && !(flags & HASH_NOSCOPE))
        !          2524:        {
        !          2525:                pos->flags = HASH_SCOPE;
        !          2526:                do
        !          2527:                {
        !          2528:                        register HASHBUCKET*    b;
        !          2529: 
        !          2530:                        if (tab->flags & HASH_SCANNING)
        !          2531:                        {
        !          2532:                                register HASHBUCKET**   sp = tab->table;
        !          2533:                                register HASHBUCKET**   sx = tab->table + tab->size;
        !          2534: 
        !          2535:                                while (sp < sx)
        !          2536:                                        for (b = *sp++; b; b = b->next)
        !          2537:                                                b->hash &= ~HASH_HIDDEN;
        !          2538:                        }
        !          2539:                } while (tab = tab->scope);
        !          2540:                tab = pos->tab;
        !          2541:        }
        !          2542:        else pos->flags = 0;
        !          2543:        tab->flags |= HASH_SCANNING;
        !          2544:        tab->frozen++;
        !          2545: }
        !          2546: 
        !          2547: /*
        !          2548:  * return next scan element
        !          2549:  */
        !          2550: 
        !          2551: HASHBUCKET*
        !          2552: hashnext(pos)
        !          2553: register HASHPOSITION* pos;
        !          2554: {
        !          2555:        register HASHBUCKET*    b;
        !          2556: 
        !          2557:        b = pos->bucket;
        !          2558:        for (;;)
        !          2559:        {
        !          2560:                if (!(b = b->next))
        !          2561:                {
        !          2562:                        do
        !          2563:                        {
        !          2564:                                if (++pos->slot >= pos->limit)
        !          2565:                                {
        !          2566:                                        pos->tab->flags &= ~HASH_SCANNING;
        !          2567:                                        pos->tab->frozen--;
        !          2568:                                        if (!pos->flags || !pos->tab->scope) return(0);
        !          2569:                                        pos->tab = pos->tab->scope;
        !          2570:                                        pos->limit = (pos->slot = pos->tab->table) + pos->tab->size;
        !          2571:                                        pos->tab->flags |= HASH_SCANNING;
        !          2572:                                        pos->tab->frozen++;
        !          2573:                                }
        !          2574:                        } while (!(b = *pos->slot));
        !          2575:                }
        !          2576:                if (!(b->hash & HASH_DELETED) && (!(pos->tab->flags & HASH_VALUE) || b->value) && (!pos->flags || !(b->hash & (HASH_HIDDEN|HASH_HIDES)))) break;
        !          2577:                if (b->hash & HASH_HIDES)
        !          2578:                {
        !          2579:                        register HASHBUCKET*    h = (HASHBUCKET*)b->name;
        !          2580: 
        !          2581:                        if (!(h->hash & HASH_HIDDEN))
        !          2582:                        {
        !          2583:                                h->hash |= HASH_HIDDEN;
        !          2584:                                if (!(b->hash & HASH_DELETED)) break;
        !          2585:                        }
        !          2586:                }
        !          2587:                else b->hash &= ~HASH_HIDDEN;
        !          2588:        }
        !          2589:        return(hash_info.last = pos->bucket = b);
        !          2590: }
        !          2591: 
        !          2592: /*
        !          2593:  * terminate scan
        !          2594:  */
        !          2595: 
        !          2596: void
        !          2597: hashdone(pos)
        !          2598: register HASHPOSITION* pos;
        !          2599: {
        !          2600:        if (pos->tab->flags & HASH_SCANNING)
        !          2601:        {
        !          2602:                pos->tab->flags &= ~HASH_SCANNING;
        !          2603:                pos->tab->frozen--;
        !          2604:        }
        !          2605: }
        !          2606: 0707070000000000621006440044230044230000010000000445242664000003300000001771hash/hashsize.cUgsfGgsf/*
        !          2607:  * G. S. Fowler
        !          2608:  * AT&T Bell Laboratories
        !          2609:  *
        !          2610:  * hash table library
        !          2611:  */
        !          2612: 
        !          2613: #include "hashlib.h"
        !          2614: 
        !          2615: /*
        !          2616:  * change table size and rehash
        !          2617:  * size must be a power of 2
        !          2618:  */
        !          2619: 
        !          2620: void
        !          2621: hashsize(tab, size)
        !          2622: register HASHTABLE*    tab;
        !          2623: int                    size;
        !          2624: {
        !          2625:        register HASHBUCKET**   old_s;
        !          2626:        register HASHBUCKET**   new_s;
        !          2627:        register HASHBUCKET*    old_b;
        !          2628:        register HASHBUCKET*    new_b;
        !          2629:        HASHBUCKET**            old_sx;
        !          2630:        unsigned int            index;
        !          2631: 
        !          2632:        if (size > 0 && size != tab->size && !(size & (size - 1)))
        !          2633:        {
        !          2634:                if (!(new_s = (HASHBUCKET**)calloc(size, sizeof(HASHBUCKET*)))) tab->flags |= HASH_FIXED;
        !          2635:                else
        !          2636:                {
        !          2637:                        old_sx = (old_s = tab->table) + tab->size;
        !          2638:                        tab->size = size;
        !          2639:                        while (old_s < old_sx)
        !          2640:                        {
        !          2641:                                old_b = *old_s++;
        !          2642:                                while (old_b)
        !          2643:                                {
        !          2644:                                        new_b = old_b;
        !          2645:                                        old_b = old_b->next;
        !          2646:                                        index = new_b->hash;
        !          2647:                                        HASHMOD(tab, index);
        !          2648:                                        new_b->next = new_s[index];
        !          2649:                                        new_s[index] = new_b;
        !          2650:                                }
        !          2651:                        }
        !          2652:                        if ((tab->flags & (HASH_RESIZE|HASH_STATIC)) != HASH_STATIC) free(tab->table);
        !          2653:                        tab->table = new_s;
        !          2654:                        tab->flags |= HASH_RESIZE;
        !          2655:                }
        !          2656:        }
        !          2657: }
        !          2658: 0707070000000000631006440044230044230000010000000471771043600003300000000771hash/hashwalk.cUgsfGgsf/*
        !          2659:  * G. S. Fowler
        !          2660:  * AT&T Bell Laboratories
        !          2661:  *
        !          2662:  * hash table library
        !          2663:  */
        !          2664: 
        !          2665: #include "hashlib.h"
        !          2666: 
        !          2667: /*
        !          2668:  * apply walker to each active bucket in the table
        !          2669:  */
        !          2670: 
        !          2671: int
        !          2672: hashwalk(tab, flags, walker)
        !          2673: HASHTABLE*             tab;
        !          2674: int                    flags;
        !          2675: register HASHINT       walker;
        !          2676: {
        !          2677:        register HASHBUCKET*    b;
        !          2678:        register int            v;
        !          2679:        HASHPOSITION            pos;
        !          2680: 
        !          2681:        v = 0;
        !          2682:        hashscan(tab, flags, &pos);
        !          2683:        while (b = hashnext(&pos))
        !          2684:                if ((v = (*walker)(hashname(b), (tab->flags & HASH_VALUE) ? b->value : (char*)b)) < 0)
        !          2685:                        break;
        !          2686:        hashdone(&pos);
        !          2687:        return(v);
        !          2688: }
        !          2689: 0707070000000000641006440044230044230000010000000475447450300003200000000703hash/memhash.cUgsfGgsf/*
        !          2690:  * G. S. Fowler
        !          2691:  * AT&T Bell Laboratories
        !          2692:  *
        !          2693:  * hash table library
        !          2694:  */
        !          2695: 
        !          2696: #include "hashlib.h"
        !          2697: 
        !          2698: /*
        !          2699:  * return the hash of buffer s of length n
        !          2700:  */
        !          2701: 
        !          2702: #if __STDC__ || __cplusplus
        !          2703: unsigned int
        !          2704: memhash(register const char* s, int n)
        !          2705: #else
        !          2706: #ifndef const
        !          2707: #define const
        !          2708: #endif
        !          2709: unsigned int
        !          2710: memhash(s, n)
        !          2711: register char* s;
        !          2712: int            n;
        !          2713: #endif
        !          2714: {
        !          2715:        register const char*    e;
        !          2716:        register unsigned int   c;
        !          2717: 
        !          2718:        e = s + n;
        !          2719:        c = 0;
        !          2720:        while (s < e) HASHPART(c, *s++);
        !          2721:        return(c);
        !          2722: }
        !          2723: 0707070000000000651006440044230044230000010000000475446041300003100000001300hash/memsum.cUgsfGgsf/*
        !          2724:  * G. S. Fowler
        !          2725:  * AT&T Bell Laboratories
        !          2726:  *
        !          2727:  * hash table library
        !          2728:  */
        !          2729: 
        !          2730: #include "hashlib.h"
        !          2731: 
        !          2732: /*
        !          2733:  * return a running 32 bit checksum of buffer b of length n
        !          2734:  *
        !          2735:  * c is the return value from a previous
        !          2736:  * memsum() or strsum() call, 0 on the first call
        !          2737:  *
        !          2738:  * the result is the same on all implementations
        !          2739:  */
        !          2740: 
        !          2741: #if __STDC__ || __cplusplus
        !          2742: unsigned long
        !          2743: memsum(const char* b, int n, register unsigned long c)
        !          2744: #else
        !          2745: unsigned long
        !          2746: memsum(b, n, c)
        !          2747: char*                  b;
        !          2748: int                    n;
        !          2749: register unsigned long c;
        !          2750: #endif
        !          2751: {
        !          2752:        register unsigned char* p;
        !          2753:        register unsigned char* e;
        !          2754: 
        !          2755:        p = (unsigned char*)b;
        !          2756:        e = p + n;
        !          2757:        while (p < e) HASHPART(c, *p++);
        !          2758: #if LONG_MAX > 2147483647
        !          2759:        return(c & 0xffffffff);
        !          2760: #else
        !          2761:        return(c);
        !          2762: #endif
        !          2763: }
        !          2764: 0707070000000000661006440044230044230000010000000475446047400003200000000655hash/strhash.cUgsfGgsf/*
        !          2765:  * G. S. Fowler
        !          2766:  * AT&T Bell Laboratories
        !          2767:  *
        !          2768:  * hash table library
        !          2769:  */
        !          2770: 
        !          2771: #include "hashlib.h"
        !          2772: 
        !          2773: /*
        !          2774:  * return the hash of the null terminated string s
        !          2775:  */
        !          2776: 
        !          2777: #if __STDC__ || __cplusplus
        !          2778: unsigned int
        !          2779: strhash(const char* s)
        !          2780: #else
        !          2781: unsigned int
        !          2782: strhash(s)
        !          2783: char*  s;
        !          2784: #endif
        !          2785: {
        !          2786:        register unsigned char* p;
        !          2787:        register unsigned int   i;
        !          2788:        register unsigned int   c;
        !          2789: 
        !          2790:        i = 0;
        !          2791:        p = (unsigned char*)s;
        !          2792:        while (c = *p++) HASHPART(i, c);
        !          2793:        return(i);
        !          2794: }
        !          2795: 0707070000000000671006440044230044230000010000000475446057700003100000001213hash/strsum.cUgsfGgsf/*
        !          2796:  * G. S. Fowler
        !          2797:  * AT&T Bell Laboratories
        !          2798:  *
        !          2799:  * hash table library
        !          2800:  */
        !          2801: 
        !          2802: #include "hashlib.h"
        !          2803: 
        !          2804: /*
        !          2805:  * return a running 32 bit checksum of string s
        !          2806:  *
        !          2807:  * c is the return value from a previous
        !          2808:  * memsum() or strsum() call, 0 on the first call
        !          2809:  *
        !          2810:  * the result is the same on all implementations
        !          2811:  */
        !          2812: 
        !          2813: #if __STDC__ || __cplusplus
        !          2814: unsigned long
        !          2815: strsum(const char* s, register unsigned long c)
        !          2816: #else
        !          2817: unsigned long
        !          2818: strsum(s, c)
        !          2819: char*                  s;
        !          2820: register unsigned long c;
        !          2821: #endif
        !          2822: {
        !          2823:        register unsigned char* p;
        !          2824:        register int            n;
        !          2825: 
        !          2826:        p = (unsigned char*)s;
        !          2827:        while (n = *p++) HASHPART(c, n);
        !          2828: #if LONG_MAX > 2147483647
        !          2829:        return(c & 0xffffffff);
        !          2830: #else
        !          2831:        return(c);
        !          2832: #endif
        !          2833: }
        !          2834: 0707070000000000701006440044230044230000010000000475434343600003300000002654include/error.hUgsfGgsf/*
        !          2835:  * G. S. Fowler
        !          2836:  * AT&T Bell Laboratories
        !          2837:  *
        !          2838:  * option, error and message formatter external definitions
        !          2839:  */
        !          2840: 
        !          2841: #ifndef ERROR_INFO
        !          2842: 
        !          2843: #include <option.h>
        !          2844: #include <errno.h>
        !          2845: 
        !          2846: #ifndef VOID
        !          2847: #define VOID   char
        !          2848: #endif
        !          2849: 
        !          2850: #define ERROR_INFO     0               /* info message -- no err_id    */
        !          2851: #define ERROR_WARNING  1               /* warning message              */
        !          2852: #define ERROR_ERROR    2               /* error message -- no err_exit */
        !          2853: #define ERROR_FATAL    3               /* error message with err_exit  */
        !          2854: #define ERROR_PANIC    ERROR_LEVEL     /* panic message with err_exit  */
        !          2855: 
        !          2856: #define ERROR_LEVEL    000077          /* level portion of status      */
        !          2857: #define ERROR_SYSTEM   000100          /* report system errno message  */
        !          2858: #define ERROR_OUTPUT   000200          /* next arg is error fd         */
        !          2859: #define ERROR_SOURCE   000400          /* next 2 args are FILE,LINE    */
        !          2860: #define ERROR_USAGE    001000          /* usage message                */
        !          2861: #define ERROR_PROMPT   002000          /* omit trailing newline        */
        !          2862: #define ERROR_NOID     004000          /* omit err_id                  */
        !          2863: #define ERROR_LIBRARY  010000          /* library routine error        */
        !          2864: 
        !          2865: #if __cplusplus
        !          2866: extern "C" {
        !          2867: #endif
        !          2868: 
        !          2869: extern int     errno;                  /* system call error status     */
        !          2870: 
        !          2871: #if __cplusplus
        !          2872: }
        !          2873: #endif
        !          2874: 
        !          2875: #if __STDC__ || __cplusplus || c_plusplus
        !          2876: #include <stdarg.h>
        !          2877: #if __cplusplus
        !          2878: extern "C" {
        !          2879: #endif
        !          2880: extern char*   seterror(int, ...);
        !          2881: extern void    error(int, ...);
        !          2882: extern void    liberror(const char*, int, ...);
        !          2883: extern void    verror(const char*, int, va_list);
        !          2884: #if __cplusplus
        !          2885: }
        !          2886: #endif
        !          2887: #else
        !          2888: extern char*   seterror();
        !          2889: extern void    error();
        !          2890: extern void    liberror();
        !          2891: extern void    verror();
        !          2892: #endif
        !          2893: 
        !          2894: #endif
        !          2895: 0707070000000000711006440044230044230000010000000475446100700003400000005664include/ftwalk.hUgsfGgsf/*
        !          2896:  * K. P. Vo
        !          2897:  * AT&T Bell Laboratories
        !          2898:  *
        !          2899:  * ftwalk(3) interface definitions
        !          2900:  */
        !          2901: 
        !          2902: #ifndef FTW_DOT
        !          2903: 
        !          2904: #ifndef VOID
        !          2905: #define VOID   char
        !          2906: #endif
        !          2907: 
        !          2908: /*
        !          2909:  * ftwalk() argument flags
        !          2910:  */
        !          2911: 
        !          2912: #define FTW_CHILDREN   (1<<0)  /* call user function on child dirs too */
        !          2913: #define FTW_DELAY      (1<<1)  /* do child stat after parent preorder  */
        !          2914: #define FTW_DOT                (1<<2)  /* don't chdir(2) to subdirectories     */
        !          2915: #define FTW_MULTIPLE   (1<<3)  /* path arg is 0 terminated char** argv */
        !          2916: #define FTW_PHYSICAL   (1<<4)  /* physical rather than logical walk    */
        !          2917: #define FTW_POST       (1<<5)  /* visit descendants before parent      */
        !          2918: #define FTW_TWICE      (1<<6)  /* visit parent before&after descendants*/
        !          2919: 
        !          2920: #define FTW_USER       (1<<10) /* first user flag bit                  */
        !          2921: 
        !          2922: struct FTW                     /* user function arg                    */
        !          2923: {
        !          2924:        struct FTW*     left;   /* left child in cycle check tree       */
        !          2925:        struct FTW*     right;  /* right child in cycle check tree      */
        !          2926:        struct FTW*     link;   /* identical to this elt on search path */
        !          2927:        struct FTW*     parent; /* parent in current search path        */
        !          2928:        union
        !          2929:        {
        !          2930:        long            number; /* local number                         */
        !          2931:        char*           pointer;/* local pointer                        */
        !          2932:        }               local;  /* local user data                      */
        !          2933:        struct stat     statb;  /* stat buffer of this object           */
        !          2934:        char*           path;   /* full pathname                        */
        !          2935:        short           pathlen;/* strlen(path)                         */
        !          2936:        unsigned short  info;   /* FTW_* type bits                      */
        !          2937:        unsigned short  status; /* user function entry/return status    */
        !          2938:        short           level;  /* current tree depth                   */
        !          2939:        short           namelen;/* strlen(name)                         */
        !          2940:        char            name[sizeof(int)];      /* file base name       */
        !          2941: };
        !          2942: 
        !          2943: /*
        !          2944:  * individual struct FTW size 
        !          2945:  */
        !          2946: 
        !          2947: #define FTWSIZE(f)     ((f)->namelen+1+sizeof(struct FTW)-sizeof(int))
        !          2948: 
        !          2949: /*
        !          2950:  * FTW.info type bits
        !          2951:  */
        !          2952: 
        !          2953: #define        FTW_NS          (1<<0)  /* stat failed - unknown                */
        !          2954: #define        FTW_F           (1<<1)  /* file - not directory or symbolic link*/
        !          2955: #define FTW_SL         (1<<2)  /* symbolic link                        */
        !          2956: #define        FTW_D           (1<<3)  /* directory - pre-order visit          */
        !          2957: 
        !          2958: #define FTW_C          (1<<4)  /* causes cycle                         */
        !          2959: #define FTW_NR         (1<<5)  /* cannot read                          */
        !          2960: #define FTW_NX         (1<<6)  /* cannot search                        */
        !          2961: #define FTW_P          (1<<7)  /* post-order visit                     */
        !          2962: 
        !          2963: #define FTW_DC (FTW_D|FTW_C)   /* directory - would cause cycle        */
        !          2964: #define        FTW_DNR (FTW_D|FTW_NR)  /* directory - no read permission       */
        !          2965: #define        FTW_DNX (FTW_D|FTW_NX)  /* directory - no search permission     */
        !          2966: #define        FTW_DP  (FTW_D|FTW_P)   /* directory - post-order visit         */
        !          2967: 
        !          2968: /*
        !          2969:  * FTW.status entry values
        !          2970:  */
        !          2971: 
        !          2972: #define FTW_NAME       (1<<0)  /* use FTW.name rather than FTW.path    */
        !          2973: #define FTW_PATH       (1<<1)  /* use FTW.path rather than FTW.name    */
        !          2974: 
        !          2975: /*
        !          2976:  * FTW.status return values
        !          2977:  */
        !          2978: 
        !          2979: #define FTW_AGAIN      (1<<2)  /* process entry again                  */
        !          2980: #define FTW_FOLLOW     (1<<3)  /* follow FTW_SL symlink                */
        !          2981: #define FTW_NOPOST     (1<<4)  /* skip post order visit                */
        !          2982: #define FTW_SKIP       (1<<5)  /* skip FTW_D directory                 */
        !          2983: #define FTW_STAT       (1<<6)  /* userf did stat                       */
        !          2984: 
        !          2985: #if __STDC__ || __cplusplus || c_plusplus
        !          2986: #if __cplusplus
        !          2987: extern "C" {
        !          2988: #endif
        !          2989: extern int     ftwalk(const char* path, int (*userf)(struct FTW*), int flags, int (*comparf)(struct FTW*, struct FTW*));
        !          2990: #if __cplusplus
        !          2991: }
        !          2992: #endif
        !          2993: #else
        !          2994: extern int     ftwalk();
        !          2995: #endif
        !          2996: 
        !          2997: #endif
        !          2998: 0707070000000000721006440044230044230000010000000475434355100003200000014206include/hash.hUgsfGgsf/*
        !          2999:  * G. S. Fowler
        !          3000:  * AT&T Bell Laboratories
        !          3001:  *
        !          3002:  * hash table library interface definitions
        !          3003:  */
        !          3004: 
        !          3005: #ifndef HASH_ALLOCATE
        !          3006: 
        !          3007: #define hash_info              _hash_info_
        !          3008: #define vhashalloc             hashvalloc
        !          3009: 
        !          3010: #ifndef VOID
        !          3011: #define VOID   char
        !          3012: #endif
        !          3013: 
        !          3014: #define HASH_ALLOCATE  (1<<0)          /* allocate new key names       */
        !          3015: #define HASH_FIXED     (1<<1)          /* fixed bucket/table size      */
        !          3016: #define HASH_HASHED    (1<<6)          /* key names already hashed     */
        !          3017: #define HASH_RESIZE    (1<<2)          /* table has been resized       */
        !          3018: #define HASH_SCANNING  (1<<3)          /* currently scanning scope     */
        !          3019: #define HASH_SCOPE     (1<<4)          /* push scope / create in bot   */
        !          3020: #define HASH_STATIC    (1<<5)          /* static table allocation      */
        !          3021: 
        !          3022: #define HASH_CREATE    (1<<8)          /* create bucket if not found   */
        !          3023: #define HASH_DELETE    (1<<9)          /* delete bucket if found       */
        !          3024: #define HASH_LOOKUP    0               /* default op                   */
        !          3025: 
        !          3026: #define HASH_BUCKET    (1<<11)         /* name is installed bucket     */
        !          3027: #define HASH_INSTALL   (1<<12)         /* install allocated bucket     */
        !          3028: #define HASH_NOSCOPE   (1<<13)         /* top scope only               */
        !          3029: #define HASH_OPAQUE    (1<<14)         /* opaque bucket                */
        !          3030: #define HASH_VALUE     (1<<15)         /* value bucket field used      */
        !          3031: 
        !          3032: #define HASH_GET       (HASH_LOOKUP|HASH_VALUE)
        !          3033: #define HASH_NEW       (HASH_CREATE|HASH_FIXED)
        !          3034: #define HASH_PUT       (HASH_CREATE|HASH_VALUE)
        !          3035: 
        !          3036: #define HASH_DELETED   (1<<(8*sizeof(int)-1))  /* deleted placeholder  */
        !          3037: #define HASH_KEEP      (1<<(8*sizeof(int)-2))  /* no free on bucket    */
        !          3038: #define HASH_HIDDEN    (1<<(8*sizeof(int)-3))  /* hidden by scope      */
        !          3039: #define HASH_HIDES     (1<<(8*sizeof(int)-4))  /* hides lower scope    */
        !          3040: #define HASH_OPAQUED   (1<<(8*sizeof(int)-5))  /* opaqued placeholder  */
        !          3041: 
        !          3042: #define HASH_RESET     (HASH_RESIZE|HASH_SCOPE|HASH_STATIC)
        !          3043: #define HASH_INTERNAL  (HASH_BUCKET|HASH_RESIZE|HASH_SCANNING|HASH_STATIC)
        !          3044: #define HASH_FLAGS     (HASH_DELETED|HASH_HIDDEN|HASH_HIDES|HASH_KEEP|HASH_OPAQUED)
        !          3045: 
        !          3046: #define HASH_alloc             1
        !          3047: #define HASH_clear             2
        !          3048: #define HASH_compare           3
        !          3049: #define HASH_free              4
        !          3050: #define HASH_hash              5
        !          3051: #define HASH_meanchain         6
        !          3052: #define HASH_name              7
        !          3053: #define HASH_namesize          8
        !          3054: #define HASH_set               9
        !          3055: #define HASH_size              10
        !          3056: #define HASH_table             11
        !          3057: 
        !          3058: #include <hashpart.h>
        !          3059: 
        !          3060: #define hashclear(t,f)         ((t)->flags &= ~((f) & ~HASH_INTERNAL))
        !          3061: #define hashdel(t,n)           hashlook(t, (char*)(n), HASH_DELETE, (char*)0)
        !          3062: #define hashget(t,n)           hashlook(t, (char*)(n), HASH_LOOKUP|HASH_VALUE, (char*)0)
        !          3063: #define hashlast(t)            (hash_info.last)
        !          3064: #define hashname(b)            ((((b)->hash&HASH_HIDES)?((HASHBUCKET*)((b)->name)):(b))->name)
        !          3065: #define hashput(t,n,v)         (char*)hashlook(t, (char*)(n), HASH_CREATE|HASH_VALUE, (char*)(v))
        !          3066: #define hashscope(t)           ((t)->scope)
        !          3067: #define hashset(t,f)           ((t)->flags |= ((f) & ~HASH_INTERNAL))
        !          3068: 
        !          3069: #define Hashbin_t              HASHBUCKET
        !          3070: #define Hashhdr_t              HASHHEADER
        !          3071: #define Hashpos_t              HASHPOSITION
        !          3072: #define Hashtab_t              HASHTABLE
        !          3073: 
        !          3074: typedef struct hashbucket      HASHBUCKET;
        !          3075: typedef struct hashheader      HASHHEADER;
        !          3076: typedef struct hashposition    HASHPOSITION;
        !          3077: typedef struct hashroot                HASHROOT;
        !          3078: typedef struct hashtable       HASHTABLE;
        !          3079: typedef unsigned int           (*HASHFUN)();
        !          3080: typedef int                    (*HASHINT)();
        !          3081: typedef char*                  (*HASHPTR)();
        !          3082: 
        !          3083: /*
        !          3084:  * the #define's avoid union tags
        !          3085:  */
        !          3086: 
        !          3087: #define HASH_HEADER                    /* common bucket header         */ \
        !          3088:        HASHBUCKET*     next;           /* next in collision chain      */ \
        !          3089:        unsigned int    hash;           /* hash flags and value         */ \
        !          3090:        char*           name            /* key name                     */
        !          3091: 
        !          3092: #define HASH_DEFAULT                   /* HASH_VALUE bucket elements   */ \
        !          3093:        char*           value           /* key value                    */
        !          3094: 
        !          3095: struct hashheader                      /* bucket header                */
        !          3096: {
        !          3097:        HASH_HEADER;
        !          3098: };
        !          3099: 
        !          3100: struct hashbucket                      /* prototype bucket             */
        !          3101: {
        !          3102:        HASH_HEADER;
        !          3103:        HASH_DEFAULT;
        !          3104: };
        !          3105: 
        !          3106: struct hashposition                    /* hash scan bucket position    */
        !          3107: {
        !          3108:        HASHTABLE*      tab;            /* table pointer                */
        !          3109:        HASHTABLE*      top;            /* top scope table pointer      */
        !          3110:        int             flags;          /* scan flags                   */
        !          3111:        HASHBUCKET*     bucket;         /* bucket                       */
        !          3112:        HASHBUCKET**    slot;           /* table slot                   */
        !          3113:        HASHBUCKET**    limit;          /* slot limit                   */
        !          3114: };
        !          3115: 
        !          3116: struct hashroot                                /* root hash table information  */
        !          3117: {
        !          3118:        int             flags;          /* flags: see HASH_[A-Z]*       */
        !          3119:        int             namesize;       /* fixed name size: 0 => string */
        !          3120:        int             meanchain;      /* resize mean chain length     */
        !          3121:        HASHFUN         hash;           /* name hash routine            */
        !          3122:        HASHINT         compare;        /* name comparision routine     */
        !          3123:        HASHPTR         alloc;          /* value allocation routine     */
        !          3124:        HASHINT         free;           /* value free routine           */
        !          3125:        int             accesses;       /* number of accesses           */
        !          3126:        int             collisions;     /* number of collisions         */
        !          3127:        HASHROOT*       next;           /* next in list of all roots    */
        !          3128:        HASHTABLE*      references;     /* referencing table list       */
        !          3129: };
        !          3130: 
        !          3131: struct hashtable                       /* hash table information       */
        !          3132: {
        !          3133:        HASHROOT*       root;           /* root hash table information  */
        !          3134:        HASHTABLE*      scope;          /* scope covered table          */
        !          3135:        short           flags;          /* flags: see HASH_[A-Z]*       */
        !          3136:        short           frozen;         /* table freeze nesting         */
        !          3137:        HASHBUCKET**    table;          /* hash slot table              */
        !          3138:        int             size;           /* table size                   */
        !          3139:        int             buckets;        /* active bucket count          */
        !          3140:        char*           name;           /* table name                   */
        !          3141:        HASHTABLE*      next;           /* root reference list link     */
        !          3142: };
        !          3143: 
        !          3144: struct hashinfo                                /* library hash info            */
        !          3145: {
        !          3146:        HASHBUCKET*     last;           /* most recent lookup bucket    */
        !          3147:        HASHTABLE*      table;          /* most recent lookup table     */
        !          3148:        HASHROOT*       list;           /* root table list              */
        !          3149: };
        !          3150: 
        !          3151: #if __cplusplus
        !          3152: extern "C" {
        !          3153: #endif
        !          3154: 
        !          3155: extern struct hashinfo hash_info;
        !          3156: 
        !          3157: #if __cplusplus
        !          3158: }
        !          3159: #endif
        !          3160: 
        !          3161: #if __STDC__ || __cplusplus || c_plusplus
        !          3162: 
        !          3163: #include <stdarg.h>
        !          3164: #include <stdio.h>
        !          3165: 
        !          3166: #if __cplusplus
        !          3167: extern "C" {
        !          3168: #endif
        !          3169: extern HASHTABLE*      hashalloc(HASHTABLE*, ...);
        !          3170: extern HASHTABLE*      hashvalloc(HASHTABLE*, va_list);
        !          3171: extern void            hashdone(HASHPOSITION*);
        !          3172: extern void            hashdump(FILE*, HASHTABLE*, int);
        !          3173: extern HASHTABLE*      hashfree(HASHTABLE*);
        !          3174: extern char*           hashlook(HASHTABLE*, const char*, int, const char*);
        !          3175: extern HASHBUCKET*     hashnext(HASHPOSITION*);
        !          3176: extern void            hashscan(HASHTABLE*, int, HASHPOSITION*);
        !          3177: extern void            hashsize(HASHTABLE*, int);
        !          3178: extern int             hashwalk(HASHTABLE*, int, HASHINT);
        !          3179: 
        !          3180: extern unsigned int    memhash(const char*, int);
        !          3181: extern unsigned long   memsum(const char*, int, unsigned long);
        !          3182: extern unsigned int    strhash(const char*);
        !          3183: extern unsigned long   strsum(const char*, unsigned long);
        !          3184: #if __cplusplus
        !          3185: }
        !          3186: #endif
        !          3187: #else
        !          3188: extern HASHTABLE*      hashalloc();
        !          3189: extern HASHTABLE*      hashvalloc();
        !          3190: extern void                    hashdone();
        !          3191: extern void            hashdump();
        !          3192: extern HASHTABLE*      hashfree();
        !          3193: extern char*           hashlook();
        !          3194: extern HASHBUCKET*     hashnext();
        !          3195: extern void            hashscan();
        !          3196: extern void            hashsize();
        !          3197: extern int             hashwalk();
        !          3198: 
        !          3199: extern unsigned int    memhash();
        !          3200: extern unsigned long   memsum();
        !          3201: extern unsigned int    strhash();
        !          3202: extern unsigned long   strsum();
        !          3203: #endif
        !          3204: 
        !          3205: #endif
        !          3206: 0707070000000000731006440044230044230000010000000472075301300003600000001053include/hashpart.hUgsfGgsf/*
        !          3207:  * K. P. Vo
        !          3208:  * G. S. Fowler
        !          3209:  * AT&T Bell Laboratories
        !          3210:  *
        !          3211:  * ``the best'' combined linear congruent checksum/hash/PRNG
        !          3212:  */
        !          3213: 
        !          3214: #ifndef HASHPART
        !          3215: 
        !          3216: #define HASH_ADD(h)    (0x9c39c33dL)
        !          3217: 
        !          3218: #if __sparc__ || sparc
        !          3219: 
        !          3220: #define HASH_A(h,n)    ((((h) << 2) - (h)) << (n))
        !          3221: #define HASH_B(h,n)    ((((h) << 4) - (h)) << (n))
        !          3222: #define HASH_C(h,n)    ((HASH_A(h,7) + HASH_B(h,0)) << (n))
        !          3223: #define HASH_MPY(h)    (HASH_C(h,22)+HASH_C(h,10)+HASH_A(h,6)+HASH_A(h,3)+(h))
        !          3224: 
        !          3225: #else
        !          3226: 
        !          3227: #define HASH_MPY(h)    ((h)*0x63c63cd9L)
        !          3228: 
        !          3229: #endif
        !          3230: 
        !          3231: #define HASHPART(h,c)  (h = HASH_MPY(h) + HASH_ADD(h) + (c))
        !          3232: 
        !          3233: #endif
        !          3234: 0707070000000000741006440044230044230000010000000475434364100003000000004055include/ls.hUgsfGgsf/*
        !          3235:  * G. S. Fowler
        !          3236:  * AT&T Bell Laboratories
        !          3237:  *
        !          3238:  * ls formatter interface definitions
        !          3239:  */
        !          3240: 
        !          3241: #ifndef LS_USER
        !          3242: 
        !          3243: #include <fsinfo.h>
        !          3244: 
        !          3245: #ifndef S_IRWXU
        !          3246: #ifndef S_IREAD
        !          3247: #define S_IREAD        00400
        !          3248: #define S_IWRITE       00200
        !          3249: #define S_IEXEC                00100
        !          3250: #endif
        !          3251: #ifndef S_ISUID
        !          3252: #define S_ISUID                04000
        !          3253: #endif
        !          3254: #ifndef S_ISGID
        !          3255: #define S_ISGID                02000
        !          3256: #endif
        !          3257: #ifndef S_ISVTX
        !          3258: #define S_ISVTX                01000
        !          3259: #endif
        !          3260: #ifndef S_IRUSR
        !          3261: #define S_IRUSR                S_IREAD
        !          3262: #define S_IWUSR                S_IWRITE
        !          3263: #define S_IXUSR                S_IEXEC
        !          3264: #define S_IRGRP                (S_IREAD>>3)
        !          3265: #define S_IWGRP                (S_IWRITE>>3)
        !          3266: #define S_IXGRP                (S_IEXEC>>3)
        !          3267: #define S_IROTH                (S_IREAD>>6)
        !          3268: #define S_IWOTH                (S_IWRITE>>6)
        !          3269: #define S_IXOTH                (S_IEXEC>>6)
        !          3270: #endif
        !          3271: 
        !          3272: #define S_IRWXU                (S_IRUSR|S_IWUSR|S_IXUSR)
        !          3273: #define S_IRWXG                (S_IRGRP|S_IWGRP|S_IXGRP)
        !          3274: #define S_IRWXO                (S_IROTH|S_IWOTH|S_IXOTH)
        !          3275: #endif
        !          3276: 
        !          3277: #ifdef stat_blocks
        !          3278: #define tblocks(p)     (((p)->st_blocks+1)/2)
        !          3279: #else
        !          3280: #define tblocks(p)     iblocks(p)
        !          3281: #if __STDC__ || __cplusplus || c_plusplus
        !          3282: #if __cplusplus
        !          3283: extern "C" {
        !          3284: #endif
        !          3285: extern long            iblocks(struct stat*);
        !          3286: #if __cplusplus
        !          3287: }
        !          3288: #endif
        !          3289: #else
        !          3290: extern long            iblocks();
        !          3291: #endif
        !          3292: #endif
        !          3293: 
        !          3294: #define LS_ATIME       (1<<0)          /* list st_atime                */
        !          3295: #define LS_BLOCKS      (1<<1)          /* list blocks used by file     */
        !          3296: #define LS_CTIME       (1<<2)          /* list st_ctime                */
        !          3297: #define LS_INUMBER     (1<<3)          /* list st_ino                  */
        !          3298: #define LS_LONG                (1<<4)          /* long listing                 */
        !          3299: #define LS_MARK                (1<<5)          /* append file name marks       */
        !          3300: #define LS_NOGROUP     (1<<6)          /* omit group name for LS_LONG  */
        !          3301: #define LS_NOUSER      (1<<7)          /* omit user name for LS_LONG   */
        !          3302: 
        !          3303: #define LS_USER                (1<<8)          /* first user flag bit          */
        !          3304: 
        !          3305: #define LS_W_BLOCKS    5               /* LS_BLOCKS field width        */
        !          3306: #define LS_W_INUMBER   7               /* LS_INUMBER field width       */
        !          3307: #define LS_W_LONG      55              /* LS_LONG width (w/o names)    */
        !          3308: #define LS_W_LINK      4               /* link text width (w/o names)  */
        !          3309: #define LS_W_MARK      1               /* LS_MARK field width          */
        !          3310: #define LS_W_NAME      9               /* group|user name field width  */
        !          3311: 
        !          3312: #if __STDC__ || __cplusplus || c_plusplus
        !          3313: #if __cplusplus
        !          3314: extern "C" {
        !          3315: #endif
        !          3316: extern char*   fmtls(char*, const char*, struct stat*, const char*, const char*, int);
        !          3317: #if __cplusplus
        !          3318: }
        !          3319: #endif
        !          3320: #else
        !          3321: extern char*   fmtls();
        !          3322: #endif
        !          3323: 
        !          3324: #endif
        !          3325: 0707070000000000751006440044230044230000010000000434062502300003400000000263include/namval.hUgsfGgsf/*
        !          3326:  * G. S. Fowler
        !          3327:  * AT&T Bell Laboratories
        !          3328:  *
        !          3329:  * name-value struct support
        !          3330:  */
        !          3331: 
        !          3332: #ifndef __NAMVAL_H__
        !          3333: #define __NAMVAL_H__
        !          3334: 
        !          3335: struct namval
        !          3336: {
        !          3337:        char*           name;
        !          3338:        int             value;
        !          3339: };
        !          3340: 
        !          3341: #endif
        !          3342: 0707070000000000761006440044230044230000010000000475434371500003400000001715include/option.hUgsfGgsf/*
        !          3343:  * G. S. Fowler
        !          3344:  * AT&T Bell Laboratories
        !          3345:  *
        !          3346:  * command line option parse assist definitions
        !          3347:  */
        !          3348: 
        !          3349: #ifndef __OPTION_H__
        !          3350: #define __OPTION_H__
        !          3351: 
        !          3352: #if __cplusplus
        !          3353: extern "C" {
        !          3354: #endif
        !          3355: 
        !          3356: extern char*   opt_arg;                /* {:,#} string argument        */
        !          3357: extern int     opt_again;              /* see cmdargs()                */
        !          3358: extern char**  opt_argv;               /* most recent argv             */
        !          3359: extern int     opt_char;               /* char pos in argv[opt_index]  */
        !          3360: extern int     opt_index;              /* argv index                   */
        !          3361: extern char*   opt_msg;                /* error/usage message buffer   */
        !          3362: extern long    opt_num;                /* # numeric argument           */
        !          3363: extern char    opt_option[3];          /* current flag {-,+} + option  */
        !          3364: extern int     opt_pchar;              /* prev opt_char for backup     */
        !          3365: extern int     opt_pindex;             /* prev opt_index for backup    */
        !          3366: 
        !          3367: #if __cplusplus
        !          3368: }
        !          3369: #endif
        !          3370: 
        !          3371: #if __STDC__ || __cplusplus || c_plusplus
        !          3372: #if __cplusplus
        !          3373: extern "C" {
        !          3374: #endif
        !          3375: extern int     optget(char**, const char*);
        !          3376: extern char*   optusage(const char*);
        !          3377: #if __cplusplus
        !          3378: }
        !          3379: #endif
        !          3380: #else
        !          3381: extern int     optget();
        !          3382: extern char*   optusage();
        !          3383: #endif
        !          3384: 
        !          3385: #endif
        !          3386: 0707070000000000771006440044230044230000010000000475434416200003000000002601include/re.hUgsfGgsf/*
        !          3387:  * G. S. Fowler
        !          3388:  * AT&T Bell Laboratories
        !          3389:  *
        !          3390:  * regular expression library definitions
        !          3391:  */
        !          3392: 
        !          3393: #ifndef RE_ALL
        !          3394: 
        !          3395: #define RE_ALL         (1<<0)  /* substitute all occurrences           */
        !          3396: #define RE_EDSTYLE     (1<<1)  /* ed(1) style magic characters         */
        !          3397: #define RE_LOWER       (1<<2)  /* substitute to lower case             */
        !          3398: #define RE_MATCH       (1<<3)  /* record matches in reprogram.match    */
        !          3399: #define RE_UPPER       (1<<4)  /* substitute to upper case             */
        !          3400: #define RE_EXTERNAL    8       /* first external flag bit              */
        !          3401: 
        !          3402: #define RE_NMATCH      ('9'-'0'+1)
        !          3403: 
        !          3404: typedef struct                 /* sub-expression match                 */
        !          3405: {
        !          3406:        char*   sp;             /* start in source string               */
        !          3407:        char*   ep;             /* end in source string                 */
        !          3408: } rematch;
        !          3409: 
        !          3410: /*
        !          3411:  * NOTE: reprogram is a pun for the interface routines
        !          3412:  *      allowing the library to change without forcing
        !          3413:  *      users to recompile
        !          3414:  */
        !          3415: 
        !          3416: typedef struct                 /* compiled regular expression program  */
        !          3417: {
        !          3418:        rematch match[RE_NMATCH+1];/* sub-expression match table        */
        !          3419: } reprogram;
        !          3420: 
        !          3421: /*
        !          3422:  * interface routines
        !          3423:  */
        !          3424: 
        !          3425: #if __STDC__ || __cplusplus || c_plusplus
        !          3426: #if __cplusplus
        !          3427: extern "C" {
        !          3428: #endif
        !          3429: extern reprogram*      recomp(const char*, int);
        !          3430: extern int             reexec(reprogram*, const char*);
        !          3431: extern void            refree(reprogram*);
        !          3432: extern void            reerror(const char*);
        !          3433: extern char*           resub(reprogram*, const char*, const char*, char*, int);
        !          3434: #if __cplusplus
        !          3435: }
        !          3436: #endif
        !          3437: #else
        !          3438: extern reprogram*      recomp();
        !          3439: extern int             reexec();
        !          3440: extern void            refree();
        !          3441: extern void            reerror();
        !          3442: extern char*           resub();
        !          3443: #endif
        !          3444: 
        !          3445: #endif
        !          3446: 0707070000000001001006440044230044230000010000000475415720300003200000016426include/sfio.hUgsfGgsf#ifndef _SFIO_H          /* protect against multiple #includes */
        !          3447: #define _SFIO_H
        !          3448: 
        !          3449: #if __STDC__ || __cplusplus || c_plusplus
        !          3450: #define _SFA_(x)       x
        !          3451: #else
        !          3452: #define _SFA_(x)       ()
        !          3453: #endif
        !          3454: 
        !          3455: #ifndef NULL
        !          3456: #define NULL   0
        !          3457: #endif
        !          3458: #ifndef EOF
        !          3459: #define EOF    (-1)
        !          3460: #endif
        !          3461: #ifndef SEEK_SET
        !          3462: #define SEEK_SET       0
        !          3463: #define SEEK_CUR       1
        !          3464: #define SEEK_END       2
        !          3465: #endif
        !          3466: 
        !          3467: typedef struct _sfdc_  Sfdisc_t;
        !          3468: typedef struct _sfio_  Sfile_t, SFIO;
        !          3469: 
        !          3470: /* discipline structure */
        !          3471: struct _sfdc_
        !          3472: {
        !          3473:        int     (*readf) _SFA_((Sfile_t*, unsigned char*, int, char*));
        !          3474:        int     (*writef) _SFA_((Sfile_t*, const unsigned char*, int, char*));
        !          3475:        long    (*seekf) _SFA_((Sfile_t*, long, int, char*));
        !          3476:        int     (*exceptf) _SFA_((Sfile_t*, int, char*));
        !          3477:        char    *handle;        /* to store any state information       */
        !          3478: };
        !          3479: 
        !          3480: /* a file structure */
        !          3481: struct _sfio_
        !          3482: {
        !          3483:        unsigned char   *next;  /* next position to read/write from     */
        !          3484:        unsigned char   *endw;  /* end of write buffer                  */
        !          3485:        unsigned char   *endr;  /* end of read buffer                   */
        !          3486:        unsigned char   *endb;  /* end of buffer                        */
        !          3487:        struct _sfio_   *push;  /* the stream that was pushed on        */
        !          3488:        short           flags;  /* type of stream                       */
        !          3489:        short           file;   /* file descriptor                      */
        !          3490:        long            orig;   /* where we start in the file           */
        !          3491: #ifdef _SFIO_PRIVATE
        !          3492:        _SFIO_PRIVATE
        !          3493: #endif
        !          3494: };
        !          3495: 
        !          3496: /* bits for various types of files */
        !          3497: #define        SF_READ         000001  /* open for reading                     */
        !          3498: #define SF_WRITE       000002  /* open for writing                     */
        !          3499: #define SF_STRING      000004  /* a string stream                      */
        !          3500: #define SF_APPEND      000010  /* associated file is in append mode    */
        !          3501: #define SF_RELATIVE    000020  /* file pos is relative to starting pos */
        !          3502: #define SF_MALLOC      000040  /* buffered space malloc-ed             */
        !          3503: #define SF_LINE                000100  /* line buffering                       */
        !          3504: #define SF_KEEPFD      000200  /* keep file opened when closing stream */
        !          3505: #define SF_SHARE       000400  /* file stream that is shared           */
        !          3506: #define SF_REUSE       001000  /* keep stream space after closing      */
        !          3507: #define SF_FLAGS       000777  /* PUBLIC FLAGS PASSABLE TO SFNEW()     */
        !          3508: #define SF_SETS                001743  /* flags passable to sfset()            */
        !          3509: 
        !          3510: #define SF_EOF         002000  /* eof was detected                     */
        !          3511: #define SF_ERROR       004000  /* an error happened                    */
        !          3512: 
        !          3513: #define SF_BUFSIZE     8192    /* suggested default buffer size        */
        !          3514: #define SF_UNBOUND     (-1)    /* unbounded buffer size                */
        !          3515: 
        !          3516: #define        sfstdin         (&_Sfstdin)     /* standard input stream        */
        !          3517: #define        sfstdout        (&_Sfstdout)    /* standard output stream       */
        !          3518: #define        sfstderr        (&_Sfstderr)    /* standard error stream        */
        !          3519: 
        !          3520: #if __cplusplus
        !          3521: extern "C"
        !          3522: {
        !          3523: #endif
        !          3524: 
        !          3525: extern int             _Sfi;
        !          3526: extern Sfile_t         _Sfstdin, _Sfstdout, _Sfstderr;
        !          3527: 
        !          3528: extern Sfile_t         *sfnew _SFA_((Sfile_t*, unsigned char*, int, int, int));
        !          3529: extern Sfile_t         *sfopen _SFA_((Sfile_t*, const char*, const char*));
        !          3530: extern Sfile_t         *sfdopen _SFA_((int, const char*));
        !          3531: extern Sfile_t         *sfpopen _SFA_((const char*, const char*, Sfile_t**));
        !          3532: extern Sfile_t         *sfstack _SFA_((Sfile_t*, Sfile_t*));
        !          3533: extern Sfile_t         *_sftmpfile _SFA_((int));
        !          3534: extern int             _sfflsbuf _SFA_((Sfile_t*, int));
        !          3535: extern int             _sffilbuf _SFA_((Sfile_t*, int));
        !          3536: extern int             _sfsync _SFA_((Sfile_t*));
        !          3537: extern int             _sfpeek _SFA_((Sfile_t*, unsigned char**));
        !          3538: extern int             sfclrlock _SFA_((Sfile_t*));
        !          3539: extern unsigned char*  sfsetbuf _SFA_((Sfile_t*, unsigned char*, int));
        !          3540: extern Sfdisc_t*       sfsetdisc _SFA_((Sfile_t*,Sfdisc_t*));
        !          3541: extern int             sfnotice _SFA_((void(*)(Sfile_t*, int)));
        !          3542: extern int             sfset _SFA_((Sfile_t*, int, int));
        !          3543: extern int             sfpool _SFA_((Sfile_t*, Sfile_t*, int));
        !          3544: extern int             sfread _SFA_((Sfile_t*, unsigned char*, int));
        !          3545: extern int             sfwrite _SFA_((Sfile_t*, const unsigned char*, int));
        !          3546: extern int             sfmove _SFA_((Sfile_t*, Sfile_t*, long, const char*));
        !          3547: extern int             sfclose _SFA_((Sfile_t*));
        !          3548: extern long            sftell _SFA_((Sfile_t*));
        !          3549: extern long            sfseek _SFA_((Sfile_t*, long, int));
        !          3550: extern int             sfllen _SFA_((long));
        !          3551: extern int             sfdlen _SFA_((double));
        !          3552: extern int             sfputs _SFA_((Sfile_t*, const char*, int));
        !          3553: extern char            *sfgets _SFA_((Sfile_t*, char*, int));
        !          3554: extern int             sfnputc _SFA_((Sfile_t*, unsigned char, int));
        !          3555: extern int             _sfputu _SFA_((Sfile_t*, unsigned long));
        !          3556: extern int             _sfputl _SFA_((Sfile_t*, long));
        !          3557: extern long            _sfgetl _SFA_((Sfile_t*));
        !          3558: extern unsigned long   _sfgetu _SFA_((Sfile_t*));
        !          3559: extern long            _sfgetl _SFA_((Sfile_t*));
        !          3560: extern int             _sfputd _SFA_((Sfile_t*, double));
        !          3561: extern double          sfgetd _SFA_((Sfile_t*));
        !          3562: extern int             sfungetc _SFA_((Sfile_t*, int));
        !          3563: extern char            *_sfcvt _SFA_((double, int, int*, int*, int));
        !          3564: extern int             sfprintf _SFA_((Sfile_t*, const char*, ...));
        !          3565: extern int             sfsprintf _SFA_((char*, int, const char*, ...));
        !          3566: extern int             sfscanf _SFA_((Sfile_t*, const char*, ...));
        !          3567: extern int             sfsscanf _SFA_((const char*, const char*, ...));
        !          3568: 
        !          3569: #if __STDC__ || __cplusplus
        !          3570: #include       <stdarg.h>
        !          3571: #endif
        !          3572: extern int             sfvprintf _SFA_((Sfile_t*, const char*, va_list));
        !          3573: extern int             sfvscanf _SFA_((Sfile_t*, const char*, va_list));
        !          3574: 
        !          3575: /* function analogues of fast in-line functions */
        !          3576: extern int             sfgetc _SFA_((Sfile_t*));
        !          3577: extern long            sfgetl _SFA_((Sfile_t*));
        !          3578: extern unsigned long   sfgetu _SFA_((Sfile_t*));
        !          3579: extern int             sfputc _SFA_((Sfile_t*,int));
        !          3580: extern int             sfputd _SFA_((Sfile_t*,double));
        !          3581: extern int             sfputl _SFA_((Sfile_t*,long));
        !          3582: extern int             sfputu _SFA_((Sfile_t*,unsigned long));
        !          3583: extern int             sfpeek _SFA_((Sfile_t*, unsigned char**));
        !          3584: extern int             sfsync _SFA_((Sfile_t*));
        !          3585: extern Sfile_t*                sfpushed _SFA_((Sfile_t*));
        !          3586: extern Sfile_t*                sftmp _SFA_((int));
        !          3587: extern int             sfslen _SFA_((void));
        !          3588: extern int             sfulen _SFA_((unsigned long));
        !          3589: extern long            sforigin _SFA_((Sfile_t*));
        !          3590: extern int             sfclearerr _SFA_((Sfile_t*));
        !          3591: extern int             sfeof _SFA_((Sfile_t*));
        !          3592: extern int             sferror _SFA_((Sfile_t*));
        !          3593: extern int             sffileno _SFA_((Sfile_t*));
        !          3594: extern char*           sfecvt _SFA_((double,int,int*,int*));
        !          3595: extern char*           sffcvt _SFA_((double,int,int*,int*));
        !          3596: 
        !          3597: #if __cplusplus
        !          3598: }
        !          3599: #endif
        !          3600: 
        !          3601: /* fast in-line functions */
        !          3602: #define sfputc(f,c)    ((f)->next >= (f)->endw ? \
        !          3603:                                _sfflsbuf(f,(int)((unsigned char)(c))) : \
        !          3604:                                (int)(*(f)->next++ = (unsigned char)(c)))
        !          3605: #define sfgetc(f)      ((f)->next >= (f)->endr ? _sffilbuf(f,1) : (int)(*(f)->next++))
        !          3606: #define sfslen()       (_Sfi)
        !          3607: #define sffileno(f)    ((f)->file)
        !          3608: #define sforigin(f)    (((f)->flags&SF_STRING) ? 0L : (f)->orig)
        !          3609: #define sfeof(f)       (((f)->flags&(SF_EOF|SF_STRING)) && (f)->next >= (f)->endb)
        !          3610: #define sferror(f)     ((f)->flags&SF_ERROR)
        !          3611: #define sfclearerr(f)  ((f)->flags &= ~(SF_ERROR|SF_EOF))
        !          3612: #define sfpushed(f)    ((f)->push)
        !          3613: #define sftmp(n)       ((n) >= 0 ? _sftmpfile(n) : \
        !          3614:                                    sfnew((Sfile_t*)0,(unsigned char*)0,-1,-1, \
        !          3615:                                        SF_READ|SF_WRITE|SF_STRING))
        !          3616: 
        !          3617: #define sfpeek(f,bufp) (((bufp) || \
        !          3618:                          ((f)->flags&(SF_READ|SF_WRITE|SF_STRING)) == \
        !          3619:                           (SF_READ|SF_WRITE|SF_STRING)) ? _sfpeek(f,bufp) : \
        !          3620:                                ((f)->endb - (f)->next))
        !          3621: #define sfsync(f)      (((f) && (((Sfile_t*)(f))->flags&SF_STRING)) ? 0 : _sfsync(f))
        !          3622: 
        !          3623: /* coding long integers in a portable and compact fashion */
        !          3624: #define SF_SBITS       6
        !          3625: #define SF_UBITS       7
        !          3626: #define SF_SIGN                (1 << SF_SBITS)
        !          3627: #define SF_MORE                (1 << SF_UBITS)
        !          3628: #define SF_U1          SF_MORE
        !          3629: #define SF_U2          (SF_U1*SF_U1)
        !          3630: #define SF_U3          (SF_U2*SF_U1)
        !          3631: #define SF_U4          (SF_U3*SF_U1)
        !          3632: #define sfulen(v)      ((v) < SF_U1 ? 1 : (v) < SF_U2 ? 2 : \
        !          3633:                         (v) < SF_U3 ? 3 : (v) < SF_U4 ? 4 : 5)
        !          3634: #define sfgetu(f)      ((_Sfi = sfgetc(f)) < 0 ? -1 : \
        !          3635:                                ((_Sfi&SF_MORE) ? _sfgetu(f) : (unsigned long)_Sfi))
        !          3636: #define sfgetl(f)      ((_Sfi = sfgetc(f)) < 0 ? -1 : \
        !          3637:                                ((_Sfi&(SF_MORE|SF_SIGN)) ? _sfgetl(f) : (long)_Sfi))
        !          3638: #define sfputu(f,v)    _sfputu((f),(unsigned long)(v))
        !          3639: #define sfputl(f,v)    _sfputl((f),(long)(v))
        !          3640: #define sfputd(f,v)    _sfputd((f),(double)(v))
        !          3641: 
        !          3642: #define sfecvt(v,n,d,s)        _sfcvt((v),(n),(d),(s),1)
        !          3643: #define sffcvt(v,n,d,s)        _sfcvt((v),(n),(d),(s),0)
        !          3644: 
        !          3645: #endif /* _SFIO_H */
        !          3646: 0707070000000001011006440044230044230000010000000475445764600003300000002655include/stack.hUgsfGgsf/*
        !          3647:  * G. S. Fowler
        !          3648:  * AT&T Bell Laboratories
        !          3649:  *
        !          3650:  * stack routine definitions
        !          3651:  */
        !          3652: 
        !          3653: #ifndef __STACK_H
        !          3654: 
        !          3655: #define __STACK_H
        !          3656: 
        !          3657: #ifndef VOID
        !          3658: #define VOID   char
        !          3659: #endif
        !          3660: 
        !          3661: typedef struct stacktable* STACK;      /* stack pointer                */
        !          3662: typedef struct stackposition STACKPOS; /* stack position               */
        !          3663: 
        !          3664: struct stackblock                      /* stack block cell             */
        !          3665: {
        !          3666:        char**            stack;        /* actual stack                 */
        !          3667:        struct stackblock* prev;        /* previous block in list       */
        !          3668:        struct stackblock* next;        /* next block in list           */
        !          3669: };
        !          3670: 
        !          3671: struct stackposition                   /* stack position               */
        !          3672: {
        !          3673:        struct stackblock* block;       /* current block pointer        */
        !          3674:        int             index;          /* index within current block   */
        !          3675: };
        !          3676: 
        !          3677: struct stacktable                      /* stack information            */
        !          3678: {
        !          3679:        struct stackblock* blocks;      /* stack table blocks           */
        !          3680:        char*           error;          /* error return value           */
        !          3681:        int             size;           /* size of each block           */
        !          3682:        STACKPOS        position;       /* current stack position       */
        !          3683: };
        !          3684: 
        !          3685: #if __STDC__ || __cplusplus || c_plusplus
        !          3686: 
        !          3687: #if __cplusplus
        !          3688: extern "C" {
        !          3689: #endif
        !          3690: 
        !          3691: extern STACK   mkstack(int size, char* error);
        !          3692: extern void    rmstack(STACK stack);
        !          3693: extern void    clrstack(STACK stack);
        !          3694: extern char*   getstack(STACK stack);
        !          3695: extern int     pushstack(STACK stack, char* value);
        !          3696: extern int     popstack(STACK stack);
        !          3697: extern void    posstack(STACK stack, int set, STACKPOS* position);
        !          3698: 
        !          3699: #if __cplusplus
        !          3700: }
        !          3701: #endif
        !          3702: 
        !          3703: #else
        !          3704: 
        !          3705: extern STACK   mkstack();
        !          3706: extern void    rmstack();
        !          3707: extern void    clrstack();
        !          3708: extern char*   getstack();
        !          3709: extern int     pushstack();
        !          3710: extern int     popstack();
        !          3711: extern void    posstack();
        !          3712: 
        !          3713: #endif
        !          3714: 
        !          3715: #endif
        !          3716: 0707070000000001021006440044230044230000010000000474506072000003200000002666include/stak.hUgsfGgsf#ifndef STAK_SMALL
        !          3717: /*
        !          3718:  * David Korn
        !          3719:  * AT&T Bell Laboratories
        !          3720:  *
        !          3721:  * Interface definitions for a stack-like storage library
        !          3722:  *
        !          3723:  */
        !          3724: 
        !          3725: #if defined(__STDC__) || __cplusplus || c_plusplus
        !          3726: #   define __ARGS(args)        args
        !          3727: #else
        !          3728: #    define const      /*empty*/
        !          3729: #   define __ARGS(args)        ()
        !          3730: #endif
        !          3731: 
        !          3732: typedef struct _stak_
        !          3733: {
        !          3734:        int             stakleft;       /* number of bytes left in frame */
        !          3735:        char            *staktop;       /* current stack location */
        !          3736:        char            *stakbot;       /* last returned stack location */
        !          3737:        short           stakref;        /* reference count */
        !          3738: #ifdef _STAK_PRIVATE
        !          3739:        _STAK_PRIVATE
        !          3740: #endif /* _STAK_PRIVATE */
        !          3741: } Stak_t;
        !          3742: 
        !          3743: #define STAK_SMALL     1       /* argument to stakcreate */
        !          3744: 
        !          3745: #if __cplusplus
        !          3746:     extern "C"
        !          3747:     {
        !          3748: #endif
        !          3749:        extern Stak_t   *stakcreate __ARGS((int));
        !          3750:        extern Stak_t   *stakinstall __ARGS((Stak_t*, char *(*)(int)));
        !          3751:        extern int      stakdelete __ARGS((Stak_t*));
        !          3752:        extern char     *stakalloc __ARGS((unsigned));
        !          3753:        extern char     *stakcopy __ARGS((const char*));
        !          3754:        extern char     *stakset __ARGS((char*, unsigned));
        !          3755:        extern char     *stakseek __ARGS((unsigned));
        !          3756:        extern int      stakputs __ARGS((const char*));
        !          3757:        extern char     *stakfreeze __ARGS((unsigned));
        !          3758:        extern char     *_stakgrow __ARGS((unsigned));
        !          3759: #if __cplusplus
        !          3760:     }
        !          3761: #endif
        !          3762: 
        !          3763: extern Stak_t          _stak_cur;      /* used by macros */
        !          3764: 
        !          3765: #define        staklink(sp)    ((sp)->stakref++)
        !          3766: #define        stakptr(n)      (_stak_cur.stakbot+(n))
        !          3767: #define        staktell()      (_stak_cur.staktop-_stak_cur.stakbot)
        !          3768: #define stakputc(c)    ((--_stak_cur.stakleft<0? _stakgrow(1):0), \
        !          3769:                                        *_stak_cur.staktop++=(c))
        !          3770: 
        !          3771: #endif /* STAK_SMALL */
        !          3772: 0707070000000001031006440044230044230000010000000474441023500003300000005417include/stdio.hUgsfGgsf/*
        !          3773:  * AT&T Bell Laboratories
        !          3774:  *
        !          3775:  * sfio stdio source emulation
        !          3776:  */
        !          3777: 
        !          3778: #ifndef _STDIO_H_
        !          3779: 
        !          3780: #if __cplusplus || c_plusplus
        !          3781: 
        !          3782: #include <../CC/stdio.h>
        !          3783: 
        !          3784: #ifndef _STDIO_H_
        !          3785: #define _STDIO_H_
        !          3786: #endif
        !          3787: 
        !          3788: #else
        !          3789: 
        !          3790: #define _STDIO_H_
        !          3791: 
        !          3792: #include <sfio.h>
        !          3793: 
        !          3794: #define _IOFBF         0
        !          3795: #define _IONBF         1
        !          3796: #define _IOLBF         2
        !          3797: #define L_ctermid      9
        !          3798: #define L_cuserid      9
        !          3799: #define P_tmpdir       "/usr/tmp/"
        !          3800: #define L_tmpnam       (sizeof(P_tmpdir)+15)
        !          3801: 
        !          3802: #if __cplusplus || c_plusplus
        !          3803: extern "C"
        !          3804: {
        !          3805: #endif
        !          3806: 
        !          3807: extern char    *ctermid _SFA_((char*));
        !          3808: extern char    *cuserid _SFA_((char*));
        !          3809: extern char    *tmpnam _SFA_((char*));
        !          3810: extern char    *tempnam _SFA_((char*));
        !          3811: extern char    *_stdgets _SFA_((char*, int n));
        !          3812: extern int     _stdprintf _SFA_((const char*, ...));
        !          3813: extern int     _stdsprintf _SFA_((char*, const char*, ...));
        !          3814: extern int     _stdscanf _SFA_((const char*, ...));
        !          3815: extern int     _stdsetvbuf _SFA_((Sfile_t*, char*, int, int));
        !          3816: 
        !          3817: #if __cplusplus || c_plusplus
        !          3818: }
        !          3819: #endif
        !          3820: 
        !          3821: #define stdin          sfstdin
        !          3822: #define stdout         sfstdout
        !          3823: #define stderr         sfstderr
        !          3824: #define FILE           Sfile_t
        !          3825: #define BUFSIZ         SF_BUFSIZE
        !          3826: 
        !          3827: #define fopen(f,m)     sfopen((Sfile_t*)0,f,m)
        !          3828: #define fdopen(fd,m)   sfdopen(fd,m)
        !          3829: #define freopen(f,m,p) sfopen(p,f,m)
        !          3830: #define tmpfile()      sftmpfile()
        !          3831: #define popen(cmd,m)   sfpopen(cmd,m,(Sfile_t**)0)
        !          3832: #define fclose(f)      sfclose(f)
        !          3833: #define pclose(f)      sfclose(f)
        !          3834: 
        !          3835: #define fwrite(p,s,n,f)        ((_Sfi = sfwrite(f,p,(s)*(n))) <= 0 ? _Sfi : _Sfi/(s))
        !          3836: #define fputc(c,f)     sfputc(f,c)
        !          3837: #define putc(c,f)      sfputc(f,c)
        !          3838: #define putw(w,f)      (_Sfi = (int)w, sfwrite(f,&_Sfi,sizeof(int)) <= 0 ? 1 : 0)
        !          3839: #define putchar(c)     sfputc(sfstdout,c)
        !          3840: #define fputs(s,f)     sfputs(f,s,0)
        !          3841: #define puts(s)                sfputs(sfstdout,s,'\n')
        !          3842: #define fprintf                sfprintf
        !          3843: #define vfprintf       sfvprintf
        !          3844: #define vprintf(f,a)   sfvprintf(sfstdout,f,a)
        !          3845: #define vsprintf       _stdvsprintf
        !          3846: #define        printf          _stdprintf
        !          3847: #define sprintf                _stdsprintf
        !          3848: 
        !          3849: #define fread(p,s,n,f) ((_Sfi = sfread(f,p,(s)*(n))) <= 0 ? _Sfi : _Sfi/(s))
        !          3850: #define fgetc(f)       sfgetc(f)
        !          3851: #define getc(f)                sfgetc(f)
        !          3852: #define getw(f)                (sfread(f,&_Sfi,sizeof(int)) == sizeof(int) ? _Sfi : -1)
        !          3853: #define getchar()      sfgetc(sfstdin)
        !          3854: #define ungetc(c,f)    sfungetc(f,c)
        !          3855: #define fgets(s,n,f)   sfgets(f,s,n)
        !          3856: #define _SIZEOF(s)     (sizeof(s) != sizeof(char*) ? sizeof(s) : BUFSIZ)
        !          3857: #define gets(s)                _stdgets(s,_SIZEOF(s))
        !          3858: #define fscanf         sfscanf
        !          3859: #define vfscanf                sfvscanf
        !          3860: #define sscanf         sfsscanf
        !          3861: #define vscanf(f,a)    sfvscanf(sfstdin,f,a)
        !          3862: #define scanf          _stdscanf
        !          3863: #define vsscanf                _stdvssanf
        !          3864: 
        !          3865: #define fflush(f)      sfsync(f)
        !          3866: #define fseek(f,o,t)   (sfseek(f,o,t) < 0L ? -1 : 0)
        !          3867: #define rewind(f)      sfseek((f),0L,0)
        !          3868: #define ftell(f)       sftell(f)
        !          3869: #define setbuf(f,b)    sfsetbuf(f,b,(b) ? BUFSIZ : 0)
        !          3870: #define setbuffer(f,b,n) sfsetbuf(f,b,n)
        !          3871: #define setlinebuf(f)  sfsetflag(f,SF_LINE,1)
        !          3872: #define setvbuf                _stdsetvbuf
        !          3873: 
        !          3874: #define fileno(f)      sffileno(f)
        !          3875: #define feof(f)                sfeof(f)
        !          3876: #define ferror(f)      sferror(f)
        !          3877: #define clearerr(f)    (sfclearerr(f),sfclearlock(f))
        !          3878: 
        !          3879: #endif
        !          3880: 
        !          3881: #endif
        !          3882: 0707070000000001041006440044230044230000010000000475434432200003200000001330include/swap.hUgsfGgsf/*
        !          3883:  * Glenn Fowler
        !          3884:  * AT&T Bell Laboratories
        !          3885:  *
        !          3886:  * internal representation conversion support definitions
        !          3887:  */
        !          3888: 
        !          3889: #ifndef BYTE
        !          3890: 
        !          3891: #define BYTE           01              /* swap bytes                   */
        !          3892: #define HALF           02              /* swap halfwords               */
        !          3893: 
        !          3894: #define getbyte(op,p)  (*((unsigned char*)(p)))
        !          3895: #define putbyte(op,p,n)        (*(p)=(n))
        !          3896: 
        !          3897: #if __STDC__ || __cplusplus || c_plusplus
        !          3898: #if __cplusplus
        !          3899: extern "C" {
        !          3900: #endif
        !          3901: extern char*           memswap(int, char*, int);
        !          3902: extern int             gethalf(int, const char*);
        !          3903: extern long            getlong(int, const char*);
        !          3904: extern void            puthalf(int, char*, int);
        !          3905: extern void            putlong(int, char*, long);
        !          3906: #if __cplusplus
        !          3907: }
        !          3908: #endif
        !          3909: #else
        !          3910: extern char*           memswap();
        !          3911: extern int             gethalf();
        !          3912: extern long            getlong();
        !          3913: extern void            puthalf();
        !          3914: extern void            putlong();
        !          3915: #endif
        !          3916: 
        !          3917: #endif
        !          3918: 0707070000000001051006440044230044230000010000000432520526300003100000004005include/tar.hUgsfGgsf/*
        !          3919:  * Standard Archive Format
        !          3920:  * USTAR - Uniform Standard Tape ARchive
        !          3921:  */
        !          3922: 
        !          3923: #ifndef TBLOCK
        !          3924: 
        !          3925: #define TBLOCK         512
        !          3926: #define NAMSIZ         100
        !          3927: #define PFXSIZ         155
        !          3928: 
        !          3929: #define TMODLEN                8
        !          3930: #define TUIDLEN                8
        !          3931: #define TGIDLEN                8
        !          3932: #define TSIZLEN                12
        !          3933: #define TMTMLEN                12
        !          3934: #define TCKSLEN                8
        !          3935: 
        !          3936: #define TMAGIC         "ustar"         /* ustar and a null             */
        !          3937: #define TMAGLEN                6
        !          3938: #define TVERSION       "00"            /* 00 and no null               */
        !          3939: #define TVERSLEN       2
        !          3940: #define TUNMLEN                32
        !          3941: #define TGNMLEN                32
        !          3942: #define TDEVLEN                8
        !          3943: 
        !          3944: /*
        !          3945:  * values used in typeflag field
        !          3946:  */
        !          3947: 
        !          3948: #define REGTYPE                '0'             /* regular file                 */
        !          3949: #define AREGTYPE       0               /* alternate REGTYPE            */
        !          3950: #define LNKTYPE                '1'             /* hard link                    */
        !          3951: #define SYMTYPE                '2'             /* soft link                    */
        !          3952: #define CHRTYPE                '3'             /* character special            */
        !          3953: #define BLKTYPE                '4'             /* block special                */
        !          3954: #define DIRTYPE                '5'             /* directory                    */
        !          3955: #define FIFOTYPE       '6'             /* FIFO special                 */
        !          3956: #define CONTYPE                '7'             /* reserved                     */
        !          3957: #define SOKTYPE                '8'             /* socket -- reserved           */
        !          3958: #define VERTYPE                'V'             /* version -- reserved          */
        !          3959: 
        !          3960: /*
        !          3961:  * bits used in mode field
        !          3962:  */
        !          3963: 
        !          3964: #define TSUID          04000           /* set uid on exec              */
        !          3965: #define TSGID          02000           /* set gid on exec              */
        !          3966: #define TSVTX          01000           /* sticky bit -- reserved       */
        !          3967: 
        !          3968: /*
        !          3969:  * file permissions
        !          3970:  */
        !          3971: 
        !          3972: #define TUREAD         00400           /* read by owner                */
        !          3973: #define TUWRITE                00200           /* write by owner               */
        !          3974: #define TUEXEC         00100           /* execute by owner             */
        !          3975: #define TGREAD         00040           /* read by group                */
        !          3976: #define TGWRITE                00020           /* execute by group             */
        !          3977: #define TGEXEC         00010           /* write by group               */
        !          3978: #define TOREAD         00004           /* read by other                */
        !          3979: #define TOWRITE                00002           /* write by other               */
        !          3980: #define TOEXEC         00001           /* execute by other             */
        !          3981: 
        !          3982: struct header
        !          3983: {
        !          3984:        char            name[NAMSIZ];
        !          3985:        char            mode[TMODLEN];
        !          3986:        char            uid[TUIDLEN];
        !          3987:        char            gid[TGIDLEN];
        !          3988:        char            size[TSIZLEN];
        !          3989:        char            mtime[TMTMLEN];
        !          3990:        char            chksum[TCKSLEN];
        !          3991:        char            typeflag;
        !          3992:        char            linkname[NAMSIZ];
        !          3993:        char            magic[TMAGLEN];
        !          3994:        char            version[TVERSLEN];
        !          3995:        char            uname[TUNMLEN];
        !          3996:        char            gname[TGNMLEN];
        !          3997:        char            devmajor[TDEVLEN];
        !          3998:        char            devminor[TDEVLEN];
        !          3999:        char            prefix[PFXSIZ];
        !          4000: };
        !          4001: 
        !          4002: union hblock
        !          4003: {
        !          4004:        char            dummy[TBLOCK];
        !          4005:        struct header   dbuf;
        !          4006: };
        !          4007: 
        !          4008: #endif
        !          4009: 0707070000000001061006440044230044230000010000000475434632700003000000006372include/tm.hUgsfGgsf/*
        !          4010:  * Glenn Fowler
        !          4011:  * AT&T Bell Laboratories
        !          4012:  *
        !          4013:  * time conversion support definitions
        !          4014:  */
        !          4015: 
        !          4016: #ifndef TM_DEFAULT
        !          4017: 
        !          4018: #define tm_data                _tm_data_
        !          4019: #define tm_info                _tm_info_
        !          4020: 
        !          4021: #include <time.h>
        !          4022: #ifndef LS_USER
        !          4023: #include <sys/types.h>
        !          4024: #endif
        !          4025: 
        !          4026: #define tmset()                do{if(!tm_info.local.standard)tminit();}while(0)
        !          4027: 
        !          4028: #ifndef VOID
        !          4029: #define VOID   char
        !          4030: #endif
        !          4031: 
        !          4032: #define TM_ADJUST      (1<<0)          /* local doesn't do leap secs   */
        !          4033: #define TM_LEAP                (1<<1)          /* do leap seconds              */
        !          4034: #define TM_UTC         (1<<2)          /* universal coordinated ref    */
        !          4035: 
        !          4036: #define TM_DST         (-60)           /* default minutes for DST      */
        !          4037: #define TM_LOCALZONE   (25 * 60)       /* use local time zone offset   */
        !          4038: #define TM_MAXLEAP     1               /* max leap secs per leap       */
        !          4039: 
        !          4040: /*
        !          4041:  * these indices must agree with tm_dform[]
        !          4042:  */
        !          4043: 
        !          4044: #define TM_MONTH_3     0
        !          4045: #define TM_MONTH       12
        !          4046: #define TM_DAY_3       24
        !          4047: #define TM_DAY         31
        !          4048: #define TM_TIME                38
        !          4049: #define TM_DATE                39
        !          4050: #define TM_DEFAULT     40
        !          4051: #define TM_MERIDIAN    41
        !          4052: 
        !          4053: #define TM_UT          43
        !          4054: #define TM_DT          47
        !          4055: #define TM_SUFFIXES    51
        !          4056: #define TM_PARTS       55
        !          4057: #define TM_HOURS       62
        !          4058: #define TM_DAYS                66
        !          4059: #define TM_LAST                69
        !          4060: #define TM_THIS                72
        !          4061: #define TM_NEXT                75
        !          4062: #define TM_EXACT       78
        !          4063: #define TM_NOISE       81
        !          4064: 
        !          4065: #define TM_NFORM       85
        !          4066: 
        !          4067: struct tl                              /* leap second info             */
        !          4068: {
        !          4069:        time_t          time;           /* the leap second event        */
        !          4070:        int             total;          /* inclusive total since epoch  */
        !          4071: };
        !          4072: 
        !          4073: struct tz                              /* time zone info               */
        !          4074: {
        !          4075:        char*           type;           /* type name                    */
        !          4076:        char*           standard;       /* standard time name           */
        !          4077:        char*           daylight;       /* daylight or summertime name  */
        !          4078:        short           west;           /* minutes west of GMT          */
        !          4079:        short           dst;            /* add to tz.west for DST       */
        !          4080: };
        !          4081: 
        !          4082: struct tmdata                          /* tm library readonly data     */
        !          4083: {
        !          4084:        char**          format;         /* default TM_* format strings  */
        !          4085:        char*           lex;            /* format lex type classes      */
        !          4086:        char*           digit;          /* output digits                */
        !          4087:        short*          days;           /* days in month i              */
        !          4088:        short*          sum;            /* days in months before i      */
        !          4089:        struct tl*      leap;           /* leap second table            */
        !          4090:        struct tz*      zone;           /* alternate timezone table     */
        !          4091: };
        !          4092: 
        !          4093: struct tminfo                          /* tm library global info       */
        !          4094: {
        !          4095:        char*           deformat;       /* TM_DEFAULT override          */
        !          4096:        int             flags;          /* flags                        */
        !          4097:        char**          format;         /* current format strings       */
        !          4098:        struct tz       local;          /* local timezone               */
        !          4099: };
        !          4100: 
        !          4101: #if __cplusplus
        !          4102: extern "C" {
        !          4103: #endif
        !          4104: 
        !          4105: extern struct tmdata   tm_data;
        !          4106: extern struct tminfo   tm_info;
        !          4107: 
        !          4108: #if __cplusplus
        !          4109: }
        !          4110: #endif
        !          4111: 
        !          4112: #if __STDC__ || __cplusplus || c_plusplus
        !          4113: #if __cplusplus
        !          4114: extern "C" {
        !          4115: #endif
        !          4116: extern time_t          time(time_t*);
        !          4117: 
        !          4118: extern time_t          tmdate(const char*, char**, time_t*);
        !          4119: extern struct tm*      tmfix(struct tm*);
        !          4120: extern char*           tmform(char*, const char*, time_t*);
        !          4121: extern int             tmgoff(const char*, char**, int);
        !          4122: extern void            tminit(void);
        !          4123: extern time_t          tmleap(time_t*);
        !          4124: extern int             tmlex(const char*, char**, char**, int, char**, int);
        !          4125: extern struct tm*      tmmake(time_t*);
        !          4126: extern char*           tmpoff(char*, const char*, int, int);
        !          4127: extern time_t          tmtime(struct tm*, int);
        !          4128: extern char*           tmtype(const char*, char**);
        !          4129: extern int             tmword(const char*, char**, const char*, char**, int);
        !          4130: extern int             tmzone(const char*, char**, const char*, int*);
        !          4131: #if __cplusplus
        !          4132: }
        !          4133: #endif
        !          4134: #else
        !          4135: extern time_t          time();
        !          4136: 
        !          4137: extern time_t          tmdate();
        !          4138: extern struct tm*      tmfix();
        !          4139: extern char*           tmform();
        !          4140: extern int             tmgoff();
        !          4141: extern void            tminit();
        !          4142: extern time_t          tmleap();
        !          4143: extern int             tmlex();
        !          4144: extern struct tm*      tmmake();
        !          4145: extern char*           tmpoff();
        !          4146: extern time_t          tmtime();
        !          4147: extern char*           tmtype();
        !          4148: extern int             tmword();
        !          4149: extern int             tmzone();
        !          4150: #endif
        !          4151: 
        !          4152: #endif
        !          4153: 0707070000000001071006440044230044230000010000000446361053400003000000017542man/ftwalk.3UgsfGgsf.TH FTWALK 3
        !          4154: .SH NAME
        !          4155: \fBftwalk\fR \- file tree walker
        !          4156: .SH SYNOPSIS
        !          4157: .ta .75i 1.5i 2.25i 3i 3.75i 4.5i 5.25i 6i
        !          4158: .PP
        !          4159: .nf
        !          4160: \fB
        !          4161: #include <ftwalk.h>
        !          4162: 
        !          4163: ftwalk(char* path, int (*userf)(struct FTW* ftw), int options,
        !          4164:        int (*comparf)(struct FTW* ftw1, struct FTW* ftw2))
        !          4165: \fR
        !          4166: .fi
        !          4167: .SH DESCRIPTION
        !          4168: .PP
        !          4169: \fIFtwalk\fR traverses a directory hierarchy using depth-first search.
        !          4170: Upon visiting each file or directory in the hierarchy, it calls
        !          4171: the user function \fIuserf\fP to process that file or directory.
        !          4172: On a directory object, \fIuserf\fR may be called twice, once in preorder
        !          4173: and once in postorder.
        !          4174: On a terminal object such as a file or an unreadable directory,
        !          4175: \fIuserf\fP is called only once.
        !          4176: Cycles due to hard links or symbolic links are detected
        !          4177: to avoid infinite loops.
        !          4178: .PP
        !          4179: \fIPath\fR is the starting point of the search.
        !          4180: It may be an absolute path name or a path name relative to
        !          4181: the current directory.
        !          4182: If \fIpath\fR is a null pointer or points to an empty string, it is treated
        !          4183: as if it points to the current (dot) directory.
        !          4184: .PP
        !          4185: \fIOptions\fR consists of zero or more of the following bits:
        !          4186: .IP
        !          4187: FTW_CHILDREN:
        !          4188: This implies preorder calls to \fIuserf\fR on directory objects.
        !          4189: On such a call to \fIuserf\fR,
        !          4190: the field \fIftw->link\fR (below) points to a link list of
        !          4191: the children of the respective directory.
        !          4192: Upon returning from \fIuserf\fP,
        !          4193: if the field \fIftw->status\fR of any child object
        !          4194: is set to FTW_SKIP (below), that child is pruned from the search.
        !          4195: .IP
        !          4196: FTW_DELAY: When \fBFTW_CHILDREN\fP is turned on,
        !          4197: the fields \fIftw->statb\fP (\fIstruct stat\fP) of children objects
        !          4198: remain undefined until these objects are visited.
        !          4199: .IP
        !          4200: FTW_DOT: Do not use \fIchdir\fR(2) during the traversal.
        !          4201: Normally \fIchdir\fR is used so that
        !          4202: the base name of the object about to be processed can be used
        !          4203: in accessing its data.
        !          4204: This can enhance \fIftwalk\fR efficiency but certain program effects
        !          4205: such as core dumps may be generated in unexpected places
        !          4206: or may not even be generated at all.
        !          4207: Whenever \fIchdir\fR generates an error, if possible,
        !          4208: the current directory is restored to the starting directory
        !          4209: (see FTW_NAME and FTW_PATH).
        !          4210: .IP
        !          4211: FTW_MULTIPLE: The \fIpath\fP argument is treated as a \fIchar**\fP
        !          4212: pointer to a null-terminated array of path names.
        !          4213: All hierarchies rooted at these paths will be searched
        !          4214: .IP
        !          4215: FTW_POST: Calls to the user function are issued only in postorder.
        !          4216: That is, \fIuserf\fP is called on a directory only after its descendants have
        !          4217: been processed.
        !          4218: The absence of this bit indicates that calls to the user functions
        !          4219: are issued in preorder. That is, \fIuserf\fP is
        !          4220: called on a directory before its descendants  are processed.
        !          4221: .IP
        !          4222: FTW_PHYSICAL: Use \fIlstat\fR(2) instead of \fIstat\fR(2) to get
        !          4223: file status and allow detection of symbolic links.
        !          4224: In addition, if each component
        !          4225: of the absolute path to the starting object has search permission,
        !          4226: the absolute path is used for early detection of cycles.
        !          4227: .IP
        !          4228: FTW_TWICE: Calls to the user function are issued in both preorder and postorder
        !          4229: for directory objects.
        !          4230: .IP
        !          4231: FTW_USER: The first of 6 user defined option bits.
        !          4232: These bits are ignored by \fIftwalk\fP.
        !          4233: .PP
        !          4234: \fIUserf\fR is a user supplied function that is
        !          4235: called upon different visits of an object.
        !          4236: If the return value of \fIuserf\fR is non-zero,
        !          4237: \fIftwalk\fR returns immediately with the same value.
        !          4238: The \fIuserf\fP prototype is:
        !          4239: .PP
        !          4240: .nf
        !          4241:        int userf(struct FTW* ftw)
        !          4242: .fi
        !          4243: .PP
        !          4244: \fBstruct FTW\fP contains at least the following elements:
        !          4245: .PP
        !          4246: .nf
        !          4247:     struct FTW*    link;    /* link list of children */
        !          4248:     struct FTW*    parent;  /* parent object on the search path */
        !          4249:     union
        !          4250:     {
        !          4251:     long           number;  /* local number */
        !          4252:     void*          pointer; /* local pointer */
        !          4253:     }              local;   /* user defined */
        !          4254:     struct stat    statb;   /* stat buffer of this object */
        !          4255:     char*          path;    /* full pathname */
        !          4256:     short          pathlen; /* strlen(path) */
        !          4257:     unsigned short info;    /* type of object */
        !          4258:     unsigned short status;  /* status of object */ 
        !          4259:     short          level;   /* depth of object on the search path */
        !          4260:     short          namelen; /* strlen(name) */
        !          4261:     char           name[];  /* file name of object */
        !          4262: .fi
        !          4263: .PP
        !          4264: The \fIlink\fR field is normally NULL.
        !          4265: If the option FTW_CHILDREN was turned on,
        !          4266: it points to the start of the list of children
        !          4267: of the directory being visited in preorder.
        !          4268: Finally, if the directory being visited causes a cycle,
        !          4269: \fIlink\fR points to the object on the search path that is
        !          4270: identical to this directory. Note that if FTW_PHYSICAL was turned on,
        !          4271: this may point to a directory that is an ancestor of the starting
        !          4272: object.
        !          4273: .PP
        !          4274: The \fIparent\fR field points to the parent object
        !          4275: on the search path. For convenience, a parent object is also supplied for
        !          4276: the starting object.
        !          4277: In this case, except for the \fIlocal\fR field which is initialized
        !          4278: to 0 and the \fIlevel\fR field which contains a negative number,
        !          4279: the rest of the structure may be undefined.
        !          4280: .PP
        !          4281: The \fIinfo\fR field indicates the type of the object
        !          4282: being visited and the type of the visit. The types are:
        !          4283: .IP
        !          4284: FTW_D: A directory being visited in preorder, i.e.,
        !          4285: none of its children has been visited by the search.
        !          4286: .IP
        !          4287: FTW_DNX: A directory being visited in preorder that does not have
        !          4288: search permission.
        !          4289: .IP
        !          4290: FTW_DP: A directory being visited in postorder, i.e., all of its
        !          4291: descendants have been completely processed.
        !          4292: .IP
        !          4293: FTW_DC: A directory that causes cycles. This is a terminal object.
        !          4294: .IP
        !          4295: FTW_DNR: A directory that cannot be opened for reading. This is a terminal object.
        !          4296: .IP
        !          4297: FTW_F: An ordinary file.
        !          4298: .IP
        !          4299: FTW_SL: A symbolic link.
        !          4300: Unless FTW_FOLLOW (below) is issued by the user function,
        !          4301: this object is terminal.
        !          4302: .IP
        !          4303: FTW_NS: \fIStat\fR failed on this object.
        !          4304: The stat buffer \fIstatb\fR is undefined.
        !          4305: This object is terminal.
        !          4306: .PP
        !          4307: The \fIstatus\fR field of \fIstruct FTW\fR is used to communicate information
        !          4308: between \fIftwalk\fR and \fIuserf\fR. On calls to \fIuserf\fR, it has one of
        !          4309: two values:
        !          4310: .IP
        !          4311: FTW_NAME: The name of the object as defined in \fIftw->name\fR should be used for
        !          4312: accessing its file information. This is because \fIchdir\fR(2) has been used
        !          4313: to set the current directory to a suitable place (see FTW_CHDIR).
        !          4314: .IP
        !          4315: FTW_PATH: The argument \fIpath\fR of \fIuserf\fR should be used
        !          4316: for accessing the file information of the object.
        !          4317: .PP
        !          4318: Upon returning, \fIuserf\fR may set the \fIstatus\fR field
        !          4319: to one of the following values:
        !          4320: .IP
        !          4321: FTW_AGAIN: If this is a directory object being visited in postorder,
        !          4322: it will be processed \fIagain\fR as if it had not been visited.
        !          4323: .IP
        !          4324: FTW_NOPOST: If this is a directory object being visited in preorder,
        !          4325: the user function will not be called on its postorder visit.
        !          4326: .IP
        !          4327: FTW_SKIP: This object and its descendants are pruned from the search.
        !          4328: .IP
        !          4329: FTW_FOLLOW: If this object is a symbolic link,
        !          4330: follow the link to its physical counterpart.
        !          4331: .PP
        !          4332: \fIComparf\fR, if not NULL, is a pointer to a function
        !          4333: used to define a search ordering for children of a directory.
        !          4334: If FTW_CHILDREN is turned on, the ordering of the children of
        !          4335: a directory is done before the preorder call to \fIuserf\fR on that directory.
        !          4336: Therefore, in that case, \fIftw->link\fR will point to the smallest child.
        !          4337: .PP
        !          4338: The \fIcomparf\fP prototype is:
        !          4339: .PP
        !          4340: .nf
        !          4341:        int comparf(struct FTW* ftw1, struct FTW* ftw2)
        !          4342: .fi
        !          4343: .PP
        !          4344: \fIComparf\fR should return a value <0, 0, or >0 to indicate whether
        !          4345: \fIftw1\fR is considered smaller, equal, or larger than \fIftw2\fR.
        !          4346: .PP
        !          4347: \fIFtwalk\fR normally returns 0.
        !          4348: On hard errors such as running out of memory, it returns -1.
        !          4349: \fIFtwalk\fR may also return other values as discussed with respect
        !          4350: to \fIuserf\fR. 
        !          4351: .SH HISTORY
        !          4352: \fIFtwalk\fR performs similar functions as that of
        !          4353: the routine \fIftw\fR provided in System V.
        !          4354: However, it is more general than \fIftw\fR
        !          4355: and suitable for use as a base in implementing
        !          4356: popular tools such as \fIls, find, tar, du,\fR and \fIrm\fR.
        !          4357: \fIFtwalk\fR also handles symbolic links and hard links gracefully.
        !          4358: .SH AUTHORS
        !          4359: Phong Vo, Glenn Fowler, Dave Korn
        !          4360: .SH SEE ALSO
        !          4361: find(1), rm(1), du(1), ls(1), tar(1), stat(2), symlink(2), chdir(3), ftw(3).
        !          4362: 0707070000000001101006440044230044230000010000000471772226300002600000027622man/hash.3UgsfGgsf.de L                \" literal font
        !          4363: .ft 5
        !          4364: .it 1 }N
        !          4365: .if !\\$1 \&\\$1 \\$2 \\$3 \\$4 \\$5 \\$6
        !          4366: ..
        !          4367: .de LR
        !          4368: .}S 5 1 \& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
        !          4369: ..
        !          4370: .de RL
        !          4371: .}S 1 5 \& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
        !          4372: ..
        !          4373: .de EX         \" start example
        !          4374: .ta 1i 2i 3i 4i 5i 6i
        !          4375: .PP
        !          4376: .RS 
        !          4377: .PD 0
        !          4378: .ft 5
        !          4379: .nf
        !          4380: ..
        !          4381: .de EE         \" end example
        !          4382: .fi
        !          4383: .ft
        !          4384: .PD
        !          4385: .RE
        !          4386: .PP
        !          4387: ..
        !          4388: .TH HASH 3
        !          4389: .SH NAME
        !          4390: hash \- hash table support
        !          4391: .SH SYNOPSIS
        !          4392: .L "#include <hash.h>"
        !          4393: .SH DESCRIPTION
        !          4394: The
        !          4395: .I hash
        !          4396: routines manipulate collections of dynamic, scoped hash tables.
        !          4397: .PP
        !          4398: A hash table provides an association between a
        !          4399: .I key
        !          4400: and its
        !          4401: .IR value .
        !          4402: A
        !          4403: .I key
        !          4404: is a sequence of 
        !          4405: .L char
        !          4406: elements and a
        !          4407: .I value
        !          4408: is a user supplied pointer to the value.
        !          4409: Each hash table has a dynamic number of slots,
        !          4410: each pointing to the head of a forward linked
        !          4411: .IR "collision chain" .
        !          4412: .PP
        !          4413: Hashing occurs as follows:
        !          4414: a
        !          4415: .I "hash function"
        !          4416: takes a
        !          4417: .I key
        !          4418: as an argument and returns a non-negative index.
        !          4419: The index modulo the table size produces a
        !          4420: slot that points to a
        !          4421: .IR "collision chain" .
        !          4422: The collision chain is sequentially searched until a match is found for
        !          4423: .IR key .
        !          4424: The hash tables are automatically resized as new entries are added.
        !          4425: .PP
        !          4426: Each hash table has one key type.
        !          4427: The default key type is a pointer to a null-terminated string.
        !          4428: The alternate key type is a pointer to a fixed length byte buffer,
        !          4429: declared for a given table by the
        !          4430: .L hashalloc()
        !          4431: function described below.
        !          4432: .PP
        !          4433: Hash table information is partitioned into two parts for efficient scoping.
        !          4434: The
        !          4435: .I root
        !          4436: part contains fixed information that is shared among a set of related
        !          4437: hash tables.
        !          4438: The remaining information is maintained on a per-table basis.
        !          4439: .PP
        !          4440: These basic types are defined in the header file
        !          4441: .B hash.h
        !          4442: (alternate names are listed in parenthesis):
        !          4443: .TP
        !          4444: .L "HASHTABLE (Hashtab_t)"
        !          4445: The per-table information.
        !          4446: The readonly public elements are:
        !          4447: .RS
        !          4448: .TP
        !          4449: .L "int buckets"
        !          4450: The number of table entries.
        !          4451: .TP
        !          4452: .L "char* name"
        !          4453: The hash table name.
        !          4454: .TP
        !          4455: .L "root"
        !          4456: The root information.
        !          4457: The public elements are:
        !          4458: .RS
        !          4459: .TP
        !          4460: .L "int root->accesses"
        !          4461: The number of lookups.
        !          4462: .TP
        !          4463: .L "int root->collisions"
        !          4464: The number of lookup collisions.
        !          4465: .RE
        !          4466: .TP
        !          4467: .L "HASHTABLE* scope"
        !          4468: The table that this scope covers, 
        !          4469: .L NULL
        !          4470: if the table is not a scope.
        !          4471: .TP
        !          4472: .L "int size"
        !          4473: The current hash table size.
        !          4474: .RE
        !          4475: .TP
        !          4476: .L "HASHBUCKET (Hashbin_t)"
        !          4477: A collision chain hash bucket.
        !          4478: The public structure elements are:
        !          4479: .RS
        !          4480: .TP
        !          4481: .L "char* hashname(HASHBUCKET*)"
        !          4482: Returns a pointer to the hash bucket key given the bucket pointer.
        !          4483: .TP
        !          4484: .L "char* value"
        !          4485: The value associated with the key.
        !          4486: .RE
        !          4487: .TP
        !          4488: .L "HASHHEADER (Hashhdr_t)"
        !          4489: The hash bucket header that must be the first element in all user defined
        !          4490: buckets.
        !          4491: .L HASH_VALUE
        !          4492: may not be used with user defined buckets.
        !          4493: .TP
        !          4494: .L "HASHPOSITION (Hashpos_t)"
        !          4495: Stores the hash table position for
        !          4496: .LR hashscan .
        !          4497: The public elements are:
        !          4498: .RS
        !          4499: .TP
        !          4500: .L "HASHBUCKET* bucket"
        !          4501: The current hash bucket pointer.
        !          4502: .RE
        !          4503: .PP
        !          4504: The routines are:
        !          4505: .TP
        !          4506: .L "HASHTABLE* hashalloc(HASHTABLE* ref, int op, ...)"
        !          4507: Creates a new hash table and returns a pointer to the table.
        !          4508: .IR malloc (3)
        !          4509: is used to allocate space for the table.
        !          4510: .L NULL
        !          4511: is returned if the table cannot be created.
        !          4512: .L ref
        !          4513: is a pointer to a reference hash table that provides
        !          4514: default values for unspecified information.
        !          4515: The new hash table and
        !          4516: .L ref
        !          4517: share the same root information.
        !          4518: If
        !          4519: .L ref
        !          4520: is
        !          4521: .L NULL
        !          4522: then new root information is created for the new table.
        !          4523: The remaining arguments appear in
        !          4524: .I op-arg
        !          4525: pairs, followed by a final
        !          4526: .L 0
        !          4527: argument.
        !          4528: The
        !          4529: .I op-arg
        !          4530: pairs are:
        !          4531: .RS
        !          4532: .TP
        !          4533: .L "HASH_alloc, (char(*)()) alloc"
        !          4534: .L alloc
        !          4535: is a function that is called to process
        !          4536: .L HASHBUCKET
        !          4537: .L value
        !          4538: assignments.
        !          4539: The single argument is
        !          4540: .L "char* value"
        !          4541: and the processed
        !          4542: .L char*
        !          4543: value is returned.
        !          4544: .TP
        !          4545: .L "HASH_clear, int flags"
        !          4546: .L flags
        !          4547: are the
        !          4548: .L ref
        !          4549: flags to be cleared in the new hash table.
        !          4550: See
        !          4551: .L HASH_set
        !          4552: below.
        !          4553: .TP
        !          4554: .L "HASH_compare, (int(*)()) compare"
        !          4555: Specifies an alternate
        !          4556: .I key
        !          4557: comparison function.
        !          4558: The arguments and return value for
        !          4559: .L compare
        !          4560: are the same as for
        !          4561: .IR strncmp (3)
        !          4562: if
        !          4563: .L HASH_namesize
        !          4564: is specified and
        !          4565: .IR strcmp (3)
        !          4566: otherwise.
        !          4567: The first argument is the 
        !          4568: .I key
        !          4569: from the current hash bucket on the 
        !          4570: .I "collision chain"
        !          4571: and the second argument is the user supplied 
        !          4572: .IR key .
        !          4573: .TP
        !          4574: .L "HASH_free, (int(*)()) free"
        !          4575: .L free
        !          4576: is a function that is called when a hash bucket is freed.
        !          4577: If
        !          4578: .L HASH_BUCKET
        !          4579: was set in
        !          4580: .L hashalloc
        !          4581: then the hash bucket pointer is passed, otherwise the bucket
        !          4582: .L value 
        !          4583: pointer is passed.
        !          4584: .TP
        !          4585: .L "HASH_hash, (int(*)()) hash"
        !          4586: Specifies an alternate
        !          4587: .I key
        !          4588: hash function.
        !          4589: A
        !          4590: .L char*
        !          4591: key argument (and, if
        !          4592: .L HASH_namesize
        !          4593: is specified, an
        !          4594: .L int
        !          4595: key size argument) is passed to
        !          4596: .LR hash .
        !          4597: The return value must be a non-negative
        !          4598: .LR int .
        !          4599: .TP
        !          4600: .L "HASH_meanchain, int meanchain"
        !          4601: Specifies the mean collision chain length.
        !          4602: The hash table is automatically resized when this value is exceeded.
        !          4603: The default mean chain length is 2.
        !          4604: .TP
        !          4605: .L "HASH_name, char* name"
        !          4606: Associates
        !          4607: .L name
        !          4608: with the hash table.
        !          4609: Used by
        !          4610: .LR hashdump) .
        !          4611: .TP
        !          4612: .L "HASH_namesize, int namesize"
        !          4613: The fixed size in bytes for
        !          4614: .I keys
        !          4615: in the table.
        !          4616: If
        !          4617: .L namesize
        !          4618: is 0 (the default) then the
        !          4619: .I keys
        !          4620: are interpreted as null-terminated strings.
        !          4621: .TP
        !          4622: .L "HASH_set, int flags"
        !          4623: Changes the hash table flags by
        !          4624: .IR or ing
        !          4625: in
        !          4626: .LR flags .
        !          4627: The flags, which may be 
        !          4628: .IR or ed
        !          4629: together, are:
        !          4630: .RS
        !          4631: .TP
        !          4632: .L HASH_ALLOCATE
        !          4633: Keys for new hash table entries are to be copied to data areas obtained from
        !          4634: .IR malloc (3).
        !          4635: .TP
        !          4636: .L HASH_FIXED
        !          4637: Fixes the hash table size, disabling any automatic table resizing.
        !          4638: .TP
        !          4639: .L HASH_SCOPE
        !          4640: The new hash table is a scope that is to be pushed on top of
        !          4641: .LR ref .
        !          4642: .L ref
        !          4643: must be
        !          4644: .RL non- NULL .
        !          4645: .RE
        !          4646: .RE
        !          4647: .TP
        !          4648: .L "HASHTABLE* hashfree(HASHTABLE* tab)"
        !          4649: The hash table
        !          4650: .L tab
        !          4651: is freed.
        !          4652: The scope covered table pointer is returned,
        !          4653: .L NULL
        !          4654: if
        !          4655: .L tab
        !          4656: is not a scope.
        !          4657: .TP
        !          4658: .L "char* hashlook(HASHTABLE* tab, char* name, int flags, char* value)"
        !          4659: Operates on the key
        !          4660: .L name
        !          4661: in the hash table
        !          4662: .L tab
        !          4663: according to
        !          4664: .L flags
        !          4665: and 
        !          4666: .LR value .
        !          4667: A
        !          4668: .L HASHBUCKET
        !          4669: pointer is returned unless otherwise noted.
        !          4670: There are three basic lookup operations:
        !          4671: .RS
        !          4672: .TP
        !          4673: .L HASH_CREATE
        !          4674: .L name
        !          4675: is entered into the top level scope if it does not already exist.
        !          4676: If
        !          4677: .L name
        !          4678: also appears in a lower scope and
        !          4679: .L HASH_ALLOC
        !          4680: is set for the table then the new bucket will share the
        !          4681: .L name
        !          4682: field value with the lower scope.
        !          4683: .TP
        !          4684: .L HASH_DELETE
        !          4685: .L name
        !          4686: is deleted from the top level scope if it exists.
        !          4687: .L NULL
        !          4688: is returned.
        !          4689: .TP
        !          4690: .L HASH_LOOKUP
        !          4691: The scopes are searched in order from top to bottom for
        !          4692: .L name .
        !          4693: The bucket pointer for the first occurrence is returned.
        !          4694: .L NULL
        !          4695: is returned if
        !          4696: .L name
        !          4697: is not found.
        !          4698: .RE
        !          4699: The basic operations may be qualified by the following
        !          4700: (the qualifiers are restricted to the basic operations in
        !          4701: the parenthesized list):
        !          4702: .RS
        !          4703: .TP
        !          4704: .L "HASH_BUCKET (HASH_CREATE,HASH_DELETE,HASH_LOOKUP)"
        !          4705: .L name
        !          4706: is a pointer to a bucket that has already been entered into the table.
        !          4707: .TP
        !          4708: .L "HASH_FIXED (HASH_CREATE)"
        !          4709: .L value
        !          4710: is taken to be the size of the hash bucket to be created for
        !          4711: .L name
        !          4712: in the top level scope.
        !          4713: The minimum bucket size is silently restricted to
        !          4714: .LR sizeof(HASHHEADER) .
        !          4715: .TP
        !          4716: .L "HASH_INSTALL (HASH_CREATE)"
        !          4717: .L name
        !          4718: is a pointer to a bucket that has not been entered into the table.
        !          4719: .TP
        !          4720: .L "HASH_NOSCOPE (HASH_LOOKUP)"
        !          4721: The lookup is restricted to the top level scope.
        !          4722: .TP
        !          4723: .L "HASH_OPAQUE (HASH_CREATE,HASH_DELETE)"
        !          4724: Sets
        !          4725: .L (HASH_CREATE)
        !          4726: or clears
        !          4727: .L (HASH_DELETE)
        !          4728: the
        !          4729: .I opaque
        !          4730: property for the bucket.
        !          4731: An opaque bucket is not visible in lower scopes.
        !          4732: .TP
        !          4733: .L "HASH_SCOPE (HASH_CREATE,HASH_DELETE)"
        !          4734: All scopes are searched for the bucket.
        !          4735: If the bucket is not found for
        !          4736: .L HASH_CREATE
        !          4737: then a new bucket is created in the lowest scope.
        !          4738: .TP
        !          4739: .L "HASH_VALUE (HASH_CREATE,HASH_LOOKUP)"
        !          4740: For
        !          4741: .L HASH_CREATE
        !          4742: the bucket
        !          4743: .L value
        !          4744: field is set to
        !          4745: .L value
        !          4746: and the bucket
        !          4747: .L name
        !          4748: value is returned.
        !          4749: For
        !          4750: .L HASH_LOOKUP
        !          4751: the bucket
        !          4752: .L value 
        !          4753: field is returned,
        !          4754: .L NULL
        !          4755: if the bucket is not found.
        !          4756: .RE
        !          4757: If
        !          4758: .L name
        !          4759: .L NULL
        !          4760: then the name from the most recent
        !          4761: .L hashlook()
        !          4762: is used, avoiding recomputation of some internal parameters.
        !          4763: .TP
        !          4764: .L "char* hashget(HASHTABLE* tab, char* name)"
        !          4765: Returns the value
        !          4766: associated with the key
        !          4767: .L name
        !          4768: in the hash table
        !          4769: .LR tab .
        !          4770: If
        !          4771: .L name
        !          4772: is
        !          4773: .L NULL
        !          4774: then the name from the most recent
        !          4775: .L hashget()
        !          4776: is used, avoiding recomputation of some internal parameters.
        !          4777: .L NULL
        !          4778: is returned if
        !          4779: .L name
        !          4780: is not in the table.
        !          4781: All scope covered tables are searched.
        !          4782: .TP
        !          4783: .L "HASHBUCKET* hashlast(HASHTABLE* tab)"
        !          4784: Returns a pointer to the most recent hash bucket for
        !          4785: the most recent hash table.
        !          4786: The value is set by
        !          4787: .LR hashlook() ,
        !          4788: .L hashscan()
        !          4789: and
        !          4790: .LR hashwalk() .
        !          4791: .TP
        !          4792: .L "char* hashput(HASHTABLE* tab, char* name, char* value)"
        !          4793: Set the value of the key
        !          4794: .L name
        !          4795: to
        !          4796: .L value
        !          4797: in the top level scope of the hash table
        !          4798: .LR tab .
        !          4799: .L name
        !          4800: is entered into the top level scope if necessary.
        !          4801: The (possibly re-allocated) key name pointer is returned
        !          4802: (see
        !          4803: .LR HASH_ALLOCATE ).
        !          4804: .TP
        !          4805: .L "int hashwalk(HASHTABLE* tab, int flags, (int(*)()) walker)"
        !          4806: The function
        !          4807: .L walker
        !          4808: is applied to each entry (not covered by a scope starting at
        !          4809: .LR tab )
        !          4810: in the hash table
        !          4811: .LR tab .
        !          4812: If
        !          4813: .L flags
        !          4814: is 
        !          4815: .L HASH_NOSCOPE
        !          4816: then only the top level hash table is used, otherwise the walk includes
        !          4817: all scope covered tables.
        !          4818: .L walker
        !          4819: is called with
        !          4820: .L char*
        !          4821: .I key
        !          4822: as the first argument and
        !          4823: .L char*
        !          4824: .I value
        !          4825: as the second argument.
        !          4826: The walk terminates after the last entry or when
        !          4827: .L walker
        !          4828: returns a negative value.
        !          4829: The return value of the last call to
        !          4830: .L walker
        !          4831: is returned.
        !          4832: Only one walk may be active within a collection of scoped tables.
        !          4833: .TP
        !          4834: .L "void hashscan(HASHTABLE* tab, int flags, HASHPOSITION* pos)"
        !          4835: Initializes 
        !          4836: .L pos
        !          4837: for a sequential scan on the hash table
        !          4838: .LR tab .
        !          4839: If
        !          4840: .L flags
        !          4841: is 
        !          4842: .L HASH_NOSCOPE
        !          4843: then only the top level hash table is used, otherwise the scan includes
        !          4844: all scope covered tables.
        !          4845: Only one scan may be active within a collection of scoped tables.
        !          4846: .L hashdone()
        !          4847: must be called to terminate the scan.
        !          4848: .TP
        !          4849: .L "int hashnext(HASHPOSITION* pos)"
        !          4850: Generates the next element in the sequential scan set up by
        !          4851: .L hashscan()
        !          4852: on
        !          4853: .LR pos .
        !          4854: If no elements remain then
        !          4855: .L 0
        !          4856: is returned.
        !          4857: Otherwise
        !          4858: .L pos->bucket
        !          4859: points to the hash bucket of the next element and
        !          4860: .L 1
        !          4861: is returned.
        !          4862: .TP
        !          4863: .L "void hashdone(HASHPOSITION* pos)"
        !          4864: Completes a scan initiated by 
        !          4865: .L hashscan()
        !          4866: on 
        !          4867: .LR pos .
        !          4868: .TP
        !          4869: .L "int hashset(HASHTABLE* tab, int flags)"
        !          4870: Sets the flags for the hash table
        !          4871: .L tab
        !          4872: by
        !          4873: .IR or ing
        !          4874: in
        !          4875: .LR flags .
        !          4876: Only
        !          4877: .L HASH_ALLOCATE
        !          4878: and
        !          4879: .L HASH_FIXED
        !          4880: may be set.
        !          4881: .TP
        !          4882: .L "int hashclear(HASHTABLE* tab, int flags)"
        !          4883: Clears the flags for the hash table
        !          4884: .L tab
        !          4885: by masking out
        !          4886: .LR flags .
        !          4887: Only
        !          4888: .L HASH_ALLOCATE
        !          4889: and
        !          4890: .L HASH_FIXED
        !          4891: may be cleared.
        !          4892: .TP
        !          4893: .L "void hashdump(FILE* fp, HASHTABLE* tab, int flags)"
        !          4894: Dumps hash table accounting info to the output file stream
        !          4895: .LR fp .
        !          4896: If
        !          4897: .L tab
        !          4898: is 
        !          4899: .L NULL
        !          4900: then all allocated hash tables are dumped, otherwise only information on
        !          4901: .L tab
        !          4902: is dumped.
        !          4903: If
        !          4904: .L flags
        !          4905: is 
        !          4906: .L HASH_BUCKET
        !          4907: then the hash bucket
        !          4908: .I key-value
        !          4909: pairs for each collision chain are also dumped.
        !          4910: .TP
        !          4911: .L "void hashsize(HASHTABLE* tab, int size)"
        !          4912: Changes the size of the hash table
        !          4913: .L tab
        !          4914: to
        !          4915: .L size
        !          4916: where
        !          4917: .L size
        !          4918: must be a power of 2.
        !          4919: Explicit calls to this routine are not necessary as hash tables
        !          4920: are automatically resized.
        !          4921: .TP
        !          4922: .L "int strhash(char* name)"
        !          4923: Hashes the null terminated character string
        !          4924: .L name
        !          4925: using a linear congruent pseudo-random number generator algorithm
        !          4926: and returns a non-negative
        !          4927: .L int
        !          4928: hash value.
        !          4929: .TP
        !          4930: .L "int memhash(char* buf, int siz)"
        !          4931: Hashes the buffer
        !          4932: .L buf
        !          4933: of
        !          4934: .L siz
        !          4935: bytes using a linear congruent pseudo-random number generator algorithm
        !          4936: and returns a non-negative
        !          4937: .L int
        !          4938: hash value.
        !          4939: .TP
        !          4940: .L "long strsum(char* name, long sum)"
        !          4941: Returns a running 31-bit checksum of the string
        !          4942: .L name
        !          4943: where
        !          4944: .L sum
        !          4945: is
        !          4946: .L 0
        !          4947: on the first call and
        !          4948: the return value from a previous
        !          4949: .L memsum
        !          4950: or
        !          4951: .L strsum
        !          4952: call otherwise.
        !          4953: The checksum value is consistent across all implementations.
        !          4954: .TP
        !          4955: .L "long memsum(char* buf, int siz, long sum)"
        !          4956: Returns a running 31-bit checksum of buffer
        !          4957: .L buf
        !          4958: of
        !          4959: .L siz
        !          4960: bytes where
        !          4961: .L sum
        !          4962: is
        !          4963: .L 0
        !          4964: on the first call and
        !          4965: the return value from a previous
        !          4966: .L memsum
        !          4967: or
        !          4968: .L strsum
        !          4969: call otherwise.
        !          4970: The checksum value is consistent across all implementations.
        !          4971: .SH "SEE ALSO"
        !          4972: sum(1)
        !          4973: 0707070000000001111006440044230044230000010000000467615557100002400000005571man/re.3UgsfGgsf.TH RE 3
        !          4974: .SH NAME
        !          4975: recomp, reexec, resub, refree, reerror \(mi regular expression library
        !          4976: .SH SYNOPSIS
        !          4977: .B #include <re.h>
        !          4978: .PP
        !          4979: .L reprogram* recomp(char* pattern, int flags)
        !          4980: .PP
        !          4981: .L int reexec(reprogram* re, char* source)
        !          4982: .PP
        !          4983: .L void resub(reprogram* re, char* old, char* new, char* destination, int flags)
        !          4984: .PP
        !          4985: .L void reerror(char* message)
        !          4986: .PP
        !          4987: .L void refree(reprogram* re)
        !          4988: .SH DESCRIPTION
        !          4989: .I recomp
        !          4990: compiles a regular expression in
        !          4991: .B pattern
        !          4992: and returns a pointer to a compiled regular expression.
        !          4993: The space is allocated by
        !          4994: .IR malloc (3)
        !          4995: and may be released by
        !          4996: .IR refree .
        !          4997: Regular expressions are as in
        !          4998: .I egrep
        !          4999: (see
        !          5000: .IR grep (1))
        !          5001: except that newlines are treated as ordinary
        !          5002: characters and
        !          5003: .B $
        !          5004: matches the end of a null-terminated string.
        !          5005: .B flags
        !          5006: may be
        !          5007: .B RE_EDSTYLE
        !          5008: which specifies
        !          5009: .IR ed (1)
        !          5010: style special characters,
        !          5011: .BR \e( ,
        !          5012: .BR \e) ,
        !          5013: .BR \e? ,
        !          5014: .B \e+
        !          5015: and
        !          5016: .B \e|
        !          5017: for the
        !          5018: .IR egrep (1)
        !          5019: .BR ( ,
        !          5020: .BR ) ,
        !          5021: .BR ? ,
        !          5022: .B +
        !          5023: and
        !          5024: .BR | ,
        !          5025: respectively.
        !          5026: .PP
        !          5027: .I reexec
        !          5028: matches the null-terminated
        !          5029: .B source
        !          5030: string against the compiled regular expression
        !          5031: .I re
        !          5032: from a previous call to
        !          5033: .IR recomp .
        !          5034: If it matches,
        !          5035: .I reexec
        !          5036: returns a non-zero value.
        !          5037: If
        !          5038: .B flags
        !          5039: is
        !          5040: .B RE_MATCH
        !          5041: then the array
        !          5042: .B re\->match
        !          5043: is filled with character pointers to the substrings of
        !          5044: .B source
        !          5045: that correspond to the
        !          5046: parenthesized subexpressions of 
        !          5047: .BR pattern :
        !          5048: .B re\->match[i].sp
        !          5049: points to the beginning and
        !          5050: .B re\->match[i].ep
        !          5051: points just beyond
        !          5052: the end of substring
        !          5053: .BR i .
        !          5054: (Subexpression
        !          5055: .B i
        !          5056: begins at the
        !          5057: .BR i th
        !          5058: matched left parenthesis, counting from 1.)
        !          5059: Pointers in
        !          5060: .B re\->match[0]
        !          5061: pick out the substring that corresponds to
        !          5062: the entire regular expression.
        !          5063: Unused elements of
        !          5064: .B re\->match
        !          5065: are filled with zeros.
        !          5066: Matches involving
        !          5067: .BR * ,
        !          5068: .BR + ,
        !          5069: and 
        !          5070: .B ?
        !          5071: are extended as far as possible.
        !          5072: A maximum of 9 subexpressions will be matched.
        !          5073: The structure of elements of
        !          5074: .B re\->match 
        !          5075: is:
        !          5076: .nf
        !          5077: .ta 8n
        !          5078:        typedef struct
        !          5079:        {
        !          5080:                char* sp;
        !          5081:                char* ep;
        !          5082:        } rematch;
        !          5083: .fi
        !          5084: .LP
        !          5085: .I resub
        !          5086: places in
        !          5087: .I destination
        !          5088: a substitution instance of
        !          5089: .B old
        !          5090: to
        !          5091: .B new
        !          5092: in
        !          5093: .B source
        !          5094: in the context of the last
        !          5095: .I reexec
        !          5096: performed on
        !          5097: .IR re\->match .
        !          5098: Each instance of
        !          5099: .BI \e n ,
        !          5100: where
        !          5101: .I n
        !          5102: is a digit, is replaced by the
        !          5103: string delimited by
        !          5104: .BI re\->match[ n ].sp
        !          5105: and
        !          5106: .BI re\->match[ n ].ep .
        !          5107: Each instance of 
        !          5108: .B &
        !          5109: is replaced by the string delimited by
        !          5110: .B re\->match[0].sp
        !          5111: and
        !          5112: .BR re\->match[0].ep .
        !          5113: If
        !          5114: .B RE_ALL
        !          5115: is set in
        !          5116: .B flags
        !          5117: then all occurrences of
        !          5118: .B old
        !          5119: are replaced by
        !          5120: .IR new .
        !          5121: If
        !          5122: .B RE_LOWER
        !          5123: .RB [ RE_UPPER ]
        !          5124: is set in
        !          5125: .B flags
        !          5126: then
        !          5127: .B old
        !          5128: is converted to lower [upper] case.
        !          5129: .LP
        !          5130: .I reerror,
        !          5131: called whenever an error is detected in
        !          5132: .I recomp,
        !          5133: .I reexec,
        !          5134: or
        !          5135: .I resub,
        !          5136: writes the string
        !          5137: .B msg
        !          5138: on the standard error file and exits.
        !          5139: .I reerror
        !          5140: may be replaced to perform
        !          5141: special error processing.
        !          5142: .SH DIAGNOSTICS
        !          5143: .I recomp
        !          5144: returns 0 for an invalid expression or other failure.
        !          5145: .I reexec
        !          5146: returns 1 if
        !          5147: .B source
        !          5148: is accepted, 0 otherwise.
        !          5149: .SH "SEE ALSO"
        !          5150: ed(1), grep(1), expr(1)
        !          5151: 0707070000000001121006440044230044230000010000000475416250000002600000073727man/sfio.3UgsfGgsf.TH SFIO 3 "21 August 1990"
        !          5152: .SH NAME
        !          5153: \fBsfio\fR \- safe/fast string/file input/output
        !          5154: .SH SYNOPSIS
        !          5155: .ta .75i 1.5i 2.25i 3i 3.75i 4.5i 5.25i 6i
        !          5156: .PP
        !          5157: .nf
        !          5158: .ft 5
        !          5159: #include       <sfio.h>
        !          5160: 
        !          5161: #define uchar  unsigned char
        !          5162: #define uint   unsigned int
        !          5163: #define ulong  unsigned long
        !          5164: 
        !          5165: Sfile_t*       sfnew(Sfile_t* f, uchar* buf, int size, int fd, int flags);
        !          5166: Sfile_t*       sfopen(Sfile_t* f, char* string, char* mode);
        !          5167: Sfile_t*       sfdopen(int fd, char* mode);
        !          5168: Sfile_t*       sfpopen(char* cmd, char* mode, Sfile_t** fcomp);
        !          5169: Sfile_t*       sfstack(Sfile_t* base, Sfile_t* top);
        !          5170: Sfile_t*       sfpushed(Sfile_t* f);
        !          5171: Sfile_t*       sftmp(int size);
        !          5172: 
        !          5173: int    sfpool(Sfile_t* f, Sfile_t* poolf, int mode);
        !          5174: Sfdisc_t*      sfsetdisc(Sfile_t* f, Sfdisc_t* disc);
        !          5175: 
        !          5176: int    sfclose(Sfile_t* f);
        !          5177: int    sfsync(Sfile_t* f);
        !          5178: 
        !          5179: int    sfpeek(Sfile_t* f, uchar** bufp);
        !          5180: 
        !          5181: int    sfgetc(Sfile_t* f);
        !          5182: int    sfungetc(Sfile_t* f, int c);
        !          5183: ulong  sfgetu(Sfile_t* f);
        !          5184: long   sfgetl(Sfile_t* f);
        !          5185: double sfgetd(Sfile_t* f);
        !          5186: char*  sfgets(Sfile_t* f, char* buf, int size);
        !          5187: int    sfread(Sfile_t* f, uchar* buf, int n);
        !          5188: int    sfscanf(Sfile_t* f, char* format, ...);
        !          5189: int    sfsscanf(char* s, char* format, ...);
        !          5190: int    sfvscanf(Sfile_t* f, char* format, va_list args);
        !          5191: 
        !          5192: int    sfputc(Sfile_t* f, int c);
        !          5193: int    sfnputc(Sfile_t* f, int c, int n);
        !          5194: int    sfputu(Sfile_t* f, ulong v);
        !          5195: int    sfputl(Sfile_t* f, long v);
        !          5196: int    sfputd(Sfile_t* f, double v);
        !          5197: int    sfputs(Sfile_t* f, char* s, int c);
        !          5198: int    sfwrite(Sfile_t* f, uchar* buf, int n);
        !          5199: int    sfmove(Sfile_t* fr, Sfile_t* fw, long n, char* seps);
        !          5200: int    sfprintf(Sfile_t* f, char* format, ...);
        !          5201: int    sfsprintf(char* s, int size, char* format, ...);
        !          5202: int    sfvprintf(Sfile_t* f, char* format, va_list args);
        !          5203: 
        !          5204: void   sfnotice(void (*noticef)(Sfile_t* f, int type));
        !          5205: int    sfset(Sfile_t* f, int flags, int i);
        !          5206: uchar* sfsetbuf(Sfile_t* f, uchar* buf, int size);
        !          5207: int    sffileno(Sfile_t* f);
        !          5208: int    sfeof(Sfile_t* f);
        !          5209: int    sferror(Sfile_t* f);
        !          5210: int    sfclearerr(Sfile_t* f);
        !          5211: int    sfclrlock(Sfile_t* f);
        !          5212: int    sfslen();
        !          5213: int    sfulen(ulong v);
        !          5214: int    sfllen(long v);
        !          5215: int    sfdlen(double v);
        !          5216: 
        !          5217: long   sforigin(Sfile_t* f);
        !          5218: long   sfseek(Sfile_t* f, long addr, int offset);
        !          5219: long   sftell(Sfile_t* f);
        !          5220: 
        !          5221: char*  sfecvt(double v, int n, int* decpt, int* sign);
        !          5222: char*  sffcvt(double v, int n, int* decpt, int* sign);
        !          5223: .fR
        !          5224: .fi
        !          5225: .SH DESCRIPTION
        !          5226: .PP
        !          5227: \fIsfio\fP is a library of functions to perform input/output on
        !          5228: objects called \fIsfio\fP streams.
        !          5229: Each \fIsfio\fP stream may correpond to some file descriptor (see \fIopen(2)\fP)
        !          5230: or some piece of primary memory.
        !          5231: A notion of stream stack is supported for
        !          5232: processing of data from complexes of streams.
        !          5233: Streams can be pooled so that their buffers can be synchronized
        !          5234: properly when switching streams for io.
        !          5235: It is also possible to change io disciplines by setting alternative
        !          5236: functions for read, write and seek.
        !          5237: .PP
        !          5238: A stream abstraction is represented by the type \f5Sfile_t\fP which
        !          5239: is defined in the header file \f5<sfio.h>\fP. A stream is locked while
        !          5240: it is being accessed by some \fIsfio\fP function. A locked stream
        !          5241: cannot be further accessed by operations that may change its internal states
        !          5242: (see \f5sfclrlock()\fP). Any such access fails and returns
        !          5243: an appropriate error code.
        !          5244: .PP
        !          5245: During an io request, if
        !          5246: a system call \f5read\fP or \f5write()\fP (or their
        !          5247: discipline counterparts) is interrupted,
        !          5248: unless a discipline function has been defined to process it,
        !          5249: the calling \fIsfio\fP function will resume the respective system call as necessary.
        !          5250: The interrupt condition is defined by \f5errno\ ==\ EINTR\fP (see \f5errno.h\fP).
        !          5251: To prevent infinite loops, this condition is always cleared before
        !          5252: the system call is resumed.
        !          5253: .PP
        !          5254: In general, \fIsfio\fP functions either return integer or pointer values.
        !          5255: In the event of an error, a function that returns integer value will
        !          5256: return \f5-1\fP while a function that returns a pointer value will return
        !          5257: \f5NULL\fP.
        !          5258: .PP
        !          5259: A number of bit flags define stream types and their operations.
        !          5260: Following are the flags:
        !          5261: .IP
        !          5262: \f5SF_READ\fP:
        !          5263: The stream is readable.
        !          5264: .IP
        !          5265: \f5SF_WRITE\fP:
        !          5266: The stream is writable.
        !          5267: .IP
        !          5268: \f5SF_STRING\fP:
        !          5269: The stream is a string (a byte array) that
        !          5270: is readable if \f5SF_READ\fP is specified or
        !          5271: writable if \f5SF_WRITE\fP is specified.
        !          5272: .IP
        !          5273: \f5SF_APPEND\fP:
        !          5274: The stream is a file opened for appending data.
        !          5275: This means that data written to the stream is always
        !          5276: appended at the end of the file.
        !          5277: On operating systems where there is no primitive to specify
        !          5278: at file opening time that a file is opened for append only,
        !          5279: \f5lseek()\fP (or its discipline replacement) will be used on
        !          5280: the file stream to approximate this behavior.
        !          5281: .IP
        !          5282: \f5SF_RELATIVE\fP:
        !          5283: If the stream corresponds to a file,
        !          5284: no seek is allowed backward beyond the starting point as defined
        !          5285: by \f5lseek(fd,0L,1)\fP (or its discipline replacement)
        !          5286: when the stream is initialized by \f5sfnew()\fP (below).
        !          5287: .IP
        !          5288: \f5SF_LINE\fP:
        !          5289: The stream is line-oriented. For write-streams, this means that the
        !          5290: buffer is flushed whenever a new-line character is output.
        !          5291: For read-streams, this means that \f5sfpeek()\fP (below) will return
        !          5292: a buffer of data which ends with a new-line. Note that the amount of
        !          5293: data that can be returned is limited by the buffer size.
        !          5294: .IP
        !          5295: \f5SF_KEEPFD\fP:
        !          5296: The file descriptor of the stream will be kept opened when the stream is closed.
        !          5297: .IP
        !          5298: \f5SF_MALLOC\fP:
        !          5299: To indicate that the stream buffer was obtained via \f5malloc()\fP
        !          5300: and can be reallocated or freed by the package.
        !          5301: .IP
        !          5302: \f5SF_REUSE\fP:
        !          5303: This flag can be set (\f5sfset()\fP so that when the stream is closed,
        !          5304: its data structure and associated information such as pool and discipline
        !          5305: is not destroyed.
        !          5306: It can also be used in a call to \f5sfnew()\fP (see below).
        !          5307: .IP
        !          5308: \f5SF_SHARE\fP:
        !          5309: This flag indicates that the associated stream is a file stream that may
        !          5310: be operated on by means beyond straightforward \fIsfio\fP usage (e.g.,
        !          5311: by multiple processes).
        !          5312: In this case, each io system call (or its discipline replacement) will be
        !          5313: preceded by a \f5lseek()\fP (or its discipline replacement) to ensure that
        !          5314: the logical stream location corresponds to the physical file location.
        !          5315: .PP
        !          5316: \f5sfnew(f,buf,size,fd,flags)\fP
        !          5317: is the primitive for creating or renewing streams.
        !          5318: For file streams, a number of operations are performed to determine
        !          5319: seekability, optimal buffer sizes if not specified, etc.
        !          5320: Each stream has a origin.
        !          5321: The origin of a \f5SF_STRING\fP stream is always \f50L\fP.
        !          5322: If a file stream is not seekable, its origin is defined as \f5-1L\fP.
        !          5323: Otherwise, its origin is defined as either the current location or \f50L\fP
        !          5324: depending on whether or not the flag \f5SF_RELATIVE\fP is turned on.
        !          5325: \f5sfseek()\fP operations are relative to this location.
        !          5326: The argument \f5f\fP of \f5sfnew()\fP, if not \f5NULL\fP, is a stream to be modified.
        !          5327: If it is \f5NULL\fP, a new stream is created.
        !          5328: The argument \f5buf\fP, if not \f5NULL\fP, is a buffer to be used.
        !          5329: In this case, \f5size\fP should be positive.
        !          5330: If \f5size\fP is 0, the stream is unbuffered.
        !          5331: If \f5size\fP is negative, \fIsfio\fP will allocate a buffer.
        !          5332: The argument \f5fd\fP is a file descriptor (e.g., from \fIopen()\fP)
        !          5333: for io operations if the stream is not an \f5SF_STRING\fP stream.
        !          5334: The last argument \f5flags\fP is a bit vector composing from the flags described above.
        !          5335: The \f5SF_REUSE\fP flag, if given, indicates that the current attributes
        !          5336: of the stream \f5f\fP should be used instead of whatever else is defined by \f5flags\fP.
        !          5337: .PP
        !          5338: \f5sfopen(f,string,mode)\fP
        !          5339: is a high-level function based on \f5sfnew()\fP to create new streams from files
        !          5340: or strings.
        !          5341: The argument \f5f\fP for \f5sfopen()\fP,
        !          5342: if not \f5NULL\fP, is a currently opened stream to be
        !          5343: closed and replaced by a new stream corresponding to the object \f5string\fP.
        !          5344: The argument \f5mode\fP can be any one of: \f5"r"\fP, \f5"r+"\fP,
        !          5345: \f5"w"\fP, \f5"w+"\fP, \f5"a"\fP, \f5"a+"\fP, \f5s\fP and \f5s+\fP.
        !          5346: The \f5r\fP, \f5w\fP, and \f5a\fP specify read, write and append mode for file streams.
        !          5347: In these cases, the argument \f5string\fP defines a path name to a file.
        !          5348: The \f5s\fP specifies that \f5string\fP is a nul-terminated string to be opened for read.
        !          5349: The \f5+\fP means that the new stream will be opened for both reading and writing.
        !          5350: .PP
        !          5351: \f5sfdopen(fd,mode)\fP makes a stream using the file descriptor \f5fd\fP.
        !          5352: The \f5mode\fP argument is used in the same way as in \f5sfopen()\fP.
        !          5353: .PP
        !          5354: \f5sfpopen(cmd,mode,fcomp)\fP
        !          5355: opens a stream \f5f\fP which is a pipe to (from) the command \f5cmd\fP
        !          5356: if the mode is \f5"w"\fP (\f5"r"\fP). If the mode is \f5"w+"\fP or \f5"r+"\fP,
        !          5357: another stream for the opposite operation is created and returned in \f5fcomp\fP.
        !          5358: Note that if either of these streams is closed, the other is also closed.
        !          5359: .PP
        !          5360: \f5sfstack(base,top)\fP is used to push or pop stream stacks.
        !          5361: Each stream stack is identified by a \f5base\fP stream
        !          5362: via which all io operations are performed.
        !          5363: Other streams on the stack are locked so that operations that may change
        !          5364: their internal states are forbidden.
        !          5365: The type of operations that can be done on a stack is defined by
        !          5366: the top level stream. If an io operation is performed and the top level stream
        !          5367: reaches the end of file condition or an error condition other than interrupts,
        !          5368: it is automatically popped and closed (see also \f5sfsetdisc\fP for alternative
        !          5369: handling of these conditions).
        !          5370: The first argument of \f5sfstack()\fP specifies the \f5base\fP stream.
        !          5371: The second argument, \f5top\fP, if not \f5NULL\fP,
        !          5372: is pushed on top of the current top stream.
        !          5373: In this case, the \f5base\fP stream pointer is returned.
        !          5374: If \f5top\fP is \f5NULL\fP, the stack is popped  and the pointer to
        !          5375: the popped stream is returned.
        !          5376: .PP
        !          5377: \f5sfpushed(f)\fP returns the pointer to the stream pushed below \f5f\fP.
        !          5378: .PP
        !          5379: \f5sftmp(size)\fP creates a stream for writing and reading temporary data.
        !          5380: If \f5size\fP is negative, the stream is a pure \f5SF_STRING\fP stream.
        !          5381: Otherwise, the stream is originally created as a \f5SF_STRING\fP stream
        !          5382: with a buffer of the given \f5size\fP. A discipline is set so that
        !          5383: when this buffer is exhausted, a real temporary file will be created.
        !          5384: Any attempt to change this discipline will also cause the temporary file
        !          5385: to be created.
        !          5386: .PP
        !          5387: \f5sfpool(f,poolf,mode)\fP manages pools of streams.
        !          5388: In a pool of streams, only one stream is current.
        !          5389: A stream becomes current when it is used for some io operation.
        !          5390: When a new stream is to become current,
        !          5391: the current stream is synchronized (see \f5sfsync()\fP)
        !          5392: if its type matches the type of the pool.
        !          5393: The first argument of \f5sfpool()\fP, \f5f\fP, is the stream to be manipulated.
        !          5394: The second argument, \f5poolf\fP, determines the operation to be done on \f5f\fP.
        !          5395: If \f5poolf\fP is \f5NULL\fP, \f5f\fP is deleted from its current pool.
        !          5396: Otherwise, \f5f\fP is put into the same pool with \f5poolf\fP.
        !          5397: If \f5poolf\fP is already in a pool, the third argument is ignored.
        !          5398: Otherwise, it determines the type of the new pool.
        !          5399: \f5mode\fP can be constructed by bitwise or-ing of \f5SF_READ\fP and \f5SF_WRITE\fP.
        !          5400: .PP
        !          5401: \f5sfsetdisc(f,disc)\fP changes
        !          5402: the io-discipline of the stream \f5f\fP, i.e.,
        !          5403: to specify alternative functions for read, write, seek, and to handle exceptions.
        !          5404: The default discipline consists of the system calls \f5read()\fP, \f5write()\fP,
        !          5405: and \f5lseek()\fP.
        !          5406: The \f5disc\fP argument is either \f5NULL\fP to reset to the default discipline
        !          5407: or a pointer to a \f5Sfdisc_t\fP structure which contains the following fields:
        !          5408: .PP
        !          5409: .nf
        !          5410:        \f5int  (*readf)();\fP
        !          5411:        \f5int  (*writef)();\fP
        !          5412:        \f5long (*seekf)();\fP
        !          5413:        \f5int  (*exceptf)();\fP
        !          5414:        \f5void*        handle;\fP
        !          5415: .fi
        !          5416: .PP
        !          5417: The first three fields of \f5Sfdisc_t\fP specify alternative io functions.
        !          5418: If any of them is \f5NULL\fP, the corresponding system call is used.
        !          5419: A discipline io function, say \f5(*readf)()\fP,
        !          5420: is called with 4 arguments.
        !          5421: The first argument is the stream pointer.
        !          5422: The second and third arguments correspond to the second and third arguments
        !          5423: of the respected system call.
        !          5424: The fourth argument is the \f5handle\fP field of \f5Sfdisc_t\fP.
        !          5425: The exception function, \f5(*exceptf)()\fP, if provided, is called
        !          5426: when an exception happens during a read/write operation, when a stream
        !          5427: is being closed, or when the discipline is being reset.
        !          5428: A read/write operation is said to cause an exception if its return value
        !          5429: is zero or negative. It is up to the exception function to determine
        !          5430: the type of exception (for example, by examining \f5errno\fP).
        !          5431: When \f5(*exceptf)()\fP is called, the stream will be opened for general operations.
        !          5432: However, \f5(*exceptf)()\fP should not attempt to close the stream.
        !          5433: \f5(*exceptf)()\fP is called as:
        !          5434: \f5(*exceptf)(f,type,handle)\fP. \f5type\fP is:
        !          5435: \f50\fP when the discipline is being reset,
        !          5436: \f5SF_EOF\fP when the stream is being closed,
        !          5437: \f5SF_READ\fP when an exception happens during a read operation, and
        !          5438: \f5SF_WRITE\fP when an exception happens during a write operation.
        !          5439: For the cases of \f5SF_READ\fP and \f5SF_WRITE\fP,
        !          5440: the executing \fIsfio\fP function will examine the return value of \f5(*exceptf)()\fP
        !          5441: for further actions:
        !          5442: \fInegative\fP for immediate return,
        !          5443: \fIzero\fP for executing default actions associated with the exception,
        !          5444: and \fIpositive\fP for resuming execution.
        !          5445: Note that a \f5SF_STRING\fP stream does not perform external io so the
        !          5446: io functions are not used. However, an exception occurs whenever
        !          5447: an io operation exceeds the stream buffer boundary and
        !          5448: \f5(*exceptf)()\fP, if defined, will be called as appropriate.
        !          5449: \f5sfsetdisc()\fP returns the pointer to the previous discipline
        !          5450: or \f5NULL\fP if an error happened.
        !          5451: Finally, it is the application's responsibility to manage the space used
        !          5452: by the \f5Sfdisc_t\fP structures.
        !          5453: .PP
        !          5454: \f5sfclose(f)\fP closes the given stream \f5f\fP and frees up its resources.
        !          5455: If \f5f\fP is \f5NULL\fP, all streams are closed.
        !          5456: If \f5f\fP is a stack of streams, all streams on the stack are closed.
        !          5457: If \f5f\fP is a \f5sfpopen\fP-stream, its companion stream, if any, is also closed.
        !          5458: Further, \f5sfclose()\fP will wait until the associated command terminates,
        !          5459: then return its exit status.
        !          5460: A few file flags affect the behavior of \f5sfclose()\fP.
        !          5461: If \f5SF_KEEPFD\fP is on, the underlying file descriptor is not closed.
        !          5462: If \f5SF_REUSE\fP is on, \f5sfclose()\fP will only synchronize the buffer
        !          5463: and close the file descriptor (subject to \f5SF_KEEPFD\fP).
        !          5464: The stream structure is left intact, including
        !          5465: pool (\f5sfpool()\fP) or discipline (\f5sfsetdisc()\fP) information.
        !          5466: .PP
        !          5467: \f5sfsync(f)\fP causes the physical file pointer of the stream
        !          5468: \f5f\fP to correspond to its logical position.
        !          5469: If \f5f\fP is the base of a stack of streams, all streams on the stack
        !          5470: are synchronized. Further, a stacked stream can only be synchronized
        !          5471: via its base stream.
        !          5472: .PP
        !          5473: \f5sfpeek(f,bufp)\fP provides a safe method for enquiring
        !          5474: information on the internal buffer of a stream.
        !          5475: If \f5bufp\fP is \f5NULL\fP, \f5sfpeek()\fP simply returns the amount of data
        !          5476: available in the buffer to read if \f5f\fP is in read mode
        !          5477: or the amount of buffer available to write if \f5f\fP is in write mode.
        !          5478: If \f5bufp\fP is not \f5NULL\fP, \f5sfpeek()\fP provides access to the buffer.
        !          5479: For a read stream, if the buffer is empty, it is filled and,
        !          5480: for a write-stream, if the buffer is full, it is flushed.
        !          5481: Then, for a read stream, \f5bufp\fP is set to the place in the buffer
        !          5482: where data is available and, for a write stream,
        !          5483: it is set to where data can be written.
        !          5484: The return value of \f5sfseek()\fP indicates how much data or space is available
        !          5485: in the buffer. However, if the stream is in \f5SF_LINE|SF_READ\fP mode,
        !          5486: the return value will be the data length up to and including the new-line character.
        !          5487: In this case, if there is not a new-line character in the buffered data,
        !          5488: more data may be read.
        !          5489: Note that the buffer location is not advanced by \f5sfpeek()\fP.
        !          5490: That must be done by a regular io call such as \f5sfread\fP or \f5sfwrite\fP on
        !          5491: the pointer returned in \f5bufp\fP.
        !          5492: Finally, \f5sfpeek()\fP treats a read/write-stream like a read-stream
        !          5493: (however, see also \f5sfset()\fP).
        !          5494: .PP
        !          5495: \f5sfgetc(f)\fP returns a byte from the stream \f5f\fP or -1 when an end-of-file
        !          5496: or error condition is encountered.
        !          5497: .PP
        !          5498: \f5sfungetc(f,c)\fP puts the byte \f5c\fP back into the stream \f5f\fP.
        !          5499: This is guaranteed to work only after a \f5sfgetc()\fP call.
        !          5500: .PP
        !          5501: \f5sfgetu(f)\fP, \f5sfgetl(f)\fP, and \f5sfgetd(f)\fP return
        !          5502: an \fIunsigned long\fP, a \fIlong\fP value, or a \fIdouble\fP value
        !          5503: that was coded in a portable fashion
        !          5504: (see \f5sfputu()\fP, \f5sfputl()\fP, and \f5sfputd()\fP).
        !          5505: If there is not enough data to decode a value,
        !          5506: these functions will return \f5-1\fP and the stream is set in an error state
        !          5507: (\f5see \f5sferror()\fP).
        !          5508: .PP
        !          5509: \f5sfgets(f,buf,size)\fP reads a line of input from the stream \f5f\fP.
        !          5510: If \f5buf\fP is not \f5NULL\fP and \f5size\fP is positive, \f5sfgets\fP
        !          5511: reads up to \f5size-1\fP characters into the buffer \f5buf\fP.
        !          5512: Otherwise, the characters are read into a static area that is dynamically
        !          5513: grown as necessary. Thus, in this case, there is no limit to line length.
        !          5514: A nul-character is appended after the input characters.
        !          5515: \f5sfgets()\fP returns the pointer to the new string or \f5NULL\fP when
        !          5516: no data was read due to end-of-file or an error condition.
        !          5517: After a string is read, its length can be found using \f5sfslen()\fP.
        !          5518: .PP
        !          5519: \f5sfread(f,buf,n)\fP reads up to \f5n\fP bytes from the stream \f5f\fP and
        !          5520: stores them in the given buffer \f5buf\fP.
        !          5521: It returns the number of bytes actually read.
        !          5522: .PP
        !          5523: \f5sfscanf(f,format,...)\fP scans a number of items from the stream \f5f\fP.
        !          5524: The item types are determined from the string \f5format\fP.
        !          5525: See \fIfscanf()\fP (UNIX User's Manual, Section 3) for details on predefined formats.
        !          5526: The standardly supported formats are:
        !          5527: \f5i, I, d, D, u, U, o, O, x, X, f, F, e, E, g, G, c, %, s,\fP and \f5[]\fP.
        !          5528: The \f5sfscanf()\fP interface also supports additional formats as described below.
        !          5529: .IP
        !          5530: The pattern \f5%&\fP indicates that the next argument in the argument list of
        !          5531: \f5sfscanf()\fP is a function, say \f5(*extf)()\fP, to process patterns that are not
        !          5532: predefined by the \f5sfscanf()\fP interface.
        !          5533: The prototype of \f5(*extf)()\fP is:
        !          5534: .nf
        !          5535:        \f5int (*extf)(Sfile_t* f, int fmt, int length, char** rv);\fP
        !          5536: .fi
        !          5537: \f5f\fP is the same input stream passed to \f5sfvscanf\fP.
        !          5538: \f5fmt\fP is the pattern to be processed.
        !          5539: \f5length\fP, if non-negative, is the maximum number of input bytes
        !          5540: to be read in processing the pattern,
        !          5541: \f5rv\fP is used to return the ``address'' of the value to be assigned.
        !          5542: \f5(*extf)()\fP returns the size of the value to be assigned.
        !          5543: A negative return value from \f5(*extf)()\fP means that the specified pattern
        !          5544: cannot be handled. This pattern is treated as if it is not matched.
        !          5545: .IP
        !          5546: The pattern \f5%@\fP indicates that the next argument in the argument list \f5args\fP
        !          5547: is a function, say \f5(*argf)()\fP, to process the values of matched patterns.
        !          5548: The prototype of \f5(*argf)()\fP is:
        !          5549: .nf
        !          5550:        \f5int (*argf)(int fmt, char* value, int n)\fP;
        !          5551: .fi
        !          5552: If the return value of \f5(*argf)()\fP is negative, the processing
        !          5553: of the current format string will be stopped (see \f5%$\fP below).
        !          5554: \f5fmt\fP determines the type of \f5value\fP: \f5f\fP for \fIfloat\fP,
        !          5555: \f5F\fP for \fIdouble\fP, \f5h\fP for \fIshort\fP, \f5d\fP for \fIint\fP,
        !          5556: \f5D\fP for \fIlong\fP, \f5s\fP for \fIchar*\fP. Any other value for \f5fmt\fP
        !          5557: means that it is an extended pattern and \f5value\fP contains an address
        !          5558: to the scanned value. \f5n\fP contains the size of the object if it is a
        !          5559: primitive type. If the object is \f5char*\fP or the address of the scanned
        !          5560: value of an extended format, \f5n\fP is the length of this object.
        !          5561: .IP
        !          5562: The pattern \f5%:\fP indicates that the next two arguments in the argument list
        !          5563: \f5args\fP define a new pair of format string and a list of arguments of
        !          5564: the type \f5va_list\fP (see \f5varargs.h\fP or \f5stdarg.h\fP).
        !          5565: The new pair is pushed on top of the stack and the scanning process continues with them.
        !          5566: The top pair of format string and argument list is popped when the processing
        !          5567: of the format string is stopped. When a new pair is stacked,
        !          5568: \f5(*argf)()\fP and \f5(*extf)()\fP are inherited.
        !          5569: They are reset when the stack is popped.
        !          5570: .PP
        !          5571: \f5sfsscanf(s,format,...)\fP is similar to \f5sfscanf()\fP
        !          5572: but it scans data from the string \f5s\fP.
        !          5573: .PP
        !          5574: \f5sfvscanf(f,format,args)\fP is the primitive underlying \f5sfscanf()\fP
        !          5575: and \f5sfscanf()\fP. It also provides a portable variable argument interface.
        !          5576: Programs that use \f5sfvscanf()\fP must include either of \f5varargs.h\fP
        !          5577: or \f5stdargs.h\fP as appropriate.
        !          5578: .PP
        !          5579: \f5sfputc(f,c)\fP writes the byte \f5c\fP to the stream \f5f\fP.
        !          5580: .PP
        !          5581: \f5sfnputc(f,c,n)\fP writes the byte \f5c\fP to the stream \f5f\fP \f5n\fP times.
        !          5582: It returns the number of bytes successfully written.
        !          5583: .PP
        !          5584: \f5sfputu(f,v)\fP, \f5sfputl(f,v)\fP write the \fIunsigned long\fP or \fIlong\fP
        !          5585: value \f5v\fP in a format that is byte-order transparent.
        !          5586: \f5sfputd(f,v)\fP writes the \fIdouble\fP value \f5v\fP in a portable format.
        !          5587: Portability across two different machines
        !          5588: requires that the bit order in a byte is the same on both machines.
        !          5589: \f5sfputd()\fP also relies on the functions \f5ldexp()\fP and \f5frexp()\fP
        !          5590: (See \fIfrexp.3\fP) for coding.
        !          5591: Upon success, \f5sfputu()\fP, \f5sfputl()\fP and \f5sfputd()\fP
        !          5592: return the number of bytes output.
        !          5593: .PP
        !          5594: \f5sfputs(f,s,c)\fP writes the null-terminated string \f5s\fP to the stream \f5f\fP.
        !          5595: If \f5c\fP is not 0, it is a character to be appended after the string has been output.
        !          5596: \f5sfputs()\fP returns the number of bytes written.
        !          5597: .PP
        !          5598: \f5sfwrite(f,buf,n)\fP writes out \f5n\fP bytes from the buffer \f5buf\fP to the
        !          5599: stream \f5f\fP. It returns the number of bytes written.
        !          5600: .PP
        !          5601: \f5sfmove(fr,fw,n,seps)\fP moves \f5n\fP objects
        !          5602: from the stream \f5fr\fP to the stream \f5fw\fP.
        !          5603: If either \f5fr\fP or \f5fw\fP is \f5NULL\fP, it acts
        !          5604: as if it is a stream corresponding to \fI/dev/null\fP.
        !          5605: If \f5n\fP is \f5<0\fP, all of \f5fr\fP is moved.
        !          5606: If \f5seps\fP is \f5NULL\fP or an empty string, the objects to be moved are bytes.
        !          5607: Otherwise, the moved objects are records separated by bytes defined in \f5seps\fP.
        !          5608: In \f5seps\fP, if the first two bytes is \f5\e0\fP, it is mapped to the zero byte.
        !          5609: All other cases map a byte to itself.
        !          5610: \f5sfmove()\fP returns the number of objects moved.
        !          5611: .PP
        !          5612: \f5sfprintf(f,format,...)\fP writes out data in
        !          5613: a format as defined by the string \f5format\fP.
        !          5614: See \fIfprintf()\fP (UNIX User's Manual, Section 3) for details on predefined
        !          5615: conversion formats.
        !          5616: The standardly supported formats are:
        !          5617: \f5n, s, c, %, h, i, d, p, u, o, x, X, g, G, e, E, f,\fP and \f5F\fP.
        !          5618: \f5sfprintf()\fP also supports additional formats as described below.
        !          5619: .IP
        !          5620: The pattern \f5%&\fP indicates that the next argument
        !          5621: is a function, say \f5(*extf)()\fP, to interpret patterns not yet defined
        !          5622: by \f5sfprintf()\fP.
        !          5623: The prototype of \f5(*extf)()\fP is:
        !          5624: .nf
        !          5625:        \f5int (*extf)(void* value, int fmt, int precis, char** sp);\fP
        !          5626: .fi
        !          5627: \f5value\fP is the value to be formatted.
        !          5628: \f5fmt\fP is the pattern to format the value.
        !          5629: \f5precis\fP is the amount of precision required.
        !          5630: \f5sp\fP is used to return the address of a string containing the formatted value.
        !          5631: If upon returning from \f5(*extf)()\fP, \f5*sp\fP is \f5NULL\fP, the pattern \f5fmt\fP
        !          5632: is treated as if it is not matched.
        !          5633: Otherwise, the return value of \f5(*extf)()\fP, if nonnegative, is taken as the length
        !          5634: of the string returned in \f5sp\fP. If not, the string is considered null-terminated.
        !          5635: The string \f5*sp\fP is processed as if the pattern \f5`s'\fP was specified.
        !          5636: .IP
        !          5637: The pattern \f5%@\fP indicates that the next argument is a function, say \f5(*argf)()\fP,
        !          5638: to get arguments. As long as \f5(*argf)()\fP is defined, the argument list is ignored.
        !          5639: The prototype of \f5(*argf)()\fP is:
        !          5640: .nf
        !          5641:        \f5int (*argf)(int fmt, char* val)\fP;
        !          5642: .fi
        !          5643: \f5fmt\fP is the pattern to be processed.
        !          5644: Following are ASCII characters and corresponding types:
        !          5645: \f5@\fP for getting a new \f5(*argf)()\fP,
        !          5646: \f5&\fP for getting a new \f5(*extf)()\fP,
        !          5647: \f51\fP for getting a new format string for stacking,
        !          5648: \f52\fP for getting a new argument list for stacking,
        !          5649: \f5d\fP for \fIint\fP,
        !          5650: \f5D\fP for \fIlong\fP,
        !          5651: \f5f\fP for \fIfloat\fP,
        !          5652: \f5F\fP for \f5double\fP, and
        !          5653: \f5s\fP for \fIchar*\fP.
        !          5654: If \f5(*extf)()\fP is defined, and an undefined pattern is encountered,
        !          5655: \f5(*argf)()\fP will be called with this pattern.
        !          5656: \f5val\fP is an address to store the value to be formatted.
        !          5657: The return value of \f5(*argf)()\fP, if negative, stops the processing
        !          5658: of the current format (see below).
        !          5659: .IP
        !          5660: The pattern \f5%:\fP indicates that the next two arguments define
        !          5661: a pair of format string and argument list of the type \f5va_list\fP.
        !          5662: If the argument getting function \f5(*argf)()\fP is already defined,
        !          5663: it is called with the argument \f5fmt\fP being the characters
        !          5664: \f51\fP and \fP2\fP for the new format string and argument list respectively.
        !          5665: The new pair is stacked on top and processing continue from there.
        !          5666: The top pair of format string and argument is popped when the format string
        !          5667: is exhausted. When a new pair is pushed, \f5(*argf)()\fP and \f5(*extf)()\fP
        !          5668: are inherited. When a pair is popped, these functions will be reset.
        !          5669: .PP
        !          5670: \f5sfsprintf(s,size,format,...)\fP is similar to \f5sfprintf()\fP
        !          5671: but it is used to format
        !          5672: the character array \f5s\fP which is of size \f5size\fP.
        !          5673: The length of the resulting string can be gotten via \f5sfslen()\fP.
        !          5674: .PP
        !          5675: \f5sfvprintf(f,format,args)\fP is the primitive underlying \f5sfprintf()\fP
        !          5676: and \f5sfsprintf()\fP. It provides a portable variable argument interface.
        !          5677: Programs that use \f5sfvprintf()\fP must include either of \f5varargs.h\fP
        !          5678: or \f5stdargs.h\fP as appropriate.
        !          5679: .PP
        !          5680: \f5sfnotice(noticef)\fP sets a function \f5(*noticef)()\fP which will
        !          5681: be called whenever a stream is created or closed.
        !          5682: \f5(*noticef)()\fP is called with two arguments.
        !          5683: The first argument is the stream pointer and
        !          5684: the second argument is either \f50\fP or \f5SF_EOF\fP to indicate
        !          5685: whether the stream is being opened or being closed.
        !          5686: .PP
        !          5687: \f5sfset(f,flags,i)\fP sets flags or file descriptor for the stream \f5f\fP.
        !          5688: If \f5flags\fP is the value \f5SF_EOF\fP, the file descriptor of the stream
        !          5689: is changed to the value in \f5i\fP. In this case, \f5sfset()\fP returns \f5-1\fP
        !          5690: on error or \f5i\fP on success.
        !          5691: If \f5flags\fP is not \f5SF_EOF\fP, it defines a collection of flags to be
        !          5692: turned on or off depending on whether \f5i\fP is non-zero or zero.
        !          5693: The flags that can be turned on or off are:
        !          5694: \f5SF_READ\fP, \f5SF_WRITE\fP,
        !          5695: \f5SF_LINE\fP, \f5SF_KEEPFD\fP, \f5SF_REUSE\fP, \f5SF_MALLOC\fP and \f5SF_SHARE\fP.
        !          5696: The flags \f5SF_READ\fP and \f5SF_WRITE\fP can be used in a call to \f5sfset()\fP
        !          5697: only if the stream \f5f\fP was opened for both read and write.
        !          5698: Turning off one of these flags means that the stream is to be treated as
        !          5699: if it was opened with the other flag exclusively (see \f5sfpeek()\fP).
        !          5700: In this case, \f5sfset()\fP returns the entire set of flags controlling the stream.
        !          5701: Thus, the current set of flags can be found by \f5sfset(f,0,0)\fP.
        !          5702: .PP
        !          5703: \f5sfsetbuf(f,buf,size)\fP changes the current buffer of the stream \f5f\fP to
        !          5704: the new buffer \f5buf\fP. If the stream is a \f5SF_WRITE\fP stream,
        !          5705: any data still in the current buffer is thrown away.
        !          5706: Thus, if an application desires to preserve such data, it should
        !          5707: call \f5sfsync()\fP before trying to switch buffers.
        !          5708: If \f5size\fP is positive, \f5buf\fP is taken as a buffer of the given size.
        !          5709: If \f5size\fP is zero, the stream will be unbuffered.
        !          5710: If \f5size\fP is negative, an internal buffer is allocated.
        !          5711: \f5sfsetbuf()\fP returns the address of the old buffer.
        !          5712: .PP
        !          5713: \f5sffileno(f)\fP returns the file descriptor of the stream \f5f\fP.
        !          5714: .PP
        !          5715: \f5sfeof(f)\fP tells whether there is any more data in the stream \f5f\fP.
        !          5716: .PP
        !          5717: \f5sforigin(f)\fP returns the origin location in the stream \f5f\fP (see \f5sfnew()\fP).
        !          5718: If this location is \f5-1L\fP, the stream is not seekable.
        !          5719: Note that the standard streams \f5sfstdin\fP, \f5sfstdout\fP, and \f5sfstderr\fP,
        !          5720: though statically allocated, are not initialized until an operation that may
        !          5721: affect its internal structure. Thus, the return value \f50L\fP of \f5sforigin()\fP 
        !          5722: on such an initialized stream is not reliable.
        !          5723: .PP
        !          5724: \f5sferror(f)\fP and \f5sfclearerr(f)\fP returns or clears the error condition
        !          5725: of the stream \f5f\fP. Note that the error condition of a stream does not prevent
        !          5726: further io operations to be performed on them.
        !          5727: .PP
        !          5728: \f5sfclrlock(f)\fP clears the lock on a locked stream.
        !          5729: Though this is unsafe, it is useful for emergency access
        !          5730: to a locked stream or to clear a stream left locked because
        !          5731: of non-local jumps (e.g., \f5longjmp()\fP).
        !          5732: .PP
        !          5733: \f5sfslen()\fP returns the length of the string most recently obtained
        !          5734: via a \f5sfgets()\fP, \f5sfsprintf()\fP, \f5sfecvt()\fP or \f5sffcvt()\fP call.
        !          5735: .PP
        !          5736: \f5sfulen(v)\fP, \f5sfllen(v)\fP and \f5sfdlen(v)\fP
        !          5737: return the number of bytes required to code the
        !          5738: \fIunsigned long\fP, \fIlong\fP or \fIdouble\fP value \f5v\fP.
        !          5739: .PP
        !          5740: \f5sfseek(f,addr,offset)\fP sets the next read/write location for the stream \f5f\fP
        !          5741: at a new address defined by the combination of \f5addr\fP and \f5offset\fP.
        !          5742: If \f5offset\fP is 0, \f5addr\fP is offset from the origin of the stream
        !          5743: (see \f5sfnew()\fP).
        !          5744: If \f5offset\fP is 1, \f5addr\fP is offset from the current location.
        !          5745: Note that if \f5f\fP was opened for appending (\f5SF_APPEND\fP) and the last operation
        !          5746: done on it was a write operation, the \fIcurrent location\fP is at the physical
        !          5747: end of file.
        !          5748: If \f5offset\fP is 2, \f5addr\fP is offset from the \fIphysical\fP end of the stream.
        !          5749: In all cases, \f5sfseek()\fP is not allowed to seek backward beyond the stream origin.
        !          5750: .PP
        !          5751: \f5sftell(f)\fP returns the current location in the stream \f5f\fP relative
        !          5752: to the stream origin (see \f5sfnew()\fP).
        !          5753: As with \f5sfseek()\fP, if \f5f\fP was opened for appending (\f5SF_APPEND\fP)
        !          5754: and the last operation done on it was a write operation,
        !          5755: the \fIcurrent location\fP is at the physical end of file.
        !          5756: If the stream \f5f\fP is unseekable, \f5sftell\fP returns the number of bytes
        !          5757: read from or written to \f5f\fP.
        !          5758: .PP
        !          5759: \f5sfecvt(v,n,decpt,sign)\fP and
        !          5760: \f5sffcvt(v,n,decpt,sign)\fP are functions to convert floating values to ASCII.
        !          5761: They corresponds to the standard functions \f5ecvt()\fP and \f5fcvt()\fP.
        !          5762: The length of the conversion string most recently done by
        !          5763: \f5sfecvt()\fP or \f5sffcvt()\fP can be found by \f5sfslen()\fP.
        !          5764: .PP
        !          5765: .SH HISTORY AND FUTURE CONSIDERATIONS
        !          5766: \fIsfio\fP has similar functionality, but is more general
        !          5767: than the \fIstdio\fP package.
        !          5768: It grows from our dissatisfaction with the awkwardness, fragility
        !          5769: and inefficiency in \fIstdio\fP.
        !          5770: An example of \fIstdio\fP awkwardness is that
        !          5771: even if a stream was opened for read and write,
        !          5772: the application code cannot arbitrarily mix read and write operations. 
        !          5773: An earlier attempt was made at rewriting \fIstdio\fP.
        !          5774: This failed due to problems that arise when linking with code based on \fIstdio\fP.
        !          5775: Changing the name space reduces this type of problems.
        !          5776: It also allows us to both stream-line and extend the interface as appropriate.
        !          5777: .SH AUTHORS
        !          5778: Kiem-Phong Vo (att!ulysses!kpv) and  David G. Korn (att!ulysses!dgk).
        !          5779: 0707070000000001131006440044230044230000010000000472454671200002600000014455man/stak.3UgsfGgsf.TH STAK 3
        !          5780: .SH NAME
        !          5781: \fBstak\fR \- data stack storage library
        !          5782: .SH SYNOPSIS
        !          5783: .ta .75i 1.5i 2.25i 3i 3.75i 4.5i 5.25i 6i
        !          5784: .PP
        !          5785: .nf
        !          5786: \f5
        !          5787: #include <stak.h>
        !          5788: 
        !          5789: Stak_t *stakcreate(int \fIflags\fP);
        !          5790: Stak_t *stakinstall(Stak_t *\fIstack\fP, char *(\fIoverflow\fP)(int));
        !          5791: int stakdelete(Stak_t *\fIstack\fP);
        !          5792: void staklink(Stak_t *\fIstack\fP)
        !          5793: 
        !          5794: char *stakalloc(unsigned \fIsize\fP);
        !          5795: char *stakcopy(const char *\fIstring\fP);
        !          5796: char *stakset(char *\fIaddress\fP, unsigned \fIoffset\fP);
        !          5797: 
        !          5798: char *stakseek(unsigned \fIoffset\fP);
        !          5799: int stakputc(int \fIc\fP);
        !          5800: int stakputs(const char *\fIstring\fP);
        !          5801: int staktell(void);
        !          5802: char *stakptr(unsigned \fIoffset\fP);
        !          5803: char *stakfreeze(unsigned \fIextra\fP);
        !          5804: \fR
        !          5805: .fi
        !          5806: .SH DESCRIPTION
        !          5807: .PP
        !          5808: \f5stak\fP is a package of routines designed to provide efficient
        !          5809: stack oriented dynamic storage.
        !          5810: A stack abstraction consists of an ordered list of contiguous
        !          5811: memory regions, called stack frames, that can hold objects of
        !          5812: arbitrary size.
        !          5813: A stack is represented by the type \f5Stak_t\fP
        !          5814: defined in header \f5<stak.h>\fP.
        !          5815: At any instant there is one active stack.
        !          5816: Variable size objects can be
        !          5817: added to the active stack
        !          5818: and programs can reference these objects directly with pointers.
        !          5819: In addition, the last object on the stack
        !          5820: (referred to here as the current object)
        !          5821: can be built incrementally.
        !          5822: The current object has an associated offset that determines its
        !          5823: current size.
        !          5824: While the current object is being built incrementally,
        !          5825: its location might
        !          5826: change so that it is necessary to reference the object with
        !          5827: relative offsets ranging from zero to the current offset of the object.
        !          5828: .PP
        !          5829: There is a preset initial active stack.
        !          5830: To use an additional stack, it is necessary to create it and to
        !          5831: install it as the active stack.
        !          5832: A stack is created with the \f5stakcreate\fP() function.
        !          5833: A \fIflags\fP argument of \f5STAK_SMALL\fP indicates that unused
        !          5834: space on the stack should be freed whenever this stack ceases
        !          5835: to be the active stack. 
        !          5836: If successful,
        !          5837: \f5stakcreate\fP() returns a pointer to a stack whose reference
        !          5838: count is 1.
        !          5839: Otherwise, \f5stakcreate\fP() returns a null pointer.
        !          5840: The \f5staklink\fP() function increases the reference count for the
        !          5841: given \fIstack\fP.
        !          5842: The \f5stakinstall\fP() function 
        !          5843: makes the specified \fIstack\fP the active stack and returns a pointer
        !          5844: to the previous active stack.
        !          5845: When the \fIoverflow\fP argument is not null,
        !          5846: it specifies a function that will
        !          5847: be called whenever \f5malloc\fP(3) fails while trying to grow the
        !          5848: stack.
        !          5849: The \fIoverflow\fP function will be called with the size that was passed
        !          5850: to \f5malloc\fP(3).
        !          5851: The \fIoverflow\fP function can call \f5exit\fP(3), call \f5longjmp\fP(3)
        !          5852: or return.
        !          5853: If the \f5overflow\fP function returns,
        !          5854: it must return a pointer to a memory region of the given size.
        !          5855: The default action is to write an error to standard error and to
        !          5856: call \f5exit\fP(2) with a non-zero exit value.
        !          5857: When \fIstack\fP is a null pointer,
        !          5858: the active stack is not changed
        !          5859: but the \fIoverflow\fP function for the active stack can be changed
        !          5860: and a pointer to the active stack is returned.
        !          5861: The \f5stakdelete\fP() function decrements the reference count and
        !          5862: frees the memory associated with
        !          5863: the specified stack
        !          5864: when the reference count is zero.
        !          5865: The effect of subsequent references to objects
        !          5866: on the stack are undefined.
        !          5867: .PP
        !          5868: The
        !          5869: \f5stakalloc\fP() function returns an aligned pointer to space on the
        !          5870: active stack that can be used to hold any object of the given \fIsize\fP.
        !          5871: \f5stakalloc\fP() is similar to \f5malloc\fP(3) except that individual
        !          5872: items returned by \f5stakalloc\fP() can not be freed.
        !          5873: \f5stakalloc\fP() causes the offset of the current object to be set to
        !          5874: zero.
        !          5875: .PP
        !          5876: The
        !          5877: \f5stakcopy\fP() function copies the given string onto the stack
        !          5878: and returns a pointer to the \fIstring\fP on the stack.
        !          5879: \f5stakcopy\fP() causes the offset of the current object to be set to
        !          5880: zero.
        !          5881: .PP
        !          5882: The \f5stakset\fP() function finds the frame containing the given
        !          5883: \fIaddress\fP, frees all frames that were created after the one containing
        !          5884: the given \fIaddress\fP, and sets the current object to the given
        !          5885: \fIaddress\fP.
        !          5886: The top of the current object is set to \fIoffset\fP bytes from
        !          5887: current object.
        !          5888: If \fIaddress\fP is not the address of an object on the
        !          5889: stack the result is undefined.
        !          5890: .PP
        !          5891: The remaining functions are used to build the current object incrementally.
        !          5892: An object that is built incrementally on the stack will  
        !          5893: always occupy contiguous memory within a stack frame but
        !          5894: until \f5stakfreeze\fP() is called,
        !          5895: the location in memory for the object can change.
        !          5896: There is a current offset associated with the current object that
        !          5897: determines where subsequent operations apply.
        !          5898: Initially, this offset is zero, and the offset changes as a result
        !          5899: of the operations you specify.
        !          5900: The \f5stakseek\fP() function is used set the offset for the
        !          5901: current object.
        !          5902: The \fIoffset\fP argument to \f5stakseek\fP() specifies the new 
        !          5903: offset for the current object.
        !          5904: The frame will be extended or moved
        !          5905: if \f5offset\fP causes the new current offset to extend beyond the
        !          5906: current frame.
        !          5907: \f5stakseek\fP() returns a pointer to the beginning of the current object.
        !          5908: The \f5staktell\fP() function gives the offset of the current object.
        !          5909: .PP
        !          5910: The \f5stakputc\fP() function adds a given character to the current object
        !          5911: on the stack.
        !          5912: The current offset is advanced by 1.
        !          5913: The \f5stakputs\fP() appends the given \fIstring\fP onto the current
        !          5914: object in the stack and returns the length of the string.
        !          5915: The current offset is advanced by the length of the string.
        !          5916: .PP
        !          5917: The \f5stakptr\fP() function converts the given \f5offset\fP
        !          5918: for the current object into a memory address on the stack.
        !          5919: This address is only valid until another stack operation is given.
        !          5920: The result is not defined if \fIoffset\fP exceeds the size of the current
        !          5921: object.
        !          5922: The \f5stakfreeze\fP()
        !          5923: function terminates the current object on the
        !          5924: stack and returns a pointer to the beginning of this object.
        !          5925: If \fIextra\fP is non-zero, \fIextra\fP bytes are added to the stack
        !          5926: before the current object is terminated.  The first added byte will
        !          5927: contain zero and the contents of the remaining bytes are undefined.
        !          5928: .PP
        !          5929: .SH HISTORY
        !          5930: The
        !          5931: \f5stak\fP
        !          5932: interface was derived from similar routines in the KornShell code
        !          5933: that is used for building parse trees and carrying out expansions.
        !          5934: It provides an efficient mechanism for grouping dynamically allocated
        !          5935: objects so that they can be freed all at once rather than individually.
        !          5936: .SH AUTHOR
        !          5937:  David Korn
        !          5938: .SH SEE ALSO
        !          5939: \f5exit(2)\fP
        !          5940: \f5longjmp(3)\fP
        !          5941: \f5malloc(3)\fP
        !          5942: 0707070000000001141006440044230044230000010000000456336256100002400000021334man/tm.3UgsfGgsf.de L          \" literal font
        !          5943: .ft 5
        !          5944: .it 1 }N
        !          5945: .if !\\$1 \&\\$1 \\$2 \\$3 \\$4 \\$5 \\$6
        !          5946: ..
        !          5947: .de LR
        !          5948: .}S 5 1 \& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
        !          5949: ..
        !          5950: .de RL
        !          5951: .}S 1 5 \& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
        !          5952: ..
        !          5953: .de EX         \" start example
        !          5954: .ta 1i 2i 3i 4i 5i 6i
        !          5955: .PP
        !          5956: .RS 
        !          5957: .PD 0
        !          5958: .ft 5
        !          5959: .nf
        !          5960: ..
        !          5961: .de EE         \" end example
        !          5962: .fi
        !          5963: .ft
        !          5964: .PD
        !          5965: .RE
        !          5966: .PP
        !          5967: ..
        !          5968: .TH TM 3
        !          5969: .SH NAME
        !          5970: tm \- time conversion support
        !          5971: .SH SYNOPSIS
        !          5972: .L "#include <tm.h>"
        !          5973: .SH DESCRIPTION
        !          5974: The
        !          5975: .I tm
        !          5976: library supports conversion between
        !          5977: string date specifications,
        !          5978: .L time_t
        !          5979: clock values and
        !          5980: .L "struct tm"
        !          5981: values.
        !          5982: .L localtime()
        !          5983: and
        !          5984: .L gmtime()
        !          5985: (see
        !          5986: .IR ctime (3))
        !          5987: are used to determine local time zone information.
        !          5988: .PP
        !          5989: .L time_t
        !          5990: values are the number of seconds since the epoch,
        !          5991: .BR "Jan 1 00:00:00 GMT 1970" ,
        !          5992: with leap seconds omitted.
        !          5993: .PP
        !          5994: The global variable
        !          5995: .L "int tm_info.flags"
        !          5996: contains flags that allow all programs using the library
        !          5997: to be controlled in a consistent manner.
        !          5998: .L tm_info.flags
        !          5999: is initialized by the
        !          6000: .L tminit()
        !          6001: routine described below, and may be explicitly reset after
        !          6002: .L tminit()
        !          6003: is called.
        !          6004: The flags are:
        !          6005: .TP
        !          6006: .L TM_ADJUST
        !          6007: Set by
        !          6008: .L tminit()
        !          6009: if
        !          6010: .L localtime()
        !          6011: and
        !          6012: .L gmtime()
        !          6013: do not compensate for leap seconds.
        !          6014: .TP
        !          6015: .L TM_LEAP
        !          6016: .L time_t
        !          6017: values are interpreted as if they include leap seconds.
        !          6018: Set by
        !          6019: .L tminit()
        !          6020: if the
        !          6021: .L leap
        !          6022: option is set in the
        !          6023: .L TM_OPTIONS
        !          6024: environment variable.
        !          6025: .TP
        !          6026: .L TM_UTC
        !          6027: Times are relative to
        !          6028: .B UTC
        !          6029: (universal coordinated time, i.e.,
        !          6030: .BR GMT ).
        !          6031: Otherwise times are relative to the local time zone.
        !          6032: Set by
        !          6033: .L tminit()
        !          6034: if the time zone name matches one of
        !          6035: .L tm_info.format[43]
        !          6036: through
        !          6037: .L tm_info.format[46]
        !          6038: described below.
        !          6039: If the time zone name is not determined by
        !          6040: .L localtime()
        !          6041: then the environment variables
        !          6042: .L TZNAME
        !          6043: (as described in BSD 4.3) and
        !          6044: .L TZ
        !          6045: (as described in System V)
        !          6046: are checked, in order.
        !          6047: If this fails then the time zone name is constructed using
        !          6048: the local time zone offset.
        !          6049: .PP
        !          6050: The routines are:
        !          6051: .TP
        !          6052: .L "time_t tmdate(char* date, char** end, time_t* clock)"
        !          6053: Parses the date specification
        !          6054: .L date
        !          6055: using the
        !          6056: .L tm_info.format
        !          6057: string table (described below)
        !          6058: and returns the equivalent
        !          6059: .L time_t
        !          6060: value.
        !          6061: If
        !          6062: .RL non- NULL ,
        !          6063: .L end
        !          6064: is set to the position of the first unrecognized character in
        !          6065: .LR date .
        !          6066: .L clock
        !          6067: is used to provide default values for omitted components in
        !          6068: .LR date .
        !          6069: If
        !          6070: .L clock
        !          6071: is
        !          6072: .L NULL
        !          6073: then the current time is used.
        !          6074: .TP
        !          6075: .L "struct tm* tmfix(struct tm* tp)"
        !          6076: Corrects any out of bounds fields in
        !          6077: .L tp
        !          6078: and returns
        !          6079: .L tp
        !          6080: as its value.
        !          6081: The corrections start with
        !          6082: .L tp->tm_sec
        !          6083: and propagate down to
        !          6084: .LR tp->tm_year .
        !          6085: For example, if
        !          6086: .L tp->tm_sec
        !          6087: were 61 then it would change to 1 and
        !          6088: .L tp->tm_min
        !          6089: would be incremented by 1, and so on.
        !          6090: .LR tp->tm_wday ,
        !          6091: .LR tp->tm_yday
        !          6092: and
        !          6093: .L tp->tm_isdst
        !          6094: are not changed as these can be computed from the other fields.
        !          6095: .TP
        !          6096: .L "char* tmform(char* buf, char* format, time_t* clock)"
        !          6097: Formats the date pointed to by
        !          6098: .L clock
        !          6099: into the buffer
        !          6100: .L buf
        !          6101: according to the format specification
        !          6102: .LR format .
        !          6103: If
        !          6104: .L format
        !          6105: is
        !          6106: .L NULL
        !          6107: or empty then the string
        !          6108: .L tm_info.format[40]
        !          6109: is used.
        !          6110: If
        !          6111: .L clock
        !          6112: is
        !          6113: .L NULL
        !          6114: then the current time is used.
        !          6115: A pointer to the end of
        !          6116: .L buf
        !          6117: (i.e., the terminating
        !          6118: .LR "'\e0'" )
        !          6119: is returned.
        !          6120: .RS
        !          6121: .PP
        !          6122: .L format
        !          6123: is in the style of
        !          6124: .IR printf (3),
        !          6125: where
        !          6126: .BI % field
        !          6127: causes the corresponding fixed size field to be placed in
        !          6128: .LR buf ,
        !          6129: zero padded if necessary, and \e\fIc\fP and \e\fInnn\fP
        !          6130: sequences are interpreted as in the C language.
        !          6131: Otherwise invalid
        !          6132: .BI % field
        !          6133: specifications and all other characters in
        !          6134: .L format
        !          6135: are copied into
        !          6136: .L buf
        !          6137: without change.
        !          6138: String field values are taken from the
        !          6139: .L tm_info.format
        !          6140: string table.
        !          6141: The
        !          6142: .I fields
        !          6143: are:
        !          6144: .TP
        !          6145: .PD 0
        !          6146: .B %
        !          6147: .B %
        !          6148: character.
        !          6149: .TP
        !          6150: .B a
        !          6151: Abbreviated weekday name.
        !          6152: .TP
        !          6153: .B A
        !          6154: Full weekday name.
        !          6155: .TP
        !          6156: .B b
        !          6157: Abbreviated month name.
        !          6158: .TP
        !          6159: .B c
        !          6160: .IR ctime (3)
        !          6161: style date without the trailing
        !          6162: .BR newline .
        !          6163: .TP
        !          6164: .B C
        !          6165: .IR date (1)
        !          6166: style date.
        !          6167: .TP
        !          6168: .B d
        !          6169: Day of month number.
        !          6170: .TP
        !          6171: .B D
        !          6172: Date as
        !          6173: .IR mm / dd / yy .
        !          6174: .TP
        !          6175: .B e
        !          6176: Blank padded day of month number.
        !          6177: .TP
        !          6178: .B E
        !          6179: Unpadded day of month number.
        !          6180: .TP
        !          6181: .B h
        !          6182: Abbreviated month name.
        !          6183: .TP
        !          6184: .B H
        !          6185: 24-hour clock hour.
        !          6186: .TP
        !          6187: .B i
        !          6188: International
        !          6189: .IR date (1)
        !          6190: date that includes the time zone type name.
        !          6191: .TP
        !          6192: .B I
        !          6193: 12-hour clock hour.
        !          6194: .TP
        !          6195: .B j
        !          6196: 1-offset Julian date.
        !          6197: .TP
        !          6198: .B J
        !          6199: 0-offset Julian date.
        !          6200: .TP
        !          6201: .B l
        !          6202: .IR ls (1)
        !          6203: .B \-l
        !          6204: date that lists recent dates with
        !          6205: .IR hh : mm
        !          6206: and distant dates with
        !          6207: .IR yyyy .
        !          6208: .TP
        !          6209: .B m
        !          6210: Month number.
        !          6211: .TP
        !          6212: .B M
        !          6213: Minutes.
        !          6214: .TP
        !          6215: .B n
        !          6216: .B newline
        !          6217: character.
        !          6218: .TP
        !          6219: .B p
        !          6220: Meridian (e.g.,
        !          6221: .B AM
        !          6222: or
        !          6223: .BR PM ).
        !          6224: .TP
        !          6225: .B r
        !          6226: 12-hour time as
        !          6227: .IR hh : mm : ss
        !          6228: .IR meridian .
        !          6229: .TP
        !          6230: .B R
        !          6231: 24-hour time as
        !          6232: .IR hh : mm .
        !          6233: .TP
        !          6234: .B S
        !          6235: Seconds.
        !          6236: .TP
        !          6237: .B t
        !          6238: .B tab
        !          6239: character.
        !          6240: .TP
        !          6241: .B T
        !          6242: 24-hour time as
        !          6243: .IR hh : mm : ss .
        !          6244: .TP
        !          6245: .B U
        !          6246: Week number with Sunday as the first day.
        !          6247: .TP
        !          6248: .B w
        !          6249: Weekday number.
        !          6250: .TP
        !          6251: .B W
        !          6252: Week number with Monday as the first day.
        !          6253: .TP
        !          6254: .B x
        !          6255: Local date style, using
        !          6256: .LR tm_info.format[39] ,
        !          6257: that includes the month, day and year.
        !          6258: .TP
        !          6259: .B X
        !          6260: Local time style, using
        !          6261: .LR tm_info.format[38] ,
        !          6262: that includes the hours and minutes.
        !          6263: .TP
        !          6264: .B y
        !          6265: 2-digit year.
        !          6266: .TP
        !          6267: .B Y
        !          6268: 4-digit year.
        !          6269: .TP
        !          6270: .B z
        !          6271: Time zone type name.
        !          6272: .TP
        !          6273: .B Z
        !          6274: Time zone name.
        !          6275: .TP
        !          6276: .BI + flag
        !          6277: .TP
        !          6278: .BI \- flag
        !          6279: Temporarily (until
        !          6280: .L tmform()
        !          6281: returns) sets (+) or clears (\-) the
        !          6282: .L tm_info.flags
        !          6283: flags specified by
        !          6284: .IR flag :
        !          6285: .RS
        !          6286: .TP
        !          6287: .B l
        !          6288: .L TM_LEAP
        !          6289: .TP
        !          6290: .B u
        !          6291: .L TM_UTC
        !          6292: .RE
        !          6293: .TP
        !          6294: .B #
        !          6295: Number of seconds since the epoch.
        !          6296: .PD
        !          6297: .RE
        !          6298: .TP
        !          6299: .L "void tminit()"
        !          6300: Implicitly called by the other
        !          6301: .I tm
        !          6302: library routines to initialize global data, including the
        !          6303: .L tm_info.format
        !          6304: table and the
        !          6305: .L tm_info.flags
        !          6306: global flags.
        !          6307: Global data should only be modified after an explicit call to
        !          6308: .LR tminit() .
        !          6309: .TP
        !          6310: .L "time_t tmleap(time_t* clock)"
        !          6311: Returns a
        !          6312: .L time_t
        !          6313: value for the time pointed to by
        !          6314: .L clock
        !          6315: with leap seconds adjusted for external
        !          6316: routines that do not handle leap seconds.
        !          6317: If
        !          6318: .L clock
        !          6319: is
        !          6320: .L NULL
        !          6321: then the current time is used.
        !          6322: Adjustments are only done if the
        !          6323: .L TM_ADJUST
        !          6324: flag is set in
        !          6325: .LR tm_info.flags .
        !          6326: .TP
        !          6327: .L "struct tm* tmmake(time_t* clock)"
        !          6328: Returns a pointer to the
        !          6329: .L tm
        !          6330: struct corresponding to the time pointed to by
        !          6331: .LR clock .
        !          6332: If
        !          6333: .L clock
        !          6334: is
        !          6335: .L NULL
        !          6336: then the current time is used.
        !          6337: .TP
        !          6338: .L "time_t tmtime(struct tm* tp, int west)"
        !          6339: Returns the
        !          6340: .L time_t
        !          6341: value corresponding to
        !          6342: .LR tp .
        !          6343: If
        !          6344: .L west
        !          6345: is
        !          6346: .L TM_LOCALZONE
        !          6347: then
        !          6348: .L tm
        !          6349: is relative to the local time zone,
        !          6350: otherwise
        !          6351: .L west
        !          6352: is the number of minutes west of
        !          6353: .B UTC
        !          6354: with daylight savings time taken into account.
        !          6355: .LR tp->tm_wday ,
        !          6356: .LR tp->tm_yday
        !          6357: and
        !          6358: .L tp->tm_isdst
        !          6359: are ignored in the conversion.
        !          6360: .PP
        !          6361: The library routines use a table of date strings pointed to by
        !          6362: .LR "char** tm_info.format" .
        !          6363: The indices in
        !          6364: .L tm_info.format
        !          6365: are fixed by category.
        !          6366: .L tm_info.format
        !          6367: may be changed to point to other tables
        !          6368: according to local language and date conventions.
        !          6369: The contents by index (showing the USA English values) are:
        !          6370: .RS
        !          6371: .TP
        !          6372: .PD 0
        !          6373: .B 0-11
        !          6374: 3-character abbreviated month names.
        !          6375: .TP
        !          6376: .B 12-23
        !          6377: Full month names.
        !          6378: .TP
        !          6379: .B 24-30
        !          6380: 3-character abbreviated weekday names.
        !          6381: .TP
        !          6382: .B 31-37
        !          6383: Full weekday names.
        !          6384: .TP
        !          6385: .B 38
        !          6386: .L tmform()
        !          6387: local time format used by the
        !          6388: .B %X
        !          6389: field.
        !          6390: .TP
        !          6391: .B 39
        !          6392: .L tmform()
        !          6393: local date format used by the
        !          6394: .B %x
        !          6395: field.
        !          6396: .TP
        !          6397: .B 40
        !          6398: .L tmform()
        !          6399: format used if the
        !          6400: .L format
        !          6401: argument is
        !          6402: .L NULL
        !          6403: or empty.
        !          6404: .TP
        !          6405: .B 41-42
        !          6406: Meridian names: AM, PM.
        !          6407: .TP
        !          6408: .B 43-46
        !          6409: .B UTC
        !          6410: time zone names: GMT, UTC, UCT, CUT.
        !          6411: .TP
        !          6412: .B 47-50
        !          6413: Daylight savings time suffix names: DST.
        !          6414: .TP
        !          6415: .B 51-54
        !          6416: Suffixes to be ignored when matching strings in
        !          6417: .LR tmform() .
        !          6418: .TP
        !          6419: .B 55-61
        !          6420: Time part names: second, hour, minute, day, week, month, year.
        !          6421: .TP
        !          6422: .B 62-65
        !          6423: Hours of the day names: midnight, morning, noon, evening.
        !          6424: .TP
        !          6425: .B 66-68
        !          6426: Relative day names: yesterday, today, tomorrow.
        !          6427: .TP
        !          6428: .B 69-71
        !          6429: Past relative time references: last, ago, past.
        !          6430: .TP
        !          6431: .B 72-75
        !          6432: Current relative time references: this, now, current.
        !          6433: .TP
        !          6434: .B 75-77
        !          6435: Future relative time references: next, hence, coming.
        !          6436: .TP
        !          6437: .B 78-80
        !          6438: Exact relative time references: exactly.
        !          6439: .TP
        !          6440: .B 81-85
        !          6441: Noise words to be ignored: at, in, on.
        !          6442: .PD
        !          6443: .RE
        !          6444: .PP
        !          6445: Low level support functions and data are described in
        !          6446: .LR <tm.h> .
        !          6447: .SH EXAMPLES
        !          6448: .EX
        !          6449: #include <tm.h>
        !          6450: main() {
        !          6451:     int       i;
        !          6452:     time_t    t;
        !          6453:     char      buf[128];
        !          6454:     struct {
        !          6455:         char* date;
        !          6456:         char* format;
        !          6457:     }         x[] = {
        !          6458:         "now",                 "%i",
        !          6459:         "2 months ago",        "%C",
        !          6460:         "this Wednesday noon", "%x %I:%M %p",
        !          6461:         "last December 25",    "%A",
        !          6462:         0,                     0
        !          6463:     };
        !          6464:     for (i = 0; x[i].date; i++) {
        !          6465:         t = tmdate(x[i].date, (char*)0, (time_t*)0);
        !          6466:         (void)tmform(buf, x[i].format, &t);
        !          6467:         puts(buf);
        !          6468:     }
        !          6469: }
        !          6470: .EE
        !          6471: produces
        !          6472: .EX
        !          6473: Fri Sep 30 12:10:14 USA EDT 1988
        !          6474: Fri Jul  1 00:00:00 EDT 1988
        !          6475: 10/05/88 12:00 PM
        !          6476: Friday
        !          6477: .EE
        !          6478: .SH "SEE ALSO"
        !          6479: date(1), time(2), ctime(3)
        !          6480: .SH BUGS
        !          6481: .L "struct tm"
        !          6482: values may get clobbered by the
        !          6483: .I tm
        !          6484: library routines as the
        !          6485: .IR ctime (3)
        !          6486: routines typically return pointers to a single static
        !          6487: .L "struct tm"
        !          6488: area.
        !          6489: .L tmdate()
        !          6490: uses an internal international time zone name table that will
        !          6491: probably always be incomplete.
        !          6492: 0707070000000001151006440044230044230000010000000461362623700003100000001006misc/calloc.cUgsfGgsf/*
        !          6493:  * since libx provides malloc(), these must be included
        !          6494:  * to avoid multiple link definitions for some shared
        !          6495:  * library implementations
        !          6496:  */
        !          6497: 
        !          6498: #include "FEATURE/bzero"
        !          6499: #ifdef _lib_bzero
        !          6500: #define memzero(p,n)           bzero(p,n)
        !          6501: #else
        !          6502: #define memzero(p,n)           memset(p,0,n)
        !          6503: #endif
        !          6504: 
        !          6505: extern char*   malloc();
        !          6506: 
        !          6507: char*
        !          6508: calloc(count, size)
        !          6509: register unsigned int  count;
        !          6510: register unsigned int  size;
        !          6511: {
        !          6512:        register char*  ptr;
        !          6513: 
        !          6514:        if (ptr = malloc(size *= count))
        !          6515:                memzero(ptr, size);
        !          6516:        return(ptr);
        !          6517: }
        !          6518: 
        !          6519: void
        !          6520: cfree(old)
        !          6521: char*  old;
        !          6522: {
        !          6523:        free(old);
        !          6524: }
        !          6525: 0707070000000001161006440044230044230000010000000472745070400003200000002634misc/cmdargs.cUgsfGgsf/*
        !          6526:  * G. S. Fowler
        !          6527:  * AT&T Bell Laboratories
        !          6528:  *
        !          6529:  * multi-pass commmand line option parse assist
        !          6530:  *
        !          6531:  *     int fun(char** argv, int last)
        !          6532:  *
        !          6533:  * each fun() argument parses as much of argv as
        !          6534:  * possible starting at (opt_index,opt_char) using
        !          6535:  * optget()
        !          6536:  *
        !          6537:  * if last!=0 then fun is the last pass to view
        !          6538:  * the current arg, otherwise fun sets opt_again=1
        !          6539:  * and another pass will get a crack at it
        !          6540:  *
        !          6541:  * 0 fun() return causes immediate cmdargs() 0 return
        !          6542:  *
        !          6543:  * cmdargs() returns non-zero if more args remain
        !          6544:  * to be parsed at opt_index
        !          6545:  */
        !          6546: 
        !          6547: #include <option.h>
        !          6548: 
        !          6549: typedef int (*PFI)();
        !          6550: 
        !          6551: int    opt_again;              /* repeat last position in next optget  */
        !          6552: 
        !          6553: #if __STDC__
        !          6554: 
        !          6555: #include <stdarg.h>
        !          6556: 
        !          6557: int
        !          6558: cmdargs(char** argv, ...)
        !          6559: 
        !          6560: #else
        !          6561: 
        !          6562: #include <varargs.h>
        !          6563: 
        !          6564: int
        !          6565: cmdargs(va_alist)
        !          6566: va_dcl
        !          6567: 
        !          6568: #endif
        !          6569: 
        !          6570: {
        !          6571:        va_list                 ap;
        !          6572:        register PFI            fun;
        !          6573:        register PFI            rep;
        !          6574:        int                     last_index;
        !          6575:        int                     last_char;
        !          6576: #if !__STDC__
        !          6577:        register char           **argv;
        !          6578: #endif
        !          6579: 
        !          6580:        rep = 0;
        !          6581:        for (;;)
        !          6582:        {
        !          6583: #if __STDC__
        !          6584:                va_start(ap, argv);
        !          6585: #else
        !          6586:                va_start(ap);
        !          6587:                argv = va_arg(ap, char**);
        !          6588: #endif
        !          6589:                while (fun = va_arg(ap, PFI))
        !          6590:                {
        !          6591:                        last_index = opt_index;
        !          6592:                        last_char = opt_char;
        !          6593:                        if (!(*fun)(argv, fun == rep) || !argv[opt_index]) return(argv[opt_index] != 0);
        !          6594:                        if (opt_again)
        !          6595:                        {
        !          6596:                                opt_again = 0;
        !          6597:                                opt_index = opt_pindex;
        !          6598:                                opt_char = opt_pchar;
        !          6599:                        }
        !          6600:                        if (!rep || opt_index != last_index || opt_char != last_char) rep = fun;
        !          6601:                        else if (fun == rep) return(1);
        !          6602:                }
        !          6603:                va_end(ap);
        !          6604:        }
        !          6605: }
        !          6606: 0707070000000001171006440044230044230000010000000460673177200003300000000762misc/cmdclose.cUgsfGgsf/*
        !          6607:  * G. S. Fowler
        !          6608:  * AT&T Bell Laboratories
        !          6609:  *
        !          6610:  * close a stream opened by cmdopen()
        !          6611:  * -1 returned if cmdopen() had a problem
        !          6612:  * otherwise exit() status of command is returned
        !          6613:  */
        !          6614: 
        !          6615: #include "cmdlib.h"
        !          6616: 
        !          6617: int
        !          6618: cmdclose(fd)
        !          6619: register int   fd;
        !          6620: {
        !          6621:        register struct cmdinfo*        cmd;
        !          6622: 
        !          6623:        for (cmd = cmds; cmd; cmd = cmd->next)
        !          6624:                if (cmd->fd == fd)
        !          6625:                {
        !          6626:                        (void)close(fd);
        !          6627:                        cmd->fd = -2;
        !          6628:                        if (cmd->pid < 0)
        !          6629:                        {
        !          6630:                                cmd->pid = 0;
        !          6631:                                return(cmd->status);
        !          6632:                        }
        !          6633:                        return(cmdwait(-cmd->pid));
        !          6634:                }
        !          6635:        return(-1);
        !          6636: }
        !          6637: 0707070000000001201006440044230044230000010000000460673177600003200000000543misc/cmdkill.cUgsfGgsf/*
        !          6638:  * G. S. Fowler
        !          6639:  * AT&T Bell Laboratories
        !          6640:  *
        !          6641:  * send sig to cmd opened by cmdopen()
        !          6642:  */
        !          6643: 
        !          6644: #include "cmdlib.h"
        !          6645: 
        !          6646: int
        !          6647: cmdkill(fd, sig)
        !          6648: register int   fd;
        !          6649: int            sig;
        !          6650: {
        !          6651:        register struct cmdinfo*        cmd;
        !          6652: 
        !          6653:        for (cmd = cmds; cmd; cmd = cmd->next)
        !          6654:                if (cmd->fd == fd)
        !          6655:                {
        !          6656:                        if (cmd->pid > 0) return(kill(cmd->pid, sig));
        !          6657:                        break;
        !          6658:                }
        !          6659:        errno = ESRCH;
        !          6660:        return(-1);
        !          6661: }
        !          6662: 0707070000000001211006440044230044230000010000000470065653000003100000001754misc/cmdlib.hUgsfGgsf/*
        !          6663:  * G. S. Fowler
        !          6664:  * AT&T Bell Laboratories
        !          6665:  *
        !          6666:  * cmd library definitions
        !          6667:  */
        !          6668: 
        !          6669: #include <limits.h>
        !          6670: #include <stdio.h>
        !          6671: #include <errno.h>
        !          6672: 
        !          6673: #define EXITBITS       8                       /* # exit status bits   */
        !          6674: #define EXITMAX                ((1<<EXITBITS)-1)       /* max exit status      */
        !          6675: 
        !          6676: #define EXITED(x)      (!((x)&EXITMAX))
        !          6677: #define EXITSTATUS(x)  (((x)>>EXITBITS)&EXITMAX)
        !          6678: 
        !          6679: #define TERMINATED(x)  (((x)&EXITMAX)!=0)
        !          6680: #define TERMSTATUS(x)  (((x)&EXITMAX)|(1<<EXITBITS))
        !          6681: #define TERMSIGNAL(x)  ((x)&(EXITMAX>>1))
        !          6682: #define TERMCORE(x)    ((x)&(1<<(EXITBITS-1)))
        !          6683: 
        !          6684: #ifndef PATH_MAX
        !          6685: #define PATH_MAX       1024
        !          6686: #endif
        !          6687: 
        !          6688: struct cmdinfo                 /* info for each cmd                    */
        !          6689: {
        !          6690:        struct cmdinfo* next;   /* next in list                         */
        !          6691:        int             pid;    /* cmd pid, 0 if free                   */
        !          6692:        short           fd;     /* cmdopen() connection if >= 0         */
        !          6693:        short           status; /* wait() exit status if pid < 0        */
        !          6694: };
        !          6695: 
        !          6696: #define cmds   _cmd_info_      /* hide external symbol                 */
        !          6697: 
        !          6698: extern struct cmdinfo* cmds;   /* cmd list                             */
        !          6699: 
        !          6700: extern int             errno;
        !          6701: 
        !          6702: extern int             cmdwait();
        !          6703: extern long            lseek();
        !          6704: extern char*           malloc();
        !          6705: extern void            sigcritical();
        !          6706: 0707070000000001221006440044230044230000010000000473420241300003200000010211misc/cmdopen.cUgsfGgsf/*
        !          6707:  * G. S. Fowler
        !          6708:  * AT&T Bell Laboratories
        !          6709:  *
        !          6710:  * common command execution support with
        !          6711:  * proper stdio and wait() syncronization
        !          6712:  *
        !          6713:  * _ contains the command path name and is
        !          6714:  * placed at the top of the environment
        !          6715:  */
        !          6716: 
        !          6717: #include "cmdlib.h"
        !          6718: 
        !          6719: static void    redirect();
        !          6720: 
        !          6721: extern char*   getenv();
        !          6722: extern char*   getshell();
        !          6723: extern char*   pathpath();
        !          6724: extern char*   putenv();
        !          6725: extern char*   strcpy();
        !          6726: 
        !          6727: /*
        !          6728:  * fork and exec cmd(argv) according to mode combinations:
        !          6729:  *
        !          6730:  *     a       argv[-1] and argv[0] can be modified
        !          6731:  *     e       clear environment
        !          6732:  *     g       run with real gid
        !          6733:  *     p       paranoid
        !          6734:  *     r       cmd stdout pipe fd returned
        !          6735:  *     w       cmd stdin pipe fd returned
        !          6736:  *     u       run with real uid
        !          6737:  *
        !          6738:  * pipe not used when r and w are omitted (no io on return fd)
        !          6739:  * cmd==0 names the current shell
        !          6740:  * envv is the child environment
        !          6741:  * redv is the child redirection vector
        !          6742:  *      even elements duped from the next element
        !          6743:  *     -1 even terminates the list
        !          6744:  *     -1 odd element means close
        !          6745:  */
        !          6746: 
        !          6747: int
        !          6748: cmdopen(cmd, argv, envv, redv, mode)
        !          6749: char*  cmd;
        !          6750: char** argv;
        !          6751: char** envv;
        !          6752: int*   redv;
        !          6753: char*  mode;
        !          6754: {
        !          6755:        register struct cmdinfo*        proc;
        !          6756:        register int                    cmdfd = -1;
        !          6757:        register char**                 p;
        !          6758:        char**                          v;
        !          6759:        int*                            r;
        !          6760:        int                             argmod = 0;
        !          6761:        int                             envclear = 0;
        !          6762:        int                             paranoid = 0;
        !          6763:        int                             realgid = 0;
        !          6764:        int                             realuid = 0;
        !          6765:        long                            pos;
        !          6766:        char                            path[PATH_MAX];
        !          6767:        char                            env[PATH_MAX + 2];
        !          6768:        int                             pio[2];
        !          6769: 
        !          6770:        extern char**                   environ;
        !          6771: 
        !          6772:        if (cmd && !pathpath(path, cmd, (char*)0, 011)) return(-1);
        !          6773:        if (mode) while (*mode) switch (*mode++)
        !          6774:        {
        !          6775:        case 'a':
        !          6776:                argmod = 1;
        !          6777:                break;
        !          6778:        case 'e':
        !          6779:                envclear = 1;
        !          6780:                break;
        !          6781:        case 'g':
        !          6782:                realgid = 1;
        !          6783:                break;
        !          6784:        case 'p':
        !          6785:                paranoid = 1;
        !          6786:                break;
        !          6787:        case 'r':
        !          6788:                cmdfd = 1;
        !          6789:                break;
        !          6790:        case 'u':
        !          6791:                realuid = 1;
        !          6792:                break;
        !          6793:        case 'w':
        !          6794:                cmdfd = 0;
        !          6795:                break;
        !          6796:        default:
        !          6797:                return(-1);
        !          6798:        }
        !          6799:        for (proc = cmds; proc; proc = proc->next)
        !          6800:                if (!proc->pid) break;
        !          6801:        if (!proc)
        !          6802:        {
        !          6803:                if (!(proc = (struct cmdinfo*)malloc(sizeof(struct cmdinfo)))) return(-1);
        !          6804:                proc->pid = 0;
        !          6805:                proc->next = cmds;
        !          6806:                cmds = proc;
        !          6807:        }
        !          6808:        if (!putenv((char*)0)) return(-1);
        !          6809:        if (cmdfd >= 0 && pipe(pio)) return(-1);
        !          6810:        fflush(stdout);
        !          6811:        fflush(stderr);
        !          6812:        sigcritical(1);
        !          6813:        proc->pid = fork();
        !          6814:        sigcritical(0);
        !          6815:        switch (proc->pid)
        !          6816:        {
        !          6817:        case -1:
        !          6818:                proc->pid = 0;
        !          6819:                if (cmdfd >= 0)
        !          6820:                {
        !          6821:                        (void)close(pio[0]);
        !          6822:                        (void)close(pio[1]);
        !          6823:                }
        !          6824:                return(-1);
        !          6825:        case 0:
        !          6826:                if (paranoid || realgid) (void)setgid(getgid());
        !          6827:                if (paranoid || realuid) (void)setuid(getuid());
        !          6828:                if ((pos = ftell(stdin)) != lseek(fileno(stdin), 0L, 1))
        !          6829:                        (void)lseek(fileno(stdin), pos, 0);
        !          6830:                if (cmdfd >= 0)
        !          6831:                {
        !          6832:                        redirect(pio[cmdfd], cmdfd);
        !          6833:                        (void)close(pio[!cmdfd]);
        !          6834:                }
        !          6835:                if (r = redv) while (*r >= 0)
        !          6836:                {
        !          6837:                        redirect(*(r + 1), *r);
        !          6838:                        r += 2;
        !          6839:                }
        !          6840:                if (envclear) environ = 0;
        !          6841:                env[0] = '_';
        !          6842:                env[1] = '=';
        !          6843:                if (!putenv(env)) _exit(EXITMAX);
        !          6844:                if (paranoid && !putenv("PATH=:/bin:/usr/bin")) _exit(EXITMAX);
        !          6845:                if (p = envv)
        !          6846:                        while (*p)
        !          6847:                                if (!putenv(*p++)) _exit(EXITMAX);
        !          6848: #if 0
        !          6849:                if ((mode = getenv("EXEC_OPTIONS")) && (*mode == 'n' || *mode == 'v'))
        !          6850:                {
        !          6851:                        if (*(mode + 1) == 'e' && (p = environ))
        !          6852:                                while (*p)
        !          6853:                                        fprintf(stderr, "%s\n", *p++);
        !          6854:                        fprintf(stderr, "+ %s", cmd ? path : "sh");
        !          6855:                        if ((p = argv) && *p)
        !          6856:                                while (*++p) fprintf(stderr, " %s", *p);
        !          6857:                        fprintf(stderr, "\n");
        !          6858:                        if (*mode == 'n') _exit(0);
        !          6859:                }
        !          6860: #endif
        !          6861:                p = argv;
        !          6862:                if (cmd)
        !          6863:                {
        !          6864:                        (void)strcpy(env + 2, path);
        !          6865:                        execv(path, p);
        !          6866:                        if (errno != ENOEXEC) _exit(EXITMAX);
        !          6867: 
        !          6868:                        /*
        !          6869:                         * try cmd as a shell script
        !          6870:                         */
        !          6871: 
        !          6872:                        if (!argmod)
        !          6873:                        {
        !          6874:                                while (*p++);
        !          6875:                                if (!(v = (char**)malloc((p - argv + 2) * sizeof(char**)))) _exit(EXITMAX);
        !          6876:                                p = v + 2;
        !          6877:                                if (*argv) argv++;
        !          6878:                                while (*p++ = *argv++);
        !          6879:                                p = v + 1;
        !          6880:                        }
        !          6881:                        *p = path;
        !          6882:                        *--p = "sh";
        !          6883:                }
        !          6884:                if (!paranoid)
        !          6885:                {
        !          6886:                        (void)strcpy(env + 2, getshell());
        !          6887:                        execv(env + 2, p);
        !          6888:                }
        !          6889:                (void)strcpy(env + 2, "/bin/sh");
        !          6890:                execv(env + 2, p);
        !          6891:                _exit(EXITMAX);
        !          6892:                /*NOTREACHED*/
        !          6893:        default:
        !          6894:                if (cmdfd >= 0)
        !          6895:                {
        !          6896:                        (void)close(pio[cmdfd]);
        !          6897:                        proc->fd = pio[!cmdfd];
        !          6898:                }
        !          6899:                else if ((proc->fd = dup(0)) < 0)
        !          6900:                        (void)cmdclose(proc->fd);
        !          6901:                return(proc->fd);
        !          6902:        }
        !          6903: }
        !          6904: 
        !          6905: /*
        !          6906:  * redirect nfd to fd
        !          6907:  * nfd==-1 means close(fd)
        !          6908:  */
        !          6909: 
        !          6910: static void
        !          6911: redirect(nfd, fd)
        !          6912: int    nfd;
        !          6913: int    fd;
        !          6914: {
        !          6915:        if (nfd != fd)
        !          6916:        {
        !          6917:                if (nfd >= 0)
        !          6918:                {
        !          6919:                        if (dup2(nfd, fd) != fd) _exit(EXITMAX);
        !          6920:                        (void)close(nfd);
        !          6921:                }
        !          6922:                else (void)close(fd);
        !          6923:        }
        !          6924: }
        !          6925: 0707070000000001231006440044230044230000010000000447753442300003100000000444misc/cmdrun.cUgsfGgsf/*
        !          6926:  * G. S. Fowler
        !          6927:  * AT&T Bell Laboratories
        !          6928:  *
        !          6929:  * cmdopen() + cmdclose()
        !          6930:  * no env mods
        !          6931:  * no redirection
        !          6932:  * effective=real
        !          6933:  */
        !          6934: 
        !          6935: extern int     cmdopen();
        !          6936: extern int     cmdclose();
        !          6937: 
        !          6938: int
        !          6939: cmdrun(cmd, argv)
        !          6940: char*  cmd;
        !          6941: char** argv;
        !          6942: {
        !          6943:        return(cmdclose(cmdopen(cmd, argv, (char**)0, (int**)0, "gu")));
        !          6944: }
        !          6945: 0707070000000001241006440044230044230000010000000470065435500003200000002636misc/cmdwait.cUgsfGgsf/*
        !          6946:  * Glenn Fowler
        !          6947:  * AT&T Bell Laboratories
        !          6948:  *
        !          6949:  * wait for cmd pid and return exit status
        !          6950:  * if pid < 0 then table not searched for -pid
        !          6951:  * -1 returned on pid error
        !          6952:  */
        !          6953: 
        !          6954: #include "cmdlib.h"
        !          6955: 
        !          6956: struct cmdinfo*                cmds;           /* open cmd list                */
        !          6957: 
        !          6958: int
        !          6959: cmdwait(pid)
        !          6960: register int   pid;
        !          6961: {
        !          6962:        register struct cmdinfo*        cmd;
        !          6963:        register int                    n;
        !          6964:        struct cmdinfo*                 slot;
        !          6965:        int                             status;
        !          6966:        int                             oerrno;
        !          6967:        long                            pos;
        !          6968: 
        !          6969:        if (pid > 0)
        !          6970:        {
        !          6971:                pid = -pid;
        !          6972:                for (cmd = cmds; cmd; cmd = cmd->next)
        !          6973:                        if (cmd->pid == pid)
        !          6974:                        {
        !          6975:                                cmd->pid = 0;
        !          6976:                                return(cmd->status);
        !          6977:                        }
        !          6978:        }
        !          6979:        pid = -pid;
        !          6980:        oerrno = errno;
        !          6981:        sigcritical(1);
        !          6982:        for (;;)
        !          6983:        {
        !          6984:                if ((n = wait(&status)) == -1)
        !          6985:                {
        !          6986:                        oerrno = ESRCH;
        !          6987:                        status = -1;
        !          6988:                        break;
        !          6989:                }
        !          6990:                if (EXITED(status))
        !          6991:                {
        !          6992:                        status = EXITSTATUS(status);
        !          6993:                        if (status == EXITMAX) status = -1;
        !          6994:                }
        !          6995:                else status = TERMSTATUS(status);
        !          6996:                for (slot = 0, cmd = cmds; cmd; cmd = cmd->next)
        !          6997:                {
        !          6998:                        if (cmd->pid == n)
        !          6999:                        {
        !          7000:                                if (pid == n) cmd->pid = 0;
        !          7001:                                else
        !          7002:                                {
        !          7003:                                        cmd->pid = -n;
        !          7004:                                        cmd->status = status;
        !          7005:                                }
        !          7006:                                break;
        !          7007:                        }
        !          7008:                        else if (!slot && !cmd->pid) slot = cmd;
        !          7009:                }
        !          7010:                if (pid == n) break;
        !          7011:                if (!cmd && ((cmd = slot) || (cmd = (struct cmdinfo*)malloc(sizeof(struct cmdinfo)))))
        !          7012:                {
        !          7013:                        cmd->fd = -2;
        !          7014:                        cmd->pid = -n;
        !          7015:                        cmd->status = status;
        !          7016:                        cmd->next = cmds;
        !          7017:                        cmds = cmd;
        !          7018:                }
        !          7019:        }
        !          7020:        if ((pos = lseek(fileno(stdin), 0L, 1)) != ftell(stdin))
        !          7021:                (void)fseek(stdin, pos, 0);
        !          7022:        sigcritical(0);
        !          7023:        errno = oerrno;
        !          7024:        return(status);
        !          7025: }
        !          7026: 0707070000000001251006440044230044230000010000000405511146200003200000005013misc/cvtatoe.cUgsfGgsf/****************************************************************
        !          7027:  *                                                              *
        !          7028:  *                   Copyright (c) 1987 AT&T                    *
        !          7029:  *                     All Rights Reserved                      *
        !          7030:  *                                                              *
        !          7031:  *        THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF        *
        !          7032:  *                            AT&T                              *
        !          7033:  *                                                              *
        !          7034:  *       The copyright notice above does not evidence any       *
        !          7035:  *      actual or intended publication of such source code      *
        !          7036:  *                                                              *
        !          7037:  ****************************************************************/
        !          7038: 
        !          7039: /*
        !          7040:  * this is an ASCII to EBCDIC conversion table
        !          7041:  * from a proposed BTL standard April 16, 1979
        !          7042:  */
        !          7043: 
        !          7044: static unsigned char atoe[] =
        !          7045: {
        !          7046:     0000,0001,0002,0003,0067,0055,0056,0057,
        !          7047:     0026,0005,0045,0013,0014,0015,0016,0017,
        !          7048:     0020,0021,0022,0023,0074,0075,0062,0046,
        !          7049:     0030,0031,0077,0047,0034,0035,0036,0037,
        !          7050:     0100,0132,0177,0173,0133,0154,0120,0175,
        !          7051:     0115,0135,0134,0116,0153,0140,0113,0141,
        !          7052:     0360,0361,0362,0363,0364,0365,0366,0367,
        !          7053:     0370,0371,0172,0136,0114,0176,0156,0157,
        !          7054:     0174,0301,0302,0303,0304,0305,0306,0307,
        !          7055:     0310,0311,0321,0322,0323,0324,0325,0326,
        !          7056:     0327,0330,0331,0342,0343,0344,0345,0346,
        !          7057:     0347,0350,0351,0255,0340,0275,0232,0155,
        !          7058:     0171,0201,0202,0203,0204,0205,0206,0207,
        !          7059:     0210,0211,0221,0222,0223,0224,0225,0226,
        !          7060:     0227,0230,0231,0242,0243,0244,0245,0246,
        !          7061:     0247,0250,0251,0300,0117,0320,0137,0007,
        !          7062:     0040,0041,0042,0043,0044,0025,0006,0027,
        !          7063:     0050,0051,0052,0053,0054,0011,0012,0033,
        !          7064:     0060,0061,0032,0063,0064,0065,0066,0010,
        !          7065:     0070,0071,0072,0073,0004,0024,0076,0341,
        !          7066:     0101,0102,0103,0104,0105,0106,0107,0110,
        !          7067:     0111,0121,0122,0123,0124,0125,0126,0127,
        !          7068:     0130,0131,0142,0143,0144,0145,0146,0147,
        !          7069:     0150,0151,0160,0161,0162,0163,0164,0165,
        !          7070:     0166,0167,0170,0200,0212,0213,0214,0215,
        !          7071:     0216,0217,0220,0152,0233,0234,0235,0236,
        !          7072:     0237,0240,0252,0253,0254,0112,0256,0257,
        !          7073:     0260,0261,0262,0263,0264,0265,0266,0267,
        !          7074:     0270,0271,0272,0273,0274,0241,0276,0277,
        !          7075:     0312,0313,0314,0315,0316,0317,0332,0333,
        !          7076:     0334,0335,0336,0337,0352,0353,0354,0355,
        !          7077:     0356,0357,0372,0373,0374,0375,0376,0377,
        !          7078: };
        !          7079: 
        !          7080: /*
        !          7081:  * convert n bytes of ip from ASCII to EBCDIC in op
        !          7082:  */
        !          7083: 
        !          7084: void
        !          7085: cvtatoe(ip, op, n)
        !          7086: register unsigned char *ip;
        !          7087: register unsigned char *op;
        !          7088: register int           n;
        !          7089: {
        !          7090:        while (n-- > 0) *op++ = atoe[*ip++];
        !          7091: }
        !          7092: 0707070000000001261006440044230044230000010000000405511165100003200000005013misc/cvtetoa.cUgsfGgsf/****************************************************************
        !          7093:  *                                                              *
        !          7094:  *                   Copyright (c) 1987 AT&T                    *
        !          7095:  *                     All Rights Reserved                      *
        !          7096:  *                                                              *
        !          7097:  *        THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF        *
        !          7098:  *                            AT&T                              *
        !          7099:  *                                                              *
        !          7100:  *       The copyright notice above does not evidence any       *
        !          7101:  *      actual or intended publication of such source code      *
        !          7102:  *                                                              *
        !          7103:  ****************************************************************/
        !          7104: 
        !          7105: /*
        !          7106:  * this is an EBCDIC to ASCII conversion table
        !          7107:  * from a proposed BTL standard April 16, 1979
        !          7108:  */
        !          7109: 
        !          7110: static unsigned char etoa[] =
        !          7111: {
        !          7112:     0000,0001,0002,0003,0234,0011,0206,0177,
        !          7113:     0227,0215,0216,0013,0014,0015,0016,0017,
        !          7114:     0020,0021,0022,0023,0235,0205,0010,0207,
        !          7115:     0030,0031,0222,0217,0034,0035,0036,0037,
        !          7116:     0200,0201,0202,0203,0204,0012,0027,0033,
        !          7117:     0210,0211,0212,0213,0214,0005,0006,0007,
        !          7118:     0220,0221,0026,0223,0224,0225,0226,0004,
        !          7119:     0230,0231,0232,0233,0024,0025,0236,0032,
        !          7120:     0040,0240,0241,0242,0243,0244,0245,0246,
        !          7121:     0247,0250,0325,0056,0074,0050,0053,0174,
        !          7122:     0046,0251,0252,0253,0254,0255,0256,0257,
        !          7123:     0260,0261,0041,0044,0052,0051,0073,0176,
        !          7124:     0055,0057,0262,0263,0264,0265,0266,0267,
        !          7125:     0270,0271,0313,0054,0045,0137,0076,0077,
        !          7126:     0272,0273,0274,0275,0276,0277,0300,0301,
        !          7127:     0302,0140,0072,0043,0100,0047,0075,0042,
        !          7128:     0303,0141,0142,0143,0144,0145,0146,0147,
        !          7129:     0150,0151,0304,0305,0306,0307,0310,0311,
        !          7130:     0312,0152,0153,0154,0155,0156,0157,0160,
        !          7131:     0161,0162,0136,0314,0315,0316,0317,0320,
        !          7132:     0321,0345,0163,0164,0165,0166,0167,0170,
        !          7133:     0171,0172,0322,0323,0324,0133,0326,0327,
        !          7134:     0330,0331,0332,0333,0334,0335,0336,0337,
        !          7135:     0340,0341,0342,0343,0344,0135,0346,0347,
        !          7136:     0173,0101,0102,0103,0104,0105,0106,0107,
        !          7137:     0110,0111,0350,0351,0352,0353,0354,0355,
        !          7138:     0175,0112,0113,0114,0115,0116,0117,0120,
        !          7139:     0121,0122,0356,0357,0360,0361,0362,0363,
        !          7140:     0134,0237,0123,0124,0125,0126,0127,0130,
        !          7141:     0131,0132,0364,0365,0366,0367,0370,0371,
        !          7142:     0060,0061,0062,0063,0064,0065,0066,0067,
        !          7143:     0070,0071,0372,0373,0374,0375,0376,0377,
        !          7144: };
        !          7145: 
        !          7146: /*
        !          7147:  * convert n bytes of ip from EBCDIC to ASCII in op
        !          7148:  */
        !          7149: 
        !          7150: void
        !          7151: cvtetoa(ip, op, n)
        !          7152: register unsigned char *ip;
        !          7153: register unsigned char *op;
        !          7154: register int           n;
        !          7155: {
        !          7156:        while (n-- > 0) *op++ = etoa[*ip++];
        !          7157: }
        !          7158: 0707070000000001271006440044230044230000010000000475453725700003000000021420misc/error.cUgsfGgsf/*
        !          7159:  * G. S. Fowler
        !          7160:  * AT&T Bell Laboratories
        !          7161:  *
        !          7162:  * error and message formatter
        !          7163:  *
        !          7164:  *     level is the error level
        !          7165:  *     level >= ERROR_FATAL calls err_exit
        !          7166:  *     level < 0 is for debug tracing
        !          7167:  *     err_write must accept write(2) args
        !          7168:  */
        !          7169: 
        !          7170: #include <ctype.h>
        !          7171: #include <error.h>
        !          7172: #include <namval.h>
        !          7173: #include <sig.h>
        !          7174: #include <sfio.h>
        !          7175: 
        !          7176: #if !__STDC__
        !          7177: 
        !          7178: #include <varargs.h>
        !          7179: 
        !          7180: #endif
        !          7181: 
        !          7182: typedef int (*PFI)();
        !          7183: 
        !          7184: extern int     exit();
        !          7185: extern int     write();
        !          7186: extern char*   strerror();
        !          7187: 
        !          7188: static PFI     err_aux;                /* call just before return      */
        !          7189: static PFI     err_exit = exit;        /* error exit routine           */
        !          7190: static PFI     err_write = write;      /* error output routine         */
        !          7191: 
        !          7192: static int     err_clear;              /* clear error() flags          */
        !          7193: static int     err_core;               /* level>=err_core -> core dump */
        !          7194: static int     err_fd = 2;             /* write(2) fd                  */
        !          7195: static int     err_errno;              /* last reported errno          */
        !          7196: static int     err_init;               /* initialized                  */
        !          7197: static int     err_set;                /* set error() flags            */
        !          7198: 
        !          7199: static char*   err_id;                 /* command id                   */
        !          7200: static char*   err_version;            /* ERROR_SOURCE command version */
        !          7201: 
        !          7202: static int*    ptr_errors;             /* >= ERROR_ERROR count         */
        !          7203: static int*    ptr_indent;             /* debug trace indent level     */
        !          7204: static int*    ptr_line;               /* input|output line number     */
        !          7205: static int*    ptr_mask;               /* multi level debug trace mask */
        !          7206: static int*    ptr_trace;              /* debug trace level            */
        !          7207: static int*    ptr_warnings;           /* ERROR_WARNING count          */
        !          7208: 
        !          7209: static char**  ptr_id;                 /* command id                   */
        !          7210: static char**  ptr_file;               /* input|output file name       */
        !          7211: 
        !          7212: #define OPT_CORE       1
        !          7213: #define OPT_FD         2
        !          7214: #define OPT_LIBRARY    3
        !          7215: #define OPT_MASK       4
        !          7216: #define OPT_SYSTEM     5
        !          7217: #define OPT_TRACE      6
        !          7218: 
        !          7219: static struct namval   options[] =     /* environment option names     */
        !          7220: {
        !          7221:        "core",         OPT_CORE,
        !          7222:        "fd",           OPT_FD,
        !          7223:        "library",      OPT_LIBRARY,
        !          7224:        "mask",         OPT_MASK,
        !          7225:        "system",       OPT_SYSTEM,
        !          7226:        "trace",        OPT_TRACE,
        !          7227:        0,              0
        !          7228: };
        !          7229: 
        !          7230: /*
        !          7231:  * called by stropt() to set options
        !          7232:  */
        !          7233: 
        !          7234: /*ARGSUSED*/
        !          7235: static int
        !          7236: setopt(a, p, n, v)
        !          7237: char*                  a;
        !          7238: register struct namval*        p;
        !          7239: register int           n;
        !          7240: register char*         v;
        !          7241: {
        !          7242:        static int      mask;
        !          7243:        static int      trace;
        !          7244: 
        !          7245:        extern long     strtol();
        !          7246: 
        !          7247:        switch (p->value)
        !          7248:        {
        !          7249:        case OPT_CORE:
        !          7250:                if (n) switch (*v)
        !          7251:                {
        !          7252:                case 'e':
        !          7253:                case 'E':
        !          7254:                        err_core = ERROR_ERROR;
        !          7255:                        break;
        !          7256:                case 'f':
        !          7257:                case 'F':
        !          7258:                        err_core = ERROR_FATAL;
        !          7259:                        break;
        !          7260:                case 'p':
        !          7261:                case 'P':
        !          7262:                        err_core = ERROR_PANIC;
        !          7263:                        break;
        !          7264:                default:
        !          7265:                        err_core = strtol(v, (char*)0, 0);
        !          7266:                        break;
        !          7267:                }
        !          7268:                else err_core = 0;
        !          7269:                break;
        !          7270:        case OPT_FD:
        !          7271:                err_fd = n ? strtol(v, (char*)0, 0) : -1;
        !          7272:                break;
        !          7273:        case OPT_LIBRARY:
        !          7274:                if (n) err_set |= ERROR_LIBRARY;
        !          7275:                else err_clear |= ERROR_LIBRARY;
        !          7276:                break;
        !          7277:        case OPT_MASK:
        !          7278:                if (n) mask = strtol(v, (char*)0, 0);
        !          7279:                else mask = 0;
        !          7280:                ptr_mask = &mask;
        !          7281:                break;
        !          7282:        case OPT_SYSTEM:
        !          7283:                if (n) err_set |= ERROR_SYSTEM;
        !          7284:                else err_clear |= ERROR_SYSTEM;
        !          7285:                break;
        !          7286:        case OPT_TRACE:
        !          7287:                if (n) trace = -strtol(v, (char*)0, 0);
        !          7288:                else trace = 0;
        !          7289:                ptr_trace = &trace;
        !          7290:                break;
        !          7291:        }
        !          7292:        return(0);
        !          7293: }
        !          7294: 
        !          7295: /*
        !          7296:  * initialize default environment
        !          7297:  */
        !          7298: 
        !          7299: static void
        !          7300: init()
        !          7301: {
        !          7302:        extern char*    getenv();
        !          7303: 
        !          7304:        err_init = 1;
        !          7305:        (void)stropt(getenv("ERROR_OPTIONS"), options, setopt, (char*)0);
        !          7306: }
        !          7307: 
        !          7308: /*
        !          7309:  * print a name, converting unprintable chars
        !          7310:  */
        !          7311: 
        !          7312: static void
        !          7313: print(sp, name, delim)
        !          7314: register SFIO* sp;
        !          7315: register char* name;
        !          7316: char*          delim;
        !          7317: {
        !          7318:        register int    c;
        !          7319: 
        !          7320:        while (c = *name++)
        !          7321:        {
        !          7322:                if (c & 0200)
        !          7323:                {
        !          7324:                        c &= 0177;
        !          7325:                        sfputc(sp, '?');
        !          7326:                }
        !          7327:                if (c < ' ')
        !          7328:                {
        !          7329:                        c += 'A' - 1;
        !          7330:                        sfputc(sp, '^');
        !          7331:                }
        !          7332:                sfputc(sp, c);
        !          7333:        }
        !          7334:        sfputs(sp, delim, 0);
        !          7335: }
        !          7336: 
        !          7337: /*
        !          7338:  * functional interface to the error message state
        !          7339:  *
        !          7340:  * upper case options are for static values
        !          7341:  * other options are for pointers to dynamic values
        !          7342:  * previous value for rightmost option is returned
        !          7343:  * 0 returned on first unknown option
        !          7344:  */
        !          7345: 
        !          7346: #if __STDC__
        !          7347: 
        !          7348: char*
        !          7349: seterror(int op, ...)
        !          7350: 
        !          7351: #else
        !          7352: 
        !          7353: char*
        !          7354: seterror(va_alist)
        !          7355: va_dcl
        !          7356: 
        !          7357: #endif
        !          7358: 
        !          7359: {
        !          7360:        va_list         ap;
        !          7361:        char*           prev;
        !          7362: #if !__STDC__
        !          7363:        int             op;
        !          7364: #endif
        !          7365: 
        !          7366:        prev = 0;
        !          7367: #if __STDC__
        !          7368:        va_start(ap, op);
        !          7369: #else
        !          7370:        va_start(ap);
        !          7371:        op = va_arg(ap, int);
        !          7372: #endif
        !          7373:        if (!op || !err_init) init();
        !          7374:        for (;;)
        !          7375:        {
        !          7376:                switch (op)
        !          7377:                {
        !          7378:                case 'A':
        !          7379:                        prev = (char*)err_aux;
        !          7380:                        err_aux = va_arg(ap, PFI);
        !          7381:                        break;
        !          7382:                case 'C':
        !          7383:                case 'I':
        !          7384:                        prev = (char*)err_id;
        !          7385:                        err_id = va_arg(ap, char*);
        !          7386:                        break;
        !          7387:                case 'E':
        !          7388:                        prev = (char*)err_exit;
        !          7389:                        err_exit = va_arg(ap, PFI);
        !          7390:                        break;
        !          7391:                case 'V':
        !          7392:                        prev = (char*)err_version;
        !          7393:                        err_version = va_arg(ap, char*);
        !          7394:                        break;
        !          7395:                case 'W':
        !          7396:                        prev = (char*)err_write;
        !          7397:                        err_write = va_arg(ap, PFI);
        !          7398:                        break;
        !          7399:                case 'c':
        !          7400:                        prev = (char*)ptr_id;
        !          7401:                        ptr_id = va_arg(ap, char**);
        !          7402:                        break;
        !          7403:                case 'f':
        !          7404:                        prev = (char*)ptr_file;
        !          7405:                        ptr_file = va_arg(ap, char**);
        !          7406:                        break;
        !          7407:                case 'i':
        !          7408:                        prev = (char*)ptr_indent;
        !          7409:                        ptr_indent = va_arg(ap, int*);
        !          7410:                        break;
        !          7411:                case 'l':
        !          7412:                        prev = (char*)ptr_line;
        !          7413:                        ptr_line = va_arg(ap, int*);
        !          7414:                        break;
        !          7415:                case 'm':
        !          7416:                        prev = (char*)ptr_mask;
        !          7417:                        ptr_mask = va_arg(ap, int*);
        !          7418:                        if (prev && ptr_mask) *ptr_mask = *((int*)prev);
        !          7419:                        break;
        !          7420:                case 't':
        !          7421:                        prev = (char*)ptr_trace;
        !          7422:                        ptr_trace = va_arg(ap, int*);
        !          7423:                        if (prev && ptr_trace) *ptr_trace = *((int*)prev);
        !          7424:                        break;
        !          7425:                case '1':
        !          7426:                        prev = (char*)ptr_warnings;
        !          7427:                        ptr_warnings = va_arg(ap, int*);
        !          7428:                        if (prev && ptr_warnings) *ptr_warnings += *((int*)prev);
        !          7429:                        break;
        !          7430:                case '2':
        !          7431:                        prev = (char*)ptr_errors;
        !          7432:                        ptr_errors = va_arg(ap, int*);
        !          7433:                        if (prev && ptr_errors) *ptr_errors += *((int*)prev);
        !          7434:                        break;
        !          7435:                case '+':
        !          7436:                        prev = (char*)err_set;
        !          7437:                        err_set = va_arg(ap, int);
        !          7438:                        break;
        !          7439:                case '-':
        !          7440:                        prev = (char*)err_clear;
        !          7441:                        err_clear = va_arg(ap, int);
        !          7442:                        break;
        !          7443:                default:
        !          7444:                        prev = 0;
        !          7445:                        /*FALLTHROUGH*/
        !          7446:                case 0:
        !          7447:                        va_end(ap);
        !          7448:                        return(prev);
        !          7449:                }
        !          7450:                op = va_arg(ap, int);
        !          7451:        }
        !          7452: }
        !          7453: 
        !          7454: #if __STDC__
        !          7455: 
        !          7456: void
        !          7457: error(int level, ...)
        !          7458: 
        !          7459: #else
        !          7460: 
        !          7461: void
        !          7462: error(va_alist)
        !          7463: va_dcl
        !          7464: 
        !          7465: #endif
        !          7466: 
        !          7467: {
        !          7468:        va_list ap;
        !          7469: #if !__STDC__
        !          7470:        int     level;
        !          7471: #endif
        !          7472: 
        !          7473: #if __STDC__
        !          7474:        va_start(ap, level);
        !          7475: #else
        !          7476:        va_start(ap);
        !          7477:        level = va_arg(ap, int);
        !          7478: #endif
        !          7479:        verror((char*)0, level, ap);
        !          7480:        va_end(ap);
        !          7481: }
        !          7482: 
        !          7483: #if __STDC__ || __cplusplus
        !          7484: void
        !          7485: verror(const char* lib, int level, va_list ap)
        !          7486: #else
        !          7487: void
        !          7488: verror(lib, level, ap)
        !          7489: char*  lib;
        !          7490: int    level;
        !          7491: va_list        ap;
        !          7492: #endif
        !          7493: {
        !          7494:        register SFIO*  sp;
        !          7495:        register int    n;
        !          7496:        int             fd;
        !          7497:        int             flags;
        !          7498:        char*           s;
        !          7499:        char*           format;
        !          7500: 
        !          7501:        int             indent;
        !          7502:        int             line;
        !          7503:        int             trace;
        !          7504:        char*           file;
        !          7505: 
        !          7506:        static int      state;
        !          7507: 
        !          7508:        if (!err_init) init();
        !          7509:        if (level > 0)
        !          7510:        {
        !          7511:                flags = level & ~ERROR_LEVEL;
        !          7512:                level &= ERROR_LEVEL;
        !          7513:        }
        !          7514:        else flags = 0;
        !          7515:        trace = ptr_trace ? *ptr_trace : 0;
        !          7516:        if (level < trace || lib && (err_clear & ERROR_LIBRARY) || level < 0 && ptr_mask && !((*ptr_mask) & (1<<(-level - 1))))
        !          7517:        {
        !          7518:                if (level >= ERROR_FATAL) (*err_exit)(level - 1);
        !          7519:                return;
        !          7520:        }
        !          7521:        if (trace < 0) flags |= ERROR_LIBRARY|ERROR_SYSTEM;
        !          7522:        flags |= err_set;
        !          7523:        flags &= ~err_clear;
        !          7524:        if (!lib) flags &= ~ERROR_LIBRARY;
        !          7525:        if (sp = sftmp(SF_UNBOUND))
        !          7526:        {
        !          7527:                file = ptr_id ? *ptr_id : err_id;
        !          7528:                if (flags & ERROR_USAGE)
        !          7529:                {
        !          7530:                        if (state & ERROR_USAGE) (void)sfprintf(sp, "       ");
        !          7531:                        else
        !          7532:                        {
        !          7533:                                state |= ERROR_USAGE;
        !          7534:                                (void)sfprintf(sp, "Usage: ");
        !          7535:                        }
        !          7536:                        if (file || opt_argv && (file = opt_argv[0])) print(sp, file, " ");
        !          7537:                }
        !          7538:                else
        !          7539:                {
        !          7540:                        state &= ~ERROR_USAGE;
        !          7541:                        if (level && !(flags & ERROR_NOID))
        !          7542:                        {
        !          7543:                                if (file) print(sp, file, (flags & ERROR_LIBRARY) ? " " : ": ");
        !          7544:                                if (flags & ERROR_LIBRARY) (void)sfprintf(sp, "[%s library]: ", lib);
        !          7545:                        }
        !          7546:                }
        !          7547:                line = ptr_line ? *ptr_line : 0;
        !          7548:                file = ptr_file ? *ptr_file : 0;
        !          7549:                if (level > 0 && line > 0)
        !          7550:                {
        !          7551:                        if (file && *file) (void)sfprintf(sp, "\"%s\", ", file);
        !          7552:                        (void)sfprintf(sp, "line %d: ", line);
        !          7553:                }
        !          7554:                switch (level)
        !          7555:                {
        !          7556:                case 0:
        !          7557:                        break;
        !          7558:                case ERROR_WARNING:
        !          7559:                        if (ptr_warnings) (*ptr_warnings)++;
        !          7560:                        (void)sfprintf(sp, "warning: ");
        !          7561:                        break;
        !          7562:                case ERROR_PANIC:
        !          7563:                        if (ptr_errors) (*ptr_errors)++;
        !          7564:                        (void)sfprintf(sp, "panic: ");
        !          7565:                        break;
        !          7566:                default:
        !          7567:                        if (level < 0)
        !          7568:                        {
        !          7569:                                if (trace < -1) (void)sfprintf(sp, "debug%d:%s", level, level > -10 ? " " : "");
        !          7570:                                else (void)sfprintf(sp, "debug: ");
        !          7571:                                indent = ptr_indent ? *ptr_indent : 0;
        !          7572:                                for (n = 0; n < indent; n++)
        !          7573:                                {
        !          7574:                                        sfputc(sp, ' ');
        !          7575:                                        sfputc(sp, ' ');
        !          7576:                                }
        !          7577:                        }
        !          7578:                        else if (ptr_errors) (*ptr_errors)++;
        !          7579:                        break;
        !          7580:                }
        !          7581:                fd = (flags & ERROR_OUTPUT) ? va_arg(ap, int) : err_fd;
        !          7582:                if (flags & ERROR_SOURCE)
        !          7583:                {
        !          7584:                        /*
        !          7585:                         * source ([version], file, line) message
        !          7586:                         */
        !          7587: 
        !          7588:                        file = va_arg(ap, char*);
        !          7589:                        line = va_arg(ap, int);
        !          7590:                        if (err_version) (void)sfprintf(sp, "(%s: %s, line %d) ", err_version, file, line);
        !          7591:                        else (void)sfprintf(sp, "(%s, line %d) ", file, line);
        !          7592:                }
        !          7593:                format = va_arg(ap, char*);
        !          7594:                (void)sfvprintf(sp, format, ap);
        !          7595:                if (!(flags & ERROR_PROMPT))
        !          7596:                {
        !          7597:                        if ((flags & ERROR_SYSTEM) && errno && errno != err_errno)
        !          7598:                        {
        !          7599:                                (void)sfprintf(sp, " [%s]", strerror(errno));
        !          7600:                                if (err_set & ERROR_SYSTEM) errno = 0;
        !          7601:                                err_errno = (level >= 0) ? 0 : errno;
        !          7602:                        }
        !          7603:                        sfputc(sp, '\n');
        !          7604:                }
        !          7605:                (void)sfseek(sp, 0L, 0);
        !          7606:                n = sfpeek(sp, (unsigned char**)&s);
        !          7607:                if (err_write) (void)(*err_write)(fd, s, n);
        !          7608:                if (err_aux) (void)(*err_aux)(lib, flags, level, s, n);
        !          7609:                (void)sfclose(sp);
        !          7610:        }
        !          7611:        if (level >= err_core && err_core)
        !          7612:        {
        !          7613:                (void)signal(SIGQUIT, SIG_DFL);
        !          7614:                (void)kill(getpid(), SIGQUIT);
        !          7615:                (void)pause();
        !          7616:        }
        !          7617:        if (level >= ERROR_FATAL) (void)(*err_exit)(level - ERROR_FATAL + 1);
        !          7618: }
        !          7619: 0707070000000001301006440044230044230000010000000440004232200003300000002414misc/fgetline.cUgsfGgsf/*
        !          7620:  * Glenn Fowler
        !          7621:  * AT&T Bell Laboratories
        !          7622:  */
        !          7623: 
        !          7624: #include <stdio.h>
        !          7625: 
        !          7626: #define LINECHUNK      256             /* line resize increment        */
        !          7627: 
        !          7628: static char*           buf;            /* current line buffer          */
        !          7629: static int             siz;            /* current buf size             */
        !          7630: 
        !          7631: extern char*           malloc();
        !          7632: extern char*           realloc();
        !          7633: 
        !          7634: /*
        !          7635:  * return next line from fp
        !          7636:  * if new!=0 then the old buffer space is not reclaimed and
        !          7637:  * the new buffer space is returned with size strlen(line)+new
        !          7638:  * otherwise an internal buffer is used for each call
        !          7639:  *
        !          7640:  * newline is replaced by 0
        !          7641:  *
        !          7642:  * 0 returned if first char is EOF
        !          7643:  * otherwise EOF is treated as a newline
        !          7644:  */
        !          7645: 
        !          7646: char*
        !          7647: fgetline(fp, new)
        !          7648: register FILE* fp;
        !          7649: int            new;
        !          7650: {
        !          7651:        register int    c;
        !          7652:        register char*  s;
        !          7653:        register char*  end;
        !          7654: 
        !          7655:        if ((!buf || new) && !(buf = malloc(siz = LINECHUNK))) return(0);
        !          7656:        s = buf;
        !          7657:        end = s + siz;
        !          7658:        for (;;)
        !          7659:        {
        !          7660:                if (s >= end)
        !          7661:                {
        !          7662:                        if (!(buf = realloc(buf, siz += LINECHUNK))) return(0);
        !          7663:                        s = buf + siz - LINECHUNK;
        !          7664:                        end = buf + siz;
        !          7665:                }
        !          7666:                switch (c = getc(fp))
        !          7667:                {
        !          7668:                case EOF:
        !          7669:                        if (s == buf)
        !          7670:                        {
        !          7671:                                if (new)
        !          7672:                                {
        !          7673:                                        free(buf);
        !          7674:                                        buf = 0;
        !          7675:                                }
        !          7676:                                return(0);
        !          7677:                        }
        !          7678:                        /*FALLTHROUGH*/
        !          7679:                case '\n':
        !          7680:                        *s = 0;
        !          7681:                        return(new ? realloc(buf, siz = buf - s + new) : buf);
        !          7682:                }
        !          7683:                *s++ = c;
        !          7684:        }
        !          7685: }
        !          7686: 
        !          7687: /*
        !          7688:  * free fgetline() buffer
        !          7689:  */
        !          7690: 
        !          7691: void
        !          7692: ffreeline()
        !          7693: {
        !          7694:        if (buf)
        !          7695:        {
        !          7696:                free(buf);
        !          7697:                buf = 0;
        !          7698:        }
        !          7699: }
        !          7700: 0707070000000001311006440044230044230000010000000475137331600002700000000764misc/fs3d.cUgsfGgsf/*
        !          7701:  * AT&T Bell Laboratories
        !          7702:  *
        !          7703:  * disable (0) / enable (1) / tell (2) 3d fs operations
        !          7704:  * the argument must be 0, 2 or a previous fs3d() return value
        !          7705:  * the return value is the previous state
        !          7706:  */
        !          7707: 
        !          7708: #define OP3D   010000
        !          7709: #define ON3D   001000
        !          7710: 
        !          7711: extern int     umask();
        !          7712: 
        !          7713: int
        !          7714: fs3d(n)
        !          7715: register int   n;
        !          7716: {
        !          7717:        register int    o;
        !          7718: 
        !          7719:        o = umask(0) | OP3D;
        !          7720:        switch (n)
        !          7721:        {
        !          7722:        case 0:
        !          7723:                (void)umask(o & ~ON3D);
        !          7724:                break;
        !          7725:        case 1:
        !          7726:                (void)umask(o | ON3D);
        !          7727:                break;
        !          7728:        default:
        !          7729:                (void)umask(o);
        !          7730:                break;
        !          7731:        }
        !          7732:        return((o & ON3D) != 0);
        !          7733: }
        !          7734: 0707070000000001321006440044230044230000010000000475447470200003100000041407misc/ftwalk.cUgsfGgsf/*
        !          7735: **     int ftwalk(char *path, int (*userf)(), int flags, int (*comparf)());
        !          7736: **
        !          7737: **     Function to walk a file system graph in a depth-first search.
        !          7738: **     Arguments of ftwalk() are:
        !          7739: **
        !          7740: **     path:   path name(s) of the root(s) of the graph to be search.
        !          7741: **
        !          7742: **     userf:  a function to be called at each node that is visited.
        !          7743: **             Called as: int userf(struct FTW* ftw)
        !          7744: **             ftw:    a structure containing info about current node.
        !          7745: **                     See ftwalk.h for info on its fields.
        !          7746: **             If func returns non-zero, ftwalk() terminates and returns this
        !          7747: **             value to its caller.
        !          7748: **
        !          7749: **     flags:  a bit vector indicating types of traversal.
        !          7750: **             See ftwalk.h for info on available bit fields.
        !          7751: **
        !          7752: **     comparf: a function to be called to order elements in the same directory.
        !          7753: **             Called as: int (*comparf)(struct FTW *f1, struct FTW *f2)
        !          7754: **             It should return -1, 0, 1 to indicate f1<f2, f1=f2 or f1>f2.
        !          7755: **
        !          7756: **     Written by K-Phong Vo, 11/30/88.
        !          7757: */
        !          7758: 
        !          7759: #include       <sys/types.h>
        !          7760: #include       <sys/stat.h>
        !          7761: #include       <dirent.h>
        !          7762: #include       <limits.h>
        !          7763: #include       <errno.h>
        !          7764: #include       <ftwalk.h>
        !          7765: 
        !          7766: #ifdef BSD
        !          7767: #define memcopy(to,fr,n)       bcopy(fr,to,n)
        !          7768: #else
        !          7769: #define memcopy(to,fr,n)       memcpy(to,fr,n)
        !          7770: #endif
        !          7771: 
        !          7772: #ifndef PATH_MAX
        !          7773: #define PATH_MAX       1024
        !          7774: #endif
        !          7775: 
        !          7776: #define reg    register
        !          7777: extern char    *malloc();
        !          7778: extern int     stat();
        !          7779: extern int     chdir();
        !          7780: extern int     errno;
        !          7781: #ifdef S_IFLNK
        !          7782: extern int     lstat();
        !          7783: extern int     lpstat();
        !          7784: #endif
        !          7785: 
        !          7786: #if MAXNAMLEN > 16
        !          7787: #define MINNAME                24
        !          7788: #else
        !          7789: #define MINNAME                16
        !          7790: #endif
        !          7791: 
        !          7792: #define Ftw            struct FTW
        !          7793: 
        !          7794: /* function to determine type of an object */
        !          7795: #ifdef S_IFLNK
        !          7796: #define TYPE(i,m)      (i = (m)&S_IFMT,i == S_IFDIR ? FTW_D : \
        !          7797:                                        i == S_IFLNK ? FTW_SL : FTW_F)
        !          7798: #else
        !          7799: #define TYPE(i,m)      (((m)&S_IFMT) == S_IFDIR ? FTW_D : FTW_F)
        !          7800: #endif
        !          7801: 
        !          7802: /* to set state.status and state.base on calls to user function */
        !          7803: #define STATUS(cdrv)   (cdrv == 0 ? FTW_NAME : FTW_PATH)
        !          7804: 
        !          7805: /* see if same object */
        !          7806: #define SAME(one,two)  ((one).st_ino == (two).st_ino && (one).st_dev == (two).st_dev)
        !          7807: 
        !          7808: /* path name */
        !          7809: #define PATH(p,l)      ((l) > 0 && (p)[0] == '.' && (p)[1] == '/' ? (p)+2 : (p))
        !          7810: 
        !          7811: /*
        !          7812:        Make/free an object of type FTW.
        !          7813: */
        !          7814: static Ftw     *Free;
        !          7815: #define freeFtw(f)     ((f)->link = Free, Free = (f))
        !          7816: 
        !          7817: static Ftw *newFtw(name,namelen)
        !          7818: reg char       *name;
        !          7819: reg int                namelen;
        !          7820: {
        !          7821:        reg Ftw *f;
        !          7822:        reg int amount;
        !          7823: 
        !          7824:        if(Free && namelen < MINNAME)
        !          7825:                f = Free, Free = f->link;
        !          7826:        else
        !          7827:        {
        !          7828:                amount = namelen < MINNAME ? MINNAME : namelen+1;
        !          7829:                if(!(f = (Ftw*) malloc(sizeof(Ftw)+amount-sizeof(int))))
        !          7830:                        return 0;
        !          7831:        }
        !          7832:        f->link = 0;
        !          7833:        f->local.number = 0;
        !          7834:        f->local.pointer = 0;
        !          7835:        f->status = FTW_NAME;
        !          7836:        f->namelen = namelen;
        !          7837:        memcopy(f->name,name,namelen+1);
        !          7838: 
        !          7839:        return f;
        !          7840: }
        !          7841: 
        !          7842: static int freeAll(f,rv)
        !          7843: reg Ftw        *f;
        !          7844: reg int        rv;
        !          7845: {
        !          7846:        reg Ftw *next;
        !          7847:        reg int freeing;
        !          7848: 
        !          7849:        for(freeing = 0; freeing < 2; ++freeing)
        !          7850:        {
        !          7851:                if(freeing == 1)
        !          7852:                        f = Free, Free = 0;
        !          7853:                while(f)
        !          7854:                {
        !          7855:                        next = f->link;
        !          7856:                        free((char*)f);
        !          7857:                        f = next;
        !          7858:                }
        !          7859:        }
        !          7860:        return rv;
        !          7861: }
        !          7862: 
        !          7863: /*
        !          7864:        To compare directories by device/inode.
        !          7865: */
        !          7866: static int statcmp(f1,f2)
        !          7867: reg Ftw        *f1, *f2;
        !          7868: {
        !          7869:        reg int d;
        !          7870:        if((d = f1->statb.st_ino - f2->statb.st_ino) != 0)
        !          7871:                return d;
        !          7872:        if((d = f1->statb.st_dev - f2->statb.st_dev) != 0)
        !          7873:                return d;
        !          7874:        /* hack for NFS system where (dev,ino) do not uniquely identify objects */
        !          7875:        return (f1->statb.st_mtime - f2->statb.st_mtime);
        !          7876: }
        !          7877: 
        !          7878: /*
        !          7879:        Search trees with top-down splaying (a la Tarjan and Sleator).
        !          7880:        When used for insertion sort, this implements a stable sort.
        !          7881: */
        !          7882: #define RROTATE(r)     (t = r->left, r->left = t->right, t->right = r, r = t)
        !          7883: #define LROTATE(r)     (t = r->right, r->right = t->left, t->left = r, r = t)
        !          7884: 
        !          7885: static Ftw *search(e,root,comparf,insert)
        !          7886: reg Ftw        *e, *root;
        !          7887: int    (*comparf)();
        !          7888: int    insert;         /* always insert */
        !          7889: {
        !          7890:        reg int         cmp;
        !          7891:        reg Ftw         *t, *left, *right, *lroot, *rroot;
        !          7892: 
        !          7893:        left = right = lroot = rroot = 0;
        !          7894:        while(root)
        !          7895:        {
        !          7896:                if((cmp = (*comparf)(e,root)) == 0 && !insert)
        !          7897:                        break;
        !          7898:                if(cmp < 0)
        !          7899:                {       /* this is the left zig-zig case */
        !          7900:                        if(root->left && (cmp = (*comparf)(e,root->left)) <= 0)
        !          7901:                        {
        !          7902:                                RROTATE(root);
        !          7903:                                if(cmp == 0 && !insert)
        !          7904:                                        break;
        !          7905:                        }
        !          7906: 
        !          7907:                        /* stick all things > e to the right tree */
        !          7908:                        if(right)
        !          7909:                                right->left = root;
        !          7910:                        else    rroot = root;
        !          7911:                        right = root;
        !          7912:                        root = root->left;
        !          7913:                        right->left = 0;
        !          7914:                }
        !          7915:                else
        !          7916:                {       /* this is the right zig-zig case */
        !          7917:                        if(root->right && (cmp = (*comparf)(e,root->right)) >= 0)
        !          7918:                        {
        !          7919:                                LROTATE(root);
        !          7920:                                if(cmp == 0 && !insert)
        !          7921:                                        break;
        !          7922:                        }
        !          7923: 
        !          7924:                        /* stick all things <= e to the left tree */
        !          7925:                        if(left)
        !          7926:                                left->right = root;
        !          7927:                        else    lroot = root;
        !          7928:                        left = root;
        !          7929:                        root = root->right;
        !          7930:                        left->right = 0;
        !          7931:                }
        !          7932:        }
        !          7933: 
        !          7934:        if(!root)
        !          7935:                root = e;
        !          7936:        else
        !          7937:        {
        !          7938:                if(right)
        !          7939:                        right->left = root->right;
        !          7940:                else    rroot = root->right;
        !          7941:                if(left)
        !          7942:                        left->right = root->left;
        !          7943:                else    lroot = root->left;
        !          7944:        }
        !          7945: 
        !          7946:        root->left = lroot;
        !          7947:        root->right = rroot;
        !          7948:        return root;
        !          7949: }
        !          7950: 
        !          7951: /*
        !          7952: **     Delete the root element from the tree
        !          7953: */
        !          7954: static Ftw *delete(root)
        !          7955: reg Ftw        *root;
        !          7956: {
        !          7957:        reg Ftw *t, *left, *right;
        !          7958: 
        !          7959:        left = root->left;
        !          7960:        right = root->right;
        !          7961:        if(!left)
        !          7962:                root = right;
        !          7963:        else
        !          7964:        {
        !          7965:                while(left->right)
        !          7966:                        LROTATE(left);
        !          7967:                left->right = right;
        !          7968:                root = left;
        !          7969:        }
        !          7970:        return root;
        !          7971: }
        !          7972: 
        !          7973: /*
        !          7974:        Convert a binary search tree into a sorted todo (link) list
        !          7975: */
        !          7976: static void getlist(top,bot,root)
        !          7977: reg Ftw        **top, **bot, *root;
        !          7978: {
        !          7979:        if(root->left)
        !          7980:                getlist(top,bot,root->left);
        !          7981:        if (*top) (*bot)->link = root, *bot = root;
        !          7982:        else *top = *bot = root;
        !          7983:        if(root->right)
        !          7984:                getlist(top,bot,root->right);
        !          7985: }
        !          7986: 
        !          7987: /*
        !          7988:        Set directory when curdir is lost in space
        !          7989: */
        !          7990: static int setdir(home,path)
        !          7991: reg char       *home, *path;
        !          7992: {
        !          7993:        reg int cdrv;
        !          7994: 
        !          7995:        if(path[0] == '/')
        !          7996:                cdrv = setcwd(path,(char*)0);
        !          7997:        else
        !          7998:        {       /* Note that path and home are in the same buffer */
        !          7999:                path[-1] = '/';
        !          8000:                cdrv = setcwd(home,(char*)0);
        !          8001:                path[-1] = '\0';
        !          8002:        }
        !          8003:        if(cdrv < 0)
        !          8004:                (void) setcwd(home,(char*)0);
        !          8005:        return cdrv;
        !          8006: }
        !          8007: 
        !          8008: /*
        !          8009:        Set to parent dir
        !          8010: */
        !          8011: static int setpdir(home,path,base)
        !          8012: reg char       *home, *path, *base;
        !          8013: {
        !          8014:        reg int cdrv, c;
        !          8015: 
        !          8016:        if(base > path)
        !          8017:        {
        !          8018:                c = base[0];
        !          8019:                base[0] = '\0';
        !          8020:                cdrv = setdir(home,path);
        !          8021:                base[0] = c;
        !          8022:        }
        !          8023:        else    cdrv = setcwd(home,(char*)0);
        !          8024:        return cdrv;
        !          8025: }
        !          8026: 
        !          8027: /*
        !          8028:        Pop a set of directories
        !          8029: */
        !          8030: static int popdirs(n_dir,ftw)
        !          8031: reg int        n_dir;
        !          8032: reg Ftw        *ftw;
        !          8033: {
        !          8034:        struct stat     sb;
        !          8035:        reg char        *s, *endbuf;
        !          8036:        char            buf[PATH_MAX];
        !          8037: 
        !          8038:        if(!ftw || ftw->level < 0)
        !          8039:                return -1;
        !          8040: 
        !          8041:        endbuf = buf + (PATH_MAX-4);
        !          8042:        while(n_dir > 0)
        !          8043:        {
        !          8044:                for(s = buf; s < endbuf && n_dir > 0; --n_dir)
        !          8045:                        *s++ = '.', *s++ = '.', *s++ = '/';
        !          8046:                *s = '\0';
        !          8047:                if(chdir(buf) < 0)
        !          8048:                        return -1;
        !          8049:        }
        !          8050:        if(stat(".",&sb) != 0 || !SAME(sb,ftw->statb))
        !          8051:                return -1;
        !          8052:        return 0;
        !          8053: }
        !          8054: 
        !          8055: /*
        !          8056:        Get top list of elt to process
        !          8057: */
        !          8058: static Ftw *toplist(paths,statf,comparf)
        !          8059: reg char       **paths;
        !          8060: int            (*statf)(), (*comparf)();
        !          8061: {
        !          8062:        reg int         i;
        !          8063:        reg char        *path;
        !          8064:        reg Ftw         *f, *root;
        !          8065:        Ftw             *top, *bot;
        !          8066:        reg struct stat *sb;
        !          8067: 
        !          8068:        top = bot = root = 0;
        !          8069:        for(; *paths; ++paths)
        !          8070:        {
        !          8071:                path = *paths;
        !          8072:                if(!path[0])
        !          8073:                        path = ".";
        !          8074: 
        !          8075:                /* make elements */
        !          8076:                if(!(f = newFtw(path,strlen(path))))
        !          8077:                        break;
        !          8078:                f->level = 0;
        !          8079:                sb = &(f->statb);
        !          8080:                f->info = (*statf)(path,sb) < 0 ? FTW_NS : TYPE(i,sb->st_mode);
        !          8081: 
        !          8082:                if(comparf)
        !          8083:                        root = search(f,root,comparf,1);
        !          8084:                else if(bot)
        !          8085:                        bot->link = f, bot = f;
        !          8086:                else    top = bot = f;
        !          8087:        }
        !          8088:        if(comparf)
        !          8089:                getlist(&top,&bot,root);
        !          8090:        return top;
        !          8091: }
        !          8092: 
        !          8093: /*
        !          8094:        Resize path buffer.
        !          8095:        Note that realloc() is not used because we may need to chdir(home)
        !          8096:        if there isn't enough space to continue
        !          8097: */
        !          8098: static int resize(home,endbuf,path,base,n_buf,incre)
        !          8099: reg char       **home, **endbuf, **path, **base;
        !          8100: int            n_buf, incre;
        !          8101: {
        !          8102:        reg char        *old, *new;
        !          8103:        reg int         n_old;
        !          8104: 
        !          8105:        /* add space for "/." used in testing FTW_DNX */
        !          8106:        n_old = n_buf;
        !          8107:        n_buf = ((n_buf+incre+4)/PATH_MAX + 1)*PATH_MAX;
        !          8108:        if(!(new = malloc(n_buf)))
        !          8109:                return -1;
        !          8110: 
        !          8111:        old = *home;
        !          8112:        *home = new;
        !          8113:        memcopy(new,old,n_old);
        !          8114:        if(endbuf)
        !          8115:                *endbuf = new + n_buf - 4;
        !          8116:        if(path)
        !          8117:                *path = new + (*path - old);
        !          8118:        if(base)
        !          8119:                *base = new + (*base - old);
        !          8120: 
        !          8121:        free(old);
        !          8122:        return n_buf;
        !          8123: }
        !          8124: 
        !          8125: /*
        !          8126:        The real thing.
        !          8127: */
        !          8128: #if __STDC__ || __cplusplus
        !          8129: ftwalk(const char *cpath, int (*userf)(struct FTW*), int flags, int (*comparf)(struct FTW*, struct FTW*))
        !          8130: #else
        !          8131: #ifndef const
        !          8132: #define const
        !          8133: #endif
        !          8134: ftwalk(path,userf,flags,comparf)
        !          8135: char   *path;
        !          8136: int    (*userf)();
        !          8137: int    flags;
        !          8138: int    (*comparf)();
        !          8139: #endif
        !          8140: {
        !          8141: #if __STDC__ || __cplusplus
        !          8142:        char            *path = (char*)cpath;
        !          8143: #endif
        !          8144:        reg int         cdrv;           /* chdir value */
        !          8145:        int             fnrv;           /* return value from user function */
        !          8146:        Ftw             topf,           /* the parent of top elt */
        !          8147:                        *todo, *top, *bot;
        !          8148:        DIR             *dirfp;
        !          8149:        int             (*statf)();     /* stat function */
        !          8150:        int             preorder, children, postorder;
        !          8151:        char            *endbuf; /* space to build paths */
        !          8152:        static char     *Home;
        !          8153:        static int      N_buf;
        !          8154: 
        !          8155:        /* decode the flags */
        !          8156:        children = (flags&FTW_CHILDREN) ? 1 : 0;
        !          8157:        children = (children && (flags&FTW_DELAY)) ? 2 : children;
        !          8158:        preorder = ((flags&FTW_POST) == 0 && !children);
        !          8159:        postorder = (flags&(FTW_POST|FTW_TWICE));
        !          8160:        cdrv = (flags&FTW_DOT) ? 1 : -1;
        !          8161: #ifdef S_IFLNK
        !          8162:        statf = (flags&FTW_PHYSICAL) ? lstat : lpstat;
        !          8163: #else
        !          8164:        statf = stat;
        !          8165: #endif
        !          8166:        /* space for home directory and paths */
        !          8167:        if(!Home)
        !          8168:                N_buf = 2*PATH_MAX;
        !          8169:        while(1)
        !          8170:        {
        !          8171:                if(!Home && !(Home = malloc(N_buf)))
        !          8172:                        return -1;
        !          8173:                Home[0] = 0;
        !          8174:                if(cdrv > 0 || getcwd(Home,N_buf))
        !          8175:                        break;
        !          8176:                else if(errno == ERANGE)
        !          8177:                {       /* need larger buffer */
        !          8178:                        free(Home);
        !          8179:                        N_buf += PATH_MAX;
        !          8180:                        Home = 0;
        !          8181:                }
        !          8182:                else    cdrv = 1;
        !          8183:        }
        !          8184:        endbuf = Home + N_buf - 4;
        !          8185: 
        !          8186:        fnrv = -1;
        !          8187: 
        !          8188:        /* make the list of top elements */
        !          8189:        todo = top = bot = 0;
        !          8190:        if((flags&FTW_MULTIPLE) && path)
        !          8191:                todo = toplist((char**)path,statf,comparf);
        !          8192:        else
        !          8193:        {
        !          8194:                char    *p[2];
        !          8195:                p[0] = path ? path : ".";
        !          8196:                p[1] = 0;
        !          8197:                todo = toplist(p,statf,comparf);
        !          8198:        }
        !          8199: 
        !          8200:        path = Home + strlen(Home) + 1;
        !          8201:        dirfp = 0;
        !          8202:        while(todo)
        !          8203:        {
        !          8204:                reg int         i, nd;
        !          8205:                reg Ftw         *ftw, *f;
        !          8206:                reg struct stat *sb;
        !          8207:                reg char        *name, *endbase;
        !          8208:                Ftw             *link, *root, *curdir, *diroot, *dotdot;
        !          8209:                struct dirent   *dir;
        !          8210:                char            *base;
        !          8211:                reg int         level, n_base, nostat, cpname;
        !          8212: 
        !          8213:                /* process the top object on the stack */
        !          8214:                ftw = todo;
        !          8215:                link = ftw->link;
        !          8216:                sb = &(ftw->statb);
        !          8217:                name = ftw->name;
        !          8218:                level = ftw->level;
        !          8219:                fnrv = -1;
        !          8220:                top = bot = root = 0;
        !          8221: 
        !          8222:                /* initialize for level 0 */
        !          8223:                if(level == 0)
        !          8224:                {
        !          8225:                        /* initialize parent */
        !          8226:                        memcopy(&topf,ftw,sizeof(topf));
        !          8227:                        topf.level = -1;
        !          8228:                        topf.name[0] = '\0';
        !          8229:                        topf.path = 0;
        !          8230:                        topf.pathlen = topf.namelen = 0;
        !          8231:                        topf.parent = 0;
        !          8232:                        ftw->parent = &topf;
        !          8233:                        
        !          8234:                        diroot = 0;
        !          8235:                        if(cdrv == 0)
        !          8236:                                (void) setcwd(Home,(char*)0);
        !          8237:                        else if(cdrv < 0)
        !          8238:                                cdrv = 0;
        !          8239:                        curdir = cdrv ? 0 : ftw->parent;
        !          8240:                        base = path;
        !          8241:                        *base = '\0';
        !          8242:                }
        !          8243: 
        !          8244:                /* chdir to parent dir if asked for */
        !          8245:                if(cdrv < 0)
        !          8246:                {
        !          8247:                        cdrv = setdir(Home,path);
        !          8248:                        curdir = cdrv ? 0 : ftw->parent;
        !          8249:                }
        !          8250: 
        !          8251:                /* add object's name to the path */
        !          8252:                if((n_base = ftw->namelen) >= endbuf-base &&
        !          8253:                   (N_buf = resize(&Home,&endbuf,&path,&base,N_buf,n_base)) < 0)
        !          8254:                        goto done;
        !          8255:                memcopy(base,name,n_base+1);
        !          8256:                name = cdrv ? path : base;
        !          8257: 
        !          8258:                /* check for cycle and open dir */
        !          8259:                if(ftw->info == FTW_D)
        !          8260:                {
        !          8261:                        if((diroot = search(ftw,diroot,statcmp,0)) != ftw)
        !          8262:                        {
        !          8263:                                ftw->info = FTW_DC;
        !          8264:                                ftw->link = diroot;
        !          8265:                        }
        !          8266:                        else
        !          8267:                        {       /* buffer is known to be large enough here! */
        !          8268:                                if(base[n_base-1] != '/')
        !          8269:                                        memcopy(base+n_base,"/.",3);
        !          8270:                                if(!(dirfp = opendir(name)))
        !          8271:                                        ftw->info = FTW_DNX;
        !          8272:                                base[n_base] = '\0';
        !          8273:                                if(!dirfp && !(dirfp = opendir(name)))
        !          8274:                                        ftw->info = FTW_DNR;
        !          8275:                        }
        !          8276:                }
        !          8277: 
        !          8278:                /* call user function in preorder */
        !          8279:                nd = ftw->info & ~FTW_DNX;
        !          8280:                if(nd || preorder)
        !          8281:                {
        !          8282:                        ftw->status = STATUS(cdrv);
        !          8283:                        ftw->link = 0;
        !          8284:                        ftw->path = PATH(path,level);
        !          8285:                        ftw->pathlen = (base - ftw->path) + n_base;
        !          8286:                        fnrv = (*userf)(ftw);
        !          8287:                        ftw->link = link;
        !          8288:                        if(fnrv)
        !          8289:                                goto done;
        !          8290: 
        !          8291:                        /* follow symlink if asked to */
        !          8292:                        if(ftw->info == FTW_SL && ftw->status == FTW_FOLLOW)
        !          8293:                        {
        !          8294:                                ftw->info = stat(name,sb) ? FTW_NS : TYPE(i,sb->st_mode);
        !          8295:                                if(ftw->info != FTW_SL)
        !          8296:                                        continue;
        !          8297:                        }
        !          8298:                        /* about to prune this ftw and already at home */
        !          8299:                        if(cdrv == 0 && level == 0 && nd)
        !          8300:                                cdrv = -1;
        !          8301:                }
        !          8302: 
        !          8303:                /* pruning the search tree */
        !          8304:                if(!dirfp || nd || ftw->status == FTW_SKIP)
        !          8305:                {
        !          8306:                        if(dirfp)
        !          8307:                                closedir(dirfp), dirfp = 0;
        !          8308:                        goto popstack;
        !          8309:                }
        !          8310: 
        !          8311:                /* FTW_D or FTW_DNX, about to read children */
        !          8312:                if(cdrv == 0)
        !          8313:                {
        !          8314:                        if((cdrv = chdir(name)) < 0)
        !          8315:                                (void) setcwd(Home,(char*)0);
        !          8316:                        curdir = cdrv < 0 ? 0 : ftw;
        !          8317:                }
        !          8318:                nostat = (children > 1 || ftw->info == FTW_DNX);
        !          8319:                cpname = ((cdrv && !nostat) || (!children && !comparf));
        !          8320:                dotdot = 0;
        !          8321:                endbase = base+n_base;
        !          8322:                if(endbase[-1] != '/')
        !          8323:                        *endbase++ = '/';
        !          8324: 
        !          8325:                while(dir = readdir(dirfp))
        !          8326:                {
        !          8327:                        if(dir->d_ino == 0)
        !          8328:                                continue;
        !          8329:                        name = dir->d_name;
        !          8330:                        nd = 0;
        !          8331:                        if(name[0] == '.')
        !          8332:                        {
        !          8333:                                if(name[1] == '\0')
        !          8334:                                        nd = 1;
        !          8335:                                else if(name[1] == '.' && name[2] == '\0')
        !          8336:                                        nd = 2;
        !          8337:                        }
        !          8338:                        if(!children && nd > 0)
        !          8339:                                continue;
        !          8340: 
        !          8341:                        /* make a new entry */
        !          8342:                        fnrv = -1;
        !          8343:                        if(!(f = newFtw(name,i = DIRNAMLEN(dir))))
        !          8344:                                goto done;
        !          8345:                        f->parent = ftw;
        !          8346:                        f->level = level+1;
        !          8347:                        sb = &(f->statb);
        !          8348: 
        !          8349:                        /* check for space */
        !          8350:                        if(i >= endbuf-endbase)
        !          8351:                        {
        !          8352:                                N_buf = resize(&Home,&endbuf,&path,&base,N_buf,i);
        !          8353:                                if(N_buf < 0)
        !          8354:                                        goto done;
        !          8355:                                endbase = base+n_base;
        !          8356:                                if(endbase[-1] != '/')
        !          8357:                                        ++endbase;
        !          8358:                        }
        !          8359:                        if(cpname)
        !          8360:                        {
        !          8361:                                memcopy(endbase,name,i+1);
        !          8362:                                if(cdrv)
        !          8363:                                        name = path;
        !          8364:                        }
        !          8365: 
        !          8366:                        if(nd == 1)
        !          8367:                        {
        !          8368:                                f->info = FTW_D;
        !          8369:                                memcopy(sb,&(ftw->statb),sizeof(struct stat));
        !          8370:                        }
        !          8371:                        else if(nostat || (*statf)(name,sb))
        !          8372:                        {
        !          8373:                                f->info = FTW_NS;
        !          8374:                                sb->st_ino = dir->d_ino;
        !          8375:                        }
        !          8376:                        else    f->info = TYPE(i,sb->st_mode);
        !          8377: 
        !          8378:                        if(nd)
        !          8379:                        {       /* don't recurse on . and .. */
        !          8380:                                f->status = FTW_SKIP;
        !          8381:                                if(nd == 2 && f->info != FTW_NS)
        !          8382:                                        dotdot = f;
        !          8383:                        }
        !          8384: 
        !          8385:                        if(comparf) /* object ordering */
        !          8386:                                root = search(f,root,comparf,1);
        !          8387:                        else if(children || f->info == FTW_D || f->info == FTW_SL)
        !          8388:                                top ? (bot->link = f, bot = f) : (top = bot = f);
        !          8389:                        else
        !          8390:                        {       /* terminal node */
        !          8391:                                f->status = STATUS(cdrv);
        !          8392:                                f->path = PATH(path,1);
        !          8393:                                f->pathlen = endbase - f->path + f->namelen;
        !          8394:                                fnrv = (*userf)(f);
        !          8395:                                freeFtw(f);
        !          8396:                                if(fnrv)
        !          8397:                                        goto done;
        !          8398:                        }
        !          8399:                }
        !          8400: 
        !          8401:                /* done with directory reading */
        !          8402:                closedir(dirfp), dirfp = 0;
        !          8403: 
        !          8404:                if(root)
        !          8405:                        getlist(&top,&bot,root);
        !          8406: 
        !          8407:                /* delay preorder with the children list */
        !          8408:                if(children)
        !          8409:                {       /* try moving back to parent dir */
        !          8410:                        base[n_base] = '\0';
        !          8411:                        if(cdrv <= 0)
        !          8412:                        {
        !          8413:                                f = ftw->parent;
        !          8414:                                if(cdrv < 0 || curdir != ftw || !dotdot ||
        !          8415:                                   !SAME(f->statb,dotdot->statb) ||
        !          8416:                                   (cdrv = chdir("..")) < 0)
        !          8417:                                        cdrv = setpdir(Home,path,base);
        !          8418:                                curdir = cdrv ? 0 : f;
        !          8419:                        }
        !          8420: 
        !          8421:                        ftw->link = top;
        !          8422:                        ftw->path = PATH(path,level);
        !          8423:                        ftw->pathlen = (base - ftw->path) + ftw->namelen;
        !          8424:                        ftw->status = STATUS(cdrv);
        !          8425:                        fnrv = (*userf)(ftw);
        !          8426:                        ftw->link = link;
        !          8427:                        if(fnrv)
        !          8428:                                goto done;
        !          8429: 
        !          8430:                        /* chdir down again */
        !          8431:                        nd = (ftw->status == FTW_SKIP);
        !          8432:                        if(!nd && cdrv == 0)
        !          8433:                        {
        !          8434:                                if((cdrv = chdir(base)) < 0)
        !          8435:                                        (void) setcwd(Home,(char*)0);
        !          8436:                                curdir = cdrv ? 0 : ftw;
        !          8437:                        }
        !          8438: 
        !          8439:                        /* prune */
        !          8440:                        if(base[n_base-1] != '/')
        !          8441:                                base[n_base] = '/';
        !          8442:                        for(bot = 0, f = top; f; )
        !          8443:                        {
        !          8444:                                if(nd || f->status == FTW_SKIP)
        !          8445:                                {
        !          8446:                                        if(bot)
        !          8447:                                                bot->link = f->link;
        !          8448:                                        else    top = f->link;
        !          8449:                                        freeFtw(f);
        !          8450:                                        f = bot ? bot->link : top;
        !          8451:                                        continue;
        !          8452:                                }
        !          8453: 
        !          8454:                                if(children > 1 && ftw->info != FTW_DNX)
        !          8455:                                {       /* now read stat buffer */
        !          8456:                                        sb = &(f->statb);
        !          8457:                                        if(f->status == FTW_STAT)
        !          8458:                                                f->info = TYPE(i,sb->st_mode);
        !          8459:                                        else
        !          8460:                                        {
        !          8461:                                                name = f->name;
        !          8462:                                                if(cdrv)
        !          8463:                                                {
        !          8464:                                                        memcopy(endbase,
        !          8465:                                                                name,f->namelen+1);
        !          8466:                                                        name = path;
        !          8467:                                                }
        !          8468:                                                if((*statf)(name,sb) == 0)
        !          8469:                                                        f->info = TYPE(i,sb->st_mode);
        !          8470:                                        }
        !          8471:                                }
        !          8472: 
        !          8473:                                /* normal continue */
        !          8474:                                bot = f, f = f->link;
        !          8475:                        }
        !          8476:                }
        !          8477: 
        !          8478:                base[n_base] = '\0';
        !          8479:                if(top)
        !          8480:                        bot->link = todo, todo = top, top = 0;
        !          8481: 
        !          8482:                /* pop objects completely processed */
        !          8483:        popstack:
        !          8484:                nd = 0; /* count number of ".." */
        !          8485:                while(todo && ftw == todo)
        !          8486:                {
        !          8487:                        f = ftw->parent;
        !          8488:                        if(ftw->info & FTW_DNX)
        !          8489:                        {
        !          8490:                                if(curdir == ftw)       /* ASSERT(cdrv == 0) */
        !          8491:                                {
        !          8492:                                        nd += 1;
        !          8493:                                        curdir = f;
        !          8494:                                }
        !          8495: 
        !          8496:                                /* perform post-order processing */
        !          8497:                                if(postorder &&
        !          8498:                                   ftw->status != FTW_SKIP && ftw->status != FTW_NOPOST)
        !          8499:                                {       /* move to parent dir */
        !          8500:                                        if(nd > 0)
        !          8501:                                        {
        !          8502:                                                cdrv = popdirs(nd,curdir);
        !          8503:                                                nd = 0;
        !          8504:                                        }
        !          8505:                                        if(cdrv < 0)
        !          8506:                                                cdrv = setpdir(Home,path,base);
        !          8507:                                        curdir = cdrv ? 0 : f;
        !          8508:        
        !          8509:                                        ftw->info = FTW_DP;
        !          8510:                                        ftw->path = PATH(path,ftw->level);
        !          8511:                                        ftw->pathlen = (base - ftw->path) + ftw->namelen;
        !          8512:                                        ftw->status = STATUS(cdrv);
        !          8513:                                        link = ftw->link;
        !          8514:                                        ftw->link = 0;
        !          8515:                                        fnrv = (*userf)(ftw);
        !          8516:                                        ftw->link = link;
        !          8517:                                        if(fnrv)
        !          8518:                                                goto done;
        !          8519:                                        if(ftw->status == FTW_AGAIN)
        !          8520:                                                ftw->info = FTW_D;
        !          8521:                                }
        !          8522: 
        !          8523:                                /* delete from dev/ino tree */
        !          8524:                                if(diroot != ftw)
        !          8525:                                        diroot = search(ftw,diroot,statcmp,0);
        !          8526:                                diroot = delete(diroot);
        !          8527:                        }
        !          8528: 
        !          8529:                        /* reset base */
        !          8530:                        if(base > path+f->namelen)
        !          8531:                                --base;
        !          8532:                        *base = '\0';
        !          8533:                        base -= f->namelen;
        !          8534: 
        !          8535:                        /* delete from top of stack */
        !          8536:                        if(ftw->status != FTW_AGAIN)
        !          8537:                        {
        !          8538:                                todo = todo->link;
        !          8539:                                freeFtw(ftw);
        !          8540:                        }
        !          8541:                        ftw = f;
        !          8542:                }
        !          8543: 
        !          8544:                /* reset current directory */
        !          8545:                if(nd > 0 && popdirs(nd,curdir) < 0)
        !          8546:                {
        !          8547:                        (void) setcwd(Home,(char*)0);
        !          8548:                        curdir = 0;
        !          8549:                        cdrv = -1;
        !          8550:                }
        !          8551: 
        !          8552:                if(todo)
        !          8553:                {
        !          8554:                        if(*base)
        !          8555:                                base += ftw->namelen;
        !          8556:                        if(*(base-1) != '/')
        !          8557:                                *base++ = '/';
        !          8558:                        *base = '\0';
        !          8559:                }
        !          8560:        }
        !          8561: 
        !          8562:        /* normal ending */
        !          8563:        fnrv = 0;
        !          8564: 
        !          8565: done:
        !          8566:        if(dirfp)
        !          8567:                closedir(dirfp);
        !          8568:        if(cdrv == 0)
        !          8569:                (void) setcwd(Home,(char*)0);
        !          8570:        if(top)
        !          8571:                bot->link = todo, todo = top;
        !          8572:        return freeAll(todo,fnrv);
        !          8573: }
        !          8574: 0707070000000001331006440044230044230000010000000475376241100003100000012422misc/getcwd.cUgsfGgsf/*
        !          8575:  * G. S. Fowler
        !          8576:  * AT&T Bell Laboratories
        !          8577:  *
        !          8578:  * pwd library support
        !          8579:  */
        !          8580: 
        !          8581: #include <sys/types.h>
        !          8582: #include <sys/stat.h>
        !          8583: #include <dirent.h>
        !          8584: #include <errno.h>
        !          8585: #include <limits.h>
        !          8586: 
        !          8587: #ifndef PATH_MAX
        !          8588: #define PATH_MAX       1024
        !          8589: #endif
        !          8590: 
        !          8591: #ifndef ERANGE
        !          8592: #define ERANGE         E2BIG
        !          8593: #endif
        !          8594: 
        !          8595: #define ERROR(e)       {errno=e;goto error;}
        !          8596: 
        !          8597: #define elements(x)    (sizeof(x)/sizeof(env[0]))
        !          8598: 
        !          8599: struct dirlist                         /* long path chdir(2) component */
        !          8600: {
        !          8601:        struct dirlist* next;           /* next component               */
        !          8602:        int             index;          /* index from end of buf        */
        !          8603: };
        !          8604: 
        !          8605: static struct dirlist* pushdir();
        !          8606: static int             popdir();
        !          8607: 
        !          8608: extern int     errno;
        !          8609: 
        !          8610: extern void    free();
        !          8611: 
        !          8612: extern int     chdir();
        !          8613: extern int     fstat();
        !          8614: extern int     stat();
        !          8615: 
        !          8616: extern char*   getenv();
        !          8617: extern char*   malloc();
        !          8618: extern char*   memcpy();
        !          8619: extern char*   realloc();
        !          8620: 
        !          8621: /*
        !          8622:  * return a pointer to the absolute path name of .
        !          8623:  * this path name may be longer than PATH_MAX
        !          8624:  *
        !          8625:  * a few environment variables are checked before the search algorithm
        !          8626:  * return value is placed in buf of len chars
        !          8627:  * if buf is 0 then space is allocated via malloc() with
        !          8628:  * len extra chars after the path name
        !          8629:  * 0 is returned on error with errno set as appropriate
        !          8630:  */
        !          8631: 
        !          8632: char*
        !          8633: getcwd(buf, len)
        !          8634: char*  buf;
        !          8635: int    len;
        !          8636: {
        !          8637:        register char*  d;
        !          8638:        register char*  p;
        !          8639:        register char*  s;
        !          8640:        DIR*            dirp = 0;
        !          8641:        int             n;
        !          8642:        int             x;
        !          8643:        int             namlen;
        !          8644:        int             extra = -1;
        !          8645:        struct dirent*  entry;
        !          8646:        struct dirlist* dirstk = 0;
        !          8647:        struct stat*    cur;
        !          8648:        struct stat*    par;
        !          8649:        struct stat*    tmp;
        !          8650:        struct stat     curst;
        !          8651:        struct stat     parst;
        !          8652:        struct stat     tstst;
        !          8653:        char            dots[PATH_MAX];
        !          8654: 
        !          8655:        static struct
        !          8656:        {
        !          8657:                char*           name;
        !          8658:                char*           path;
        !          8659:                unsigned long   dev;
        !          8660:                unsigned long   ino;
        !          8661:        }               env[] =
        !          8662:        {
        !          8663:                { "PWD",        0, 0, 0 },
        !          8664:                { "HOME",       0, 0, 0 },
        !          8665:        };
        !          8666: 
        !          8667:        if (len < 0 || buf && len <= 0) ERROR(EINVAL);
        !          8668:        cur = &curst;
        !          8669:        par = &parst;
        !          8670: #if defined(FS_3D)
        !          8671:        {
        !          8672:                extern char*    pathcwd();
        !          8673: 
        !          8674:                if (p = pathcwd()) goto easy;
        !          8675:        }
        !          8676: #endif
        !          8677:        if (stat(".", par)) ERROR(errno);
        !          8678:        for (n = 0; n < elements(env); n++)
        !          8679:        {
        !          8680:                if ((p = getenv(env[n].name)) && *p == '/' && !stat(p, cur))
        !          8681:                {
        !          8682:                        env[n].path = p;
        !          8683:                        env[n].dev = cur->st_dev;
        !          8684:                        env[n].ino = cur->st_ino;
        !          8685:                        if (cur->st_ino == par->st_ino && cur->st_dev == par->st_dev)
        !          8686:                        {
        !          8687: #if defined(FS_3D)
        !          8688:                        easy:
        !          8689: #endif
        !          8690:                                namlen = strlen(p) + 1;
        !          8691:                                if (buf)
        !          8692:                                {
        !          8693:                                        if (len < namlen) ERROR(ERANGE);
        !          8694:                                }
        !          8695:                                else if (!(buf = malloc(namlen + len))) ERROR(ENOMEM);
        !          8696:                                return(memcpy(buf, p, namlen));
        !          8697:                        }
        !          8698:                }
        !          8699:        }
        !          8700:        if (!buf)
        !          8701:        {
        !          8702:                extra = len;
        !          8703:                len = PATH_MAX;
        !          8704:                if (!(buf = malloc(len + extra))) ERROR(ENOMEM);
        !          8705:        }
        !          8706:        d = dots;
        !          8707:        p = buf + len - 1;
        !          8708:        *p = 0;
        !          8709:        n = elements(env);
        !          8710:        for (;;)
        !          8711:        {
        !          8712:                tmp = cur;
        !          8713:                cur = par;
        !          8714:                par = tmp;
        !          8715:                if ((d - dots) > (PATH_MAX - 4))
        !          8716:                {
        !          8717:                        if (!(dirstk = pushdir(dirstk, dots, p, buf + len - 1))) ERROR(ERANGE);
        !          8718:                        d = dots;
        !          8719:                }
        !          8720:                *d++ = '.';
        !          8721:                *d++ = '.';
        !          8722:                *d++ = '/';
        !          8723:                *d = 0;
        !          8724:                if (!(dirp = opendir(dots)) || fstat(dirp->dd_fd, par)) ERROR(errno);
        !          8725:                if (par->st_dev == cur->st_dev)
        !          8726:                {
        !          8727:                        if (par->st_ino == cur->st_ino)
        !          8728:                        {
        !          8729:                                closedir(dirp);
        !          8730:                                *--p = '/';
        !          8731:                        pop:
        !          8732:                                if (p != buf)
        !          8733:                                {
        !          8734:                                        d = buf;
        !          8735:                                        while (*d++ = *p++);
        !          8736:                                        len = d - buf;
        !          8737:                                        if (extra >= 0 && !(buf = realloc(buf, len + extra))) ERROR(ENOMEM);
        !          8738:                                }
        !          8739:                                if (dirstk && popdir(dirstk, buf + len - 1))
        !          8740:                                {
        !          8741:                                        dirstk = 0;
        !          8742:                                        ERROR(errno);
        !          8743:                                }
        !          8744:                                return(buf);
        !          8745:                        }
        !          8746:                        while (entry = readdir(dirp))
        !          8747:                                if (entry->d_ino == cur->st_ino)
        !          8748:                                {
        !          8749:                                        namlen = DIRNAMLEN(entry);
        !          8750:                                        goto found;
        !          8751:                                }
        !          8752: 
        !          8753:                        /*
        !          8754:                         * this fallthrough handles logical naming
        !          8755:                         */
        !          8756: 
        !          8757:                        rewinddir(dirp);
        !          8758:                }
        !          8759:                do
        !          8760:                {
        !          8761:                        if (!(entry = readdir(dirp))) ERROR(ENOENT);
        !          8762:                        namlen = DIRNAMLEN(entry);
        !          8763:                        if ((d - dots) > (PATH_MAX - 1 - namlen))
        !          8764:                        {
        !          8765:                                *d = 0;
        !          8766:                                if (namlen >= PATH_MAX || !(dirstk = pushdir(dirstk, dots + 3, p, buf + len - 1))) ERROR(ERANGE);
        !          8767:                                d = dots + 3;
        !          8768:                        }
        !          8769:                        (void)memcpy(d, entry->d_name, namlen + 1);
        !          8770:                        if (stat(dots, &tstst)) ERROR(errno);
        !          8771:                } while (tstst.st_ino != cur->st_ino || tstst.st_dev != cur->st_dev);
        !          8772:        found:
        !          8773:                if (*p) *--p = '/';
        !          8774:                while ((p -= namlen) <= (buf + 1))
        !          8775:                {
        !          8776:                        x = (buf + len - 1) - (p += namlen);
        !          8777:                        s = buf + len;
        !          8778:                        if (extra < 0 || !(buf = realloc(buf, (len += PATH_MAX) + extra))) ERROR(ERANGE);
        !          8779:                        p = buf + len;
        !          8780:                        while (p > buf + len - 1 - x) *--p = *--s;
        !          8781:                }
        !          8782:                if (n < elements(env))
        !          8783:                {
        !          8784:                        (void)memcpy(p, env[n].path, namlen);
        !          8785:                        goto pop;
        !          8786:                }
        !          8787:                (void)memcpy(p, entry->d_name, namlen);
        !          8788:                closedir(dirp);
        !          8789:                dirp = 0;
        !          8790:                for (n = 0; n < elements(env); n++)
        !          8791:                        if (env[n].ino == (unsigned long)par->st_ino && env[n].dev == par->st_dev)
        !          8792:                        {
        !          8793:                                namlen = strlen(env[n].path);
        !          8794:                                goto found;
        !          8795:                        }
        !          8796:        }
        !          8797:  error:
        !          8798:        if (buf)
        !          8799:        {
        !          8800:                if (dirstk) (void)popdir(dirstk, buf + len - 1);
        !          8801:                if (extra >= 0) free(buf);
        !          8802:        }
        !          8803:        if (dirp) closedir(dirp);
        !          8804:        return(0);
        !          8805: }
        !          8806: 
        !          8807: /*
        !          8808:  * push long dir component onto stack
        !          8809:  */
        !          8810: 
        !          8811: static struct dirlist*
        !          8812: pushdir(d, dots, path, end)
        !          8813: register struct dirlist*       d;
        !          8814: char*                          dots;
        !          8815: char*                          path;
        !          8816: char*                          end;
        !          8817: {
        !          8818:        register struct dirlist*        p;
        !          8819: 
        !          8820:        if (!(p = (struct dirlist*)malloc(sizeof(struct dirlist))) || chdir(dots))
        !          8821:        {
        !          8822:                if (p) free(p);
        !          8823:                if (d) (void)popdir(d, end);
        !          8824:                return(0);
        !          8825:        }
        !          8826:        p->index = end - path;
        !          8827:        p->next = d;
        !          8828:        return(p);
        !          8829: }
        !          8830: 
        !          8831: /*
        !          8832:  * pop long dir component chdir stack
        !          8833:  */
        !          8834: 
        !          8835: static int
        !          8836: popdir(d, end)
        !          8837: register struct dirlist*       d;
        !          8838: register char*                 end;
        !          8839: {
        !          8840:        register struct dirlist*        dp;
        !          8841:        int                             v;
        !          8842: 
        !          8843:        v = 0;
        !          8844:        while (dp = d)
        !          8845:        {
        !          8846:                d = d->next;
        !          8847:                if (!v)
        !          8848:                {
        !          8849:                        if (d) *(end - d->index - 1) = 0;
        !          8850:                        v = chdir(end - dp->index);
        !          8851:                        if (d) *(end - d->index - 1) = '/';
        !          8852:                }
        !          8853:                free(dp);
        !          8854:        }
        !          8855:        return(v);
        !          8856: }
        !          8857: 0707070000000001341006440044230044230000010000000434065551000003400000000673misc/getnamval.cUgsfGgsf/*
        !          8858:  * Glenn Fowler
        !          8859:  * AT&T Bell Laboratories
        !          8860:  */
        !          8861: 
        !          8862: #include <namval.h>
        !          8863: 
        !          8864: #define streq(a,b)     (*(a)==*(b)&&!strcmp(a,b))
        !          8865: 
        !          8866: extern int             strcmp();
        !          8867: 
        !          8868: /*
        !          8869:  * return value for name in tab
        !          8870:  *
        !          8871:  * the last name in tab must be 0
        !          8872:  * the last value in tab is returned if name is not found
        !          8873:  */
        !          8874: 
        !          8875: int
        !          8876: getnamval(tab, name)
        !          8877: register struct namval*        tab;
        !          8878: register char*         name;
        !          8879: {
        !          8880:        for (; tab->name; tab++)
        !          8881:                if (streq(tab->name, name))
        !          8882:                        break;
        !          8883:        return(tab->value);
        !          8884: }
        !          8885: 0707070000000001351006440044230044230000010000000471351750400003300000002221misc/getshell.cUgsfGgsf/*
        !          8886:  * G. S. Fowler
        !          8887:  * D. G. Korn
        !          8888:  * AT&T Bell Laboratories
        !          8889:  *
        !          8890:  * shell library support
        !          8891:  */
        !          8892: 
        !          8893: extern char*   getenv();
        !          8894: extern char*   strrchr();
        !          8895: 
        !          8896: extern int     access();
        !          8897: extern int     geteuid();
        !          8898: extern int     getegid();
        !          8899: extern int     getgid();
        !          8900: extern int     getuid();
        !          8901: extern int     strmatch();
        !          8902: 
        !          8903: /*
        !          8904:  * return pointer to the full path name of the shell
        !          8905:  *
        !          8906:  * SHELL is read from the environment and must start with /
        !          8907:  *
        !          8908:  * if set-uid or set-gid then the executable and its containing
        !          8909:  * directory must not be writable by the real user
        !          8910:  *
        !          8911:  * /bin/sh is returned by default
        !          8912:  *
        !          8913:  * NOTE: csh is rejected because the bsh/csh differentiation is
        !          8914:  *       not done for `csh script arg ...'
        !          8915:  */
        !          8916: 
        !          8917: char*
        !          8918: getshell()
        !          8919: {
        !          8920:        register char*  s;
        !          8921:        register char*  sh;
        !          8922:        register int    i;
        !          8923: 
        !          8924:        if ((sh = getenv("SHELL")) && *sh == '/' && strmatch(sh, "*/(sh|*[!cC]sh)"))
        !          8925:        {
        !          8926:                if (!(i = getuid()))
        !          8927:                {
        !          8928:                        if (!strmatch(sh, "?(/usr)?(/local)/?(l)bin/?([a-z])sh")) goto defshell;
        !          8929:                }
        !          8930:                else if (i != geteuid() || getgid() != getegid())
        !          8931:                {
        !          8932:                        if (!access(sh, 2)) goto defshell;
        !          8933:                        s = strrchr(sh, '/');
        !          8934:                        *s = 0;
        !          8935:                        i = access(sh, 2);
        !          8936:                        *s = '/';
        !          8937:                        if (!i) goto defshell;
        !          8938:                }
        !          8939:                return(sh);
        !          8940:        }
        !          8941:  defshell:
        !          8942:        return("/bin/sh");
        !          8943: }
        !          8944: 0707070000000001361006440044230044230000010000000475326201600003500000002450misc/getsymlink.cUgsfGgsf/*
        !          8945: * G. S. Fowler
        !          8946: * AT&T Bell Laboratories
        !          8947: */
        !          8948: 
        !          8949: #include "univlib.h"
        !          8950: 
        !          8951: #ifdef UNIV_MAX
        !          8952: 
        !          8953: #include <ctype.h>
        !          8954: 
        !          8955: #endif
        !          8956: 
        !          8957: extern int     readlink();
        !          8958: 
        !          8959: /*
        !          8960:  * return external representation for symbolic link text of name in buf
        !          8961:  * the link text string length is returned
        !          8962:  */
        !          8963: 
        !          8964: int
        !          8965: getsymlink(name, buf, siz)
        !          8966: char*  name;
        !          8967: char*  buf;
        !          8968: int    siz;
        !          8969: {
        !          8970:        int     n;
        !          8971: 
        !          8972:        if ((n = readlink(name, buf, siz)) < 0) return(-1);
        !          8973:        if (n >= siz)
        !          8974:        {
        !          8975:                errno = EINVAL;
        !          8976:                return(-1);
        !          8977:        }
        !          8978:        buf[n] = 0;
        !          8979: #ifdef UNIV_MAX
        !          8980:        if (isspace(*buf))
        !          8981:        {
        !          8982:                register char*  s;
        !          8983:                register char*  t;
        !          8984:                register char*  u;
        !          8985:                register char*  v;
        !          8986:                int             match = 0;
        !          8987:                char            tmp[PATH_MAX];
        !          8988: 
        !          8989:                extern char*    strcpy();
        !          8990: 
        !          8991:                s = buf;
        !          8992:                t = tmp;
        !          8993:                while (isalnum(*++s) || *s == '_' || *s == '.');
        !          8994:                if (*s++)
        !          8995:                {
        !          8996:                        for (;;)
        !          8997:                        {
        !          8998:                                if (!*s || isspace(*s))
        !          8999:                                {
        !          9000:                                        if (match)
        !          9001:                                        {
        !          9002:                                                *t = 0;
        !          9003:                                                n = t - tmp;
        !          9004:                                                (void)strcpy(buf, tmp);
        !          9005:                                        }
        !          9006:                                        break;
        !          9007:                                }
        !          9008:                                if (t >= &tmp[sizeof(tmp)]) break;
        !          9009:                                *t++ = *s++;
        !          9010:                                if (!match && t < &tmp[sizeof(tmp) - univ_size + 1]) for (n = 0; n < UNIV_MAX; n++)
        !          9011:                                {
        !          9012:                                        if (*(v = s - 1) == *(u = univ_name[n]))
        !          9013:                                        {
        !          9014:                                                while (*u && *v++ == *u) u++;
        !          9015:                                                if (!*u)
        !          9016:                                                {
        !          9017:                                                        match = 1;
        !          9018:                                                        (void)strcpy(t - 1, univ_cond);
        !          9019:                                                        t += univ_size - 1;
        !          9020:                                                        s = v;
        !          9021:                                                        break;
        !          9022:                                                }
        !          9023:                                        }
        !          9024:                                }
        !          9025:                        }
        !          9026:                }
        !          9027:        }
        !          9028: #endif
        !          9029:        return(n);
        !          9030: }
        !          9031: 0707070000000001371006440044230044230000010000000475326710200003200000001221misc/getuniv.cUgsfGgsf/*
        !          9032:  * G. S. Fowler
        !          9033:  * AT&T Bell Laboratories
        !          9034:  *
        !          9035:  * universe support
        !          9036:  */
        !          9037: 
        !          9038: #include "univlib.h"
        !          9039: 
        !          9040: int
        !          9041: getuniv(buf)
        !          9042: char*  buf;
        !          9043: {
        !          9044: #if _lib_getuniverse
        !          9045:        return(getuniverse(buf));
        !          9046: #else
        !          9047: #ifndef UNIV_MAX
        !          9048:        register char*  s;
        !          9049: 
        !          9050:        extern char*    getenv();
        !          9051: 
        !          9052:        if ((s = getenv(univ_env)) && *s)
        !          9053:        {
        !          9054:                (void)strncpy(buf, s, UNIV_SIZE - 1);
        !          9055:                buf[UNIV_SIZE - 1] = 0;
        !          9056:                return(0);
        !          9057:        }
        !          9058: #else
        !          9059: #ifdef ATT_UNIV
        !          9060:        register int    n;
        !          9061: 
        !          9062:        if ((n = setuniverse(ATT_UNIV)) < 0) return(-1);
        !          9063:        (void)setuniverse(n);
        !          9064:        if (n >= 1 && n <= UNIV_MAX)
        !          9065:        {
        !          9066:                (void)strncpy(buf, univ_name[n - 1], UNIV_SIZE - 1);
        !          9067:                buf[UNIV_SIZE - 1] = 0;
        !          9068:                return(0);
        !          9069:        }
        !          9070: #endif
        !          9071: #endif
        !          9072:        errno = EINVAL;
        !          9073:        return(-1);
        !          9074: #endif
        !          9075: }
        !          9076: 0707070000000001401006440044230044230000010000000467174004300003000000000423misc/getwd.cUgsfGgsf/*
        !          9077:  * getwd() using getcwd()
        !          9078:  *
        !          9079:  * some getwd()'s are incredible
        !          9080:  */
        !          9081: 
        !          9082: #include <limits.h>
        !          9083: 
        !          9084: #ifndef PATH_MAX
        !          9085: #define PATH_MAX       1024
        !          9086: #endif
        !          9087: 
        !          9088: char*
        !          9089: getwd(path)
        !          9090: char*  path;
        !          9091: {
        !          9092:        if (getcwd(path, PATH_MAX)) return(path);
        !          9093:        (void)strcpy(path, "getwd: error in . or ..");
        !          9094:        return(0);
        !          9095: }
        !          9096: 0707070000000001411006440044230044230000010000000430010751100003000000001041misc/hsort.cUgsfGgsf/*
        !          9097:  *  hsort - sort an array pointers using fn
        !          9098:  *
        !          9099:  *     fn follows strcmp(3) conventions
        !          9100:  *
        !          9101:  *   David Korn
        !          9102:  *   AT&T Bell Laboratories
        !          9103:  *
        !          9104:  *  derived from Bourne Shell
        !          9105:  */
        !          9106: 
        !          9107: void
        !          9108: hsort(argv,n,fn)
        !          9109: char *argv[];
        !          9110: int (*fn)();
        !          9111: {
        !          9112:        register int    i, j, m;
        !          9113:        int  k;
        !          9114:        for(j=1; j<=n; j*=2);
        !          9115:        for(m=2*j-1; m/=2;)
        !          9116:        {
        !          9117:                k=n-m;
        !          9118:                for(j=0; j<k; j++)
        !          9119:                {
        !          9120:                        for(i=j; i>=0; i-=m)
        !          9121:                        {
        !          9122:                                register char **ap;
        !          9123:                                ap = &argv[i];
        !          9124:                                if((*fn)(ap[m],ap[0])>=0)
        !          9125:                                        break;
        !          9126:                                else
        !          9127:                                {
        !          9128:                                        char *s;
        !          9129:                                        s=ap[m];
        !          9130:                                        ap[m]=ap[0];
        !          9131:                                        ap[0]=s;
        !          9132:                                }
        !          9133:                        }
        !          9134:                }
        !          9135:        }
        !          9136: }
        !          9137: 0707070000000001421006440044230044230000010000000475446533500003300000000722misc/liberror.cUgsfGgsf/*
        !          9138:  * G. S. Fowler
        !          9139:  * AT&T Bell Laboratories
        !          9140:  *
        !          9141:  * library error handler
        !          9142:  */
        !          9143: 
        !          9144: #include <error.h>
        !          9145: 
        !          9146: #if __STDC__
        !          9147: 
        !          9148: #include <stdarg.h>
        !          9149: 
        !          9150: void
        !          9151: liberror(const char* lib, int level, ...)
        !          9152: 
        !          9153: #else
        !          9154: 
        !          9155: #include <varargs.h>
        !          9156: 
        !          9157: void
        !          9158: liberror(va_alist)
        !          9159: va_dcl
        !          9160: 
        !          9161: #endif
        !          9162: 
        !          9163: {
        !          9164:        va_list ap;
        !          9165: #if !__STDC__
        !          9166:        char*   lib;
        !          9167:        int     level;
        !          9168: #endif
        !          9169: 
        !          9170: #if __STDC__
        !          9171:        va_start(ap, level);
        !          9172: #else
        !          9173:        va_start(ap);
        !          9174:        lib = va_arg(ap, char*);
        !          9175:        level = va_arg(ap, int);
        !          9176: #endif
        !          9177:        verror(lib, level, ap);
        !          9178:        va_end(ap);
        !          9179: }
        !          9180: 0707070000000001431006440044230044230000010000000453044200400003100000000502misc/lpstat.cUgsfGgsf#include <sys/types.h>
        !          9181: #include <sys/stat.h>
        !          9182: 
        !          9183: extern int     errno;
        !          9184: 
        !          9185: /*
        !          9186:  * physical stat if logical fails
        !          9187:  */
        !          9188: 
        !          9189: int
        !          9190: lpstat(path, st)
        !          9191: char*          path;
        !          9192: struct stat*   st;
        !          9193: {
        !          9194: #ifdef S_IFLNK
        !          9195:        int     oerrno;
        !          9196: 
        !          9197:        oerrno = errno;
        !          9198:        if (!stat(path, st)) return(0);
        !          9199:        errno = oerrno;
        !          9200:        return(lstat(path, st));
        !          9201: #else
        !          9202:        return(stat(path, st));
        !          9203: #endif
        !          9204: }
        !          9205: 0707070000000001441006440044230044230000010000000472744000200003100000053613misc/malloc.cUgsfGgsf#if cray
        !          9206: 
        !          9207: /* Phong needs to figure this one out */
        !          9208: 
        !          9209: int    _lib_dummy;
        !          9210: 
        !          9211: #else /* cray */
        !          9212: 
        !          9213: /**********************************************************************
        !          9214:        Memory management: malloc(), realloc(), free(), M_brksize.
        !          9215:        M_brksize: if > 0 is the maximum amount that the bottom free
        !          9216:                block can grow to. If not SEGMENT, GETCORE() will
        !          9217:                be used to compact bottom space.
        !          9218: 
        !          9219:        The following #-parameters may be redefined:
        !          9220:        SEGMENT: if defined, memory requests are assumed to be
        !          9221:                non-contiguous across calls of GETCORE's. SEGMENT defines
        !          9222:                the size of each GETCORE request.
        !          9223:        CORESIZE: min number of bytes to used with GETCORE.
        !          9224:                On a SEGMENT machine, this should be defined
        !          9225:                as the size of a segment. Default is 4096.
        !          9226:        GETCORE: a function to get more core memory. If not SEGMENT,
        !          9227:                GETCORE(0) is assumed to return the next available
        !          9228:                address. Default is 'sbrk'.
        !          9229:        ERRCORE: the error code as returned by GETCORE.
        !          9230:                Default is ((char*)(-1)).
        !          9231:        MTRACE: if #define-d, code is included to trace and certify that
        !          9232:                malloc-ed blocks are not corrupted. Available functions
        !          9233:                and variables:
        !          9234:                int (*Mt_corrupt)(addr,size,stamp)
        !          9235:                        The function called when a corrupted block is detected.
        !          9236:                                addr: address of the corrupted block
        !          9237:                                size: size of the block.
        !          9238:                                stamp: a user/program-defined stamp (below).
        !          9239:                        If Mt_corrupt is NULL, a default function is used.
        !          9240:                Mt_certify: if not 0, indicates that the arena should
        !          9241:                        be automatically certified on each call to malloc,
        !          9242:                        realloc, or free. Default is 0.
        !          9243:                Mt_trace: if >= 0, is the file descriptor to write out
        !          9244:                        a trace of all calls to malloc, free, realloc.
        !          9245:                        Default is -1.
        !          9246:                mt_stamp(VOID *data, VOID *stamp)
        !          9247:                        Set a stamp for a malloc-ed block. This stamp is used
        !          9248:                        in (*corrupt)() calls. For example, a stamp may be
        !          9249:                        an indicator of the place where malloc was called.
        !          9250:                mt_certify()
        !          9251:                        Check all blocks to see if they are ok. If a block is
        !          9252:                        corrupted, (*corrupt)() is called as above.
        !          9253:                mt_stat(int fd)
        !          9254:                        Print arena statistics.
        !          9255: 
        !          9256:        With minor variations, the basic allocation strategy is best-fit.
        !          9257:        Lists of free blocks of the same size are kept in a splay tree.
        !          9258:        For results on splay trees, see:
        !          9259:                Self-Adjusting Binary Trees,
        !          9260:                DD Sleator & RE Tarjan, JACM 1985.
        !          9261: 
        !          9262:        The header of a block contains the size of the data part in bytes.
        !          9263:        Since the size of a block is 0%4, the low two bits of the header
        !          9264:        are free and used as follows:
        !          9265:                BIT0:   1 for busy (block is in use), 0 for free.
        !          9266:                BIT1:   if the block is busy, this bit is 1 if the
        !          9267:                        preceding block in contiguous memory is free.
        !          9268:                        Otherwise, it is always 0.
        !          9269: 
        !          9270:        Kiem-Phong Vo, AT&T Bell Laboratories
        !          9271: **********************************************************************/
        !          9272: 
        !          9273: int    M_brksize;      /* the max size for Bottom */
        !          9274: 
        !          9275: /* debugging macros */
        !          9276: #ifdef DEBUG
        !          9277: #define VOID           unsigned char
        !          9278: #define        ASSERT(p)       ((void) ((p) ? 0 : (abort(),0)))
        !          9279: #define COUNT(n)       ((void) ((n) += 1))
        !          9280: #define DISCOUNT(n)    ((void) ((n) -= 1))
        !          9281: static int             N_malloc, N_realloc, N_free, N_block, N_list;
        !          9282: #else
        !          9283: #define VOID           char
        !          9284: #define        ASSERT(p)
        !          9285: #define COUNT(n)
        !          9286: #define DISCOUNT(n)
        !          9287: #endif /*DEBUG*/
        !          9288: 
        !          9289: /* system call to get more core */
        !          9290: #ifdef SEGMENT
        !          9291: #define CORESIZE       SEGMENT
        !          9292: #else
        !          9293: #define CORESIZE       (4096)
        !          9294: #endif
        !          9295: #define GETCORE                sbrk
        !          9296: #define ERRCORE                ((VOID*)(-1))
        !          9297: extern VOID    *GETCORE(), *malloc(), *realloc();
        !          9298: extern void    free();
        !          9299: 
        !          9300: /* function to copy data from one area to another */
        !          9301: #include "FEATURE/bcopy"
        !          9302: #ifdef _lib_bcopy
        !          9303: #undef memcpy
        !          9304: #define memcpy(to,fr,n)                bcopy(fr,to,n)
        !          9305: #endif
        !          9306: 
        !          9307: /* for conveniences */
        !          9308: #define reg            register
        !          9309: #define uchar          unsigned char
        !          9310: #define uint           unsigned int
        !          9311: #define NULL           (0L)
        !          9312: #define NIL(p)         ((p)(NULL))
        !          9313: #define MINSIZE                ((int)(sizeof(TREE)-sizeof(WORD)))
        !          9314: #define ROUND(x,y)     ((((x)+((y)-1))/(y))*(y))
        !          9315: 
        !          9316: /* the following structures are used to compute a suitable alignment for all types */
        !          9317: typedef union _u_
        !          9318: {
        !          9319:        int     i;
        !          9320:        VOID*   s;
        !          9321:        double  d;
        !          9322:        VOID    big[1024];
        !          9323: } _ua_;
        !          9324: typedef struct _s_
        !          9325: {
        !          9326:        VOID    c;
        !          9327:        _ua_    u;
        !          9328: } _sa_;
        !          9329: #define ALIGN          ((int)(sizeof(_sa_) - sizeof(_ua_)))
        !          9330: #define WORDSIZE        ROUND((int)ALIGN,4)
        !          9331: 
        !          9332: typedef union _w_
        !          9333: {      /* the proto-word */
        !          9334:        uint            w_i;            /* an int */
        !          9335:        struct _t_      *w_p;           /* a pointer */
        !          9336:        VOID            w_a[ALIGN];     /* to force alignment */
        !          9337: } WORD;
        !          9338: 
        !          9339: typedef struct _t_
        !          9340: {      /* structure of a node in the free tree */
        !          9341:        WORD    t_s;    /* size of this element */
        !          9342:        WORD    t_n;    /* next in link list */
        !          9343:        WORD    t_l;    /* left child */
        !          9344:        WORD    t_r;    /* right child */
        !          9345:        WORD    t_d;    /* dummy to reserve space for self-pointer */
        !          9346: } TREE;
        !          9347: 
        !          9348: /* usable # of bytes in the block */
        !          9349: #define SIZE(b)                (((b)->t_s).w_i)
        !          9350: 
        !          9351: /* free tree pointers */
        !          9352: #define LEFT(b)                (((b)->t_l).w_p)
        !          9353: #define RIGHT(b)       (((b)->t_r).w_p)
        !          9354: 
        !          9355: /* links in linked lists */
        !          9356: #define LINK(b)                (((b)->t_n).w_p)
        !          9357: #define BACK(b)                (((b)->t_l).w_p)
        !          9358: 
        !          9359: /* set/test indicator to see if a block is in the tree or in a list */
        !          9360: #define SETNOTREE(b)   (RIGHT(b) = (TREE*)(~0))
        !          9361: #define ISNOTREE(b)    (RIGHT(b) == (TREE*)(~0))
        !          9362: 
        !          9363: /* functions to get information on a block */
        !          9364: #define DATA(b)                (((VOID*) (b)) + WORDSIZE)
        !          9365: #define BLOCK(d)       ((TREE*) ((d) - WORDSIZE))
        !          9366: #define SELFP(b)       ((TREE**) (((VOID*) (b)) + SIZE(b)))
        !          9367: #define LAST(b)                (*((TREE**) (((VOID*) (b)) - WORDSIZE)))
        !          9368: #define NEXT(b)                ((TREE*) (((VOID*) (b)) + SIZE(b) + WORDSIZE))
        !          9369: #define BOTTOM(b)      ((DATA(b)+SIZE(b)+WORDSIZE) == Baddr)
        !          9370: 
        !          9371: /* functions to set and test the lowest two bits of a word */
        !          9372: #define        BIT0            (01)    /* ....01 */
        !          9373: #define BIT1           (02)    /* ...010 */
        !          9374: #define BITS01         (03)    /* ...011 */
        !          9375: #define ISBIT0(w)      ((w) & BIT0)
        !          9376: #define ISBIT1(w)      ((w) & BIT1)
        !          9377: #define        SETBIT0(w)      ((w) |= BIT0)
        !          9378: #define SETBIT1(w)     ((w) |= BIT1)
        !          9379: #define CLRBIT0(w)     ((w) &= ~BIT0)
        !          9380: #define CLRBIT1(w)     ((w) &= ~BIT1)
        !          9381: #define ISBITS01(w)    ((w) & BITS01)
        !          9382: #define SETBITS01(w)   ((w) |= BITS01)
        !          9383: #define CLRBITS01(w)   ((w) &= ~BITS01)
        !          9384: #define CPYBITS01(w,f) ((w) |= (f)&BITS01)
        !          9385: 
        !          9386: static TREE    *Root,          /* root of the free tree */
        !          9387:                *Bottom,        /* the last free chunk in the arena */
        !          9388:                *morecore(),    /* function to get more core */
        !          9389:                *t_search();    /* to look for a free block */
        !          9390: 
        !          9391: static VOID    *Baddr,         /* current high address of the arena */
        !          9392:                *Lfree,         /* last free block with data intact */
        !          9393:                *Nofree;        /* this block is not to be freed */
        !          9394: 
        !          9395: /* lists of small blocks */
        !          9396: #define LGET   16
        !          9397: static TREE    *List[(MINSIZE-WORDSIZE)/WORDSIZE];
        !          9398: 
        !          9399: /* circular queue of delayed free blocks */
        !          9400: #define QSIZE  (1<<8)
        !          9401: #define QMASK  (QSIZE-1)
        !          9402: static VOID    **Qfree;
        !          9403: static int     Qhead = -1, Qtail = 0;
        !          9404: #define CYCLE(n)       (n = (n+1)&QMASK)
        !          9405: #define REWIND(n)      (n = (n+QMASK)&QMASK)
        !          9406: #define QVOID()                (Qhead < 0)
        !          9407: #define QFULL()                (Qtail == Qhead)
        !          9408: #define QENDADD()      (Qhead < 0 ? (Qhead = 0) : 0)
        !          9409: #define QENDDEL()      (Qtail == Qhead ? (Qhead = -1, Qtail = 0) : 0)
        !          9410: #define ENQUEUE(x)     ((Qfree[Qtail] = (x)), CYCLE(Qtail), QENDADD())
        !          9411: #define DEQUEUE(x)     (((x) = Qfree[Qhead]), CYCLE(Qhead), QENDDEL())
        !          9412: #define DESTACK(x)     (REWIND(Qtail), ((x) = Qfree[Qtail]), QENDDEL())
        !          9413: 
        !          9414: /*
        !          9415: **     Coalesce adjacent blocks and free left-over memory.
        !          9416: */
        !          9417: #define UNLINK(u)      { if(LINK(u)) \
        !          9418:                                BACK(LINK(u)) = BACK(u); \
        !          9419:                          LINK(BACK(u)) = LINK(u);      /**/ DISCOUNT(N_block); \
        !          9420:                        }
        !          9421: #define FMERGE(t,n)    { n = NEXT(t); \
        !          9422:                          if(!ISBIT0(SIZE(n))) \
        !          9423:                          {     if(n != Bottom) \
        !          9424:                                {       if(!ISNOTREE(n)) \
        !          9425:                                                t_search(SIZE(n)); \
        !          9426:                                        else    UNLINK(n); \
        !          9427:                                } \
        !          9428:                                else    Bottom = NIL(TREE*); \
        !          9429:                                SIZE(t) += SIZE(n)+WORDSIZE; \
        !          9430:                                CLRBIT1(SIZE(NEXT(t))); \
        !          9431:                                /**/ ASSERT(ISBIT0(SIZE(NEXT(t)))); \
        !          9432:                          } \
        !          9433:                        }
        !          9434: #define BMERGE(t,n)    { n = LAST(t); \
        !          9435:                          if(!ISNOTREE(n)) \
        !          9436:                                t_search(SIZE(n)); \
        !          9437:                          else  UNLINK(n); \
        !          9438:                          SIZE(n) += SIZE(t)+WORDSIZE; \
        !          9439:                          t = n; \
        !          9440:                        }
        !          9441: #define FREE(f)                { if(BOTTOM(f)) \
        !          9442:                                Bottom = f; \
        !          9443:                          else \
        !          9444:                          {     SETBIT0(SIZE(f)); /**/ ASSERT(!Lfree); \
        !          9445:                                Lfree = DATA(f); \
        !          9446:                          } \
        !          9447:                        }
        !          9448: /*
        !          9449: ** Trace malloc/free patterns.
        !          9450: */
        !          9451: #ifdef MTRACE
        !          9452: #define MTNONE         0
        !          9453: #define MTFREE         1
        !          9454: #define MTMALLOC       2
        !          9455: #define MTREALLOC      3
        !          9456: #define MTSPACE                (3*WORDSIZE)
        !          9457: #define MTSIZE(b)      (SIZE(b)&(~BITS01))
        !          9458: #define MTNEXT(b)      ((TREE*)(DATA(b) + MTSIZE(b)))
        !          9459: #define USIZE(b)       (*((uint*)(DATA(b)+MTSIZE(b)-(2*WORDSIZE))))
        !          9460: #define USTAMP(b)      (*((VOID**)(DATA(b)+MTSIZE(b)-WORDSIZE)))
        !          9461: #define MTSETFREE(b)   (USTAMP(b) = (VOID*)(~0))
        !          9462: #define MTISFREE(b)    (!ISBITS01(SIZE(b)) || USTAMP(b) == (VOID*)(~0))
        !          9463: #define SMAGIC(b)      ((uchar*)(DATA(b)+USIZE(b)))
        !          9464: #define EMAGIC(b)      ((uchar*)(DATA(b)+MTSIZE(b)-(2*WORDSIZE)))
        !          9465: #define MAGIC          0253    /* 10101011 pattern */
        !          9466: 
        !          9467: static VOID    *Laddr;         /* low address of the arena */
        !          9468: int    (*Mt_corrupt)();        /* function to process corrupted blocks */
        !          9469: int    Mt_certify;             /* automatically certify the arena */
        !          9470: int    Mt_trace = -1;          /* print trace of mallocs and frees */
        !          9471: 
        !          9472: /* Convert an int to a string */
        !          9473: static itoa(i,buf)
        !          9474: reg uint       i;
        !          9475: reg char       *buf;
        !          9476: {
        !          9477:        reg int k, c;
        !          9478: 
        !          9479:        k = 0;
        !          9480:        do
        !          9481:        {
        !          9482:                buf[k++] = '0' + i%10;
        !          9483:                i /= 10;
        !          9484:        }       while(i != 0);
        !          9485:        buf[k] = '\0';
        !          9486:        for(i = 0; i < k/2; ++i)
        !          9487:        {
        !          9488:                c = buf[i];
        !          9489:                buf[i] = buf[(k-i)-1];
        !          9490:                buf[(k-i)-1] = c;
        !          9491:        }
        !          9492: }
        !          9493: 
        !          9494: /* internal function for warning on corruption */
        !          9495: static int mt_corrupt(addr,usize,stamp)
        !          9496: reg VOID       *addr;
        !          9497: reg uint       usize;
        !          9498: reg VOID       *stamp;
        !          9499: {
        !          9500:        char    buf[64], *mesg;
        !          9501: 
        !          9502:        mesg = "corrupt:addr=";
        !          9503:        write(2,mesg,strlen(mesg));
        !          9504:        itoa((uint)addr,buf);
        !          9505:        write(2,buf,strlen(buf));
        !          9506: 
        !          9507:        mesg = ":size=";
        !          9508:        write(2,mesg,strlen(mesg));
        !          9509:        itoa(usize,buf);
        !          9510:        write(2,buf,strlen(buf));
        !          9511: 
        !          9512:        mesg = ":stamp=";
        !          9513:        write(2,mesg,strlen(mesg));
        !          9514:        itoa((uint)stamp,buf);
        !          9515:        write(2,buf,strlen(buf));
        !          9516: 
        !          9517:        write(2,"\n",1);
        !          9518: }
        !          9519: 
        !          9520: /* Print trace information */
        !          9521: static mt_trace(addr,type)
        !          9522: reg VOID       *addr;
        !          9523: reg int                type;
        !          9524: {
        !          9525:        char    *mesg, buf[64];
        !          9526: 
        !          9527:        mesg =  type == MTMALLOC ? "malloc" : type == MTFREE ? "free" : "realloc";
        !          9528:        write(Mt_trace,mesg,strlen(mesg));
        !          9529: 
        !          9530:        mesg = ":addr=";
        !          9531:        write(Mt_trace,mesg,strlen(mesg));
        !          9532:        itoa((uint)addr,buf);
        !          9533:        write(Mt_trace,buf,strlen(buf));
        !          9534: 
        !          9535:        mesg = ":size=";
        !          9536:        write(Mt_trace,mesg,strlen(mesg));
        !          9537:        itoa(USIZE(BLOCK(addr)),buf);
        !          9538:        write(Mt_trace,buf,strlen(buf));
        !          9539: 
        !          9540:        write(Mt_trace,"\n",1);
        !          9541: }
        !          9542: 
        !          9543: /* Print a warning */
        !          9544: static mt_didfree(addr,type)
        !          9545: reg VOID       *addr;
        !          9546: reg int                type;
        !          9547: {
        !          9548:        char    *mesg, buf[64];
        !          9549: 
        !          9550:        mesg = type == MTFREE ? "free:addr=" : "realloc:addr=";
        !          9551:        write(2,mesg,strlen(mesg));
        !          9552:        itoa((uint)addr,buf);
        !          9553:        write(2,buf,strlen(buf));
        !          9554:        mesg = ":already freed\n";
        !          9555:        write(2,mesg,strlen(mesg));
        !          9556: }
        !          9557: 
        !          9558: /* Set trace info for a block */
        !          9559: static mt_setinfo(bp,usize,type)
        !          9560: reg TREE       *bp;
        !          9561: reg uint       usize;
        !          9562: int            type;
        !          9563: {
        !          9564:        reg uchar       *magic, *emagic;
        !          9565: 
        !          9566:        USIZE(bp) = usize;
        !          9567:        USTAMP(bp) = NIL(VOID*);
        !          9568:        for(magic = SMAGIC(bp), emagic = EMAGIC(bp); magic < emagic; ++magic)
        !          9569:                *magic = MAGIC;
        !          9570: 
        !          9571:        if(Mt_trace >= 0 && type != MTNONE)
        !          9572:                mt_trace(DATA(bp),type);
        !          9573: }
        !          9574: 
        !          9575: /* Set a stamp */
        !          9576: mt_stamp(addr,stamp)
        !          9577: reg VOID       *addr, *stamp;
        !          9578: {
        !          9579:        USTAMP(BLOCK(addr)) = stamp;
        !          9580: }
        !          9581: 
        !          9582: /* Certify that no data block has been corrupted */
        !          9583: mt_certify()
        !          9584: {
        !          9585:        reg TREE        *bp, *endb;
        !          9586:        reg uchar       *magic, *endm;
        !          9587: 
        !          9588:        if(!Mt_corrupt)
        !          9589:                Mt_corrupt = mt_corrupt;
        !          9590: 
        !          9591:        for(bp = (TREE*)Laddr, endb = (TREE*) Baddr; bp < endb; bp = MTNEXT(bp))
        !          9592:        {
        !          9593:                if(MTISFREE(bp) || MTSIZE(bp) == 0)
        !          9594:                        continue;
        !          9595:                if(USIZE(bp) >= MTSIZE(bp))
        !          9596:                        (*Mt_corrupt)(DATA(bp),USIZE(bp),USTAMP(bp));
        !          9597:                else for(magic = SMAGIC(bp), endm = EMAGIC(bp); magic < endm; ++magic)
        !          9598:                        if(*magic != MAGIC)
        !          9599:                        {
        !          9600:                                (*Mt_corrupt)(DATA(bp),USIZE(bp),USTAMP(bp));
        !          9601:                                break;
        !          9602:                        }
        !          9603:        }
        !          9604: }
        !          9605: 
        !          9606: /* Print block statistics */
        !          9607: mt_stat(fd)
        !          9608: int    fd;
        !          9609: {
        !          9610:        reg TREE        *bp, *endb;
        !          9611:        reg uint        nbusy, sfree, sbusy, mbusy;
        !          9612:        char            buf[64], *mesg;
        !          9613: 
        !          9614:        nbusy = sfree = sbusy = mbusy = 0;
        !          9615:        for(bp = (TREE*)Laddr, endb = (TREE*) Baddr; bp < endb; bp = MTNEXT(bp))
        !          9616:        {
        !          9617:                if(MTISFREE(bp) || MTSIZE(bp) == 0)
        !          9618:                        sfree += MTSIZE(bp);
        !          9619:                else
        !          9620:                {
        !          9621:                        nbusy += 1;
        !          9622:                        sbusy += USIZE(bp);
        !          9623:                        mbusy += MTSIZE(bp);
        !          9624:                }
        !          9625:        }
        !          9626: 
        !          9627:        mesg="free_space=";
        !          9628:        write(fd,mesg,strlen(mesg));
        !          9629:        itoa(sfree,buf);
        !          9630:        write(fd,buf,strlen(buf));
        !          9631: 
        !          9632:        mesg=", busy_blocks=";
        !          9633:        write(fd,mesg,strlen(mesg));
        !          9634:        itoa(nbusy,buf);
        !          9635:        write(fd,buf,strlen(buf));
        !          9636: 
        !          9637:        mesg=", user_space=";
        !          9638:        write(fd,mesg,strlen(mesg));
        !          9639:        itoa(sbusy,buf);
        !          9640:        write(fd,buf,strlen(buf));
        !          9641: 
        !          9642:        mesg=", malloc_space=";
        !          9643:        write(fd,mesg,strlen(mesg));
        !          9644:        itoa(mbusy,buf);
        !          9645:        write(fd,buf,strlen(buf));
        !          9646: 
        !          9647:        write(fd,"\n",1);
        !          9648: }
        !          9649: #endif /* MTRACE */
        !          9650: 
        !          9651: /*
        !          9652: **     malloc().
        !          9653: */
        !          9654: VOID *malloc(size)
        !          9655: reg uint       size;
        !          9656: {
        !          9657:        reg TREE        *tp, *np, *fp;
        !          9658:        reg int         n, i;
        !          9659: #ifdef MTRACE
        !          9660:        /* save true size and make size large enough to hold our data */
        !          9661:        reg uint        mtsize = size;
        !          9662:        size = size <= (MINSIZE-MTSPACE) ? MINSIZE : size + MTSPACE;
        !          9663:        if(Mt_certify)
        !          9664:                mt_certify();
        !          9665: #endif
        !          9666:        /**/ COUNT(N_malloc);
        !          9667: 
        !          9668:        size = size == 0 ? WORDSIZE : ROUND(size,WORDSIZE);
        !          9669:        tp = NIL(TREE*);
        !          9670:        if(Lfree)
        !          9671:        {       /* see if the last free block can be used */
        !          9672:                fp = BLOCK(Lfree);
        !          9673:                Lfree = NIL(VOID*);
        !          9674:                n = SIZE(fp);
        !          9675:                CLRBITS01(SIZE(fp));
        !          9676:                if(SIZE(fp) == size)
        !          9677:                {       /* exact match, use it as is */
        !          9678:                        SIZE(fp) = n;
        !          9679:                        if(!QVOID())
        !          9680:                                DESTACK(Lfree);
        !          9681: #ifdef MTRACE
        !          9682:                        mt_setinfo(fp,mtsize,MTMALLOC);
        !          9683: #endif
        !          9684:                        return DATA(fp);
        !          9685:                }
        !          9686:                else if(n >= MINSIZE && size >= MINSIZE && !ISBIT1(n))
        !          9687:                {       /* see if good enough */
        !          9688:                        FMERGE(fp,np);
        !          9689:                        if(!BOTTOM(fp) && SIZE(fp) >= size)
        !          9690:                                tp = fp;
        !          9691:                }
        !          9692:                else    SIZE(fp) = n;
        !          9693:                if(!tp)
        !          9694:                        free(Lfree = DATA(fp));
        !          9695:        }
        !          9696: 
        !          9697:        if(size < MINSIZE)
        !          9698:        {       /**/ ASSERT(!Lfree && QVOID());
        !          9699:                n = size/WORDSIZE - 1;
        !          9700:                if(List[n] == NIL(TREE*))
        !          9701:                {       /* get a bunch of these small blocks */
        !          9702:                        if(!(tp = (TREE*) malloc((size+WORDSIZE)*LGET)))
        !          9703:                                return NIL(VOID*);
        !          9704:                        List[n] = tp;
        !          9705:                        for(i = LGET-1; i > 0; --i)
        !          9706:                        {
        !          9707:                                SIZE(tp) = size;
        !          9708:                                tp = LINK(tp) = NEXT(tp);
        !          9709:                        }
        !          9710:                        SIZE(tp) = size;
        !          9711:                        LINK(tp) = NIL(TREE*);
        !          9712:                }
        !          9713:                tp = List[n];
        !          9714:                List[n] = LINK(tp);
        !          9715:                return DATA(tp);
        !          9716:        }
        !          9717: 
        !          9718:        if(!tp)
        !          9719:        {       /* normal malloc requests */
        !          9720:                if(Root && (tp = t_search(size)) != NIL(TREE*))
        !          9721:                        CLRBIT1(SIZE(NEXT(tp)));
        !          9722:                else if((tp = Bottom) != NIL(TREE*) && SIZE(tp) >= size)
        !          9723:                        Bottom = NIL(TREE*);
        !          9724:                else if((tp = morecore(size)) == NIL(TREE*))
        !          9725:                        return NIL(VOID*);
        !          9726:        }       /**/ ASSERT(tp && !ISBITS01(SIZE(tp)));
        !          9727: 
        !          9728:        if((n = SIZE(tp)-size) >= (MINSIZE+WORDSIZE))
        !          9729:        {       /* the leftover is enough for a new free piece */
        !          9730:                SIZE(tp) = size;
        !          9731:                np = NEXT(tp);
        !          9732:                SIZE(np) = n-WORDSIZE;
        !          9733: #ifdef MTRACE
        !          9734:                MTSETFREE(np);
        !          9735: #endif
        !          9736:                FREE(np);
        !          9737:        }
        !          9738: 
        !          9739:        /* peel out a pending free block */
        !          9740:        if(!Lfree && !QVOID())
        !          9741:                DESTACK(Lfree);
        !          9742: 
        !          9743:        /* return the allocated space */
        !          9744: #ifdef MTRACE
        !          9745:        mt_setinfo(tp,mtsize,MTMALLOC);
        !          9746: #endif
        !          9747:        SETBIT0(SIZE(tp));
        !          9748:        return DATA(tp);
        !          9749: }
        !          9750: 
        !          9751: /*
        !          9752: **     realloc().
        !          9753: */
        !          9754: VOID *realloc(old,size)
        !          9755: VOID           *old;
        !          9756: reg uint       size;
        !          9757: {
        !          9758:        reg TREE        *tp, *np;
        !          9759:        reg int         n, ts;
        !          9760:        reg VOID        *new;
        !          9761: #ifdef MTRACE
        !          9762:        reg uint        mtsize = size;
        !          9763:        if(old)
        !          9764:        {
        !          9765:                size = size < (MINSIZE-MTSPACE) ? MINSIZE : size + MTSPACE;
        !          9766:                if(Mt_certify)
        !          9767:                        mt_certify();
        !          9768:                if(MTISFREE(BLOCK(old)))
        !          9769:                        mt_didfree(old,MTREALLOC);
        !          9770:                if(Mt_trace >= 0)
        !          9771:                        mt_trace(old,MTREALLOC);
        !          9772:        }
        !          9773: #endif
        !          9774:        /**/ COUNT(N_realloc);
        !          9775: 
        !          9776:        if(!old)
        !          9777:                return malloc(size);
        !          9778: 
        !          9779:        if(Lfree)
        !          9780:        {       /* free everything except old */
        !          9781:                Nofree = old;
        !          9782:                free(Lfree);
        !          9783:                Nofree = NIL(VOID*);
        !          9784:        }
        !          9785: 
        !          9786:        size = size == 0 ? WORDSIZE : ROUND(size,WORDSIZE);
        !          9787:        tp = BLOCK(old);
        !          9788:        ts = SIZE(tp);
        !          9789:        if(size >= MINSIZE && ts >= MINSIZE)
        !          9790:        {
        !          9791:                CLRBITS01(SIZE(tp));
        !          9792:                if((n = SIZE(tp)-size) < 0)
        !          9793:                {       /* growing, try forward merging */
        !          9794:                        FMERGE(tp,np);
        !          9795:                        n = SIZE(tp) - size;
        !          9796: #ifndef SEGMENT
        !          9797:                        if(n < 0 && BOTTOM(tp) && GETCORE(0) == Baddr)
        !          9798:                        {       /* try extending core */
        !          9799:                                Bottom = tp;
        !          9800:                                if((tp = morecore(size)) != NIL(TREE*))
        !          9801:                                        n = SIZE(tp) - size;
        !          9802:                        }
        !          9803: #endif /*!SEGMENT*/
        !          9804:                }
        !          9805:                if(n >= (MINSIZE+WORDSIZE))
        !          9806:                {       /* left over is enough for a new piece */
        !          9807:                        SIZE(tp) = size;
        !          9808:                        np = NEXT(tp);
        !          9809:                        SIZE(np) = (n-WORDSIZE);
        !          9810: #ifdef MTRACE
        !          9811:                        MTSETFREE(np);
        !          9812: #endif
        !          9813:                        FREE(np);
        !          9814:                }
        !          9815:                CPYBITS01(SIZE(tp),ts);
        !          9816:                if(n >= 0) /* got it */
        !          9817:                {
        !          9818: #ifdef MTRACE
        !          9819:                        mt_setinfo(tp,mtsize,MTMALLOC);
        !          9820: #endif
        !          9821:                        return old;
        !          9822:                }
        !          9823:        }
        !          9824: #ifdef MTRACE
        !          9825:        MTSETFREE(BLOCK(old));
        !          9826: #endif
        !          9827:        /* call malloc to get a new block */
        !          9828:        CLRBITS01(ts);
        !          9829:        if((new = malloc(size)) != NIL(VOID*))
        !          9830:                memcpy(new,old,ts < size ? ts : size);
        !          9831: 
        !          9832:        /**/ ASSERT(!QFULL());
        !          9833:        if(!Lfree)
        !          9834:                Lfree = old;
        !          9835:        else    ENQUEUE(old);
        !          9836: #ifdef MTRACE
        !          9837:        mt_setinfo(BLOCK(new),mtsize,MTNONE);
        !          9838: #endif
        !          9839:        return new;
        !          9840: }
        !          9841: 
        !          9842: /*
        !          9843: **     free().
        !          9844: */
        !          9845: void free(old)
        !          9846: reg VOID       *old;
        !          9847: {
        !          9848:        reg int         size;
        !          9849:        reg TREE        *tp, *np, *sp;
        !          9850:        reg VOID        *dequeue;
        !          9851: #ifdef MTRACE
        !          9852:        if(old != Lfree)
        !          9853:        {
        !          9854:                if(Mt_certify)
        !          9855:                        mt_certify();
        !          9856:                if(MTISFREE(BLOCK(old)))
        !          9857:                        mt_didfree(old,MTFREE);
        !          9858:                else    MTSETFREE(BLOCK(old));
        !          9859:                if(Mt_trace >= 0)
        !          9860:                        mt_trace(old,MTFREE);
        !          9861:        }
        !          9862: #endif
        !          9863:        /**/ COUNT(N_free);
        !          9864: 
        !          9865:        if(!old)
        !          9866:                old = Lfree;
        !          9867: 
        !          9868:        dequeue = NIL(VOID*);
        !          9869:        if(Lfree != old)
        !          9870:        {       /* this is a normal free call */
        !          9871:                if(Lfree)
        !          9872:                {       /* make queue space for current Lfree */
        !          9873:                        if(QFULL())
        !          9874:                                DEQUEUE(dequeue);       /**/ ASSERT(!QFULL());
        !          9875:                        ENQUEUE(Lfree);
        !          9876:                }
        !          9877:                Lfree = old;
        !          9878:                old = dequeue;
        !          9879:        }
        !          9880:        else    Lfree = NIL(VOID*);
        !          9881: 
        !          9882:        while(old)
        !          9883:        {
        !          9884:                if(old == Nofree)
        !          9885:                        goto next;
        !          9886: 
        !          9887:                tp = BLOCK(old);
        !          9888:                if((size = SIZE(tp)) < MINSIZE)
        !          9889:                {       /* small block */
        !          9890:                        size = size/WORDSIZE - 1;
        !          9891:                        LINK(tp) = List[size];
        !          9892:                        List[size] = tp;
        !          9893:                        goto next;
        !          9894:                }
        !          9895: 
        !          9896:                /* merge adjacent free blocks */
        !          9897:                CLRBITS01(SIZE(tp));
        !          9898:                FMERGE(tp,np);
        !          9899:                if(ISBIT1(size))
        !          9900:                        BMERGE(tp,np);
        !          9901: 
        !          9902:                if(BOTTOM(tp))
        !          9903:                {       /* bottom block */
        !          9904:                        Bottom = tp;
        !          9905: #ifndef SEGMENT
        !          9906:                        if(M_brksize > 0 && GETCORE(0) == Baddr)
        !          9907:                        {
        !          9908:                                M_brksize = ROUND(M_brksize,CORESIZE);
        !          9909:                                if((size = SIZE(tp)-MINSIZE) >= M_brksize)
        !          9910:                                {
        !          9911:                                        size = (size/CORESIZE)*CORESIZE;
        !          9912:                                        GETCORE(-size);
        !          9913:                                        if((old = GETCORE(0)) != Baddr)
        !          9914:                                        {
        !          9915:                                                Baddr = old;
        !          9916:                                                SIZE(tp) = (old-WORDSIZE) - DATA(tp);
        !          9917:                                                SIZE(NEXT(tp)) = BIT0;
        !          9918:                                        }
        !          9919:                                }
        !          9920:                        }
        !          9921: #endif
        !          9922:                        goto next;
        !          9923:                }
        !          9924: 
        !          9925:                /* tell next block that this one is free */
        !          9926:                SETBIT1(SIZE(NEXT(tp)));        /**/ ASSERT(ISBIT0(SIZE(NEXT(tp))));
        !          9927: 
        !          9928:                /* leaf insert into the free tree */
        !          9929:                LEFT(tp) = RIGHT(tp) = LINK(tp) = NIL(TREE*);
        !          9930:                *(SELFP(tp)) = tp;
        !          9931:                /**/ COUNT(N_block);
        !          9932: 
        !          9933:                if(!Root)
        !          9934:                {       /**/ COUNT(N_list);
        !          9935:                        Root = tp;
        !          9936:                        goto next;
        !          9937:                }
        !          9938: 
        !          9939:                np = Root;
        !          9940:                size = SIZE(tp);
        !          9941:                while(1)
        !          9942:                {
        !          9943:                        if(SIZE(np) > size)
        !          9944:                        {
        !          9945:                                if((sp = LEFT(np)) != NIL(TREE*))
        !          9946:                                        np = sp;
        !          9947:                                else
        !          9948:                                {       /**/ COUNT(N_list);
        !          9949:                                        LEFT(np) = tp;
        !          9950:                                        break;
        !          9951:                                }
        !          9952:                        }
        !          9953:                        else if(SIZE(np) < size)
        !          9954:                        {
        !          9955:                                if((sp = RIGHT(np)) != NIL(TREE*))
        !          9956:                                        np = sp;
        !          9957:                                else
        !          9958:                                {       /**/ COUNT(N_list);
        !          9959:                                        RIGHT(np) = tp;
        !          9960:                                        break;
        !          9961:                                }
        !          9962:                        }
        !          9963:                        else /* SIZE(np) == size */
        !          9964:                        {
        !          9965:                                if((sp = LINK(np)) != NIL(TREE*))
        !          9966:                                {
        !          9967:                                        LINK(tp) = sp;
        !          9968:                                        BACK(sp) = tp;
        !          9969:                                }
        !          9970:                                LINK(np) = tp;
        !          9971:                                BACK(tp) = np;
        !          9972:                                SETNOTREE(tp);
        !          9973:                                break;
        !          9974:                        }
        !          9975:                }
        !          9976:        next:
        !          9977:                if(dequeue || QVOID())
        !          9978:                        old = NIL(VOID*);
        !          9979:                else    DEQUEUE(old);
        !          9980:        }
        !          9981: }
        !          9982: 
        !          9983: /*
        !          9984: **     Get more core. Gaps in memory are noted as busy blocks.
        !          9985: */
        !          9986: static TREE *morecore(size)
        !          9987: reg uint       size;
        !          9988: {
        !          9989:        reg TREE        *tp, *bp;
        !          9990:        reg VOID        *addr;
        !          9991: 
        !          9992:        /* space for queue of delayed free blocks */
        !          9993:        if(!Qfree)
        !          9994:                size += QSIZE*sizeof(Qfree[0]);
        !          9995: 
        !          9996:        /* try to extend the Bottom block if possible */
        !          9997:        bp = Bottom;
        !          9998:        Bottom = NIL(TREE*);
        !          9999: 
        !          10000:        /* get memory */
        !          10001:        size += 2*WORDSIZE;
        !          10002:        size = ROUND(size,CORESIZE);
        !          10003:        if((addr = GETCORE(size)) == ERRCORE)
        !          10004:        {
        !          10005:                Bottom = bp;
        !          10006:                return NIL(TREE*);
        !          10007:        }
        !          10008: 
        !          10009:        if(addr == Baddr)
        !          10010:        {       /* contiguous memory, merge with previous bottom */
        !          10011:                if(bp)
        !          10012:                {
        !          10013:                        addr = ((VOID*)bp);
        !          10014:                        size += SIZE(bp) + 2*WORDSIZE;
        !          10015:                }
        !          10016:                else
        !          10017:                {
        !          10018:                        addr = Baddr-WORDSIZE;
        !          10019:                        size += WORDSIZE;
        !          10020:                }
        !          10021:        }
        !          10022:        else
        !          10023:        {
        !          10024: #ifndef SEGMENT
        !          10025:                if((((uint)addr)%ALIGN) != 0)
        !          10026:                {       /* make sure alignment is correct */
        !          10027:                        reg uint n = ALIGN - ((uint)addr)%ALIGN;
        !          10028:                        if(GETCORE(n) == ERRCORE)
        !          10029:                        {
        !          10030:                                Bottom = bp;
        !          10031:                                return NIL(TREE*);
        !          10032:                        }
        !          10033:                        addr += n;
        !          10034:                }
        !          10035: #endif
        !          10036:                if(!Qfree)
        !          10037:                {       /* space for the free queue */
        !          10038:                        Qfree = (VOID**) addr;
        !          10039:                        addr += QSIZE*sizeof(Qfree[0]);
        !          10040:                        size -= QSIZE*sizeof(Qfree[0]);
        !          10041:                }
        !          10042: #ifdef MTRACE
        !          10043:                if(!Laddr)
        !          10044:                        Laddr = addr;
        !          10045: #endif
        !          10046:        }
        !          10047: 
        !          10048:        /* new bottom address */
        !          10049:        Baddr = addr + size;
        !          10050: 
        !          10051:        /* new bottom block */
        !          10052:        tp = ((TREE*) addr);
        !          10053:        SIZE(tp) = size - 2*WORDSIZE;   /**/ASSERT((SIZE(tp)%WORDSIZE) == 0);
        !          10054: 
        !          10055:        /* reserved the last word to head any noncontiguous memory */
        !          10056:        SETBIT0(SIZE(NEXT(tp)));
        !          10057: 
        !          10058:        if(bp && bp != tp)
        !          10059:        {       /* non-contiguous memory, free old bottom block */
        !          10060:                /**/ ASSERT(!Lfree && QVOID());
        !          10061:                SETBIT0(SIZE(bp));
        !          10062:                ENQUEUE(DATA(bp));
        !          10063:        }
        !          10064: 
        !          10065:        return tp;
        !          10066: }
        !          10067: 
        !          10068: /*
        !          10069: **     Tree rotation functions
        !          10070: */
        !          10071: #define RROTATE(t,r)   (t = LEFT(r), LEFT(r) = RIGHT(t), RIGHT(t) = r, r = t)
        !          10072: #define LROTATE(t,r)   (t = RIGHT(r), RIGHT(r) = LEFT(t), LEFT(t) = r, r = t)
        !          10073: #define RLINK(r,s,x)   (r ? (s = LEFT(s) = x) : (r = s = x))
        !          10074: #define LLINK(r,s,x)   (r ? (s = RIGHT(s) = x) : (r = s = x))
        !          10075: #define RTWICE(t,r)    (LEFT(LEFT(r)) = RIGHT(t), RIGHT(t) = r, r = t)
        !          10076: #define LTWICE(t,r)    (RIGHT(RIGHT(r)) = LEFT(t), LEFT(t) = r, r = t)
        !          10077: 
        !          10078: /*
        !          10079: **     Look up a suitable element in the tree. If found, delete it from
        !          10080: **     the tree and return its address.
        !          10081: **     This uses the top-down splay strategy.
        !          10082: */
        !          10083: static TREE *t_search(size)
        !          10084: reg int                size;
        !          10085: {
        !          10086:        reg int         cmp;
        !          10087:        reg TREE        *t, *del, *left, *right, *lroot, *rroot;
        !          10088: 
        !          10089:        /* find the right one to delete */
        !          10090:        del = Root;
        !          10091:        lroot = rroot = NIL(TREE*);
        !          10092:        while(del)
        !          10093:        {       /**/ ASSERT(!ISBITS01(size) && !ISBITS01(SIZE(del)));
        !          10094:                if((cmp = size - SIZE(del)) == 0)
        !          10095:                        break;
        !          10096:                if(cmp < 0)
        !          10097:                {
        !          10098:                        if((t = LEFT(del)) == NIL(TREE*))
        !          10099:                        {
        !          10100:                                RLINK(rroot,right,del);
        !          10101:                                del = NIL(TREE*);
        !          10102:                        }
        !          10103:                        else if((cmp = size - SIZE(t)) <= 0)
        !          10104:                        {       /* left,left case */
        !          10105:                                RROTATE(t,del);
        !          10106:                                if(cmp == 0)
        !          10107:                                        break;
        !          10108:                                RLINK(rroot,right,del);
        !          10109:                                del = LEFT(del);
        !          10110:                        }
        !          10111:                        else
        !          10112:                        {       /* left, right case */
        !          10113:                                RLINK(rroot,right,del);
        !          10114:                                LLINK(lroot,left,t);
        !          10115:                                del = RIGHT(t);
        !          10116:                        }
        !          10117:                }
        !          10118:                else
        !          10119:                {
        !          10120:                        if((t = RIGHT(del)) == NIL(TREE*))
        !          10121:                        {
        !          10122:                                LLINK(lroot,left,del);
        !          10123:                                del = NIL(TREE*);
        !          10124:                        }
        !          10125:                        else if((cmp = size - SIZE(t)) >= 0)
        !          10126:                        {       /* right, right case */
        !          10127:                                LROTATE(t,del);
        !          10128:                                if(cmp == 0)
        !          10129:                                        break;
        !          10130:                                LLINK(lroot,left,t);
        !          10131:                                del = RIGHT(del);
        !          10132:                        }
        !          10133:                        else
        !          10134:                        {       /* right, left case */
        !          10135:                                LLINK(lroot,left,del);
        !          10136:                                RLINK(rroot,right,t);
        !          10137:                                del = LEFT(t);
        !          10138:                        }
        !          10139:                }
        !          10140:        }
        !          10141: 
        !          10142:        if(del)
        !          10143:        {
        !          10144:                if(lroot)
        !          10145:                {
        !          10146:                        RIGHT(left) = LEFT(del);
        !          10147:                        LEFT(del) = lroot;
        !          10148:                }
        !          10149:                if(rroot)
        !          10150:                {
        !          10151:                        LEFT(right) = RIGHT(del);
        !          10152:                        RIGHT(del) = rroot;
        !          10153:                }
        !          10154:        }
        !          10155:        else
        !          10156:        {
        !          10157:                if(lroot)
        !          10158:                        RIGHT(left) = NIL(TREE*);
        !          10159:                if(rroot)
        !          10160:                {       /* get least one > size */
        !          10161:                        LEFT(right) = NIL(TREE*);
        !          10162:                        while(LEFT(rroot))
        !          10163:                        {       /* left zig-zig case */
        !          10164:                                if((t = LEFT(LEFT(rroot))) != NIL(TREE*))
        !          10165:                                        RTWICE(t,rroot);
        !          10166:                                else    RROTATE(t,rroot);
        !          10167:                        }
        !          10168:                        LEFT(rroot) = lroot;
        !          10169:                        del = rroot;
        !          10170:                }
        !          10171:                else
        !          10172:                {
        !          10173:                        Root = lroot;
        !          10174:                        return NIL(TREE*);
        !          10175:                }
        !          10176:        }
        !          10177: 
        !          10178:        if((t = LINK(del)) != NIL(TREE*))
        !          10179:        {       /* start of a non-singleton list */
        !          10180:                LEFT(t) = LEFT(del);
        !          10181:                RIGHT(t) = RIGHT(del);
        !          10182:                Root = t;       /**/ ASSERT(!ISNOTREE(t));
        !          10183:        }
        !          10184:        else
        !          10185:        {       /**/ DISCOUNT(N_list);
        !          10186:                if((right = RIGHT(del)) != NIL(TREE*))
        !          10187:                {       /* make least elt of right tree the root */
        !          10188:                        while(LEFT(right))
        !          10189:                        {       /* left zig-zig case */
        !          10190:                                if((t = LEFT(LEFT(right))) != NIL(TREE*))
        !          10191:                                        RTWICE(t,right);
        !          10192:                                else    RROTATE(t,right);
        !          10193:                        }
        !          10194:                        LEFT(right) = LEFT(del);
        !          10195:                        Root = right;
        !          10196:                }
        !          10197:                else    Root = LEFT(del);
        !          10198:        }       /**/ DISCOUNT(N_block);
        !          10199: 
        !          10200:        return del;
        !          10201: }
        !          10202: 
        !          10203: #endif /* cray */
        !          10204: 0707070000000001451006440044230044230000010000000475356526700003100000020504misc/optget.cUgsfGgsf/*
        !          10205:  * G. S. Fowler
        !          10206:  * AT&T Bell Laboratories
        !          10207:  *
        !          10208:  * command line option parse assist
        !          10209:  */
        !          10210: 
        !          10211: char*          opt_arg;                /* {:,#} string argument        */
        !          10212: char**         opt_argv;               /* most recent argv             */
        !          10213: int            opt_char;               /* char pos in argv[opt_index]  */
        !          10214: int            opt_index;              /* argv index                   */
        !          10215: char*          opt_msg;                /* error/usage message buffer   */
        !          10216: long           opt_num;                /* # numeric argument           */
        !          10217: char           opt_option[3];          /* current flag {-,+} + option  */
        !          10218: int            opt_pchar;              /* prev opt_char for backup     */
        !          10219: int            opt_pindex;             /* prev opt_index for backup    */
        !          10220: 
        !          10221: static char*   opt_opts[8];            /* cached opts arguments        */
        !          10222: static int     opt_nopt;               /* opt_opts[] index             */
        !          10223: 
        !          10224: #define elements(x)    (sizeof(x)/sizeof(x[0]))
        !          10225: 
        !          10226: #define OPT_MSG                512
        !          10227: 
        !          10228: static int     error();
        !          10229: 
        !          10230: extern char*   malloc();
        !          10231: extern char*   optusage();
        !          10232: extern long    strtol();
        !          10233: 
        !          10234: /*
        !          10235:  * argv:       command line argv where argv[0] is command name
        !          10236:  *
        !          10237:  * opts:       option control string
        !          10238:  *
        !          10239:  *     ':'             option takes string arg
        !          10240:  *     '#'             option takes numeric arg (concat option may follow)
        !          10241:  *     '?'             (first) following options not in usage
        !          10242:  *                     (following # or :) optional arg
        !          10243:  *                     (following option or ]) remaining not in usage
        !          10244:  *     '['...']'       (following # or :) optional option arg description
        !          10245:  *                     (otherwise) mutually exclusive option grouping
        !          10246:  *     ' '...          optional argument(s) description (to end of string)
        !          10247:  *
        !          10248:  * return:
        !          10249:  *
        !          10250:  *     0               no more options
        !          10251:  *     '?'             usage: opt_arg points to message sans `Usage: command'
        !          10252:  *     ':'             error: opt_arg points to message sans `command:'
        !          10253:  *
        !          10254:  * -- or ++ terminates option list and returns 0
        !          10255:  *
        !          10256:  * -? puts usage message sans command name in opt_arg and returns '?'
        !          10257:  *
        !          10258:  * if any # option is specified then numeric options (e.g., -123)
        !          10259:  * are associated with the leftmost # option in opts
        !          10260:  */
        !          10261: 
        !          10262: int
        !          10263: optget(argv, opts)
        !          10264: register char**        argv;
        !          10265: char*          opts;
        !          10266: {
        !          10267:        register int    c;
        !          10268:        register char*  s;
        !          10269:        int             n;
        !          10270:        char*           e;
        !          10271: 
        !          10272:        opt_pindex = opt_index;
        !          10273:        opt_pchar = opt_char;
        !          10274:        for (;;)
        !          10275:        {
        !          10276:                if (!opt_index)
        !          10277:                {
        !          10278:                        opt_index = 1;
        !          10279:                        opt_char = 0;
        !          10280:                }
        !          10281:                if (!opt_char)
        !          10282:                {
        !          10283:                        if (opt_index == 1)
        !          10284:                        {
        !          10285:                                opt_argv = argv;
        !          10286:                                opt_nopt = 0;
        !          10287:                                if (*opts != '?') opt_opts[opt_nopt++] = opts;
        !          10288:                        }
        !          10289:                        if (!(s = argv[opt_index]) || (opt_option[0] = *s++) != '-' && opt_option[0] != '+' || !*s)
        !          10290:                                return(0);
        !          10291:                        if (*s++ == opt_option[0] && !*s)
        !          10292:                        {
        !          10293:                                opt_index++;
        !          10294:                                return(0);
        !          10295:                        }
        !          10296:                        opt_char++;
        !          10297:                }
        !          10298:                if (c = opt_option[1] = argv[opt_index][opt_char++]) break;
        !          10299:                opt_char = 0;
        !          10300:                opt_index++;
        !          10301:        }
        !          10302:        if ((!opt_nopt || opt_opts[opt_nopt - 1] != opts) && opt_nopt < elements(opt_opts) && *opts != '?')
        !          10303:        {
        !          10304:                n = 0;
        !          10305:                do if (n >= opt_nopt)
        !          10306:                {
        !          10307:                        opt_opts[opt_nopt++] = opts;
        !          10308:                        break;
        !          10309:                } while (opt_opts[n++] != opts);
        !          10310:        }
        !          10311:        if (c == '?')
        !          10312:        {
        !          10313:                opt_arg = optusage((char*)0);
        !          10314:                return(c);
        !          10315:        }
        !          10316:        e = 0;
        !          10317:        if (c == ':' || c == '#' || c == ' ' || c == '[' || c == ']') s = "";
        !          10318:        else
        !          10319:        {
        !          10320:                s = opts;
        !          10321:                while (*s)
        !          10322:                {
        !          10323:                        if (*s == c) break;
        !          10324:                        if (*s == ' ')
        !          10325:                        {
        !          10326:                                s = "";
        !          10327:                                break;
        !          10328:                        }
        !          10329:                        if (*s == ':' || *s == '#')
        !          10330:                        {
        !          10331:                                if (*++s == '?') s++;
        !          10332:                                if (*s == '[')
        !          10333:                                {
        !          10334:                                        n = 1;
        !          10335:                                        while (*++s)
        !          10336:                                        {
        !          10337:                                                if (*s == '[') n++;
        !          10338:                                                else if (*s == ']' && !--n)
        !          10339:                                                {
        !          10340:                                                        s++;
        !          10341:                                                        break;
        !          10342:                                                }
        !          10343:                                        }
        !          10344:                                        n = 0;
        !          10345:                                }
        !          10346:                        }
        !          10347:                        else
        !          10348:                        {
        !          10349:                                if (!e && *s == '#' && s > opts) e = s - 1;
        !          10350:                                s++;
        !          10351:                        }
        !          10352:                }
        !          10353:        }
        !          10354:        if (!*s)
        !          10355:        {
        !          10356:                if (c < '0' || c > '9' || !e) return(error(""));
        !          10357:                c = opt_option[1] = *(s = e);
        !          10358:                opt_char--;
        !          10359:        }
        !          10360:        opt_arg = 0;
        !          10361:        if (*++s == ':' || *s == '#')
        !          10362:        {
        !          10363:                if (*(opt_arg = &argv[opt_index++][opt_char]))
        !          10364:                {
        !          10365:                        if (*s == '#')
        !          10366:                        {
        !          10367:                                opt_num = strtol(opt_arg, &e, 0);
        !          10368:                                if (e == opt_arg)
        !          10369:                                {
        !          10370:                                        if (*(s + 1) == '?')
        !          10371:                                        {
        !          10372:                                                opt_arg = 0;
        !          10373:                                                opt_index--;
        !          10374:                                                return(c);
        !          10375:                                        }
        !          10376:                                        else c = error(s);
        !          10377:                                }
        !          10378:                                else if (*e)
        !          10379:                                {
        !          10380:                                        opt_char += e - opt_arg;
        !          10381:                                        opt_index--;
        !          10382:                                        return(c);
        !          10383:                                }
        !          10384:                        }
        !          10385:                }
        !          10386:                else if (opt_arg = argv[opt_index])
        !          10387:                {
        !          10388:                        opt_index++;
        !          10389:                        if (*(s + 1) == '?' && (*opt_arg == '-' || *opt_arg == '+'))
        !          10390:                        {
        !          10391:                                if (*(opt_arg + 1)) opt_index--;
        !          10392:                                opt_arg = 0;
        !          10393:                        }
        !          10394:                        else if (*s == '#')
        !          10395:                        {
        !          10396:                                opt_num = strtol(opt_arg, &e, 0);
        !          10397:                                if (*e)
        !          10398:                                {
        !          10399:                                        if (*(s + 1) == '?')
        !          10400:                                        {
        !          10401:                                                opt_arg = 0;
        !          10402:                                                opt_index--;
        !          10403:                                        }
        !          10404:                                        else c = error(s);
        !          10405:                                }
        !          10406:                        }
        !          10407:                }
        !          10408:                else if (*(s + 1) != '?') c = error(s);
        !          10409:                opt_char = 0;
        !          10410:        }
        !          10411:        return(c);
        !          10412: }
        !          10413: 
        !          10414: /*
        !          10415:  * return pointer to usage message sans `Usage: command'
        !          10416:  * if opts is 0 then opt_opts is used
        !          10417:  */
        !          10418: 
        !          10419: char*
        !          10420: optusage(opts)
        !          10421: char*  opts;
        !          10422: {
        !          10423:        register int    c;
        !          10424:        register char*  p;
        !          10425:        register char*  s;
        !          10426:        register char*  t;
        !          10427:        char*           b;
        !          10428:        char*           x;
        !          10429:        char*           z;
        !          10430:        char**          o;
        !          10431:        char**          v;
        !          10432:        char**          e;
        !          10433:        int             n;
        !          10434:        int             m;
        !          10435: 
        !          10436:        if (opts)
        !          10437:        {
        !          10438:                o = &opts;
        !          10439:                e = o + 1;
        !          10440:        }
        !          10441:        else
        !          10442:        {
        !          10443:                o = opt_opts;
        !          10444:                e = o + opt_nopt;
        !          10445:        }
        !          10446:        if (e == o) return("[* call optget() before optusage() *]");
        !          10447:        if (!opt_msg && !(opt_msg = malloc(OPT_MSG))) return("[* out of space *]");
        !          10448:        s = opt_msg;
        !          10449:        for (v = o; v < e; v++)
        !          10450:        {
        !          10451:                p = *v;
        !          10452:                while ((c = *p++) && c != ' ' && c != '?')
        !          10453:                {
        !          10454:                        if (c == '[')
        !          10455:                        {
        !          10456:                                if (s != opt_msg) *s++ = ' ';
        !          10457:                                *s++ = '[';
        !          10458:                                b = s;
        !          10459:                                m = 1;
        !          10460:                                for (;;)
        !          10461:                                {
        !          10462:                                        if (!(c = *p)) break;
        !          10463:                                        p++;
        !          10464:                                        if (c == '[')
        !          10465:                                        {
        !          10466:                                                m++;
        !          10467:                                                if (s != b)
        !          10468:                                                {
        !          10469:                                                        *s++ = ' ';
        !          10470:                                                        *s++ = '|';
        !          10471:                                                        *s++ = ' ';
        !          10472:                                                }
        !          10473:                                                *s++ = '[';
        !          10474:                                                b = s;
        !          10475:                                        }
        !          10476:                                        else if (c == ']')
        !          10477:                                        {
        !          10478:                                                *s++ = ']';
        !          10479:                                                if (!--m) break;
        !          10480:                                        }
        !          10481:                                        else
        !          10482:                                        {
        !          10483:                                                if (s != b)
        !          10484:                                                {
        !          10485:                                                        *s++ = ' ';
        !          10486:                                                        *s++ = '|';
        !          10487:                                                        *s++ = ' ';
        !          10488:                                                }
        !          10489:                                                *s++ = '-';
        !          10490:                                                *s++ = c;
        !          10491:                                                if (*p == ':' && (t = "arg") || *p == '#' && (t = "num"))
        !          10492:                                                {
        !          10493:                                                        if (c = (*++p == '?'))
        !          10494:                                                        {
        !          10495:                                                                p++;
        !          10496:                                                                *s++ = '[';
        !          10497:                                                        }
        !          10498:                                                        else *s++ = ' ';
        !          10499:                                                        if (*p == '[')
        !          10500:                                                        {
        !          10501:                                                                n = 1;
        !          10502:                                                                while (*s = *++p)
        !          10503:                                                                {
        !          10504:                                                                        if (*p == '[') n++;
        !          10505:                                                                        else if (*p == ']' && !--n)
        !          10506:                                                                        {
        !          10507:                                                                                p++;
        !          10508:                                                                                break;
        !          10509:                                                                        }
        !          10510:                                                                        s++;
        !          10511:                                                                }
        !          10512:                                                        }
        !          10513:                                                        else while (*s = *t++) s++;
        !          10514:                                                        if (c) *s++ = ']';
        !          10515:                                                }
        !          10516:                                        }
        !          10517:                                }
        !          10518:                        }
        !          10519:                        else if (*p == ':' || *p == '#')
        !          10520:                        {
        !          10521:                                if (*++p == '?') p++;
        !          10522:                                if (*p == '[')
        !          10523:                                {
        !          10524:                                        n = 1;
        !          10525:                                        while (*++p)
        !          10526:                                        {
        !          10527:                                                if (*p == '[') n++;
        !          10528:                                                else if (*p == ']' && !--n)
        !          10529:                                                {
        !          10530:                                                        p++;
        !          10531:                                                        break;
        !          10532:                                                }
        !          10533:                                        }
        !          10534:                                }
        !          10535:                        }
        !          10536:                }
        !          10537:        }
        !          10538:        b = s;
        !          10539:        for (v = o; v < e; v++)
        !          10540:        {
        !          10541:                p = *v;
        !          10542:                while ((c = *p++) && c != ' ' && c != '?')
        !          10543:                {
        !          10544:                        if (c == '[')
        !          10545:                        {
        !          10546:                                m = 1;
        !          10547:                                for (;;)
        !          10548:                                {
        !          10549:                                        if (!(c = *p)) break;
        !          10550:                                        p++;
        !          10551:                                        if (c == '[') m++;
        !          10552:                                        else if (c == ']' && !--m) break;
        !          10553:                                }
        !          10554:                        }
        !          10555:                        else if (*p == ':' || *p == '#')
        !          10556:                        {
        !          10557:                                if (*++p == '?') p++;
        !          10558:                                if (*p == '[')
        !          10559:                                {
        !          10560:                                        n = 1;
        !          10561:                                        while (*++p)
        !          10562:                                        {
        !          10563:                                                if (*p == '[') n++;
        !          10564:                                                else if (*p == ']' && !--n)
        !          10565:                                                {
        !          10566:                                                        p++;
        !          10567:                                                        break;
        !          10568:                                                }
        !          10569:                                        }
        !          10570:                                }
        !          10571:                        }
        !          10572:                        else
        !          10573:                        {
        !          10574:                                if (s == b)
        !          10575:                                {
        !          10576:                                        if (s != opt_msg) *s++ = ' ';
        !          10577:                                        *s++ = '[';
        !          10578:                                        *s++ = '-';
        !          10579:                                }
        !          10580:                                *s++ = c;
        !          10581:                        }
        !          10582:                }
        !          10583:        }
        !          10584:        if (s != b) *s++ = ']';
        !          10585:        x = 0;
        !          10586:        z = 0;
        !          10587:        for (v = o; v < e; v++)
        !          10588:        {
        !          10589:                p = *v;
        !          10590:                while (c = *p++)
        !          10591:                {
        !          10592:                        if (c == '[')
        !          10593:                        {
        !          10594:                                m = 1;
        !          10595:                                for (;;)
        !          10596:                                {
        !          10597:                                        if (!(c = *p)) break;
        !          10598:                                        p++;
        !          10599:                                        if (c == '[') m++;
        !          10600:                                        else if (c == ']' && !--m) break;
        !          10601:                                }
        !          10602:                        }
        !          10603:                        else if (c == ' ')
        !          10604:                        {
        !          10605:                                x = p;
        !          10606:                                break;
        !          10607:                        }
        !          10608:                        else if (c == '?') z = s;
        !          10609:                        else if (*p == ':' && (t = "arg") || *p == '#' && (t = "num"))
        !          10610:                        {
        !          10611:                                if (s != b) *s++ = ' ';
        !          10612:                                *s++ = '[';
        !          10613:                                *s++ = '-';
        !          10614:                                *s++ = c;
        !          10615:                                if (c = (*++p == '?'))
        !          10616:                                {
        !          10617:                                        p++;
        !          10618:                                        *s++ = '[';
        !          10619:                                }
        !          10620:                                else *s++ = ' ';
        !          10621:                                if (*p == '[')
        !          10622:                                {
        !          10623:                                        n = 1;
        !          10624:                                        while (*s = *++p)
        !          10625:                                        {
        !          10626:                                                if (*p == '[') n++;
        !          10627:                                                else if (*p == ']' && !--n)
        !          10628:                                                {
        !          10629:                                                        p++;
        !          10630:                                                        break;
        !          10631:                                                }
        !          10632:                                                s++;
        !          10633:                                        }
        !          10634:                                }
        !          10635:                                else while (*s = *t++) s++;
        !          10636:                                if (c) *s++ = ']';
        !          10637:                                *s++ = ']';
        !          10638:                                if (z) s = z;
        !          10639:                        }
        !          10640:                }
        !          10641:        }
        !          10642:        if (p = x)
        !          10643:        {
        !          10644:                if (s != opt_msg) *s++ = ' ';
        !          10645:                while (*s = *p++) s++;
        !          10646:        }
        !          10647:        return(opt_msg);
        !          10648: }
        !          10649: 
        !          10650: /*
        !          10651:  * point opt_arg to an error message for opt_option
        !          10652:  * p points to opts location for opt_option
        !          10653:  * optget() return value is returned
        !          10654:  */
        !          10655: 
        !          10656: static int
        !          10657: error(p)
        !          10658: register char* p;
        !          10659: {
        !          10660:        register char*  s;
        !          10661:        register char*  t;
        !          10662:        int             n;
        !          10663: 
        !          10664:        if (!opt_msg && !(opt_msg = malloc(OPT_MSG))) opt_arg = "[* out of space *]";
        !          10665:        else
        !          10666:        {
        !          10667:                s = opt_arg = opt_msg;
        !          10668:                *s++ = opt_option[0];
        !          10669:                *s++ = opt_option[1];
        !          10670:                *s++ = ':';
        !          10671:                *s++ = ' ';
        !          10672:                if (*p == '#' || *p == ':')
        !          10673:                {
        !          10674:                        if (*p == '#')
        !          10675:                        {
        !          10676:                                t = "numeric ";
        !          10677:                                while (*s = *t++) s++;
        !          10678:                        }
        !          10679:                        if (*++p == '[')
        !          10680:                        {
        !          10681:                                n = 1;
        !          10682:                                while (*s = *++p)
        !          10683:                                {
        !          10684:                                        if (*s == '[') n++;
        !          10685:                                        else if (*s == ']' && !--n) break;
        !          10686:                                        s++;
        !          10687:                                }
        !          10688:                                *s++ = ' ';
        !          10689:                        }
        !          10690:                        p = "argument expected";
        !          10691:                }
        !          10692:                else p = "unknown option";
        !          10693:                while (*s++ = *p++);
        !          10694:        }
        !          10695:        return(':');
        !          10696: }
        !          10697: 0707070000000001461006440044230044230000010000000474310516700003500000002731misc/pathaccess.cUgsfGgsf/*
        !          10698:  * G. S. Fowler
        !          10699:  * AT&T Bell Laboratories
        !          10700:  *
        !          10701:  * return path to file a/b with access mode using : separated dirs
        !          10702:  * both a and b may be 0
        !          10703:  * if (mode&PATH_REG) then path must not be a directory
        !          10704:  * if (mode&PATH_ABS) then path must be rooted
        !          10705:  * path returned in path buffer
        !          10706:  */
        !          10707: 
        !          10708: #include <limits.h>
        !          10709: #include <sys/types.h>
        !          10710: #include <sys/stat.h>
        !          10711: 
        !          10712: #define PATH_RWX       007
        !          10713: #define        PATH_REG        010
        !          10714: #define PATH_ABS       020
        !          10715: 
        !          10716: #ifndef PATH_MAX
        !          10717: #define PATH_MAX       1024
        !          10718: #endif
        !          10719: 
        !          10720: static char*   pathcat();
        !          10721: 
        !          10722: extern int     access();
        !          10723: extern char*   getcwd();
        !          10724: extern char*   pathcanon();
        !          10725: 
        !          10726: char*
        !          10727: pathaccess(path, dirs, a, b, mode)
        !          10728: register char* path;
        !          10729: register char* dirs;
        !          10730: char*          a;
        !          10731: char*          b;
        !          10732: register int   mode;
        !          10733: {
        !          10734:        int             sep = ':';
        !          10735:        char            cwd[PATH_MAX];
        !          10736:        struct stat     st;
        !          10737: 
        !          10738:        do
        !          10739:        {
        !          10740:                dirs = pathcat(path, dirs, sep, a, b);
        !          10741:                (void)pathcanon(path);
        !          10742:                if (!access(path, mode & PATH_RWX))
        !          10743:                {
        !          10744:                        if ((mode & PATH_REG) && (stat(path, &st) || (st.st_mode & S_IFMT) == S_IFDIR)) continue;
        !          10745:                        if (*path == '/' || !(mode & PATH_ABS)) return(path);
        !          10746:                        dirs = getcwd(cwd, sizeof(cwd));
        !          10747:                        sep = 0;
        !          10748:                }
        !          10749:        } while (dirs);
        !          10750:        return(0);
        !          10751: }
        !          10752: 
        !          10753: /*
        !          10754:  * single dir support for pathaccess()
        !          10755:  */
        !          10756: 
        !          10757: static char*
        !          10758: pathcat(path, dirs, sep, a, b)
        !          10759: char*          path;
        !          10760: register char* dirs;
        !          10761: int            sep;
        !          10762: char*          a;
        !          10763: register char* b;
        !          10764: {
        !          10765:        register char*  s;
        !          10766: 
        !          10767:        s = path;
        !          10768:        while (*dirs && *dirs != sep) *s++ = *dirs++;
        !          10769:        if (s != path) *s++ = '/';
        !          10770:        if (a)
        !          10771:        {
        !          10772:                while (*s = *a++) s++;
        !          10773:                if (b) *s++ = '/';
        !          10774:        }
        !          10775:        else if (!b) b = ".";
        !          10776:        if (b) while (*s++ = *b++);
        !          10777:        return(*dirs ? ++dirs : 0);
        !          10778: }
        !          10779: 0707070000000001471006440044230044230000010000000460171260700003400000002736misc/pathcanon.cUgsfGgsf/*
        !          10780:  * G. S. Fowler
        !          10781:  * AT&T Bell Laboratories
        !          10782:  *
        !          10783:  * in-place path name canonicalization -- preserves the logical view
        !          10784:  * pointer to trailing 0 in path returned
        !          10785:  *
        !          10786:  *     remove redundant .'s and /'s
        !          10787:  *     move ..'s to the front
        !          10788:  *     /.. preserved (for pdu and newcastle hacks)
        !          10789:  *     FS_3D handles ...
        !          10790:  * 
        !          10791:  * longer pathname possible if FS_3D ... involved
        !          10792:  */
        !          10793: 
        !          10794: char*
        !          10795: pathcanon(path)
        !          10796: char*  path;
        !          10797: {
        !          10798:        register char*  r;
        !          10799:        register char*  s;
        !          10800:        register char*  t;
        !          10801:        register int    dots;
        !          10802: 
        !          10803:        dots = 0;
        !          10804:        r = s = t = path;
        !          10805:        for (;;) switch (*t++ = *s++)
        !          10806:        {
        !          10807:        case '.':
        !          10808:                dots++;
        !          10809:                break;
        !          10810:        case 0:
        !          10811:                s--;
        !          10812:                /*FALLTHROUGH*/
        !          10813:        case '/':
        !          10814:                while (*s == '/') s++;
        !          10815:                switch (dots)
        !          10816:                {
        !          10817:                case 1:
        !          10818:                        t -= 2;
        !          10819:                        break;
        !          10820:                case 2:
        !          10821:                        if (t - 5 < r) r = t;
        !          10822:                        else for (t -= 5; t > r && *(t - 1) != '/'; t--);
        !          10823:                        break;
        !          10824:                case 3:
        !          10825: #if defined(FS_3D)
        !          10826:                        {
        !          10827:                                char*           x;
        !          10828:                                char*           o;
        !          10829:                                int             c;
        !          10830: 
        !          10831:                                extern char*    pathnext();
        !          10832: 
        !          10833:                                o = t;
        !          10834:                                if ((t -= 5) <= path) t = path + 1;
        !          10835:                                c = *t;
        !          10836:                                *t = 0;
        !          10837:                                if (x = pathnext(path, s - (*s != 0)))
        !          10838:                                {
        !          10839:                                        r = path;
        !          10840:                                        if (t == r + 1) x = r;
        !          10841:                                        s = t = x;
        !          10842:                                }
        !          10843:                                else
        !          10844:                                {
        !          10845:                                        *t = c;
        !          10846:                                        t = o;
        !          10847:                                }
        !          10848:                        }
        !          10849: #else
        !          10850:                        r = t;
        !          10851: #endif
        !          10852:                        break;
        !          10853:                }
        !          10854:                if (!*s)
        !          10855:                {
        !          10856:                        if (t > path && !*(t - 1)) t--;
        !          10857:                        if (t == path) *t++ = '.';
        !          10858: #if DONT_PRESERVE_TRAILING_SLASH
        !          10859:                        else if (t > path + 1 && *(t - 1) == '/') t--;
        !          10860: #else
        !          10861:                        else if ((s <= path || *(s - 1) != '/') && t > path + 1 && *(t - 1) == '/') t--;
        !          10862: #endif
        !          10863:                        *t = 0;
        !          10864:                        return(t);
        !          10865:                }
        !          10866:                dots = 0;
        !          10867:                break;
        !          10868:        default:
        !          10869:                dots = 4;
        !          10870:                break;
        !          10871:        }
        !          10872: }
        !          10873: 0707070000000001501006440044230044230000010000000471404133700003400000000306misc/pathcheck.cUgsfGgsf/*
        !          10874:  * G. S. Fowler
        !          10875:  * AT&T Bell Laboratories
        !          10876:  *
        !          10877:  * no-op stub for runtime validation
        !          10878:  * the tool name and argv[0] are passed
        !          10879:  */
        !          10880: 
        !          10881: /*ARGSUSED*/
        !          10882: void
        !          10883: pathcheck(tool, arg0)
        !          10884: char*  tool;
        !          10885: char*  arg0;
        !          10886: {
        !          10887: }
        !          10888: 0707070000000001511006440044230044230000010000000475330642500003200000010735misc/pathkey.cUgsfGgsf/*
        !          10889:  * Glenn Fowler
        !          10890:  * AT&T Bell Laboratories
        !          10891:  *
        !          10892:  * generate 14 char lookup key for lang path in key
        !          10893:  * based on 32-bit checksum on path
        !          10894:  *
        !          10895:  * if key==0 then space is malloc'd
        !          10896:  * if attr != 0 then attribute var assignments placed here:
        !          10897:  *     ATTRIBUTES      list of attribute names
        !          10898:  */
        !          10899: 
        !          10900: #include <limits.h>
        !          10901: #include <ctype.h>
        !          10902: #include <preroot.h>
        !          10903: #include <stdio.h>
        !          10904: 
        !          10905: #define elements(x)    (sizeof(x)/sizeof(x[0]))
        !          10906: 
        !          10907: char*
        !          10908: pathkey(key, attr, lang, path)
        !          10909: char*          key;
        !          10910: char*          attr;
        !          10911: char*          lang;
        !          10912: register char* path;
        !          10913: {
        !          10914:        register char*          s;
        !          10915:        register char*          k;
        !          10916:        char*                   t;
        !          10917:        char*                   flags;
        !          10918:        char**                  p;
        !          10919:        int                     c;
        !          10920:        unsigned long           n;
        !          10921:        char                    buf[15];
        !          10922:        char*                   usr[16];
        !          10923:        char*                   env[elements(usr) + 3];
        !          10924:        char*                   ver[2];
        !          10925:        char                    tmp[PATH_MAX];
        !          10926: 
        !          10927:        extern char*            getenv();
        !          10928:        extern int              getuniv();
        !          10929:        extern unsigned long    memsum();
        !          10930:        extern char*            strcopy();
        !          10931:        extern char*            strdup();
        !          10932:        extern int              strlen();
        !          10933:        extern char*            strchr();
        !          10934:        extern char*            strrchr();
        !          10935: 
        !          10936:        extern char**           environ;
        !          10937: 
        !          10938:        for (c = 0; c < elements(env); c++) env[c] = 0;
        !          10939:        if (!key) key = buf;
        !          10940:        n = 0;
        !          10941: 
        !          10942:        /*
        !          10943:         * trailing flags in path
        !          10944:         */
        !          10945: 
        !          10946:        if (flags = strchr(path, ' '))
        !          10947:        {
        !          10948:                if (flags == path) flags = 0;
        !          10949:                else
        !          10950:                {
        !          10951:                        (void)strcpy(tmp, path);
        !          10952:                        *(flags = tmp + (flags - path)) = 0;
        !          10953:                        path = tmp;
        !          10954:                }
        !          10955:        }
        !          10956: 
        !          10957:        /*
        !          10958:         * 3D
        !          10959:         */
        !          10960: 
        !          10961:        if (fs3d(2) && (c = mount(path, tmp, 012|(PATH_MAX<<4))) > 1 && c < PATH_MAX)
        !          10962:                path = tmp;
        !          10963: 
        !          10964:        /*
        !          10965:         * preroot
        !          10966:         */
        !          10967: 
        !          10968:        if (attr) attr = strcopy(attr, "PREROOT='");
        !          10969: #if FS_PREROOT
        !          10970:        if (k = getenv(PR_BASE))
        !          10971:        {
        !          10972:                if (s = strrchr(k, '/')) k = s + 1;
        !          10973:                n = memsum(k, strlen(k), n);
        !          10974:        }
        !          10975:        if (attr && (getpreroot(attr, path) || getpreroot(attr, (char*)0))) attr += strlen(attr);
        !          10976: #else
        !          10977:        if ((k = getenv("VIRTUAL_ROOT")) && *k == '/')
        !          10978:        {
        !          10979:                n = memsum(k, strlen(k), n);
        !          10980:                if (attr) attr = strcopy(attr, k);
        !          10981:        }
        !          10982: #endif
        !          10983: 
        !          10984:        /*
        !          10985:         * universe
        !          10986:         */
        !          10987: 
        !          10988:        if (attr) attr = strcopy(attr, "' UNIVERSE='");
        !          10989:        if (!getuniv(buf))
        !          10990:        {
        !          10991:                n = memsum(buf, strlen(buf), n);
        !          10992:                if (attr) attr = strcopy(attr, buf);
        !          10993:        }
        !          10994: 
        !          10995:        /*
        !          10996:         * environment
        !          10997:         *
        !          10998:         *      ${VERSION_ENVIRONMENT}  : list of alternate env vars
        !          10999:         *      ${VERSION_<lang>}
        !          11000:         *      ${VERSION_<base(path)>}
        !          11001:         *      ${<toupper(base(path))>VER}
        !          11002:         */
        !          11003: 
        !          11004:        if (attr) *attr++ = '\'';
        !          11005:        k = getenv("VERSION_ENVIRONMENT");
        !          11006:        c = 0;
        !          11007:        while (c < elements(usr))
        !          11008:        {
        !          11009:                usr[c++] = k;
        !          11010:                if (k) for (;;)
        !          11011:                {
        !          11012:                        if (!*k)
        !          11013:                        {
        !          11014:                                k = 0;
        !          11015:                                break;
        !          11016:                        }
        !          11017:                        if (*k++ == ':') break;
        !          11018:                }
        !          11019:        }
        !          11020:        ver[0] = lang;
        !          11021:        ver[1] = k = (s = strrchr(path, '/')) ? s + 1 : path;
        !          11022:        s = buf;
        !          11023:        if (isdigit(*k))
        !          11024:        {
        !          11025:                if (*k == '3' && *(k + 1) == 'b')
        !          11026:                {
        !          11027:                        /*
        !          11028:                         * cuteness never pays
        !          11029:                         */
        !          11030: 
        !          11031:                        k += 2;
        !          11032:                        *s++ = 'B';
        !          11033:                        *s++ = 'B';
        !          11034:                        *s++ = 'B';
        !          11035:                }
        !          11036:                else *s++ = 'U';
        !          11037:        }
        !          11038:        for (; (c = *k) && s < &buf[sizeof(buf) - 1]; k++)
        !          11039:        {
        !          11040:                if (!isalnum(c)) c = '_';
        !          11041:                else if (islower(c)) c = toupper(c);
        !          11042:                *s++ = c;
        !          11043:        }
        !          11044:        *s = 0;
        !          11045:        for (p = environ; *p; p++)
        !          11046:        {
        !          11047:                s = "VERSION_";
        !          11048:                for (k = *p; *k && *k == *s; k++, s++);
        !          11049:                if (*k && !*s)
        !          11050:                {
        !          11051:                        for (c = 0; c < elements(ver); c++)
        !          11052:                                if (!env[c] && (s = ver[c]))
        !          11053:                                {
        !          11054:                                        for (t = k; *t && *t != '=' && *t++ == *s; s++);
        !          11055:                                        if (*t == '=' && (!*s || (s - ver[c]) > 1))
        !          11056:                                        {
        !          11057:                                                env[c] = *p;
        !          11058:                                                goto found;
        !          11059:                                        }
        !          11060:                                }
        !          11061:                }
        !          11062:                if (!env[2])
        !          11063:                {
        !          11064:                        s = buf;
        !          11065:                        for (k = *p; *k && *s++ == *k; k++);
        !          11066:                        if ((s - buf) > 2 && k[0] == 'V' && k[1] == 'E' && k[2] == 'R' && k[3] == '=')
        !          11067:                        {
        !          11068:                                env[2] = *p;
        !          11069:                                goto found;
        !          11070:                        }
        !          11071:                }
        !          11072:                for (c = 0; c < elements(usr) && (s = usr[c]); c++)
        !          11073:                        if (!env[c + elements(env) - elements(usr)])
        !          11074:                        {
        !          11075:                                for (k = *p; *k && *k == *s; k++, s++);
        !          11076:                                if (*k == '=' && (!*s || *s == ':'))
        !          11077:                                {
        !          11078:                                        env[c + elements(env) - elements(usr)] = *p;
        !          11079:                                        goto found;
        !          11080:                                }
        !          11081:                        }
        !          11082:        found:  ;
        !          11083:        }
        !          11084:        for (c = 0; c < elements(env); c++)
        !          11085:                if (k = env[c])
        !          11086:                {
        !          11087:                        if (attr)
        !          11088:                        {
        !          11089:                                *attr++ = ' ';
        !          11090:                                while ((*attr++ = *k++) != '=');
        !          11091:                                *attr++ = '\'';
        !          11092:                                attr = strcopy(attr, k);
        !          11093:                                *attr++ = '\'';
        !          11094:                        }
        !          11095:                        else while (*k && *k++ != '=');
        !          11096:                        n = memsum(k, strlen(k), n);
        !          11097:                }
        !          11098:        if (attr)
        !          11099:        {
        !          11100:                attr = strcopy(attr, " ATTRIBUTES='PREROOT UNIVERSE");
        !          11101:                for (c = 0; c < elements(env); c++)
        !          11102:                        if (k = env[c])
        !          11103:                        {
        !          11104:                                *attr++ = ' ';
        !          11105:                                while ((*attr = *k++) != '=') attr++;
        !          11106:                        }
        !          11107:                *attr++ = '\'';
        !          11108:                *attr = 0;
        !          11109:        }
        !          11110: 
        !          11111:        /*
        !          11112:         * now the normal stuff
        !          11113:         */
        !          11114: 
        !          11115:        if (flags) *flags = ' ';
        !          11116:        s = path + strlen(path);
        !          11117:        (void)sprintf(key, "%08lX", memsum(path, s - path, n));
        !          11118:        k = key + 14;
        !          11119:        *k = 0;
        !          11120:        if (!flags) t = path;
        !          11121:        else if ((t = s - 4) < flags) t = flags + 1;
        !          11122:        for (;;)
        !          11123:        {
        !          11124:                if (--s < t)
        !          11125:                {
        !          11126:                        if (t == path) break;
        !          11127:                        s = flags - 2;
        !          11128:                        t = path;
        !          11129:                }
        !          11130:                if (*s != '/' && *s != ' ')
        !          11131:                {
        !          11132:                        *--k = *s;
        !          11133:                        if (k <= key + 8) break;
        !          11134:                }
        !          11135:        }
        !          11136:        while (k > key + 8) *--k = '.';
        !          11137:        return(key == buf ? strdup(key) : key);
        !          11138: }
        !          11139: 0707070000000001521006440044230044230000010000000475401160400003300000002547misc/pathpath.cUgsfGgsf/*
        !          11140:  * G. S. Fowler
        !          11141:  * AT&T Bell Laboratories
        !          11142:  *
        !          11143:  * return full path to p with mode access using $PATH
        !          11144:  * if a!=0 then it and $0 and $_ with $PWD are used for
        !          11145:  * related root searching
        !          11146:  * the related root must have a bin subdir
        !          11147:  * full path returned in path buffer
        !          11148:  */
        !          11149: 
        !          11150: extern char*   getenv();
        !          11151: extern char*   pathaccess();
        !          11152: extern char*   strchr();
        !          11153: extern char*   strcopy();
        !          11154: 
        !          11155: char*
        !          11156: pathpath(path, p, a, mode)
        !          11157: register char* path;
        !          11158: char*          p;
        !          11159: char*          a;
        !          11160: int            mode;
        !          11161: {
        !          11162:        register char*  s;
        !          11163:        char*           x;
        !          11164: 
        !          11165:        extern char**   environ;
        !          11166:        extern char**   opt_argv;
        !          11167: 
        !          11168:        static char*    cmd;
        !          11169: 
        !          11170:        if (s = a)
        !          11171:        {
        !          11172:                x = s;
        !          11173:                a = p;
        !          11174:                p = "..";
        !          11175:                if (strchr(s, '/') || ((s = cmd) || opt_argv && (s = *opt_argv)) && strchr(s, '/') || (s = *environ) && *s++ == '_' && *s++ == '=' && strchr(s, '/') || *x && !access(x, 0) && (s = getenv("PWD")) && *s == '/')
        !          11176:                {
        !          11177:                        if (!cmd) cmd = s;
        !          11178:                        s = strcopy(path, s);
        !          11179:                        for (;;)
        !          11180:                        {
        !          11181:                                do if (s <= path) goto normal; while (*--s == '/');
        !          11182:                                do if (s <= path) goto normal; while (*--s != '/');
        !          11183:                                (void)strcpy(s + 1, "bin");
        !          11184:                                if (!access(path, 0))
        !          11185:                                {
        !          11186:                                        if (s = pathaccess(path, path, p, a, mode)) return(s);
        !          11187:                                        goto normal;
        !          11188:                                }
        !          11189:                        }
        !          11190:                normal: ;
        !          11191:                }
        !          11192:        }
        !          11193:        if (!a && strchr(p, '/')) x = "";
        !          11194:        else if (!(x = getenv("PATH"))) x = ":/bin:/usr/bin";
        !          11195:        if (!(s = pathaccess(path, x, p, a, mode)) && !*x && (x = getenv("FPATH")))
        !          11196:                s = pathaccess(path, x, p, a, mode);
        !          11197:        return(s);
        !          11198: }
        !          11199: 0707070000000001531006440044230044230000010000000475507470200003400000004433misc/pathprobe.cUgsfGgsf/*
        !          11200:  * G. S. Fowler
        !          11201:  * AT&T Bell Laboratories
        !          11202:  *
        !          11203:  * return in path the full path name of the probe(1)
        !          11204:  * information for lang and tool using proc
        !          11205:  * if attr != 0 then path attribute assignments placed here
        !          11206:  *
        !          11207:  * if path==0 then the space is malloc'd
        !          11208:  *
        !          11209:  * op:
        !          11210:  *
        !          11211:  *     -1      return path name with no generation
        !          11212:  *     0       verbose probe
        !          11213:  *     1       silent probe
        !          11214:  *
        !          11215:  * 0 returned if the info does not exist and cannot be generated
        !          11216:  */
        !          11217: 
        !          11218: #include <limits.h>
        !          11219: #include <ls.h>
        !          11220: 
        !          11221: #ifndef PROBE
        !          11222: #define PROBE          "probe"
        !          11223: #endif
        !          11224: 
        !          11225: #ifndef PATH_MAX
        !          11226: #define PATH_MAX       1024
        !          11227: #endif
        !          11228: 
        !          11229: extern int     access();
        !          11230: extern int     cmdrun();
        !          11231: extern char*   malloc();
        !          11232: extern char*   pathpath();
        !          11233: extern char*   pathkey();
        !          11234: extern int     stat();
        !          11235: extern char*   strchr();
        !          11236: extern char*   strcopy();
        !          11237: extern char*   strcpy();
        !          11238: extern char*   strncpy();
        !          11239: extern char*   strdup();
        !          11240: 
        !          11241: char*
        !          11242: pathprobe(path, attr, lang, tool, proc, op)
        !          11243: char*  path;
        !          11244: char*  attr;
        !          11245: char*  lang;
        !          11246: char*  tool;
        !          11247: char*  proc;
        !          11248: int    op;
        !          11249: {
        !          11250:        register char*  p;
        !          11251:        register char*  k;
        !          11252:        register char** ap;
        !          11253:        int             n;
        !          11254:        char*           e;
        !          11255:        char*           probe;
        !          11256:        char            buf[PATH_MAX];
        !          11257:        char            cmd[PATH_MAX];
        !          11258:        char            lib[PATH_MAX];
        !          11259:        char*           arg[6];
        !          11260:        time_t          ptime;
        !          11261:        struct stat     st;
        !          11262: 
        !          11263:        if (*proc != '/')
        !          11264:        {
        !          11265:                if (p = strchr(proc, ' '))
        !          11266:                {
        !          11267:                        n = p - proc;
        !          11268:                        proc = strncpy(buf, proc, n);
        !          11269:                        *(proc + n) = 0;
        !          11270:                }
        !          11271:                if (!(proc = pathpath(cmd, proc, (char*)0, 031))) return(0);
        !          11272:                if (p) (void)strcpy(proc + strlen(proc), p);
        !          11273:        }
        !          11274:        if (!path) path = buf;
        !          11275:        probe = PROBE;
        !          11276:        p = strcopy(lib, "lib/");
        !          11277:        p = strcopy(p, probe);
        !          11278:        *p++ = '/';
        !          11279:        p = strcopy(k = p, lang);
        !          11280:        *p++ = '/';
        !          11281:        p = strcopy(p, tool);
        !          11282:        *p++ = '/';
        !          11283:        e = strcopy(p, probe);
        !          11284:        if (!pathpath(path, lib, "", 021) || stat(path, &st)) return(0);
        !          11285:        ptime = st.st_mtime;
        !          11286:        (void)pathkey(p, attr, lang, proc);
        !          11287:        p = path + strlen(path) - (e - k);
        !          11288:        (void)strcpy(p, k);
        !          11289:        if (op >= 0 && !stat(path, &st))
        !          11290:        {
        !          11291:                if (ptime <= st.st_mtime || ptime <= st.st_ctime) op = -1;
        !          11292:                else if (st.st_mode & S_IWUSR)
        !          11293:                {
        !          11294:                        if (op == 0) error(0, "%s probe information for %s language processor %s must be manually regenerated", tool, lang, proc);
        !          11295:                        op = -1;
        !          11296:                }
        !          11297:        }
        !          11298:        if (op >= 0)
        !          11299:        {
        !          11300:                (void)strcpy(p, probe);
        !          11301:                ap = arg;
        !          11302:                *ap++ = path;
        !          11303:                if (op > 0) *ap++ = "-s";
        !          11304:                *ap++ = lang;
        !          11305:                *ap++ = tool;
        !          11306:                *ap++ = proc;
        !          11307:                *ap = 0;
        !          11308:                if (cmdrun(path, arg)) return(0);
        !          11309:                (void)strcpy(p, k);
        !          11310:                if (access(path, 4)) return(0);
        !          11311:        }
        !          11312:        return(path == buf ? strdup(path) : path);
        !          11313: }
        !          11314: 0707070000000001541006440044230044230000010000000473127621400003300000003552misc/pathtemp.cUgsfGgsf/*
        !          11315:  * AT&T Bell Laboratories
        !          11316:  *
        !          11317:  * generate a temp file path name
        !          11318:  *
        !          11319:  *     [<dir>/][<pfx>]<pid><suf>
        !          11320:  *
        !          11321:  * length(<suf>)==3
        !          11322:  * length(<pfx>)<=PREFIX
        !          11323:  * length(<pfx>)+length(<pid>)+length(<suf>)==BASE
        !          11324:  *
        !          11325:  *     tmpnam(p)               pathtemp(p, 0, 0)
        !          11326:  *     tempnam(d, p)           pathtemp(0, d, p)
        !          11327:  *
        !          11328:  * if buf==0 then space is malloc'd
        !          11329:  * otherwise sizeof(buf) must be >= strlen(dir) + BASE + 2
        !          11330:  * dir and pfx may be 0
        !          11331:  * if dir is 0 then sizeof(buf) must be >= TOTAL or it must
        !          11332:  * be a previous pathtemp() return with the same dir and pfx
        !          11333:  * only first PREFIX chars of pfx are used
        !          11334:  */
        !          11335: 
        !          11336: #define TOTAL  128
        !          11337: #define BASE   14
        !          11338: #define PREFIX 6
        !          11339: 
        !          11340: #define TMPENV "TMPDIR"
        !          11341: #define TMP1   "/tmp"
        !          11342: #define TMP2   "/usr/tmp"
        !          11343: 
        !          11344: #define LOSEED 'a'
        !          11345: #define HISEED 'z'
        !          11346: 
        !          11347: extern char*   getenv();
        !          11348: extern char*   malloc();
        !          11349: 
        !          11350: extern int     access();
        !          11351: extern int     strlen();
        !          11352: 
        !          11353: char*
        !          11354: pathtemp(buf, dir, pfx)
        !          11355: char*          buf;
        !          11356: register char* dir;
        !          11357: char*          pfx;
        !          11358: {
        !          11359:        register char*  p;
        !          11360:        register char*  s;
        !          11361:        int             pid;
        !          11362: 
        !          11363:        static char*    tmpdir;
        !          11364:        static char     seed[] = { LOSEED - 1, LOSEED, LOSEED, 0 };
        !          11365: 
        !          11366:        if ((!dir || *dir && access(dir, 3)) && !(dir = tmpdir))
        !          11367:        {
        !          11368:                if ((!(dir = getenv(TMPENV)) || !*dir || strlen(dir) >= (TOTAL - BASE - 2) || access(dir, 3)) && access(dir = TMP1, 3) && access(dir = TMP2, 3))
        !          11369:                        return(0);
        !          11370:                tmpdir = dir;
        !          11371:        }
        !          11372:        if (!(s = buf) && !(s = malloc(strlen(dir) + BASE + 2))) return(0);
        !          11373:        for (p = s; *p = *dir++; p++);
        !          11374:        if (p > s && *(p - 1) != '/') *p++ = '/';
        !          11375:        if (pfx)
        !          11376:        {
        !          11377:                dir = pfx;
        !          11378:                pfx = p;
        !          11379:                while (*dir && p < pfx + PREFIX) *p++ = *dir++;
        !          11380:        }
        !          11381:        else pfx = p;
        !          11382:        pfx = dir = p + (BASE - (p - pfx) - sizeof(seed) + 1);
        !          11383:        pid = getpid();
        !          11384:        while (--dir >= p)
        !          11385:        {
        !          11386:                *dir = pid % 10 + '0';
        !          11387:                pid /= 10;
        !          11388:        }
        !          11389:        p = pfx;
        !          11390:        dir = seed;
        !          11391:        while (*p++ = *dir++);
        !          11392:        do
        !          11393:        {
        !          11394:                for (p = pfx; *p == HISEED; *p++ = LOSEED);
        !          11395:                if (!*p)
        !          11396:                {
        !          11397:                        if (!buf) free(s);
        !          11398:                        s = 0;
        !          11399:                        break;
        !          11400:                }
        !          11401:                ++*p;
        !          11402:        } while (!access(s, 0));
        !          11403:        p = seed;
        !          11404:        dir = pfx;
        !          11405:        while (*p++ = *dir++);
        !          11406:        return(s);
        !          11407: }
        !          11408: 0707070000000001551006440044230044230000010000000474114261300003100000000664misc/perror.cUgsfGgsf/*
        !          11409:  * G. S. Fowler
        !          11410:  * AT&T Bell Laboratories
        !          11411:  *
        !          11412:  * perror() using strerror()
        !          11413:  */
        !          11414: 
        !          11415: #include <stdio.h>
        !          11416: 
        !          11417: #include "FEATURE/strerror"
        !          11418: 
        !          11419: #ifdef _lib_strerror
        !          11420: 
        !          11421: int    _lib_dummy;
        !          11422: 
        !          11423: #else
        !          11424: 
        !          11425: extern int     errno;
        !          11426: 
        !          11427: extern int     write();
        !          11428: extern char*   strerror();
        !          11429: 
        !          11430: void
        !          11431: perror(s)
        !          11432: char*  s;
        !          11433: {
        !          11434:        char    buf[1024];
        !          11435: 
        !          11436:        if (s && *s) sprintf(buf, "%s: %s\n", s, strerror(errno));
        !          11437:        else sprintf(buf, "%s\n", strerror(errno));
        !          11438:        (void)write(2, buf, strlen(buf));
        !          11439: }
        !          11440: 
        !          11441: #endif
        !          11442: 0707070000000001561006440044230044230000010000000475137333500003100000003546misc/putenv.cUgsfGgsf/*
        !          11443:  * put name=value in the environment
        !          11444:  * pointer to name=value returned
        !          11445:  * environ==0 is ok
        !          11446:  *
        !          11447:  *     putenv("N=V")           add N=V
        !          11448:  *     putenv("N")             delete N
        !          11449:  *     putenv(0)               expect more (pre-fork optimization)
        !          11450:  *
        !          11451:  * _ always placed at the top
        !          11452:  */
        !          11453: 
        !          11454: #define INCREMENT      16              /* environ increment            */
        !          11455: 
        !          11456: extern char**  environ;
        !          11457: 
        !          11458: extern char*   malloc();
        !          11459: extern char*   realloc();
        !          11460: extern char*   strchr();
        !          11461: 
        !          11462: char*
        !          11463: putenv(key)
        !          11464: char*  key;
        !          11465: {
        !          11466:        static char**   envv;           /* recorded environ             */
        !          11467:        static char**   next;           /* next free slot               */
        !          11468:        static char**   last;           /* last free slot (0)           */
        !          11469: 
        !          11470:        register char** v = environ;
        !          11471:        register char** p = envv;
        !          11472:        register char*  s;
        !          11473:        register char*  t;
        !          11474:        int             n;
        !          11475: 
        !          11476:        if (p && !v)
        !          11477:        {
        !          11478:                next = p;
        !          11479:                *++next = 0;
        !          11480:        }
        !          11481:        else if (p != v || !v)
        !          11482:        {
        !          11483:                if (v)
        !          11484:                {
        !          11485:                        while (*v++);
        !          11486:                        n = v - environ + INCREMENT;
        !          11487:                        v = environ;
        !          11488:                }
        !          11489:                else n = INCREMENT;
        !          11490:                if (!p || (last - p + 1) < n)
        !          11491:                {
        !          11492:                        if (p) free(p);
        !          11493:                        else if (fs3d(2))
        !          11494:                        {
        !          11495:                                (void)close(open(".", 0));
        !          11496:                                v = environ;
        !          11497:                        }
        !          11498:                        if (!(p = (char**)malloc(n * sizeof(char**))))
        !          11499:                                return(0);
        !          11500:                        last = p + n - 1;
        !          11501:                }
        !          11502:                envv = environ = p;
        !          11503:                if (v && v[0] && v[0][0] == '_' && v[0][1] == '=') *p++ = *v++;
        !          11504:                else *p++ = "_=";
        !          11505:                if (!v) *p = 0;
        !          11506:                else while (*p = *v++)
        !          11507:                        if (p[0][0] == '_' && p[0][1] == '=') envv[0] = *p;
        !          11508:                        else p++;
        !          11509:                next = p;
        !          11510:                p = envv;
        !          11511:        }
        !          11512:        else if (next == last)
        !          11513:        {
        !          11514:                n = last - v + INCREMENT + 1;
        !          11515:                if (!(p = (char**)realloc(p, n * sizeof(char**))))
        !          11516:                        return(0);
        !          11517:                last = p + n - 1;
        !          11518:                next = last - INCREMENT;
        !          11519:                envv = environ = p;
        !          11520:        }
        !          11521:        if (!key) return(*p);
        !          11522:        for (; s = *p; p++)
        !          11523:        {
        !          11524:                t = key;
        !          11525:                do
        !          11526:                {
        !          11527:                        if (!*t || *t == '=')
        !          11528:                        {
        !          11529:                                if (*s == '=')
        !          11530:                                {
        !          11531:                                        if (!*t)
        !          11532:                                        {
        !          11533:                                                s = *p;
        !          11534:                                                v = p++;
        !          11535:                                                while (*v++ = *p++);
        !          11536:                                                next--;
        !          11537:                                                return(s);
        !          11538:                                        }
        !          11539:                                        return(*p = key);
        !          11540:                                }
        !          11541:                                break;
        !          11542:                        }
        !          11543:                } while (*t++ == *s++);
        !          11544:        }
        !          11545:        if (!strchr(key, '=')) return(key);
        !          11546:        p = next;
        !          11547:        *++next = 0;
        !          11548:        return(*p = key);
        !          11549: }
        !          11550: 0707070000000001571006440044230044230000010000000475326177400003500000001603misc/putsymlink.cUgsfGgsf/*
        !          11551: * G. S. Fowler
        !          11552: * AT&T Bell Laboratories
        !          11553: */
        !          11554: 
        !          11555: #include "univlib.h"
        !          11556: 
        !          11557: extern int     symlink();
        !          11558: 
        !          11559: /*
        !          11560:  * create symbolic name from external representation text in buf
        !          11561:  * the arg order matches link(2)
        !          11562:  */
        !          11563: 
        !          11564: int
        !          11565: putsymlink(buf, name)
        !          11566: char*  buf;
        !          11567: char*  name;
        !          11568: {
        !          11569:        register char*  t = buf;
        !          11570: #ifdef UNIV_MAX
        !          11571:        register char*  s = buf;
        !          11572:        register char*  v;
        !          11573:        int             n;
        !          11574:        char            tmp[PATH_MAX];
        !          11575: 
        !          11576:        extern int      strncmp();
        !          11577: 
        !          11578:        while (*s)
        !          11579:        {
        !          11580:                if (*s++ == univ_cond[0] && !strncmp(s - 1, univ_cond, univ_size))
        !          11581:                {
        !          11582:                        s--;
        !          11583:                        t = tmp;
        !          11584:                        for (n = 0; n < UNIV_MAX; n++)
        !          11585:                                if (*univ_name[n])
        !          11586:                        {
        !          11587:                                *t++ = ' ';
        !          11588: #ifdef ATT_UNIV
        !          11589:                                *t++ = '1' + n;
        !          11590:                                *t++ = ':';
        !          11591: #else
        !          11592:                                for (v = univ_name[n]; *t = *v++; t++);
        !          11593:                                *t++ = '%';
        !          11594: #endif
        !          11595:                                for (v = buf; v < s; *t++ = *v++);
        !          11596:                                for (v = univ_name[n]; *t = *v++; t++);
        !          11597:                                for (v = s + univ_size; *t = *v++; t++);
        !          11598:                        }
        !          11599:                        t = tmp;
        !          11600:                        break;
        !          11601:                }
        !          11602:        }
        !          11603: #endif
        !          11604:        return(symlink(t, name));
        !          11605: }
        !          11606: 0707070000000001601006440044230044230000010000000473215504000003000000002451misc/query.cUgsfGgsf/*
        !          11607:  * AT&T Bell Laboratories
        !          11608:  *
        !          11609:  * output printf prompt and read response
        !          11610:  * if format==0 then verify that interaction is possible
        !          11611:  *
        !          11612:  * return:
        !          11613:  *
        !          11614:  *     0       [1yY+]
        !          11615:  *     -1      [qQ] or EOF
        !          11616:  *     1       otherwise
        !          11617:  *
        !          11618:  * if quit>=0 then [qQ] or EOF calls exit(quit)
        !          11619:  */
        !          11620: 
        !          11621: #include <stdio.h>
        !          11622: 
        !          11623: extern int     errno;
        !          11624: 
        !          11625: #if __STDC__
        !          11626: 
        !          11627: #include <stdarg.h>
        !          11628: 
        !          11629: int
        !          11630: query(int quit, char* format, ...)
        !          11631: 
        !          11632: #else
        !          11633: 
        !          11634: #include <varargs.h>
        !          11635: 
        !          11636: int
        !          11637: query(va_alist)
        !          11638: va_dcl
        !          11639: 
        !          11640: #endif
        !          11641: 
        !          11642: {
        !          11643:        va_list         ap;
        !          11644:        register int    n;
        !          11645:        register int    c;
        !          11646: #if !__STDC__
        !          11647:        int             quit;
        !          11648:        char*           format;
        !          11649: #endif
        !          11650:        static FILE*    rfp;
        !          11651:        static FILE*    wfp;
        !          11652: 
        !          11653:        if (!rfp)
        !          11654:        {
        !          11655:                c = errno;
        !          11656:                if (isatty(fileno(stdin))) rfp = stdin;
        !          11657:                else if (!(rfp = fopen("/dev/tty", "r"))) return(-1);
        !          11658:                if (isatty(fileno(stderr))) wfp = stderr;
        !          11659:                else if (!(wfp = fopen("/dev/tty", "w"))) return(-1);
        !          11660:                errno = c;
        !          11661:        }
        !          11662: #if __STDC__
        !          11663:        va_start(ap, format);
        !          11664: #else
        !          11665:        va_start(ap);
        !          11666:        quit = va_arg(ap, int);
        !          11667:        format = va_arg(ap, char*);
        !          11668: #endif
        !          11669:        if (!format) return(0);
        !          11670:        fflush(stdout);
        !          11671:        vfprintf(wfp, format, ap);
        !          11672:        fflush(wfp);
        !          11673:        for (n = c = getc(rfp);; c = getc(rfp)) switch (c)
        !          11674:        {
        !          11675:        case EOF:
        !          11676:                n = c;
        !          11677:                /*FALLTHROUGH*/
        !          11678:        case '\n':
        !          11679:                switch (n)
        !          11680:                {
        !          11681:                case EOF:
        !          11682:                case 'q':
        !          11683:                case 'Q':
        !          11684:                        if (quit >= 0) exit(quit);
        !          11685:                        return(-1);
        !          11686:                case '1':
        !          11687:                case 'y':
        !          11688:                case 'Y':
        !          11689:                case '+':
        !          11690:                        return(0);
        !          11691:                default:
        !          11692:                        return(1);
        !          11693:                }
        !          11694:        }
        !          11695:        va_end(ap);
        !          11696: }
        !          11697: 0707070000000001611006440044230044230000010000000434534132200003100000002730misc/setcwd.cUgsfGgsf/*
        !          11698:  * K. P. Vo
        !          11699:  * G. S. Fowler
        !          11700:  * AT&T Bell Laboratories
        !          11701:  */
        !          11702: 
        !          11703: #include <limits.h>
        !          11704: #include <errno.h>
        !          11705: 
        !          11706: #ifndef PATH_MAX
        !          11707: #define PATH_MAX       1024
        !          11708: #endif
        !          11709: 
        !          11710: extern int     errno;
        !          11711: 
        !          11712: #if DEBUG
        !          11713: 
        !          11714: #undef PATH_MAX
        !          11715: 
        !          11716: #define PATH_MAX       16
        !          11717: 
        !          11718: static int
        !          11719: vchdir(path)
        !          11720: char*  path;
        !          11721: {
        !          11722:        int     n;
        !          11723: 
        !          11724:        if (strlen(path) >= PATH_MAX)
        !          11725:        {
        !          11726:                errno = ENAMETOOLONG;
        !          11727:                n = -1;
        !          11728:        }
        !          11729:        else n = chdir(path);
        !          11730:        liberror("setcwd", -1, "chdir(%s)=%d", path, n);
        !          11731:        return(n);
        !          11732: }
        !          11733: 
        !          11734: #define chdir(p)       vchdir(p)
        !          11735: 
        !          11736: #endif
        !          11737: 
        !          11738: /*
        !          11739:  * set the current directory to path
        !          11740:  * if path is long and home!=0 then setcwd(home,0)
        !          11741:  * is called on intermediate chdir errors
        !          11742:  */
        !          11743: 
        !          11744: int
        !          11745: setcwd(path, home)
        !          11746: register char* path;
        !          11747: char*          home;
        !          11748: {
        !          11749:        register char*  s;
        !          11750:        register int    n;
        !          11751:        int             r;
        !          11752: 
        !          11753:        r = 0;
        !          11754:        for (;;)
        !          11755:        {
        !          11756:                /*
        !          11757:                 * this should work 99% of the time
        !          11758:                 */
        !          11759: 
        !          11760:                if (!chdir(path)) return(r);
        !          11761: 
        !          11762:                /*
        !          11763:                 * chdir failed
        !          11764:                 */
        !          11765: 
        !          11766:                n = strlen(path);
        !          11767:                if (n < PATH_MAX) return(-1);
        !          11768: #ifdef ENAMETOOLONG
        !          11769:                if (errno != ENAMETOOLONG) return(-1);
        !          11770: #endif
        !          11771: 
        !          11772:                /*
        !          11773:                 * path is too long
        !          11774:                 */
        !          11775: 
        !          11776:                for (;;)
        !          11777:                {
        !          11778:                        /*
        !          11779:                         * get a short prefix component
        !          11780:                         */
        !          11781: 
        !          11782:                        s = path + PATH_MAX;
        !          11783:                        while (--s >= path)
        !          11784:                                if (*s == '/') break;
        !          11785:                        if (s <= path) break;
        !          11786: 
        !          11787:                        /*
        !          11788:                         * chdir to the prefix
        !          11789:                         */
        !          11790: 
        !          11791:                        *s = '\0';
        !          11792:                        if (chdir(path)) break;
        !          11793:                        *s++ = '/';
        !          11794: 
        !          11795:                        /*
        !          11796:                         * do the remainder
        !          11797:                         */
        !          11798: 
        !          11799:                        if ((n -= s - path) < PATH_MAX)
        !          11800:                        {
        !          11801:                                if (chdir(s)) break;
        !          11802:                                return(r);
        !          11803:                        }
        !          11804:                        path = s;
        !          11805:                }
        !          11806: 
        !          11807:                /*
        !          11808:                 * try to recover back to home
        !          11809:                 */
        !          11810: 
        !          11811:                if (!(path = home)) return(-1);
        !          11812:                home = 0;
        !          11813:                r = -1;
        !          11814:        }
        !          11815: }
        !          11816: 0707070000000001621006440044230044230000010000000475327610200003200000001244misc/setuniv.cUgsfGgsf/*
        !          11817:  * G. S. Fowler
        !          11818:  * AT&T Bell Laboratories
        !          11819:  *
        !          11820:  * set universe by name
        !          11821:  */
        !          11822: 
        !          11823: #include "univlib.h"
        !          11824: 
        !          11825: #define streq(a,b)     (*(a)==*(b)&&!strcmp(a,b))
        !          11826: 
        !          11827: int
        !          11828: setuniv(buf)
        !          11829: char*  buf;
        !          11830: {
        !          11831: #if _lib_getuniverse
        !          11832:        return(setuniverse(buf));
        !          11833: #else
        !          11834: #ifndef UNIV_MAX
        !          11835:        char            tmp[32];
        !          11836: 
        !          11837:        extern char*    putenv();
        !          11838:        extern char*    strdup();
        !          11839: 
        !          11840:        (void)sprintf(tmp, "%s=%-*.*s", univ_env, UNIV_SIZE - 1, UNIV_SIZE - 1, buf);
        !          11841:        if ((buf = strdup(tmp)) && putenv(buf)) return(0);
        !          11842:        errno = ENOMEM;
        !          11843:        return(-1);
        !          11844: #else
        !          11845: #ifdef ATT_UNIV
        !          11846:        register int    n;
        !          11847: 
        !          11848:        for (n = 0; n < UNIV_MAX; n++)
        !          11849:                if (streq(buf, univ_name[n]))
        !          11850:                        return(setuniverse(n + 1) >= 0 ? 0 : -1);
        !          11851: #endif
        !          11852:        errno = EINVAL;
        !          11853:        return(-1);
        !          11854: #endif
        !          11855: #endif
        !          11856: }
        !          11857: 0707070000000001631006440044230044230000010000000471770731000003200000004521misc/sigcrit.cUgsfGgsf/*
        !          11858:  * G. S. Fowler
        !          11859:  * AT&T Bell Laboratories
        !          11860:  *
        !          11861:  * signal critical region support
        !          11862:  */
        !          11863: 
        !          11864: #include <sig.h>
        !          11865: 
        !          11866: #define elements(x)    (sizeof(x)/sizeof(x[0]))
        !          11867: 
        !          11868: #include "FEATURE/sigsetmask"
        !          11869: 
        !          11870: static int     signals[] =             /* held inside critical region  */
        !          11871: {
        !          11872:        SIGINT,
        !          11873:        SIGQUIT,
        !          11874:        SIGHUP,
        !          11875: };
        !          11876: 
        !          11877: #ifndef SIG_SETMASK
        !          11878: #ifndef        _lib_sigsetmask
        !          11879: 
        !          11880: static long    hold;                   /* held signal mask             */
        !          11881: 
        !          11882: /*
        !          11883:  * hold last signal for later delivery
        !          11884:  */
        !          11885: 
        !          11886: static void
        !          11887: interrupt(sig)
        !          11888: int    sig;
        !          11889: {
        !          11890:        (void)signal(sig, interrupt);
        !          11891:        hold |= sigmask(sig);
        !          11892: }
        !          11893: 
        !          11894: #endif
        !          11895: #endif
        !          11896: 
        !          11897: /*
        !          11898:  * critical signal region handler
        !          11899:  *
        !          11900:  * op>0                push region, return region level
        !          11901:  * op==0       pop region, return region level
        !          11902:  * op<0                return non-zero if any signals held in current region
        !          11903:  *
        !          11904:  * signals[] held until region popped
        !          11905:  */
        !          11906: 
        !          11907: int
        !          11908: sigcritical(op)
        !          11909: int    op;
        !          11910: {
        !          11911:        register int    i;
        !          11912:        static int      level;
        !          11913: #ifdef SIG_SETMASK
        !          11914:        static sigset_t mask;
        !          11915:        sigset_t        nmask;
        !          11916: #else
        !          11917: #ifdef _lib_sigsetmask
        !          11918:        static long     mask;
        !          11919: #else
        !          11920:        static signal_t handler[elements(signals)];
        !          11921: #endif
        !          11922: #endif
        !          11923: 
        !          11924:        if (op > 0)
        !          11925:        {
        !          11926:                if (!level++)
        !          11927:                {
        !          11928: #ifdef SIG_SETMASK
        !          11929:                        (void)sigemptyset(&nmask);
        !          11930:                        for (i = 0; i < elements(signals); i++)
        !          11931:                                (void)sigaddset(&nmask, signals[i]);
        !          11932:                        (void)sigprocmask(SIG_BLOCK, &nmask, &mask);
        !          11933: #else
        !          11934: #ifdef _lib_sigsetmask
        !          11935:                        mask = 0;
        !          11936:                        for (i = 0; i < elements(signals); i++)
        !          11937:                                mask |= sigmask(signals[i]);
        !          11938:                        mask = sigblock(mask);
        !          11939: #else
        !          11940:                        hold = 0;
        !          11941:                        for (i = 0; i < elements(signals); i++)
        !          11942:                                if ((handler[i] = signal(signals[i], interrupt)) == SIG_IGN)
        !          11943:                                {
        !          11944:                                        (void)signal(signals[i], SIG_IGN);
        !          11945:                                        hold &= ~sigmask(signals[i]);
        !          11946:                                }
        !          11947: #endif
        !          11948: #endif
        !          11949:                }
        !          11950:                return(level);
        !          11951:        }
        !          11952:        else if (!op)
        !          11953:        {
        !          11954:                if (!--level)
        !          11955:                {
        !          11956: #ifdef SIG_SETMASK
        !          11957:                        (void)sigprocmask(SIG_SETMASK, &mask, (sigset_t*)0);
        !          11958: #else
        !          11959: #ifdef _lib_sigsetmask
        !          11960:                        (void)sigsetmask(mask);
        !          11961: #else
        !          11962:                        for (i = 0; i < elements(signals); i++)
        !          11963:                                (void)signal(signals[i], handler[i]);
        !          11964:                        if (hold)
        !          11965:                        {
        !          11966:                                for (i = 0; i < elements(signals); i++)
        !          11967:                                        if (hold & sigmask(signals[i]))
        !          11968:                                                (void)kill(getpid(), signals[i]);
        !          11969:                                (void)pause();
        !          11970:                        }
        !          11971: #endif
        !          11972: #endif
        !          11973:                }
        !          11974:                return(level);
        !          11975:        }
        !          11976:        else
        !          11977:        {
        !          11978: #ifdef SIG_SETMASK
        !          11979:                (void)sigpending(&nmask);
        !          11980:                for (i = 0; i < elements(signals); i++)
        !          11981:                        if (sigismember(&nmask, signals[i]))
        !          11982:                                return(1);
        !          11983:                return(0);
        !          11984: #else
        !          11985: #ifdef _lib_sigsetmask
        !          11986:                /* no way to get pending signals without installing handler */
        !          11987:                return(0);
        !          11988: #else
        !          11989:                return(hold != 0);
        !          11990: #endif
        !          11991: #endif
        !          11992:        }
        !          11993: }
        !          11994: 0707070000000001641006440044230044230000010000000471771116600003000000005225misc/stack.cUgsfGgsf/*
        !          11995:  * G. S. Fowler
        !          11996:  *
        !          11997:  * stack routines
        !          11998:  */
        !          11999: 
        !          12000: #include "stack.h"
        !          12001: 
        !          12002: #if !lint
        !          12003: static char    id[] = "\n@(#)stack (AT&T Bell Laboratories) 05/01/84\0\n";
        !          12004: #endif
        !          12005: 
        !          12006: extern char    *malloc();
        !          12007: 
        !          12008: /*
        !          12009:  * create a new stack
        !          12010:  */
        !          12011: 
        !          12012: STACK
        !          12013: mkstack(size, error)
        !          12014: register int   size;
        !          12015: char           *error;
        !          12016: {
        !          12017:        register STACK                  stack;
        !          12018:        register struct stackblock      *b;
        !          12019: 
        !          12020:        if (size <= 0) size = 100;
        !          12021:        if (!(stack = (STACK)malloc(sizeof(struct stacktable)))) return((STACK)0);
        !          12022:        if (!(b = (struct stackblock*)malloc(sizeof(struct stackblock))))
        !          12023:        {
        !          12024:                free(stack);
        !          12025:                return((STACK)0);
        !          12026:        }
        !          12027:        if (!(b->stack = (char**)malloc(sizeof(char*)*size)))
        !          12028:        {
        !          12029:                free(b);
        !          12030:                free(stack);
        !          12031:                return((STACK)0);
        !          12032:        }
        !          12033:        stack->blocks = b;
        !          12034:        stack->size = size;
        !          12035:        stack->error = error;
        !          12036:        stack->position.block = b;
        !          12037:        stack->position.index = -1;
        !          12038:        b->next = (struct stackblock*)0;
        !          12039:        b->prev = (struct stackblock*)0;
        !          12040:        return(stack);
        !          12041: }
        !          12042: 
        !          12043: /*
        !          12044:  * remove a stack
        !          12045:  */
        !          12046: 
        !          12047: void
        !          12048: rmstack(stack)
        !          12049: register STACK stack;
        !          12050: {
        !          12051:        register struct stackblock      *b;
        !          12052: 
        !          12053:        for (b = stack->blocks; b; b = b->next)
        !          12054:        {
        !          12055:                free(b->stack);
        !          12056:                free(b);
        !          12057:        }
        !          12058:        free(stack);
        !          12059: }
        !          12060: 
        !          12061: /*
        !          12062:  * clear stack
        !          12063:  */
        !          12064: 
        !          12065: void
        !          12066: clrstack(stack)
        !          12067: register STACK stack;
        !          12068: {
        !          12069:        stack->position.block = stack->blocks;
        !          12070:        stack->position.index = -1;
        !          12071: }
        !          12072: 
        !          12073: /*
        !          12074:  * get value on top of stack
        !          12075:  */
        !          12076: 
        !          12077: char*
        !          12078: getstack(stack)
        !          12079: register STACK stack;
        !          12080: {
        !          12081:        if (stack->position.index < 0) return(stack->error);
        !          12082:        else return(stack->position.block->stack[stack->position.index]);
        !          12083: }
        !          12084: 
        !          12085: /*
        !          12086:  * push value on to stack
        !          12087:  */
        !          12088: 
        !          12089: int
        !          12090: pushstack(stack, value)
        !          12091: register STACK stack;
        !          12092: char           *value;
        !          12093: {
        !          12094:        register struct stackblock      *b;
        !          12095: 
        !          12096:        if (++stack->position.index >= stack->size)
        !          12097:        {
        !          12098:                b = stack->position.block;
        !          12099:                if (!b->next)
        !          12100:                {
        !          12101:                        if (!(b->next = (struct stackblock*)malloc(sizeof(struct stackblock))))
        !          12102:                                return(-1);
        !          12103:                        b = b->next;
        !          12104:                        if (!(b->stack = (char**)malloc(sizeof(char*)*stack->size)))
        !          12105:                                return(-1);
        !          12106:                        b->prev = stack->position.block;
        !          12107:                        b->next = (struct stackblock*)0;
        !          12108:                        stack->position.block = b;
        !          12109:                }
        !          12110:                stack->position.index = 0;
        !          12111:        }
        !          12112:        stack->position.block->stack[stack->position.index] = value;
        !          12113:        return(0);
        !          12114: }
        !          12115: 
        !          12116: /*
        !          12117:  * pop value off stack
        !          12118:  */
        !          12119: 
        !          12120: int
        !          12121: popstack(stack)
        !          12122: register STACK stack;
        !          12123: {
        !          12124:        /*
        !          12125:         * return:
        !          12126:         *
        !          12127:         *      -1      if stack empty before pop
        !          12128:         *       0      if stack empty after pop
        !          12129:         *       1      if stack not empty before & after pop
        !          12130:         */
        !          12131: 
        !          12132:        if (stack->position.index < 0) return(-1);
        !          12133:        else if (--stack->position.index < 0)
        !          12134:        {
        !          12135:                if (!stack->position.block->prev) return(0);
        !          12136:                stack->position.block = stack->position.block->prev;
        !          12137:                stack->position.index = stack->size - 1;
        !          12138:                return(1);
        !          12139:        }
        !          12140:        else return(1);
        !          12141: }
        !          12142: 
        !          12143: /*
        !          12144:  * set|get stack position
        !          12145:  */
        !          12146: 
        !          12147: void
        !          12148: posstack(stack, set, position)
        !          12149: register STACK stack;
        !          12150: int            set;
        !          12151: STACKPOS       *position;
        !          12152: {
        !          12153:        if (set) stack->position = *position;
        !          12154:        else *position = stack->position;
        !          12155: }
        !          12156: 0707070000000001651006440044230044230000010000000473060502400002700000020644misc/stak.cUgsfGgsf/*
        !          12157:  *   Routines to implement a stack-like storage library
        !          12158:  *
        !          12159:  *   A stack consists of a link list of variable size frames
        !          12160:  *   The beginning of each frame is initialized with a frame structure
        !          12161:  *   that contains a pointer to the previous frame and a pointer to the
        !          12162:  *   end of the current frame.
        !          12163:  *
        !          12164:  *   David Korn
        !          12165:  *   AT&T Bell Laboratories
        !          12166:  *   Room 3C-526B
        !          12167:  *   Murray Hill, N. J. 07974
        !          12168:  *   Tel. x7975
        !          12169:  *   ulysses!dgk
        !          12170:  *
        !          12171:  */
        !          12172: 
        !          12173: extern char    *malloc();
        !          12174: extern char    *strcpy();
        !          12175: #ifdef USE_REALLOC
        !          12176:     /* can only be used when realloc() to smaller size will not move data */
        !          12177:     extern char        *realloc();
        !          12178: #endif /* USE_REALLOC */
        !          12179: 
        !          12180: #define _STAK_PRIVATE \
        !          12181:        short           stakflags;      /* stack attributes */ \
        !          12182:        struct  _stak_  *stakcur;       /* current stack pointer  */ \
        !          12183:        char            *stakbase;      /* base of current stack frame */ \
        !          12184:        char            *stakend;       /* end of current stack frame */ \
        !          12185:        char            *(*stakoverflow)();     /* called when malloc fails */
        !          12186: 
        !          12187: #include       "stak.h"
        !          12188: 
        !          12189: #define STAK_MYSIZE    2               /* local argument to stakcreate */
        !          12190: #define STAK_FSIZE     (1024*sizeof(int))
        !          12191: #define round(a,b)     ((((a)+b)-1)&~((b)-1))
        !          12192: 
        !          12193: #ifdef STAKSTATS
        !          12194:     static struct
        !          12195:     {
        !          12196:        int     create;
        !          12197:        int     delete;
        !          12198:        int     install;
        !          12199:        int     alloc;
        !          12200:        int     copy;
        !          12201:        int     puts;
        !          12202:        int     seek;
        !          12203:        int     set;
        !          12204:        int     grow;
        !          12205:        int     addsize;
        !          12206:        int     delsize;
        !          12207:        int     movsize;
        !          12208:     } _stakstats;
        !          12209: #   define increment(x)        (_stakstats.x++)
        !          12210: #   define count(x,n)  (_stakstats.x += (n))
        !          12211: #else
        !          12212: #   define increment(x)
        !          12213: #   define count(x,n)
        !          12214: #endif /* STAKSTATS */
        !          12215: 
        !          12216: struct frame
        !          12217: {
        !          12218:        char    *prev;
        !          12219:        char    *end;
        !          12220: };
        !          12221: 
        !          12222: static char *overflow();
        !          12223: static const char Omsg[] = "malloc failed while growing stack\n";
        !          12224: static int minsize = STAK_FSIZE;
        !          12225: 
        !          12226: Stak_t _stak_cur =
        !          12227: {
        !          12228:        0,                      /* stakleft */
        !          12229:        (char*)(&_stak_cur),    /* staktop */
        !          12230:        (char*)(&_stak_cur),    /* stakbot */
        !          12231:        1,                      /* stakref */
        !          12232:        0,                      /* stakflags */
        !          12233:        &_stak_cur,             /* stakcur */
        !          12234:        (char*)(&_stak_cur),    /* stakbase */
        !          12235:        (char*)(&_stak_cur),    /* stakend */
        !          12236:        overflow                /* stakoverflow */
        !          12237: };
        !          12238: 
        !          12239: /*
        !          12240:  * create a stack
        !          12241:  * minsize is normally STAK_FSIZE but may be larger when set by _stakgrow()
        !          12242:  */
        !          12243: 
        !          12244: Stak_t *stakcreate(flags)
        !          12245: register int flags;
        !          12246: {
        !          12247:        register Stak_t *sp;
        !          12248:        register char *cp;
        !          12249:        register struct frame *fp;
        !          12250:        register int size,fsize;
        !          12251:        if(flags&STAK_MYSIZE)
        !          12252:                fsize = minsize;
        !          12253: #ifndef USE_REALLOC
        !          12254:        else if(flags&STAK_SMALL)
        !          12255:                fsize = STAK_FSIZE/16;
        !          12256: #endif /* USE_REALLOC */
        !          12257:        else
        !          12258:                fsize = STAK_FSIZE;
        !          12259:        minsize = STAK_FSIZE;
        !          12260:        size = fsize + sizeof(struct frame)+sizeof(Stak_t);
        !          12261:        if((cp=malloc(size))==0)
        !          12262:                return((Stak_t*)0);
        !          12263:        increment(create);
        !          12264:        count(addsize,size);
        !          12265:        sp = (Stak_t*)cp;
        !          12266:        sp->stakcur = sp;
        !          12267:        cp += sizeof(Stak_t);
        !          12268:        fp = (struct frame*)cp;
        !          12269:        fp->prev = 0;
        !          12270:        sp->stakbase = cp;
        !          12271:        sp->stakref = 1;
        !          12272:        cp += sizeof(struct frame);
        !          12273:        sp->staktop = sp->stakbot = cp;
        !          12274:        sp->stakflags = (flags&STAK_SMALL);
        !          12275:        sp->stakoverflow = _stak_cur.stakoverflow;
        !          12276:        sp->stakend  = fp->end = cp+fsize;
        !          12277:        sp->stakleft = fsize;
        !          12278:        return(sp);
        !          12279: }
        !          12280: 
        !          12281: /*
        !          12282:  * return a pointer to the current stack
        !          12283:  * if <sp> is not null, it becomes the new current stack
        !          12284:  * <oflow> becomes the new overflow function
        !          12285:  */
        !          12286: 
        !          12287: #if defined(__STDC__)
        !          12288:     Stak_t *stakinstall(Stak_t *sp, char *(*oflow)(int))
        !          12289: #else
        !          12290:     Stak_t *stakinstall(sp,oflow)
        !          12291:     Stak_t *sp;
        !          12292:     char *(*oflow)();
        !          12293: #endif /* __STDC__ */
        !          12294: {
        !          12295:        Stak_t *oldsp = _stak_cur.stakcur;
        !          12296:        increment(install);
        !          12297:        if(sp)
        !          12298:        {
        !          12299: #ifdef USE_REALLOC
        !          12300:                register struct frame *fp;
        !          12301:                register char *cp;
        !          12302:                /* only works if realloc() to reduce does not relocate */
        !          12303:                if(_stak_cur.stakflags&STAK_SMALL)
        !          12304:                {
        !          12305:                        /* shrink the last frame */
        !          12306:                        fp = (struct frame*)(cp=_stak_cur.stakbase);
        !          12307:                        if(fp->prev==0)
        !          12308:                                cp = (char*)oldsp;
        !          12309:                        _stak_cur.stakend = fp->end = _stak_cur.staktop;
        !          12310:                        _stak_cur.stakleft = 0;
        !          12311:                        if(realloc(cp,_stak_cur.stakend-cp)!=cp)
        !          12312:                                return(0);
        !          12313:                }
        !          12314: #endif /* USE_REALLOC */
        !          12315:                *oldsp = _stak_cur;
        !          12316:                _stak_cur = *sp;
        !          12317:        }
        !          12318:        else
        !          12319:                sp = oldsp;
        !          12320:        if(oflow)
        !          12321:                sp->stakoverflow = (char*(*)())oflow;
        !          12322:        return(oldsp);
        !          12323: }
        !          12324: 
        !          12325: /*
        !          12326:  * terminate a stack and free up the space
        !          12327:  */
        !          12328: 
        !          12329: stakdelete(sp)
        !          12330: Stak_t *sp;
        !          12331: {
        !          12332:        register char *cp = sp->stakbase;
        !          12333:        register struct frame *fp;
        !          12334:        if(--sp->stakref>0)
        !          12335:                return(1);
        !          12336:        increment(delete);
        !          12337:        while(1)
        !          12338:        {
        !          12339:                fp = (struct frame*)cp;
        !          12340:                if(fp->prev)
        !          12341:                {
        !          12342:                        cp = fp->prev;
        !          12343:                        free((char*)fp);
        !          12344:                }
        !          12345:                else
        !          12346:                        break;
        !          12347:        }
        !          12348:        /* now free the first frame */
        !          12349:        if(sp != &_stak_cur)
        !          12350:                free((void*)sp);
        !          12351:        return(0);
        !          12352: }
        !          12353: 
        !          12354: /*
        !          12355:  * reset the bottom of the current stack back to <loc>
        !          12356:  * if <loc> is not in this stack, then the stack is reset to the beginning
        !          12357:  * otherwise, the top of the stack is set to stakbot+<offset>
        !          12358:  *
        !          12359:  */
        !          12360: 
        !          12361: char *stakset(loc,offset)
        !          12362: register char *loc;
        !          12363: unsigned offset;
        !          12364: {
        !          12365:        register Stak_t *sp = &_stak_cur;
        !          12366:        register char *cp;
        !          12367:        register struct frame *fp;
        !          12368:        if(sp==sp->stakcur)
        !          12369:                return(sp->stakbot);
        !          12370:        increment(set);
        !          12371:        while(1)
        !          12372:        {
        !          12373:                /* see whether <loc> is in current stack frame */
        !          12374:                if(loc>=(cp=sp->stakbase) && loc<=sp->stakend)
        !          12375:                {
        !          12376:                        sp->stakbot = cp + round(loc-cp,sizeof(char*));
        !          12377:                        sp->staktop = loc+offset;
        !          12378:                        goto found;
        !          12379:                }
        !          12380:                fp = (struct frame*)cp;
        !          12381:                if(fp->prev)
        !          12382:                {
        !          12383:                        sp->stakbase = fp->prev;
        !          12384:                        sp->stakend = ((struct frame*)(fp->prev))->end;
        !          12385:                        free(cp);
        !          12386:                }
        !          12387:                else
        !          12388:                        break;
        !          12389:        }
        !          12390:        /* set stack back to the beginning */
        !          12391:        sp->staktop = sp->stakbot = ((char*)(sp->stakcur+1))+sizeof(struct frame);
        !          12392: found:
        !          12393:        sp->stakleft = sp->stakend - sp->staktop;
        !          12394:        return(sp->stakbot);
        !          12395: }
        !          12396: 
        !          12397: /*
        !          12398:  * allocate <n> bytes on the current stack
        !          12399:  */
        !          12400: 
        !          12401: #if defined(__STDC__)
        !          12402:     char *stakalloc(register unsigned n)
        !          12403: #else
        !          12404:     char *stakalloc(n)
        !          12405:     register unsigned n;
        !          12406: #endif /* __STDC__ */
        !          12407: {
        !          12408:        register Stak_t *sp = &_stak_cur;
        !          12409:        register char *old;
        !          12410:        increment(alloc);
        !          12411:        n = round(n,sizeof(char*));
        !          12412:        if((sp->stakleft += ((sp->staktop-sp->stakbot)-(int)n)) <=0)
        !          12413:                _stakgrow(n);
        !          12414:        old = sp->stakbot;
        !          12415:        sp->stakbot = sp->staktop = old+n;
        !          12416:        return(old);
        !          12417: }
        !          12418: 
        !          12419: /*
        !          12420:  * begin a new stack word of at least <n> bytes
        !          12421:  */
        !          12422: char *stakseek(n)
        !          12423: register unsigned n;
        !          12424: {
        !          12425:        register Stak_t *sp = &_stak_cur;
        !          12426:        increment(seek);
        !          12427:        if((sp->stakleft += ((sp->staktop-sp->stakbot)-(int)n)) <=0)
        !          12428:                _stakgrow(n);
        !          12429:        sp->staktop = sp->stakbot+n;
        !          12430:        return(sp->stakbot);
        !          12431: }
        !          12432: 
        !          12433: /*
        !          12434:  * put the string <str> onto the stack
        !          12435:  * returns the length of the string
        !          12436:  */
        !          12437: int    stakputs(str)
        !          12438: register const char *str;
        !          12439: {
        !          12440:        register Stak_t *sp = &_stak_cur;
        !          12441:        register const char *cp=str;
        !          12442:        register int n;
        !          12443:        while(*cp++);
        !          12444:        n = cp-str;
        !          12445:        increment(puts);
        !          12446:        if((sp->stakleft -= n) <=0)
        !          12447:                _stakgrow(n);
        !          12448:        strcpy(sp->staktop,str);
        !          12449:        sp->staktop += --n;
        !          12450:        return(n);
        !          12451: }
        !          12452: 
        !          12453: /*
        !          12454:  * advance the stack to the current top
        !          12455:  * if extra is non-zero, first add a extra bytes and zero the first
        !          12456:  */
        !          12457: char   *stakfreeze(extra)
        !          12458: register unsigned extra;
        !          12459: {
        !          12460:        register Stak_t *sp = &_stak_cur;
        !          12461:        register char *old = sp->stakbot;
        !          12462:        register char *top = sp->staktop;
        !          12463:        if(extra)
        !          12464:        {
        !          12465:                if(extra > sp->stakleft)
        !          12466:                {
        !          12467:                        top = _stakgrow(extra);
        !          12468:                        old = sp->stakbot;
        !          12469:                }
        !          12470:                *top = 0;
        !          12471:                top += extra;
        !          12472:        }
        !          12473:        sp->staktop = sp->stakbot += round(top-old,sizeof(char*));
        !          12474:        sp->stakleft = sp->stakend-sp->staktop;
        !          12475:        return(old);
        !          12476: }
        !          12477: 
        !          12478: /*
        !          12479:  * copy string <str> onto the stack as a new stack word
        !          12480:  */
        !          12481: char   *stakcopy(str)
        !          12482: const char *str;
        !          12483: {
        !          12484:        register Stak_t *sp = &_stak_cur;
        !          12485:        register char *cp = (char*)str;
        !          12486:        register int n;
        !          12487:        while(*cp++);
        !          12488:        n = round(cp-str,sizeof(char*));
        !          12489:        increment(copy);
        !          12490:        if((sp->stakleft += ((sp->staktop-sp->stakbot)-n)) <=0)
        !          12491:                _stakgrow(n);
        !          12492:        strcpy(cp=sp->stakbot,str);
        !          12493:        sp->stakbot = sp->staktop = cp+n;
        !          12494:        return(cp);
        !          12495: }
        !          12496: 
        !          12497: /*
        !          12498:  * add a new stack frame of size >= <n> to the current stack.
        !          12499:  * if <n> > 0, copy the bytes from stakbot to staktop to the new stack
        !          12500:  * if <n> is zero, then copy the remainder of the stack frame from stakbot
        !          12501:  * to the end is copied into the new stack frame
        !          12502:  */
        !          12503: 
        !          12504: char *_stakgrow(size)
        !          12505: unsigned size;
        !          12506: {
        !          12507:        register int n = size;
        !          12508:        register Stak_t *sp = &_stak_cur;
        !          12509:        register struct frame *fp;
        !          12510:        register char *cp;
        !          12511:        register unsigned m = (n?sp->staktop:sp->stakend)-sp->stakbot;
        !          12512:        n += (m + sizeof(struct frame)+1);
        !          12513:        if(sp->stakflags&STAK_SMALL)
        !          12514: #ifndef USE_REALLOC
        !          12515:                n = round(n,STAK_FSIZE/16);
        !          12516:        else
        !          12517: #endif /* !USE_REALLOC */
        !          12518:                n = round(n,STAK_FSIZE);
        !          12519:        /* check for first time default stack reference */
        !          12520:        if(sp==sp->stakcur)
        !          12521:        {
        !          12522:                minsize = n;
        !          12523:                if((sp = stakcreate(STAK_MYSIZE))==0)
        !          12524:                        sp = (Stak_t*)overflow(sizeof(Stak_t));
        !          12525:                _stak_cur = *sp;
        !          12526:                return(sp->stakbot);
        !          12527:        }
        !          12528:        cp = malloc(n);
        !          12529:        if(cp==(char*)0)
        !          12530:                cp = (*sp->stakoverflow)(n);
        !          12531:        increment(grow);
        !          12532:        count(addsize,n);
        !          12533:        fp = (struct frame*)cp;
        !          12534:        fp->prev = sp->stakbase;
        !          12535:        sp->stakbase = cp;
        !          12536:        sp->stakend = fp->end = cp+n;
        !          12537:        sp->stakleft = n-(m+size+sizeof(struct frame));
        !          12538:        cp = (char*)(fp+1);
        !          12539:        if(m)
        !          12540:                memcpy(cp,sp->stakbot,m);
        !          12541:        count(movsize,m);
        !          12542:        sp->stakbot = cp;
        !          12543:        return(sp->staktop = sp->stakbot+m);
        !          12544: }
        !          12545: 
        !          12546: 
        !          12547: static char *overflow(n)
        !          12548: int n;
        !          12549: {
        !          12550:        (&n,1);
        !          12551:        write(2,Omsg, sizeof(Omsg)-1);
        !          12552:        exit(2);
        !          12553:        /* NOTREACHED */
        !          12554:        return(0);
        !          12555: }
        !          12556: 
        !          12557: 0707070000000001661006440044230044230000010000000475327573300003300000000560misc/univdata.cUgsfGgsf/*
        !          12558:  * G. S. Fowler
        !          12559:  * AT&T Bell Laboratories
        !          12560:  *
        !          12561:  * universe common data
        !          12562:  */
        !          12563: 
        !          12564: #include "univlib.h"
        !          12565: 
        !          12566: #ifndef UNIV_MAX
        !          12567: 
        !          12568: char           univ_env[] = "__UNIVERSE__";
        !          12569: 
        !          12570: #else
        !          12571: 
        !          12572: #ifndef NUMUNIV
        !          12573: 
        !          12574: char*          univ_name[] = { "att", "ucb" };
        !          12575: 
        !          12576: int            univ_max = sizeof(univ_name) / sizeof(univ_name[0]);
        !          12577: 
        !          12578: #endif
        !          12579: 
        !          12580: char           univ_cond[] = "$(UNIVERSE)";
        !          12581: 
        !          12582: int            univ_size = sizeof(univ_cond) - 1;
        !          12583: 
        !          12584: #endif
        !          12585: 0707070000000001671006440044230044230000010000000475326251000003200000001376misc/univlib.hUgsfGgsf/*
        !          12586:  * G. S. Fowler
        !          12587:  * AT&T Bell Laboratories
        !          12588:  *
        !          12589:  * universe support
        !          12590:  *
        !          12591:  * symbolic link external representation has trailing '\0' and $(...) style
        !          12592:  * conditionals where $(...) corresponds to a kernel object (i.e., probably
        !          12593:  * not environ)
        !          12594:  *
        !          12595:  * universe symlink conditionals use $(UNIVERSE)
        !          12596:  */
        !          12597: 
        !          12598: #include "FEATURE/universe"
        !          12599: 
        !          12600: #ifdef _bin_universe
        !          12601: 
        !          12602: #include <limits.h>
        !          12603: #include <ls.h>
        !          12604: 
        !          12605: #ifdef _sys_universe
        !          12606: #include <sys/universe.h>
        !          12607: #endif
        !          12608: 
        !          12609: #ifndef PATH_MAX
        !          12610: #define PATH_MAX       1024
        !          12611: #endif
        !          12612: 
        !          12613: #ifdef NUMUNIV
        !          12614: #define UNIV_MAX       NUMUNIV
        !          12615: #else
        !          12616: #define UNIV_MAX       univ_max
        !          12617: extern char*           univ_name[];
        !          12618: extern int             univ_max;
        !          12619: #endif
        !          12620: 
        !          12621: extern char            univ_cond[];
        !          12622: extern int             univ_size;
        !          12623: 
        !          12624: #else
        !          12625: 
        !          12626: #define UNIV_SIZE      9
        !          12627: 
        !          12628: extern char            univ_env[];
        !          12629: 
        !          12630: #endif
        !          12631: 
        !          12632: #include <errno.h>
        !          12633: 
        !          12634: extern int             errno;
        !          12635: 0707070000000001701006440044230044230000010000000460411345100002700000003067port/copy.cUgsfGgsf/*
        !          12636:  * Glenn Fowler
        !          12637:  * AT&T Bell Laboratories
        !          12638:  *
        !          12639:  * copy from rfd to wfd (with conditional mmap hacks)
        !          12640:  */
        !          12641: 
        !          12642: #if sun
        !          12643: 
        !          12644: #include "FEATURE/mmap"
        !          12645: 
        !          12646: #ifdef _lib_mmap
        !          12647: 
        !          12648: #include <sys/types.h>
        !          12649: #include <sys/stat.h>
        !          12650: #include <sys/mman.h>
        !          12651: 
        !          12652: #define MAPSIZE                (1024*256)
        !          12653: 
        !          12654: extern int             munmap();
        !          12655: extern caddr_t         mmap();
        !          12656: 
        !          12657: #endif
        !          12658: 
        !          12659: #endif
        !          12660: 
        !          12661: #define round(x,y)     (((x)+(y)-1)&~((y)-1))
        !          12662: 
        !          12663: #define BUFSIZ         4096
        !          12664: 
        !          12665: /*
        !          12666:  * copy n bytes from rfd to wfd
        !          12667:  * actual byte count returned
        !          12668:  * if n<=0 then ``good'' size is used
        !          12669:  */
        !          12670: 
        !          12671: long
        !          12672: copy(rfd, wfd, n)
        !          12673: int    rfd;
        !          12674: int    wfd;
        !          12675: int    n;
        !          12676: {
        !          12677:        register long   c;
        !          12678: #ifdef MAPSIZE
        !          12679:        off_t           pos;
        !          12680:        off_t           mapsize;
        !          12681:        char*           mapbuf;
        !          12682:        struct stat     st;
        !          12683: 
        !          12684:        extern int              fstat();
        !          12685:        extern off_t            lseek();
        !          12686: #endif
        !          12687: 
        !          12688:        static int              bufsiz;
        !          12689:        static char*            buf;
        !          12690: 
        !          12691:        extern char*            malloc();
        !          12692: 
        !          12693:        if (n <= 0 || n >= BUFSIZ * 2)
        !          12694:        {
        !          12695: #if MAPSIZE
        !          12696:                if (!fstat(rfd, &st) && (st.st_mode & S_IFMT) == S_IFREG && (pos = lseek(rfd, (off_t)0, 1)) != ((off_t)-1))
        !          12697:                {
        !          12698:                        if (pos >= st.st_size) return(0);
        !          12699:                        mapsize = st.st_size - pos;
        !          12700:                        if (mapsize > MAPSIZE) mapsize = (mapsize > n && n > 0) ? n : MAPSIZE;
        !          12701:                        if (mapsize >= BUFSIZ * 2 && (mapbuf = mmap((caddr_t)0, mapsize, PROT_READ, MAP_SHARED, rfd, pos)) != ((caddr_t)-1))
        !          12702:                        {
        !          12703:                                if (write(wfd, mapbuf, mapsize) != mapsize || lseek(rfd, mapsize, 1) == ((off_t)-1)) return(-1);
        !          12704:                                (void)munmap(mapbuf, mapsize);
        !          12705:                                return(mapsize);
        !          12706:                        }
        !          12707:                }
        !          12708: #endif
        !          12709:                if (n <= 0) n = BUFSIZ;
        !          12710:        }
        !          12711:        if (n > bufsiz)
        !          12712:        {
        !          12713:                if (buf) free(buf);
        !          12714:                bufsiz = round(n, BUFSIZ);
        !          12715:                if (!(buf = malloc(bufsiz))) return(-1);
        !          12716:        }
        !          12717:        if ((c = read(rfd, buf, n)) > 0 && write(wfd, buf, c) != c) c = -1;
        !          12718:        return(c);
        !          12719: }
        !          12720: 0707070000000001711006440044230044230000010000000454126366000003000000000624port/fclex.cUgsfGgsf/*
        !          12721:  * set|clear file descriptor close-on-exec flag
        !          12722:  */
        !          12723: 
        !          12724: #include <errno.h>
        !          12725: #include <fcntl.h>
        !          12726: #ifndef F_SETFD
        !          12727: #include <sys/filio.h> /* 9th edition */
        !          12728: #endif
        !          12729: 
        !          12730: extern int     errno;
        !          12731: 
        !          12732: int
        !          12733: fclex(fd, flag)
        !          12734: int    fd;
        !          12735: int    flag;
        !          12736: {
        !          12737:        flag &= 01;
        !          12738: #ifdef F_SETFD
        !          12739:        return(fcntl(fd, F_SETFD, flag));
        !          12740: #else
        !          12741: #ifdef FIOCLEX
        !          12742:        return(ioctl(fd, flag ? FIOCLEX : FIONCLEX, 0));
        !          12743: #else
        !          12744:        errno = EINVAL;
        !          12745:        return(-1);
        !          12746: #endif
        !          12747: #endif
        !          12748: }
        !          12749: 0707070000000001721006440044230044230000010000000473371751100003100000032604port/genhdr.cUgsfGgsf/*
        !          12750:  * G. S. Fowler
        !          12751:  * AT&T Bell Laboratories
        !          12752:  *
        !          12753:  * generate libx header files
        !          12754:  * usually controlled by mkhdr
        !          12755:  *
        !          12756:  * genhdr hdr
        !          12757:  *
        !          12758:  * NOTE: two's complement binary integral representation assumed
        !          12759:  */
        !          12760: 
        !          12761: #if !lint
        !          12762: static char id[] = "\n@(#)genhdr (ulysses!gsf) 12/11/90\0\n";
        !          12763: #endif
        !          12764: 
        !          12765: #include "FEATURE/dir"
        !          12766: #include "FEATURE/getdents"
        !          12767: 
        !          12768: #include <lcllimits.h>
        !          12769: #include <lclparam.h>
        !          12770: #include <lcldirent.h>
        !          12771: #include <lclstdio.h>
        !          12772: 
        !          12773: #if !defined(_lcl_dirent) && defined(_sys_dir)
        !          12774: #include <sys/dir.h>
        !          12775: #endif
        !          12776: 
        !          12777: #ifndef SIG_IGN
        !          12778: #include <signal.h>
        !          12779: #endif
        !          12780: 
        !          12781: union _u_
        !          12782: {
        !          12783:        long            u1;
        !          12784:        char*           u2;
        !          12785:        double          u3;
        !          12786:        char            u4[1024];
        !          12787: };
        !          12788: 
        !          12789: struct _s_
        !          12790: {
        !          12791:        char            s1;
        !          12792:        union _u_       s2;
        !          12793: };
        !          12794: 
        !          12795: struct _m_
        !          12796: {
        !          12797:        char*           text;
        !          12798:        char*           name;
        !          12799:        int             value;
        !          12800: };
        !          12801: 
        !          12802: #define elements(x)    (sizeof(x)/sizeof(x[0]))
        !          12803: #define round(x,y)     (((x)+((y)-1))&~((y)-1))
        !          12804: 
        !          12805: static struct _m_ map[] =
        !          12806: {
        !          12807: #ifdef SIGABRT
        !          12808: "Abort",                       "ABRT",         SIGABRT,
        !          12809: #endif
        !          12810: #ifdef SIGALRM
        !          12811: "Alarm call",                  "ALRM",         SIGALRM,
        !          12812: #endif
        !          12813: #ifdef SIGAPOLLO
        !          12814: "Apollo",                      "APOLLO",       SIGAPOLLO,
        !          12815: #endif
        !          12816: #ifdef SIGBUS
        !          12817: "Bus error",                   "BUS",          SIGBUS,
        !          12818: #endif
        !          12819: #ifdef SIGCHLD
        !          12820: "Child status change",         "CHLD",         SIGCHLD,
        !          12821: #endif
        !          12822: #ifdef SIGCLD
        !          12823: "Death of child",              "CLD",          SIGCLD,
        !          12824: #endif
        !          12825: #ifdef SIGCONT
        !          12826: "Stopped process continued",   "CONT",         SIGCONT,
        !          12827: #endif
        !          12828: #ifdef SIGDEBUG
        !          12829: "Debug trap",                  "DEBUG",        SIGDEBUG,
        !          12830: #endif
        !          12831: #ifdef SIGEMT
        !          12832: "EMT trap",                    "EMT",          SIGEMT,
        !          12833: #endif
        !          12834: #ifdef SIGERR
        !          12835: "ERR trap",                    "ERR",          SIGERR,
        !          12836: #endif
        !          12837: #ifdef SIGEXIT
        !          12838: "Exit",                                "EXIT",         SIGEXIT,
        !          12839: #endif
        !          12840: #ifdef SIGFPE
        !          12841: "Floating exception",          "FPE",          SIGFPE,
        !          12842: #endif
        !          12843: #ifdef SIGHUP
        !          12844: "Hangup",                      "HUP",          SIGHUP,
        !          12845: #endif
        !          12846: #ifdef SIGILL
        !          12847: "Illegal instruction",         "ILL",          SIGILL,
        !          12848: #endif
        !          12849: #ifdef SIGINT
        !          12850: "Interrupt",                   "INT",          SIGINT,
        !          12851: #endif
        !          12852: #ifdef SIGIO
        !          12853: "IO possible",                 "IO",           SIGIO,
        !          12854: #endif
        !          12855: #ifdef SIGIOT
        !          12856: "IOT trap",                    "IOT",          SIGIOT,
        !          12857: #endif
        !          12858: #ifdef SIGKILL
        !          12859: "Killed",                      "KILL",         SIGKILL,
        !          12860: #endif
        !          12861: #ifdef SIGLAB
        !          12862: "LAB trap",                    "LAB",          SIGLAB,
        !          12863: #endif
        !          12864: #ifdef SIGKILL
        !          12865: "Killed",                      "KILL",         SIGKILL,
        !          12866: #endif
        !          12867: #ifdef SIGLOST
        !          12868: "Resources lost",              "LOST",         SIGLOST,
        !          12869: #endif
        !          12870: #ifdef SIGPHONE
        !          12871: "Phone status change",         "PHONE",        SIGPHONE,
        !          12872: #endif
        !          12873: #ifdef SIGPIPE
        !          12874: "Broken Pipe",                 "PIPE",         SIGPIPE,
        !          12875: #endif
        !          12876: #ifdef SIGPOLL
        !          12877: "Poll event",                  "POLL",         SIGPOLL,
        !          12878: #endif
        !          12879: #ifdef SIGPROF
        !          12880: "Profiling time alarm",                "PROF",         SIGPROF,
        !          12881: #endif
        !          12882: #ifdef SIGPWR
        !          12883: "Power fail",                  "PWR",          SIGPWR,
        !          12884: #endif
        !          12885: #ifdef SIGQUIT
        !          12886: "Quit",                                "QUIT",         SIGQUIT,
        !          12887: #endif
        !          12888: #ifdef SIGSEGV
        !          12889: "Memory fault",                        "SEGV",         SIGSEGV,
        !          12890: #endif
        !          12891: #ifdef SIGSSTOP
        !          12892: "Sendable stop",               "SSTOP",        SIGSSTOP,
        !          12893: #endif
        !          12894: #ifdef gould
        !          12895: "Stack overflow",              "STKOV",        28,
        !          12896: #endif
        !          12897: #ifdef SIGSTOP
        !          12898: "Stopped (signal)",            "STOP",         SIGSTOP,
        !          12899: #endif
        !          12900: #ifdef SIGSYS
        !          12901: "Bad system call",             "SYS",          SIGSYS,
        !          12902: #endif
        !          12903: #ifdef SIGTERM
        !          12904: "Terminated",                  "TERM",         SIGTERM,
        !          12905: #endif
        !          12906: #ifdef SIGTINT
        !          12907: "Interrupt (terminal)",                "TINT",         SIGTINT,
        !          12908: #endif
        !          12909: #ifdef SIGTRAP
        !          12910: "Trace/BPT trap",              "TRAP",         SIGTRAP,
        !          12911: #endif
        !          12912: #ifdef SIGTSTP
        !          12913: "Stopped",                     "TSTP",         SIGTSTP,
        !          12914: #endif
        !          12915: #ifdef SIGTTIN
        !          12916: "Stopped (tty input)",         "TTIN",         SIGTTIN,
        !          12917: #endif
        !          12918: #ifdef SIGTTOU
        !          12919: "Stopped (tty output)",                "TTOU",         SIGTTOU,
        !          12920: #endif
        !          12921: #ifdef SIGURG
        !          12922: "Urgent IO",                   "URG",          SIGURG,
        !          12923: #endif
        !          12924: #ifdef SIGUSR1
        !          12925: "User signal 1",               "USR1",         SIGUSR1,
        !          12926: #endif
        !          12927: #ifdef SIGUSR2
        !          12928: "User signal 2",               "USR2",         SIGUSR2,
        !          12929: #endif
        !          12930: #ifdef SIGVTALRM
        !          12931: "Virtual time alarm",          "VTALRM",       SIGVTALRM,
        !          12932: #endif
        !          12933: #ifdef SIGWINCH
        !          12934: "Window change",               "WINCH",        SIGWINCH,
        !          12935: #endif
        !          12936: #ifdef SIGWIND
        !          12937: "Window change",               "WIND",         SIGWIND,
        !          12938: #endif
        !          12939: #ifdef SIGWINDOW
        !          12940: "Window change",               "WINDOW",       SIGWINDOW,
        !          12941: #endif
        !          12942: #ifdef SIGXCPU
        !          12943: "CPU time limit",              "XCPU",         SIGXCPU,
        !          12944: #endif
        !          12945: #ifdef SIGXFSZ
        !          12946: "File size limit",             "XFSZ",         SIGXFSZ,
        !          12947: #endif
        !          12948: 0
        !          12949: };
        !          12950: 
        !          12951: static int     index[64];
        !          12952: 
        !          12953: main(argc, argv)
        !          12954: int    argc;
        !          12955: char** argv;
        !          12956: {
        !          12957:        register int    i;
        !          12958:        register int    j;
        !          12959:        register int    k;
        !          12960: 
        !          12961:        int             align0;
        !          12962:        int             align1;
        !          12963:        int             align2;
        !          12964:        unsigned long   bit1;
        !          12965:        unsigned long   bit2;
        !          12966:        unsigned long   bits0;
        !          12967:        unsigned long   bits1;
        !          12968:        unsigned long   bits2;
        !          12969:        union _u_       u;
        !          12970:        union _u_       v;
        !          12971: 
        !          12972:        char            c;
        !          12973:        unsigned char   uc;
        !          12974:        unsigned short  us;
        !          12975:        unsigned int    ui;
        !          12976:        unsigned long   ul;
        !          12977:        unsigned long   val;
        !          12978: 
        !          12979:        char*           hdr;
        !          12980: 
        !          12981:        if (argc != 2 || !(hdr = *++argv)) hdr = "UNKNOWN";
        !          12982:        if (!strcmp(hdr, "align"))
        !          12983:        {
        !          12984:                u.u2 = u.u4;
        !          12985:                v.u2 = u.u2 + 1;
        !          12986:                bit1 = u.u1 ^ v.u1;
        !          12987:                v.u2 = u.u2 + 2;
        !          12988:                bit2 = u.u1 ^ v.u1;
        !          12989:                align0 = sizeof(struct _s_) - sizeof(union _u_);
        !          12990:                bits0 = 0;
        !          12991:                k = 0;
        !          12992:                for (j = 0; j < align0; j++)
        !          12993:                {
        !          12994:                        u.u2 = u.u4 + j;
        !          12995:                        bits1 = 0;
        !          12996:                        for (i = 0; i < align0; i++)
        !          12997:                        {
        !          12998:                                v.u2 = u.u2 + i;
        !          12999:                                bits1 |= u.u1 ^ v.u1;
        !          13000:                        }
        !          13001:                        if (!bits0 || bits1 < bits0)
        !          13002:                        {
        !          13003:                                bits0 = bits1;
        !          13004:                                k = j;
        !          13005:                        }
        !          13006:                }
        !          13007:                align1 = round(align0, 2);
        !          13008:                u.u2 = u.u4 + k;
        !          13009:                for (bits1 = bits0; i < align1; i++)
        !          13010:                {
        !          13011:                        v.u2 = u.u2 + i;
        !          13012:                        bits1 |= u.u1 ^ v.u1;
        !          13013:                }
        !          13014:                align2 = round(align0, 4);
        !          13015:                for (bits2 = bits1; i < align2; i++)
        !          13016:                {
        !          13017:                        v.u2 = u.u2 + i;
        !          13018:                        bits2 |= u.u1 ^ v.u1;
        !          13019:                }
        !          13020:                printf("typedef unsigned %s INTEGRAL;\n", sizeof(char*) >= sizeof(long) ? "long" : sizeof(char*) >= sizeof(int) ? "int" : "short");
        !          13021:                printf("\n");
        !          13022:                printf("#define CHUNK           %d\n", sizeof(char*) >= 4 ? 8192 : 1024);
        !          13023:                printf("#define INTEGRAL        %s\n", sizeof(char*) >= sizeof(long) ? "long" : sizeof(char*) >= sizeof(int) ? "int" : "short");
        !          13024:                printf("#define INTEGER(x)      ((INTEGRAL)(x))\n");
        !          13025:                printf("#define POINTER(x)      ((char*)(x))\n");
        !          13026:                if (bits2 == (align2 - 1)) printf("#define ROUND(x,y)   POINTER(INTEGER((x)+(y)-1)&~((y)-1))\n");
        !          13027:                else printf("#define ROUND(x,y) POINTER(INTEGER(ALIGN(x)+(((y)+%d)/%d)-1)&~((((y)+%d)/%d)-1))\n", align0, align0, align0, align0);
        !          13028:                printf("\n");
        !          13029:                if (align0 == align2)
        !          13030:                {
        !          13031:                        printf("#define BOUND           BOUND2\n");
        !          13032:                        printf("#define ALIGN(x)        ALIGN2(x)\n");
        !          13033:                        printf("#define TRUNC(x)        TRUNC2(x)\n");
        !          13034:                }
        !          13035:                else if (align0 == align1)
        !          13036:                {
        !          13037:                        printf("#define BOUND           BOUND1\n");
        !          13038:                        printf("#define ALIGN(x)        ALIGN1(x)\n");
        !          13039:                        printf("#define TRUNC(x)        TRUNC1(x)\n");
        !          13040:                }
        !          13041:                else
        !          13042:                {
        !          13043:                        printf("#define BOUND           1\n");
        !          13044:                        printf("#define ALIGN(x)        POINTER(x)\n");
        !          13045:                        printf("#define TRUNC(x)        POINTER(x)\n");
        !          13046:                }
        !          13047:                printf("\n");
        !          13048:                printf("#define BIT1            0x%lx\n", bit1);
        !          13049:                if (align1 == align2)
        !          13050:                {
        !          13051:                        printf("#define BOUND1          BOUND2\n");
        !          13052:                        printf("#define ALIGN1(x)       ALIGN2(x)\n");
        !          13053:                        printf("#define TRUNC1(x)       TRUNC2(x)\n");
        !          13054:                }
        !          13055:                else
        !          13056:                {
        !          13057:                        printf("#define BOUND1          %d\n", align1);
        !          13058:                        printf("#define ALIGN1(x)       TRUNC1((x)+%d)\n", align1 - 1);
        !          13059:                        printf("#define TRUNC1(x)       POINTER(INTEGER((x)+%d)&0x%lx)\n", align1 - 1, ~(bits0|bits1));
        !          13060:                }
        !          13061:                printf("#define CLRBIT1(x)      POINTER(INTEGER(x)&0x%lx)\n", ~bit1);
        !          13062:                printf("#define SETBIT1(x)      POINTER(INTEGER(x)|0x%lx)\n", bit1);
        !          13063:                printf("#define TSTBIT1(x)      POINTER(INTEGER(x)&0x%lx)\n", bit1);
        !          13064:                printf("\n");
        !          13065:                printf("#define BIT2            0x%lx\n", bit2);
        !          13066:                printf("#define BOUND2          %d\n", align2);
        !          13067:                printf("#define ALIGN2(x)       TRUNC2((x)+%d)\n", align2 - 1);
        !          13068:                printf("#define TRUNC2(x)       POINTER(INTEGER(x)&0x%lx)\n", ~(bits0|bits1|bits2));
        !          13069:                printf("#define CLRBIT2(x)      POINTER(INTEGER(x)&0x%lx)\n", ~bit2);
        !          13070:                printf("#define SETBIT2(x)      POINTER(INTEGER(x)|0x%lx)\n", bit2);
        !          13071:                printf("#define TSTBIT2(x)      POINTER(INTEGER(x)&0x%lx)\n", bit2);
        !          13072:                printf("\n");
        !          13073:        }
        !          13074:        else if (!strcmp(hdr, "dirent"))
        !          13075:        {
        !          13076: #ifdef _lib_getdents
        !          13077:                printf("#define _dir_getdents   1       /* getdents() in library */\n");
        !          13078: #endif
        !          13079: #ifdef rewinddir
        !          13080:                printf("#define _dir_rewinddir  1       /* rewinddir locally defined */\n");
        !          13081: #endif
        !          13082: #ifdef _sys_dir
        !          13083:                printf("#define _dir_sys        1       /* #include <sys/dir.h> ok */\n");
        !          13084: #endif
        !          13085:                printf("\n");
        !          13086:        }
        !          13087:        else if (!strcmp(hdr, "fsinfo"))
        !          13088:        {
        !          13089: #ifdef BUFFERSIZE
        !          13090:                val = BUFFERSIZE;
        !          13091: #else
        !          13092: #ifdef MAXBSIZE
        !          13093:                val = MAXBSIZE;
        !          13094: #else
        !          13095: #ifdef SBUFSIZE
        !          13096:                val = SBUFSIZE;
        !          13097: #else
        !          13098: #ifdef BUFSIZ
        !          13099:                val = BUFSIZ;
        !          13100: #else
        !          13101:                if (sizeof(char*) > 4) val = 8192;
        !          13102:                else if (sizeof(char*) < 4) val = 512;
        !          13103:                else val = 4096;
        !          13104: #endif
        !          13105: #endif
        !          13106: #endif
        !          13107: #endif
        !          13108:                printf("#define BUFFERSIZE      %lu\n", val);
        !          13109:                printf("\n");
        !          13110:        }
        !          13111:        else if (!strcmp(hdr, "limits"))
        !          13112:        {
        !          13113:                /*
        !          13114:                 * <limits.h> with *constant* valued macros
        !          13115:                 */
        !          13116: 
        !          13117: #ifdef CHAR_BIT
        !          13118:                val = CHAR_BIT;
        !          13119:                printf("#undef  CHAR_BIT\n");
        !          13120: #else
        !          13121:                uc = 0;
        !          13122:                uc = ~uc;
        !          13123:                val = 1;
        !          13124:                while (uc >>= 1) val++;
        !          13125: #endif
        !          13126:                printf("#define CHAR_BIT        %lu\n", val);
        !          13127: 
        !          13128:                c = 0;
        !          13129:                c = ~c;
        !          13130:                uc = 0;
        !          13131:                uc = ~uc;
        !          13132:                us = 0;
        !          13133:                us = ~us;
        !          13134:                ui = 0;
        !          13135:                ui = ~ui;
        !          13136:                ul = 0;
        !          13137:                ul = ~ul;
        !          13138: 
        !          13139: #ifdef UCHAR_MAX
        !          13140:                val = UCHAR_MAX;
        !          13141:                printf("#undef  UCHAR_MAX\n");
        !          13142: #else
        !          13143:                val = uc;
        !          13144: #endif
        !          13145:                printf("#if __STDC__\n");
        !          13146:                printf("#define UCHAR_MAX       %luU\n", val);
        !          13147:                printf("#else\n");
        !          13148:                printf("#define UCHAR_MAX       %lu\n", val);
        !          13149:                printf("#endif\n");
        !          13150: 
        !          13151: #ifdef SCHAR_MIN
        !          13152:                val = -(SCHAR_MIN);
        !          13153:                printf("#undef  SCHAR_MIN\n");
        !          13154: #else
        !          13155:                val = (unsigned char)(uc >> 1) + 1;
        !          13156: #endif
        !          13157:                printf("#define SCHAR_MIN       -%lu\n", val);
        !          13158: 
        !          13159: #ifdef SCHAR_MAX
        !          13160:                val = SCHAR_MAX;
        !          13161:                printf("#undef  SCHAR_MAX\n");
        !          13162: #else
        !          13163:                val = (unsigned char)(uc >> 1);
        !          13164: #endif
        !          13165:                printf("#define SCHAR_MAX       %lu\n", val);
        !          13166: 
        !          13167:                if (c < 0)
        !          13168:                {
        !          13169: #ifdef CHAR_MIN
        !          13170:                        printf("#undef  CHAR_MIN\n");
        !          13171: #endif
        !          13172:                        printf("#define CHAR_MIN        SCHAR_MIN\n");
        !          13173: 
        !          13174: #ifdef CHAR_MAX
        !          13175:                        printf("#undef  CHAR_MAX\n");
        !          13176: #endif
        !          13177:                        printf("#define CHAR_MAX        SCHAR_MAX\n");
        !          13178:                }
        !          13179:                else
        !          13180:                {
        !          13181: #ifdef CHAR_MIN
        !          13182:                        printf("#undef  CHAR_MIN\n");
        !          13183: #endif
        !          13184:                        printf("#define CHAR_MIN        0\n");
        !          13185: 
        !          13186: #ifdef CHAR_MAX
        !          13187:                        printf("#undef  CHAR_MAX\n");
        !          13188: #endif
        !          13189:                        printf("#define CHAR_MAX        UCHAR_MAX\n");
        !          13190:                }
        !          13191: 
        !          13192: #ifdef USHRT_MAX
        !          13193:                val = USHRT_MAX;
        !          13194:                printf("#undef  USHRT_MAX\n");
        !          13195: #else
        !          13196:                val = us;
        !          13197: #endif
        !          13198:                printf("#if __STDC__\n");
        !          13199:                printf("#define USHRT_MAX       %luU\n", val);
        !          13200:                printf("#else\n");
        !          13201:                printf("#define USHRT_MAX       %lu\n", val);
        !          13202:                printf("#endif\n");
        !          13203: 
        !          13204: #ifdef SHRT_MIN
        !          13205:                val = -(SHRT_MIN);
        !          13206:                printf("#undef  SHRT_MIN\n");
        !          13207: #else
        !          13208:                val = (unsigned short)(us >> 1) + 1;
        !          13209: #endif
        !          13210:                printf("#define SHRT_MIN        -%lu\n", val);
        !          13211: 
        !          13212: #ifdef SHRT_MAX
        !          13213:                val = SHRT_MAX;
        !          13214:                printf("#undef  SHRT_MAX\n");
        !          13215: #else
        !          13216:                val = (unsigned short)(us >> 1);
        !          13217: #endif
        !          13218:                printf("#define SHRT_MAX        %lu\n", val);
        !          13219: 
        !          13220:                if (ui == us)
        !          13221:                {
        !          13222: #ifdef UINT_MAX
        !          13223:                        printf("#undef  UINT_MAX\n");
        !          13224: #endif
        !          13225:                        printf("#define UINT_MAX        USHRT_MAX\n");
        !          13226: 
        !          13227: #ifdef INT_MIN
        !          13228:                        printf("#undef  INT_MIN\n");
        !          13229: #endif
        !          13230:                        printf("#define INT_MIN         SHRT_MIN\n");
        !          13231: 
        !          13232: #ifdef INT_MAX
        !          13233:                        printf("#undef  INT_MAX\n");
        !          13234: #endif
        !          13235:                        printf("#define INT_MAX         SHRT_MAX\n");
        !          13236:                }
        !          13237:                else
        !          13238:                {
        !          13239: #ifdef UINT_MAX
        !          13240:                        val = UINT_MAX;
        !          13241:                        printf("#undef  UINT_MAX\n");
        !          13242: #else
        !          13243:                        val = ui;
        !          13244: #endif
        !          13245:                        printf("#if __STDC__\n");
        !          13246:                        printf("#define UINT_MAX        %luU\n", val);
        !          13247:                        printf("#else\n");
        !          13248:                        printf("#define UINT_MAX        %lu\n", val);
        !          13249:                        printf("#endif\n");
        !          13250: 
        !          13251: #ifdef INT_MIN
        !          13252:                        val = -(INT_MIN);
        !          13253:                        printf("#undef  INT_MIN\n");
        !          13254: #else
        !          13255:                        val = (unsigned int)(ui >> 1) + 1;
        !          13256: #endif
        !          13257:                        printf("#define INT_MIN         -%lu\n", val);
        !          13258: 
        !          13259: #ifdef INT_MAX
        !          13260:                        val = INT_MAX;
        !          13261:                        printf("#undef  INT_MAX\n");
        !          13262: #else
        !          13263:                        val = (unsigned int)(ui >> 1);
        !          13264: #endif
        !          13265:                        printf("#define INT_MAX         %lu\n", val);
        !          13266:                }
        !          13267: 
        !          13268:                if (ul == ui)
        !          13269:                {
        !          13270: #ifdef ULONG_MAX
        !          13271:                        printf("#undef  ULONG_MAX\n");
        !          13272: #endif
        !          13273:                        printf("#define ULONG_MAX       UINT_MAX\n");
        !          13274: 
        !          13275: #ifdef LONG_MIN
        !          13276:                        printf("#undef  LONG_MIN\n");
        !          13277: #endif
        !          13278:                        printf("#define LONG_MIN        INT_MIN\n");
        !          13279: 
        !          13280: #ifdef LONG_MAX
        !          13281:                        printf("#undef  LONG_MAX\n");
        !          13282: #endif
        !          13283:                        printf("#define LONG_MAX        INT_MAX\n");
        !          13284:                }
        !          13285:                else
        !          13286:                {
        !          13287: #ifdef ULONG_MAX
        !          13288:                        val = ULONG_MAX;
        !          13289:                        printf("#undef  ULONG_MAX\n");
        !          13290: #else
        !          13291:                        val = ui;
        !          13292: #endif
        !          13293:                        printf("#if __STDC__\n");
        !          13294:                        printf("#define ULONG_MAX       %luU\n", val);
        !          13295:                        printf("#else\n");
        !          13296:                        printf("#define ULONG_MAX       %lu\n", val);
        !          13297:                        printf("#endif\n");
        !          13298: 
        !          13299: #ifdef LONG_MIN
        !          13300:                        val = -(LONG_MIN);
        !          13301:                        printf("#undef  LONG_MIN\n");
        !          13302: #else
        !          13303:                        val = (unsigned long)(ul >> 1) + 1;
        !          13304: #endif
        !          13305:                        printf("#define LONG_MIN        -%lu\n", val);
        !          13306: 
        !          13307: #ifdef LONG_MAX
        !          13308:                        val = LONG_MAX;
        !          13309:                        printf("#undef  LONG_MAX\n");
        !          13310: #else
        !          13311:                        val = (unsigned long)(ul >> 1);
        !          13312: #endif
        !          13313:                        printf("#define LONG_MAX        %lu\n", val);
        !          13314:                }
        !          13315: 
        !          13316:                /*
        !          13317:                 * POSIX values
        !          13318:                 */
        !          13319: 
        !          13320:                printf("\n");
        !          13321:                printf("/*\n");
        !          13322:                printf(" * system implementation limits\n");
        !          13323:                printf(" */\n");
        !          13324:                printf("\n");
        !          13325: 
        !          13326: #ifdef ARG_MAX
        !          13327:                val = ARG_MAX;
        !          13328:                printf("#undef  ARG_MAX\n");
        !          13329: #else
        !          13330: #ifdef NCARGS
        !          13331:                val = NCARGS;
        !          13332: #else
        !          13333:                val = 5120;
        !          13334: #endif
        !          13335: #endif
        !          13336:                printf("#define ARG_MAX         %lu\n", val);
        !          13337: 
        !          13338: #ifdef MAX_CANON
        !          13339:                val = MAX_CANON;
        !          13340:                printf("#undef  MAX_CANON\n");
        !          13341: #else
        !          13342: #ifdef CANBSIZ
        !          13343:                val = CANBSIZ;
        !          13344: #else
        !          13345:                val = 256;
        !          13346: #endif
        !          13347: #endif
        !          13348:                printf("#define MAX_CANON       %lu\n", val);
        !          13349: 
        !          13350: #ifdef LINK_MAX
        !          13351:                val = LINK_MAX;
        !          13352:                printf("#undef  LINK_MAX\n");
        !          13353: #else
        !          13354: #ifdef MAXLINK
        !          13355:                val = MAXLINK;
        !          13356: #else
        !          13357: #ifdef SHRT_MAX
        !          13358:                val = SHRT_MAX;
        !          13359: #else
        !          13360:                val = (unsigned short)(us >> 1);
        !          13361: #endif
        !          13362: #endif
        !          13363: #endif
        !          13364:                printf("#define LINK_MAX        %lu\n", val);
        !          13365: 
        !          13366: #ifdef NGROUPS_MAX
        !          13367:                val = NGROUPS_MAX;
        !          13368:                printf("#undef  NGROUPS_MAX\n");
        !          13369: #else
        !          13370: #ifdef NGROUPS
        !          13371:                val = NGROUPS;
        !          13372: #else
        !          13373:                val = 0;
        !          13374: #endif
        !          13375: #endif
        !          13376:                printf("#define NGROUPS_MAX     %lu\n", val);
        !          13377: 
        !          13378: #ifdef PATH_MAX
        !          13379:                val = PATH_MAX;
        !          13380:                printf("#undef  PATH_MAX\n");
        !          13381: #else
        !          13382: #ifdef MAXPATHLEN
        !          13383:                val = MAXPATHLEN;
        !          13384: #else
        !          13385:                val = 1024;
        !          13386: #endif
        !          13387: #endif
        !          13388:                printf("#define PATH_MAX        %lu\n", val);
        !          13389: 
        !          13390: #ifdef OPEN_MAX
        !          13391:                val = OPEN_MAX;
        !          13392:                printf("#undef  OPEN_MAX\n");
        !          13393: #else
        !          13394:                val = 2;
        !          13395:                while ((i = dup(0)) >= 0)
        !          13396:                        if (i > val) val = i;
        !          13397: #endif
        !          13398:                printf("#define OPEN_MAX        %lu\n", val);
        !          13399: 
        !          13400: #ifdef OPEN_MAX_CEIL
        !          13401:                val = OPEN_MAX_CEIL;
        !          13402:                printf("#undef  OPEN_MAX_CEIL\n");
        !          13403:                printf("#define OPEN_MAX_CEIL   %lu\n", val);
        !          13404: #else
        !          13405:                printf("#define OPEN_MAX_CEIL   OPEN_MAX\n");
        !          13406: #endif
        !          13407:                printf("\n");
        !          13408:        }
        !          13409:        else if (!strcmp(hdr, "sigdata"))
        !          13410:        {
        !          13411:                /*
        !          13412:                 * sigdata.h for sigdata.c
        !          13413:                 */
        !          13414: 
        !          13415:                k = 0;
        !          13416:                for (i = 0; map[i].name; i++)
        !          13417:                        if ((j = map[i].value) > 0 && j < elements(index))
        !          13418:                        {
        !          13419:                                if (j > k) k = j;
        !          13420:                                index[j] = i;
        !          13421:                        }
        !          13422:                printf("int     sig_max = %d;\n", k);
        !          13423:                printf("\n");
        !          13424:                printf("char*   sig_name[] =\n");
        !          13425:                printf("{\n");
        !          13426:                for (i = 0; i <= k; i++)
        !          13427:                        if (j = index[i]) printf("      \"%s\",\n", map[j].name);
        !          13428:                        else printf("   \"%d\",\n", i);
        !          13429:                printf("};\n");
        !          13430:                printf("\n");
        !          13431:                printf("char*   sig_text[] =\n");
        !          13432:                printf("{\n");
        !          13433:                for (i = 0; i <= k; i++)
        !          13434:                        if (j = index[i]) printf("      \"%s\",\n", map[j].text);
        !          13435:                        else printf("   \"Signal %d\",\n", i);
        !          13436:                printf("};\n");
        !          13437:        }
        !          13438:        else
        !          13439:        {
        !          13440:                fprintf(stderr, "Usage: genhdr align ^ dirent ^ fsinfo ^ limits ^ sigdata\n");
        !          13441:                exit(1);
        !          13442:        }
        !          13443:        exit(0);
        !          13444: }
        !          13445: 0707070000000001731006440044230044230000010000000460145424500003200000001551port/iblocks.cUgsfGgsf/*
        !          13446:  * return number of blocks, including indirect block count
        !          13447:  * given stat info
        !          13448:  *
        !          13449:  * for systems not supporting stat.st_blocks
        !          13450:  */
        !          13451: 
        !          13452: #include <lclparam.h>
        !          13453: #include <fsinfo.h>
        !          13454: 
        !          13455: #ifndef stat_blocks
        !          13456: 
        !          13457: #ifndef B_DIRECT
        !          13458: #define B_DIRECT       10
        !          13459: #endif
        !          13460: 
        !          13461: #ifdef BITFS
        !          13462: 
        !          13463: #define B_SIZE         BSIZE(st->st_dev)
        !          13464: #define B_INDIRECT     NINDIR(st->st_dev)
        !          13465: 
        !          13466: #else
        !          13467: 
        !          13468: #ifdef BSIZE
        !          13469: #define B_SIZE         BSIZE
        !          13470: #else
        !          13471: #define B_SIZE         1024
        !          13472: #endif
        !          13473: 
        !          13474: #ifdef NINDIR
        !          13475: #define B_INDIRECT     NINDIR
        !          13476: #else
        !          13477: #define B_INDIRECT     128
        !          13478: #endif
        !          13479: 
        !          13480: #endif
        !          13481: 
        !          13482: #endif
        !          13483: 
        !          13484: long
        !          13485: iblocks(st)
        !          13486: struct stat*   st;
        !          13487: {
        !          13488: #ifdef stat_blocks
        !          13489:        return((st->st_blocks + 1) / 2);
        !          13490: #else
        !          13491:        long    b;
        !          13492:        long    t;
        !          13493: 
        !          13494:        t = b = (st->st_size + B_SIZE - 1) / B_SIZE;
        !          13495:        if ((b -= B_DIRECT) > 0)
        !          13496:        {
        !          13497:                t += (b - 1) / B_INDIRECT + 1;
        !          13498:                if ((b -= B_INDIRECT) > 0)
        !          13499:                {
        !          13500:                        t += (b - 1) / (B_INDIRECT * B_INDIRECT) + 1;
        !          13501:                        if (b > B_INDIRECT * B_INDIRECT) t++;
        !          13502:                }
        !          13503:        }
        !          13504:        return(t);
        !          13505: #endif
        !          13506: }
        !          13507: 0707070000000001741006440044230044230000010000000475447175700003100000022652port/mkhdr.shUgsfGgsf:
        !          13508: #
        !          13509: # mkhdr hdr [ genhdr ] [ cc [ ccflags ] ]
        !          13510: #
        !          13511: # @(#)mkhdr (ulysses!gsf) 01/31/91
        !          13512: #
        !          13513: case $# in
        !          13514: 0)     echo "Usage: $0 hdr [ genhdr ] [ cc [ ccflags ] ]" >&2; exit 1 ;;
        !          13515: esac
        !          13516: hdr=$1
        !          13517: shift
        !          13518: case $1 in
        !          13519: "")    genhdr= ;;
        !          13520: *)     genhdr=$1 ;;
        !          13521: esac
        !          13522: case $# in
        !          13523: 0)     ;;
        !          13524: *)     shift ;;
        !          13525: esac
        !          13526: cc=${1-cc}
        !          13527: case $# in
        !          13528: 0)     ;;
        !          13529: *)     shift ;;
        !          13530: esac
        !          13531: tmp=x.$$
        !          13532: trap 'code=$?; rm -f $tmp.?; exit $code' 0 1 2 3
        !          13533: case $hdr in
        !          13534: align) case $genhdr in
        !          13535:        "")     echo "$0: $hdr: genhdr arg required" >&2; exit 1 ;;
        !          13536:        esac
        !          13537:        cat <<!
        !          13538: /*
        !          13539:  * AT&T Bell Laboratories
        !          13540:  * alignment and pointer pun definitions
        !          13541:  * : : generated by $0 and $genhdr : :
        !          13542:  */
        !          13543: 
        !          13544: #ifndef __ALIGN_H__
        !          13545: #define __ALIGN_H__
        !          13546: 
        !          13547: !
        !          13548:        $genhdr $hdr || exit 1
        !          13549:        cat <<!
        !          13550: #endif
        !          13551: !
        !          13552:        ;;
        !          13553: dirent)        case $genhdr in
        !          13554:        "")     echo "$0: $hdr: genhdr arg required" >&2; exit 1 ;;
        !          13555:        esac
        !          13556:        cat<<!
        !          13557: /*
        !          13558:  * AT&T Bell Laboratories
        !          13559:  * directory stream access definitions
        !          13560:  *
        !          13561:  *     #include <sys/types.h>
        !          13562:  *     #include <dirent.h>
        !          13563:  *
        !          13564:  * : : generated by $0 and $genhdr : :
        !          13565:  */
        !          13566: 
        !          13567: #ifndef __DIRENT_H__
        !          13568: 
        !          13569: #include <lcldirent.h>
        !          13570: 
        !          13571: #ifndef __DIRENT_H__
        !          13572: #define __DIRENT_H__
        !          13573: #endif
        !          13574: 
        !          13575: !
        !          13576:        $genhdr $hdr || exit 1
        !          13577:        for i in "" "#ifndef d_ino
        !          13578: #define d_ino  d_fileno
        !          13579: #endif" "#ifndef d_fileno
        !          13580: #define d_fileno       d_ino
        !          13581: #endif"
        !          13582:        do      cat > $tmp.c <<!
        !          13583: #include <sys/types.h>
        !          13584: #include <lcldirent.h>
        !          13585: #ifdef _lcl_dirent
        !          13586: static struct dirent dir;
        !          13587: #else
        !          13588: #include <sys/dir.h>
        !          13589: static struct direct dir;
        !          13590: #endif
        !          13591: $i
        !          13592: int n1 = sizeof(dir.d_ino);
        !          13593: int n2 = sizeof(dir.d_fileno);
        !          13594: !
        !          13595:                if      $cc -I. ${1+"$@"} -c $tmp.c >/dev/null 2>&1
        !          13596:                then    break
        !          13597:                fi
        !          13598:        done
        !          13599:        nl=
        !          13600:        case $i in
        !          13601:        ?*)     nl=1
        !          13602:                echo "$i"
        !          13603:                ;;
        !          13604:        esac
        !          13605:        cat > $tmp.c <<!
        !          13606: #include <sys/types.h>
        !          13607: #include <lcldirent.h>
        !          13608: #ifdef _lcl_dirent
        !          13609: static struct dirent dir;
        !          13610: #else
        !          13611: #include <sys/dir.h>
        !          13612: static struct direct dir;
        !          13613: #endif
        !          13614: int n1 = sizeof(dir.d_namlen);
        !          13615: !
        !          13616:        if      $cc -I. ${1+"$@"} -c $tmp.c >/dev/null 2>&1
        !          13617:        then    nl=1
        !          13618:                echo "#define _dir_namlen       1       /* dirent.d_namlen */"
        !          13619:        fi
        !          13620:        case $nl in
        !          13621:        ?*)     echo ;;
        !          13622:        esac
        !          13623:        cat <<!
        !          13624: #ifndef _lcl_dirent
        !          13625: 
        !          13626: #ifdef _dir_sys
        !          13627: 
        !          13628: #include <sys/dir.h>
        !          13629: 
        !          13630: #else
        !          13631: 
        !          13632: #undef _dir_rewinddir
        !          13633: 
        !          13634: #define DIRSIZ 14
        !          13635: 
        !          13636: struct direct
        !          13637: {
        !          13638:        short   d_ino;
        !          13639:        char    d_name[DIRSIZ];
        !          13640: };
        !          13641: 
        !          13642: #endif
        !          13643: 
        !          13644: #ifdef _dir_rewinddir
        !          13645: 
        !          13646: /*
        !          13647:  * variable length directory entry format
        !          13648:  */
        !          13649: 
        !          13650: #define _dir_variable
        !          13651: 
        !          13652: #ifndef dirent
        !          13653: #define dirent direct
        !          13654: #endif
        !          13655: 
        !          13656: #else
        !          13657: 
        !          13658: /*
        !          13659:  * fixed length directory entry format
        !          13660:  */
        !          13661: 
        !          13662: #define _dir_fixed
        !          13663: 
        !          13664: #ifndef DIRSIZ
        !          13665: #define DIRSIZ         14              /* maximum entry link length    */
        !          13666: #endif
        !          13667: 
        !          13668: #ifndef MAXNAMLEN
        !          13669: #define        MAXNAMLEN       DIRSIZ          /* maximum filename length      */
        !          13670: #endif
        !          13671: 
        !          13672: #ifdef _dir_getdents
        !          13673: 
        !          13674: struct dirent                          /* data from local getdents()   */
        !          13675: {
        !          13676:        long            d_ino;          /* file number of entry         */
        !          13677:        long            d_off;          /* entry seek offset            */
        !          13678:        unsigned short  d_reclen;       /* length of this record        */
        !          13679:        char            d_name[1];      /* link name                    */
        !          13680: };
        !          13681: 
        !          13682: #else
        !          13683: 
        !          13684: #ifndef _dir_namlen
        !          13685: #define _dir_namlen    1
        !          13686: #endif
        !          13687: 
        !          13688: struct dirent                          /* data from readdir()          */
        !          13689: {
        !          13690:        long            d_fileno;       /* file number of entry         */
        !          13691:        unsigned short  d_reclen;       /* length of this record        */
        !          13692:        unsigned short  d_namlen;       /* strlen(d_name)               */
        !          13693:        char            d_name[1];      /* link name                    */
        !          13694: };
        !          13695: 
        !          13696: #endif
        !          13697: 
        !          13698: typedef struct
        !          13699: {
        !          13700:        int             dd_fd;          /* file descriptor              */
        !          13701:        int             dd_loc;         /* offset in block              */
        !          13702:        int             dd_size;        /* amount of valid data         */
        !          13703:        char*           dd_buf;         /* directory block              */
        !          13704: } DIR;                                 /* stream data from opendir()   */
        !          13705: 
        !          13706: extern DIR*            opendir();
        !          13707: extern struct dirent*  readdir();
        !          13708: extern long            telldir();
        !          13709: extern void            seekdir();
        !          13710: extern void            closedir();
        !          13711: 
        !          13712: #if !_dir_local
        !          13713: #define rewinddir(dirp)        seekdir(dirp,0L)
        !          13714: #endif
        !          13715: 
        !          13716: #endif
        !          13717: 
        !          13718: #endif
        !          13719: 
        !          13720: #if _dir_namlen
        !          13721: #define DIRNAMLEN(d)   ((d)->d_namlen)
        !          13722: #else
        !          13723: #define DIRNAMLEN(d)   strlen((d)->d_name)
        !          13724: #endif
        !          13725: 
        !          13726: #endif
        !          13727: !
        !          13728:        ;;
        !          13729: fsinfo)        case $genhdr in
        !          13730:        "")     echo "$0: $hdr: genhdr arg required" >&2; exit 1 ;;
        !          13731:        esac
        !          13732:        cat <<!
        !          13733: /*
        !          13734:  * AT&T Bell Laboratories
        !          13735:  * file system user interface definitions
        !          13736:  * : : generated by $0 and $genhdr : :
        !          13737:  */
        !          13738: 
        !          13739: #ifndef __FSINFO_H__
        !          13740: #define __FSINFO_H__
        !          13741: 
        !          13742: #ifndef __LCLPARAM_H__
        !          13743: #ifndef S_IFMT
        !          13744: #ifndef TM_DEFAULT
        !          13745: #include <sys/types.h>
        !          13746: #endif
        !          13747: #include <sys/stat.h>
        !          13748: #endif
        !          13749: #endif
        !          13750: !
        !          13751:        nl=
        !          13752:        for i in blocks blksize
        !          13753:        do      cat > $tmp.c <<!
        !          13754: #include <sys/types.h>
        !          13755: #include <sys/stat.h>
        !          13756: static struct stat st;
        !          13757: int bytes = sizeof(st.st_$i);
        !          13758: !
        !          13759:                if      $cc ${1+"$@"} -c $tmp.c >/dev/null 2>&1
        !          13760:                then    case $nl in
        !          13761:                        "")     nl=1
        !          13762:                                echo
        !          13763:                                ;;
        !          13764:                        esac
        !          13765:                        echo "#define stat_$i   1       /* struct stat has st_$i */"
        !          13766:                fi
        !          13767:        done
        !          13768:        cat > $tmp.c <<!
        !          13769: #include <sys/types.h>
        !          13770: #include <sys/stat.h>
        !          13771: #ifndef major
        !          13772: #include <sys/param.h>
        !          13773: #ifndef major
        !          13774: #include <sys/sysmacros.h>
        !          13775: #endif
        !          13776: "#ifndef major" =
        !          13777: #ifdef major
        !          13778: "#define major(x)" = major((x))
        !          13779: #else
        !          13780: "#define major(x)" = ((int)(((unsigned)(x)>>8)&0377))
        !          13781: #endif
        !          13782: "#endif" =
        !          13783: "#ifndef minor" =
        !          13784: #ifdef minor
        !          13785: "#define minor(x)" = minor((x))
        !          13786: #else
        !          13787: "#define minor(x)" = ((int)((x)&0377))
        !          13788: #endif
        !          13789: "#endif" =
        !          13790: "#ifndef makedev" =
        !          13791: #ifdef makedev
        !          13792: "#define makedev(x,y)" = makedev((x),(y))
        !          13793: #else
        !          13794: "#define makedev(x,y)" = ((dev_t)((((x)&0377)<<8)|((y)&0377)))
        !          13795: #endif
        !          13796: "#endif" =
        !          13797: #endif
        !          13798: !
        !          13799:        if      $cc ${1+"$@"} -E $tmp.c > $tmp.i 2>/dev/null
        !          13800:        then    sed -e '/"#/!d' -e 's/.*#/#/' -e 's/"[^=]*=//' $tmp.i
        !          13801:        else    cat <<!
        !          13802: 
        !          13803: #ifndef major
        !          13804: #define major(x)       ((int)(((unsigned)(x)>>8)&0377))
        !          13805: #endif
        !          13806: #ifndef minor
        !          13807: #define minor(x)       ((int)((x)&0377))
        !          13808: #endif
        !          13809: #ifndef makedev
        !          13810: #define makedev(x,y)   ((dev_t)((((x)&0377)<<8)|((y)&0377)))
        !          13811: #endif
        !          13812: !
        !          13813:        fi
        !          13814:        echo
        !          13815:        $genhdr $hdr || exit 1
        !          13816:        cat <<!
        !          13817: #endif
        !          13818: !
        !          13819:        ;;
        !          13820: lclparam)
        !          13821:        HDR=LCLPARAM
        !          13822:        cat <<!
        !          13823: /*
        !          13824:  * AT&T Bell Laboratories
        !          13825:  * <sys/param.h> + <sys/types.h> + <sys/stat.h>
        !          13826:  * : : generated by $0 : :
        !          13827:  */
        !          13828: 
        !          13829: #ifndef __${HDR}_H__
        !          13830: #define __${HDR}_H__
        !          13831: 
        !          13832: !
        !          13833:        for i in "#include <sys/param.h>" "#include <sys/param.h>
        !          13834: #ifndef S_IFDIR
        !          13835: #include <sys/stat.h>
        !          13836: #endif" "#include <sys/param.h>
        !          13837: #ifndef S_IFDIR
        !          13838: #include <sys/types.h>
        !          13839: #include <sys/stat.h>
        !          13840: #endif" "#ifndef S_IFDIR
        !          13841: #include <sys/types.h>
        !          13842: #include <sys/stat.h>
        !          13843: #endif"
        !          13844:        do      echo "$i
        !          13845: struct stat V_stat_V;
        !          13846: F_stat_F() { V_stat_V.st_mode = 0; }" > $tmp.c
        !          13847:                if      $cc ${1+"$@"} -c $tmp.c >/dev/null 2>&1
        !          13848:                then    echo "$i"
        !          13849:                        break
        !          13850:                fi
        !          13851:        done
        !          13852:        cat <<!
        !          13853: 
        !          13854: #endif
        !          13855: !
        !          13856:        ;;
        !          13857: lcl*)  lcl=`echo $hdr | sed -e 's/lcl//'`
        !          13858:        HDR=`echo $hdr | tr '[a-z]' '[A-Z]'`
        !          13859:        cat <<!
        !          13860: /*
        !          13861:  * AT&T Bell Laboratories
        !          13862:  * untrusted local <$lcl.h>
        !          13863:  * : : generated by $0 : :
        !          13864:  */
        !          13865: 
        !          13866: #ifndef __${HDR}_H__
        !          13867: #define __${HDR}_H__
        !          13868: 
        !          13869: !
        !          13870:        echo "#include <$lcl.h>" > $tmp.c
        !          13871:        if      $cc ${1+"$@"} -E $tmp.c > $tmp.i 2>/dev/null
        !          13872:        then    f=`sed -e '/^#[line     ]*1[    ][      ]*"\/.*\/'$lcl'\.h"/!d' -e '/\/sys\/'$lcl'\.h"/d' -e s'/.*"\(.*\)".*/\1/' $tmp.i`
        !          13873:        else    f=
        !          13874:        fi
        !          13875:        case $lcl in
        !          13876:        dirent) case $f in
        !          13877:                "")     h=sys/dir ;;
        !          13878:                *)      h=dirent ;;
        !          13879:                esac
        !          13880:                v=
        !          13881:                for i in DIR opendir readdir rewinddir seekdir telldir closedir
        !          13882:                do      cat > $tmp.c <<!
        !          13883: #include <sys/types.h>
        !          13884: #include <$h.h>
        !          13885: #ifndef $i
        !          13886: (
        !          13887: #endif
        !          13888: !
        !          13889:                        if      $cc ${1+"$@"} -c $tmp.c >/dev/null 2>&1
        !          13890:                        then    v="$v $i"
        !          13891:                        fi
        !          13892:                done
        !          13893:                case $v in
        !          13894:                ?*)     echo "#if _dir_local"
        !          13895:                        for i in $v
        !          13896:                        do      echo "#undef $i"
        !          13897:                        done
        !          13898:                        echo "#endif"
        !          13899:                        ;;
        !          13900:                esac
        !          13901:                ;;
        !          13902:        esac
        !          13903:        case $f in
        !          13904:        "")     echo "/* no local <$lcl.h> */"
        !          13905:                ;;
        !          13906:        *)      echo "/* begin local <$lcl.h> */"
        !          13907:                cat $f
        !          13908:                cat <<!
        !          13909: /* end local <$lcl.h> */
        !          13910: 
        !          13911: #undef _lcl_$lcl
        !          13912: #define _lcl_$lcl      1
        !          13913: !
        !          13914:                ;;
        !          13915:        esac
        !          13916:        cat <<!
        !          13917: 
        !          13918: #endif
        !          13919: !
        !          13920:        ;;
        !          13921: limits)        case $genhdr in
        !          13922:        "")     echo "$0: $hdr: genhdr arg required" >&2; exit 1 ;;
        !          13923:        esac
        !          13924:        cat <<!
        !          13925: /*
        !          13926:  * AT&T Bell Laboratories
        !          13927:  * C language implementation integral type sizes
        !          13928:  * : : generated by $0 and $genhdr : :
        !          13929:  */
        !          13930: 
        !          13931: #ifndef __LIMITS_H__
        !          13932: 
        !          13933: #include <lcllimits.h>
        !          13934: 
        !          13935: #ifndef __LIMITS_H__
        !          13936: #define __LIMITS_H__
        !          13937: #endif
        !          13938: 
        !          13939: !
        !          13940:        $genhdr $hdr || exit 1
        !          13941:        cat <<!
        !          13942: #endif
        !          13943: !
        !          13944:        ;;
        !          13945: preroot)cat <<!
        !          13946: /*
        !          13947:  * AT&T Bell Laboratories
        !          13948:  * preroot interface definitions
        !          13949:  * : : generated by $0 : :
        !          13950:  */
        !          13951: 
        !          13952: #ifndef __PREROOT_H__
        !          13953: #define __PREROOT_H__
        !          13954: 
        !          13955: !
        !          13956:        if      (/etc/preroot / /bin/echo) >/dev/null 2>&1
        !          13957:        then    cat <<!
        !          13958: #define FS_PREROOT     1                       /* preroot enabled      */
        !          13959: #define PR_BASE                "CCS"                   /* preroot base env var */
        !          13960: #define PR_COMMAND     "/etc/preroot"          /* the preroot command  */
        !          13961: #define PR_REAL                "/dev/.."               /* real root pathname   */
        !          13962: #define PR_SILENT      "CCSQUIET"              /* no command trace     */
        !          13963: 
        !          13964: #if __STDC__ || __cplusplus || c_plusplus
        !          13965: #if __cplusplus
        !          13966: extern "C" {
        !          13967: #endif
        !          13968: 
        !          13969: extern char*           getpreroot(char* path, char* cmd);
        !          13970: extern int             ispreroot();
        !          13971: extern int             realopen(char* path, int mode, int perm);
        !          13972: extern void            setpreroot(int argc, char** argv, char* dir);
        !          13973: 
        !          13974: #if __cplusplus
        !          13975: }
        !          13976: #endif
        !          13977: 
        !          13978: #else
        !          13979: 
        !          13980: extern char*           getpreroot();
        !          13981: extern int             ispreroot();
        !          13982: extern int             realopen();
        !          13983: extern void            setpreroot();
        !          13984: 
        !          13985: #endif
        !          13986: !
        !          13987:        else    echo "/* preroot not enabled */"
        !          13988:        fi
        !          13989:        cat <<!
        !          13990: 
        !          13991: #endif
        !          13992: !
        !          13993:        ;;
        !          13994: sig)   cat <<!
        !          13995: /*
        !          13996:  * AT&T Bell Laboratories
        !          13997:  * signal support
        !          13998:  * : : generated by $0 : :
        !          13999:  */
        !          14000: 
        !          14001: #ifndef __SIG_H__
        !          14002: #define __SIG_H__
        !          14003: 
        !          14004: #include <signal.h>
        !          14005: 
        !          14006: #ifndef sigmask
        !          14007: #define sigmask(s)     (1<<((s)-1))
        !          14008: #endif
        !          14009: 
        !          14010: !
        !          14011:        cat > $tmp.c <<!
        !          14012: #include <signal.h>
        !          14013: #ifdef TYPE
        !          14014: #if __STDC__
        !          14015: typedef TYPE (*signal_t)(int);
        !          14016: #else
        !          14017: typedef TYPE (*signal_t)();
        !          14018: #endif
        !          14019: #endif
        !          14020: signal_t f()
        !          14021: {
        !          14022:        signal_t        handler;
        !          14023:        handler = signal(1, SIG_IGN);
        !          14024:        return(handler);
        !          14025: }
        !          14026: !
        !          14027:        if      $cc ${1+"$@"} -c $tmp.c >/dev/null 2>&1
        !          14028:        then    :
        !          14029:        else    for i in void int
        !          14030:                do      $cc ${1+"$@"} -c -DTYPE=$i $tmp.c >/dev/null 2>&1 && break
        !          14031:                done
        !          14032:                cat <<!
        !          14033: #if __STDC__
        !          14034: typedef $i (*signal_t)(int);
        !          14035: #else
        !          14036: typedef $i (*signal_t)();
        !          14037: #endif
        !          14038: 
        !          14039: !
        !          14040:        fi
        !          14041:        cat <<!
        !          14042: #endif
        !          14043: !
        !          14044:        ;;
        !          14045: sigdata)case $genhdr in
        !          14046:        "")     echo "$0: $hdr: genhdr arg required" >&2; exit 1 ;;
        !          14047:        esac
        !          14048:        cat <<!
        !          14049: /*
        !          14050:  * AT&T Bell Laboratories
        !          14051:  * signal name/text tables
        !          14052:  * : : generated by $0 and $genhdr : :
        !          14053:  */
        !          14054: 
        !          14055: !
        !          14056:        $genhdr $hdr || exit 1
        !          14057:        ;;
        !          14058: ttyinfo)
        !          14059:        HDR=TTYINFO
        !          14060:        cat <<!
        !          14061: /*
        !          14062:  * AT&T Bell Laboratories
        !          14063:  * tty info
        !          14064:  * : : generated by $0 : :
        !          14065:  */
        !          14066: 
        !          14067: #ifndef __${HDR}_H__
        !          14068: #define __${HDR}_H__
        !          14069: 
        !          14070: !
        !          14071:        x="/* no local tty info */"
        !          14072:        for i in sgtty termio termios sys/termios sys/ttyio sys/ioctl
        !          14073:        do      echo "#include <$i.h>" > $tmp.c
        !          14074:                if      $cc ${1+"$@"} -c $tmp.c >/dev/null 2>&1
        !          14075:                then    x="#include <$i.h>"
        !          14076:                        break
        !          14077:                fi
        !          14078:        done
        !          14079:        cat <<!
        !          14080: $x
        !          14081: 
        !          14082: #endif
        !          14083: !
        !          14084:        ;;
        !          14085: *)     echo "$0: $hdr: unknown header" >&2
        !          14086:        exit 1
        !          14087:        ;;
        !          14088: esac
        !          14089: 0707070000000001751006440044230044230000010000000466623227100003200000000025port/sigdata.cUgsfGgsf#include "sigdata.h"
        !          14090: 0707070000000001761006440044230044230000010000000474213166300003000000004770port/touch.cUgsfGgsf/*
        !          14091:  * G. S. Fowler
        !          14092:  * AT&T Bell Laboratories
        !          14093:  *
        !          14094:  * touch file access and modify times of file
        !          14095:  * if force>0 then file will be created if it doesn't exist
        !          14096:  * if force<0 then times are taken verbatim
        !          14097:  * times have one second granularity
        !          14098:  *
        !          14099:  *     (time_t)(-1)    retain old time
        !          14100:  *     0               use current time
        !          14101:  */
        !          14102: 
        !          14103: #include <sys/types.h>
        !          14104: #include <sys/stat.h>
        !          14105: #include <errno.h>
        !          14106: 
        !          14107: #include "FEATURE/utime"
        !          14108: 
        !          14109: #if _hdr_utime && _lib_utime
        !          14110: #include <utime.h>
        !          14111: #endif
        !          14112: 
        !          14113: extern int     errno;
        !          14114: 
        !          14115: int
        !          14116: touch(file, atime, mtime, force)
        !          14117: char*  file;
        !          14118: time_t atime;
        !          14119: time_t mtime;
        !          14120: int    force;
        !          14121: {
        !          14122:        int             n;
        !          14123:        int             fd;
        !          14124:        int             oerrno = errno;
        !          14125: #if _lib_utime
        !          14126:        time_t          now;
        !          14127:        struct stat     st;
        !          14128: #if _hdr_utime
        !          14129:        struct utimbuf  ut;
        !          14130: #else
        !          14131:        time_t          ut[2];
        !          14132: #endif
        !          14133: 
        !          14134:        extern int      close();
        !          14135:        extern int      creat();
        !          14136:        extern int      stat();
        !          14137:        extern time_t   time();
        !          14138:        extern int      utime();
        !          14139: 
        !          14140:        if (force >= 0)
        !          14141:        {
        !          14142:                if (atime == (time_t)(-1) || mtime == (time_t)(-1))
        !          14143:                {
        !          14144:                        if (stat(file, &st)) st.st_atime = st.st_mtime = 0;
        !          14145:                        if (atime == (time_t)(-1)) atime = st.st_atime;
        !          14146:                        if (mtime == (time_t)(-1)) mtime = st.st_mtime;
        !          14147:                }
        !          14148:                if (!atime || !mtime)
        !          14149: #if _hdr_utime
        !          14150:                if (atime || mtime)
        !          14151: #endif
        !          14152:                {
        !          14153:                        (void)time(&now);
        !          14154:                        if (!atime) atime = now;
        !          14155:                        if (!mtime) mtime = now;
        !          14156:                }
        !          14157:        }
        !          14158: #if _hdr_utime
        !          14159:        ut.actime = atime;
        !          14160:        ut.modtime = mtime;
        !          14161:        n = utime(file, (force < 0 || atime || mtime) ? &ut : (struct utimbuf*)0);
        !          14162: #else
        !          14163:        ut[0] = atime;
        !          14164:        ut[1] = mtime;
        !          14165:        n = utime(file, ut);
        !          14166: #endif
        !          14167:        if (n)
        !          14168: #else
        !          14169:        if (mtime)
        !          14170:        {
        !          14171:                /*
        !          14172:                 * NOTE: the emulation allows atime to change
        !          14173:                 *       for mtime only requests
        !          14174:                 */
        !          14175: 
        !          14176:                errno = EINVAL;
        !          14177:                return(-1);
        !          14178:        }
        !          14179: #endif
        !          14180:        {
        !          14181: #if _lib_utime
        !          14182:                if (errno == ENOENT)
        !          14183: #else
        !          14184: 
        !          14185:                extern int      access();
        !          14186: 
        !          14187:                if (access(file, 0))
        !          14188: #endif
        !          14189:                {
        !          14190:                        if (!force || (fd = creat(file, 0666)) < 0) return(-1);
        !          14191:                        close(fd);
        !          14192:                        errno = oerrno;
        !          14193: #if _lib_utime
        !          14194: #if _hdr_utime
        !          14195:                        return((force < 0 || atime || mtime) ? utime(file, &ut) : 0);
        !          14196: #else
        !          14197:                        return((atime != now || mtime != now) ? utime(file, ut) : 0);
        !          14198: #endif
        !          14199: #else
        !          14200:                        return(0);
        !          14201: #endif
        !          14202:                }
        !          14203: #if !_hdr_utime || !_lib_utime
        !          14204: #if _lib_utime
        !          14205:                if (atime == now && mtime == now && (fd = open(file, 2)) >= 0)
        !          14206: #else
        !          14207:                if ((fd = open(file, 2)) >= 0)
        !          14208: #endif
        !          14209:                {
        !          14210:                        char    c;
        !          14211: 
        !          14212:                        extern long     lseek();
        !          14213:                        extern int      open();
        !          14214:                        extern int      read();
        !          14215:                        extern int      write();
        !          14216: 
        !          14217:                        if (read(fd, &c, 1) == 1)
        !          14218:                        {
        !          14219:                                if (lseek(fd, 0L, 0) == 0L && write(fd, &c, 1) == 1)
        !          14220:                                {
        !          14221:                                        errno = oerrno;
        !          14222:                                        n = 0;
        !          14223:                                }
        !          14224:                                close(fd);
        !          14225:                        }
        !          14226:                        else
        !          14227:                        {
        !          14228:                                close(fd);
        !          14229:                                if ((fd = creat(file, 0666)) >= 0)
        !          14230:                                {
        !          14231:                                        close(fd);
        !          14232:                                        errno = oerrno;
        !          14233:                                        n = 0;
        !          14234:                                }
        !          14235:                        }
        !          14236:                }
        !          14237: #endif
        !          14238:        }
        !          14239:        return(n);
        !          14240: }
        !          14241: 0707070000000001771006440044230044230000010000000463744205000003200000002660port/winsize.cUgsfGgsf/*
        !          14242:  * AT&T Bell Laboratories
        !          14243:  * return terminal rows and cols
        !          14244:  */
        !          14245: 
        !          14246: #include <ttyinfo.h>
        !          14247: 
        !          14248: #include "FEATURE/jioctl"
        !          14249: #ifdef _hdr_jioctl
        !          14250: #define winsize        jwinsize
        !          14251: #include <jioctl.h>
        !          14252: #undef winsize
        !          14253: #else
        !          14254: #ifdef _sys_jioctl
        !          14255: #define winsize        jwinsize
        !          14256: #include <sys/jioctl.h>
        !          14257: #undef winsize
        !          14258: #endif
        !          14259: #endif
        !          14260: 
        !          14261: static int     ttctl();
        !          14262: 
        !          14263: void
        !          14264: winsize(rows, cols)
        !          14265: register int*  rows;
        !          14266: register int*  cols;
        !          14267: {
        !          14268: #ifdef TIOCGSIZE
        !          14269:        struct ttysize  ts;
        !          14270: 
        !          14271:        if (!ttctl(TIOCGSIZE, &ts) && ts.ts_lines > 0 && ts.ts_cols > 0)
        !          14272:        {
        !          14273:                if (rows) *rows = ts.ts_lines;
        !          14274:                if (cols) *cols = ts.ts_cols;
        !          14275:        }
        !          14276:        else
        !          14277: #else
        !          14278: #ifdef TIOCGWINSZ
        !          14279:        struct winsize  ws;
        !          14280: 
        !          14281:        if (!ttctl(TIOCGWINSZ, &ws) && ws.ws_col > 0 && ws.ws_row > 0)
        !          14282:        {
        !          14283:                if (rows) *rows = ws.ws_row;
        !          14284:                if (cols) *cols = ws.ws_col;
        !          14285:        }
        !          14286:        else
        !          14287: #else
        !          14288: #ifdef JWINSIZE
        !          14289:        struct jwinsize ws;
        !          14290: 
        !          14291:        if (!ttctl(JWINSIZE, &ws) && ws.bytesx > 0 && ws.bytesy > 0)
        !          14292:        {
        !          14293:                if (rows) *rows = ws.bytesy;
        !          14294:                if (cols) *cols = ws.bytesx;
        !          14295:        }
        !          14296:        else
        !          14297: #endif
        !          14298: #endif
        !          14299: #endif
        !          14300:        {
        !          14301:                char*           s;
        !          14302: 
        !          14303:                extern int      atoi();
        !          14304:                extern char*    getenv();
        !          14305: 
        !          14306:                if (rows) *rows = (s = getenv("LINES")) ? atoi(s) : 0;
        !          14307:                if (cols) *cols = (s = getenv("COLUMNS")) ? atoi(s) : 0;
        !          14308:        }
        !          14309: }
        !          14310: 
        !          14311: /*
        !          14312:  * tty ioctl() -- no cache
        !          14313:  */
        !          14314: 
        !          14315: static int
        !          14316: ttctl(op, tt)
        !          14317: int    op;
        !          14318: char*  tt;
        !          14319: {
        !          14320:        register int    fd;
        !          14321:        register int    v;
        !          14322: 
        !          14323:        extern int      ioctl();
        !          14324: 
        !          14325:        for (fd = 0; fd <= 2; fd++)
        !          14326:                if (!ioctl(fd, op, tt)) return(0);
        !          14327:        if ((fd = open("/dev/tty", 0)) >= 0)
        !          14328:        {
        !          14329:                v = ioctl(fd, op, tt);
        !          14330:                (void)close(fd);
        !          14331:                return(v);
        !          14332:        }
        !          14333:        return(-1);
        !          14334: }
        !          14335: 0707070000000002001006440044230044230000010000000470170002700004000000005736preroot/getpreroot.cUgsfGgsf/*
        !          14336:  * AT&T Bell Laboratories
        !          14337:  * return the real absolute pathname of the preroot dir for cmd
        !          14338:  * if cmd==0 then current preroot path returned
        !          14339:  */
        !          14340: 
        !          14341: #include <preroot.h>
        !          14342: 
        !          14343: #if FS_PREROOT
        !          14344: 
        !          14345: #include <sys/types.h>
        !          14346: #include <sys/stat.h>
        !          14347: #include <dirent.h>
        !          14348: #include <errno.h>
        !          14349: #include <limits.h>
        !          14350: #include <stdio.h>
        !          14351: 
        !          14352: #ifndef PATH_MAX
        !          14353: #define PATH_MAX       1024
        !          14354: #endif
        !          14355: 
        !          14356: #ifndef ERANGE
        !          14357: #define ERANGE         E2BIG
        !          14358: #endif
        !          14359: 
        !          14360: #define ERROR(e)       {errno=e;goto error;}
        !          14361: 
        !          14362: extern int             errno;
        !          14363: 
        !          14364: extern char*           strdup();
        !          14365: 
        !          14366: char*
        !          14367: getpreroot(path, cmd)
        !          14368: char*  path;
        !          14369: char*  cmd;
        !          14370: {
        !          14371:        register int    c;
        !          14372:        register char*  p;
        !          14373:        register FILE*  fp;
        !          14374:        char            buf[PATH_MAX];
        !          14375: 
        !          14376:        if (!path) path = buf;
        !          14377:        if (cmd)
        !          14378:        {
        !          14379:                (void)sprintf(buf, "set x `%s= %s - </dev/null 2>&1`\nwhile :\ndo\nshift\ncase $# in\n[012]) break ;;\nesac\ncase \"$1 $2\" in\n\"+ %s\")       echo $3; break ;;\nesac\ndone\n", PR_SILENT, cmd, PR_COMMAND);
        !          14380:                if (!(fp = popen(buf, "rug"))) return(0);
        !          14381:                for (p = path; (c = getc(fp)) != EOF && c != '\n'; *p++ = c);
        !          14382:                *p = 0;
        !          14383:                (void)pclose(fp);
        !          14384:                if (path == p) return(0);
        !          14385:                return(path == buf ? strdup(path) : path);
        !          14386:        }
        !          14387:        else
        !          14388:        {
        !          14389:                char*           d;
        !          14390:                DIR*            dirp = 0;
        !          14391:                int             namlen;
        !          14392:                int             euid;
        !          14393:                int             ruid;
        !          14394:                struct dirent*  entry;
        !          14395:                struct stat*    cur;
        !          14396:                struct stat*    par;
        !          14397:                struct stat*    tmp;
        !          14398:                struct stat     curst;
        !          14399:                struct stat     parst;
        !          14400:                struct stat     tstst;
        !          14401:                char            dots[PATH_MAX];
        !          14402: 
        !          14403:                cur = &curst;
        !          14404:                par = &parst;
        !          14405:                if ((ruid = getuid()) != (euid = geteuid())) (void)setuid(ruid);
        !          14406:                if (stat(PR_REAL, cur) || stat("/", par) || cur->st_dev == par->st_dev && cur->st_ino == par->st_ino) ERROR(ENOTDIR);
        !          14407: 
        !          14408:                /*
        !          14409:                 * like getcwd() but starting at the preroot
        !          14410:                 */
        !          14411: 
        !          14412:                d = dots;
        !          14413:                *d++ = '/';
        !          14414:                p = path + PATH_MAX - 1;
        !          14415:                *p = 0;
        !          14416:                for (;;)
        !          14417:                {
        !          14418:                        tmp = cur;
        !          14419:                        cur = par;
        !          14420:                        par = tmp;
        !          14421:                        if ((d - dots) > (PATH_MAX - 4)) ERROR(ERANGE);
        !          14422:                        *d++ = '.';
        !          14423:                        *d++ = '.';
        !          14424:                        *d = 0;
        !          14425:                        if (!(dirp = opendir(dots)) || fstat(dirp->dd_fd, par)) ERROR(errno);
        !          14426:                        *d++ = '/';
        !          14427:                        if (par->st_dev == cur->st_dev)
        !          14428:                        {
        !          14429:                                if (par->st_ino == cur->st_ino)
        !          14430:                                {
        !          14431:                                        closedir(dirp);
        !          14432:                                        *--p = '/';
        !          14433:                                        if (ruid != euid) (void)setuid(euid);
        !          14434:                                        if (path == buf) return(strdup(p));
        !          14435:                                        if (path != p)
        !          14436:                                        {
        !          14437:                                                d = path;
        !          14438:                                                while (*d++ = *p++);
        !          14439:                                        }
        !          14440:                                        return(path);
        !          14441:                                }
        !          14442:                                while (entry = readdir(dirp))
        !          14443:                                        if (entry->d_ino == cur->st_ino)
        !          14444:                                        {
        !          14445:                                                namlen = DIRNAMLEN(entry);
        !          14446:                                                goto found;
        !          14447:                                        }
        !          14448:        
        !          14449:                                /*
        !          14450:                                 * this fallthrough handles logical naming
        !          14451:                                 */
        !          14452: 
        !          14453:                                rewinddir(dirp);
        !          14454:                        }
        !          14455:                        do
        !          14456:                        {
        !          14457:                                if (!(entry = readdir(dirp))) ERROR(ENOENT);
        !          14458:                                namlen = DIRNAMLEN(entry);
        !          14459:                                if ((d - dots) > (PATH_MAX - 1 - namlen)) ERROR(ERANGE);
        !          14460:                                (void)memcpy(d, entry->d_name, namlen + 1);
        !          14461:                                if (stat(dots, &tstst)) ERROR(errno);
        !          14462:                        } while (tstst.st_ino != cur->st_ino || tstst.st_dev != cur->st_dev);
        !          14463:                found:
        !          14464:                        if (*p) *--p = '/';
        !          14465:                        if ((p -= namlen) <= (path + 1)) ERROR(ERANGE);
        !          14466:                        (void)memcpy(p, entry->d_name, namlen);
        !          14467:                        closedir(dirp);
        !          14468:                        dirp = 0;
        !          14469:                }
        !          14470:        error:
        !          14471:                if (dirp) closedir(dirp);
        !          14472:                if (ruid != euid) (void)setuid(euid);
        !          14473:        }
        !          14474:        return(0);
        !          14475: }
        !          14476: 
        !          14477: #else
        !          14478: 
        !          14479: int    _lib_dummy;
        !          14480: 
        !          14481: #endif
        !          14482: 0707070000000002011006440044230044230000010000000451442135700003700000001636preroot/ispreroot.cUgsfGgsf/*
        !          14483:  * AT&T Bell Laboratories
        !          14484:  * return 1 if dir [any dir] is the preroot
        !          14485:  */
        !          14486: 
        !          14487: #include <preroot.h>
        !          14488: 
        !          14489: #if FS_PREROOT
        !          14490: 
        !          14491: #include <sys/types.h>
        !          14492: #include <sys/stat.h>
        !          14493: 
        !          14494: static int     same();
        !          14495: 
        !          14496: int
        !          14497: ispreroot(dir)
        !          14498: char*  dir;
        !          14499: {
        !          14500:        static int      prerooted = -1;
        !          14501: 
        !          14502:        if (dir) return(same("/", dir));
        !          14503:        if (prerooted < 0) prerooted = !same("/", PR_REAL);
        !          14504:        return(prerooted);
        !          14505: }
        !          14506: 
        !          14507: /*
        !          14508:  * return 1 if files a and b are the same under preroot
        !          14509:  *
        !          14510:  * NOTE: the kernel disables preroot for set-uid processes
        !          14511:  */
        !          14512: 
        !          14513: static int
        !          14514: same(a, b)
        !          14515: char*  a;
        !          14516: char*  b;
        !          14517: {
        !          14518:        int             i;
        !          14519:        int             euid;
        !          14520:        int             ruid;
        !          14521: 
        !          14522:        struct stat     ast;
        !          14523:        struct stat     bst;
        !          14524: 
        !          14525:        extern int      geteuid();
        !          14526:        extern int      getuid();
        !          14527:        extern int      setuid();
        !          14528:        extern int      stat();
        !          14529: 
        !          14530:        if ((ruid = getuid()) != (euid = geteuid())) (void)setuid(ruid);
        !          14531:        i = !stat(a, &ast) && !stat(b, &bst) && ast.st_dev == bst.st_dev && ast.st_ino == bst.st_ino;
        !          14532:        if (ruid != euid) (void)setuid(euid);
        !          14533:        return(i);
        !          14534: }
        !          14535: 
        !          14536: #else
        !          14537: 
        !          14538: int    _lib_dummy;
        !          14539: 
        !          14540: #endif
        !          14541: 0707070000000002021006440044230044230000010000000451416302400003600000000767preroot/realopen.cUgsfGgsf/*
        !          14542:  * AT&T Bell Laboratories
        !          14543:  * disable preroot and open path relative to the real root
        !          14544:  */
        !          14545: 
        !          14546: #include <preroot.h>
        !          14547: 
        !          14548: #if FS_PREROOT
        !          14549: 
        !          14550: #include <limits.h>
        !          14551: 
        !          14552: #ifndef PATH_MAX
        !          14553: #define PATH_MAX       1024
        !          14554: #endif
        !          14555: 
        !          14556: int
        !          14557: realopen(path, mode, perm)
        !          14558: char*  path;
        !          14559: int    mode;
        !          14560: int    perm;
        !          14561: {
        !          14562:        char            buf[PATH_MAX + 8];
        !          14563: 
        !          14564:        extern int      open();
        !          14565:        extern char*    strcopy();
        !          14566: 
        !          14567:        if (*path != '/' || !ispreroot((char*)0)) return(-1);
        !          14568:        (void)strcopy(strcopy(buf, PR_REAL), path);
        !          14569:        return(open(buf, mode, perm));
        !          14570: }
        !          14571: 
        !          14572: #else
        !          14573: 
        !          14574: int    _lib_dummy;
        !          14575: 
        !          14576: #endif
        !          14577: 0707070000000002031006440044230044230000010000000460465034500004000000002117preroot/setpreroot.cUgsfGgsf/*
        !          14578:  * AT&T Bell Laboratories
        !          14579:  * force current command to run under dir preroot
        !          14580:  */
        !          14581: 
        !          14582: #include <preroot.h>
        !          14583: 
        !          14584: #if FS_PREROOT
        !          14585: 
        !          14586: #include <limits.h>
        !          14587: #include <stdio.h>
        !          14588: 
        !          14589: #ifndef PATH_MAX
        !          14590: #define PATH_MAX       1024
        !          14591: #endif
        !          14592: 
        !          14593: extern char*   getenv();
        !          14594: extern char*   malloc();
        !          14595: extern char*   pathpath();
        !          14596: 
        !          14597: void
        !          14598: setpreroot(argv, dir)
        !          14599: register char**        argv;
        !          14600: char*          dir;
        !          14601: {
        !          14602:        register char*  s;
        !          14603:        register char** ap;
        !          14604:        int             argc;
        !          14605:        char*           cmd;
        !          14606:        char**          av;
        !          14607:        char            buf[PATH_MAX];
        !          14608: 
        !          14609:        extern char**   opt_argv;
        !          14610: 
        !          14611:        if ((argv || (argv = opt_argv)) && (dir || (dir = getenv(PR_BASE)) && *dir) && !ispreroot(dir) && (*(cmd = *argv++) == '/' || (cmd = pathpath(buf, cmd, (char*)0, 031))))
        !          14612:        {
        !          14613:                argc = 3;
        !          14614:                for (ap = argv; *ap++; argc++);
        !          14615:                if (av = (char**)malloc(argc * sizeof(char**)))
        !          14616:                {
        !          14617:                        ap = av;
        !          14618:                        *ap++ = PR_COMMAND;
        !          14619:                        *ap++ = dir;
        !          14620:                        *ap++ = cmd;
        !          14621:                        while (*ap++ = *argv++);
        !          14622:                        if (!(s = getenv(PR_SILENT)) || !*s)
        !          14623:                        {
        !          14624:                                fprintf(stderr, "+");
        !          14625:                                ap = av;
        !          14626:                                while (s = *ap++)
        !          14627:                                        fprintf(stderr, " %s", s);
        !          14628:                                fprintf(stderr, "\n");
        !          14629:                                fflush(stderr);
        !          14630:                        }
        !          14631:                        execv(*av, av);
        !          14632:                        free(av);
        !          14633:                }
        !          14634:        }
        !          14635: }
        !          14636: 
        !          14637: #else
        !          14638: 
        !          14639: int    _lib_dummy;
        !          14640: 
        !          14641: #endif
        !          14642: 0707070000000002041006440044230044230000010000000475453717200002700000022664re/recomp.cUgsfGgsf/*
        !          14643:  * AT&T Bell Laboratories
        !          14644:  *
        !          14645:  * regular expression compiler
        !          14646:  *
        !          14647:  * derived from the 9th edition regexp(3):
        !          14648:  *
        !          14649:  *     \[0-9] sub-expression references allowed in patterns
        !          14650:  *
        !          14651:  *     8 bit transparent
        !          14652:  *
        !          14653:  *     ed(1) style syntax supported as option
        !          14654:  */
        !          14655: 
        !          14656: #include "relib.h"
        !          14657: 
        !          14658: #if DEBUG
        !          14659: #include <stdio.h>
        !          14660: #endif
        !          14661: 
        !          14662: typedef struct Node                    /* parser info                  */
        !          14663: {
        !          14664:        Inst*   first;
        !          14665:        Inst*   last;
        !          14666: } Node;
        !          14667: 
        !          14668: #define        NSTACK  32                      /* misc stack depth             */
        !          14669: 
        !          14670: struct state
        !          14671: {
        !          14672:        Node    andstack[NSTACK];
        !          14673:        Node*   andp;
        !          14674:        int     atorstack[NSTACK];
        !          14675:        int*    atorp;
        !          14676:        int     subidstack[NSTACK];     /* parallel to atorstack        */
        !          14677:        int*    subidp;
        !          14678:        int     cursubid;               /* current sub-expression id    */
        !          14679:        int     refsubid;               /* reference sub-expression id  */
        !          14680:        int     lastwasand;             /* last token was operand       */
        !          14681:        int     nbra;
        !          14682:        unsigned char*  exprp;          /* next source expression char  */
        !          14683:        int     nclass;
        !          14684:        Class*  classp;
        !          14685:        Inst*   freep;
        !          14686:        int     errors;
        !          14687:        int     flags;                  /* RE_MATCH if '\[0-9]'         */
        !          14688: };
        !          14689: 
        !          14690: static struct state*   re;             /* compiler state               */
        !          14691: 
        !          14692: #if __STDC__ || __cplusplus
        !          14693: extern int     chresc(const char*, char**);
        !          14694: extern char*   memset(char*, int, int);
        !          14695: extern char*   strcopy(char*, const char*);
        !          14696: #else
        !          14697: extern int     chresc();
        !          14698: extern char*   memset();
        !          14699: extern char*   strcopy();
        !          14700: #endif
        !          14701: 
        !          14702: static void
        !          14703: rcerror(s)
        !          14704: char*  s;
        !          14705: {
        !          14706:        re->errors++;
        !          14707:        reerror(s);
        !          14708: }
        !          14709: 
        !          14710: static void
        !          14711: reerr2(s, c)
        !          14712: register char* s;
        !          14713: int            c;
        !          14714: {
        !          14715:        char    buf[100];
        !          14716: 
        !          14717:        s = strcopy(buf, s);
        !          14718:        *s++ = c;
        !          14719:        *s = 0;
        !          14720:        rcerror(buf);
        !          14721: }
        !          14722: 
        !          14723: static void
        !          14724: cant(s)
        !          14725: char*  s;
        !          14726: {
        !          14727:        char    buf[100];
        !          14728: 
        !          14729:        (void)strcopy(strcopy(buf, "internal error: "), s);
        !          14730:        rcerror(buf);
        !          14731: }
        !          14732: 
        !          14733: static Inst*
        !          14734: newinst(t)
        !          14735: int    t;
        !          14736: {
        !          14737:        re->freep->type = t;
        !          14738:        re->freep->left = 0;
        !          14739:        re->freep->right = 0;
        !          14740:        return(re->freep++);
        !          14741: }
        !          14742: 
        !          14743: static void
        !          14744: pushand(f, l)
        !          14745: Inst*  f;
        !          14746: Inst*  l;
        !          14747: {
        !          14748:        if (re->andp >= &re->andstack[NSTACK]) cant("operand stack overflow");
        !          14749:        re->andp->first = f;
        !          14750:        re->andp->last = l;
        !          14751:        re->andp++;
        !          14752: }
        !          14753: 
        !          14754: static Node*
        !          14755: popand(op)
        !          14756: int    op;
        !          14757: {
        !          14758:        register Inst*  inst;
        !          14759: 
        !          14760:        if (re->andp <= &re->andstack[0])
        !          14761:        {
        !          14762:                reerr2("missing operand for ", op);
        !          14763:                inst = newinst(NOP);
        !          14764:                pushand(inst, inst);
        !          14765:        }
        !          14766:        return(--re->andp);
        !          14767: }
        !          14768: 
        !          14769: static void
        !          14770: pushator(t)
        !          14771: int    t;
        !          14772: {
        !          14773:        if (re->atorp >= &re->atorstack[NSTACK]) cant("operator stack overflow");
        !          14774:        *re->atorp++ = t;
        !          14775:        *re->subidp++ = re->cursubid;
        !          14776: }
        !          14777: 
        !          14778: static int
        !          14779: popator()
        !          14780: {
        !          14781:        if (re->atorp <= &re->atorstack[0]) cant("operator stack underflow");
        !          14782:        re->subidp--;
        !          14783:        return(*--re->atorp);
        !          14784: }
        !          14785: 
        !          14786: static void
        !          14787: evaluntil(pri)
        !          14788: register int   pri;
        !          14789: {
        !          14790:        register Node*  op1;
        !          14791:        register Node*  op2;
        !          14792:        register Inst*  inst1;
        !          14793:        register Inst*  inst2;
        !          14794: 
        !          14795:        while (pri == RBRA || re->atorp[-1] >= pri)
        !          14796:        {
        !          14797:                switch(popator())
        !          14798:                {
        !          14799:                case LBRA:
        !          14800:                        /*
        !          14801:                         * must have been RBRA
        !          14802:                         */
        !          14803: 
        !          14804:                        op1 = popand('(');
        !          14805:                        inst2 = newinst(RBRA);
        !          14806:                        inst2->subid = *re->subidp;
        !          14807:                        op1->last->next = inst2;
        !          14808:                        inst1 = newinst(LBRA);
        !          14809:                        inst1->subid = *re->subidp;
        !          14810:                        inst1->next = op1->first;
        !          14811:                        pushand(inst1, inst2);
        !          14812:                        return;
        !          14813:                case OR:
        !          14814:                        op2 = popand('|');
        !          14815:                        op1 = popand('|');
        !          14816:                        inst2 = newinst(NOP);
        !          14817:                        op2->last->next = inst2;
        !          14818:                        op1->last->next = inst2;
        !          14819:                        inst1 = newinst(OR);
        !          14820:                        inst1->right = op1->first;
        !          14821:                        inst1->left = op2->first;
        !          14822:                        pushand(inst1, inst2);
        !          14823:                        break;
        !          14824:                case CAT:
        !          14825:                        op2 = popand(0);
        !          14826:                        op1 = popand(0);
        !          14827:                        op1->last->next = op2->first;
        !          14828:                        pushand(op1->first, op2->last);
        !          14829:                        break;
        !          14830:                case STAR:
        !          14831:                        op2 = popand('*');
        !          14832:                        inst1 = newinst(OR);
        !          14833:                        op2->last->next = inst1;
        !          14834:                        inst1->right = op2->first;
        !          14835:                        pushand(inst1, inst1);
        !          14836:                        break;
        !          14837:                case PLUS:
        !          14838:                        op2 = popand('+');
        !          14839:                        inst1 = newinst(OR);
        !          14840:                        op2->last->next = inst1;
        !          14841:                        inst1->right = op2->first;
        !          14842:                        pushand(op2->first, inst1);
        !          14843:                        break;
        !          14844:                case QUEST:
        !          14845:                        op2 = popand('?');
        !          14846:                        inst1 = newinst(OR);
        !          14847:                        inst2 = newinst(NOP);
        !          14848:                        inst1->left = inst2;
        !          14849:                        inst1->right = op2->first;
        !          14850:                        op2->last->next = inst2;
        !          14851:                        pushand(inst1, inst2);
        !          14852:                        break;
        !          14853:                default:
        !          14854:                        cant("unknown operator in evaluntil()");
        !          14855:                        break;
        !          14856:                }
        !          14857:        }
        !          14858: }
        !          14859: 
        !          14860: static void
        !          14861: operator(t)
        !          14862: register int   t;
        !          14863: {
        !          14864:        register int    thisisand = 0;
        !          14865: 
        !          14866:        switch (t)
        !          14867:        {
        !          14868:        case LBRA:
        !          14869:                if (re->cursubid < RE_NMATCH) re->cursubid++;
        !          14870:                re->nbra++;
        !          14871:                if (re->lastwasand) operator(CAT);
        !          14872:                pushator(t);
        !          14873:                re->lastwasand = 0;
        !          14874:                break;
        !          14875:        case RBRA:
        !          14876:                if (--re->nbra < 0) rcerror("unmatched )");
        !          14877:                evaluntil(t);
        !          14878:                re->lastwasand = 1;
        !          14879:                break;
        !          14880:        case STAR:
        !          14881:        case QUEST:
        !          14882:        case PLUS:
        !          14883:                thisisand = 1;
        !          14884:                /* fall through ... */
        !          14885:        default:
        !          14886:                evaluntil(t);
        !          14887:                pushator(t);
        !          14888:                re->lastwasand = thisisand;
        !          14889:                break;
        !          14890:        }
        !          14891: }
        !          14892: 
        !          14893: static void
        !          14894: operand(t)
        !          14895: int    t;
        !          14896: {
        !          14897:        register Inst*  i;
        !          14898: 
        !          14899:        /*
        !          14900:         * catenate is implicit
        !          14901:         */
        !          14902: 
        !          14903:        if (re->lastwasand) operator(CAT);
        !          14904:        i = newinst(t);
        !          14905:        switch (t)
        !          14906:        {
        !          14907:        case CCLASS:
        !          14908:                i->cclass = re->classp[re->nclass - 1].map;
        !          14909:                break;
        !          14910:        case SUBEXPR:
        !          14911:                i->subid = re->refsubid;
        !          14912:                break;
        !          14913:        }
        !          14914:        pushand(i, i);
        !          14915:        re->lastwasand = 1;
        !          14916: }
        !          14917: 
        !          14918: static void
        !          14919: optimize(pp)
        !          14920: Prog*  pp;
        !          14921: {
        !          14922:        register Inst*  inst;
        !          14923:        register Inst*  target;
        !          14924: 
        !          14925:        for (inst = pp->firstinst; inst->type != END; inst++)
        !          14926:        {
        !          14927:                target = inst->next;
        !          14928:                while (target->type == NOP) target = target->next;
        !          14929:                inst->next = target;
        !          14930:        }
        !          14931: }
        !          14932: 
        !          14933: #if DEBUG
        !          14934: static void
        !          14935: dumpstack()
        !          14936: {
        !          14937:        Node*   stk;
        !          14938:        int*    ip;
        !          14939: 
        !          14940:        printf("operators\n");
        !          14941:        for (ip = re->atorstack; ip < re->atorp; ip++)
        !          14942:                printf("0%o\n", *ip);
        !          14943:        printf("operands\n");
        !          14944:        for (stk = re->andstack; stk < re->andp; stk++)
        !          14945:                printf("0%o\t0%o\n", stk->first->type, stk->last->type);
        !          14946: }
        !          14947: 
        !          14948: static void
        !          14949: dump(pp)
        !          14950: Prog*  pp;
        !          14951: {
        !          14952:        Inst*   l;
        !          14953: 
        !          14954:        l = pp->firstinst;
        !          14955:        do
        !          14956:        {
        !          14957:                printf("%d:\t0%o\t%d\t%d\n",
        !          14958:                        l-pp->firstinst, l->type,
        !          14959:                        l->left-pp->firstinst, l->right-pp->firstinst);
        !          14960:        } while (l++->type);
        !          14961: }
        !          14962: #endif
        !          14963: 
        !          14964: static int
        !          14965: nextc()
        !          14966: {
        !          14967:        register int    c;
        !          14968: 
        !          14969:        switch (c = *re->exprp++)
        !          14970:        {
        !          14971:        case 0:
        !          14972:                rcerror("missing ] in character class");
        !          14973:                break;
        !          14974:        case '\\':
        !          14975:                if (!(c = chresc((char*)re->exprp - 1, (char**)&re->exprp)))
        !          14976:                        rcerror("trailing \\ is invalid");
        !          14977:                break;
        !          14978:        case ']':
        !          14979:                c = 0;
        !          14980:                break;
        !          14981:        }
        !          14982:        return(c);
        !          14983: }
        !          14984: 
        !          14985: static void
        !          14986: bldcclass()
        !          14987: {
        !          14988:        register int    c1;
        !          14989:        register int    c2;
        !          14990:        register char*  map;
        !          14991:        register int    negate;
        !          14992: 
        !          14993:        if (re->nclass >= NCLASS) reerr2("too many character classes -- limit ", NCLASS + '0');
        !          14994:        map = re->classp[re->nclass++].map;
        !          14995:        (void)memset(map, 0, elements(re->classp[0].map));
        !          14996: 
        !          14997:        /*
        !          14998:         * we have already seen the '['
        !          14999:         */
        !          15000: 
        !          15001:        if (*re->exprp == '^')
        !          15002:        {
        !          15003:                re->exprp++;
        !          15004:                negate = 1;
        !          15005:        }
        !          15006:        else negate = 0;
        !          15007:        if (*re->exprp == ']')
        !          15008:        {
        !          15009:                re->exprp++;
        !          15010:                setbit(map, ']');
        !          15011:        }
        !          15012:        if (*re->exprp == '-')
        !          15013:        {
        !          15014:                re->exprp++;
        !          15015:                setbit(map, '-');
        !          15016:        }
        !          15017:        while (c1 = c2 = nextc())
        !          15018:        {
        !          15019:                if (*re->exprp == '-')
        !          15020:                {
        !          15021:                        re->exprp++;
        !          15022:                        c2 = nextc();
        !          15023:                }
        !          15024:                for (; c1 <= c2; c1++) setbit(map, c1);
        !          15025:        }
        !          15026:        if (negate)
        !          15027:                for (c1 = 0; c1 < elements(re->classp[0].map); c1++)
        !          15028:                        map[c1] = ~map[c1];
        !          15029: 
        !          15030:        /*
        !          15031:         * always exclude '\0'
        !          15032:         */
        !          15033: 
        !          15034:        clrbit(map, 0);
        !          15035: }
        !          15036: 
        !          15037: static int
        !          15038: lex()
        !          15039: {
        !          15040:        register int    c;
        !          15041: 
        !          15042:        switch(c = *re->exprp++)
        !          15043:        {
        !          15044:        case 0:
        !          15045:                c = END;
        !          15046:                re->exprp--;
        !          15047:                break;
        !          15048:        case '\\':
        !          15049:                switch (c = *re->exprp++)
        !          15050:                {
        !          15051:                case 0:
        !          15052:                        re->exprp--;
        !          15053:                        rcerror("trailing \\ is invalid");
        !          15054:                        break;
        !          15055:                case '1': case '2': case '3': case '4':
        !          15056:                case '5': case '6': case '7': case '8': case '9':
        !          15057:                        if ((c - '0') > re->cursubid) reerr2("invalid sub-expression reference \\", c);
        !          15058:                        else
        !          15059:                        {
        !          15060:                                re->refsubid = c - '0';
        !          15061:                                re->flags |= RE_MATCH;
        !          15062:                                c = SUBEXPR;
        !          15063:                        }
        !          15064:                        break;
        !          15065:                case '?':
        !          15066:                        if (re->flags & RE_EDSTYLE) c = QUEST;
        !          15067:                        break;
        !          15068:                case '+':
        !          15069:                        if (re->flags & RE_EDSTYLE) c = PLUS;
        !          15070:                        break;
        !          15071:                case '|':
        !          15072:                        if (re->flags & RE_EDSTYLE) c = OR;
        !          15073:                        break;
        !          15074:                case '(':
        !          15075:                        if (re->flags & RE_EDSTYLE) c = LBRA;
        !          15076:                        break;
        !          15077:                case ')':
        !          15078:                        if (re->flags & RE_EDSTYLE) c = RBRA;
        !          15079:                        break;
        !          15080:                case '<':
        !          15081:                        if (re->flags & RE_EDSTYLE) c = BID;
        !          15082:                        break;
        !          15083:                case '>':
        !          15084:                        if (re->flags & RE_EDSTYLE) c = EID;
        !          15085:                        break;
        !          15086:                default:
        !          15087:                        c = chresc((char*)re->exprp - 2, (char**)&re->exprp);
        !          15088:                        break;
        !          15089:                }
        !          15090:                break;
        !          15091:        case '*':
        !          15092:                c = STAR;
        !          15093:                break;
        !          15094:        case '.':
        !          15095:                c = ANY;
        !          15096:                break;
        !          15097:        case '^':
        !          15098:                c = BOL;
        !          15099:                break;
        !          15100:        case '$':
        !          15101:                c = EOL;
        !          15102:                break;
        !          15103:        case '[':
        !          15104:                c = CCLASS;
        !          15105:                bldcclass();
        !          15106:                break;
        !          15107:        case '?':
        !          15108:                if (!(re->flags & RE_EDSTYLE)) c = QUEST;
        !          15109:                break;
        !          15110:        case '+':
        !          15111:                if (!(re->flags & RE_EDSTYLE)) c = PLUS;
        !          15112:                break;
        !          15113:        case '|':
        !          15114:                if (!(re->flags & RE_EDSTYLE)) c = OR;
        !          15115:                break;
        !          15116:        case '(':
        !          15117:                if (!(re->flags & RE_EDSTYLE)) c = LBRA;
        !          15118:                break;
        !          15119:        case ')':
        !          15120:                if (!(re->flags & RE_EDSTYLE)) c = RBRA;
        !          15121:                break;
        !          15122:        case '<':
        !          15123:                if (!(re->flags & RE_EDSTYLE)) c = BID;
        !          15124:                break;
        !          15125:        case '>':
        !          15126:                if (!(re->flags & RE_EDSTYLE)) c = EID;
        !          15127:                break;
        !          15128:        }
        !          15129:        return(c);
        !          15130: }
        !          15131: 
        !          15132: #if __STDC__ || __cplusplus
        !          15133: reprogram*
        !          15134: recomp(const char* s, int reflags)
        !          15135: #else
        !          15136: reprogram*
        !          15137: recomp(s, reflags)
        !          15138: char*  s;
        !          15139: int    reflags;
        !          15140: #endif
        !          15141: {
        !          15142:        register int    token;
        !          15143:        Prog*           pp;
        !          15144:        struct state    restate;
        !          15145: 
        !          15146:        /*
        !          15147:         * get memory for the program
        !          15148:         */
        !          15149: 
        !          15150:        if (!(pp = (Prog*)malloc(sizeof(Prog) + 3 * sizeof(Inst) * strlen(s))))
        !          15151:        {
        !          15152:                rcerror("out of memory");
        !          15153:                return(0);
        !          15154:        }
        !          15155:        re = &restate;
        !          15156:        re->freep = pp->firstinst;
        !          15157:        re->classp = pp->class;
        !          15158:        re->errors = 0;
        !          15159:        re->flags = reflags & ((1<<RE_EXTERNAL) - 1);
        !          15160: 
        !          15161:        /*
        !          15162:         * go compile the sucker
        !          15163:         */
        !          15164: 
        !          15165:        re->exprp = (unsigned char*)s;
        !          15166:        re->nclass = 0;
        !          15167:        re->nbra = 0;
        !          15168:        re->atorp = re->atorstack;
        !          15169:        re->andp = re->andstack;
        !          15170:        re->subidp = re->subidstack;
        !          15171:        re->lastwasand = 0;
        !          15172:        re->cursubid = 0;
        !          15173: 
        !          15174:        /*
        !          15175:         * start with a low priority operator to prime parser
        !          15176:         */
        !          15177: 
        !          15178:        pushator(START - 1);
        !          15179:        while ((token = lex()) != END)
        !          15180:        {
        !          15181:                if (token >= OPERATOR) operator(token);
        !          15182:                else operand(token);
        !          15183:        }
        !          15184: 
        !          15185:        /*
        !          15186:         * close with a low priority operator
        !          15187:         */
        !          15188: 
        !          15189:        evaluntil(START);
        !          15190: 
        !          15191:        /*
        !          15192:         * force END
        !          15193:         */
        !          15194: 
        !          15195:        operand(END);
        !          15196:        evaluntil(START);
        !          15197: #if DEBUG
        !          15198:        dumpstack();
        !          15199: #endif
        !          15200:        if (re->nbra) rcerror("unmatched (");
        !          15201:        re->andp--;
        !          15202: 
        !          15203:        /*
        !          15204:         * re->andp points to first and only operand
        !          15205:         */
        !          15206: 
        !          15207:        pp->startinst = re->andp->first;
        !          15208:        pp->flags = re->flags;
        !          15209: #if DEBUG
        !          15210:        dump(pp);
        !          15211: #endif
        !          15212:        optimize(pp);
        !          15213: #ifdef DEBUG
        !          15214:        printf("start: %d\n", re->andp->first-pp->firstinst);
        !          15215:        dump(pp);
        !          15216: #endif
        !          15217:        if (re->errors)
        !          15218:        {
        !          15219:                free(pp);
        !          15220:                pp = 0;
        !          15221:        }
        !          15222:        return((reprogram*)pp);
        !          15223: }
        !          15224: 
        !          15225: /*
        !          15226:  * free program compiled by recomp()
        !          15227:  */
        !          15228: 
        !          15229: void
        !          15230: refree(pp)
        !          15231: reprogram*     pp;
        !          15232: {
        !          15233:        free(pp);
        !          15234: }
        !          15235: 0707070000000002051006440044230044230000010000000475446313600003000000000400re/reerror.cUgsfGgsf/*
        !          15236:  * AT&T Bell Laboratories
        !          15237:  *
        !          15238:  * regular expression error routine
        !          15239:  */
        !          15240: 
        !          15241: #include <re.h>
        !          15242: #include <error.h>
        !          15243: 
        !          15244: #if __STDC__ || __cplusplus
        !          15245: void
        !          15246: reerror(const char* s)
        !          15247: #else
        !          15248: void
        !          15249: reerror(s)
        !          15250: char*  s;
        !          15251: #endif
        !          15252: {
        !          15253:        liberror("re", 3, "regular expression: %s", s);
        !          15254: }
        !          15255: 0707070000000002061006440044230044230000010000000475453466200002700000011530re/reexec.cUgsfGgsf/*
        !          15256:  * AT&T Bell Laboratories
        !          15257:  *
        !          15258:  * regular expression executor
        !          15259:  */
        !          15260: 
        !          15261: #include "relib.h"
        !          15262: 
        !          15263: #include <ctype.h>
        !          15264: 
        !          15265: #define LISTINCREMENT  8
        !          15266: 
        !          15267: typedef struct List
        !          15268: {
        !          15269:        Inst*   inst;           /* instruction of the thread            */
        !          15270:        Subexp  se;             /* matched sub-expressions this thread  */
        !          15271: } List;
        !          15272: 
        !          15273: /*
        !          15274:  * note optimization in addinst:
        !          15275:  *     *p must be pending when addinst called; if *l has been looked
        !          15276:  *     at already, the optimization is a bug.
        !          15277:  */
        !          15278: 
        !          15279: static List*
        !          15280: newthread(p, ip, sep)
        !          15281: register List*         p;      /* list to add to                       */
        !          15282: register Inst*         ip;     /* instruction to add                   */
        !          15283: register Subexp*       sep;    /* pointers to sub-expressions          */
        !          15284: {
        !          15285:        for (; p->inst; p++)
        !          15286:                if (p->inst == ip)
        !          15287:                {
        !          15288:                        if (sep->m[0].sp < p->se.m[0].sp) p->se = *sep;
        !          15289:                        return(0);
        !          15290:                }
        !          15291:        p->inst = ip;
        !          15292:        p->se = *sep;
        !          15293:        (++p)->inst = 0;
        !          15294:        return(p);
        !          15295: }
        !          15296: 
        !          15297: static void
        !          15298: newmatch(mp, np)
        !          15299: register Subexp*       mp;
        !          15300: register Subexp*       np;
        !          15301: {
        !          15302:        if (!mp->m[0].sp || np->m[0].sp < mp->m[0].sp || np->m[0].sp == mp->m[0].sp && np->m[0].ep > mp->m[0].ep)
        !          15303:                *mp = *np;
        !          15304: }
        !          15305: 
        !          15306: #if __STDC__ || __cplusplus
        !          15307: int
        !          15308: reexec(reprogram* aprogp, const char* starts)
        !          15309: #else
        !          15310: #ifndef const
        !          15311: #define const
        !          15312: #endif
        !          15313: int
        !          15314: reexec(progp, starts)
        !          15315: Prog*  progp;                  /* program to run                       */
        !          15316: char*  starts;         /* string to run program on             */
        !          15317: #endif
        !          15318: {
        !          15319: #if __STDC__ || __cplusplus
        !          15320:        Prog*           progp = (Prog*)aprogp;
        !          15321: #endif
        !          15322:        register int            flag = 0;
        !          15323:        register Inst*          inst;
        !          15324:        register List*          tlp;
        !          15325:        register const char*    s;
        !          15326:        Subexp*                 mp;
        !          15327:        int                     checkstart;
        !          15328:        int                     startchar;
        !          15329: 
        !          15330:        List*           tl;     /* this list, next list                 */
        !          15331:        List*           nl;     /* this list, next list                 */
        !          15332:        List*           tle;    /* ends of this and next list           */
        !          15333:        List*           nle;    /* ends of this and next list           */
        !          15334:        List*           list[2];
        !          15335:        List*           liste[2];
        !          15336:        int             match = 0;
        !          15337: 
        !          15338:        static int      listsize = LISTINCREMENT;
        !          15339:        static Subexp   sempty; /* empty set of matches                 */
        !          15340: 
        !          15341: 
        !          15342:        startchar = progp->startinst->type < TOKEN ? progp->startinst->type : 0;
        !          15343:        mp = (progp->flags & RE_MATCH) ? &progp->subexp : 0;
        !          15344:        list[0] = 0;
        !          15345:  Restart:
        !          15346:        match = 0;
        !          15347:        checkstart = startchar;
        !          15348:        sempty.m[0].sp = 0;
        !          15349:        if (mp) mp->m[0].sp = mp->m[0].ep = 0;
        !          15350:        if (!list[0])
        !          15351:        {
        !          15352:                if (!(list[0] = (List*)malloc(2 * listsize * sizeof(List))))
        !          15353:                        reerror("list overflow");
        !          15354:                list[1] = list[0] + listsize;
        !          15355:                liste[0] = list[0] + listsize - 1;
        !          15356:                liste[1] = list[1] + listsize - 1;
        !          15357:        }
        !          15358:        list[0][0].inst = list[1][0].inst = 0;
        !          15359: 
        !          15360:        /*
        !          15361:         * execute machine once for each character, including terminal '\0'
        !          15362:         */
        !          15363: 
        !          15364:        s = starts;
        !          15365:        do
        !          15366:        {
        !          15367:                /*
        !          15368:                 * fast check for first char
        !          15369:                 */
        !          15370: 
        !          15371:                if (checkstart && *s != startchar) continue;
        !          15372:                tl = list[flag];
        !          15373:                tle = liste[flag];
        !          15374:                nl = list[flag ^= 1];
        !          15375:                nle = liste[flag];
        !          15376:                nl->inst = 0;
        !          15377: 
        !          15378:                /*
        !          15379:                 * add first instruction to this list
        !          15380:                 */
        !          15381: 
        !          15382:                sempty.m[0].sp = (char*)s;
        !          15383:                (void)newthread(tl, progp->startinst, &sempty);
        !          15384: 
        !          15385:                /*
        !          15386:                 * execute machine until this list is empty
        !          15387:                 */
        !          15388: 
        !          15389:                for (tlp = tl; inst = tlp->inst; tlp++)
        !          15390:                {
        !          15391:                        /*
        !          15392:                         * assignment =
        !          15393:                         */
        !          15394:  Switchstmt:
        !          15395:                        switch (inst->type)
        !          15396:                        {
        !          15397:                        case LBRA:
        !          15398:                                tlp->se.m[inst->subid].sp = (char*)s;
        !          15399:                                inst = inst->next;
        !          15400:                                goto Switchstmt;
        !          15401:                        case RBRA:
        !          15402:                                tlp->se.m[inst->subid].ep = (char*)s;
        !          15403:                                inst = inst->next;
        !          15404:                                goto Switchstmt;
        !          15405:                        case ANY:
        !          15406:                                goto Addinst;
        !          15407:                        case BOL:
        !          15408:                                if (s == starts)
        !          15409:                                {
        !          15410:                                        inst = inst->next;
        !          15411:                                        goto Switchstmt;
        !          15412:                                }
        !          15413:                                break;
        !          15414:                        case EOL:
        !          15415:                                if (!*s)
        !          15416:                                {
        !          15417:                                        inst = inst->next;
        !          15418:                                        goto Switchstmt;
        !          15419:                                }
        !          15420:                                break;
        !          15421:                        case BID:
        !          15422:                                if (s == starts || !isalnum(*(s - 1)) && *(s - 1) != '_')
        !          15423:                                {
        !          15424:                                        inst = inst->next;
        !          15425:                                        goto Switchstmt;
        !          15426:                                }
        !          15427:                                break;
        !          15428:                        case EID:
        !          15429:                                if (!*s || !isalnum(*s) && *s != '_')
        !          15430:                                {
        !          15431:                                        inst = inst->next;
        !          15432:                                        goto Switchstmt;
        !          15433:                                }
        !          15434:                                break;
        !          15435:                        case CCLASS:
        !          15436:                                if (tstbit(inst->cclass, *s)) goto Addinst;
        !          15437:                                break;
        !          15438:                        case OR:
        !          15439:                                /*
        !          15440:                                 * evaluate right choice later
        !          15441:                                 */
        !          15442: 
        !          15443:                                if (newthread(tlp, inst->right, &tlp->se) == tle)
        !          15444:                                        goto Realloc;
        !          15445: 
        !          15446:                                /*
        !          15447:                                 * efficiency: advance and re-evaluate
        !          15448:                                 */
        !          15449: 
        !          15450:                                inst = inst->left;
        !          15451:                                goto Switchstmt;
        !          15452:                        case SUBEXPR:
        !          15453:                                {
        !          15454:                                        const char*     ss;
        !          15455:                                        const char*     ms = (char*)tlp->se.m[inst->subid].sp;
        !          15456:                                        const char*     me = (char*)tlp->se.m[inst->subid].ep;
        !          15457: 
        !          15458: #if DEBUG
        !          15459:                                        {
        !          15460:                                                int     c;
        !          15461: 
        !          15462:                                                c = *me;
        !          15463:                                                *me = 0;
        !          15464:                                                error(-1, "subexpression %d ref=\"%s\"", inst->subid, ms);
        !          15465:                                                *me = c;
        !          15466:                                                error(-1, "subexpression %d src=\"%s\"", inst->subid, s);
        !          15467:                                        }
        !          15468: #endif
        !          15469:                                        if (ms == me)
        !          15470:                                        {
        !          15471:                                                inst = inst->next;
        !          15472:                                                goto Switchstmt;
        !          15473:                                        }
        !          15474:                                        for (ss = s; ms < me && *ss++ == *ms; ms++);
        !          15475:                                        if (ms == me)
        !          15476:                                        {
        !          15477:                                                s = ss - 1;
        !          15478:                                                goto Addinst;
        !          15479:                                        }
        !          15480:                                }
        !          15481:                                break;
        !          15482:                        case END:
        !          15483:                                /*
        !          15484:                                 * match!
        !          15485:                                 */
        !          15486: 
        !          15487:                                match = 1;
        !          15488:                                tlp->se.m[0].ep = (char*)s;
        !          15489:                                if (mp) newmatch(mp, &tlp->se);
        !          15490:                                break;
        !          15491:                        default:
        !          15492:                                /*
        !          15493:                                 * regular character
        !          15494:                                 */
        !          15495: 
        !          15496:                                if (inst->type == *s)
        !          15497:                                {
        !          15498:  Addinst:
        !          15499:                                        if (newthread(nl, inst->next, &tlp->se) == nle)
        !          15500:                                                goto Realloc;
        !          15501:                                }
        !          15502:                                break;
        !          15503:                        }
        !          15504:                }
        !          15505:                checkstart = startchar && !nl->inst;
        !          15506:        } while (*s++);
        !          15507:        return(match);
        !          15508:  Realloc:
        !          15509:        free(list[0]);
        !          15510:        list[0] = 0;
        !          15511:        listsize += LISTINCREMENT;
        !          15512:        goto Restart;
        !          15513: }
        !          15514: 0707070000000002071006440044230044230000010000000475356670400002600000004633re/relib.hUgsfGgsf/*
        !          15515:  * AT&T Bell Laboratories
        !          15516:  *
        !          15517:  * regular expression library private definitions
        !          15518:  */
        !          15519: 
        !          15520: #include <re.h>
        !          15521: #include <limits.h>
        !          15522: 
        !          15523: #define NCLASS         16              /* max # [...] expressions      */
        !          15524: 
        !          15525: #define elements(x)    (sizeof(x)/sizeof(x[0]))
        !          15526: 
        !          15527: #define clrbit(set,bit)        (set[(bit)/CHAR_BIT]&=~(1<<((bit)%CHAR_BIT)))
        !          15528: #define setbit(set,bit)        (set[(bit)/CHAR_BIT]|=(1<<((bit)%CHAR_BIT)))
        !          15529: #define tstbit(set,bit)        ((set[(bit)/CHAR_BIT]&(1<<((bit)%CHAR_BIT)))!=0)
        !          15530: 
        !          15531: typedef struct                 /* sub-expression match table           */
        !          15532: {
        !          15533:        rematch         m[RE_NMATCH + 2];
        !          15534: } Subexp;
        !          15535: 
        !          15536: typedef struct                 /* character class bit vector           */
        !          15537: {
        !          15538:        char            map[UCHAR_MAX / CHAR_BIT + 1];
        !          15539: } Class;
        !          15540: 
        !          15541: typedef struct Inst            /* machine instruction                  */
        !          15542: {
        !          15543:        int             type;   /* <TOKEN ==> literal, otherwise action */
        !          15544:        union
        !          15545:        {
        !          15546: 
        !          15547:        int             sid;    /* sub-expression id for RBRA and LBRA  */
        !          15548:        struct Inst     *other; /* for right child                      */
        !          15549:        char            *cls;   /* CCLASS bit vector                    */
        !          15550: 
        !          15551:        } u;
        !          15552:        struct Inst     *left;  /* left child                           */
        !          15553: } Inst;
        !          15554: 
        !          15555: #define        next    left
        !          15556: #define        subid   u.sid
        !          15557: #define right  u.other
        !          15558: #define cclass u.cls
        !          15559: 
        !          15560: /*
        !          15561:  * NOTE: subexp must be the first element to match reprogram.match
        !          15562:  */
        !          15563: 
        !          15564: typedef struct                         /* compiled program             */
        !          15565: {
        !          15566:        Subexp          subexp;         /* sub-expression matches       */
        !          15567:        int             flags;          /* RE_* flags                   */
        !          15568:        Inst            *startinst;     /* start pc                     */
        !          15569:        Class           class[NCLASS];  /* .data                        */
        !          15570:        Inst            firstinst[5];   /* .text                        */
        !          15571: } Prog;
        !          15572: 
        !          15573: /*
        !          15574:  * tokens and actions
        !          15575:  *
        !          15576:  *     TOKEN<=x<OPERATOR are tokens, i.e. operands for operators
        !          15577:  *     >=OPERATOR are operators, value == precedence
        !          15578:  */
        !          15579: 
        !          15580: #define TOKEN          (UCHAR_MAX+1)
        !          15581: #define        ANY             (UCHAR_MAX+1)   /* `.' any character            */
        !          15582: #define        NOP             (UCHAR_MAX+2)   /* no operation (internal)      */
        !          15583: #define        BOL             (UCHAR_MAX+3)   /* `^' beginning of line        */
        !          15584: #define        EOL             (UCHAR_MAX+4)   /* `$' end of line              */
        !          15585: #define        BID             (UCHAR_MAX+5)   /* `\<' begin identifier        */
        !          15586: #define        EID             (UCHAR_MAX+6)   /* `\>' end identifier          */
        !          15587: #define        CCLASS          (UCHAR_MAX+7)   /* `[]' character class         */
        !          15588: #define SUBEXPR                (UCHAR_MAX+8)   /* `\#' sub-expression          */
        !          15589: #define        END             (UCHAR_MAX+9)   /* terminate: match found       */
        !          15590: 
        !          15591: #define        OPERATOR        (UCHAR_MAX+11)
        !          15592: #define        START           (UCHAR_MAX+11)  /* start, stack marker          */
        !          15593: #define        RBRA            (UCHAR_MAX+12)  /* `)' right bracket            */
        !          15594: #define        LBRA            (UCHAR_MAX+13)  /* `(' left bracket             */
        !          15595: #define        OR              (UCHAR_MAX+14)  /* `|' alternation              */
        !          15596: #define        CAT             (UCHAR_MAX+15)  /* concatentation (implicit)    */
        !          15597: #define        STAR            (UCHAR_MAX+16)  /* `*' closure                  */
        !          15598: #define        PLUS            (UCHAR_MAX+17)  /* a+ == aa*                    */
        !          15599: #define        QUEST           (UCHAR_MAX+18)  /* a? == 0 or 1 a's             */
        !          15600: 0707070000000002101006440044230044230000010000000475447565300002600000003614re/resub.cUgsfGgsf/*
        !          15601:  * AT&T Bell Laboratories
        !          15602:  *
        !          15603:  * regular expression match substitution
        !          15604:  */
        !          15605: 
        !          15606: #include "relib.h"
        !          15607: 
        !          15608: #include <ctype.h>
        !          15609: 
        !          15610: /*
        !          15611:  * do a single substitution
        !          15612:  */
        !          15613: 
        !          15614: /*ARGSUSED*/
        !          15615: #if __STDC__ || __cplusplus
        !          15616: static char*
        !          15617: sub(register const char* sp, register char* dp, register rematch* mp, int flags)
        !          15618: #else
        !          15619: static char*
        !          15620: sub(sp, dp, mp, flags)
        !          15621: register char*         sp;
        !          15622: register char*         dp;
        !          15623: register rematch*      mp;
        !          15624: int                    flags;
        !          15625: #endif
        !          15626: {
        !          15627:        register int    i;
        !          15628:        char*           s;
        !          15629: 
        !          15630:        for (;;) switch (*dp = *sp++)
        !          15631:        {
        !          15632:        case 0:
        !          15633:                return(dp);
        !          15634:        case '\\':
        !          15635:                switch (i = *sp++)
        !          15636:                {
        !          15637:                case 0:
        !          15638:                        sp--;
        !          15639:                        break;
        !          15640:                case '0': case '1': case '2': case '3': case '4':
        !          15641:                case '5': case '6': case '7': case '8': case '9':
        !          15642:                        i -= '0';
        !          15643:                        if (mp[i].sp)
        !          15644:                        {
        !          15645:                                s = mp[i].sp;
        !          15646:                                while (s < mp[i].ep) *dp++ = *s++;
        !          15647:                        }
        !          15648:                        break;
        !          15649:                default:
        !          15650:                        *dp++ = chresc(sp - 2, &s);
        !          15651:                        sp = s;
        !          15652:                        break;
        !          15653:                }
        !          15654:                break;
        !          15655:        case '&':
        !          15656:                if (mp[0].sp)
        !          15657:                {
        !          15658:                        s = mp[0].sp;
        !          15659:                        while (s < mp[0].ep) *dp++ = *s++;
        !          15660:                }
        !          15661:                break;
        !          15662:        default:
        !          15663:                dp++;
        !          15664:                break;
        !          15665:        }
        !          15666: }
        !          15667: 
        !          15668: /*
        !          15669:  * ed(1) style substitute using matches from last reexec()
        !          15670:  */
        !          15671: 
        !          15672: #if __STDC__ || __cplusplus
        !          15673: char*
        !          15674: resub(reprogram* re, register const char* op, const char* sp, register char* dp, int flags)
        !          15675: #else
        !          15676: char*
        !          15677: resub(re, op, sp, dp, flags)
        !          15678: reprogram*             re;     /* compiled re                          */
        !          15679: register char*         op;     /* original subject string              */
        !          15680: char*                  sp;     /* substitution string                  */
        !          15681: register char*         dp;     /* destination string                   */
        !          15682: int                    flags;  /* RE_ALL, RE_LOWER, RE_UPPER           */
        !          15683: #endif
        !          15684: {
        !          15685:        register rematch*       mp;
        !          15686: 
        !          15687:        mp = re->match;
        !          15688:        do
        !          15689:        {
        !          15690:                while (op < mp->sp) *dp++ = *op++;
        !          15691:                op = dp;
        !          15692:                dp = sub(sp, dp, mp, flags);
        !          15693:                if (flags & (RE_LOWER|RE_UPPER))
        !          15694:                {
        !          15695:                        while (op < dp)
        !          15696:                        {
        !          15697:                                if (flags & RE_LOWER)
        !          15698:                                {
        !          15699:                                        if (isupper(*op)) *(char*)op = tolower(*op);
        !          15700:                                }
        !          15701:                                else if (islower(*op)) *(char*)op = toupper(*op);
        !          15702:                                op++;
        !          15703:                        }
        !          15704:                }
        !          15705:                op = mp->ep;
        !          15706:        } while ((flags & RE_ALL) && *op && mp->sp != mp->ep && reexec(re, op));
        !          15707:        while (*dp++ = *op++);
        !          15708:        return(--dp);
        !          15709: }
        !          15710: 0707070000000002111006440044230044230000010000000474665052300003600000000223sfio/_sfclearerr.cUgsfGgsf#include     "_sfhdr.h"
        !          15711: 
        !          15712: #if __STDC__ || __cplusplus
        !          15713: sfclearerr(reg Sfile_t* f)
        !          15714: #else
        !          15715: sfclearerr(f)
        !          15716: reg Sfile_t    *f;
        !          15717: #endif
        !          15718: {
        !          15719:        return _SFCLEARERR(f);
        !          15720: }
        !          15721: 0707070000000002121006440044230044230000010000000474665201700003200000000567sfio/_sfecvt.cUgsfGgsf#include "_sfhdr.h"
        !          15722: 
        !          15723: #if __STDC__ || __cplusplus
        !          15724: char *sfecvt(reg double dval, int n_digit, int* decpt, int* sign)
        !          15725: #else
        !          15726: char *sfecvt(dval,n_digit,decpt,sign)
        !          15727: reg double     dval;           /* value to convert */
        !          15728: int            n_digit;        /* number of digits wanted */
        !          15729: int            *decpt;         /* to return decimal point */
        !          15730: int            *sign;          /* to return sign */
        !          15731: #endif
        !          15732: {
        !          15733:        return _SFECVT(dval,n_digit,decpt,sign);
        !          15734: }
        !          15735: 0707070000000002131006440044230044230000010000000474665044200003100000000204sfio/_sfeof.cUgsfGgsf#include  "_sfhdr.h"
        !          15736: 
        !          15737: #if __STDC__ || __cplusplus
        !          15738: sfeof(reg Sfile_t* f)
        !          15739: #else
        !          15740: sfeof(f)
        !          15741: reg Sfile_t    *f;
        !          15742: #endif
        !          15743: {
        !          15744:        return _SFEOF(f);
        !          15745: }
        !          15746: 0707070000000002141006440044230044230000010000000474665042000003300000000212sfio/_sferror.cUgsfGgsf#include        "_sfhdr.h"
        !          15747: 
        !          15748: #if __STDC__ || __cplusplus
        !          15749: sferror(reg Sfile_t* f)
        !          15750: #else
        !          15751: sferror(f)
        !          15752: reg Sfile_t    *f;
        !          15753: #endif
        !          15754: {
        !          15755:        return _SFERROR(f);
        !          15756: }
        !          15757: 0707070000000002151006440044230044230000010000000474665204700003200000000567sfio/_sffcvt.cUgsfGgsf#include "_sfhdr.h"
        !          15758: 
        !          15759: #if __STDC__ || __cplusplus
        !          15760: char *sffcvt(reg double dval, int n_digit, int* decpt, int* sign)
        !          15761: #else
        !          15762: char *sffcvt(dval,n_digit,decpt,sign)
        !          15763: reg double     dval;           /* value to convert */
        !          15764: int            n_digit;        /* number of digits wanted */
        !          15765: int            *decpt;         /* to return decimal point */
        !          15766: int            *sign;          /* to return sign */
        !          15767: #endif
        !          15768: {
        !          15769:        return _SFFCVT(dval,n_digit,decpt,sign);
        !          15770: }
        !          15771: 0707070000000002161006440044230044230000010000000474665210000003400000000215sfio/_sffileno.cUgsfGgsf#include       "_sfhdr.h"
        !          15772: 
        !          15773: #if __STDC__ || __cplusplus
        !          15774: sffileno(reg Sfile_t* f)
        !          15775: #else
        !          15776: sffileno(f)
        !          15777: reg Sfile_t    *f;
        !          15778: #endif
        !          15779: {
        !          15780:        return _SFFILENO(f);
        !          15781: }
        !          15782: 0707070000000002171006440044230044230000010000000474665002500003200000000207sfio/_sfgetc.cUgsfGgsf#include "_sfhdr.h"
        !          15783: 
        !          15784: #if __STDC__ || __cplusplus
        !          15785: sfgetc(reg Sfile_t* f)
        !          15786: #else
        !          15787: sfgetc(f)
        !          15788: reg Sfile_t    *f;
        !          15789: #endif
        !          15790: {
        !          15791:        return _SFGETC(f);
        !          15792: }
        !          15793: 0707070000000002201006440044230044230000010000000474665144100003200000000221sfio/_sfgetl.cUgsfGgsf#include "_sfhdr.h"
        !          15794: 
        !          15795: #if __STDC__ || __cplusplus
        !          15796: long sfgetl(reg Sfile_t* f)
        !          15797: #else
        !          15798: long sfgetl(f)
        !          15799: reg Sfile_t    *f;
        !          15800: #endif
        !          15801: {
        !          15802:        return _SFGETL(f);
        !          15803: }
        !          15804: 0707070000000002211006440044230044230000010000000474665146500003200000000223sfio/_sfgetu.cUgsfGgsf#include "_sfhdr.h"
        !          15805: 
        !          15806: #if __STDC__ || __cplusplus
        !          15807: ulong sfgetu(reg Sfile_t* f)
        !          15808: #else
        !          15809: ulong sfgetu(f)
        !          15810: reg Sfile_t    *f;
        !          15811: #endif
        !          15812: {
        !          15813:        return _SFGETU(f);
        !          15814: }
        !          15815: 0707070000000002221006440044230044230000010000000474736247100003100000002073sfio/_sfhdr.hUgsfGgsf#include  "sfhdr.h"
        !          15816: 
        !          15817: /*     This header file defines analogues for all public macro functions.
        !          15818:        The analogues are used for building function analogues.
        !          15819: */
        !          15820: 
        !          15821: #define _SFPUTC(f,c)   sfputc(f,c)
        !          15822: #define _SFGETC(f)     sfgetc(f)
        !          15823: #define _SFSLEN()      sfslen()
        !          15824: #define _SFFILENO(f)   sffileno(f)
        !          15825: #define _SFORIGIN(f)   sforigin(f)
        !          15826: #define _SFEOF(f)      sfeof(f)
        !          15827: #define _SFERROR(f)    sferror(f)
        !          15828: #define _SFCLEARERR(f) sfclearerr(f)
        !          15829: #define _SFPUSHED(f)   sfpushed(f)
        !          15830: #define _SFTMP(s)      sftmp(s)
        !          15831: #define _SFPEEK(f,bp)  sfpeek(f,bp)
        !          15832: #define _SFSYNC(f)     sfsync(f)
        !          15833: #define _SFULEN(v)     sfulen(v)
        !          15834: #define _SFGETU(f)     sfgetu(f)
        !          15835: #define _SFGETL(f)     sfgetl(f)
        !          15836: #define _SFPUTU(f,v)   sfputu(f,v)
        !          15837: #define _SFPUTL(f,v)   sfputl(f,v)
        !          15838: #define _SFPUTD(f,v)   sfputd(f,v)
        !          15839: #define _SFECVT(v,n,d,s) sfecvt(v,n,d,s)
        !          15840: #define _SFFCVT(v,n,d,s) sffcvt(v,n,d,s)
        !          15841: 
        !          15842: #undef sfputc
        !          15843: #undef sfgetc
        !          15844: #undef sfslen
        !          15845: #undef sffileno
        !          15846: #undef sforigin
        !          15847: #undef sfeof
        !          15848: #undef sferror
        !          15849: #undef sfclearerr
        !          15850: #undef sfpushed
        !          15851: #undef sftmp
        !          15852: #undef sfpeek
        !          15853: #undef sfsync
        !          15854: #undef sfulen
        !          15855: #undef sfgetu
        !          15856: #undef sfgetl
        !          15857: #undef sfputu
        !          15858: #undef sfputl
        !          15859: #undef sfputd
        !          15860: #undef sfecvt
        !          15861: #undef sffcvt
        !          15862: 0707070000000002231006440044230044230000010000000474665047000003400000000227sfio/_sforigin.cUgsfGgsf#include       "_sfhdr.h"
        !          15863: 
        !          15864: #if __STDC__ || __cplusplus
        !          15865: long sforigin(reg Sfile_t* f)
        !          15866: #else
        !          15867: long sforigin(f)
        !          15868: reg Sfile_t    *f;
        !          15869: #endif
        !          15870: {
        !          15871:        return _SFORIGIN(f);
        !          15872: }
        !          15873: 0707070000000002241006440044230044230000010000000474665110500003200000000322sfio/_sfpeek.cUgsfGgsf#include "_sfhdr.h"
        !          15874: 
        !          15875: #if __STDC__ || __cplusplus
        !          15876: sfpeek(reg Sfile_t* f, uchar** bp)
        !          15877: #else
        !          15878: sfpeek(f,bp)
        !          15879: reg Sfile_t    *f;     /* file to peek */
        !          15880: uchar          **bp;   /* start of data area */
        !          15881: #endif
        !          15882: {
        !          15883:        return _SFPEEK(f,bp);
        !          15884: }
        !          15885: 0707070000000002251006440044230044230000010000000474670025400003400000000237sfio/_sfpushed.cUgsfGgsf#include       "_sfhdr.h"
        !          15886: 
        !          15887: #if __STDC__ || __cplusplus
        !          15888: Sfile_t* sfpushed(reg Sfile_t* f)
        !          15889: #else
        !          15890: Sfile_t* sfpushed(f)
        !          15891: reg Sfile_t    *f;
        !          15892: #endif
        !          15893: {
        !          15894:        return _SFPUSHED(f);
        !          15895: }
        !          15896: 0707070000000002261006440044230044230000010000000474664775400003200000000242sfio/_sfputc.cUgsfGgsf#include "_sfhdr.h"
        !          15897: 
        !          15898: #if __STDC__ || __cplusplus
        !          15899: sfputc(reg Sfile_t* f, reg int c)
        !          15900: #else
        !          15901: sfputc(f,c)
        !          15902: reg Sfile_t    *f;
        !          15903: reg int                c;
        !          15904: #endif
        !          15905: {
        !          15906:        return _SFPUTC(f,c);
        !          15907: }
        !          15908: 0707070000000002271006440044230044230000010000000474665164200003200000000247sfio/_sfputd.cUgsfGgsf#include "_sfhdr.h"
        !          15909: 
        !          15910: #if __STDC__ || __cplusplus
        !          15911: sfputd(reg Sfile_t* f, reg double v)
        !          15912: #else
        !          15913: sfputd(f,v)
        !          15914: reg Sfile_t    *f;
        !          15915: reg double     v;
        !          15916: #endif
        !          15917: {
        !          15918:        return _SFPUTD(f,v);
        !          15919: }
        !          15920: 0707070000000002301006440044230044230000010000000474665160400003200000000243sfio/_sfputl.cUgsfGgsf#include "_sfhdr.h"
        !          15921: 
        !          15922: #if __STDC__ || __cplusplus
        !          15923: sfputl(reg Sfile_t* f, reg long v)
        !          15924: #else
        !          15925: sfputl(f,v)
        !          15926: reg Sfile_t    *f;
        !          15927: reg long       v;
        !          15928: #endif
        !          15929: {
        !          15930:        return _SFPUTL(f,v);
        !          15931: }
        !          15932: 0707070000000002311006440044230044230000010000000474665155000003200000000245sfio/_sfputu.cUgsfGgsf#include "_sfhdr.h"
        !          15933: 
        !          15934: #if __STDC__ || __cplusplus
        !          15935: sfputu(reg Sfile_t* f, reg ulong v)
        !          15936: #else
        !          15937: sfputu(f,v)
        !          15938: reg Sfile_t    *f;
        !          15939: reg ulong      v;
        !          15940: #endif
        !          15941: {
        !          15942:        return _SFPUTU(f,v);
        !          15943: }
        !          15944: 0707070000000002321006440044230044230000010000000474665007600003200000000065sfio/_sfslen.cUgsfGgsf#include "_sfhdr.h"
        !          15945: 
        !          15946: sfslen()
        !          15947: {
        !          15948:        return _SFSLEN();
        !          15949: }
        !          15950: 0707070000000002331006440044230044230000010000000474665120500003200000000251sfio/_sfsync.cUgsfGgsf#include "_sfhdr.h"
        !          15951: 
        !          15952: #if __STDC__ || __cplusplus
        !          15953: _sfsync(reg Sfile_t* f)
        !          15954: #else
        !          15955: _sfsync(f)
        !          15956: reg Sfile_t    *f;     /* stream to be synchronized */
        !          15957: #endif
        !          15958: {
        !          15959:        return _SFSYNC(f);
        !          15960: }
        !          15961: 0707070000000002341006440044230044230000010000000474665070500003100000000214sfio/_sftmp.cUgsfGgsf#include  "_sfhdr.h"
        !          15962: 
        !          15963: #if __STDC__ || __cplusplus
        !          15964: Sfile_t* sftmp(reg int n)
        !          15965: #else
        !          15966: Sfile_t* sftmp(n)
        !          15967: reg int        n;
        !          15968: #endif
        !          15969: {
        !          15970:        return _SFTMP(n);
        !          15971: }
        !          15972: 0707070000000002351006440044230044230000010000000474665133500003200000000201sfio/_sfulen.cUgsfGgsf#include "_sfhdr.h"
        !          15973: 
        !          15974: #if __STDC__ || __cplusplus
        !          15975: sfulen(reg ulong v)
        !          15976: #else
        !          15977: sfulen(v)
        !          15978: reg ulong      v;
        !          15979: #endif
        !          15980: {
        !          15981:        return _SFULEN(v);
        !          15982: }
        !          15983: 0707070000000002361006440044230044230000010000000475416407600003200000003720sfio/sfclose.cUgsfGgsf#include "sfhdr.h"
        !          15984: 
        !          15985: /*     Close a given file stream. If the file stream is associated with
        !          15986: **     a process via sfpopen(), both streams will be closed. The closed
        !          15987: **     stream is synced.
        !          15988: **
        !          15989: **     Written by Kiem-Phong Vo (06/27/90)
        !          15990: */
        !          15991: 
        !          15992: #if __STDC__ || __cplusplus
        !          15993: sfclose(reg Sfile_t *f)
        !          15994: #else
        !          15995: sfclose(f)
        !          15996: reg Sfile_t    *f;
        !          15997: #endif
        !          15998: {
        !          15999:        reg int         rv, flags;
        !          16000: 
        !          16001:        if(!f)
        !          16002:        {       /* close-all */
        !          16003:                while(1)
        !          16004:                {       reg Sfpool_t    *p;
        !          16005: 
        !          16006:                        /* the "goto" is because the lists change after each sfclose */
        !          16007:                        for(p = &_Sfpool; p != NIL(Sfpool_t*); p = p->fore)
        !          16008:                        for(f = p->head; f; f = f->fore)
        !          16009:                                if(!SFFROZEN(f))
        !          16010:                                        goto close_f;
        !          16011:                close_f:
        !          16012:                        if(!f)
        !          16013:                                return 0;
        !          16014:                        (void) sfclose(f);
        !          16015:                }
        !          16016:        }
        !          16017: 
        !          16018:        if(SFFROZEN(f))
        !          16019:                return -1;
        !          16020:        flags = f->flags;
        !          16021: 
        !          16022:        /* closing a stack of streams */
        !          16023:        while(f->push)
        !          16024:                if(sfclose((*_Sfstack)(f,NIL(Sfile_t*))) < 0)
        !          16025:                        return -1;
        !          16026: 
        !          16027:        /* tell the register function */
        !          16028:        if(_Sfnotify)
        !          16029:                (*_Sfnotify)(f,SF_EOF);
        !          16030: 
        !          16031:        /* this is from popen */
        !          16032:        if(_Sfpclose && (flags&SF_PROCESS))
        !          16033:                return (*_Sfpclose)(f);
        !          16034: 
        !          16035:        /* sync file pointer */
        !          16036:        f->mode &= ~SF_POOL;
        !          16037:        rv = sfsync(f);
        !          16038: 
        !          16039:        /* terminate discipline */
        !          16040:        if(f->disc && f->disc->exceptf)
        !          16041:                (*(f->disc->exceptf))(f,SF_EOF,f->disc->handle);
        !          16042: 
        !          16043:        /* free space used */
        !          16044:        if(!(flags&SF_REUSE))
        !          16045:        {       /* remove from the list of active streams */
        !          16046:                if(f->pool)
        !          16047:                {       if(_Sfpmove)
        !          16048:                                (*_Sfpmove)(f,-1);
        !          16049:                        else
        !          16050:                        {       if(f->fore)
        !          16051:                                        f->fore->back = f->back;
        !          16052:                                if(f->back)
        !          16053:                                        f->back->fore = f->fore;
        !          16054:                                else    f->pool->head = f->fore;
        !          16055:                        }
        !          16056:                        f->pool = NIL(Sfpool_t*);
        !          16057:                        f->fore = f->back = NIL(Sfile_t*);
        !          16058:                }
        !          16059: 
        !          16060:                f->disc = NIL(Sfdisc_t*);
        !          16061: 
        !          16062:                if(f->data && (flags&SF_MALLOC))
        !          16063:                {       free((char*)f->data);
        !          16064:                        f->data = NIL(uchar*);
        !          16065:                        f->size = 0;
        !          16066:                }
        !          16067:        }
        !          16068: 
        !          16069:        if(!(flags&(SF_KEEPFD|SF_STRING)))
        !          16070:                while(close(f->file) < 0 && errno == EINTR)
        !          16071:                        errno = 0;
        !          16072:        f->file = -1;
        !          16073: 
        !          16074:        if(!(flags&SF_REUSE) && f != sfstdin && f != sfstdout && f != sfstderr)
        !          16075:                SFFREE(f);
        !          16076:        else
        !          16077:        {       f->mode = 0;
        !          16078:                f->flags = 0;
        !          16079:                f->here = f->orig = 0L;
        !          16080:                f->endb = f->endr = f->endw = f->next = f->data;
        !          16081:        }
        !          16082: 
        !          16083:        return rv;
        !          16084: }
        !          16085: 0707070000000002371006440044230044230000010000000475414054700003400000000610sfio/sfclrlock.cUgsfGgsf#include       "sfhdr.h"
        !          16086: 
        !          16087: /*     Function to clear a locked stream.
        !          16088: **     This is useful for programs that longjmp from the mid of an sfio function.
        !          16089: **     There is no guarantee on data integrity in such a case.
        !          16090: **
        !          16091: **     Written by Kiem-Phong Vo (07/20/90).
        !          16092: */
        !          16093: #if __STDC__ || __cplusplus
        !          16094: sfclrlock(reg Sfile_t* f)
        !          16095: #else
        !          16096: sfclrlock(f)
        !          16097: reg Sfile_t    *f;
        !          16098: #endif
        !          16099: {
        !          16100:        f->mode &= ~SF_LOCK;
        !          16101:        return sfset(f,f->flags,1);
        !          16102: }
        !          16103: 0707070000000002401006440044230044230000010000000471533620500003000000005424sfio/sfcvt.cUgsfGgsf#include   "sfhdr.h"
        !          16104: 
        !          16105: /*     Convert a floating point value to ASCII
        !          16106: **     This function unifies fcvt() and ecvt() in libc.a.
        !          16107: **
        !          16108: **     Written by Kiem-Phong Vo (06/27/90)
        !          16109: */
        !          16110: 
        !          16111: #define INTPART                (IDIGITS/2)
        !          16112: #define INFINITE       (_Sfi = 3, "Inf")
        !          16113: #define ZERO           (_Sfi = 1, "0")
        !          16114: 
        !          16115: #if __STDC__ || __cplusplus
        !          16116: char *_sfcvt(reg double dval, int n_digit, int* decpt, int* sign, int e_format)
        !          16117: #else
        !          16118: char *_sfcvt(dval,n_digit,decpt,sign,e_format)
        !          16119: reg double     dval;           /* value to convert */
        !          16120: int            n_digit;        /* number of digits wanted */
        !          16121: int            *decpt;         /* to return decimal point */
        !          16122: int            *sign;          /* to return sign */
        !          16123: int            e_format;       /* doing e-format */
        !          16124: #endif
        !          16125: {
        !          16126: #ifdef NATIVE  /* NATIVE *cvt() can do this faster than we can */
        !          16127:        reg char        *sp;
        !          16128:        extern char     *fcvt(), *ecvt();
        !          16129:        sp = e_format ? ecvt(dval,n_digit,decpt,sign) : fcvt(dval,n_digit,decpt,sign);
        !          16130:        _Sfi = strlen(sp);
        !          16131:        return sp;
        !          16132: #else
        !          16133:        reg long        n, v, w;
        !          16134:        reg char        *sp, *ep, *buf, *endsp;
        !          16135:        static char     *Buf;
        !          16136: 
        !          16137:        /* set up local buffer */
        !          16138:        if(!Buf && !(Buf = malloc(MAXDIGITS)))
        !          16139:                return INFINITE;
        !          16140: 
        !          16141:        *sign = *decpt = 0;
        !          16142:        if(dval == 0.)
        !          16143:                return ZERO;
        !          16144:        else if(*sign = (dval < 0.))    /* assignment = */
        !          16145:                dval = -dval;
        !          16146: 
        !          16147:        n = 0;
        !          16148:        if(dval >= (double)MAXLONG)
        !          16149:        {       /* scale to a small enough number to fit an int */
        !          16150:                v = MAXEXP10-1;
        !          16151:                do
        !          16152:                {       if(dval < _Sfpos10[v])
        !          16153:                                v -= 1;
        !          16154:                        else
        !          16155:                        {
        !          16156:                                dval *= _Sfneg10[v];
        !          16157:                                if((n += (1<<v)) >= IDIGITS)
        !          16158:                                        return INFINITE;
        !          16159:                        }
        !          16160:                } while(dval >= (double)MAXLONG);
        !          16161:        }
        !          16162:        else if(dval < 1e-1)
        !          16163:        {       /* scale to get rid of leading zeros */
        !          16164:                v = MAXEXP10-1;
        !          16165:                do
        !          16166:                {       if(dval > _Sfneg10[v])
        !          16167:                                v -= 1;
        !          16168:                        else
        !          16169:                        {
        !          16170:                                dval *= _Sfpos10[v];
        !          16171:                                if((n -= (1<<v)) <= -IDIGITS)
        !          16172:                                        return ZERO;
        !          16173:                        }
        !          16174:                } while(dval < 1e-1);
        !          16175:        }
        !          16176:        *decpt = (int)n;
        !          16177: 
        !          16178:        buf = sp = Buf+INTPART;
        !          16179:        if((v = (int)dval) != 0)
        !          16180:        {       /* translate the integer part */
        !          16181:                dval -= (double)v;
        !          16182: 
        !          16183:                sfucvt(v,sp,n,w,ep);
        !          16184: 
        !          16185:                n = buf-sp;
        !          16186:                if((*decpt += (int)n) >= IDIGITS)
        !          16187:                        return INFINITE;
        !          16188:                buf = sp;
        !          16189:                sp = Buf+INTPART;
        !          16190:        }
        !          16191:        else    n = 0;
        !          16192: 
        !          16193:        /* remaining number of digits to compute; add 1 for later rounding */
        !          16194:        n = ((e_format || *decpt <= 0) ? 1 : *decpt+1) - n;
        !          16195:        if(n_digit > 0)
        !          16196:                n += n_digit;
        !          16197: 
        !          16198:        if((ep = (sp+n)) > (endsp = Buf+(MAXDIGITS-2)))
        !          16199:                ep = endsp; 
        !          16200:        if(sp > ep)
        !          16201:                sp = ep;
        !          16202:        else while(sp < ep)
        !          16203:        {       /* generate fractional digits */
        !          16204:                if(dval <= 0.)
        !          16205:                {       /* fill with 0's */
        !          16206:                        do { *sp++ = '0'; } while(sp < ep);
        !          16207:                        goto done;
        !          16208:                }
        !          16209:                *sp++ = (char)('0' + (n = (int)(dval *= 10.)));
        !          16210:                dval -= (double)n;
        !          16211:        }
        !          16212: 
        !          16213:        if(ep <= buf)
        !          16214:                ep = buf+1;
        !          16215:        else if(ep < endsp)
        !          16216:        {       /* round the last digit */
        !          16217:                *--sp += 5;
        !          16218:                while(*sp > '9')
        !          16219:                {
        !          16220:                        *sp = '0';
        !          16221:                        if(sp > buf)
        !          16222:                                *--sp += 1;
        !          16223:                        else
        !          16224:                        {       /* next power of 10 */
        !          16225:                                *sp = '1';
        !          16226:                                *decpt += 1;
        !          16227:                                if(!e_format)
        !          16228:                                {       /* add one more 0 for %f precision */
        !          16229:                                        ep[-1] = '0';
        !          16230:                                        ep += 1;
        !          16231:                                }
        !          16232:                        }
        !          16233:                }
        !          16234:        }
        !          16235: 
        !          16236: done:
        !          16237:        *--ep = '\0';
        !          16238:        _Sfi = ep-buf;
        !          16239:        return buf;
        !          16240: 
        !          16241: #endif /*NATIVE*/
        !          16242: }
        !          16243: 0707070000000002411006440044230044230000010000000471533623700003100000001116sfio/sfdlen.cUgsfGgsf#include  "sfhdr.h"
        !          16244: 
        !          16245: /*     Return the length of a double value if coded in a portable format
        !          16246: **
        !          16247: **     Written by Kiem-Phong Vo (08/05/90)
        !          16248: */
        !          16249: 
        !          16250: #if __STDC__ || __cplusplus
        !          16251: sfdlen(reg double v)
        !          16252: #else
        !          16253: sfdlen(v)
        !          16254: reg double     v;
        !          16255: #endif
        !          16256: {
        !          16257: #define N_ARRAY                (16*sizeof(double))
        !          16258:        reg int         n, w;
        !          16259:        reg double      x;
        !          16260:        int             exp;
        !          16261: 
        !          16262:        if(v < 0)
        !          16263:                v = -v;
        !          16264: 
        !          16265:        /* make the magnitude of v < 1 */
        !          16266:        if(v != 0.)
        !          16267:                v = frexp(v,&exp);
        !          16268:        else    exp = 0;
        !          16269: 
        !          16270:        for(w = 1; w <= N_ARRAY; ++w)
        !          16271:        {       /* get 2^SF_PRECIS precision at a time */
        !          16272:                n = (int)(x = ldexp(v,SF_PRECIS));
        !          16273:                if((v = x-n) <= 0.)
        !          16274:                        break;
        !          16275:        }
        !          16276: 
        !          16277:        return 1 + sfulen(exp) + w;
        !          16278: }
        !          16279: 0707070000000002421006440044230044230000010000000475453567200003200000001611sfio/sfdopen.cUgsfGgsf#include "sfhdr.h"
        !          16280: 
        !          16281: /*     Open a stream given a file descriptor.
        !          16282: **
        !          16283: **     Written by Kiem-Phong Vo (06/27/90).
        !          16284: */
        !          16285: 
        !          16286: #if !__STDC__ && !__cplusplus
        !          16287: #ifndef const
        !          16288: #define const
        !          16289: #endif
        !          16290: #endif
        !          16291: 
        !          16292: Sfile_t *sfdopen(fd,mode)
        !          16293: reg int                fd;
        !          16294: reg const char *mode;
        !          16295: {
        !          16296:        reg int         sflags;
        !          16297:        reg Sfile_t     *f;
        !          16298: 
        !          16299:        if(fd < 0 || !mode || !mode[0])
        !          16300:                return NIL(Sfile_t*);
        !          16301: 
        !          16302:        /* construct the open flags */
        !          16303:        sflags = 0;
        !          16304:        while(1) switch(*mode++)
        !          16305:        {
        !          16306:        case 'w' :
        !          16307:                sflags = SF_WRITE;
        !          16308:                break;
        !          16309:        case 'a' :
        !          16310:                (void) lseek(fd,0L,2);
        !          16311:                sflags = SF_WRITE | SF_APPEND;
        !          16312:                break;
        !          16313:        case 'r' :
        !          16314:                sflags = SF_READ;
        !          16315:                break;
        !          16316:        case '+' :
        !          16317:                sflags |= SF_READ|SF_WRITE;
        !          16318:        case 'b' :
        !          16319:                break;
        !          16320:        case  0  :
        !          16321:                goto e_mode;
        !          16322:        default :
        !          16323:                return NIL(Sfile_t*);
        !          16324:        }
        !          16325: e_mode:
        !          16326:        if(!sflags)
        !          16327:                return NIL(Sfile_t*);
        !          16328: 
        !          16329:        if((f = sfnew(NIL(Sfile_t*),NIL(uchar*),-1,fd,sflags)) != NIL(Sfile_t*))
        !          16330:                if(mode[0] != 'r' && f->mode != SF_WRITE)
        !          16331:                        _sfmode(f,SF_WRITE);
        !          16332: 
        !          16333:        return f;
        !          16334: }
        !          16335: 0707070000000002431006440044230044230000010000000474736226600003300000003334sfio/sfexcept.cUgsfGgsf#include        "sfhdr.h"
        !          16336: 
        !          16337: /*     Function to handle io exceptions.
        !          16338: **     Written by Kiem-Phong Vo (8/18/90)
        !          16339: */
        !          16340: #if __STDC__ || __cplusplus
        !          16341: _sfexcept(reg Sfile_t* f, reg int type, reg int io)
        !          16342: #else
        !          16343: _sfexcept(f,type,io)
        !          16344: reg Sfile_t    *f;     /* stream where the exception happened */
        !          16345: reg int                type;   /* io type that was performed */
        !          16346: reg int                io;     /* the io return value that indicated exception */
        !          16347: #endif
        !          16348: {
        !          16349:        reg int         d;
        !          16350:        reg uchar       *data;
        !          16351:        reg int         (*exceptf)_SFA_((Sfile_t*,int,char*));
        !          16352:        reg char        *handle;
        !          16353: 
        !          16354:        f->flags |= io < 0 ? SF_ERROR : SF_EOF;
        !          16355: 
        !          16356:        exceptf = f->disc ? f->disc->exceptf : NIL(int(*)_SFA_((Sfile_t*,int,char*)));
        !          16357:        handle = f->disc ? f->disc->handle : NIL(char*);
        !          16358:        if(exceptf)
        !          16359:        {       /* check with discipline function */
        !          16360:                SFOPEN(f); d = (*exceptf)(f,type,handle); SFLOCK(f);
        !          16361:                if(d < 0)
        !          16362:                        return SF_EDONE;
        !          16363:                else if(d > 0)
        !          16364:                        return SF_EDISC;
        !          16365:        }
        !          16366: 
        !          16367:        /* handle default cases for string streams */
        !          16368:        if((f->mode&SF_STRING) && io >= 0)
        !          16369:        {       if(type == SF_READ || (f->size >= 0 && !(f->flags&SF_MALLOC)))
        !          16370:                        goto chk_stack;
        !          16371: 
        !          16372:                /* extend buffer */
        !          16373:                if((d = f->size) < 0)
        !          16374:                        d = 0;
        !          16375:                d = ((d+io+SF_GRAIN)/SF_GRAIN)*SF_GRAIN;
        !          16376:                data = (uchar*)(f->size > 0 ? realloc((char*)f->data,d) : malloc(d));
        !          16377:                if(!data)
        !          16378:                        goto chk_stack;
        !          16379:                f->flags |= SF_MALLOC;
        !          16380:                f->endr = f->endw = f->data = data;
        !          16381:                f->endb = data+d;
        !          16382:                f->next = data+(f->size > 0 ? f->size : 0);
        !          16383:                f->size = d;
        !          16384:                return SF_ECONT;
        !          16385:        }
        !          16386: 
        !          16387:        if(errno == EINTR)
        !          16388:        {       /* if just an interrupt, we can continue */
        !          16389:                errno = 0;
        !          16390:                f->flags &= ~(SF_EOF|SF_ERROR);
        !          16391:                return SF_ECONT;
        !          16392:        }
        !          16393: 
        !          16394: chk_stack:
        !          16395:        if(f->push &&
        !          16396:           ((type == SF_READ  && f->next >= f->endb) ||
        !          16397:            (type == SF_WRITE && f->next <= f->data)))
        !          16398:        {       /* pop the stack */
        !          16399:                SFOPEN(f);
        !          16400:                sfclose((*_Sfstack)(f,NIL(Sfile_t*)));
        !          16401:                return SF_ESTACK;
        !          16402:        }
        !          16403: 
        !          16404:        return SF_EDONE;
        !          16405: }
        !          16406: 0707070000000002441006440044230044230000010000000475416411700003300000003666sfio/sfextern.cUgsfGgsf#include        "sfhdr.h"
        !          16407: 
        !          16408: /*     External variables used by sfio
        !          16409: **     Written by Kiem-Phong Vo (06/27/90)
        !          16410: */
        !          16411: 
        !          16412: Sfile_t        _Sfstdin =
        !          16413: {      NIL(uchar*),            /* next */
        !          16414:        NIL(uchar*),            /* endw */
        !          16415:        NIL(uchar*),            /* endr */
        !          16416:        NIL(uchar*),            /* endb */
        !          16417:        NIL(Sfile_t*),          /* push */
        !          16418:        SF_READ,                /* flags */
        !          16419:        0,                      /* file */
        !          16420:        0L,                     /* orig */
        !          16421: 
        !          16422:        0,                      /* size */
        !          16423:        NIL(uchar*),            /* data */
        !          16424:        0L,                     /* here */
        !          16425:        0,                      /* mode: will be set by sfmode() */
        !          16426:        "",                     /* tiny */
        !          16427:        NIL(Sfdisc_t*),         /* disc */
        !          16428:        &_Sfpool,               /* pool */
        !          16429:        NIL(Sfile_t*),          /* back */
        !          16430:        &_Sfstdout              /* fore */
        !          16431: };
        !          16432: Sfile_t _Sfstdout =
        !          16433: {      NIL(uchar*),            /* next */
        !          16434:        NIL(uchar*),            /* endw */
        !          16435:        NIL(uchar*),            /* endr */
        !          16436:        NIL(uchar*),            /* endb */
        !          16437:        NIL(Sfile_t*),          /* push */
        !          16438:        SF_WRITE,               /* flags */
        !          16439:        1,                      /* file */
        !          16440:        0L,                     /* orig */
        !          16441: 
        !          16442:        0,                      /* size */
        !          16443:        NIL(uchar*),            /* data */
        !          16444:        0L,                     /* here */
        !          16445:        0,                      /* mode: will be set by sfmode() */
        !          16446:        "",                     /* tiny */
        !          16447:        NIL(Sfdisc_t*),         /* disc */
        !          16448:        &_Sfpool,               /* pool */
        !          16449:        &_Sfstdin,              /* back */
        !          16450:        &_Sfstderr              /* fore */
        !          16451: };
        !          16452: Sfile_t _Sfstderr =
        !          16453: {      NIL(uchar*),            /* next */
        !          16454:        NIL(uchar*),            /* endw */
        !          16455:        NIL(uchar*),            /* endr */
        !          16456:        NIL(uchar*),            /* endb */
        !          16457:        NIL(Sfile_t*),          /* push */
        !          16458:        SF_WRITE,               /* flags */
        !          16459:        2,                      /* file */
        !          16460:        0L,                     /* orig */
        !          16461: 
        !          16462:        0,                      /* size */
        !          16463:        NIL(uchar*),            /* data */
        !          16464:        0L,                     /* here */
        !          16465:        0,                      /* mode: will be set by sfmode() */
        !          16466:        "",                     /* tiny */
        !          16467:        NIL(Sfdisc_t*),         /* disc */
        !          16468:        &_Sfpool,               /* pool */
        !          16469:        &_Sfstdout,             /* back */
        !          16470:        NIL(Sfile_t*)           /* fore */
        !          16471: };
        !          16472: 
        !          16473: Sfpool_t _Sfpool =             /* the discrete pool of streams */
        !          16474:        { 0, &_Sfstdin, NIL(Sfpool_t*), NIL(Sfpool_t*) };
        !          16475: 
        !          16476: Sfile_t        *_Sffree;               /* free list of streams */
        !          16477: Fa_t   *_Fafree;               /* free list of format/arglist stack objects */
        !          16478: 
        !          16479: int    _Sfi;                                   /* for fast integer decoding */
        !          16480: int    (*_Sfpclose)_SFA_((Sfile_t*));          /* to close a sfpopen-stream */
        !          16481: int    (*_Sfpmove)_SFA_((Sfile_t*, int));      /* to move a stream in a pool */
        !          16482: Sfile_t        *(*_Sfstack)_SFA_((Sfile_t*, Sfile_t*));/* to manipulate a stack of streams */
        !          16483: void   (*_Sfnotify)_SFA_((Sfile_t*, int));     /* to register streams */
        !          16484: 0707070000000002451006440044230044230000010000000472652346300003300000004430sfio/sffilbuf.cUgsfGgsf#include        "sfhdr.h"
        !          16485: 
        !          16486: /*     Fill the buffer of a stream with data.
        !          16487: **     sffilbuf behaves differently based on the second argument 'type'.
        !          16488: **     If type > 0, the first byte read is returned.
        !          16489: **     If type == 0 and in line mode, sffilbuf tries to read up to \n and
        !          16490: **             if \n is detected, the number of bytes up to \n is returned.
        !          16491: **     In all other cases, the number of bytes read is returned.
        !          16492: **
        !          16493: **     Written by Kiem-Phong Vo (06/27/90)
        !          16494: */
        !          16495: 
        !          16496: #if __STDC__ || __cplusplus
        !          16497: _sffilbuf(reg Sfile_t* f, int type)
        !          16498: #else
        !          16499: _sffilbuf(f,type)
        !          16500: reg Sfile_t    *f;     /* fill the read buffer of this stream */
        !          16501: int            type;   /* see above */
        !          16502: #endif
        !          16503: {
        !          16504:        reg int         r, n;
        !          16505:        reg uchar       *s, *data, *endb, *line, c;
        !          16506:        reg int         (*readf) _SFA_((Sfile_t*, uchar*, int, char*));
        !          16507:        reg long        (*seekf) _SFA_((Sfile_t*, long, int, char*));
        !          16508:        reg char        *handle;
        !          16509: 
        !          16510: redo_loop:
        !          16511:        if(f->mode != SF_READ && SFMODE(f,SF_READ) < 0)
        !          16512:                return -1;
        !          16513:        SFLOCK(f);
        !          16514: 
        !          16515:        readf = f->disc ? f->disc->readf : NIL(int(*) _SFA_((Sfile_t*,uchar*,int,char*)));
        !          16516:        seekf = f->disc ? f->disc->seekf : NIL(long(*) _SFA_((Sfile_t*,long,int,char*)));
        !          16517:        handle = f->disc ? f->disc->handle : NIL(char*);
        !          16518: 
        !          16519:        if(((endb = f->endb) - f->next) <= 0)
        !          16520:        {       /* no more string data */
        !          16521:                if(f->mode&SF_STRING)
        !          16522:                {       r = 0;
        !          16523:                        goto at_eof;
        !          16524:                }
        !          16525:                endb = f->next = f->endb = f->endr = f->data;
        !          16526:        }
        !          16527:        else if(type > 0)
        !          16528:                goto done;
        !          16529: 
        !          16530:        line = NIL(uchar*);
        !          16531:        n = f->size - (endb - f->data);
        !          16532:        data = endb;
        !          16533:        while(n > 0)
        !          16534:        {
        !          16535:                if(f->flags&SF_SHARE)
        !          16536:                        f->here = SEEKF(seekf,f,f->here,0,handle);
        !          16537:                if((r = READF(readf,f,data,n,handle)) > 0)
        !          16538:                {
        !          16539:                        f->here += r;
        !          16540:                        f->endb = (endb += r);
        !          16541:                        if(type > 0) /* return a char */
        !          16542:                                goto done;
        !          16543: 
        !          16544:                        /* normal filbuf */
        !          16545:                        if(type < 0 || !(f->flags&SF_LINE))
        !          16546:                                goto done;
        !          16547: 
        !          16548:                        /* must see a \n */
        !          16549:                        c = endb[-1]; endb[-1] = '\n';
        !          16550:                        s = data;
        !          16551:                        while(*s++ != '\n')
        !          16552:                                ;
        !          16553:                        endb[-1] = c;
        !          16554:                        if(s < endb || c == '\n')
        !          16555:                        {
        !          16556:                                line = s;
        !          16557:                                goto done;
        !          16558:                        }
        !          16559: 
        !          16560:                        /* read some more */
        !          16561:                        n -= r;
        !          16562:                        data += r;
        !          16563:                }
        !          16564:                else
        !          16565:                {       /* eof or error */
        !          16566:                at_eof :
        !          16567:                        switch(_sfexcept(f,SF_READ,r))
        !          16568:                        {
        !          16569:                        case SF_ESTACK :
        !          16570:                                if(f->next < (endb = f->endb))
        !          16571:                                        goto done;
        !          16572:                                /* else fall through */
        !          16573:                        case SF_EDISC :
        !          16574:                                SFopen(f);
        !          16575:                                goto redo_loop;
        !          16576:                        case SF_EDONE :
        !          16577:                                goto done;
        !          16578:                        }
        !          16579:                }
        !          16580:        }
        !          16581: 
        !          16582: done:
        !          16583:        r = type > 0 ?  (f->next < endb ? (int)(*f->next++) : EOF) :
        !          16584:                        ((line ? line : endb) - f->next);
        !          16585:        SFOPEN(f);
        !          16586:        return r;
        !          16587: }
        !          16588: 0707070000000002461006440044230044230000010000000475116766300003300000005016sfio/sfflsbuf.cUgsfGgsf#include        "sfhdr.h"
        !          16589: 
        !          16590: /*     Write a buffer out to a file descriptor or
        !          16591: **     extending a buffer for a SF_STRING stream.
        !          16592: **
        !          16593: **     Written by Kiem-Phong Vo (06/27/90)
        !          16594: */
        !          16595: 
        !          16596: #if __STDC__ || __cplusplus
        !          16597: _sfflsbuf(reg Sfile_t* f, reg int c)
        !          16598: #else
        !          16599: _sfflsbuf(f,c)
        !          16600: reg Sfile_t    *f;     /* write out the buffered content of this stream */
        !          16601: reg int                c;      /* if c>=0, c is also written out */ 
        !          16602: #endif
        !          16603: {
        !          16604:        reg int         n, w;
        !          16605:        reg uchar       *data;
        !          16606:        reg int         (*writef) _SFA_((Sfile_t*, const uchar*, int, char*));
        !          16607:        reg long        (*seekf) _SFA_((Sfile_t*, long, int, char*));
        !          16608:        reg char        *handle;
        !          16609:        uchar           outc;
        !          16610:        int             inpc = c;
        !          16611: 
        !          16612: redo_loop:
        !          16613:        if(f->mode != SF_WRITE && SFMODE(f,SF_WRITE) < 0)
        !          16614:                return -1;
        !          16615:        SFLOCK(f);
        !          16616: 
        !          16617:        writef = f->disc ? f->disc->writef :
        !          16618:                        NIL(int(*)_SFA_((Sfile_t*, const uchar*, int, char*)));
        !          16619:        seekf  = f->disc ? f->disc->seekf  :
        !          16620:                        NIL(long(*)_SFA_((Sfile_t*, long, int, char*)));
        !          16621:        handle = f->disc ? f->disc->handle : NIL(char*);
        !          16622: 
        !          16623:        n = f->next - (data = f->data);
        !          16624:        if(n >= f->size && (f->mode&SF_STRING))
        !          16625:        {       /* at eof */
        !          16626:                w = 0;
        !          16627:                goto at_eof;
        !          16628:        }
        !          16629: 
        !          16630:        if(c >= 0)
        !          16631:        {       /* there is still space in the buffer */
        !          16632:                if(n < f->size)
        !          16633:                {       *f->next++ = c;
        !          16634:                        w = 1;
        !          16635:                        if(c != '\n' || (f->flags&SF_STRING) || !(f->flags&SF_LINE))
        !          16636:                                goto done;
        !          16637:                        n += 1;
        !          16638:                        c = -1;
        !          16639:                }
        !          16640:                else if(n == 0)
        !          16641:                {       /* unbuffered io */
        !          16642:                        outc = (uchar)c;
        !          16643:                        data = &outc;
        !          16644:                        n = 1;
        !          16645:                        c = -1;
        !          16646:                }
        !          16647:        }
        !          16648:        else if(n <= 0)
        !          16649:        {       /* no op */
        !          16650:                w = 0;
        !          16651:                goto done;
        !          16652:        }
        !          16653: 
        !          16654:        /* write data to file */
        !          16655:        f->next = f->data;
        !          16656:        for(;;)
        !          16657:        {       /* make sure we are at the right place before writing */
        !          16658: #ifdef NO_OFLAGS /* simulate append mode */
        !          16659:                if(f->flags&SF_APPEND)
        !          16660:                        f->here = SEEKF(seekf,f,0L,2,handle);
        !          16661:                else /* no, it doesn't dangle */
        !          16662: #endif
        !          16663:                if(f->flags&SF_SHARE)
        !          16664:                        f->here = SEEKF(seekf,f,f->here,0,handle);
        !          16665: 
        !          16666:                if((w = WRITEF(writef,f,data,n,handle)) > 0)
        !          16667:                {       /* successful write */
        !          16668:                        f->here += w;
        !          16669:                        if((n -= w) > 0)
        !          16670:                                data += w;
        !          16671:                        else if(c < 0)
        !          16672:                                goto done;
        !          16673:                        else if(c == '\n' && (f->flags&SF_LINE))
        !          16674:                        {       /* line buffering */
        !          16675:                                outc = '\n';
        !          16676:                                data = &outc;
        !          16677:                                n = 1;
        !          16678:                                c = -1;
        !          16679:                        }
        !          16680:                        else
        !          16681:                        {       *f->next++ = c;
        !          16682:                                goto done;
        !          16683:                        }
        !          16684:                }
        !          16685:                else
        !          16686:                {
        !          16687:                at_eof :
        !          16688:                        if(data == &outc)
        !          16689:                                c = outc;
        !          16690:                        else
        !          16691:                        {       /* save unwritten data */
        !          16692:                                if(data != f->data)
        !          16693:                                        memcpy((char*)f->data,(char*)data,n);
        !          16694:                                f->next = f->data+n;
        !          16695:                        }
        !          16696: 
        !          16697:                        switch(_sfexcept(f,SF_WRITE,w))
        !          16698:                        {
        !          16699:                        default :
        !          16700:                        case SF_EDISC :
        !          16701:                        case SF_ESTACK :
        !          16702:                                SFopen(f);
        !          16703:                                goto redo_loop;
        !          16704:                        case SF_EDONE :
        !          16705:                                if(c >= 0 && f->next < f->endb)
        !          16706:                                        *f->next++ = c;
        !          16707:                                w = -1;
        !          16708:                                goto done;
        !          16709:                        }
        !          16710:                }
        !          16711:        }
        !          16712: done :
        !          16713:        SFOPEN(f);
        !          16714:        return (inpc < 0 || w < 0) ? w : inpc;
        !          16715: }
        !          16716: 0707070000000002471006440044230044230000010000000471533746700003100000001357sfio/sfgetd.cUgsfGgsf#include  "sfhdr.h"
        !          16717: 
        !          16718: /*     Read a portably coded double value
        !          16719: **
        !          16720: **     Written by Kiem-Phong Vo (08/05/90)
        !          16721: */
        !          16722: 
        !          16723: #if __STDC__ || __cplusplus
        !          16724: double sfgetd(Sfile_t* f)
        !          16725: #else
        !          16726: double sfgetd(f)
        !          16727: Sfile_t        *f;
        !          16728: #endif
        !          16729: {
        !          16730:        reg uchar       *s, *ends, c;
        !          16731:        reg double      v;
        !          16732:        reg int         p, sign, exp;
        !          16733: 
        !          16734:        if((sign = sfgetc(f)) < 0 || (exp = (int)sfgetu(f)) < 0)
        !          16735:                return -1.;
        !          16736: 
        !          16737:        SFLOCK(f);
        !          16738: 
        !          16739:        v = 0.;
        !          16740:        for(;;)
        !          16741:        {       /* fast read for data */
        !          16742:                if(SFRPEEK(f,s,p) <= 0)
        !          16743:                {       f->flags |= SF_ERROR;
        !          16744:                        v = -1.;
        !          16745:                        goto done;
        !          16746:                }
        !          16747: 
        !          16748:                for(ends = s+p; s < ends; )
        !          16749:                {
        !          16750:                        c = *s++;
        !          16751:                        v += SFUVALUE(c);
        !          16752:                        v = ldexp(v,-SF_PRECIS);
        !          16753:                        if(!(c&SF_MORE))
        !          16754:                        {       f->next = s;
        !          16755:                                goto done;
        !          16756:                        }
        !          16757:                }
        !          16758:                f->next = s;
        !          16759:        }
        !          16760: 
        !          16761: done:
        !          16762:        v = ldexp(v,(sign&02) ? -exp : exp);
        !          16763:        if(sign&01)
        !          16764:                v = -v;
        !          16765:        SFOPEN(f);
        !          16766:        return v;
        !          16767: }
        !          16768: 0707070000000002501006440044230044230000010000000471531654200003100000001407sfio/sfgetl.cUgsfGgsf#include  "sfhdr.h"
        !          16769: 
        !          16770: /*     Read a long value coded in a portable format.
        !          16771: **
        !          16772: **     Written by Kiem-Phong Vo (06/27/90)
        !          16773: */
        !          16774: 
        !          16775: #if __STDC__ || __cplusplus
        !          16776: long _sfgetl(reg Sfile_t* f)
        !          16777: #else
        !          16778: long _sfgetl(f)
        !          16779: reg Sfile_t    *f;
        !          16780: #endif
        !          16781: {
        !          16782:        reg uchar       *s, *ends, c;
        !          16783:        reg int         p;
        !          16784:        reg long        v;
        !          16785: 
        !          16786:        if(_Sfi&SF_SIGN)
        !          16787:                return -SFSVALUE(_Sfi)-1;
        !          16788: 
        !          16789:        SFLOCK(f);
        !          16790:        v = SFUVALUE(_Sfi);
        !          16791:        for(;;)
        !          16792:        {
        !          16793:                if(SFRPEEK(f,s,p) <= 0)
        !          16794:                {       f->flags |= SF_ERROR;
        !          16795:                        v = -1;
        !          16796:                        goto done;
        !          16797:                }
        !          16798:                for(ends = s+p; s < ends;)
        !          16799:                {
        !          16800:                        c = *s++;
        !          16801:                        if(c&SF_MORE)
        !          16802:                                v = ((ulong)v << SF_UBITS) | SFUVALUE(c);
        !          16803:                        else
        !          16804:                        {       /* special translation for this byte */
        !          16805:                                v = ((ulong)v << SF_SBITS) | SFSVALUE(c);
        !          16806:                                f->next = s;
        !          16807:                                v = (c&SF_SIGN) ? -v-1 : v;
        !          16808:                                goto done;
        !          16809:                        }
        !          16810:                }
        !          16811:                f->next = s;
        !          16812:        }
        !          16813: done :
        !          16814:        SFOPEN(f);
        !          16815:        return v;
        !          16816: }
        !          16817: 0707070000000002511006440044230044230000010000000475215125400003100000003510sfio/sfgets.cUgsfGgsf#include  "sfhdr.h"
        !          16818: 
        !          16819: /*     Read a line into a buffer. The line length is saved in the
        !          16820: **     stream buffer and can be accessed via sfslen(). If the buffer
        !          16821: **     size n is <= 0, the string will be kept in a static area.
        !          16822: **
        !          16823: **     Written by Kiem-Phong Vo (06/27/90)
        !          16824: */
        !          16825: 
        !          16826: #if __STDC__ || __cplusplus
        !          16827: char *sfgets(reg Sfile_t *f, char* us, reg int n)
        !          16828: #else
        !          16829: char *sfgets(f,us,n)
        !          16830: reg Sfile_t    *f;     /* stream to read from */
        !          16831: char           *us;    /* space to read into */
        !          16832: reg int                n;      /* max number of bytes to read */
        !          16833: #endif
        !          16834: {
        !          16835:        reg uchar       *ps, *s;
        !          16836:        reg int         p;
        !          16837:        static uchar    *Sfs;
        !          16838:        static int      Sfn;
        !          16839: 
        !          16840:        if(f->mode != SF_READ && SFMODE(f,SF_READ) < 0)
        !          16841:                return NIL(char*);
        !          16842:        SFLOCK(f);
        !          16843: 
        !          16844:        if(n <= 0 || !us)
        !          16845:        {       us = (char*)Sfs;
        !          16846:                n  = -1;
        !          16847:        }
        !          16848:        else    n -= 1;
        !          16849: 
        !          16850:        s = (uchar*)us;
        !          16851:        while(n)
        !          16852:        {       /* peek the read buffer for data */
        !          16853:                if(SFRPEEK(f,ps,p) <= 0)
        !          16854:                        break;
        !          16855: 
        !          16856:                /* set amount copyable right now */
        !          16857:                if(p > n)
        !          16858:                {       if(n > 0)
        !          16859:                                p = n;
        !          16860:                        else
        !          16861:                        {       /* make sure our buffer has space */
        !          16862:                                n = s - Sfs;
        !          16863:                                if(n >= Sfn-1)
        !          16864:                                {       Sfn += SF_GRAIN;
        !          16865:                                        Sfs = Sfs ? (uchar*)realloc((char*)Sfs,Sfn) :
        !          16866:                                                    (uchar*)malloc(Sfn);
        !          16867:                                        if(!Sfs)
        !          16868:                                        {       /* can't get more space */
        !          16869:                                                Sfs = (uchar*)us;
        !          16870:                                                Sfn -= SF_GRAIN;
        !          16871:                                                break;
        !          16872:                                        }
        !          16873:                                        else
        !          16874:                                        {       us = (char*)Sfs;
        !          16875:                                                s = Sfs+n;
        !          16876:                                        }
        !          16877:                                }
        !          16878: 
        !          16879:                                /* copy at most this much */
        !          16880:                                if(p > (n = (Sfn-1)-n))
        !          16881:                                        p = n;
        !          16882:                                n = -1;
        !          16883:                        }
        !          16884:                }
        !          16885: 
        !          16886:                if((f->flags&SF_STRING) && !(f->flags&SF_WRITE))
        !          16887:                {       reg uchar *endps = ps+p;
        !          16888:                        while(ps < endps && (*s++ = *ps++) != '\n')
        !          16889:                                ;
        !          16890:                }
        !          16891:                else
        !          16892:                {       reg int c = ps[p-1]; ps[p-1] = '\n';
        !          16893:                        while((*s++ = *ps++) != '\n')
        !          16894:                                ;
        !          16895:                        if((ps - f->next) == p)
        !          16896:                                s[-1] = c;
        !          16897:                        f->next[p-1] = c;
        !          16898:                }
        !          16899: 
        !          16900:                /* gobble up read data */
        !          16901:                f->next = ps;
        !          16902: 
        !          16903:                if(ps[-1] == '\n')
        !          16904:                        break;
        !          16905:                else if(n > 0)
        !          16906:                        n -= p;
        !          16907:        }
        !          16908: 
        !          16909:        if((_Sfi = s - ((uchar*)us)) <= 0)
        !          16910:                us = NIL(char*);
        !          16911:        else    *s = '\0';
        !          16912: done :
        !          16913:        SFOPEN(f);
        !          16914:        return us;
        !          16915: }
        !          16916: 0707070000000002521006440044230044230000010000000473117502400003100000001252sfio/sfgetu.cUgsfGgsf#include  "sfhdr.h"
        !          16917: 
        !          16918: /*     Read an unsigned long value coded in a portable format.
        !          16919: **
        !          16920: **     Written by Kiem-Phong Vo (06/27/90)
        !          16921: */
        !          16922: 
        !          16923: #if __STDC__ || __cplusplus
        !          16924: ulong _sfgetu(reg Sfile_t* f)
        !          16925: #else
        !          16926: ulong _sfgetu(f)
        !          16927: reg Sfile_t    *f;
        !          16928: #endif
        !          16929: {
        !          16930:        reg uchar       *s, *ends, c;
        !          16931:        reg int         p;
        !          16932:        reg ulong       v;
        !          16933: 
        !          16934:        if(f->mode != SF_READ && SFMODE(f,SF_READ) < 0)
        !          16935:                return -1L;
        !          16936: 
        !          16937:        SFLOCK(f);
        !          16938:        v = SFUVALUE(_Sfi);
        !          16939:        for(;;)
        !          16940:        {
        !          16941:                if(SFRPEEK(f,s,p) <= 0)
        !          16942:                {       f->flags |= SF_ERROR;
        !          16943:                        v = (ulong)(-1);
        !          16944:                        goto done;
        !          16945:                }
        !          16946:                for(ends = s+p; s < ends;)
        !          16947:                {
        !          16948:                        c = *s++;
        !          16949:                        v = (v << SF_UBITS) | SFUVALUE(c);
        !          16950:                        if(!(c&SF_MORE))
        !          16951:                        {
        !          16952:                                f->next = s;
        !          16953:                                goto done;
        !          16954:                        }
        !          16955:                }
        !          16956:                f->next = s;
        !          16957:        }
        !          16958: done:
        !          16959:        SFOPEN(f);
        !          16960:        return v;
        !          16961: }
        !          16962: 0707070000000002531006440044230044230000010000000475447604400003000000023455sfio/sfhdr.hUgsfGgsf#ifndef _SFHDR_H
        !          16963: #define _SFHDR_H
        !          16964: 
        !          16965: /*     Internal definitions for sfio.
        !          16966: **     Written by Kiem-Phong Vo (07/16/90)
        !          16967: **     AT&T Bell Laboratories
        !          16968: */
        !          16969: 
        !          16970: /* the parts of Sfio_t private to sfio functions */
        !          16971: #define _SFIO_PRIVATE \
        !          16972:        int             size;   /* buffer size                  */ \
        !          16973:        unsigned char   *data;  /* data buffer                  */ \
        !          16974:        long            here;   /* current physical location    */ \
        !          16975:        unsigned char   mode;   /* current io mode              */ \
        !          16976:        unsigned char   tiny[1];/* for unbuffered read stream   */ \
        !          16977:        struct _sfdc_   *disc;  /* discipline                   */ \
        !          16978:        struct _sfpl_   *pool;  /* the pool containing this     */ \
        !          16979:        struct _sfio_   *back;  /* backward link in pool        */ \
        !          16980:        struct _sfio_   *fore;  /* forward link in pool         */
        !          16981: 
        !          16982: #include       "sfio.h"
        !          16983: #include       <errno.h>
        !          16984: #include       <sys/types.h>
        !          16985: #include       <sys/stat.h>
        !          16986: #include       <ctype.h>
        !          16987: #include       <fcntl.h>
        !          16988: #if __STDC__ || __cplusplus
        !          16989: #include       <stdarg.h>
        !          16990: #else
        !          16991: #include       <varargs.h>
        !          16992: #endif
        !          16993: 
        !          16994: #define uchar          unsigned char
        !          16995: #define ulong          unsigned long
        !          16996: #define uint           unsigned int
        !          16997: #define reg            register
        !          16998: #define NIL(p)         ((p)0)
        !          16999: 
        !          17000: /* stream pool structure. */
        !          17001: typedef struct _sfpl_
        !          17002: {
        !          17003:        int             mode;           /* type of pool                 */
        !          17004:        Sfile_t         *head;          /* head of pool's stream list   */
        !          17005:        struct _sfpl_   *back;          /* linked list of pools         */
        !          17006:        struct _sfpl_   *fore;
        !          17007: } Sfpool_t;
        !          17008: 
        !          17009: /* extension structures for sfvprintf/sfvscanf */
        !          17010: typedef int(*Argf_s)_SFA_((char,char*,uint));
        !          17011: typedef int(*Extf_s)_SFA_((Sfile_t*,int,int,char**));
        !          17012: typedef int(*Argf_p)_SFA_((int,char*));
        !          17013: typedef int(*Extf_p)_SFA_((char*,int,int,char*));
        !          17014: typedef struct _fa_
        !          17015: {
        !          17016:        char            *form;          /* format string                */
        !          17017:        va_list         args;           /* corresponding arglist        */
        !          17018:        union
        !          17019:        { Argf_s        s;              /* argf for sfvscanf            */
        !          17020:          Argf_p        p;              /* argf for sfvprintf           */
        !          17021:        }               argf;
        !          17022:        union
        !          17023:        { Extf_s        s;              /* extf for sfvscanf            */
        !          17024:          Extf_p        p;              /* extf for sfvprintf           */
        !          17025:        }               extf;
        !          17026:        struct _fa_     *next;          /* next on the stack            */
        !          17027: } Fa_t;
        !          17028: #define FAMALLOC(f)    ((f = _Fafree) ? (_Fafree = f->next, f) : \
        !          17029:                                (f = (Fa_t*)malloc(sizeof(Fa_t))))
        !          17030: #define FAFREE(f)      (f->next = _Fafree, _Fafree = f)
        !          17031: 
        !          17032: /* function to clear an sfio structure */
        !          17033: #define SFCLEAR(f) \
        !          17034:        ((f)->next = (f)->endw = (f)->endr = (f)->endb = (f)->data = NIL(uchar*), \
        !          17035:         (f)->flags = 0, (f)->file = -1, (f)->orig = (f)->here = -1L, \
        !          17036:         (f)->mode = 0, (f)->size = 0, (f)->disc = NIL(Sfdisc_t*), \
        !          17037:         (f)->pool = NIL(Sfpool_t*), (f)->push = (f)->back = (f)->fore = NIL(Sfile_t*))
        !          17038: 
        !          17039: /* get the real value of a byte in a coded long or ulong */
        !          17040: #define SFUVALUE(v)    ((v)&(SF_MORE-1))
        !          17041: #define SFSVALUE(v)    ((v)&(SF_SIGN-1))
        !          17042: 
        !          17043: /* amount of precision to get in each iteration during coding of doubles */
        !          17044: #define SF_PRECIS      (SF_UBITS-1)
        !          17045: 
        !          17046: /* garin size for buffer increment */
        !          17047: #define SF_GRAIN       1024
        !          17048: 
        !          17049: /* bits for the mode field */
        !          17050: #define SF_SYNC                0010    /* stream was synced                    */
        !          17051: #define SF_PUSH                0020    /* stream has been pushed               */
        !          17052: #define SF_LOCK                0040    /* stream is locked for io op           */
        !          17053: #define SF_POOL                0200    /* stream is in a pool but not current  */
        !          17054: 
        !          17055: /* check to see if the stream can be accessed */
        !          17056: #define SFFROZEN(f)    ((f)->mode&(SF_PUSH|SF_LOCK))
        !          17057: 
        !          17058: /* NOTE: these flags share the same space with the public flags */
        !          17059: #define SF_PROCESS     0010000 /* this stream is sfpopen               */
        !          17060: #define SF_PUTC                0020000 /* sfputc ok on this stream             */
        !          17061: #define SF_GETC                0040000 /* sfgetc ok on this stream             */
        !          17062: #define SF_BOTH                0100000 /* both read/write                      */
        !          17063: 
        !          17064: /* lock/open a stream */
        !          17065: #define SFlock(f)      ((f)->mode |= SF_LOCK)
        !          17066: #define SFopen(f)      ((f)->mode &= ~SF_LOCK)
        !          17067: #define SFLOCK(f)      (SFlock(f), (f)->endr = (f)->endw = (f)->data)
        !          17068: #define SFOPEN(f)      (SFopen(f), \
        !          17069:                         (f)->endr = ((f)->flags&SF_GETC) ? (f)->endb : (f)->data, \
        !          17070:                         (f)->endw = ((f)->flags&SF_PUTC) ? (f)->endb : (f)->data)
        !          17071: 
        !          17072: /* short-hand for common stream types */
        !          17073: #define SF_RDWR                (SF_READ|SF_WRITE)
        !          17074: #define SF_RDSTR       (SF_READ|SF_STRING)
        !          17075: #define SF_WRSTR       (SF_WRITE|SF_STRING)
        !          17076: 
        !          17077: /* exception types */
        !          17078: #define SF_EDONE       0       /* stop this operation and return       */
        !          17079: #define SF_EDISC       1       /* discipline says it's ok              */
        !          17080: #define SF_ESTACK      2       /* stack was popped                     */
        !          17081: #define SF_ECONT       3       /* can continue normally                */
        !          17082: 
        !          17083: /* more than this for a line buffer, we might as well flush */
        !          17084: #define HIFORLINE      128
        !          17085: 
        !          17086: /* read/write/seek functions with disciplines */
        !          17087: #define READF(rdfn,f,d,n,hdl)  ((rdfn) ? (*(rdfn))(f,d,n,hdl) : read((f)->file,d,n))
        !          17088: #define WRITEF(wrfn,f,d,n,hdl) ((wrfn) ? (*(wrfn))(f,d,n,hdl) : write((f)->file,(char*)d,n))
        !          17089: #define SEEKF(skfn,f,p,o,hdl)  ((skfn) ? (*(skfn))(f,p,o,hdl) : lseek((f)->file,p,o))
        !          17090: 
        !          17091: /* control flags for open() */
        !          17092: #ifndef O_CREAT        /* V9 */
        !          17093: #define NO_OFLAGS
        !          17094: #define O_CREAT                004
        !          17095: #define O_TRUNC                010
        !          17096: #define O_APPEND       020
        !          17097: 
        !          17098: #ifndef O_RDONLY
        !          17099: #define        O_RDONLY        000
        !          17100: #endif
        !          17101: #ifndef O_WRONLY
        !          17102: #define O_WRONLY       001
        !          17103: #endif
        !          17104: #ifndef O_RDWR
        !          17105: #define O_RDWR         002
        !          17106: #endif
        !          17107: #endif
        !          17108: 
        !          17109: /* floating point to ascii conversion */
        !          17110: #define MAXLONG                ((long)(((ulong)~0L) >> 1))
        !          17111: #define MAXEXP10       6
        !          17112: #define MAXPOW10       (1 << MAXEXP10)
        !          17113: #define FDIGITS                60              /* max allowed fractional digits */
        !          17114: #define IDIGITS                1536            /* max number of digits in int part */
        !          17115: #define MAXDIGITS      (((FDIGITS+IDIGITS)/sizeof(int) + 1)*sizeof(int))
        !          17116: 
        !          17117: /* sfucvt() converts decimal integers to ASCII */
        !          17118: #define SFDIGIT(v,scale,digit) \
        !          17119:        { if(v < 5*scale) \
        !          17120:                if(v < 2*scale) \
        !          17121:                        if(v < 1*scale) \
        !          17122:                                { digit = '0'; } \
        !          17123:                        else    { digit = '1'; v -= 1*scale; } \
        !          17124:                else    if(v < 3*scale) \
        !          17125:                                { digit = '2'; v -= 2*scale; } \
        !          17126:                        else if(v < 4*scale) \
        !          17127:                                { digit = '3'; v -= 3*scale; } \
        !          17128:                        else    { digit = '4'; v -= 4*scale; } \
        !          17129:          else  if(v < 7*scale) \
        !          17130:                        if(v < 6*scale) \
        !          17131:                                { digit = '5'; v -= 5*scale; } \
        !          17132:                        else    { digit = '6'; v -= 6*scale; } \
        !          17133:                else    if(v < 8*scale) \
        !          17134:                                { digit = '7'; v -= 7*scale; } \
        !          17135:                        else if(v < 9*scale) \
        !          17136:                                { digit = '8'; v -= 8*scale; } \
        !          17137:                        else    { digit = '9'; v -= 9*scale; } \
        !          17138:        }
        !          17139: #define sfucvt(v,s,n,w,list) \
        !          17140:        { list = (char*)_Sfdec; \
        !          17141:          while((ulong)v >= 100000) \
        !          17142:          {     w = v; v = ((ulong)v)/100000; n = ((ulong)w) - ((ulong)v)*100000; \
        !          17143:                SFDIGIT(n,10000,s[-5]); \
        !          17144:                SFDIGIT(n,1000,s[-4]); \
        !          17145:                SFDIGIT(n,100,s[-3]); \
        !          17146:                *--s = (char)('0' + ((n = (uchar)list[n])&017)); \
        !          17147:                *--s = (char)('0' + (n >> 4)); \
        !          17148:                s -= 3; \
        !          17149:          } \
        !          17150:          if(v >= 100) \
        !          17151:          {     if(v >= 1000) \
        !          17152:                {       if(v >= 10000) \
        !          17153:                        {       w = 3; \
        !          17154:                                SFDIGIT(v,10000,s[-5]); \
        !          17155:                        } \
        !          17156:                        else    w = 2; \
        !          17157:                        SFDIGIT(v,1000,s[-4]); \
        !          17158:                } \
        !          17159:                else    w = 1; \
        !          17160:                SFDIGIT(v,100,s[-3]); \
        !          17161:                *--s = (char)('0' + ((n = (uchar)list[v])&017)); \
        !          17162:                *--s = (char)('0' + (n >> 4)); \
        !          17163:                s -= w; \
        !          17164:          } \
        !          17165:          else \
        !          17166:          {     *--s = (char)('0' + ((n = (uchar)list[v])&017)); \
        !          17167:                if((n >>= 4) > 0) \
        !          17168:                        *--s = (char)('0' + n); \
        !          17169:          } \
        !          17170:        }
        !          17171: 
        !          17172: /* fast peek of a stream */
        !          17173: #define SFAVAIL(f,s,n) ((n) = (f)->endb - ((s) = (f)->next) )
        !          17174: #define SFRPEEK(f,s,n) (SFAVAIL((f),(s),(n)) > 0 ? (n) : \
        !          17175:                         ((SFopen(f), (n) = _sffilbuf(f,-1), SFLOCK(f)), \
        !          17176:                          (n) <= 0 ? -1 : SFAVAIL(f,s,n)))
        !          17177: #define SFWPEEK(f,s,n) (SFAVAIL((f),(s),(n)) > 0 ? (n) : \
        !          17178:                         ((SFopen(f), (n) = _sfflsbuf(f,-1), SFLOCK(f)), \
        !          17179:                          (n) <  0 ? -1 : SFAVAIL(f,s,n)))
        !          17180: #define SFMODE(f,m)    ((f)->mode != SF_STRING ? _sfmode((f),(m)) : \
        !          17181:                         (((f)->flags&(m)) == (m) ? 0 : -1))
        !          17182: 
        !          17183: /* malloc and free of streams */
        !          17184: #define SFFREE(f)      (f->fore = _Sffree, _Sffree = f)
        !          17185: #define SFALLOC(f)     ((f = _Sffree) ? (_Sffree = f->fore, f) : \
        !          17186:                                   (f = (Sfile_t*)malloc(sizeof(Sfile_t))))
        !          17187: 
        !          17188: /* handy functions */
        !          17189: #define min(x,y)       ((x) < (y) ? (x) : (y))
        !          17190: #define max(x,y)       ((x) > (y) ? (x) : (y))
        !          17191: 
        !          17192: /* fast functions for memory copy and memory clear */
        !          17193: #ifdef LIBX
        !          17194: #include       "FEATURE/bcopy"
        !          17195: #include       "FEATURE/atexit"
        !          17196: #include       "FEATURE/onexit"
        !          17197: #include       "FEATURE/on_exit"
        !          17198: #else
        !          17199: #ifdef BSD
        !          17200: #define        _lib_bcopy
        !          17201: #define _lib_on_exit
        !          17202: #else
        !          17203: #ifdef V9
        !          17204: #define _lib_onexit
        !          17205: #endif /*V9*/
        !          17206: #endif /*BSD*/
        !          17207: #endif /*LIBX*/
        !          17208: 
        !          17209: #ifdef _lib_bcopy
        !          17210: #undef memcpy
        !          17211: #define memcpy(to,fr,n)        bcopy((fr),(to),(n))
        !          17212: #define memclear(s,n)  bzero((s),(n))
        !          17213: #else
        !          17214: #define memclear(s,n)  memset((s),'\0',(n))
        !          17215: #endif
        !          17216: 
        !          17217: #ifndef _lib_atexit
        !          17218: #ifdef _lib_on_exit
        !          17219: #define atexit on_exit
        !          17220: #else
        !          17221: #ifdef _lib_onexit
        !          17222: #define atexit onexit
        !          17223: #endif /*onexit*/
        !          17224: #endif /*on_exit*/
        !          17225: #endif /*atexit*/
        !          17226: 
        !          17227: #ifdef atexit
        !          17228: #define _lib_atexit
        !          17229: #endif
        !          17230: 
        !          17231: /* note that MEMCPY advances the associated pointers */
        !          17232: #define MEMCPY(to,fr,n) \
        !          17233:        switch(n) \
        !          17234:        { default : memcpy((char*)to,(char*)fr,n); to += n; fr += n; break; \
        !          17235:          case  7 : *to++ = *fr++; \
        !          17236:          case  6 : *to++ = *fr++; \
        !          17237:          case  5 : *to++ = *fr++; \
        !          17238:          case  4 : *to++ = *fr++; \
        !          17239:          case  3 : *to++ = *fr++; \
        !          17240:          case  2 : *to++ = *fr++; \
        !          17241:          case  1 : *to++ = *fr++; \
        !          17242:          case  0 : break; \
        !          17243:        }
        !          17244: #define MEMSET(s,c,n) \
        !          17245:        switch(n) \
        !          17246:        { default : memset((char*)s,(char)c,n); s += n; break; \
        !          17247:          case  7 : *s++ = c; \
        !          17248:          case  6 : *s++ = c; \
        !          17249:          case  5 : *s++ = c; \
        !          17250:          case  4 : *s++ = c; \
        !          17251:          case  3 : *s++ = c; \
        !          17252:          case  2 : *s++ = c; \
        !          17253:          case  1 : *s++ = c; \
        !          17254:          case  0 : break; \
        !          17255:        }
        !          17256: 
        !          17257: #ifdef __cplusplus
        !          17258: extern "C" {
        !          17259: #endif
        !          17260: 
        !          17261: extern Fa_t    *_Fafree;
        !          17262: extern Sfile_t *_Sffree;
        !          17263: extern Sfpool_t        _Sfpool;
        !          17264: extern double  _Sfpos10[MAXEXP10], _Sfneg10[MAXEXP10];
        !          17265: extern uchar   _Sfdec[];
        !          17266: extern int     (*_Sfpclose)_SFA_((Sfile_t*));
        !          17267: extern int     (*_Sfpmove)_SFA_((Sfile_t*, int));
        !          17268: extern Sfile_t *(*_Sfstack)_SFA_((Sfile_t*, Sfile_t*));
        !          17269: extern void    (*_Sfnotify)_SFA_((Sfile_t*, int));
        !          17270: 
        !          17271: extern int     errno;
        !          17272: extern int     _sfmode _SFA_((Sfile_t*, int));
        !          17273: extern int     _sfexcept _SFA_((Sfile_t*, int, int));
        !          17274: extern double  frexp _SFA_((double, int*)), ldexp _SFA_((double,int));
        !          17275: extern double  strtod _SFA_((char*, char**));
        !          17276: extern char    *malloc _SFA_((int));
        !          17277: extern char    *realloc _SFA_((char*,int));
        !          17278: extern char    *mktemp _SFA_((char*));
        !          17279: extern int     unlink _SFA_((char*));
        !          17280: extern void    free _SFA_((char*));
        !          17281: extern int     strlen _SFA_((const char*));
        !          17282: extern int     isatty _SFA_((int));
        !          17283: extern void    memset _SFA_((char*,char,int));
        !          17284: 
        !          17285: #ifdef _lib_bcopy
        !          17286: extern void    bcopy _SFA_((char*,char*,int));
        !          17287: #ifndef __cplusplus
        !          17288: extern void    bzero _SFA_((char*,int));
        !          17289: #endif
        !          17290: #else
        !          17291: extern void    memcpy _SFA_((void*,void*,int));
        !          17292: #endif
        !          17293: 
        !          17294: extern int     read _SFA_((int,void*,int));
        !          17295: extern int     write _SFA_((int,void*,int));
        !          17296: extern long    lseek _SFA_((int,long,int));
        !          17297: extern int     open _SFA_((char*, int, int));
        !          17298: extern int     close _SFA_((int));
        !          17299: extern int     dup _SFA_((int));
        !          17300: extern void    _exit _SFA_((int));
        !          17301: extern int     atexit _SFA_((void(*)()));
        !          17302: 
        !          17303: #if __cplusplus
        !          17304: }
        !          17305: #endif
        !          17306: 
        !          17307: #endif /* _SFHDR_H */
        !          17308: 0707070000000002541006440044230044230000010000000471531670300003100000000447sfio/sfllen.cUgsfGgsf#include  "sfhdr.h"
        !          17309: 
        !          17310: /*     Get size of a long value coded in a portable format
        !          17311: **
        !          17312: **     Written by Kiem-Phong Vo (06/27/90)
        !          17313: */
        !          17314: #if __STDC__ || __cplusplus
        !          17315: sfllen(reg long v)
        !          17316: #else
        !          17317: sfllen(v)
        !          17318: reg long       v;
        !          17319: #endif
        !          17320: {
        !          17321:        if(v < 0)
        !          17322:                v = -(v+1);
        !          17323:        v = (ulong)v >> SF_SBITS;
        !          17324:        return 1 + (v > 0 ? sfulen(v) : 0);
        !          17325: }
        !          17326: 0707070000000002551006440044230044230000010000000475414055600003100000004660sfio/sfmode.cUgsfGgsf#include  "sfhdr.h"
        !          17327: 
        !          17328: /*     Switch the given stream to a desired mode
        !          17329: **
        !          17330: **     Written by Kiem-Phong Vo (06/27/90)
        !          17331: */
        !          17332: 
        !          17333: #if __STDC__ || __cplusplus
        !          17334: _sfmode(reg Sfile_t* f, reg int wanted)
        !          17335: #else
        !          17336: _sfmode(f,wanted)
        !          17337: reg Sfile_t    *f;     /* change r/w mode and sync file pointer for this stream */
        !          17338: reg int                wanted; /* desired mode */
        !          17339: #endif
        !          17340: {
        !          17341:        reg int         n, rv;
        !          17342:        reg long        addr, (*seekf)_SFA_((Sfile_t*,long,int,char*));
        !          17343:        reg char        *handle;
        !          17344: 
        !          17345:        if(SFFROZEN(f))
        !          17346:                return -1;
        !          17347: 
        !          17348:        SFLOCK(f);
        !          17349:        rv = 0;
        !          17350: 
        !          17351:        if(f->mode&SF_POOL)
        !          17352:        {       /* move to head of pool */
        !          17353:                if(f != f->pool->head)
        !          17354:                {       if(SFFROZEN(f->pool->head))
        !          17355:                        {       SFOPEN(f);
        !          17356:                                return -1;
        !          17357:                        }
        !          17358:                        (*_Sfpmove)(f,0);
        !          17359:                }
        !          17360:                f->mode &= ~SF_POOL;
        !          17361:                if((n = f->mode&~SF_LOCK) != 0 && (wanted == 0 || n == wanted))
        !          17362:                        goto done;
        !          17363:        }
        !          17364: 
        !          17365:        seekf = f->disc ? f->disc->seekf : NIL(long(*)_SFA_((Sfile_t*,long,int,char*)));
        !          17366:        handle = f->disc ? f->disc->handle : NIL(char*);
        !          17367:        switch(f->mode&~SF_LOCK)
        !          17368:        {
        !          17369:        case 0: /* initializing an unitialized std-stream */
        !          17370:                SFopen(f); (void) sfnew(f,NIL(uchar*),-1,f->file,f->flags);
        !          17371:                goto done;
        !          17372: 
        !          17373:        case SF_WRITE: /* switching to SF_READ */
        !          17374:                if(!(f->flags&SF_READ))
        !          17375:                        rv = -1;
        !          17376:                else
        !          17377:                {       /* reset buffer */
        !          17378:                        SFopen(f);
        !          17379:                        if((rv = _sfflsbuf(f,-1)) < 0)
        !          17380:                                goto done;
        !          17381:                        SFLOCK(f);
        !          17382:                        if(f->flags&SF_APPEND)
        !          17383:                                f->here = SEEKF(seekf,f,0L,1,handle);
        !          17384:                        if(f->size == 0)
        !          17385:                        {       /* unbuffered */
        !          17386:                                f->data = f->tiny;
        !          17387:                                f->size = sizeof(f->tiny);
        !          17388:                        }
        !          17389:                        f->next = f->endr = f->endw = f->endb = f->data;
        !          17390:                        f->mode = SF_READ;
        !          17391:                        if(f->size > 1 && f->orig >= 0)
        !          17392:                                (void) sfseek(f,f->here-f->orig,0);
        !          17393:                }
        !          17394:                goto done;
        !          17395: 
        !          17396:        case SF_SYNC: /* a previously sync-ed read stream */
        !          17397:                if(wanted == SF_WRITE)
        !          17398:                {       /* can't do it */
        !          17399:                        if(!(f->flags&SF_WRITE))
        !          17400:                                rv = -1;
        !          17401:                        else    goto do_write;
        !          17402:                }
        !          17403:                else
        !          17404:                {       /* just reset the pointers */
        !          17405:                        f->mode = SF_READ|SF_LOCK;
        !          17406:                        addr = f->here + (f->endb - f->next);
        !          17407:                        if((addr = SEEKF(seekf,f,addr,0,handle)) < 0)
        !          17408:                                rv = -1;
        !          17409:                        else    f->here = addr;
        !          17410:                }
        !          17411:                goto done;
        !          17412: 
        !          17413:        case SF_READ: /* switching to SF_WRITE */
        !          17414:                if(!(f->flags&SF_WRITE))
        !          17415:                {       rv = -1;
        !          17416:                        goto done;
        !          17417:                }
        !          17418: 
        !          17419:                if((n = f->endb-f->data) > 0)
        !          17420:                {       /* reset file pointer */
        !          17421:                        addr = f->here - n;
        !          17422:                        if((addr = SEEKF(seekf,f,addr,0,handle)) < 0)
        !          17423:                        {       rv = -1;
        !          17424:                                goto done;
        !          17425:                        }
        !          17426:                        else    f->here = addr;
        !          17427:                }
        !          17428:        do_write:
        !          17429:                if(f->data == f->tiny)
        !          17430:                {
        !          17431:                        f->endb = f->data = f->next = NIL(uchar*);
        !          17432:                        f->size = 0;
        !          17433:                }
        !          17434:                else    f->endb = f->data + f->size;
        !          17435:                f->mode = SF_WRITE;
        !          17436:                goto done;
        !          17437:        }
        !          17438: done :
        !          17439:        SFopen(f);
        !          17440:        sfset(f,f->flags,1);
        !          17441:        return rv;
        !          17442: }
        !          17443: 0707070000000002561006440044230044230000010000000475416165400003100000010230sfio/sfmove.cUgsfGgsf#include  "sfhdr.h"
        !          17444: 
        !          17445: #if sparc
        !          17446: #include       <sys/mman.h>
        !          17447: #define MAPSIZE        (256*1024)
        !          17448: #endif
        !          17449: 
        !          17450: /*     Move data from one stream to another.
        !          17451: **     This code is written so that it'll work even in the presence
        !          17452: **     of stacking streams, pool, and discipline.
        !          17453: **     If you must change it, be gentle.
        !          17454: **
        !          17455: **     Written by Kiem-Phong Vo (12/07/90)
        !          17456: */
        !          17457: 
        !          17458: #if __STDC__ || __cplusplus
        !          17459: sfmove(Sfile_t* fr, Sfile_t* fw, reg long n, const char* rs)
        !          17460: #else
        !          17461: sfmove(fr,fw,n,rs)
        !          17462: Sfile_t                *fr;    /* moving data from this stream */
        !          17463: Sfile_t                *fw;    /* moving data to this stream */
        !          17464: reg long       n;      /* number of bytes/records to move. <0 for unbounded move */
        !          17465: reg char       *rs;    /* record separators */
        !          17466: #endif
        !          17467: {
        !          17468:        reg uchar       *cp, *next;
        !          17469:        reg int         r, w, rc;
        !          17470:        reg int         direct;
        !          17471:        reg long        n_move;
        !          17472:        uchar           rbuf[SF_GRAIN];
        !          17473:        char            rsv[(uchar)(~0)];
        !          17474: #if sparc
        !          17475:        caddr_t         mbuf = (caddr_t)(-1);
        !          17476:        off_t           msize = 0;
        !          17477: #endif
        !          17478: 
        !          17479:        if(!fr)
        !          17480:                return 0;
        !          17481: 
        !          17482:        if(rs)
        !          17483:        {       /* set up the mapping to determine which byte is a separator */
        !          17484:                if(*rs)
        !          17485:                {       memclear(rsv,sizeof(rsv));
        !          17486:                        if(rs[0] == '\\' && rs[1] == '0')
        !          17487:                        {       /* coding of the zero byte */
        !          17488:                                rsv[rc = 0] = 1;
        !          17489:                                rs += 2;
        !          17490:                        }
        !          17491:                        else    rc = (uchar)(*rs);
        !          17492: 
        !          17493:                        /* coding of the rest of the bytes */
        !          17494:                        while(r = (uchar)(*rs++))
        !          17495:                                rsv[r] = 1;
        !          17496:                        rs = rsv;
        !          17497:                }
        !          17498:                else    rs = NIL(char*);
        !          17499:        }
        !          17500: 
        !          17501:        for(n_move = 0; n != 0; )
        !          17502:        {       /* get the input stream into the right mode */
        !          17503:                if(fr->mode != SF_READ && SFMODE(fr,SF_READ) < 0)
        !          17504:                        break;
        !          17505: 
        !          17506:                /* try reading a block of data */
        !          17507:                direct = 0;
        !          17508:                if((r = fr->endb - (next = fr->next)) <= 0)
        !          17509:                {       /* sffilbuf handles stack and discipline */
        !          17510:                        if(fr->disc || fr->push)
        !          17511:                        {       (void)_sffilbuf(fr,-1);
        !          17512:                                if((r = fr->endb - (next = fr->next)) <= 0)
        !          17513:                                        break;
        !          17514:                        }
        !          17515:                        /* no more data */
        !          17516:                        else if(fr->flags&SF_STRING)
        !          17517:                                break;
        !          17518:                        /* try direct read */
        !          17519:                        else
        !          17520:                        {       
        !          17521: #if sparc                      /* try memory mapping for fast read */
        !          17522:                                struct stat     st;
        !          17523: 
        !          17524:                                if(mbuf != (caddr_t)(-1))
        !          17525:                                {       /* release previous mapped space */
        !          17526:                                        munmap(mbuf,msize);
        !          17527:                                        mbuf = (caddr_t)(-1);
        !          17528:                                }
        !          17529: 
        !          17530:                                if(fr->orig >= 0 && (n < 0 || n >= SF_BUFSIZE) &&
        !          17531:                                   fstat(fr->file,&st) >= 0 &&
        !          17532:                                   (st.st_mode&S_IFMT) == S_IFREG)
        !          17533:                                {       if((msize = st.st_size - fr->here) > MAPSIZE)
        !          17534:                                                msize = MAPSIZE;
        !          17535:                                        if(msize > n && n > 0)
        !          17536:                                                msize = n;
        !          17537:                                        mbuf = mmap(NIL(caddr_t),msize,PROT_READ,
        !          17538:                                                    MAP_SHARED,fr->file,fr->here);
        !          17539:                                        if(mbuf != (caddr_t)(-1))
        !          17540:                                        {       /* advance read pointer */
        !          17541:                                                (void)lseek(fr->file,msize,1);
        !          17542:                                                next = (uchar*)mbuf;
        !          17543:                                                r = msize;
        !          17544:                                                goto r_done;
        !          17545:                                        }
        !          17546:                                }
        !          17547: #endif
        !          17548:                                /* get a decent size buffer to work with */
        !          17549:                                if((w = fr->size) >= sizeof(rbuf))
        !          17550:                                        next = fr->data;
        !          17551:                                else
        !          17552:                                {       next = rbuf;
        !          17553:                                        w = sizeof(rbuf);
        !          17554:                                }
        !          17555: 
        !          17556:                                if(!rs && n > 0 && n < w)
        !          17557:                                        w = (int)n;
        !          17558:                                while((r = read(fr->file,next,w)) < 0 && errno == EINTR)
        !          17559:                                        errno = 0;
        !          17560:                                if(r <= 0)
        !          17561:                                        break;
        !          17562: 
        !          17563:                                /* for future sfseek's correctness */
        !          17564:                        r_done:
        !          17565:                                fr->next = fr->endb = fr->endr = fr->data;
        !          17566:                                direct = 1;
        !          17567:                        }
        !          17568:                }
        !          17569: 
        !          17570:                if(!rs)
        !          17571:                {       if(n > 0)
        !          17572:                        {       if(n < r)
        !          17573:                                        r = (int)n;
        !          17574:                                n -= r;
        !          17575:                        }
        !          17576:                        n_move += r;
        !          17577:                }
        !          17578:                else
        !          17579:                {       /* count lines */
        !          17580:                        reg uchar       *endb = next+r;
        !          17581:                        reg int         string = (fr->flags&SF_STRING);
        !          17582: 
        !          17583:                        if(!direct)
        !          17584:                                SFlock(fr);
        !          17585:                        if(!string)
        !          17586:                        {       w = endb[-1];
        !          17587:                                endb[-1] = rc;
        !          17588:                        }
        !          17589:                        else    w = 0;
        !          17590:                        for(cp = next; cp < endb; )
        !          17591:                        {       /* find the line extent */
        !          17592:                                if(string)
        !          17593:                                        while(cp < endb && !rs[*cp++])
        !          17594:                                                ;
        !          17595:                                else    while(!rs[*cp++])
        !          17596:                                                ;
        !          17597:                                if(cp < endb || w == rc)
        !          17598:                                {       n_move += 1;
        !          17599:                                        if(n > 0 && (n -= 1) == 0)
        !          17600:                                                break;
        !          17601:                                }
        !          17602:                        }
        !          17603:                        if(!string)
        !          17604:                                endb[-1] = w;
        !          17605:                        r = cp-next;
        !          17606:                        if(!direct)
        !          17607:                                SFopen(fr);
        !          17608:                        else if(cp < endb)
        !          17609:                                (void) lseek(fr->file,(long)(cp-endb),1);
        !          17610:                }
        !          17611: 
        !          17612:                /* advance read pointer */
        !          17613:                if(direct)
        !          17614:                        fr->here += r;
        !          17615:                else    fr->next += r;
        !          17616: 
        !          17617:                /* write out data */
        !          17618:                if(fw)
        !          17619:                {       if(fw->mode != SF_WRITE && SFMODE(fw,SF_WRITE) < 0)
        !          17620:                                goto w_error;
        !          17621:                        if((fw->endb - (cp = fw->next)) > r)
        !          17622:                        {       SFlock(fw);
        !          17623:                                MEMCPY(cp,next,r);
        !          17624:                                fw->next = cp;
        !          17625:                                SFopen(fw);
        !          17626:                        }
        !          17627:                        else if((w = sfwrite(fw,next,r)) != r)
        !          17628:                        {       /* write error */
        !          17629:                                if(w > 0)
        !          17630:                                {       r -= w;
        !          17631:                                        if(!rs)
        !          17632:                                                n_move -= r;
        !          17633:                                }
        !          17634:                        w_error :
        !          17635:                                (void) sfseek(fr,(long)(-r),1);
        !          17636:                                break;
        !          17637:                        }
        !          17638:                }
        !          17639:        }
        !          17640: 
        !          17641: #if sparc
        !          17642:        if(mbuf != (caddr_t)(-1))
        !          17643:                munmap(mbuf,msize);
        !          17644: #endif
        !          17645: 
        !          17646:        return n_move;
        !          17647: }
        !          17648: 0707070000000002571006440044230044230000010000000475416406200003000000006536sfio/sfnew.cUgsfGgsf#include   "sfhdr.h"
        !          17649: 
        !          17650: /*     Fundamental function to create a new stream.
        !          17651: **     The argument flags defines the type of stream and the scheme
        !          17652: **     of buffering.
        !          17653: **
        !          17654: **     Written by Kiem-Phong Vo (06/27/90)
        !          17655: */
        !          17656: 
        !          17657: /* to be done on exit */
        !          17658: static int     _Cleanup = 0;
        !          17659: static void _cleanup()
        !          17660: {      /* sync all streams */
        !          17661:        if(_Cleanup >= 0)
        !          17662:        {       _Cleanup = -1;
        !          17663:                sfsync(NIL(Sfile_t*));
        !          17664:        }
        !          17665: }
        !          17666: 
        !          17667: #if __STDC__ || __cplusplus
        !          17668: Sfile_t *sfnew(Sfile_t* oldf, uchar* buf, int size, int file, int flags)
        !          17669: #else
        !          17670: Sfile_t *sfnew(oldf,buf,size,file,flags)
        !          17671: Sfile_t        *oldf;  /* old stream to be reused */
        !          17672: uchar  *buf;   /* a buffer to read/write, if NULL, will be allocated */
        !          17673: int    size;   /* buffer size if buf is given or desired buffer size */
        !          17674: int    file;   /* file descriptor to read/write from */
        !          17675: int    flags;  /* type of file stream */
        !          17676: #endif
        !          17677: {
        !          17678:        reg Sfile_t     *f;
        !          17679:        reg long        (*seekf)_SFA_((Sfile_t*,long,int,char*));
        !          17680:        reg char        *handle;
        !          17681: 
        !          17682:        if(!_Cleanup)
        !          17683:        {       _Cleanup = 1;
        !          17684:                (void)atexit(_cleanup);
        !          17685:        }
        !          17686: 
        !          17687:        if((oldf && SFFROZEN(oldf)) || (!oldf && !(flags&SF_RDWR)))
        !          17688:                return NIL(Sfile_t*);
        !          17689: 
        !          17690:        /* make a stream structure */
        !          17691:        if(oldf)
        !          17692:        {       f = oldf;
        !          17693:                if(flags&SF_REUSE)
        !          17694:                        flags = f->flags;
        !          17695:                if((f->mode&SF_STRING) && f->data && (f->flags&SF_MALLOC))
        !          17696:                {       free((char*)f->data);
        !          17697:                        f->data = f->endb = f->next = NIL(uchar*);
        !          17698:                        f->size = 0;
        !          17699:                }
        !          17700:        }
        !          17701:        else
        !          17702:        {       if(file >= 0 && file <= 2 && !(flags&SF_STRING))
        !          17703:                {       /* reuse a sfstd-stream if possible */
        !          17704:                        f = file == 0 ? sfstdin : file == 1 ? sfstdout : sfstderr;
        !          17705:                        if(f->file >= 0 ||
        !          17706:                           (f == sfstdin && (flags&SF_RDWR) != SF_READ) ||
        !          17707:                           (f != sfstdin && (flags&SF_RDWR) != SF_WRITE))
        !          17708:                                f = NIL(Sfile_t*);
        !          17709:                }
        !          17710:                else    f = NIL(Sfile_t*);
        !          17711: 
        !          17712:                if(!f && !SFALLOC(f))
        !          17713:                        return NIL(Sfile_t*);
        !          17714:                SFCLEAR(f);
        !          17715:        }
        !          17716: 
        !          17717:        /* stream type */
        !          17718:        f->mode = (flags&SF_STRING) ? SF_STRING :
        !          17719:                  ((flags&SF_WRITE) && oldf && (oldf->mode&SF_WRITE)) ? SF_WRITE :
        !          17720:                  (flags&SF_READ) ? SF_READ : SF_WRITE;
        !          17721:        f->flags = (flags&SF_FLAGS)&~SF_REUSE;
        !          17722:        if((f->flags&SF_RDWR) == SF_RDWR)
        !          17723:                f->flags |= SF_BOTH;
        !          17724: 
        !          17725:        if(f->mode&SF_STRING)
        !          17726:        {       /* note that f->here is set in sfsetbuf() */
        !          17727:                f->file = -1;
        !          17728:                f->orig = 0L;
        !          17729:        }
        !          17730:        else
        !          17731:        {       SFLOCK(f);
        !          17732:                f->file = file;
        !          17733:                f->orig = 0L;
        !          17734: 
        !          17735:                if((f == sfstdin || f == sfstdout || f == sfstderr) &&
        !          17736:                   !f->data && isatty(file))
        !          17737:                {       /* this stream is not seekable */
        !          17738:                        f->orig = -1L;
        !          17739:                        if(f != sfstdin)
        !          17740:                                f->flags |= SF_LINE;
        !          17741:                }
        !          17742: 
        !          17743:                if(f->orig == 0L)
        !          17744:                {       /* set seek location */
        !          17745:                        seekf = (oldf && oldf->disc) ? oldf->disc->seekf :
        !          17746:                                        NIL(long(*)_SFA_((Sfile_t*,long,int,char*)));
        !          17747:                        handle = (oldf && oldf->disc) ? oldf->disc->handle : NIL(char*);
        !          17748:                        f->orig = SEEKF(seekf,f,0L,(flags&SF_APPEND) ? 2 : 1,handle);
        !          17749:                        if(f->orig > 0 && !(flags&SF_RELATIVE))
        !          17750:                                f->orig = 0L;
        !          17751:                }
        !          17752:                f->here = f->orig > 0L ? f->orig : 0L;
        !          17753: 
        !          17754:                if(!f->data && !buf && size < 0)
        !          17755:                {       /* special cases for stream buffer size */
        !          17756:                        if(f == sfstderr)
        !          17757:                                size = 0;
        !          17758:                        else if(f->orig < 0L && (f->mode&SF_WRITE) && (f->flags&SF_LINE))
        !          17759:                                size = SF_GRAIN;
        !          17760:                        else    size = SF_BUFSIZE;
        !          17761:                }
        !          17762:        }
        !          17763: 
        !          17764:        /* set buffer pointers */
        !          17765:        SFOPEN(f);
        !          17766:        sfset(f,f->flags,1);
        !          17767:        if(!(flags&SF_STRING) && oldf && size < 0)
        !          17768:        {       buf = f->data;
        !          17769:                size = f->size;
        !          17770:                f->data = f->next = f->endr = f->endw = f->endb = NIL(uchar*);
        !          17771:                f->size = 0;
        !          17772:        }
        !          17773:        sfsetbuf(f,buf,size);
        !          17774: 
        !          17775:        if(!oldf)
        !          17776:        {       /* link to the list of active streams */
        !          17777:                f->pool = &_Sfpool;
        !          17778:                f->fore = _Sfpool.head;
        !          17779:                if(_Sfpool.head)
        !          17780:                        _Sfpool.head->back = f;
        !          17781:                _Sfpool.head = f;
        !          17782:        }
        !          17783: 
        !          17784:        if(_Sfnotify)
        !          17785:                (*_Sfnotify)(f,0);
        !          17786: 
        !          17787:        return f;
        !          17788: }
        !          17789: 0707070000000002601006440044230044230000010000000475416404000003300000000422sfio/sfnotify.cUgsfGgsf#include        "sfhdr.h"
        !          17790: 
        !          17791: 
        !          17792: /*     Set the function to be called when a stream is opened or closed
        !          17793: **
        !          17794: **     Written by Kiem-Phong Vo (01/06/91)
        !          17795: */
        !          17796: #if __STDC__ || __cplusplus
        !          17797: sfnotify(void (*notify)(Sfile_t*, int))
        !          17798: #else
        !          17799: sfnotify(notify)
        !          17800: void   (*notify)();
        !          17801: #endif
        !          17802: {
        !          17803:        _Sfnotify = notify;
        !          17804: }
        !          17805: 0707070000000002611006440044230044230000010000000472663404400003200000001657sfio/sfnputc.cUgsfGgsf#include "sfhdr.h"
        !          17806: 
        !          17807: /*     Write out a character n times
        !          17808: **
        !          17809: **     Written by Kiem-Phong Vo (06/27/90)
        !          17810: */
        !          17811: 
        !          17812: #if __STDC__ || __cplusplus
        !          17813: sfnputc(reg Sfile_t* f, reg uchar c, reg int n)
        !          17814: #else
        !          17815: sfnputc(f,c,n)
        !          17816: reg Sfile_t    *f;     /* file to write */
        !          17817: reg uchar      c;      /* char to be written */
        !          17818: reg int                n;      /* number of time to repeat */
        !          17819: #endif
        !          17820: {
        !          17821:        reg uchar       *ps;
        !          17822:        reg int         p, w;
        !          17823:        uchar           buf[128];
        !          17824: 
        !          17825:        if(f->mode != SF_WRITE && SFMODE(f,SF_WRITE) < 0)
        !          17826:                return -1;
        !          17827: 
        !          17828:        SFLOCK(f);
        !          17829: 
        !          17830:        /* write into a suitable buffer */
        !          17831:        if((p = (f->endb-(ps = f->next))) < n)
        !          17832:                { ps = buf; p = sizeof(buf); }
        !          17833:        if(p > n)
        !          17834:                p = n;
        !          17835:        MEMSET(ps,c,p);
        !          17836:        ps -= p;
        !          17837: 
        !          17838:        w = n;
        !          17839:        if(ps == f->next)
        !          17840:        {       /* simple sfwrite */
        !          17841:                f->next += p;
        !          17842:                if(c == '\n')
        !          17843:                        { SFopen(f); _sfflsbuf(f,-1); }
        !          17844:                goto done;
        !          17845:        }
        !          17846: 
        !          17847:        for(;;)
        !          17848:        {       /* hard write of data */
        !          17849:                SFopen(f);
        !          17850:                if((p = sfwrite(f,ps,p)) <= 0 || (n -= p) <= 0)
        !          17851:                {       w -= n;
        !          17852:                        goto done;
        !          17853:                }
        !          17854:                SFLOCK(f);
        !          17855:                if(p > n)
        !          17856:                        p = n;
        !          17857:        }
        !          17858: done :
        !          17859:        SFOPEN(f);
        !          17860:        return w;
        !          17861: }
        !          17862: 0707070000000002621006440044230044230000010000000474736437700003100000004455sfio/sfopen.cUgsfGgsf#include  "sfhdr.h"
        !          17863: 
        !          17864: /*     Open a file/string for IO.
        !          17865: **     If f is not nil, it is taken as an existing stream that should be
        !          17866: **     closed and its structure reused for the new stream.
        !          17867: **
        !          17868: **     Written by Kiem-Phong Vo (06/27/90)
        !          17869: */
        !          17870: 
        !          17871: #if __STDC__ || __cplusplus
        !          17872: Sfile_t *sfopen(reg Sfile_t* f, const char* file, const char* mode)
        !          17873: #else
        !          17874: Sfile_t *sfopen(f,file,mode)
        !          17875: reg Sfile_t    *f;             /* old stream structure */
        !          17876: char           *file;          /* file/string to be opened */
        !          17877: reg char       *mode;          /* mode of the stream */
        !          17878: #endif
        !          17879: {
        !          17880:        reg int         fd, oflags, sflags, oldfd;
        !          17881: 
        !          17882:        if((f && SFFROZEN(f)) || !file || !mode)
        !          17883:                return NIL(Sfile_t*);
        !          17884:        oldfd = -1;
        !          17885: 
        !          17886:        if(f)
        !          17887:        {       /* reuse the space of this stream */
        !          17888:                f->flags |= SF_REUSE;
        !          17889:                f->flags &= ~SF_KEEPFD; /* force closing of f->file */
        !          17890:                oldfd = f->file;
        !          17891:                (void) sfclose(f);
        !          17892:        }
        !          17893: 
        !          17894:        /* construct the open flags */
        !          17895:        sflags = 0;
        !          17896:        while(1) switch(*mode++)
        !          17897:        {
        !          17898:        case 'w' :
        !          17899:                oflags = O_WRONLY | O_TRUNC | O_CREAT;
        !          17900:                sflags = SF_WRITE;
        !          17901:                break;
        !          17902:        case 'a' :
        !          17903:                oflags = O_WRONLY | O_APPEND | O_CREAT;
        !          17904:                sflags = SF_WRITE | SF_APPEND;
        !          17905:                break;
        !          17906:        case 'r' :
        !          17907:                oflags = O_RDONLY;
        !          17908:                sflags = SF_READ;
        !          17909:                break;
        !          17910:        case '+' :
        !          17911:                oflags = (oflags & ~(O_RDONLY|O_WRONLY))|O_RDWR;
        !          17912:                sflags |= SF_READ|SF_WRITE;
        !          17913:                break;
        !          17914:        case 's' :
        !          17915:                sflags = SF_STRING|SF_READ;
        !          17916:                break;
        !          17917:        case 'b' :
        !          17918:                break;
        !          17919:        case  0  :
        !          17920:                goto e_mode;
        !          17921:        default :
        !          17922:                return NIL(Sfile_t*);
        !          17923:        }
        !          17924: e_mode :;
        !          17925: 
        !          17926:        if(sflags&SF_STRING)
        !          17927:                return sfnew(f,(uchar*)file,strlen(file),-1,sflags);
        !          17928:        else if(!sflags || !file[0])
        !          17929:                return NIL(Sfile_t*);
        !          17930: 
        !          17931:        /* open the file */
        !          17932: #ifndef NO_OFLAGS
        !          17933:        fd = open((char*)file,oflags,0666);
        !          17934: #else
        !          17935:        if((fd = open(file,oflags&03)) < 0 &&
        !          17936:           (oflags&O_CREAT) && (fd = creat(file,0666)) >= 0 && !(oflags&O_WRONLY))
        !          17937:        {       /* the file now exists, reopen it for read/write */
        !          17938:                (void) close(fd);
        !          17939:                fd = open(file,oflags&03);
        !          17940:        }
        !          17941:        else if(fd >= 0)
        !          17942:        {       /* truncate file */
        !          17943:                if(oflags&O_TRUNC)
        !          17944:                {       reg int tf = creat(file,0666);
        !          17945:                        (void)close(tf);
        !          17946:                }
        !          17947: 
        !          17948:                /* make sure file pointer is at the top */
        !          17949:                if((oflags&O_RDWR) && !(oflags&O_APPEND))
        !          17950:                        (void)lseek(fd,0L,0);
        !          17951:        }
        !          17952: #endif
        !          17953:        if(fd < 0)
        !          17954:                return NIL(Sfile_t*);
        !          17955: 
        !          17956:        if(oldfd >= 0 && fd != oldfd && (oldfd = dup(fd)) >= 0)
        !          17957:        {       /* freopen desires fd == oldfd */
        !          17958:                (void) close(fd);
        !          17959:                fd = oldfd;
        !          17960:        }
        !          17961: 
        !          17962:        if(!(f = sfnew(f,NIL(uchar*),-1,fd,sflags)) )
        !          17963:                (void) close(fd);
        !          17964:        else if(mode[0] != 'r' && f->mode != SF_WRITE)
        !          17965:                _sfmode(f,SF_WRITE);
        !          17966: 
        !          17967:        return f;
        !          17968: }
        !          17969: 0707070000000002631006440044230044230000010000000474736457400003100000004673sfio/sfpeek.cUgsfGgsf#include  "sfhdr.h"
        !          17970: 
        !          17971: /*     Return the portion of the internal stream buffer available
        !          17972: **     for reading/writing. If a stream is SF_READ and the buffer is
        !          17973: **     empty, it will be filled. If a stream is SF_WRITE and the buffer
        !          17974: **     full, it will be flushed.
        !          17975: **     A peek on a SF_READ stream that is line buffered will return the
        !          17976: **     portion of data up to \n.
        !          17977: **     Note also that this function does not advance the buffer pointer.
        !          17978: **     That must be done by an appropriate sfread or sfwrite call.
        !          17979: **
        !          17980: **     Written by Kiem-Phong Vo (06/27/90).
        !          17981: */
        !          17982: 
        !          17983: #if __STDC__ || __cplusplus
        !          17984: _sfpeek(reg Sfile_t* f, uchar** bp)
        !          17985: #else
        !          17986: _sfpeek(f,bp)
        !          17987: reg Sfile_t    *f;     /* file to peek */
        !          17988: uchar          **bp;   /* start of data area */
        !          17989: #endif
        !          17990: {
        !          17991:        reg int         n;
        !          17992:        reg uchar       *s, *ends;
        !          17993:        reg int         c, o, a;
        !          17994: 
        !          17995:        /* for consistency the desired mode for a RDWR stream is always READ */
        !          17996:        n = (f->flags&SF_RDWR) == SF_RDWR ? SF_READ : (f->mode&SF_RDWR);
        !          17997:        if(f->mode != n && SFMODE(f,n) < 0)
        !          17998:                return -1;
        !          17999: 
        !          18000:        SFLOCK(f);
        !          18001:        if((f->flags&(SF_RDWR|SF_STRING)) == (SF_RDWR|SF_STRING))
        !          18002:        {       /* a read/write string stream, update current end */
        !          18003:                if((o = f->next-f->data) > f->here && o != f->orig)
        !          18004:                        f->here = f->orig = o;
        !          18005:                n = (f->data+f->here)-f->next;
        !          18006:                if(!bp)
        !          18007:                        goto done;
        !          18008:        }
        !          18009:        else if((n = f->endb - f->next) == 0)
        !          18010:        {       SFopen(f);
        !          18011:                if(f->flags&SF_READ)
        !          18012:                        _sffilbuf(f,-1);
        !          18013:                else    _sfflsbuf(f,-1);
        !          18014:                SFLOCK(f);
        !          18015:                n = f->endb - f->next;
        !          18016:        }
        !          18017: 
        !          18018:        if(n <= 0 || (f->mode&SF_WRITE) || !(f->flags&SF_READ) || !(f->flags&SF_LINE))
        !          18019:        {       /* normal business */
        !          18020:                *bp = f->next;
        !          18021:                goto done;
        !          18022:        }
        !          18023: 
        !          18024:        /* in line-buffering read mode, find \n */
        !          18025:        n = (ends = f->endb) - (s = f->next);
        !          18026:        if((f->flags&SF_STRING) && !(f->flags&SF_WRITE))
        !          18027:        {       /* must do this slowly */
        !          18028:                while(s < ends && *s++ != '\n')
        !          18029:                        ;
        !          18030:                c = s[-1];
        !          18031:        }
        !          18032:        else
        !          18033:        {       /* fast loop */
        !          18034:                c = ends[-1]; ends[-1] = '\n';
        !          18035:                while(*s++ != '\n')
        !          18036:                        ;
        !          18037:                ends[-1] = c;
        !          18038:        }
        !          18039: 
        !          18040:        /* we are done */
        !          18041:        if(s < ends || c == '\n' || (f->flags&SF_STRING))
        !          18042:        {       n = s - (*bp = f->next);
        !          18043:                goto done;
        !          18044:        }
        !          18045: 
        !          18046:        /* must read more, try to align data by moving it back */
        !          18047:        if((f->mode&SF_READ) && (o = f->next - f->data) > 0)
        !          18048:        {       /* shift left data, make sure alignment is correct */
        !          18049:                a = f->size >= (2*SF_GRAIN) ? SF_GRAIN :
        !          18050:                        ((f->size/2)/sizeof(void*)+1)*sizeof(void*);
        !          18051:                if((c = (n/a + 1)*a - n) > o)
        !          18052:                {       n = ends - (*bp = f->next);
        !          18053:                        goto done;
        !          18054:                }
        !          18055:                else if(c < o)
        !          18056:                {       /* copy data */
        !          18057:                        ends = f->next;
        !          18058:                        f->next = s = f->data+c;
        !          18059:                        f->endb = s+n;
        !          18060:                        MEMCPY(s,ends,n);
        !          18061:                }
        !          18062:        }
        !          18063: 
        !          18064:        SFopen(f);
        !          18065:        n = _sffilbuf(f,0);
        !          18066:        *bp = f->next;
        !          18067: 
        !          18068: done:
        !          18069:        SFOPEN(f);
        !          18070:        return n;
        !          18071: }
        !          18072: 0707070000000002641006440044230044230000010000000475414060400003100000007016sfio/sfpool.cUgsfGgsf#include  "sfhdr.h"
        !          18073: 
        !          18074: /*     Management of pools of streams.
        !          18075: **     If pf is not nil, f is pooled with pf and f becomes current;
        !          18076: **     otherwise, f is isolated from its pool. flag can be any of:
        !          18077: **     0, SF_READ, SF_WRITE or SF_READ|SFWRITE to indicate the type
        !          18078: **     of stream that gets synced when a stream becomes non-current.
        !          18079: **     If flag is 0, the pool type is unchanged.
        !          18080: **
        !          18081: **     Written by Kiem-Phong Vo (6/27/90).
        !          18082: */
        !          18083: 
        !          18084: static Sfpool_t                *Pfree; /* list of free pools */
        !          18085: 
        !          18086: #if __STDC__ || __cplusplus
        !          18087: static void delpool(reg Sfpool_t* p)
        !          18088: #else
        !          18089: static delpool(p)
        !          18090: reg Sfpool_t   *p;
        !          18091: #endif
        !          18092: {
        !          18093:        if(p == &_Sfpool)
        !          18094:                return;
        !          18095:        if(p->fore)
        !          18096:                p->fore->back = p->back;
        !          18097:        if(p->back)
        !          18098:                p->back->fore = p->fore;
        !          18099:        p->fore = Pfree;
        !          18100:        Pfree = p;
        !          18101: }
        !          18102: 
        !          18103: #if __STDC__ || __cplusplus
        !          18104: static Sfpool_t *newpool(reg int mode)
        !          18105: #else
        !          18106: static Sfpool_t *newpool(mode)
        !          18107: reg int        mode;
        !          18108: #endif
        !          18109: {
        !          18110:        reg Sfpool_t    *p;
        !          18111: 
        !          18112:        if(Pfree)
        !          18113:        {       /* from the free list */
        !          18114:                p = Pfree;
        !          18115:                Pfree = p->fore;
        !          18116:        }
        !          18117:        else    p = (Sfpool_t*) malloc(sizeof(Sfpool_t));
        !          18118: 
        !          18119:        p->mode = mode;
        !          18120:        p->head = NIL(Sfile_t*);
        !          18121: 
        !          18122:        /* insert into chain of pools */
        !          18123:        if((p->fore = _Sfpool.fore) != NIL(Sfpool_t*))
        !          18124:                p->fore->back = p;
        !          18125:        p->back = &_Sfpool;
        !          18126:        _Sfpool.fore = p;
        !          18127:        return p;
        !          18128: }
        !          18129: 
        !          18130: #if __STDC__ || __cplusplus
        !          18131: static sfpmove(reg Sfile_t* f, reg int type)
        !          18132: #else
        !          18133: static sfpmove(f,type)
        !          18134: reg Sfile_t    *f;
        !          18135: reg int                type;   /* <0 : deleting, 0: move-to-front, >0: inserting */
        !          18136: #endif
        !          18137: {
        !          18138:        reg Sfpool_t    *p;
        !          18139:        reg Sfile_t     *head;
        !          18140: 
        !          18141:        SFLOCK(f);
        !          18142:        p = f->pool;
        !          18143:        if(type < 0)
        !          18144:        {       /* deleting from pool */
        !          18145:                if(f->fore)
        !          18146:                        f->fore->back = f->back;
        !          18147:                if(f->back)
        !          18148:                        f->back->fore = f->fore;
        !          18149:                else    p->head = f->fore;
        !          18150:                f->pool = NIL(Sfpool_t*);
        !          18151: 
        !          18152:                if(p != &_Sfpool)
        !          18153:                {       if(!(head = p->head))
        !          18154:                                delpool(p);
        !          18155:                        else if(!head->fore)
        !          18156:                        {       /* remove the last one */
        !          18157:                                sfpmove(head,-1);
        !          18158:                                head->pool = &_Sfpool;
        !          18159:                                sfpmove(head,1);
        !          18160:                        }
        !          18161:                }
        !          18162:        }
        !          18163:        else if(type > 0)
        !          18164:        {       /* insertion */
        !          18165:                if((head = p->head) != NIL(Sfile_t*))
        !          18166:                {       /* right after current head */
        !          18167:                        if((f->fore = head->fore) != NIL(Sfile_t*))
        !          18168:                                f->fore->back = f;
        !          18169:                        f->back = head;
        !          18170:                        head->fore = f;
        !          18171:                        f->mode |= SF_POOL;
        !          18172:                        SFopen(f);
        !          18173:                        sfset(f,f->flags,1);
        !          18174:                }
        !          18175:                else    
        !          18176:                {       f->fore = f->back = NIL(Sfile_t*);
        !          18177:                        p->head = f;
        !          18178:                }
        !          18179:        }
        !          18180:        else if(p != &_Sfpool && (head = p->head) && head != f && !SFFROZEN(head))
        !          18181:        {       /* syn head stream before moving it */
        !          18182:                if(head->mode&p->mode)
        !          18183:                        sfsync(head);
        !          18184:                head->mode |= SF_POOL;
        !          18185:                sfset(head,head->flags,1);
        !          18186: 
        !          18187:                if(f->fore)
        !          18188:                        f->fore->back = f->back;
        !          18189:                f->back->fore = f->fore;
        !          18190:                f->back = NIL(Sfile_t*);
        !          18191:                f->fore = head;
        !          18192:                head->back = f;
        !          18193:                p->head = f;
        !          18194:                f->mode &= ~SF_POOL;
        !          18195:        }
        !          18196: 
        !          18197:        SFOPEN(f);
        !          18198:        return 0;
        !          18199: }
        !          18200: 
        !          18201: #if __STDC__ || __cplusplus
        !          18202: sfpool(reg Sfile_t* f, reg Sfile_t* pf, reg int mode)
        !          18203: #else
        !          18204: sfpool(f,pf,mode)
        !          18205: reg Sfile_t    *f;
        !          18206: reg Sfile_t    *pf;
        !          18207: reg int                mode;
        !          18208: #endif
        !          18209: {
        !          18210:        reg Sfpool_t    *p;
        !          18211: 
        !          18212:        /* function to move a stream in a pool */
        !          18213:        _Sfpmove = sfpmove;
        !          18214: 
        !          18215:        if(!f || f == pf ||                     /* nothing to do */
        !          18216:           (!pf && f->pool == &_Sfpool) ||      /* already isolated */
        !          18217:                                                /* new pool but type is unknown */
        !          18218:           (pf && pf->pool == &_Sfpool && (mode&SF_RDWR) == 0))
        !          18219:                return -1;
        !          18220: 
        !          18221:        if(SFFROZEN(f) || (!f->mode && _sfmode(f,0) < 0))
        !          18222:                return -1;
        !          18223:        if(pf && (SFFROZEN(pf) || (!pf->mode && _sfmode(pf,0) < 0)))
        !          18224:                return -1;
        !          18225: 
        !          18226:        /* isolate it from current pool */
        !          18227:        p = f->pool;
        !          18228:        sfpmove(f,-1);
        !          18229: 
        !          18230:        if(!pf)
        !          18231:        {       /* add to the discrete pool */  
        !          18232:                f->pool = &_Sfpool;
        !          18233:                sfpmove(f,1);
        !          18234:                return 0;
        !          18235:        }
        !          18236: 
        !          18237:        if((p = pf->pool) == &_Sfpool)
        !          18238:        {       /* making a new pool */
        !          18239:                sfpmove(pf,-1);
        !          18240:                p = newpool(mode&SF_RDWR);
        !          18241:                pf->pool = p;
        !          18242:                sfpmove(pf,1);
        !          18243:        }
        !          18244: 
        !          18245:        if(f->pool != p)
        !          18246:        {       /* insert f into the pool */
        !          18247:                f->pool = p;
        !          18248:                sfpmove(f,1);
        !          18249:        }
        !          18250: 
        !          18251:        return 0;
        !          18252: }
        !          18253: 0707070000000002651006440044230044230000010000000474661552600003200000007510sfio/sfpopen.cUgsfGgsf#include "sfhdr.h"
        !          18254: 
        !          18255: /* fork function to use */
        !          18256: #ifdef LIBX
        !          18257: #include       "FEATURE/vfork"
        !          18258: #else
        !          18259: #ifdef BSD
        !          18260: #define                _lib_vfork
        !          18261: #endif
        !          18262: #ifdef sparc
        !          18263: #define                _hdr_vfork
        !          18264: #endif
        !          18265: #endif /*LIBX*/
        !          18266: 
        !          18267: #ifdef _lib_vfork
        !          18268: #define fork   vfork
        !          18269: #ifdef _hdr_vfork
        !          18270: #include       <vfork.h>
        !          18271: #endif
        !          18272: #endif
        !          18273: 
        !          18274: #if __cplusplus
        !          18275: extern "C" {
        !          18276: #endif
        !          18277: extern int fork();
        !          18278: extern int wait _SFA_((int*));
        !          18279: extern int pipe _SFA_((int*));
        !          18280: extern int execl _SFA_((char*,char*,...));
        !          18281: #if __cplusplus
        !          18282: }
        !          18283: #endif
        !          18284: 
        !          18285: /* pipe ends */
        !          18286: #define READ   0
        !          18287: #define WRITE  1
        !          18288: 
        !          18289: /* to keep track of opened processes */
        !          18290: typedef struct _sfp_
        !          18291: {
        !          18292:        int             pid;    /* process id */
        !          18293:        Sfile_t         *one;   /* streams associated with */
        !          18294:        Sfile_t         *two;
        !          18295:        struct _sfp_    *fore;  /* link list */
        !          18296: } Popen_t;
        !          18297: static Popen_t *Process;
        !          18298: 
        !          18299: #if __STDC__ || __cplusplus
        !          18300: static _sfpclose(reg Sfile_t* f)
        !          18301: #else
        !          18302: static _sfpclose(f)
        !          18303: reg Sfile_t    *f;     /* stream to close */
        !          18304: #endif
        !          18305: {
        !          18306:        reg Popen_t     *last, *p;
        !          18307:        int             pid, status;
        !          18308: 
        !          18309:        /* find the associated process structure */
        !          18310:        for(last = NIL(Popen_t*), p = Process; p; last = p, p = p->fore)
        !          18311:                if(f == p->one || f == p->two)
        !          18312:                        break;
        !          18313: 
        !          18314:        if(!p || (p->one && SFFROZEN(p->one)) || (p->two && SFFROZEN(p->two)))
        !          18315:                return -1;
        !          18316: 
        !          18317:        /* close the associated streams */
        !          18318:        if(p->one)
        !          18319:        {
        !          18320:                p->one->flags &= ~SF_PROCESS;
        !          18321:                sfclose(p->one);
        !          18322:        }
        !          18323:        if(p->two)
        !          18324:        {
        !          18325:                p->two->flags &= ~SF_PROCESS;
        !          18326:                sfclose(p->two);
        !          18327:        }
        !          18328: 
        !          18329:        /* wait for process termination */
        !          18330:        while((pid = wait(&status)) != p->pid && pid != -1)
        !          18331:                ;
        !          18332: 
        !          18333:        /* delete from process table */
        !          18334:        if(last)
        !          18335:                last->fore = p->fore;
        !          18336:        else    Process = p->fore;
        !          18337:        free((char*)p);
        !          18338: 
        !          18339:        return (pid == -1 ? -1 : status);
        !          18340: }
        !          18341: 
        !          18342: #if __STDC__ || __cplusplus
        !          18343: Sfile_t *sfpopen(const char* command, const char* mode, Sfile_t** compf)
        !          18344: #else
        !          18345: Sfile_t *sfpopen(command,mode,compf)
        !          18346: char   *command;       /* command to execute */
        !          18347: char   *mode;          /* mode of the stream */
        !          18348: Sfile_t        **compf;        /* to return the companion stream if mode is "x+" */
        !          18349: #endif
        !          18350: {
        !          18351:        reg int         pid, keep, ckeep, flg, cflg;
        !          18352:        reg Sfile_t     *f, *cf;
        !          18353:        reg Popen_t     *p;
        !          18354:        int             parent[2], child[2];
        !          18355: 
        !          18356:        /* sanity check */
        !          18357:        if(!command || !command[0] || !mode || (mode[0] != 'r' && mode[0] != 'w'))
        !          18358:                return NIL(Sfile_t*);
        !          18359: 
        !          18360:        /* set the close function */
        !          18361:        _Sfpclose = _sfpclose;
        !          18362: 
        !          18363:        /* make a process structure */
        !          18364:        if(!(p = (Popen_t*) malloc(sizeof(Popen_t))) )
        !          18365:                return NIL(Sfile_t*);
        !          18366: 
        !          18367:        /* make pipes */
        !          18368:        parent[0] = parent[1] = child[0] = child[1] = -1;
        !          18369:        if(pipe(parent) < 0)
        !          18370:                goto error;
        !          18371:        if(mode[1] == '+' && pipe(child) < 0)
        !          18372:                goto error;
        !          18373: 
        !          18374:        f = cf = NIL(Sfile_t*);
        !          18375:        switch(pid = fork())
        !          18376:        {
        !          18377:        default :       /* in parent process */
        !          18378:                /* determine which pipe ends to keep */
        !          18379:                if(mode[0] == 'r')
        !          18380:                        { keep = READ; ckeep = WRITE; flg = SF_READ; cflg = SF_WRITE; }
        !          18381:                else    { keep = WRITE; ckeep = READ; flg = SF_WRITE; cflg = SF_READ; }
        !          18382: 
        !          18383:                /* make the streams */
        !          18384:                if(!(f = sfnew(NIL(Sfile_t*),NIL(uchar*),-1,parent[keep],flg)))
        !          18385:                        goto error;
        !          18386:                close(parent[!keep]);
        !          18387: 
        !          18388:                if(mode[1] == '+')
        !          18389:                {       /* make the companion stream */
        !          18390:                        if(!(cf = sfnew(NIL(Sfile_t*),NIL(uchar*),-1,child[ckeep],cflg)))
        !          18391:                                goto error;
        !          18392:                        close(child[!ckeep]);
        !          18393:                        *compf = cf;
        !          18394:                        cf->flags |= SF_PROCESS;
        !          18395:                }
        !          18396: 
        !          18397:                /* save process info */
        !          18398:                f->flags |= SF_PROCESS;
        !          18399:                p->one = f;
        !          18400:                p->two = cf;
        !          18401:                p->pid = pid;
        !          18402:                p->fore = Process;
        !          18403:                Process = p;
        !          18404:                return f;
        !          18405: 
        !          18406:        case 0 :        /* in child process */
        !          18407:                /* determine what to keep */
        !          18408:                if(mode[0] == 'r')
        !          18409:                        { keep = WRITE; ckeep = READ; }
        !          18410:                else    { keep = READ; ckeep = WRITE; }
        !          18411: 
        !          18412:                /* make std-streams */
        !          18413:                close(keep);
        !          18414:                if(dup(parent[keep]) != keep)
        !          18415:                        _exit(127);
        !          18416:                close(parent[!keep]);
        !          18417:                if(mode[1] == '+')
        !          18418:                {
        !          18419:                        close(ckeep);
        !          18420:                        if(dup(child[ckeep]) != ckeep)
        !          18421:                                _exit(127);
        !          18422:                        close(child[!ckeep]);
        !          18423:                }
        !          18424: 
        !          18425:                /* now exec the command */
        !          18426:                execl("/bin/sh", "sh", "-c", command, NIL(char*));
        !          18427:                _exit(127);
        !          18428:                return NIL(Sfile_t*);
        !          18429: 
        !          18430:        case -1 :       /* error */
        !          18431:        error:
        !          18432:                close(parent[0]); close(parent[1]);
        !          18433:                close(child[0]); close(child[1]);
        !          18434:                free((char*)p);
        !          18435:                if(f)
        !          18436:                        sfclose(f);
        !          18437:                if(cf)
        !          18438:                        sfclose(cf);
        !          18439:                return NIL(Sfile_t*);
        !          18440:        }
        !          18441: }
        !          18442: 0707070000000002661006440044230044230000010000000475414061500003300000002114sfio/sfprintf.cUgsfGgsf#include        "sfhdr.h"
        !          18443: 
        !          18444: /*     Print data with a given format
        !          18445: **
        !          18446: **     Written by Kiem-Phong Vo (06/27/90)
        !          18447: */
        !          18448: 
        !          18449: #if __STDC__ || __cplusplus
        !          18450: sfprintf(Sfile_t *f, const char *form, ...)
        !          18451: #else
        !          18452: sfprintf(f,form,va_alist)
        !          18453: reg Sfile_t    *f;     /* file stream to print to */
        !          18454: reg char       *form;  /* print format */
        !          18455: va_dcl
        !          18456: #endif
        !          18457: {
        !          18458:        va_list args;
        !          18459:        reg int rv;
        !          18460: 
        !          18461: #if __STDC__ || __cplusplus
        !          18462:        va_start(args,form);
        !          18463: #else
        !          18464:        va_start(args);
        !          18465: #endif
        !          18466:        rv = sfvprintf(f,form,args);
        !          18467: 
        !          18468:        va_end(args);
        !          18469:        return rv;
        !          18470: }
        !          18471: 
        !          18472: #if __STDC__ || __cplusplus
        !          18473: sfsprintf(char *s, int n, const char *form, ...)
        !          18474: #else
        !          18475: sfsprintf(s,n,form,va_alist)
        !          18476: reg char       *s;
        !          18477: reg int                n;
        !          18478: reg char       *form;
        !          18479: va_dcl
        !          18480: #endif
        !          18481: {
        !          18482:        va_list args;
        !          18483:        Sfile_t f;
        !          18484:        reg int rv;
        !          18485: 
        !          18486:        if(!s || n <= 0)
        !          18487:                return -1;
        !          18488: 
        !          18489:        /* make a fake stream */
        !          18490:        SFCLEAR(&f);
        !          18491:        f.flags = SF_STRING|SF_WRITE;
        !          18492:        f.mode = SF_STRING;
        !          18493:        f.size = n-1;
        !          18494:        f.data = f.next = f.endr = (uchar*)s;
        !          18495:        f.endb = f.endw = f.data+f.size;
        !          18496:        sfset(&f,f.flags,1);
        !          18497: 
        !          18498: #if __STDC__ || __cplusplus
        !          18499:        va_start(args,form);
        !          18500: #else
        !          18501:        va_start(args);
        !          18502: #endif
        !          18503:        rv = sfvprintf(&f,form,args);
        !          18504:        *f.next = '\0';
        !          18505:        _Sfi = f.next - f.data;
        !          18506: 
        !          18507:        va_end(args);
        !          18508: 
        !          18509:        return rv;
        !          18510: }
        !          18511: 0707070000000002671006440044230044230000010000000473120005600003100000002144sfio/sfputd.cUgsfGgsf#include  "sfhdr.h"
        !          18512: 
        !          18513: /*     Write out a double value in a portable format
        !          18514: **
        !          18515: **     Written by Kiem-Phong Vo (08/05/90)
        !          18516: */
        !          18517: 
        !          18518: #if __STDC__ || __cplusplus
        !          18519: _sfputd(Sfile_t* f, reg double v)
        !          18520: #else
        !          18521: _sfputd(f,v)
        !          18522: Sfile_t                *f;
        !          18523: reg double     v;
        !          18524: #endif
        !          18525: {
        !          18526: #define N_ARRAY                (16*sizeof(double))
        !          18527:        reg int         n, w;
        !          18528:        reg double      x;
        !          18529:        reg uchar       *s, *ends;
        !          18530:        int             exp;
        !          18531:        uchar           c[N_ARRAY];
        !          18532: 
        !          18533:        if(f->mode != SF_WRITE && SFMODE(f,SF_WRITE) < 0)
        !          18534:                return -1;
        !          18535: 
        !          18536:        /* get the sign of v */
        !          18537:        if(v < 0)
        !          18538:        {       v = -v;
        !          18539:                n = 01;
        !          18540:        }
        !          18541:        else    n = 0;
        !          18542: 
        !          18543:        /* make the magnitude of v < 1 */
        !          18544:        if(v != 0.)
        !          18545:                v = frexp(v,&exp);
        !          18546:        else    exp = 0;
        !          18547: 
        !          18548:        /* code the sign of v and exp */
        !          18549:        if((w = exp) < 0)
        !          18550:        {       n |= 02;
        !          18551:                w = -w;
        !          18552:        }
        !          18553: 
        !          18554:        /* write out the signs and the exp */
        !          18555:        if(sfputc(f,n) < 0 || (w = sfputu(f,w)) < 0)
        !          18556:                return -1;
        !          18557:        w += 1;
        !          18558: 
        !          18559:        s = (ends = &c[0])+sizeof(c);
        !          18560:        while(s > ends)
        !          18561:        {       /* get 2^SF_PRECIS precision at a time */
        !          18562:                n = (int)(x = ldexp(v,SF_PRECIS));
        !          18563:                *--s = n|SF_MORE;
        !          18564:                if((v = x-n) <= 0.)
        !          18565:                        break;
        !          18566:        }
        !          18567: 
        !          18568:        /* last byte is not SF_MORE */
        !          18569:        ends = &c[0] + sizeof(c) -1;
        !          18570:        *ends &= ~SF_MORE;
        !          18571: 
        !          18572:        /* write out coded bytes */
        !          18573:        n = ends - s + 1;
        !          18574:        return sfwrite(f,s,n) == n ? w+n : -1;
        !          18575: }
        !          18576: 0707070000000002701006440044230044230000010000000473117771500003100000002121sfio/sfputl.cUgsfGgsf#include  "sfhdr.h"
        !          18577: 
        !          18578: /*     Write out a long value in a portable format
        !          18579: **
        !          18580: **     Written by Kiem-Phong Vo (06/27/90)
        !          18581: */
        !          18582: 
        !          18583: #if __STDC__ || __cplusplus
        !          18584: _sfputl(reg Sfile_t* f, reg long v)
        !          18585: #else
        !          18586: _sfputl(f,v)
        !          18587: reg Sfile_t    *f;     /* write a portable long to this stream */
        !          18588: reg long       v;      /* the value to be written */
        !          18589: #endif
        !          18590: {
        !          18591: #define N_ARRAY                (2*sizeof(long))
        !          18592:        reg uchar       *s, *ps;
        !          18593:        reg int         n, p;
        !          18594:        uchar           c[N_ARRAY];
        !          18595: 
        !          18596:        if(f->mode != SF_WRITE && SFMODE(f,SF_WRITE) < 0)
        !          18597:                return -1;
        !          18598: 
        !          18599:        s = ps = &(c[N_ARRAY-1]);
        !          18600:        if(v < 0)
        !          18601:        {       /* add 1 to avoid 2-complement problems with -MAXINT */
        !          18602:                v = -(v+1);
        !          18603:                *s = (uchar)(SFSVALUE(v) | SF_SIGN);
        !          18604:        }
        !          18605:        else    *s = (uchar)(SFSVALUE(v));
        !          18606:        v = (ulong)v >> SF_SBITS;
        !          18607: 
        !          18608:        while(v > 0)
        !          18609:        {
        !          18610:                *--s = (uchar)(SFUVALUE(v) | SF_MORE);
        !          18611:                v = (ulong)v >> SF_UBITS;
        !          18612:        }
        !          18613:        n = (ps-s)+1;
        !          18614: 
        !          18615:        /* write the hard way */
        !          18616:        if(n > 7 || SFWPEEK(f,ps,p) < n)
        !          18617:                return sfwrite(f,s,n);
        !          18618: 
        !          18619:        SFLOCK(f);
        !          18620:        switch(n)
        !          18621:        {
        !          18622:        case 7 : *ps++ = *s++;
        !          18623:        case 6 : *ps++ = *s++;
        !          18624:        case 5 : *ps++ = *s++;
        !          18625:        case 4 : *ps++ = *s++;
        !          18626:        case 3 : *ps++ = *s++;
        !          18627:        case 2 : *ps++ = *s++;
        !          18628:        case 1 : *ps++ = *s++;
        !          18629:        }
        !          18630:        f->next = ps;
        !          18631:        SFOPEN(f);
        !          18632: 
        !          18633:        return n;
        !          18634: }
        !          18635: 0707070000000002711006440044230044230000010000000475116744600003100000002642sfio/sfputs.cUgsfGgsf#include  "sfhdr.h"
        !          18636: 
        !          18637: /*     Put out a nul-terminated string
        !          18638: **
        !          18639: **     Written by Kiem-Phong Vo
        !          18640: */
        !          18641: #if __STDC__ || __cplusplus
        !          18642: sfputs(reg Sfile_t* f, const char* s, int t)
        !          18643: #else
        !          18644: sfputs(f,s,t)
        !          18645: reg Sfile_t    *f;
        !          18646: char           *s;
        !          18647: int            t;
        !          18648: #endif
        !          18649: {
        !          18650:        reg int         p;
        !          18651:        reg uchar       *os, *ps;
        !          18652:        reg int         n;
        !          18653: 
        !          18654:        if(f->mode != SF_WRITE && SFMODE(f,SF_WRITE) < 0)
        !          18655:                return -1;
        !          18656: 
        !          18657:        SFLOCK(f);
        !          18658:        if(f->size <= 0 || (uchar*)s == f->next)
        !          18659:        {       /* unbuffered stream or writing after sfpeek() */
        !          18660:                n = strlen((char*)s);
        !          18661:                SFopen(f);
        !          18662:                if((p = sfwrite(f,(uchar*)s,n)) == n && t != 0 && sfputc(f,t) >= 0)
        !          18663:                        p += 1;
        !          18664:                goto done;
        !          18665:        }
        !          18666: 
        !          18667:        os = (uchar*)s;
        !          18668:        while(1)
        !          18669:        {       /* peek buffer for space */
        !          18670:                if(SFWPEEK(f,ps,p) <= 0)
        !          18671:                        break;
        !          18672: 
        !          18673:                /* fast copy loop */
        !          18674:                while((*ps++ = *os++) != '\0' && --p > 0)
        !          18675:                        ;
        !          18676: 
        !          18677:                if(ps[-1] == '\0')
        !          18678:                {       /* done */
        !          18679:                        p = -1;
        !          18680:                        if(t != 0)      /* add the last char if any */
        !          18681:                                ps[-1] = t;
        !          18682:                        else    { ps -= 1; os -= 1; }
        !          18683:                }
        !          18684: 
        !          18685:                /* move the write pointer */
        !          18686:                f->next = ps;
        !          18687:                if(p < 0)
        !          18688:                        break;
        !          18689:        }
        !          18690: 
        !          18691:        p = (char*)os - s;
        !          18692: 
        !          18693:        if((f->flags&SF_LINE) && !(f->flags&SF_STRING))
        !          18694:        {       /* see if we need to flush the buffer */
        !          18695:                if(t == '\n')
        !          18696:                        t = HIFORLINE;
        !          18697:                else if((t = (ps = f->next) - (os = f->data)) < HIFORLINE && t > 0)
        !          18698:                {       /* long check for embedded \n */
        !          18699:                        n = os[0]; os[0] = '\n';
        !          18700:                        while(*--ps != '\n')
        !          18701:                                ;
        !          18702:                        if(ps > os || n == '\n')
        !          18703:                                t = HIFORLINE;
        !          18704:                        os[0] = n;
        !          18705:                }
        !          18706:                if(t >= HIFORLINE)
        !          18707:                        { SFopen(f); (void) _sfflsbuf(f,-1); }
        !          18708:        }
        !          18709: 
        !          18710: done :
        !          18711:        SFOPEN(f);
        !          18712:        return p;
        !          18713: }
        !          18714: 0707070000000002721006440044230044230000010000000473117761300003100000001705sfio/sfputu.cUgsfGgsf#include  "sfhdr.h"
        !          18715: 
        !          18716: /*     Write out an unsigned long value in a portable format.
        !          18717: **
        !          18718: **     Written by Kiem-Phong Vo (06/27/90)
        !          18719: */
        !          18720: 
        !          18721: #if __STDC__ || __cplusplus
        !          18722: _sfputu(reg Sfile_t* f, reg ulong v)
        !          18723: #else
        !          18724: _sfputu(f,v)
        !          18725: reg Sfile_t    *f;     /* write a portable ulong to this stream */
        !          18726: reg ulong      v;      /* the unsigned value to be written */
        !          18727: #endif
        !          18728: {
        !          18729: #define N_ARRAY                (2*sizeof(long))
        !          18730:        reg uchar       *s, *ps;
        !          18731:        reg int         n, p;
        !          18732:        uchar           c[N_ARRAY];
        !          18733: 
        !          18734:        if(f->mode != SF_WRITE && SFMODE(f,SF_WRITE) < 0)
        !          18735:                return -1;
        !          18736: 
        !          18737:        /* code v as integers in base SF_UBASE */
        !          18738:        s = ps = &(c[N_ARRAY-1]);
        !          18739:        *s = (uchar)SFUVALUE(v);
        !          18740:        while((v >>= SF_UBITS) > 0)
        !          18741:                *--s = (uchar)(SFUVALUE(v) | SF_MORE);
        !          18742:        n = (ps-s)+1;
        !          18743: 
        !          18744:        if(n > 7 || SFWPEEK(f,ps,p) < n)
        !          18745:                return sfwrite(f,s,n);
        !          18746: 
        !          18747:        SFLOCK(f);
        !          18748:        switch(n)
        !          18749:        {
        !          18750:        case 7 : *ps++ = *s++;
        !          18751:        case 6 : *ps++ = *s++;
        !          18752:        case 5 : *ps++ = *s++;
        !          18753:        case 4 : *ps++ = *s++;
        !          18754:        case 3 : *ps++ = *s++;
        !          18755:        case 2 : *ps++ = *s++;
        !          18756:        case 1 : *ps++ = *s++;
        !          18757:        }
        !          18758:        f->next = ps;
        !          18759:        SFOPEN(f);
        !          18760: 
        !          18761:        return n;
        !          18762: }
        !          18763: 0707070000000002731006440044230044230000010000000474537763700003100000004201sfio/sfread.cUgsfGgsf#include  "sfhdr.h"
        !          18764: 
        !          18765: /*     Read n bytes from a tream into a buffer
        !          18766: **
        !          18767: **     Written by Kiem-Phong Vo (06/27/90)
        !          18768: */
        !          18769: 
        !          18770: #if __STDC__ || __cplusplus
        !          18771: sfread(reg Sfile_t* f, reg uchar* s, reg int n)
        !          18772: #else
        !          18773: sfread(f,s,n)
        !          18774: reg Sfile_t    *f;     /* read from this stream */
        !          18775: reg uchar      *s;     /* buffer to read into */
        !          18776: reg int                n;      /* number of bytes to be read */
        !          18777: #endif
        !          18778: {
        !          18779:        reg uchar       *data;
        !          18780:        reg int         r;
        !          18781:        reg int         (*readf) _SFA_((Sfile_t*, uchar*, int, char*));
        !          18782:        reg long        (*seekf) _SFA_((Sfile_t*, long, int, char*));
        !          18783:        reg char        *handle;
        !          18784:        reg uchar       *begs = s;      /* true start of buffer */
        !          18785: 
        !          18786: redo_loop:
        !          18787:        if(f->mode != SF_READ && SFMODE(f,SF_READ) < 0)
        !          18788:                return -1;
        !          18789:        SFLOCK(f);
        !          18790:        if(s == f->next)
        !          18791:        {       /* fast read after sfpeek() */
        !          18792:                if((r = f->endb - f->next) > n)
        !          18793:                        r = n <= 0 ? 0 : n;
        !          18794:                if(r > 0)
        !          18795:                        f->next = (s += r);
        !          18796:                goto done;
        !          18797:        }
        !          18798: 
        !          18799:        readf = f->disc ? f->disc->readf :
        !          18800:                        NIL(int(*)_SFA_((Sfile_t*, uchar*, int, char*)));
        !          18801:        seekf = f->disc ? f->disc->seekf :
        !          18802:                        NIL(long(*)_SFA_((Sfile_t*, long, int, char*)));
        !          18803:        handle = f->disc ? f->disc->handle : NIL(char*);
        !          18804: 
        !          18805:        if((r = f->endb - (data = f->next)) > n)
        !          18806:                r = n <= 0 ? 0 : n;
        !          18807:        for(;;)
        !          18808:        {       /* copy data - note that s is advanced too */
        !          18809:                MEMCPY(s,data,r);
        !          18810: 
        !          18811:                f->next += r;
        !          18812:                if((n -= r) <= 0)
        !          18813:                        goto done;
        !          18814: 
        !          18815:                if(f->flags&SF_STRING)
        !          18816:                {       r = 0;
        !          18817:                        goto at_eof;
        !          18818:                }
        !          18819: 
        !          18820:                /* read directly into requested buffer */
        !          18821:                f->next = f->endb = f->endr = f->data;
        !          18822:                while(n >= (r = f->size))
        !          18823:                {       /* unbuffered read */
        !          18824:                        if(r <= 1)
        !          18825:                                r = n;
        !          18826:                        else
        !          18827:                        {       /* read by a round-up unit */
        !          18828:                                if(r > SF_GRAIN)
        !          18829:                                        r = SF_GRAIN;
        !          18830:                                r = (n/r)*r;
        !          18831:                        }
        !          18832:                        if(f->flags&SF_SHARE)
        !          18833:                                f->here = SEEKF(seekf,f,f->here,0,handle);
        !          18834:                        if((r = READF(readf,f,s,r,handle)) > 0)
        !          18835:                        {
        !          18836:                                f->here += r;
        !          18837:                                s += r;
        !          18838:                                if((n -= r) <= 0)
        !          18839:                                        goto done;
        !          18840:                        }
        !          18841:                        else
        !          18842:                        {       /* eof or error */
        !          18843:                        at_eof:
        !          18844:                                switch(_sfexcept(f,SF_READ,r))
        !          18845:                                {
        !          18846:                                case SF_EDISC :
        !          18847:                                case SF_ESTACK :
        !          18848:                                        SFopen(f);
        !          18849:                                        goto redo_loop;
        !          18850:                                case SF_EDONE :
        !          18851:                                        goto done;
        !          18852:                                default :
        !          18853:                                        continue;
        !          18854:                                }
        !          18855:                        }
        !          18856:                }
        !          18857: 
        !          18858:                /* fill our buffer and continue */
        !          18859:                SFopen(f);
        !          18860:                if((r = _sffilbuf(f,-1)) <= 0)
        !          18861:                        goto done;
        !          18862:                SFLOCK(f);
        !          18863:                if(r > n)
        !          18864:                        r = n;
        !          18865:                data = f->next;
        !          18866:        }
        !          18867: done :
        !          18868:        SFOPEN(f);
        !          18869:        return s-begs;
        !          18870: }
        !          18871: 0707070000000002741006440044230044230000010000000475414062400003200000002014sfio/sfscanf.cUgsfGgsf#include "sfhdr.h"
        !          18872: 
        !          18873: /*     Read formated data from a stream
        !          18874: **
        !          18875: **     Written by Kiem-Phong Vo (06/27/90)
        !          18876: */
        !          18877: 
        !          18878: #if __STDC__ || __cplusplus
        !          18879: sfscanf(Sfile_t *f, const char *form, ...)
        !          18880: #else
        !          18881: sfscanf(f,form,va_alist)
        !          18882: reg Sfile_t    *f;     /* file to be scanned */
        !          18883: reg char       *form;  /* scanning format */
        !          18884: va_dcl
        !          18885: #endif
        !          18886: {
        !          18887:        va_list args;
        !          18888:        reg int rv;
        !          18889: 
        !          18890: #if __STDC__ || __cplusplus
        !          18891:        va_start(args,form);
        !          18892: #else
        !          18893:        va_start(args);
        !          18894: #endif
        !          18895:        rv = sfvscanf(f,form,args);
        !          18896:        va_end(args);
        !          18897:        return rv;
        !          18898: }
        !          18899: 
        !          18900: #if __STDC__ || __cplusplus
        !          18901: sfsscanf(const char *s, const char *form,...)
        !          18902: #else
        !          18903: sfsscanf(s,form,va_alist)
        !          18904: reg char       *s;
        !          18905: reg char       *form;
        !          18906: va_dcl
        !          18907: #endif
        !          18908: {
        !          18909:        va_list args;
        !          18910:        Sfile_t f;
        !          18911:        reg int rv;
        !          18912: 
        !          18913:        if(!s)
        !          18914:                return -1;
        !          18915: 
        !          18916:        /* make a fake stream */
        !          18917:        SFCLEAR(&f);
        !          18918:        f.flags = SF_STRING|SF_READ;
        !          18919:        f.mode = SF_STRING;
        !          18920:        f.size = strlen((char*)s);
        !          18921:        f.data = f.next = f.endw = (uchar*)s;
        !          18922:        f.endb = f.endr = f.data+f.size;
        !          18923:        sfset(&f,f.flags,1);
        !          18924: 
        !          18925: #if __STDC__ || __cplusplus
        !          18926:        va_start(args,form);
        !          18927: #else
        !          18928:        va_start(args);
        !          18929: #endif
        !          18930:        rv = sfvscanf(&f,form,args);
        !          18931:        va_end(args);
        !          18932: 
        !          18933:        return rv;
        !          18934: }
        !          18935: 0707070000000002751006440044230044230000010000000471606707700003100000007342sfio/sfseek.cUgsfGgsf#include  "sfhdr.h"
        !          18936: 
        !          18937: /*     Set the IO pointer to a specific location in the stream
        !          18938: **
        !          18939: **     Written by Kiem-Phong Vo (06/27/90)
        !          18940: */
        !          18941: 
        !          18942: #if __STDC__ || __cplusplus
        !          18943: long sfseek(reg Sfile_t* f, reg long p, reg int type)
        !          18944: #else
        !          18945: long sfseek(f,p,type)
        !          18946: reg Sfile_t    *f;     /* seek to a new location in this stream */
        !          18947: reg long       p;      /* place to seek to */
        !          18948: int            type;   /* 0: from org, 1: from here, 2: from end */
        !          18949: #endif
        !          18950: {
        !          18951:        reg long        r, s;
        !          18952:        reg long        (*seekf)_SFA_((Sfile_t*,long,int,char*));
        !          18953:        reg char        *handle;
        !          18954: 
        !          18955:        /* set the stream to the right mode */
        !          18956:        if((!f->mode || (f->mode&~(SF_RDWR|SF_STRING))) && _sfmode(f,0) < 0)
        !          18957:                return -1;
        !          18958: 
        !          18959:        if(type < 0 || type > 2 || f->orig < 0L)
        !          18960:                return -1;
        !          18961: 
        !          18962:        /* lock the stream for internal manipulations */
        !          18963:        SFLOCK(f);
        !          18964: 
        !          18965:        /* clear error and eof bits */
        !          18966:        f->flags &= ~(SF_EOF|SF_ERROR);
        !          18967: 
        !          18968:        if(f->mode&SF_STRING)
        !          18969:        {       /* actual current end of data */
        !          18970:                if((f->flags&SF_WRITE) &&
        !          18971:                   (s = f->next-f->data) > f->here && s != f->orig)
        !          18972:                        f->here = s;
        !          18973: 
        !          18974:                /* new location */
        !          18975:                if(type == 1)
        !          18976:                        p += f->next - f->data;
        !          18977:                else if(type == 2)
        !          18978:                        p += f->here;
        !          18979: 
        !          18980:                if(p < 0 || p > f->size)
        !          18981:                {       p = -1;
        !          18982:                        goto done;
        !          18983:                }
        !          18984: 
        !          18985:                f->next = f->data+p;
        !          18986:                f->orig = p;    /* use this to determine if writes occured */
        !          18987: 
        !          18988:                /* clear the part skipped over */
        !          18989:                if(p > f->here)
        !          18990:                        memclear((char*)(f->data+f->here),(int)(p-f->here));
        !          18991: 
        !          18992:                goto done;
        !          18993:        }
        !          18994: 
        !          18995:        seekf = f->disc ? f->disc->seekf :
        !          18996:                        NIL(long(*)_SFA_((Sfile_t*,long,int,char*)));
        !          18997:        handle = f->disc ? f->disc->handle : NIL(char*);
        !          18998: 
        !          18999:        /* currently known seek location */
        !          19000:        s = f->here + ((f->mode&SF_READ) ? f->next-f->endb : f->next-f->data);
        !          19001: 
        !          19002:        if(type == 1 && p == 0 && !(f->flags&(SF_APPEND|SF_SHARE)) )
        !          19003:        {       /* certify current location only */
        !          19004:                if((p = SEEKF(seekf,f,f->here,0,handle)) != f->here)
        !          19005:                        p = -1;
        !          19006:                else    p = s - f->orig;
        !          19007:                goto done;
        !          19008:        }
        !          19009: 
        !          19010:        if(f->mode&SF_WRITE)
        !          19011:        {       if((f->flags&(SF_APPEND|SF_SHARE)) ||
        !          19012:                   (type == 0 ? p+f->orig : type == 1 ? p+s : -1) != s)
        !          19013:                {       /* sync physical and virtual views */
        !          19014:                        SFopen(f);
        !          19015:                        if(_sfflsbuf(f,-1) < 0)
        !          19016:                        {       p = -1;
        !          19017:                                goto done;
        !          19018:                        }
        !          19019:                        SFLOCK(f);
        !          19020:                        s = f->here;
        !          19021:                }
        !          19022: 
        !          19023:                if(f->flags&SF_APPEND)
        !          19024:                {       /* the true location for a SF_APPEND stream */
        !          19025:                        s = f->here = SEEKF(seekf,f,0L,2,handle);
        !          19026:                        r = p + (type == 0 ? f->orig : s);
        !          19027:                }
        !          19028:                else if(!(f->flags&SF_SHARE))
        !          19029:                        r = type == 0 ? p+f->orig : type == 1 ? p+s : -1;
        !          19030:                else    r = -1;
        !          19031:                if(r == s)
        !          19032:                {       /* at where we are supposed to be */
        !          19033:                        p = r - f->orig;
        !          19034:                        goto done;
        !          19035:                }
        !          19036:        }
        !          19037:        else if(type < 2 && !(f->flags&(SF_SHARE|SF_APPEND)) &&
        !          19038:                (r = p + (type == 0 ? f->orig : s)) > f->here)
        !          19039:        {       /* move forward by reading */
        !          19040:                if(f->next == f->endb)
        !          19041:                        f->endb = f->endr = f->next = f->data;
        !          19042:                if(r < (s + (f->size - (f->endb-f->data))))
        !          19043:                {       SFopen(f);
        !          19044:                        _sffilbuf(f,-1);
        !          19045:                        SFLOCK(f);
        !          19046:                }
        !          19047:        }
        !          19048: 
        !          19049:        if(type < 2)
        !          19050:        {       /* place to seek to */  
        !          19051:                p += type == 0 ? f->orig : s;
        !          19052: 
        !          19053:                if((f->mode&SF_READ) && !(f->flags&(SF_SHARE|SF_APPEND)) &&
        !          19054:                   p >= (f->here - (f->endb-f->data)) && p <= f->here)
        !          19055:                {       /* still in bound, safe to just move the pointer */
        !          19056:                        f->next = f->endb - (f->here-p);
        !          19057:                        p -= f->orig;
        !          19058:                        goto done;
        !          19059:                }
        !          19060: 
        !          19061:                /* now must seek */
        !          19062:                p = SEEKF(seekf,f,p,0,handle);
        !          19063:        }
        !          19064:        else    p = SEEKF(seekf,f,p,2,handle);
        !          19065: 
        !          19066:        /* moved backward too far */
        !          19067:        if(p >= 0 && p < f->orig)
        !          19068:        {       SEEKF(seekf,f,f->here,0,handle);
        !          19069:                p = -1;
        !          19070:        }
        !          19071:        if(p < 0)
        !          19072:                goto done;
        !          19073: 
        !          19074:        f->here = p;
        !          19075:        if(f->mode&SF_READ)
        !          19076:        {       /* any buffered data is invalid */
        !          19077:                f->next = f->endr = f->endb = f->data;
        !          19078: 
        !          19079:                /* seek to a rounded boundary to improve performance */
        !          19080:                if((s = f->size) > SF_GRAIN)
        !          19081:                        s = SF_GRAIN;
        !          19082:                r = s > 1 ? (p/s)*s : p;
        !          19083:                if(r < p && r >= f->orig && SEEKF(seekf,f,r,0,handle) == r)
        !          19084:                {       /* now fill buffer */
        !          19085:                        f->here = r;
        !          19086:                        SFopen(f); (void) _sffilbuf(f,-1); SFLOCK(f);
        !          19087:                        if(f->here < p)
        !          19088:                        {       p = -1;
        !          19089:                                goto done;
        !          19090:                        }
        !          19091:                        f->next = f->endb - (f->here-p);
        !          19092:                }
        !          19093:        }
        !          19094: 
        !          19095:        p -= f->orig;
        !          19096: 
        !          19097: done :
        !          19098:        SFOPEN(f);
        !          19099:        return p;
        !          19100: }
        !          19101: 0707070000000002761006440044230044230000010000000475414161200003000000003101sfio/sfset.cUgsfGgsf#include   "sfhdr.h"
        !          19102: 
        !          19103: /*     Set some control flags or file descript for the stream
        !          19104: **
        !          19105: **     Written by Kiem-Phong Vo (07/16/90)
        !          19106: */
        !          19107: #define RDSTRING(f)    ((f->flags&SF_RDSTR) == SF_RDSTR)
        !          19108: #define WRSTRING(f)    ((f->flags&SF_WRSTR) == SF_WRSTR)
        !          19109: #define RDSTREAM(f)    (f->mode&SF_READ)
        !          19110: #define WRSTREAM(f)    ((f->mode&SF_WRITE) && !(f->flags&SF_LINE))
        !          19111: 
        !          19112: #if __STDC__ || __cplusplus
        !          19113: sfset(reg Sfile_t* f, reg int flags, reg int i)
        !          19114: #else
        !          19115: sfset(f,flags,i)
        !          19116: reg Sfile_t    *f;
        !          19117: reg int                flags;
        !          19118: reg int                i;
        !          19119: #endif
        !          19120: {
        !          19121:        if(flags == SF_EOF)
        !          19122:        {       /* changing file descriptor */
        !          19123:                if(SFFROZEN(f))
        !          19124:                        return -1;
        !          19125:                f->file = i;
        !          19126:                return i;
        !          19127:        }
        !          19128: 
        !          19129:        if(!f->mode) /* a std-stream */
        !          19130:                (void)sfnew(f,NIL(uchar*),-1,f->file,f->flags);
        !          19131:        else if(SFFROZEN(f))
        !          19132:                return 0;
        !          19133: 
        !          19134:        SFLOCK(f);
        !          19135: 
        !          19136:        /* can't touch this mode */
        !          19137:        if(!(f->flags&SF_BOTH))
        !          19138:                flags &= ~SF_RDWR;
        !          19139:        /* must have at least one read/write mode */
        !          19140:        else if(!i && (flags&SF_RDWR) && (flags&SF_RDWR) != SF_RDWR)
        !          19141:                f->flags |= SF_RDWR;
        !          19142: 
        !          19143:        if(i)
        !          19144:                f->flags |=  (flags&SF_SETS);
        !          19145:        else    f->flags &= ~(flags&SF_SETS);
        !          19146: 
        !          19147:        if(!(f->mode&(SF_PUSH|SF_POOL)) && (RDSTRING(f) || RDSTREAM(f)))
        !          19148:                f->flags |= SF_GETC;
        !          19149:        else    f->flags &= ~SF_GETC;
        !          19150: 
        !          19151:        if(!(f->mode&(SF_PUSH|SF_POOL)) && (WRSTRING(f) || WRSTREAM(f)))
        !          19152:                f->flags |= SF_PUTC;
        !          19153:        else    f->flags &= ~SF_PUTC;
        !          19154: 
        !          19155:        if(f->orig < 0)
        !          19156:                f->flags &= ~(SF_RELATIVE|SF_SHARE|SF_APPEND);
        !          19157: 
        !          19158:        SFOPEN(f);
        !          19159: 
        !          19160:        if(!(f->mode&SF_STRING))
        !          19161:        {       /* if mode is exclusive, f must be in the right mode */
        !          19162:                flags = f->flags&SF_RDWR;
        !          19163:                if((flags == SF_WRITE && !(f->mode&SF_WRITE)) ||
        !          19164:                   (flags == SF_READ && !(f->mode&(SF_READ|SF_SYNC))) )
        !          19165:                        _sfmode(f,flags);
        !          19166:        }
        !          19167: 
        !          19168:        return f->flags;
        !          19169: }
        !          19170: 0707070000000002771006440044230044230000010000000474537763700003300000005127sfio/sfsetbuf.cUgsfGgsf#include        "sfhdr.h"
        !          19171: 
        !          19172: #ifdef LIBX
        !          19173: #include       <fsinfo.h>
        !          19174: #else
        !          19175: #ifdef BSD
        !          19176: #define         stat_blksize
        !          19177: #endif
        !          19178: #endif
        !          19179: 
        !          19180: /*     Set a (new) buffer for a stream.
        !          19181: **     If size < 0, it is assigned a suitable value depending on the
        !          19182: **     kind of stream. The actual buffer size allocated is dependent
        !          19183: **     on how much memory is available.
        !          19184: **
        !          19185: **     Written by Kiem-Phong Vo (06/27/90)
        !          19186: */
        !          19187: 
        !          19188: #if __STDC__ || __cplusplus
        !          19189: uchar *sfsetbuf(reg Sfile_t* f, reg uchar* buf, reg int size)
        !          19190: #else
        !          19191: uchar *sfsetbuf(f,buf,size)
        !          19192: reg Sfile_t    *f;     /* stream to be buffered */
        !          19193: reg uchar      *buf;   /* new buffer, !NULL if size > 0 */
        !          19194: reg int                size;   /* buffer size, -1 for default size */
        !          19195: #endif
        !          19196: {
        !          19197:        reg int         sf_malloc;
        !          19198:        reg uchar       *obuf;
        !          19199: 
        !          19200:        if(!f->mode)
        !          19201:        {       /* a std-stream */
        !          19202:                obuf = f->data;
        !          19203:                (void)sfnew(f,buf,size,f->file,f->flags);
        !          19204:                return obuf;
        !          19205:        }
        !          19206: 
        !          19207:        /* set the stream to the right mode */
        !          19208:        if((f->mode&~(SF_RDWR|SF_STRING)) && _sfmode(f,0) < 0)
        !          19209:                return NIL(uchar*);
        !          19210: 
        !          19211:        /* pure read/string streams must have a valid string */
        !          19212:        if((f->flags&(SF_RDWR|SF_STRING)) == SF_RDSTR && (size < 0 || !buf))
        !          19213:                size = 0;
        !          19214: 
        !          19215:        /* sync stream before switching buffer */
        !          19216:        if((f->mode&SF_READ) && f->next < f->endb)
        !          19217:                sfsync(f);
        !          19218: 
        !          19219:        /* lock for internal work */
        !          19220:        SFLOCK(f);
        !          19221: 
        !          19222:        /* get buffer space */
        !          19223:        sf_malloc = 0;
        !          19224:        if(size < 0)
        !          19225:        {       /* define a default size suitable for block transfer */
        !          19226:                buf = NIL(uchar*);
        !          19227:                if(f->mode&SF_STRING)
        !          19228:                        size = SF_GRAIN;
        !          19229:                else
        !          19230:                {       /* try to set an optimal size for io */
        !          19231:                        struct stat     sb;
        !          19232:                        if(fstat(f->file,&sb) < 0)
        !          19233:                                size = SF_GRAIN;
        !          19234:                        else
        !          19235:                        {       if(f->mode&SF_READ)
        !          19236:                                {       /* maybe only need small buffer */
        !          19237:                                        if((size = (int)sb.st_size) > SF_BUFSIZE)
        !          19238:                                                size = SF_BUFSIZE;
        !          19239:                                        size = ((size+SF_GRAIN-1)/SF_GRAIN)*SF_GRAIN;
        !          19240:                                }
        !          19241: #ifdef stat_blksize
        !          19242:                                if(size <= 0 || size > sb.st_blksize)
        !          19243:                                        size = (int)sb.st_blksize;
        !          19244: #endif
        !          19245:                                if(size <= 0)
        !          19246:                                        size = SF_BUFSIZE;
        !          19247:                        }
        !          19248:                }
        !          19249:        }
        !          19250:        if(size > 0 && !buf)
        !          19251:        {       /* try to allocate it */
        !          19252:                while(!(buf = (uchar*) malloc(size)) && size > 0)
        !          19253:                        size /= 2;
        !          19254:                if(size > 0)
        !          19255:                        sf_malloc = SF_MALLOC;
        !          19256:                else if(f->mode&SF_STRING)
        !          19257:                {       SFOPEN(f);
        !          19258:                        return NIL(uchar*);
        !          19259:                }
        !          19260:        }
        !          19261:        if(size == 0 && (f->mode&SF_READ))
        !          19262:        {       /* use the internal buffer */
        !          19263:                size = sizeof(f->tiny);
        !          19264:                buf = f->tiny;
        !          19265:                sf_malloc = 0;
        !          19266:        }
        !          19267: 
        !          19268:        /* current buffer */
        !          19269:        obuf = f->data;
        !          19270: 
        !          19271:        /* set up new buffer */
        !          19272:        f->size = size;
        !          19273:        f->next = f->data = f->endr = f->endw = buf;
        !          19274:        f->endb = (f->mode&SF_READ) ? buf : buf+size;
        !          19275:        if(f->mode&SF_STRING)
        !          19276:        {
        !          19277:                f->orig = 0L;
        !          19278:                f->here = sf_malloc ? 0L : size;
        !          19279:        }
        !          19280: 
        !          19281:        if(obuf && obuf != buf && (f->flags&SF_MALLOC))
        !          19282:        {       free((char*)obuf);
        !          19283:                obuf = NIL(uchar*);
        !          19284:        }
        !          19285: 
        !          19286:        f->flags = (f->flags & ~SF_MALLOC)|sf_malloc;
        !          19287: 
        !          19288:        SFOPEN(f);
        !          19289:        return obuf;
        !          19290: }
        !          19291: 0707070000000003001006440044230044230000010000000471532037700003400000001066sfio/sfsetdisc.cUgsfGgsf#include       "sfhdr.h"
        !          19292: 
        !          19293: /*     Set a new discipline for a stream.
        !          19294: **
        !          19295: **     Written by Kiem-Phong Vo (06/27/90)
        !          19296: */
        !          19297: 
        !          19298: #if __STDC__ || __cplusplus
        !          19299: Sfdisc_t* sfsetdisc(reg Sfile_t* f, reg Sfdisc_t* disc)
        !          19300: #else
        !          19301: Sfdisc_t* sfsetdisc(f,disc)
        !          19302: reg Sfile_t    *f;
        !          19303: reg Sfdisc_t   *disc;
        !          19304: #endif
        !          19305: {
        !          19306:        reg Sfdisc_t    *old;
        !          19307: 
        !          19308:        /* set the stream to the right mode */
        !          19309:        if((!f->mode || (f->mode&~(SF_RDWR|SF_STRING))) && _sfmode(f,0) < 0)
        !          19310:                return NIL(Sfdisc_t*);
        !          19311: 
        !          19312:        /* now set the new discipline */
        !          19313:        if((old = f->disc) && old->exceptf)
        !          19314:                (*(old->exceptf))(f,0,old->handle);
        !          19315:        f->disc = disc;
        !          19316: 
        !          19317:        return old;
        !          19318: }
        !          19319: 0707070000000003011006440044230044230000010000000472060046300003400000002707sfio/sfsetflag.cUgsfGgsf#include       "sfhdr.h"
        !          19320: 
        !          19321: /*     Set some control flags for the stream
        !          19322: **
        !          19323: **     Written by Kiem-Phong Vo (07/16/90)
        !          19324: */
        !          19325: #define RDSTRING(f)    ((f->flags&SF_RDSTR) == SF_RDSTR)
        !          19326: #define WRSTRING(f)    ((f->flags&SF_WRSTR) == SF_WRSTR)
        !          19327: #define RDSTREAM(f)    (f->mode&SF_READ)
        !          19328: #define WRSTREAM(f)    ((f->mode&SF_WRITE) && !(f->flags&SF_LINE))
        !          19329: 
        !          19330: #if __STDC__ || __cplusplus
        !          19331: sfsetflag(reg Sfile_t* f, reg int flags, reg int on)
        !          19332: #else
        !          19333: sfsetflag(f,flags,on)
        !          19334: reg Sfile_t    *f;
        !          19335: reg int                flags;
        !          19336: reg int                on;
        !          19337: #endif
        !          19338: {
        !          19339:        if(!f->mode) /* a std-stream */
        !          19340:                (void)sfnew(f,NIL(uchar*),-1,f->file,f->flags);
        !          19341:        else if(SFFROZEN(f))
        !          19342:                return 0;
        !          19343: 
        !          19344:        SFLOCK(f);
        !          19345: 
        !          19346:        /* can't touch this mode */
        !          19347:        if(!(f->flags&SF_BOTH))
        !          19348:                flags &= ~SF_RDWR;
        !          19349:        /* must have at least one read/write mode */
        !          19350:        else if(!on && (flags&SF_RDWR) && (flags&SF_RDWR) != SF_RDWR)
        !          19351:                f->flags |= SF_RDWR;
        !          19352: 
        !          19353:        if(on)
        !          19354:                f->flags |=  (flags&SF_SETS);
        !          19355:        else    f->flags &= ~(flags&SF_SETS);
        !          19356: 
        !          19357:        if(!(f->mode&(SF_PUSH|SF_POOL)) && (RDSTRING(f) || RDSTREAM(f)))
        !          19358:                f->flags |= SF_GETC;
        !          19359:        else    f->flags &= ~SF_GETC;
        !          19360: 
        !          19361:        if(!(f->mode&(SF_PUSH|SF_POOL)) && (WRSTRING(f) || WRSTREAM(f)))
        !          19362:                f->flags |= SF_PUTC;
        !          19363:        else    f->flags &= ~SF_PUTC;
        !          19364: 
        !          19365:        if(f->orig < 0)
        !          19366:                f->flags &= ~(SF_RELATIVE|SF_SHARE|SF_APPEND);
        !          19367: 
        !          19368:        SFOPEN(f);
        !          19369: 
        !          19370:        if(!(f->mode&SF_STRING))
        !          19371:        {       /* if mode is exclusive, f must be in the right mode */
        !          19372:                flags = f->flags&SF_RDWR;
        !          19373:                if((flags == SF_WRITE && !(f->mode&SF_WRITE)) ||
        !          19374:                   (flags == SF_READ && !(f->mode&(SF_READ|SF_SYNC))) )
        !          19375:                        _sfmode(f,flags);
        !          19376:        }
        !          19377: 
        !          19378:        return f->flags;
        !          19379: }
        !          19380: 0707070000000003021006440044230044230000010000000475414166000003200000003200sfio/sfstack.cUgsfGgsf#include "sfhdr.h"
        !          19381: 
        !          19382: 
        !          19383: /*     Push/pop streams
        !          19384: **
        !          19385: **     Written by Kiem-Phong Vo (07/10/90)
        !          19386: */
        !          19387: 
        !          19388: #if __STDC__ || __cplusplus
        !          19389: Sfile_t *sfstack(reg Sfile_t* f1,reg Sfile_t* f2)
        !          19390: #else
        !          19391: Sfile_t *sfstack(f1,f2)
        !          19392: reg Sfile_t    *f1, *f2;
        !          19393: #endif
        !          19394: {
        !          19395:        Sfile_t         tmp;
        !          19396:        reg Sfile_t     *rf;
        !          19397: 
        !          19398:        /* can't push on something that is currently frozen */
        !          19399:        if(SFFROZEN(f1) || (f2 && SFFROZEN(f2)))
        !          19400:                return NIL(Sfile_t*);
        !          19401: 
        !          19402:        /* initializing std-streams */
        !          19403:        if((!f1->mode && _sfmode(f1,0) < 0) ||
        !          19404:           (f2 && !f2->mode && _sfmode(f2,0) < 0))
        !          19405:                return NIL(Sfile_t*);
        !          19406: 
        !          19407:        /* give access to other internal functions */
        !          19408:        _Sfstack = sfstack;
        !          19409: 
        !          19410:        if(!f2)
        !          19411:        {       /* popping */
        !          19412:                if(!f1->push)
        !          19413:                        return NIL(Sfile_t*);
        !          19414:                f2 = f1->push;
        !          19415:        }
        !          19416:        else if(_Sfpmove && f1->pool && f1->pool != &_Sfpool && !f1->back)
        !          19417:        {       /* get something else to the front since f1 will be locked */
        !          19418:                for(rf = f1->fore; rf; rf = rf->fore)
        !          19419:                {       if(SFFROZEN(rf))
        !          19420:                                continue;
        !          19421:                        (*_Sfpmove)(rf,0);
        !          19422:                        break;
        !          19423:                }
        !          19424:        }
        !          19425: 
        !          19426:        SFLOCK(f1);
        !          19427:        SFLOCK(f2);
        !          19428: 
        !          19429:        /* swap image */
        !          19430:        tmp = *f2; *f2 = *f1; *f1 = tmp;
        !          19431: 
        !          19432:        if(f1->pool != f2->pool)
        !          19433:        {       /* reset pool pointers */
        !          19434:                if(f1->pool)
        !          19435:                {       if(f1->back)
        !          19436:                                f1->back->fore = f1;
        !          19437:                        else    f1->pool->head = f1;
        !          19438:                        if(f1->fore)
        !          19439:                                f1->fore->back = f1;
        !          19440:                }
        !          19441:                if(f2->pool)
        !          19442:                {       if(f2->back)
        !          19443:                                f2->back->fore = f2;
        !          19444:                        else    f2->pool->head = f2;
        !          19445:                        if(f2->fore)
        !          19446:                                f2->fore->back = f2;
        !          19447:                }
        !          19448:        }
        !          19449: 
        !          19450:        if(f2->push != f2)
        !          19451:        {       /* freeze the pushed stream */
        !          19452:                f2->mode |= SF_PUSH;
        !          19453:                f2->flags &= ~(SF_GETC|SF_PUTC);
        !          19454:                f1->push = f2;
        !          19455:                rf = f1;
        !          19456:        }
        !          19457:        else
        !          19458:        {       /* unfreeze the just exposed stream */
        !          19459:                f1->mode &= ~SF_PUSH;
        !          19460:                SFopen(f1); sfset(f1,f1->flags,1);
        !          19461:                f2->push = NIL(Sfile_t*);
        !          19462:                rf = f2;
        !          19463:        }
        !          19464: 
        !          19465:        SFOPEN(f1);
        !          19466:        SFOPEN(f2);
        !          19467:        return rf;
        !          19468: }
        !          19469: 0707070000000003031006440044230044230000010000000471532054500003300000005004sfio/sfstrtod.cUgsfGgsf#include        "sfhdr.h"
        !          19470: 
        !          19471: /*     Convert a double value represented in an ASCII format into
        !          19472: **     the internal double representation.
        !          19473: **
        !          19474: **     Written by David Korn and Kiem-Phong Vo (06/27/90)
        !          19475: */
        !          19476: 
        !          19477: #ifdef NATIVE
        !          19478: int    _Sfstrtod;
        !          19479: #else
        !          19480: 
        !          19481: #define BATCH  (2*sizeof(int)) /* accumulate this many digits at a time */
        !          19482: #define IPART          0       /* doing integer part */
        !          19483: #define FPART          1       /* doing fractional part */
        !          19484: #define EPART          2       /* doing exponent part */
        !          19485: 
        !          19486: #if __STDC__ || __cplusplus
        !          19487: static double pow10(reg int n)
        !          19488: #else
        !          19489: static double pow10(n)
        !          19490: reg int        n;
        !          19491: #endif
        !          19492: {
        !          19493:        reg int         m, pow;
        !          19494:        reg double      dval, d, *pow10;
        !          19495: 
        !          19496:        /* set up look up table */
        !          19497:        if((pow = n) < 0)
        !          19498:        {
        !          19499:                pow10 = _Sfneg10;
        !          19500:                pow = -pow;
        !          19501:        }
        !          19502:        else    pow10 = _Sfpos10;
        !          19503: 
        !          19504:        /* reduce to a low exponent */
        !          19505:        dval = 1.;
        !          19506:        if(pow >= MAXPOW10)
        !          19507:        {       d = pow10[MAXEXP10-1]*pow10[MAXEXP10-1];        
        !          19508:                for(m = pow/MAXPOW10; m > 0; --m)
        !          19509:                        dval *= d;
        !          19510:                pow = pow%MAXPOW10;
        !          19511:        }
        !          19512: 
        !          19513:        /* fast loop for the rest */
        !          19514:        for(m = 1; m <= pow;)
        !          19515:        {
        !          19516:                if(m&pow)
        !          19517:                        dval *= *pow10;
        !          19518:                pow10 += 1;
        !          19519:                if(n < 0)
        !          19520:                        pow >>= 1;
        !          19521:                else    m <<= 1;
        !          19522:        }
        !          19523: 
        !          19524:        return dval;
        !          19525: }
        !          19526: 
        !          19527: #if __STDC__ || __cplusplus
        !          19528: double strtod(reg char* s, char** retp)
        !          19529: #else
        !          19530: double strtod(s,retp)
        !          19531: reg char       *s;     /* string to convert */
        !          19532: char           **retp; /* to return the remainder of string */
        !          19533: #endif
        !          19534: {
        !          19535:        reg int         n, c, m;
        !          19536:        reg double      dval;
        !          19537:        reg int         mode, fexp, sign, expsign;
        !          19538: 
        !          19539:        /* skip initial blanks */
        !          19540:        while(isspace(*s))
        !          19541:                ++s;
        !          19542: 
        !          19543:        /* get the sign */
        !          19544:        if((sign = (*s == '-')) || *s == '+')
        !          19545:                s += 1;
        !          19546: 
        !          19547:        mode = IPART;
        !          19548:        fexp = expsign = 0;
        !          19549:        dval = 0.;
        !          19550:        while(*s)
        !          19551:        {       /* accumulate a handful of the digits */
        !          19552:                for(m = BATCH, n = 0; m > 0; --m, ++s)
        !          19553:                {       /* get and process a char */
        !          19554:                        c = *s;
        !          19555:                        if(isdigit(c))
        !          19556:                                n = 10*n + (c - '0');
        !          19557:                        else    break;
        !          19558:                }
        !          19559: 
        !          19560:                /* number of digits accumulated */
        !          19561:                m = BATCH-m;
        !          19562: 
        !          19563:                if(mode == IPART)
        !          19564:                {       /* doing the integer part */
        !          19565:                        if(dval == 0.)
        !          19566:                                dval = (double)n;
        !          19567:                        else    dval = dval*pow10(m) + (double)n;
        !          19568:                }
        !          19569:                else if(mode == FPART)
        !          19570:                {       /* doing the fractional part */
        !          19571:                        fexp -= m;
        !          19572:                        if(n > 0)
        !          19573:                                dval += n*pow10(fexp);
        !          19574:                }
        !          19575:                else if(n)
        !          19576:                {       /* doing the exponent part */
        !          19577:                        if(expsign)
        !          19578:                                n = -n;
        !          19579:                        dval *= pow10(n);
        !          19580:                }
        !          19581: 
        !          19582:                if(!c)
        !          19583:                        break;
        !          19584: 
        !          19585:                if(m < BATCH)
        !          19586:                {       /* detected a non-digit */
        !          19587:                        if(c == '.')
        !          19588:                        {       /* start the fractional part or no match */
        !          19589:                                if(mode != IPART)
        !          19590:                                        break;
        !          19591:                                mode = FPART;
        !          19592:                                s += 1;
        !          19593:                        }
        !          19594:                        else if(c == 'e' || c == 'E')
        !          19595:                        {
        !          19596:                                if(mode == EPART)
        !          19597:                                        break;
        !          19598:                                mode = EPART;
        !          19599:                                c = *++s;
        !          19600:                                if((expsign = (c == '-')) || c == '+')
        !          19601:                                        s += 1;
        !          19602:                        }
        !          19603:                        else    break;
        !          19604:                }
        !          19605:        }
        !          19606: 
        !          19607:        if(retp)
        !          19608:                *retp = s;
        !          19609:        return sign ? -dval : dval;
        !          19610: }
        !          19611: 
        !          19612: #endif /* NATIVE */
        !          19613: 0707070000000003041006440044230044230000010000000473061527500003100000003471sfio/sfsync.cUgsfGgsf#include  "sfhdr.h"
        !          19614: 
        !          19615: static char    *Version = "\n@(#)sfio (AT&T Bell Laboratories) 12/07/90\0\n";
        !          19616: 
        !          19617: /*     Synchronize data in buffers with the file system.
        !          19618: **     If f is nil, all streams are sync-ed
        !          19619: **
        !          19620: **     Written by Kiem-Phong Vo (06/27/90)
        !          19621: */
        !          19622: 
        !          19623: #if __STDC__ || __cplusplus
        !          19624: _sfsync(reg Sfile_t* f)
        !          19625: #else
        !          19626: _sfsync(f)
        !          19627: reg Sfile_t    *f;     /* stream to be synchronized */
        !          19628: #endif
        !          19629: {
        !          19630:        reg int         n, rv, flag;
        !          19631: 
        !          19632:        if(!f)
        !          19633:        {       /* use recursion to handle the sync-all case */
        !          19634:                reg Sfpool_t    *p;
        !          19635: 
        !          19636:                rv = 0;
        !          19637:                for(p = &_Sfpool; p != NIL(Sfpool_t*); p = p->fore)
        !          19638:                        for(f = p->head; f != NIL(Sfile_t*); f = f->fore)
        !          19639:                        {       /* can't sync these */  
        !          19640:                                if(SFFROZEN(f))
        !          19641:                                        continue;
        !          19642: 
        !          19643:                                /* make sure pool list is not rearranged */
        !          19644:                                flag = f->mode&SF_POOL;
        !          19645:                                f->mode &= ~SF_POOL;
        !          19646:                                if(sfsync(f) < 0)
        !          19647:                                        rv = -1;
        !          19648:                                f->mode |= flag;
        !          19649:                        }
        !          19650:                return rv;
        !          19651:        }
        !          19652: 
        !          19653:        if(f->mode == 0 || (f->mode&SF_SYNC))
        !          19654:                return 0;
        !          19655: 
        !          19656:        if((f->mode&~(SF_RDWR|SF_STRING)) && _sfmode(f,0) < 0)
        !          19657:                return -1;
        !          19658: 
        !          19659:        rv = 0;
        !          19660:        for(; f; f = f->push)
        !          19661:        {       /* pretend that this stream is not on a stack */
        !          19662:                SFLOCK(f);
        !          19663:                flag = f->mode&SF_PUSH;
        !          19664:                f->mode &= ~SF_PUSH;
        !          19665: 
        !          19666:                if(f->mode&SF_WRITE)
        !          19667:                {       /* sync the buffer, make sure pool don't move */
        !          19668:                        SFopen(f);
        !          19669:                        flag = f->mode&SF_POOL;
        !          19670:                        f->mode &= ~SF_POOL;
        !          19671:                        if(_sfflsbuf(f,-1) < 0)
        !          19672:                                rv = -1;
        !          19673:                        f->mode |= flag;
        !          19674:                        SFLOCK(f);
        !          19675:                }
        !          19676:                else if((f->mode&SF_READ) && !(f->flags&SF_SHARE) &&
        !          19677:                        f->orig >= 0 && (n = f->endb-f->next) > 0)
        !          19678:                {       /* make sure the file pointer is at the right place */
        !          19679:                        reg long        (*seekf)_SFA_((Sfile_t*,long,int,char*));
        !          19680:                        reg char        *handle;
        !          19681: 
        !          19682:                        f->mode = SF_SYNC|SF_LOCK;
        !          19683:                        seekf = f->disc ? f->disc->seekf :
        !          19684:                                        NIL(long(*)_SFA_((Sfile_t*,long,int,char*)));
        !          19685:                        handle = f->disc ? f->disc->handle : NIL(char*);
        !          19686:                        f->here -= n;
        !          19687:                        if(SEEKF(seekf,f,f->here,0,handle) < 0)
        !          19688:                                rv = -1;
        !          19689:                }
        !          19690: 
        !          19691:                f->mode |= flag;
        !          19692:                SFOPEN(f);
        !          19693:        }
        !          19694: 
        !          19695:        return rv;
        !          19696: }
        !          19697: 0707070000000003051006440044230044230000010000000471442321200003200000002404sfio/sftable.cUgsfGgsf#include "sfhdr.h"
        !          19698: 
        !          19699: /* tables to aid fast look-up of powers of ten */
        !          19700: double _Sfpos10[MAXEXP10] =
        !          19701: {
        !          19702:        1e1, 1e2, 1e4, 1e8, 1e16, 1e32
        !          19703: };
        !          19704: double _Sfneg10[MAXEXP10] =
        !          19705: {
        !          19706:        1e-1, 1e-2, 1e-4, 1e-8, 1e-16, 1e-32
        !          19707: };
        !          19708: 
        !          19709: /* codes for digits of numbers in the range [0-100) */
        !          19710: uchar  _Sfdec[] =
        !          19711: {
        !          19712: (0<<4)|0, (0<<4)|1, (0<<4)|2, (0<<4)|3, (0<<4)|4,
        !          19713: (0<<4)|5, (0<<4)|6, (0<<4)|7, (0<<4)|8, (0<<4)|9,
        !          19714: (1<<4)|0, (1<<4)|1, (1<<4)|2, (1<<4)|3, (1<<4)|4,
        !          19715: (1<<4)|5, (1<<4)|6, (1<<4)|7, (1<<4)|8, (1<<4)|9,
        !          19716: (2<<4)|0, (2<<4)|1, (2<<4)|2, (2<<4)|3, (2<<4)|4,
        !          19717: (2<<4)|5, (2<<4)|6, (2<<4)|7, (2<<4)|8, (2<<4)|9,
        !          19718: (3<<4)|0, (3<<4)|1, (3<<4)|2, (3<<4)|3, (3<<4)|4,
        !          19719: (3<<4)|5, (3<<4)|6, (3<<4)|7, (3<<4)|8, (3<<4)|9,
        !          19720: (4<<4)|0, (4<<4)|1, (4<<4)|2, (4<<4)|3, (4<<4)|4,
        !          19721: (4<<4)|5, (4<<4)|6, (4<<4)|7, (4<<4)|8, (4<<4)|9,
        !          19722: (5<<4)|0, (5<<4)|1, (5<<4)|2, (5<<4)|3, (5<<4)|4,
        !          19723: (5<<4)|5, (5<<4)|6, (5<<4)|7, (5<<4)|8, (5<<4)|9,
        !          19724: (6<<4)|0, (6<<4)|1, (6<<4)|2, (6<<4)|3, (6<<4)|4,
        !          19725: (6<<4)|5, (6<<4)|6, (6<<4)|7, (6<<4)|8, (6<<4)|9,
        !          19726: (7<<4)|0, (7<<4)|1, (7<<4)|2, (7<<4)|3, (7<<4)|4,
        !          19727: (7<<4)|5, (7<<4)|6, (7<<4)|7, (7<<4)|8, (7<<4)|9,
        !          19728: (8<<4)|0, (8<<4)|1, (8<<4)|2, (8<<4)|3, (8<<4)|4,
        !          19729: (8<<4)|5, (8<<4)|6, (8<<4)|7, (8<<4)|8, (8<<4)|9,
        !          19730: (9<<4)|0, (9<<4)|1, (9<<4)|2, (9<<4)|3, (9<<4)|4,
        !          19731: (9<<4)|5, (9<<4)|6, (9<<4)|7, (9<<4)|8, (9<<4)|9,
        !          19732: };
        !          19733: 0707070000000003061006440044230044230000010000000471532062000003100000001222sfio/sftell.cUgsfGgsf#include  "sfhdr.h"
        !          19734: 
        !          19735: /*     Tell the current location in a given stream
        !          19736: **
        !          19737: **     Written by Kiem-Phong Vo (06/27/90)
        !          19738: */
        !          19739: 
        !          19740: #if __STDC__ || __cplusplus
        !          19741: long sftell(reg Sfile_t* f)
        !          19742: #else
        !          19743: long sftell(f)
        !          19744: reg Sfile_t    *f;
        !          19745: #endif
        !          19746: {      
        !          19747:        reg long        here;
        !          19748: 
        !          19749:        /* set the stream to the right mode */
        !          19750:        if((!f->mode || (f->mode&~(SF_RDWR|SF_STRING))) && _sfmode(f,0) < 0)
        !          19751:                return -1;
        !          19752: 
        !          19753:        if(f->mode&SF_STRING)
        !          19754:                return (long)(f->next-f->data);
        !          19755: 
        !          19756:        /* let sfseek() handle the hard case */
        !          19757:        if(f->orig >= 0 && (f->flags&(SF_SHARE|SF_APPEND)))
        !          19758:                return sfseek(f,0L,1);
        !          19759: 
        !          19760:        here = f->here + ((f->mode&SF_WRITE) ? f->next-f->data : f->next-f->endb);
        !          19761:        return here - (f->orig > 0 ? f->orig : 0L);
        !          19762: }
        !          19763: 0707070000000003071006440044230044230000010000000474537763700003400000003635sfio/sftmpfile.cUgsfGgsf#include       "sfhdr.h"
        !          19764: #ifndef F_SETFD
        !          19765: #ifndef FIOCLEX
        !          19766: #ifdef V9
        !          19767: #include       <sys/filio.h>
        !          19768: #endif /*V9*/
        !          19769: #endif /*FIOCLEX*/
        !          19770: #endif /*F_SETFD*/
        !          19771: 
        !          19772: 
        !          19773: /*     Create a temporary stream for read/write.
        !          19774: **     The stream is originally created as a memory-resident stream.
        !          19775: **     When this memory is exceeded, a real temp file will be created.
        !          19776: **     The temp file creation sequence is somewhat convoluted so that
        !          19777: **     pool/stack/discipline will work correctly.
        !          19778: **
        !          19779: **     Written by David Korn and Kiem-Phong Vo (12/10/90)
        !          19780: */
        !          19781: 
        !          19782: #if __STDC__ || __cplusplus
        !          19783: static _tmpexcept(Sfile_t* f, int type, char* hdl)
        !          19784: #else
        !          19785: static _tmpexcept(f,type,hdl)
        !          19786: Sfile_t        *f;
        !          19787: int    type;
        !          19788: char   *hdl;
        !          19789: #endif
        !          19790: {
        !          19791:        reg int         here, extent;
        !          19792:        Sfile_t         newf;
        !          19793: 
        !          19794:        /* do nothing cases */
        !          19795:        if(type == SF_EOF || type == SF_READ)
        !          19796:                return 0;
        !          19797: 
        !          19798:        /* get the extent of current data */
        !          19799:        here = extent = f->next-f->data;
        !          19800:        if(extent < f->here)
        !          19801:                extent = (int)(f->here);
        !          19802: 
        !          19803:        /* try to create the temp file */
        !          19804:        SFCLEAR(&newf);
        !          19805:        hdl = mktemp("/tmp/sfXXXXXXXX");
        !          19806:        if(!sfopen(&newf,hdl,"w+"))
        !          19807:                return -1;
        !          19808: 
        !          19809:        /* remove the temp file and set close-on-exec */
        !          19810:        while(unlink(hdl) < 0 && errno == EINTR)
        !          19811:                errno = 0;
        !          19812: #ifdef F_SETFD
        !          19813:        (void)fcntl(newf.file,F_SETFD,0);
        !          19814: #else
        !          19815: #ifdef FIOCLEX
        !          19816:        (void)ioctl(newf.file,FIOCLEX,0);
        !          19817: #endif
        !          19818: #endif
        !          19819: 
        !          19820:        /* now remake the old stream into the new image */
        !          19821:        f->disc = NIL(Sfdisc_t*);
        !          19822:        if(!sfnew(f,NIL(uchar*),-1,newf.file,SF_READ|SF_WRITE))
        !          19823:        {       while(close(newf.file) < 0 && errno == EINTR)
        !          19824:                        errno = 0;
        !          19825:                return -1;
        !          19826:        }
        !          19827:        (void)sfwrite(f,f->data,extent);
        !          19828:        (void)sfseek(f,(long)here,0);
        !          19829: 
        !          19830:        return 1;
        !          19831: }
        !          19832: 
        !          19833: #if __STDC__ || __cplusplus
        !          19834: Sfile_t* _sftmpfile(int s)
        !          19835: #else
        !          19836: Sfile_t* _sftmpfile(s)
        !          19837: int    s;
        !          19838: #endif
        !          19839: {
        !          19840:        reg Sfile_t     *f;
        !          19841:        static Sfdisc_t Tmpdisc;
        !          19842: 
        !          19843:        /* make this a memory resident stream at first */
        !          19844:        if(!(f = sfnew(NIL(Sfile_t*),NIL(uchar*),s,-1,SF_STRING|SF_READ|SF_WRITE)))
        !          19845:                return NIL(Sfile_t*);
        !          19846: 
        !          19847:        /* set up a discipline for out-of-bound, etc. */
        !          19848:        Tmpdisc.exceptf = _tmpexcept;
        !          19849:        sfsetdisc(f,&Tmpdisc);
        !          19850:        return f;
        !          19851: }
        !          19852: 0707070000000003101006440044230044230000010000000471532064700003300000001215sfio/sfungetc.cUgsfGgsf#include        "sfhdr.h"
        !          19853: 
        !          19854: /*     Push back one byte to a given SF_READ stream
        !          19855: **
        !          19856: **     Written by Kiem-Phong Vo (06/27/90)
        !          19857: */
        !          19858: 
        !          19859: #if __STDC__ || __cplusplus
        !          19860: sfungetc(reg Sfile_t* f, reg int c)
        !          19861: #else
        !          19862: sfungetc(f,c)
        !          19863: reg Sfile_t    *f;     /* push back one byte to this stream */
        !          19864: reg int                c;      /* the value to be pushed back */
        !          19865: #endif
        !          19866: {
        !          19867:        reg uchar       *cp;
        !          19868: 
        !          19869:        if(c < 0 || (f->mode != SF_READ && SFMODE(f,SF_READ) < 0) || f->next <= f->data)
        !          19870:                return -1;
        !          19871: 
        !          19872:        SFLOCK(f);
        !          19873:        if(*(cp = --f->next) != (uchar)c)
        !          19874:        {
        !          19875:                if((f->flags&SF_STRING) && !(f->flags&SF_WRITE))
        !          19876:                {       /* avoid writing into a constant string */
        !          19877:                        f->next += 1;
        !          19878:                        c = -1;
        !          19879:                }
        !          19880:                else    *cp = (uchar)c;
        !          19881:        }
        !          19882:        SFOPEN(f);
        !          19883:        return c;
        !          19884: }
        !          19885: 0707070000000003111006440044230044230000010000000475116762500003400000030047sfio/sfvprintf.cUgsfGgsf#include       "sfhdr.h"
        !          19886: 
        !          19887: /*     The engine for formatting data
        !          19888: **
        !          19889: **     Written by Kiem-Phong Vo (06/27/90)
        !          19890: */
        !          19891: 
        !          19892: #define HIGHBIT                (~(((ulong)~0L) >> 1))
        !          19893: 
        !          19894: #define F_LEFT         00001   /* left justification (-) */
        !          19895: #define F_SIGN         00002   /* must set a sign - or + */
        !          19896: #define F_BLANK                00004   /* if not - and +, then prepend a blank */
        !          19897: #define F_ZERO         00010   /* zero padding on the left side */
        !          19898: #define F_ALTER                00020   /* various alternative formats (#) */
        !          19899: #define F_PAD          00040   /* some kind of padding is needed */
        !          19900: 
        !          19901: #define F_REPEAT       00100   /* repeat the pattern until precision is exhausted */
        !          19902: #define F_0X           00200   /* must add a zero for prefix of hex format */
        !          19903: #define F_MINUS                00400   /* has a minus sign */
        !          19904: #define F_PREFIX       (F_MINUS|F_SIGN|F_BLANK|F_0X)
        !          19905: 
        !          19906: #define F_LONG         01000   /* object is long */
        !          19907: #define F_FLOAT                02000   /* %fFeEgG format */
        !          19908: #define F_GFORMAT      04000   /* a %gG format */
        !          19909: 
        !          19910: #define FPRECIS                6       /* default precision for floats */
        !          19911: 
        !          19912: #define GETARG(elt,arge,argf,args,type,fmt) \
        !          19913:        { if(!argf) \
        !          19914:                elt = va_arg(args,type); \
        !          19915:          else if((*argf)(fmt,(char*)(&arge)) < 0) \
        !          19916:                goto pop_fa; \
        !          19917:          else  elt = arge; \
        !          19918:        }
        !          19919: 
        !          19920: #if __STDC__ || __cplusplus
        !          19921: sfvprintf(Sfile_t* f, const char* form, va_list args)
        !          19922: #else
        !          19923: sfvprintf(f,form,args)
        !          19924: Sfile_t        *f;             /* file to print to */
        !          19925: char   *form;          /* format to use */
        !          19926: va_list        args;           /* arg list if argf == 0 */
        !          19927: #endif
        !          19928: {
        !          19929:        reg long        n, lval;
        !          19930:        reg char        *sp, *ssp, *d;
        !          19931:        reg long        v;
        !          19932:        reg int         flags;
        !          19933:        reg char        *ep, *endep, *endsp, *endd;
        !          19934:        reg int         precis, width, n_output, r;
        !          19935:        int             fmt, sign, decpt;
        !          19936:        double          dval;
        !          19937:        long            al;
        !          19938:        int             ai, *ap;
        !          19939:        char            *as;
        !          19940:        Argf_p          argf;
        !          19941:        Extf_p          extf;
        !          19942:        va_list         alist;
        !          19943:        reg Fa_t        *fa, *fast;
        !          19944:        char            buf[MAXDIGITS];
        !          19945:        char            data[SF_GRAIN];
        !          19946: 
        !          19947:        /* fast io system */
        !          19948: #define SFflush(f,c)   (SFopen(f), r = _sfflsbuf(f,(int)c), SFLOCK(f), r)
        !          19949: #define SFwrite(f,s,n) (SFopen(f), r = sfwrite(f,(uchar*)s,(int)n), SFLOCK(f), r)
        !          19950: #define SFnputc(f,c,n) (SFopen(f), r = sfnputc(f,(uchar)c,(int)n), SFLOCK(f), r)
        !          19951: #define SFSET(f)       (d = (char*)f->next, endd = (char*)f->endb)
        !          19952: #define SFINIT(f)      (SFSET(f), n_output = 0)
        !          19953: #define SFEND(f)       ((n_output += (uchar*)d - f->next), (f->next = (uchar*)d))
        !          19954: #define SFPUTC(f,c) \
        !          19955:        { if(d >= endd) \
        !          19956:                { SFEND(f); if(SFflush(f,c) <  0) break; n_output += 1; SFSET(f); } \
        !          19957:          else  { *d++ = (char)c; } \
        !          19958:        }
        !          19959: #define SFNPUTC(f,c,n) \
        !          19960:        { if((endd-d) < n) \
        !          19961:                { SFEND(f); if(SFnputc(f,c,n) != n) break; n_output += (int)n; SFSET(f); } \
        !          19962:          else  { while(n--) *d++ = (char)c; } \
        !          19963:        }
        !          19964: #define SFWRITE(f,s,n) \
        !          19965:        { if((endd-d) < n) \
        !          19966:                { SFEND(f); if(SFwrite(f,s,n) != n) break; n_output += (int)n; SFSET(f); } \
        !          19967:          else  MEMCPY(d,s,(int)n); \
        !          19968:        }
        !          19969: 
        !          19970:        /* make sure stream is in write mode and buffer is not NULL */
        !          19971:        if(f->mode != SF_WRITE && SFMODE(f,SF_WRITE) < 0)
        !          19972:                return -1;
        !          19973: 
        !          19974:        SFLOCK(f);
        !          19975: 
        !          19976:        if(f->data == NIL(uchar*))
        !          19977:        {       f->data = f->next = (uchar*)data;
        !          19978:                f->endw = f->endb = f->data+sizeof(data);
        !          19979:        }
        !          19980:        SFINIT(f);
        !          19981: 
        !          19982:        argf = NIL(Argf_p);
        !          19983:        extf = NIL(Extf_p);
        !          19984:        fast = NIL(Fa_t*);
        !          19985: 
        !          19986: loop_fa :
        !          19987:        while(n = *form++)
        !          19988:        {
        !          19989:                flags = 0;
        !          19990:                if(n != '%')
        !          19991:                {       /* collect the non-pattern chars */
        !          19992:                        sp = ssp = (char*)(form-1);
        !          19993:                        while((n = *++ssp) && n != '%')
        !          19994:                                ;
        !          19995:                        form = endsp = ssp;
        !          19996:                        goto do_output;
        !          19997:                }
        !          19998: 
        !          19999:                endep = ep = NIL(char*);
        !          20000:                endsp = sp = buf+(sizeof(buf)-1);
        !          20001:                width = precis = -1;
        !          20002: 
        !          20003:        loop_flags:     /* LOOP FOR FLAGS, WIDTH AND PRECISION */
        !          20004:                switch(fmt = *form++)
        !          20005:                {
        !          20006:                case '-' :
        !          20007:                        flags |= F_LEFT;
        !          20008:                        goto loop_flags;
        !          20009:                case ' ' :
        !          20010:                        flags |= F_BLANK;
        !          20011:                        goto loop_flags;
        !          20012:                case '+' :
        !          20013:                        flags |= F_SIGN;
        !          20014:                        goto loop_flags;
        !          20015:                case '#' :
        !          20016:                        flags |= F_ALTER;
        !          20017:                        goto loop_flags;
        !          20018:                case '.' :      /* done with width */
        !          20019:                        if(width < 0)
        !          20020:                                width = 0;
        !          20021:                        goto loop_flags;
        !          20022:                case '*' :      /* variable width or precision */
        !          20023:                        GETARG(lval,ai,argf,args,int,'d');
        !          20024:                        if(width >= 0)
        !          20025:                                precis = (int)lval;
        !          20026:                        else if((width = (int)lval) < 0)
        !          20027:                        {       /* left justification */
        !          20028:                                width = (int)(-lval);
        !          20029:                                flags |= F_LEFT;
        !          20030:                        }
        !          20031:                        flags |= F_PAD;
        !          20032:                        goto loop_flags;
        !          20033:                case '0' :      /* defining width or precision */
        !          20034:                        if(width < 0)
        !          20035:                                flags |= F_ZERO;
        !          20036:                        /* fall thru */
        !          20037:                case '1' : case '2' : case '3' :
        !          20038:                case '4' : case '5' : case '6' :
        !          20039:                case '7' : case '8' : case '9' :
        !          20040:                        lval = fmt - '0';
        !          20041:                        for(n = *form; isdigit(n); n = *++form)
        !          20042:                                lval = lval*10 + (n - '0');
        !          20043:                        if(width < 0)
        !          20044:                                width = (int)lval;
        !          20045:                        else    precis = (int)lval;
        !          20046:                        flags |= F_PAD;
        !          20047:                        goto loop_flags;
        !          20048:                case 'l' :
        !          20049:                        flags |= F_LONG;
        !          20050:                case 'h' : /* no short */
        !          20051:                        goto loop_flags;
        !          20052: 
        !          20053:                        /* PRINTF DIRECTIVES */
        !          20054: 
        !          20055:                case '&' : /* change extension function */
        !          20056:                        if(!argf)
        !          20057:                                extf = va_arg(args,Extf_p);
        !          20058:                        else if((*argf)('&',(char*)(&extf)) < 0)
        !          20059:                                goto pop_fa;
        !          20060:                        continue;
        !          20061:                case '@' : /* change argument getting function */
        !          20062:                        if(!argf)
        !          20063:                                argf = va_arg(args,Argf_p);
        !          20064:                        else if((*argf)('@',(char*)(&argf)) < 0)
        !          20065:                                goto pop_fa;
        !          20066:                        continue;
        !          20067:                case ':' : /* stack a pair of format/arglist */
        !          20068:                        if(!FAMALLOC(fa))
        !          20069:                                goto done;
        !          20070:                        fa->form = (char*)form;
        !          20071:                        GETARG(form,form,argf,args,char*,'1');
        !          20072:                        if(!form)
        !          20073:                                form = "";
        !          20074:                        GETARG(alist,alist,argf,args,va_list,'2');
        !          20075:                        fa->args = args;
        !          20076:                        fa->argf.p = argf;
        !          20077:                        fa->extf.p = extf;
        !          20078:                        args = alist;
        !          20079:                        fa->next = fast;
        !          20080:                        fast = fa;
        !          20081:                        continue;
        !          20082: 
        !          20083:                default :       /* unknown directive */
        !          20084:                        if(extf)
        !          20085:                        {       /* call the extension function */
        !          20086:                                GETARG(sp,as,argf,args,char*,fmt);
        !          20087:                                n = (*extf)(sp,fmt,precis,(char*)(&as));
        !          20088:                                if((sp = as) != NIL(char*))
        !          20089:                                        goto s_format;
        !          20090:                        }
        !          20091: 
        !          20092:                        /* treat as text */
        !          20093:                        form -= 1;
        !          20094:                        continue;
        !          20095: 
        !          20096:                case 's':       /* a string */
        !          20097:                        GETARG(sp,as,argf,args,char*,'s');
        !          20098:                        n = -1;
        !          20099:                        if(!sp)
        !          20100:                        {       /* standard error string for null pointer */
        !          20101:                                endsp = (sp = "(null)") + 6;
        !          20102:                                flags = 0;
        !          20103:                        }
        !          20104:                        else
        !          20105:                        {       /* set other bound */
        !          20106:                        s_format:
        !          20107:                                if(n < 0)
        !          20108:                                {       ssp = sp-1;
        !          20109:                                        while(*++ssp)
        !          20110:                                                ;
        !          20111:                                        n = ssp-sp;
        !          20112:                                }
        !          20113:                                if(precis >= 0 && precis < n)
        !          20114:                                        n = precis;
        !          20115:                                endsp = sp+n;
        !          20116:                        }
        !          20117:                        flags &= ~(F_SIGN|F_BLANK|F_ALTER);
        !          20118:                        precis = 0;
        !          20119:                        break;
        !          20120: 
        !          20121:                case 'n':       /* return current output length */
        !          20122:                        GETARG(ap,ap,argf,args,int*,'n');
        !          20123:                        SFEND(f);
        !          20124:                        *ap = n_output;
        !          20125:                        continue;
        !          20126:                case 'c':       /* a character */
        !          20127:                        GETARG(fmt,fmt,argf,args,int,'d');
        !          20128:                case '%' :
        !          20129:                        flags = (flags&~(F_SIGN|F_BLANK|F_ZERO))|F_REPEAT;
        !          20130:                        if(precis <= 0)
        !          20131:                                precis = 1;
        !          20132:                        break;
        !          20133:                case 'i':       /* signed integer */
        !          20134:                case 'd':
        !          20135:                        if(flags&F_LONG)
        !          20136:                                { GETARG(lval,al,argf,args,long,'D'); }
        !          20137:                        else    { GETARG(lval,ai,argf,args,int,'d');  }
        !          20138:                        if(lval < 0)
        !          20139:                        {
        !          20140:                                flags |= F_MINUS;
        !          20141:                                if(lval == HIGHBIT)
        !          20142:                                {       /* avoid overflow */
        !          20143:                                        lval = ((ulong)HIGHBIT)/10;
        !          20144:                                        *--sp = (char)('0' +
        !          20145:                                                       ((ulong)HIGHBIT -
        !          20146:                                                        (((ulong)HIGHBIT)/10)*10));
        !          20147:                                }
        !          20148:                                else    lval = -lval;
        !          20149:                        }
        !          20150:                        goto base_10;
        !          20151:                case 'p':       /* pointer value */
        !          20152:                        GETARG(ssp,as,argf,args,char*,'p');
        !          20153:                        lval = (long)ssp;
        !          20154:                        flags = (flags&~(F_SIGN|F_BLANK))|F_ALTER;
        !          20155:                        fmt = 'x';
        !          20156:                        goto base_16;
        !          20157:                case 'u':       /* unsigned value */
        !          20158:                case 'o':
        !          20159:                case 'x':
        !          20160:                case 'X':
        !          20161:                        if(flags&F_LONG)
        !          20162:                                { GETARG(lval,al,argf,args,long,'D'); }
        !          20163:                        else    { GETARG(lval,ai,argf,args,int,'d');  }
        !          20164:                        flags &= ~(F_SIGN|F_BLANK);
        !          20165:                        if(fmt == 'o')
        !          20166:                        {       /* base 8 conversion */
        !          20167:                                do      { *--sp = (char)('0' + (lval&07)); }
        !          20168:                                while(lval = (ulong)lval >> 3);
        !          20169:                                if((flags&F_ALTER) && *sp != '0')
        !          20170:                                        *--sp = '0';
        !          20171:                        }
        !          20172:                        else if(fmt == 'u')
        !          20173:                        {       /* base 10 unsigned conversion */
        !          20174:                        base_10:
        !          20175:                                sfucvt(lval,sp,n,v,ssp);
        !          20176:                        }
        !          20177:                        else
        !          20178:                        {       /* base 16 conversion */
        !          20179:                        base_16:
        !          20180:                                if((flags&F_ALTER) && lval)
        !          20181:                                        flags |= F_0X;
        !          20182:                                ssp = fmt == 'X' ? "0123456789ABCDEF":"0123456789abcdef";
        !          20183:                                do
        !          20184:                                {        *--sp = ssp[lval&017];
        !          20185:                                } while(lval = ((ulong)lval) >> 4);
        !          20186:                        }
        !          20187:                        precis -= (endsp-sp);
        !          20188:                        break;
        !          20189:                case 'g':       /* ultimately becomes %e or %f */
        !          20190:                case 'G':
        !          20191:                        GETARG(dval,dval,argf,args,double,'F');
        !          20192:                        precis = precis < 0 ? FPRECIS : precis == 0 ? 1 : precis;
        !          20193:                        ep = sfecvt(dval,min(precis,FDIGITS),&decpt,&sign);
        !          20194:                        if(dval == 0.)
        !          20195:                                decpt = 1;
        !          20196:                        else if(*ep == 'I')
        !          20197:                                goto infinite;
        !          20198: 
        !          20199:                        if(!(flags&F_ALTER))
        !          20200:                        {       /* zap trailing 0s */
        !          20201:                                if((n = sfslen()) > precis)
        !          20202:                                        n = precis;
        !          20203:                                while((n -= 1) >= 1 && ep[n] == '0')
        !          20204:                                        ;
        !          20205:                                n += 1;
        !          20206:                        }
        !          20207:                        else    n = precis;
        !          20208: 
        !          20209:                        flags = (flags & ~F_ZERO) | F_GFORMAT;
        !          20210:                        if(decpt < -3 || decpt > precis)
        !          20211:                        {
        !          20212:                                precis = (int)(n-1);
        !          20213:                                goto e_format;
        !          20214:                        }
        !          20215:                        else
        !          20216:                        {
        !          20217:                                precis = (int)(n - decpt);
        !          20218:                                goto f_format;
        !          20219:                        }
        !          20220:                case 'e':       /* double value in scientific notation */
        !          20221:                case 'E':
        !          20222:                        /* convert data into ascii */
        !          20223:                        GETARG(dval,dval,argf,args,double,'F');
        !          20224:                        n = (precis = precis < 0 ? FPRECIS : precis)+1;
        !          20225:                        ep = sfecvt(dval,(int)min(n,FDIGITS),&decpt,&sign);
        !          20226: 
        !          20227:                e_format: /* now build the x.yyyy string */
        !          20228:                        if(isalpha(*ep))
        !          20229:                                goto infinite;
        !          20230:                        sp = endsp = buf+1;     /* reserve space for sign */
        !          20231:                        *endsp++ = *ep ? *ep++ : '0';
        !          20232: 
        !          20233:                        if(precis > 0 || (flags&F_ALTER))
        !          20234:                                *endsp++ = '.';
        !          20235:                        ssp = endsp;
        !          20236:                        endep = ep+precis;
        !          20237:                        while((*endsp++ = *ep++) && ep <= endep)
        !          20238:                                ;
        !          20239:                        precis -= (endsp -= 1) - ssp;
        !          20240: 
        !          20241:                        /* build the exponent */
        !          20242:                        ep = endep = buf+(sizeof(buf)-1);
        !          20243:                        if(dval != 0.)
        !          20244:                        {
        !          20245:                                if((n = decpt - 1) < 0)
        !          20246:                                        n = -n;
        !          20247:                                while(n > 9)
        !          20248:                                {       lval = n; n /= 10;      
        !          20249:                                        *--ep = (char)('0' + (lval - n*10));
        !          20250:                                }
        !          20251:                        }
        !          20252:                        else    n = 0;
        !          20253:                        *--ep = (char)('0' + n);
        !          20254:                        if(endep-ep <= 1)       /* at least 2 digits */
        !          20255:                                *--ep = '0';
        !          20256: 
        !          20257:                        /* the e/Exponent separator and sign */
        !          20258:                        *--ep = (decpt > 0 || dval == 0.) ? '+' : '-';
        !          20259:                        *--ep = isupper(fmt) ? 'E' : 'e';
        !          20260: 
        !          20261:                        flags = (flags&~F_ZERO)|F_FLOAT;
        !          20262:                        goto end_efg;
        !          20263:                case 'f':       /* float or double in xxx.yyy notation */
        !          20264:                case 'F':
        !          20265:                        GETARG(dval,dval,argf,args,double,'F');
        !          20266:                        precis = precis < 0 ? FPRECIS : precis;
        !          20267:                        ep = sffcvt(dval,min(precis,FDIGITS),&decpt,&sign);
        !          20268: 
        !          20269:                f_format: /* data before the '.' */
        !          20270:                        if(isalpha(*ep))
        !          20271:                        {
        !          20272:                        infinite:
        !          20273:                                endsp = (sp = ep)+sfslen();
        !          20274:                                ep = endep;
        !          20275:                                precis = 0;
        !          20276:                                goto end_efg;
        !          20277:                        }
        !          20278: 
        !          20279:                        endsp = sp = buf+1;     /* save a space for sign */
        !          20280:                        endep = ep+decpt;
        !          20281:                        while(ep < endep && (*endsp++ = *ep++))
        !          20282:                                ;
        !          20283:                        if(endsp == sp)
        !          20284:                                *endsp++ = '0';
        !          20285: 
        !          20286:                        if(precis > 0 || (flags&F_ALTER))
        !          20287:                                *endsp++ = '.';
        !          20288: 
        !          20289:                        if((n = -decpt) > 0)
        !          20290:                        {       /* output zeros for negative exponent */
        !          20291:                                ssp = endsp + min(n,precis);
        !          20292:                                precis -= (int)n;
        !          20293:                                while(endsp < ssp)
        !          20294:                                        *endsp++ = '0';
        !          20295:                        }
        !          20296: 
        !          20297:                        ssp = endsp;
        !          20298:                        endep = ep+precis;
        !          20299:                        while((*endsp++ = *ep++) && ep <= endep)
        !          20300:                                ;
        !          20301:                        precis -= (endsp -= 1) - ssp;
        !          20302:                        ep = endep;
        !          20303:                        flags |= F_FLOAT;
        !          20304:                end_efg:
        !          20305:                        if(sign)
        !          20306:                        {       /* if a %gG, output the sign now */
        !          20307:                                if(flags&F_GFORMAT)
        !          20308:                                        *--sp = '-';
        !          20309:                                else    flags |= F_MINUS;
        !          20310:                        }
        !          20311:                        break;
        !          20312:                }
        !          20313: 
        !          20314:                if(!flags)
        !          20315:                        goto do_output;
        !          20316:                else if(flags&(F_MINUS|F_SIGN|F_BLANK))
        !          20317:                        fmt = (flags&F_MINUS) ? '-' : (flags&F_SIGN) ? '+' : ' ';
        !          20318: 
        !          20319:                n = (endsp-sp) + (endep-ep) + (precis <= 0 ? 0 : precis) +
        !          20320:                    ((flags&F_0X) ? 2 : (flags&F_PREFIX) ? 1 : 0);
        !          20321:                if((lval = width-n) > 0)
        !          20322:                {       /* check for padding */
        !          20323:                        if(!(flags&F_ZERO))
        !          20324:                        {       /* right padding */
        !          20325:                                if(flags&F_LEFT)
        !          20326:                                        lval = -lval;
        !          20327:                                else if(flags&F_PREFIX)
        !          20328:                                {       /* blank padding, output prefix now */
        !          20329:                                        *--sp = fmt;
        !          20330:                                        if((flags&F_0X))
        !          20331:                                                *--sp = '0';
        !          20332:                                        flags &= ~F_PREFIX;
        !          20333:                                }
        !          20334:                        }
        !          20335:                }
        !          20336:                else    lval = 0;
        !          20337: 
        !          20338:                if(flags&F_PREFIX)
        !          20339:                {       /* output prefix */
        !          20340:                        if(flags&F_0X)
        !          20341:                                SFPUTC(f,'0');
        !          20342:                        SFPUTC(f,fmt);
        !          20343:                        if(fmt != ' ')
        !          20344:                                flags |= F_ZERO;
        !          20345:                }
        !          20346: 
        !          20347:                if((n = lval) > 0)
        !          20348:                {       /* left padding */
        !          20349:                        v = (flags&F_ZERO) ? '0' : ' ';
        !          20350:                        SFNPUTC(f,v,n);
        !          20351:                }
        !          20352: 
        !          20353:                if((n = precis) > 0 && ((flags&F_REPEAT) || !(flags&F_FLOAT)))
        !          20354:                {       /* repeated chars or padding for integer precision */
        !          20355:                        v = (flags&F_REPEAT) ? fmt : '0';
        !          20356:                        SFNPUTC(f,v,n);
        !          20357:                        precis = 0;
        !          20358:                }
        !          20359: 
        !          20360:        do_output:
        !          20361:                if((n = endsp-sp) > 0)
        !          20362:                        SFWRITE(f,sp,n);
        !          20363: 
        !          20364:                if(flags&(F_FLOAT|F_LEFT))
        !          20365:                {       /* F_FLOAT: right padding for float precision */
        !          20366:                        if((n = precis) > 0)
        !          20367:                                SFNPUTC(f,'0',n);
        !          20368: 
        !          20369:                        /* F_FLOAT: the exponent of %eE */
        !          20370:                        if((n = endep-(sp=ep)) > 0)
        !          20371:                                SFWRITE(f,sp,n);
        !          20372: 
        !          20373:                        /* F_LEFT: right padding */
        !          20374:                        if((n = -lval) > 0)
        !          20375:                                SFNPUTC(f,' ',n);
        !          20376:                }
        !          20377:        }
        !          20378: 
        !          20379: pop_fa:        if(fa = fast)
        !          20380:        {       /* pop the format stack and continue */
        !          20381:                form = fa->form;
        !          20382:                args = fa->args;
        !          20383:                argf = fa->argf.p;
        !          20384:                extf = fa->extf.p;
        !          20385:                fast = fa->next;
        !          20386:                FAFREE(fa);
        !          20387:                goto loop_fa;
        !          20388:        }
        !          20389: 
        !          20390: done:
        !          20391:        SFEND(f);
        !          20392: 
        !          20393:        r = f->next - f->data;
        !          20394:        if((d = (char*)f->data) == data)
        !          20395:                f->data = NIL(uchar*);
        !          20396:        f->next = f->data;
        !          20397:        f->endw = f->endb = f->data+f->size;
        !          20398: 
        !          20399:        if(r > 0 && (d == data || ((f->flags&SF_LINE) && !(f->flags&SF_STRING))))
        !          20400:        {       SFopen(f);
        !          20401:                (void) sfwrite(f,(uchar*)d,r);
        !          20402:        }
        !          20403:        else    f->next += r;
        !          20404: 
        !          20405:        SFOPEN(f);
        !          20406:        return n_output;
        !          20407: }
        !          20408: 0707070000000003121006440044230044230000010000000475157210100003300000022010sfio/sfvscanf.cUgsfGgsf#include        "sfhdr.h"
        !          20409: 
        !          20410: /*     The main engine for reading formatted data
        !          20411: **
        !          20412: **     Written by Kiem-Phong Vo (06/27/90)
        !          20413: */
        !          20414: 
        !          20415: #define        S_NORMAL        0       /* argument is a pointer to a normal object */
        !          20416: #define S_LONG         1       /* argument is a pointer to a long object */
        !          20417: #define S_SHORT                2       /* argument is a pointer to a short object */
        !          20418: 
        !          20419: #define a2f(s) strtod(s,NIL(char**))
        !          20420: 
        !          20421: #define A_SIZE         (1<<8)  /* alphabet */
        !          20422: #if __STDC__ || __cplusplus
        !          20423: static char *setclass(reg char* form, reg char* accept)
        !          20424: #else
        !          20425: static char *setclass(form,accept)
        !          20426: reg char       *form;          /* format string */
        !          20427: reg char       *accept;        /* accepted characters are set to 1 */
        !          20428: #endif
        !          20429: {
        !          20430:        reg int         fmt, c, yes;
        !          20431: 
        !          20432:        if((fmt = *form++) == '^')
        !          20433:        {       /* we want the complement of this set */
        !          20434:                yes = 0;
        !          20435:                fmt = *form++;
        !          20436:        }
        !          20437:        else    yes = 1;
        !          20438: 
        !          20439:        for(c = 0; c < A_SIZE; ++c)
        !          20440:                accept[c] = !yes;
        !          20441: 
        !          20442:        if(fmt == ']' || fmt == '-')
        !          20443:        {       /* special first char */
        !          20444:                accept[fmt] = yes;
        !          20445:                fmt = *form++;
        !          20446:        }
        !          20447: 
        !          20448:        for(; fmt != ']'; fmt = *form++)
        !          20449:        {       /* done */
        !          20450:                if(!fmt)
        !          20451:                        return (form-1);
        !          20452: 
        !          20453:                /* interval */
        !          20454:                if(fmt != '-' || form[0] == ']' || form[-2] > form[0])
        !          20455:                        accept[fmt] = yes;
        !          20456:                else for(c = form[-2]+1; c < form[0]; ++c)
        !          20457:                        accept[c] = yes;
        !          20458:        }
        !          20459: 
        !          20460:        return form;
        !          20461: }
        !          20462: 
        !          20463: #define SETARG(val,argf,args,type,fmt,form) \
        !          20464:        { if(!argf) \
        !          20465:                *va_arg(args,type*) = (type)val; \
        !          20466:          else if((*argf)(fmt,(char*)(&val),sizeof(val)) < 0) \
        !          20467:                form = ""; \
        !          20468:        }
        !          20469: 
        !          20470: #if __STDC__ || __cplusplus
        !          20471: sfvscanf(Sfile_t* f, reg const char* form, va_list args)
        !          20472: #else
        !          20473: sfvscanf(f,form,args)
        !          20474: Sfile_t                *f;             /* file to be scanned */
        !          20475: reg char       *form;          /* scanning format */
        !          20476: va_list                args;
        !          20477: #endif
        !          20478: {
        !          20479:        reg int         fmt, inp;
        !          20480:        reg char        *d;
        !          20481:        reg int         skip, size, length, n_match;
        !          20482:        reg Sfile_t     *sf;
        !          20483:        reg char        *sp;
        !          20484:        char            accept[MAXDIGITS];
        !          20485:        reg char        *endd;
        !          20486:        Argf_s          argf;
        !          20487:        Extf_s          extf;
        !          20488:        reg Fa_t        *fa, *fast;
        !          20489:        va_list         alist;
        !          20490: 
        !          20491:        /* fast io system */
        !          20492: #define SFSET(f)       (d = (char*)f->next, endd = (char*)f->endb)
        !          20493: #define SFEND(f)       (f->next = (uchar*)d)
        !          20494: #define SFFILL(f,c)    (SFEND(f), (SFopen(f),c = _sffilbuf(f,1),SFLOCK(f)), SFSET(f), c)
        !          20495: #define SFGETC(f,c)    (d >= endd ? SFFILL(f,c) : (c = (int)(*d++)))
        !          20496: #define SFUNGETC(f,c)  (--d)
        !          20497: 
        !          20498:        if(f->mode != SF_READ && SFMODE(f,SF_READ) < 0)
        !          20499:                return -1;
        !          20500:        SFLOCK(f);
        !          20501:        SFSET(f);
        !          20502:        n_match = 0;
        !          20503:        inp = -1;
        !          20504:        sf = NIL(Sfile_t*);
        !          20505:        argf = NIL(Argf_s);
        !          20506:        extf = NIL(Extf_s);
        !          20507:        fast = NIL(Fa_t*);
        !          20508: 
        !          20509: loop_fa :
        !          20510:        while(fmt = *form++)
        !          20511:        {
        !          20512:                switch(fmt)
        !          20513:                {
        !          20514:                default : /* literal match */
        !          20515:                literal :
        !          20516:                        if(SFGETC(f,inp) != fmt)
        !          20517:                        {       /* premature eof */
        !          20518:                                if(inp < 0)
        !          20519:                                        return -1;
        !          20520:                                SFUNGETC(f,inp);
        !          20521:                                goto done;
        !          20522:                        }
        !          20523:                        continue;
        !          20524: 
        !          20525:                case ' ' : /* skip blanks */
        !          20526:                case '\t':
        !          20527:                case '\n':
        !          20528:                        do      { SFGETC(f,inp); }
        !          20529:                        while(isspace(inp) || inp == '\n');
        !          20530:                        if(inp < 0)
        !          20531:                                goto done;
        !          20532:                        else    SFUNGETC(f,inp);
        !          20533:                        continue;
        !          20534: 
        !          20535:                case '%' : /* matching some pattern */
        !          20536:                        skip = 0;
        !          20537:                        switch(fmt = *form++)
        !          20538:                        {
        !          20539:                        case '%' : /* match % literally */
        !          20540:                                goto literal;
        !          20541: 
        !          20542:                        case '@' : /* set argument getting function */
        !          20543:                                argf = va_arg(args,Argf_s);
        !          20544:                                continue;
        !          20545: 
        !          20546:                        case '&' : /* set extension function */
        !          20547:                                extf = va_arg(args,Extf_s);
        !          20548:                                continue;
        !          20549: 
        !          20550:                        case ':' : /* stack a pair of format/arglist */
        !          20551:                                if(!FAMALLOC(fa))
        !          20552:                                        goto done;
        !          20553:                                fa->form = (char*)form;
        !          20554:                                if(!(form = va_arg(args,char*)))
        !          20555:                                        form = "";
        !          20556:                                alist = va_arg(args,va_list);
        !          20557:                                fa->args = args;
        !          20558:                                args = alist;
        !          20559:                                fa->extf.s = extf;
        !          20560:                                fa->argf.s = argf;
        !          20561:                                fa->next = fast;
        !          20562:                                fast = fa;
        !          20563:                                continue;
        !          20564: 
        !          20565:                        case '*' :      /* skip one argument */
        !          20566:                                skip = 1;
        !          20567:                                fmt = *form++;
        !          20568: 
        !          20569:                        default :
        !          20570:                                /* scan length */
        !          20571:                                length = 0;
        !          20572:                                while(isdigit(fmt))
        !          20573:                                {       length = length*10 + (fmt - '0');
        !          20574:                                        fmt = *form++;
        !          20575:                                }
        !          20576: 
        !          20577:                                /* size of object to be assigned */
        !          20578:                                if(fmt == 'l')
        !          20579:                                        { size = S_LONG; fmt = *form++; }
        !          20580:                                else if(fmt == 'h')
        !          20581:                                        { size = S_SHORT; fmt = *form++; }
        !          20582:                                else    size = S_NORMAL;
        !          20583: 
        !          20584:                                /* canonicalize format */
        !          20585:                                switch(fmt)
        !          20586:                                {
        !          20587:                                case 'D' : case 'I' : case 'U' :
        !          20588:                                        size = S_LONG;
        !          20589:                                case 'i' : case 'u' :
        !          20590:                                        fmt = 'd';
        !          20591:                                        break;
        !          20592:                                case 'O' :
        !          20593:                                        size = S_LONG;
        !          20594:                                        fmt = 'o';
        !          20595:                                        break;
        !          20596:                                case 'X' :
        !          20597:                                        size = S_LONG;
        !          20598:                                        fmt = 'x';
        !          20599:                                        break;
        !          20600:                                case 'E' : case 'F' : case 'G' :
        !          20601:                                        size = S_LONG;
        !          20602:                                case 'e' : case 'f' : case 'g' :
        !          20603:                                        fmt = 'f';
        !          20604:                                        break;
        !          20605:                                }
        !          20606:                        }
        !          20607:                }
        !          20608: 
        !          20609:                /* scan length */
        !          20610:                if(length == 0)
        !          20611:                        length = fmt == 'c' ? 1 : SF_BUFSIZE;
        !          20612: 
        !          20613:                /* define the first input character */
        !          20614:                if(fmt == 'c' || fmt == '[')
        !          20615:                        SFGETC(f,inp);
        !          20616:                else
        !          20617:                {       /* skip starting blanks */
        !          20618:                        do      { SFGETC(f,inp); }
        !          20619:                        while(isspace(inp) || inp == '\n')
        !          20620:                                ;
        !          20621:                }
        !          20622:                if(inp < 0)
        !          20623:                        goto done;
        !          20624: 
        !          20625:                if(fmt == 'f')
        !          20626:                {       /* a float or double */
        !          20627:                        reg char        *val;
        !          20628:                        reg int         dot, exponent;
        !          20629:                        double          dval;
        !          20630: 
        !          20631:                        val = accept;
        !          20632:                        if(length >= MAXDIGITS)
        !          20633:                                length = MAXDIGITS-1;
        !          20634:                        dot = exponent = 0;
        !          20635:                        do
        !          20636:                        {       if(isdigit(inp))
        !          20637:                                        *val++ = inp;
        !          20638:                                else if(inp == '.')
        !          20639:                                {       /* too many dots */
        !          20640:                                        if(dot++ > 0)
        !          20641:                                                break;
        !          20642:                                        *val++ = '.';
        !          20643:                                }
        !          20644:                                else if(inp == 'e' || inp == 'E')
        !          20645:                                {       /* too many e,E */
        !          20646:                                        if(exponent++ > 0)
        !          20647:                                                break;
        !          20648:                                        *val++ = inp;
        !          20649:                                        SFGETC(f,inp);
        !          20650:                                        if(inp == '-' || inp == '+' || isdigit(inp))
        !          20651:                                                *val++ = inp;
        !          20652:                                        else    break;
        !          20653:                                }
        !          20654:                                else if(inp == '-' || inp == '+')
        !          20655:                                {       /* too many signs */
        !          20656:                                        if(val > accept)
        !          20657:                                                break;
        !          20658:                                        *val++ = inp;
        !          20659:                                }
        !          20660:                                else    break;
        !          20661: 
        !          20662:                        } while(--length > 0 && SFGETC(f,inp) >= 0);
        !          20663: 
        !          20664:                        if(val > accept)
        !          20665:                        {       /* there is something to convert */
        !          20666:                                n_match += 1;
        !          20667:                                *val = '\0';
        !          20668: 
        !          20669:                                if(!skip)
        !          20670:                                {       /* assign */
        !          20671:                                        dval = a2f(accept);
        !          20672:                                        switch(size)
        !          20673:                                        {
        !          20674:                                        case S_LONG:
        !          20675:                                                SETARG(dval,argf,args,double,'F',form);
        !          20676:                                                break;
        !          20677:                                        case S_SHORT :
        !          20678:                                        case S_NORMAL:
        !          20679:                                                SETARG(dval,argf,args,float,'f',form);
        !          20680:                                                break;
        !          20681:                                        }
        !          20682:                                }
        !          20683:                        }
        !          20684:                }
        !          20685:                else if(fmt == 's' || fmt == 'c' || fmt == '[')
        !          20686:                {       n_match += 1;
        !          20687: 
        !          20688:                        sp = NIL(char*);
        !          20689:                        if(!skip)
        !          20690:                        {       if(!argf)
        !          20691:                                        sp = va_arg(args,char*);
        !          20692:                                else if(!sf)
        !          20693:                                        sf = sfnew(NIL(Sfile_t*),NIL(uchar*),-1,-1,
        !          20694:                                                   SF_STRING|SF_WRITE);
        !          20695:                                else    sfseek(sf,0L,0);
        !          20696:                        }
        !          20697: 
        !          20698:                        if(fmt == 's')
        !          20699:                        {       /* copy a string */
        !          20700:                                do
        !          20701:                                {       if(isspace(inp) || inp == '\n')
        !          20702:                                                break;
        !          20703:                                        if(sp)
        !          20704:                                                *sp++ = inp;
        !          20705:                                        else if(!skip && sf)
        !          20706:                                                sfputc(sf,inp);
        !          20707:                                } while(--length > 0 && SFGETC(f,inp) >= 0);
        !          20708:                        }
        !          20709:                        else if(fmt == 'c')
        !          20710:                        {       /* copy characters */
        !          20711:                                do
        !          20712:                                {       if(sp)
        !          20713:                                                *sp++ = inp;
        !          20714:                                        else if(!skip && sf)
        !          20715:                                                sfputc(sf,inp);
        !          20716:                                } while(--length > 0 && SFGETC(f,inp) >= 0);
        !          20717:                        }
        !          20718:                        else
        !          20719:                        {       /* copy characters from a class */
        !          20720:                                form = setclass((char*)form,accept);
        !          20721:                                do
        !          20722:                                {       if(!accept[inp])
        !          20723:                                                break;
        !          20724:                                        if(sp)
        !          20725:                                                *sp++ = inp;
        !          20726:                                        else if(!skip && sf)
        !          20727:                                                sfputc(sf,inp);
        !          20728:                                } while(--length > 0 && SFGETC(f,inp) >= 0);
        !          20729:                        }
        !          20730:                        if(sp)
        !          20731:                        {       if(fmt != 'c' || length > 1)
        !          20732:                                        *sp = '\0';
        !          20733:                        }
        !          20734:                        else if(!skip && sf)
        !          20735:                        {       sfputc(sf,'\0');
        !          20736:                                if((*argf)('s',(char*)sf->data,sf->next-sf->data) < 0)
        !          20737:                                        form = "";
        !          20738:                        }
        !          20739:                }
        !          20740:                else if(fmt == 'd' || fmt == 'o' || fmt == 'x')
        !          20741:                {       /* some integer type */
        !          20742:                        long    lval;
        !          20743:                        reg int base, sign;
        !          20744: 
        !          20745:                        base = fmt == 'o' ? 8 : fmt == 'x' ? 16 : 10;
        !          20746:                        if(inp == '-' || inp == '+')
        !          20747:                        {       /* get the sign */
        !          20748:                                sign = inp == '-' ? -1 : 1;
        !          20749:                                SFGETC(f,inp);
        !          20750:                                length -= 1;
        !          20751:                        }
        !          20752:                        else    sign = 1;
        !          20753:                        if(inp < 0)
        !          20754:                                goto done;
        !          20755: 
        !          20756:                        /* skip leading 0's */
        !          20757:                        do
        !          20758:                        {       if(inp != '0')
        !          20759:                                        break;
        !          20760:                        } while(--length > 0 && SFGETC(f,inp) >= 0);
        !          20761: 
        !          20762:                        /* now convert */
        !          20763:                        lval = 0;
        !          20764:                        if(base == 10)
        !          20765:                        {       if(length > 0) do
        !          20766:                                {       if(inp < '0' || inp > '9')
        !          20767:                                                break;
        !          20768:                                        lval = (lval << 3) + (lval << 1) + (inp - '0');
        !          20769:                                } while(--length > 0 && SFGETC(f,inp) >= 0);
        !          20770:                        }
        !          20771:                        else if(base == 8)
        !          20772:                        {       if(length > 0) do
        !          20773:                                {       if(inp < '0' || inp > '7')
        !          20774:                                                break;
        !          20775:                                        lval = (lval << 3) + (inp - '0');
        !          20776:                                } while(--length > 0 && SFGETC(f,inp) >= 0);
        !          20777:                        }
        !          20778:                        else    /* base 16 */
        !          20779:                        {       if(length > 0 && (inp == 'x' || inp == 'X'))
        !          20780:                                {       /* skip leading x */
        !          20781:                                        SFGETC(f,inp);
        !          20782:                                        length -= 1;
        !          20783:                                }
        !          20784:                                if(length > 0) do
        !          20785:                                {       if(inp >= '0' && inp <= '9')
        !          20786:                                                inp = inp - '0';
        !          20787:                                        else if(inp >= 'a' && inp <= 'f')
        !          20788:                                                inp = (inp - 'a') + 10;
        !          20789:                                        else if(inp >= 'A' && inp <= 'F')
        !          20790:                                                inp = (inp - 'A') + 10;
        !          20791:                                        else    break;
        !          20792:                                        lval = (lval << 4) + inp;
        !          20793:                                } while(--length > 0 && SFGETC(f,inp) >= 0);
        !          20794:                        }
        !          20795: 
        !          20796:                        /* assign */
        !          20797:                        n_match += 1;
        !          20798:                        if(sign < 0)
        !          20799:                                lval = -lval;
        !          20800:                        if(!skip) switch(size)
        !          20801:                        {
        !          20802:                        case S_SHORT :
        !          20803:                                SETARG(lval,argf,args,short,'h',form);
        !          20804:                                break;
        !          20805:                        case S_NORMAL :
        !          20806:                                SETARG(lval,argf,args,int,'d',form);
        !          20807:                                break;
        !          20808:                        case S_LONG :
        !          20809:                                SETARG(lval,argf,args,long,'D',form);
        !          20810:                                break;
        !          20811:                        }
        !          20812:                }
        !          20813:                else if(extf)
        !          20814:                {       /* call extension function */
        !          20815:                        char    *rv;
        !          20816:                        int     n;
        !          20817:                        SFEND(f);
        !          20818:                        SFOPEN(f);
        !          20819:                        n = (*extf)(f,fmt,length,&rv);
        !          20820:                        SFLOCK(f);
        !          20821:                        SFSET(f);
        !          20822:                        if(n >= 0)
        !          20823:                        {       n_match += 1;
        !          20824:                                if(!skip)
        !          20825:                                {       if(!argf)
        !          20826:                                        {       sp = va_arg(args,char*);
        !          20827:                                                while(n--)
        !          20828:                                                        *sp++ = *rv++;
        !          20829:                                        }
        !          20830:                                        else if((*argf)(fmt,rv,n) < 0)
        !          20831:                                                form = "";
        !          20832:                                }
        !          20833:                        }
        !          20834:                        continue;
        !          20835:                }
        !          20836: 
        !          20837:                if(inp < 0)
        !          20838:                        break;
        !          20839:                else if(length > 0)
        !          20840:                        SFUNGETC(f,inp);
        !          20841:        }
        !          20842: 
        !          20843:        if(fa = fast)
        !          20844:        {       /* check for stacked formats/arglists */
        !          20845:                form = fa->form;
        !          20846:                args = fa->args;
        !          20847:                argf = fa->argf.s;
        !          20848:                extf = fa->extf.s;
        !          20849:                fast = fa->next;
        !          20850:                FAFREE(fa);
        !          20851:                goto loop_fa;
        !          20852:        }
        !          20853: 
        !          20854: done:
        !          20855:        if(sf)
        !          20856:                sfclose(sf);
        !          20857:        SFEND(f);
        !          20858:        SFOPEN(f);
        !          20859:        return (n_match == 0 && inp < 0) ? -1 : n_match;
        !          20860: }
        !          20861: 0707070000000003131006440044230044230000010000000475453670000003200000005643sfio/sfwrite.cUgsfGgsf#include "sfhdr.h"
        !          20862: 
        !          20863: /*     Write data out to the file system
        !          20864: **
        !          20865: **     Written by Kiem-Phong Vo (06/27/90)
        !          20866: */
        !          20867: 
        !          20868: #if __STDC__ || __cplusplus
        !          20869: sfwrite(reg Sfile_t* f, reg const uchar* s, reg int n)
        !          20870: #else
        !          20871: sfwrite(f,s,n)
        !          20872: reg Sfile_t    *f;     /* write to this stream */
        !          20873: reg uchar      *s;     /* buffer to be written */
        !          20874: reg int                n;      /* number of bytes */
        !          20875: #endif
        !          20876: {
        !          20877:        reg uchar       *data;
        !          20878:        reg int         w;
        !          20879:        reg int         line_fls;
        !          20880:        reg int         (*writef)_SFA_((Sfile_t*, const uchar*, int, char*));
        !          20881:        reg long        (*seekf)_SFA_((Sfile_t*, long, int, char*));
        !          20882:        reg char        *handle;
        !          20883: #if __STDC__ || __cplusplus
        !          20884:        reg const uchar *begs;
        !          20885: #else
        !          20886:        reg uchar       *begs;
        !          20887: #endif
        !          20888:        begs = s;
        !          20889: 
        !          20890: redo_loop:
        !          20891:        if(f->mode != SF_WRITE && SFMODE(f,SF_WRITE) < 0)
        !          20892:                return -1;
        !          20893:        SFLOCK(f);
        !          20894: 
        !          20895:        writef = f->disc ? f->disc->writef :
        !          20896:                        NIL(int(*)_SFA_((Sfile_t*,const uchar*,int,char*)));
        !          20897:        seekf  = f->disc ? f->disc->seekf  :
        !          20898:                        NIL(long(*)_SFA_((Sfile_t*, long, int, char*)));
        !          20899:        handle = f->disc ? f->disc->handle : NIL(char*);
        !          20900: 
        !          20901:        /* see if must flush because of line buffering */
        !          20902:        line_fls = 0;
        !          20903:        if((f->flags&SF_LINE) && !(f->flags&SF_STRING))
        !          20904:        {       if(n >= HIFORLINE)
        !          20905:                        line_fls = 1;
        !          20906:                else for(data = (uchar*)s+n-1; data >= (uchar*)s;)
        !          20907:                        if(*data-- == '\n')
        !          20908:                        {       line_fls = 1;
        !          20909:                                break;
        !          20910:                        }
        !          20911:        }
        !          20912: 
        !          20913:        if((uchar*)s == (data = f->next))
        !          20914:        {       /* user wrote directly into this buffer */
        !          20915:                if((w = f->endb - data) > n)
        !          20916:                        w = n <= 0 ? 0 : n;
        !          20917:                f->next += w;
        !          20918:                s += w;
        !          20919:                if((n -= w) <= 0)
        !          20920:                        goto done;
        !          20921:                data += w;
        !          20922:        }
        !          20923: 
        !          20924:        if((w = f->endb - data) == f->size && w <= n && !(f->mode&SF_STRING))
        !          20925:                goto do_write;
        !          20926:        else if(w > n)
        !          20927:                w = n;
        !          20928:        for(;;)
        !          20929:        {       /* copy data - note that s is advanced too */
        !          20930:                MEMCPY(data,s,w);
        !          20931: 
        !          20932:                f->next += w;
        !          20933:                if((n -= w) <= 0)
        !          20934:                        goto done;
        !          20935: 
        !          20936:                if(f->mode&SF_STRING)
        !          20937:                {       w = n;
        !          20938:                        goto at_eof;
        !          20939:                }
        !          20940: 
        !          20941:                if(f->next > f->data)
        !          20942:                {       /* clear buffer before direct writes */ 
        !          20943:                        SFopen(f);
        !          20944:                        if(_sfflsbuf(f,-1) < 0)
        !          20945:                                goto done;
        !          20946:                        SFLOCK(f);
        !          20947:                }
        !          20948: 
        !          20949:        do_write :
        !          20950:                while(n >= (w = f->size) || line_fls)
        !          20951:                {
        !          20952:                        if(w <= 1 || line_fls)  /* unbuffered write */
        !          20953:                                w = n;
        !          20954:                        else
        !          20955:                        {       /* write using a round-up unit */
        !          20956:                                if(w > SF_GRAIN)
        !          20957:                                        w = SF_GRAIN;
        !          20958:                                w = (n/w)*w;
        !          20959:                        }
        !          20960: 
        !          20961: #ifdef NO_OFLAGS       /* simulate append mode */
        !          20962:                        if(f->flags&SF_APPEND)
        !          20963:                                f->here = SEEKF(seekf,f,0L,2,handle);
        !          20964:                        else /* not really dangling */
        !          20965: #endif
        !          20966:                        if(f->flags&SF_SHARE)
        !          20967:                                f->here = SEEKF(seekf,f,f->here,0,handle);
        !          20968: 
        !          20969:                        if((w = WRITEF(writef,f,s,w,handle)) > 0)
        !          20970:                        {       /* successful write */
        !          20971:                                f->here += w;
        !          20972:                                s += w;
        !          20973:                                if((n -= w) <= 0)
        !          20974:                                        goto done;
        !          20975:                        }
        !          20976:                        else
        !          20977:                        {       /* a write exception occured */
        !          20978:                        at_eof :
        !          20979:                                switch(_sfexcept(f,SF_WRITE,w))
        !          20980:                                {
        !          20981:                                case SF_EDISC :
        !          20982:                                case SF_ESTACK :
        !          20983:                                        SFopen(f);
        !          20984:                                        goto redo_loop;
        !          20985:                                case SF_EDONE :
        !          20986:                                        goto done;
        !          20987:                                default :
        !          20988:                                        if(f->mode&SF_STRING)
        !          20989:                                                goto set_copy;
        !          20990:                                        else    continue;
        !          20991:                                }
        !          20992:                        }
        !          20993:                }
        !          20994: 
        !          20995:                /* prepare to copy data into buffer */
        !          20996:        set_copy:
        !          20997:                data = f->next;
        !          20998:                if((w = f->endb - data) > n)
        !          20999:                        w = n;
        !          21000:        }
        !          21001: done :
        !          21002:        SFOPEN(f);
        !          21003:        if(line_fls && f->next > f->data)
        !          21004:                _sfflsbuf(f,-1);
        !          21005:        return s-begs;
        !          21006: }
        !          21007: 0707070000000003141006440044230044230000010000000475242176100003300000000153stdio/sprintf.cUgsfGgsf#include "sfhdr.h"
        !          21008: #include "stdio.h"
        !          21009: 
        !          21010: #undef sprintf
        !          21011: #define _stdsprintf    sprintf
        !          21012: 
        !          21013: #include "stdsprintf.c"
        !          21014: 0707070000000003151006440044230044230000010000000473126373400003300000000474stdio/stdgets.cUgsfGgsf#include        "sfhdr.h"
        !          21015: #include       "stdio.h"
        !          21016: 
        !          21017: /*     Stdio gets()
        !          21018: **
        !          21019: **     Written by Kiem-Phong Vo (12/10/90)
        !          21020: */
        !          21021: 
        !          21022: #if __STDC__ || __cplusplus
        !          21023: char *_stdgets(reg char *s, reg int n)
        !          21024: #else
        !          21025: char *_stdgets(s,n)
        !          21026: reg char       *s;
        !          21027: reg int                n;
        !          21028: #endif
        !          21029: {      if(!s || sfgets(sfstdin,s,n) != s)
        !          21030:                return NIL(char*);
        !          21031:        s[_Sfi--] = '\0';
        !          21032:        return s;
        !          21033: }
        !          21034: 0707070000000003161006440044230044230000010000000473126376300003500000000652stdio/stdprintf.cUgsfGgsf#include      "sfhdr.h"
        !          21035: #include       "stdio.h"
        !          21036: 
        !          21037: 
        !          21038: /*     printf function
        !          21039: **
        !          21040: **     Written by Kiem-Phong Vo (12/10/90)
        !          21041: */
        !          21042: 
        !          21043: #if __STDC__ || __cplusplus
        !          21044: _stdprintf(const char *form, ...)
        !          21045: #else
        !          21046: _stdprintf(form,va_alist)
        !          21047: reg char       *form;  /* print format */
        !          21048: va_dcl
        !          21049: #endif
        !          21050: {
        !          21051:        va_list args;
        !          21052:        reg int rv;
        !          21053: 
        !          21054: #if __STDC__ || __cplusplus
        !          21055:        va_start(args,form);
        !          21056: #else
        !          21057:        va_start(args);
        !          21058: #endif
        !          21059:        rv = sfvprintf(sfstdout,form,args);
        !          21060: 
        !          21061:        va_end(args);
        !          21062:        return rv;
        !          21063: }
        !          21064: 0707070000000003171006440044230044230000010000000473227016700003400000000671stdio/stdscanf.cUgsfGgsf#include       "sfhdr.h"
        !          21065: #include       "stdio.h"
        !          21066: 
        !          21067: /*     Read formatted data from a stream
        !          21068: **
        !          21069: **     Written by Kiem-Phong Vo (06/27/90)
        !          21070: */
        !          21071: 
        !          21072: #if __STDC__ || __cplusplus
        !          21073: _stdscanf(const char *form, ...)
        !          21074: #else
        !          21075: _stdscanf(form,va_alist)
        !          21076: reg char       *form;  /* scanning format */
        !          21077: va_dcl
        !          21078: #endif
        !          21079: {
        !          21080:        va_list args;
        !          21081:        reg int rv;
        !          21082: 
        !          21083: #if __STDC__ || __cplusplus
        !          21084:        va_start(args,form);
        !          21085: #else
        !          21086:        va_start(args);
        !          21087: #endif
        !          21088:        rv = sfvscanf(sfstdin,form,args);
        !          21089:        va_end(args);
        !          21090:        return rv;
        !          21091: }
        !          21092: 0707070000000003201006440044230044230000010000000475414265500003600000001066stdio/stdsetvbuf.cUgsfGgsf#include     "sfhdr.h"
        !          21093: #include       "stdio.h"
        !          21094: 
        !          21095: /*     Stdio function setvbuf()
        !          21096: **
        !          21097: **     Written by Kiem-Phong Vo (12/10/90)
        !          21098: */
        !          21099: 
        !          21100: #if __STDC__ || __cplusplus
        !          21101: _stdsetvbuf(Sfile_t* f, char *buf, int type, int size)
        !          21102: #else
        !          21103: _stdsetvbuf(f,buf,type,size)
        !          21104: Sfile_t        *f;
        !          21105: char   *buf;
        !          21106: int    type;
        !          21107: int    size;
        !          21108: #endif
        !          21109: {
        !          21110:        if(type == _IOLBF)
        !          21111:                sfset(f,SF_LINE,1);
        !          21112:        else if((f->flags&SF_STRING))
        !          21113:                return -1;
        !          21114:        else if(type == _IONBF)
        !          21115:        {       sfsync(f);
        !          21116:                sfsetbuf(f,NIL(uchar*),0);
        !          21117:        }
        !          21118:        else if(type == _IOFBF)
        !          21119:        {       if(size == 0)
        !          21120:                        size = SF_BUFSIZE;
        !          21121:                sfsync(f);
        !          21122:                sfsetbuf(f,(uchar*)buf,size);
        !          21123:        }
        !          21124: 
        !          21125:        return 0;
        !          21126: }
        !          21127: 0707070000000003211006440044230044230000010000000475414267000003600000001316stdio/stdsprintf.cUgsfGgsf#include     "sfhdr.h"
        !          21128: #include       "stdio.h"
        !          21129: 
        !          21130: 
        !          21131: /*     sprintf function
        !          21132: **
        !          21133: **     Written by Kiem-Phong Vo (12/10/90)
        !          21134: */
        !          21135: 
        !          21136: 
        !          21137: #if __STDC__ || __cplusplus
        !          21138: _stdsprintf(char *s, const char *form, ...)
        !          21139: #else
        !          21140: _stdsprintf(s,form,va_alist)
        !          21141: reg char       *s;
        !          21142: reg char       *form;
        !          21143: va_dcl
        !          21144: #endif
        !          21145: {
        !          21146:        va_list args;
        !          21147:        Sfile_t f;
        !          21148:        reg int rv;
        !          21149: 
        !          21150:        if(!s)
        !          21151:                return -1;
        !          21152: 
        !          21153:        /* make a fake stream */
        !          21154:        SFCLEAR(&f);
        !          21155:        f.flags = SF_STRING|SF_WRITE;
        !          21156:        f.mode = SF_STRING;
        !          21157:        f.size = 4*SF_BUFSIZE;
        !          21158:        f.data = f.next = f.endr = (uchar*)s;
        !          21159:        f.endb = f.endw = f.data+f.size;
        !          21160:        sfset(&f,f.flags,1);
        !          21161: 
        !          21162: #if __STDC__ || __cplusplus
        !          21163:        va_start(args,form);
        !          21164: #else
        !          21165:        va_start(args);
        !          21166: #endif
        !          21167:        rv = sfvprintf(&f,form,args);
        !          21168:        *f.next = '\0';
        !          21169:        _Sfi = f.next - f.data;
        !          21170: 
        !          21171:        va_end(args);
        !          21172: 
        !          21173:        return rv;
        !          21174: }
        !          21175: 0707070000000003221006440044230044230000010000000475414270100003700000001041stdio/stdvsprintf.cUgsfGgsf#include    "sfhdr.h"
        !          21176: 
        !          21177: #if __STDC__ || __cplusplus
        !          21178: _stdvsprintf(char *s, const char *form, va_list args)
        !          21179: #else
        !          21180: _stdvsprintf(s,form,args)
        !          21181: register char  *s;
        !          21182: register char  *form;
        !          21183: va_list                args;
        !          21184: #endif
        !          21185: {
        !          21186:        Sfile_t f;
        !          21187:        reg int rv;
        !          21188: 
        !          21189:        if(!s)
        !          21190:                return -1;
        !          21191: 
        !          21192:        /* make a fake stream */
        !          21193:        SFCLEAR(&f);
        !          21194:        f.flags = SF_STRING|SF_WRITE;
        !          21195:        f.mode = SF_STRING;
        !          21196:        f.size = 4*SF_BUFSIZE;
        !          21197:        f.data = f.next = f.endr = (uchar*)s;
        !          21198:        f.endb = f.endw = f.data+f.size;
        !          21199:        sfset(&f,f.flags,1);
        !          21200: 
        !          21201:        rv = sfvprintf(&f,form,args);
        !          21202:        *f.next = '\0';
        !          21203:        _Sfi = f.next - f.data;
        !          21204: 
        !          21205:        return rv;
        !          21206: }
        !          21207: 0707070000000003231006440044230044230000010000000475414271000003600000000754stdio/stdvsscanf.cUgsfGgsf#include     "sfhdr.h"
        !          21208: 
        !          21209: #if __STDC__ || __cplusplus
        !          21210: _stdvsscanf(char *s, const char *form, va_list args)
        !          21211: #else
        !          21212: _stdvsscanf(s,form,args)
        !          21213: register char  *s;
        !          21214: register char  *form;
        !          21215: va_list                args;
        !          21216: #endif
        !          21217: {
        !          21218:        Sfile_t f;
        !          21219:        reg int rv;
        !          21220: 
        !          21221:        if(!s)
        !          21222:                return -1;
        !          21223: 
        !          21224:        /* make a fake stream */
        !          21225:        SFCLEAR(&f);
        !          21226:        f.flags = SF_STRING|SF_READ;
        !          21227:        f.mode = SF_STRING;
        !          21228:        f.size = strlen((char*)s);
        !          21229:        f.data = f.next = f.endr = (uchar*)s;
        !          21230:        f.endb = f.endw = f.data+f.size;
        !          21231:        sfset(&f,f.flags,1);
        !          21232: 
        !          21233:        return sfvscanf(&f,form,args);
        !          21234: }
        !          21235: 0707070000000003241006440044230044230000010000000475242201400003400000000157stdio/vsprintf.cUgsfGgsf#include "sfhdr.h"
        !          21236: #include "stdio.h"
        !          21237: 
        !          21238: #undef vsprintf
        !          21239: #define _stdvsprintf   vsprintf
        !          21240: 
        !          21241: #include "stdvsprintf.c"
        !          21242: 0707070000000003251006440044230044230000010000000417047315600003300000002753string/chresc.cUgsfGgsf/*
        !          21243:  * G. S. Fowler
        !          21244:  * AT&T Bell Laboratories
        !          21245:  *
        !          21246:  * return the next character in the string s
        !          21247:  * \ character constants are converted
        !          21248:  * p is updated to point to the next character in s
        !          21249:  */
        !          21250: 
        !          21251: int
        !          21252: chresc(s, p)
        !          21253: register char* s;
        !          21254: char**         p;
        !          21255: {
        !          21256:        register char*  q;
        !          21257:        register int    c;
        !          21258: 
        !          21259:        switch (c = *s++)
        !          21260:        {
        !          21261:        case 0:
        !          21262:                return(0);
        !          21263:        case '\\':
        !          21264:                switch (c = *s++)
        !          21265:                {
        !          21266:                case '0': case '1': case '2': case '3':
        !          21267:                case '4': case '5': case '6': case '7':
        !          21268:                        c -= '0';
        !          21269:                        q = s + 2;
        !          21270:                        while (s < q) switch (*s)
        !          21271:                        {
        !          21272:                        case '0': case '1': case '2': case '3':
        !          21273:                        case '4': case '5': case '6': case '7':
        !          21274:                                c = (c << 3) + *s++ - '0';
        !          21275:                                break;
        !          21276:                        default:
        !          21277:                                q = s;
        !          21278:                                break;
        !          21279:                        }
        !          21280:                        break;
        !          21281:                case 'a':
        !          21282:                        c = '\007';
        !          21283:                        break;
        !          21284:                case 'b':
        !          21285:                        c = '\b';
        !          21286:                        break;
        !          21287:                case 'f':
        !          21288:                        c = '\f';
        !          21289:                        break;
        !          21290:                case 'n':
        !          21291:                        c = '\n';
        !          21292:                        break;
        !          21293:                case 'r':
        !          21294:                        c = '\r';
        !          21295:                        break;
        !          21296:                case 't':
        !          21297:                        c = '\t';
        !          21298:                        break;
        !          21299:                case 'v':
        !          21300:                        c = '\013';
        !          21301:                        break;
        !          21302:                case 'x':
        !          21303:                        c = 0;
        !          21304:                        q = s;
        !          21305:                        while (q) switch (*s)
        !          21306:                        {
        !          21307:                        case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
        !          21308:                                c = (c << 4) + *s++ - 'a' + 10;
        !          21309:                                break;
        !          21310:                        case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
        !          21311:                                c = (c << 4) + *s++ - 'A' + 10;
        !          21312:                                break;
        !          21313:                        case '0': case '1': case '2': case '3': case '4':
        !          21314:                        case '5': case '6': case '7': case '8': case '9':
        !          21315:                                c = (c << 4) + *s++ - '0';
        !          21316:                                break;
        !          21317:                        default:
        !          21318:                                q = 0;
        !          21319:                                break;
        !          21320:                        }
        !          21321:                        break;
        !          21322:                case 'E':
        !          21323:                        c = '\033';
        !          21324:                        break;
        !          21325:                case 0:
        !          21326:                        s--;
        !          21327:                        break;
        !          21328:                }
        !          21329:                break;
        !          21330:        }
        !          21331:        if (p) *p = s;
        !          21332:        return(c);
        !          21333: }
        !          21334: 0707070000000003261006440044230044230000010000000414141332000003100000000756string/ctoi.cUgsfGgsf/*
        !          21335:  * G. S. Fowler
        !          21336:  * AT&T Bell Laboratories
        !          21337:  *
        !          21338:  * convert a 0 terminated character constant string to an int
        !          21339:  */
        !          21340: 
        !          21341: #include <limits.h>
        !          21342: 
        !          21343: extern int     chresc(/* char* string, char** next */);
        !          21344: 
        !          21345: int
        !          21346: ctoi(s)
        !          21347: register char* s;
        !          21348: {
        !          21349:        register int    c;
        !          21350:        register int    n;
        !          21351:        register int    x;
        !          21352:        char*           p;
        !          21353: 
        !          21354:        c = 0;
        !          21355:        for (n = 0; n < sizeof(int) * CHAR_BIT; n += CHAR_BIT)
        !          21356:        {
        !          21357:                switch (x = *s++)
        !          21358:                {
        !          21359:                case '\\':
        !          21360:                        x = chresc(s - 1, &p);
        !          21361:                        s = p;
        !          21362:                        break;
        !          21363:                case 0:
        !          21364:                        return(c);
        !          21365:                }
        !          21366:                c |= x << n;
        !          21367:        }
        !          21368:        return(c);
        !          21369: }
        !          21370: 0707070000000003271006440044230044230000010000000474114302000003700000001560string/fmtelapsed.cUgsfGgsf/*
        !          21371:  * return pointer to formatted elapsed time for t 1/n secs
        !          21372:  * compatible with strelapsed()
        !          21373:  * 8 consecutive calls before overwrite
        !          21374:  * return value length is at most 6
        !          21375:  */
        !          21376: 
        !          21377: #include <stdio.h>
        !          21378: 
        !          21379: #define elements(x)    (sizeof(x)/sizeof(x[0]))
        !          21380: 
        !          21381: char*
        !          21382: fmtelapsed(t, n)
        !          21383: register unsigned long t;
        !          21384: register int           n;
        !          21385: {
        !          21386:        register unsigned long  s;
        !          21387: 
        !          21388:        static int              amt[] = { 1, 60, 60, 24, 7, 4, 12, 20 };
        !          21389:        static char             chr[] = "smhdwMYS";
        !          21390: 
        !          21391:        static char             tms[8][7];
        !          21392:        static int              tm;
        !          21393: 
        !          21394:        if (t == 0L) return("0");
        !          21395:        if (t == ~0L) return("%");
        !          21396:        if (++tm >= elements(tms)) tm = 0;
        !          21397:        s = t / n;
        !          21398:        if (s < 60) (void)sprintf(tms[tm], "%d.%02ds", s % 100, (t * 100 / n) % 100);
        !          21399:        else
        !          21400:        {
        !          21401:                for (n = 1; n < elements(amt) - 1; n++)
        !          21402:                {
        !          21403:                        if ((t = s / amt[n]) < amt[n + 1]) break;
        !          21404:                        s = t;
        !          21405:                }
        !          21406:                (void)sprintf(tms[tm], "%d%c%02d%c", (s / amt[n]) % 100, chr[n], s % amt[n], chr[n - 1]);
        !          21407:        }
        !          21408:        return(tms[tm]);
        !          21409: }
        !          21410: 0707070000000003301006440044230044230000010000000474560131600003300000001453string/fmtgid.cUgsfGgsf/*
        !          21411:  * G. S. Fowler
        !          21412:  * AT&T Bell Laboratories
        !          21413:  *
        !          21414:  * gid number -> name
        !          21415:  */
        !          21416: 
        !          21417: #include <stdio.h>
        !          21418: #include <hash.h>
        !          21419: #define getgrgid       _SYS_getgrgid
        !          21420: #include <grp.h>
        !          21421: #undef getgrgid
        !          21422: 
        !          21423: extern char*           strdup();
        !          21424: 
        !          21425: extern struct group*   getgrgid();
        !          21426: 
        !          21427: /*
        !          21428:  * return gid name given gid number
        !          21429:  */
        !          21430: 
        !          21431: char*
        !          21432: fmtgid(gid)
        !          21433: int    gid;
        !          21434: {
        !          21435:        register char*          name;
        !          21436:        register struct group*  gr;
        !          21437: 
        !          21438:        static HASHTABLE*       gidtab;
        !          21439:        static char             buf[sizeof(int) * 3 + 1];
        !          21440: 
        !          21441:        if (!gidtab && !(gidtab = hashalloc((HASHTABLE*)0, HASH_set, HASH_ALLOCATE, HASH_namesize, sizeof(gid), HASH_name, "gidnum", 0))) (void)sprintf(name = buf, "%d", gid);
        !          21442:        else if (!(name = hashget(gidtab, &gid)))
        !          21443:        {
        !          21444:                if (gr = getgrgid(gid)) name = gr->gr_name;
        !          21445:                else (void)sprintf(name = buf, "%d", gid);
        !          21446:                (void)hashput(gidtab, (char*)0, name = strdup(name));
        !          21447:        }
        !          21448:        return(name);
        !          21449: }
        !          21450: 0707070000000003311006440044230044230000010000000475445730400003200000004325string/fmtls.cUgsfGgsf/*
        !          21451:  * G. S. Fowler
        !          21452:  * AT&T Bell Laboratories
        !          21453:  *
        !          21454:  * ls formatter
        !          21455:  */
        !          21456: 
        !          21457: #include <ls.h>
        !          21458: #include <tm.h>
        !          21459: #include <stdio.h>
        !          21460: 
        !          21461: #ifndef S_IFLNK
        !          21462: #define S_IFLNK                0120000
        !          21463: #endif
        !          21464: 
        !          21465: extern char*           fmtmode();
        !          21466: extern char*           fmtuid();
        !          21467: extern char*           fmtgid();
        !          21468: 
        !          21469: /*
        !          21470:  * ls formatter
        !          21471:  *
        !          21472:  *     buf     results placed here
        !          21473:  *     name    file name
        !          21474:  *     st      file stat buffer
        !          21475:  *     info    optional info
        !          21476:  *     link    link text if != 0
        !          21477:  *     flags   LS_* flags
        !          21478:  *
        !          21479:  *     return  end of formatted buf
        !          21480:  */
        !          21481: 
        !          21482: #if __STDC__ || __cplusplus
        !          21483: char*
        !          21484: fmtls(char* buf, const char* name, register struct stat* st, const char* info, const char* link, register int flags)
        !          21485: #else
        !          21486: char*
        !          21487: fmtls(buf, name, st, info, link, flags)
        !          21488: char*                  buf;
        !          21489: char*                  name;
        !          21490: register struct stat*  st;
        !          21491: char*                  info;
        !          21492: char*                  link;
        !          21493: register int           flags;
        !          21494: #endif
        !          21495: {
        !          21496:        register char*          s;
        !          21497:        time_t                  tm;
        !          21498: 
        !          21499:        s = buf;
        !          21500:        if (flags & LS_INUMBER)
        !          21501:        {
        !          21502:                (void)sprintf(s, "%*lu ", LS_W_INUMBER - 1, (unsigned long)st->st_ino);
        !          21503:                while (*++s);
        !          21504:        }
        !          21505:        if (flags & LS_BLOCKS)
        !          21506:        {
        !          21507:                (void)sprintf(s, "%*lu ", LS_W_BLOCKS - 1, (unsigned long)tblocks(st));
        !          21508:                while (*++s);
        !          21509:        }
        !          21510:        if (flags & LS_LONG)
        !          21511:        {
        !          21512:                (void)sprintf(s, "%s%3u", fmtmode(st->st_mode), (unsigned int)st->st_nlink);
        !          21513:                while (*++s);
        !          21514:                if (!(flags & LS_NOUSER))
        !          21515:                {
        !          21516:                        (void)sprintf(s, " %-*s", LS_W_NAME - 1, fmtuid(st->st_uid));
        !          21517:                        while (*++s);
        !          21518:                }
        !          21519:                if (!(flags & LS_NOGROUP))
        !          21520:                {
        !          21521:                        (void)sprintf(s, " %-*s", LS_W_NAME - 1, fmtgid(st->st_gid));
        !          21522:                        while (*++s);
        !          21523:                }
        !          21524:                switch (st->st_mode & S_IFMT)
        !          21525:                {
        !          21526:                case S_IFBLK:
        !          21527:                case S_IFCHR:
        !          21528:                        (void)sprintf(s, " %3u,%3u ", (unsigned int)major(st->st_rdev), (unsigned int)minor(st->st_rdev));
        !          21529:                        break;
        !          21530:                default:
        !          21531:                        (void)sprintf(s, "%8lu ", (unsigned long)st->st_size);
        !          21532:                        break;
        !          21533:                }
        !          21534:                while (*++s);
        !          21535:                tm = (flags & LS_ATIME) ? st->st_atime : (flags & LS_CTIME) ? st->st_ctime : st->st_mtime;
        !          21536:                s = tmform(s, "%?%l", &tm);
        !          21537:                *s++ = ' ';
        !          21538:        }
        !          21539:        if (info)
        !          21540:        {
        !          21541:                while (*s = *info++) s++;
        !          21542:                *s++ = ' ';
        !          21543:        }
        !          21544:        while (*s = *name++) s++;
        !          21545:        if (flags & LS_MARK) switch (st->st_mode & S_IFMT)
        !          21546:        {
        !          21547:        case S_IFDIR:
        !          21548:                *s++ = '/';
        !          21549:                break;
        !          21550:        case S_IFLNK:
        !          21551:                *s++ = '@';
        !          21552:                break;
        !          21553:        case S_IFREG:
        !          21554:                if (st->st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)) *s++ = '*';
        !          21555:                break;
        !          21556:        }
        !          21557:        if (link)
        !          21558:        {
        !          21559:                (void)sprintf(s, " %s %s", (st->st_mode & S_IFMT) == S_IFLNK ? "->" : "==", link);
        !          21560:                while (*++s);
        !          21561:        }
        !          21562:        *s = 0;
        !          21563:        return(s);
        !          21564: }
        !          21565: 0707070000000003321006440044230044230000010000000462626300400003400000000642string/fmtmode.cUgsfGgsf/*
        !          21566:  * G. S. Fowler
        !          21567:  * AT&T Bell Laboratories
        !          21568:  *
        !          21569:  * return ls -l style file mode string given file mode bits
        !          21570:  */
        !          21571: 
        !          21572: #include "modelib.h"
        !          21573: 
        !          21574: char*
        !          21575: fmtmode(mode)
        !          21576: register int   mode;
        !          21577: {
        !          21578:        register char*          s;
        !          21579:        register struct modeop* p;
        !          21580: 
        !          21581:        static char             buf[MODELEN + 1];
        !          21582: 
        !          21583:        s = buf;
        !          21584:        for (p = modetab; p < &modetab[MODELEN]; p++)
        !          21585:                *s++ = p->name[((mode & p->mask1) >> p->shift1) | ((mode & p->mask2) >> p->shift2)];
        !          21586:        return(buf);
        !          21587: }
        !          21588: 0707070000000003331006440044230044230000010000000474537706700003400000004557string/fmtperm.cUgsfGgsf/*
        !          21589:  * G. S. Fowler
        !          21590:  * AT&T Bell Laboratories
        !          21591:  *
        !          21592:  * return strperm() expression for perm
        !          21593:  */
        !          21594: 
        !          21595: #include <ls.h>
        !          21596: 
        !          21597: char*
        !          21598: fmtperm(perm)
        !          21599: register int   perm;
        !          21600: {
        !          21601:        register char*  s;
        !          21602:        register char*  p;
        !          21603:        char*           o;
        !          21604: 
        !          21605:        static char     buf[32];
        !          21606: 
        !          21607:        s = buf;
        !          21608: 
        !          21609:        /*
        !          21610:         * ugo
        !          21611:         */
        !          21612: 
        !          21613:        p = s;
        !          21614:        *s++ = '+';
        !          21615:        o = s;
        !          21616:        if (perm & S_ISVTX) *s++ = 't';
        !          21617:        if ((perm & (S_ISUID|S_ISGID)) == (S_ISUID|S_ISGID))
        !          21618:        {
        !          21619:                perm &= ~(S_ISUID|S_ISGID);
        !          21620:                *s++ = 's';
        !          21621:        }
        !          21622:        if ((perm & (S_IRUSR|S_IRGRP|S_IROTH)) == (S_IRUSR|S_IRGRP|S_IROTH))
        !          21623:        {
        !          21624:                perm &= ~(S_IRUSR|S_IRGRP|S_IROTH);
        !          21625:                *s++ = 'r';
        !          21626:        }
        !          21627:        if ((perm & (S_IWUSR|S_IWGRP|S_IWOTH)) == (S_IWUSR|S_IWGRP|S_IWOTH))
        !          21628:        {
        !          21629:                perm &= ~(S_IWUSR|S_IWGRP|S_IWOTH);
        !          21630:                *s++ = 'w';
        !          21631:        }
        !          21632:        if ((perm & (S_IXUSR|S_IXGRP|S_IXOTH)) == (S_IXUSR|S_IXGRP|S_IXOTH))
        !          21633:        {
        !          21634:                perm &= ~(S_IXUSR|S_IXGRP|S_IXOTH);
        !          21635:                *s++ = 'x';
        !          21636:        }
        !          21637:        if (s == o) s = p;
        !          21638: 
        !          21639:        /*
        !          21640:         * ug
        !          21641:         */
        !          21642: 
        !          21643:        p = s;
        !          21644:        if (s > buf) *s++ = ',';
        !          21645:        *s++ = 'u';
        !          21646:        *s++ = 'g';
        !          21647:        *s++ = '+';
        !          21648:        o = s;
        !          21649:        if ((perm & (S_IRUSR|S_IRGRP)) == (S_IRUSR|S_IRGRP))
        !          21650:        {
        !          21651:                perm &= ~(S_IRUSR|S_IRGRP);
        !          21652:                *s++ = 'r';
        !          21653:        }
        !          21654:        if ((perm & (S_IWUSR|S_IWGRP)) == (S_IWUSR|S_IWGRP))
        !          21655:        {
        !          21656:                perm &= ~(S_IWUSR|S_IWGRP);
        !          21657:                *s++ = 'w';
        !          21658:        }
        !          21659:        if ((perm & (S_IXUSR|S_IXGRP)) == (S_IXUSR|S_IXGRP))
        !          21660:        {
        !          21661:                perm &= ~(S_IXUSR|S_IXGRP);
        !          21662:                *s++ = 'x';
        !          21663:        }
        !          21664:        if (s == o) s = p;
        !          21665: 
        !          21666:        /*
        !          21667:         * u
        !          21668:         */
        !          21669: 
        !          21670:        p = s;
        !          21671:        if (s > buf) *s++ = ',';
        !          21672:        *s++ = 'u';
        !          21673:        *s++ = '+';
        !          21674:        o = s;
        !          21675:        if (perm & S_ISUID) *s++ = 's';
        !          21676:        if (perm & S_IRUSR) *s++ = 'r';
        !          21677:        if (perm & S_IWUSR) *s++ = 'w';
        !          21678:        if (perm & S_IXUSR) *s++ = 'x';
        !          21679:        if (s == o) s = p;
        !          21680: 
        !          21681:        /*
        !          21682:         * go
        !          21683:         */
        !          21684: 
        !          21685:        p = s;
        !          21686:        if (s > buf) *s++ = ',';
        !          21687:        *s++ = 'g';
        !          21688:        *s++ = 'o';
        !          21689:        *s++ = '+';
        !          21690:        o = s;
        !          21691:        if ((perm & (S_IRGRP|S_IROTH)) == (S_IRGRP|S_IROTH))
        !          21692:        {
        !          21693:                perm &= ~(S_IRGRP|S_IROTH);
        !          21694:                *s++ = 'r';
        !          21695:        }
        !          21696:        if ((perm & (S_IWGRP|S_IWOTH)) == (S_IWGRP|S_IWOTH))
        !          21697:        {
        !          21698:                perm &= ~(S_IWGRP|S_IWOTH);
        !          21699:                *s++ = 'w';
        !          21700:        }
        !          21701:        if ((perm & (S_IXGRP|S_IXOTH)) == (S_IXGRP|S_IXOTH))
        !          21702:        {
        !          21703:                perm &= ~(S_IXGRP|S_IXOTH);
        !          21704:                *s++ = 'x';
        !          21705:        }
        !          21706:        if (s == o) s = p;
        !          21707: 
        !          21708:        /*
        !          21709:         * g
        !          21710:         */
        !          21711: 
        !          21712:        p = s;
        !          21713:        if (s > buf) *s++ = ',';
        !          21714:        *s++ = 'g';
        !          21715:        *s++ = '+';
        !          21716:        o = s;
        !          21717:        if (perm & S_ISGID) *s++ = 's';
        !          21718:        if (perm & S_IRGRP) *s++ = 'r';
        !          21719:        if (perm & S_IWGRP) *s++ = 'w';
        !          21720:        if (perm & S_IXGRP) *s++ = 'x';
        !          21721:        if (s == o) s = p;
        !          21722: 
        !          21723:        /*
        !          21724:         * o
        !          21725:         */
        !          21726: 
        !          21727:        p = s;
        !          21728:        if (s > buf) *s++ = ',';
        !          21729:        *s++ = 'o';
        !          21730:        *s++ = '+';
        !          21731:        o = s;
        !          21732:        if (perm & S_IROTH) *s++ = 'r';
        !          21733:        if (perm & S_IWOTH) *s++ = 'w';
        !          21734:        if (perm & S_IXOTH) *s++ = 'x';
        !          21735:        if (s == o) s = p;
        !          21736:        if (s == buf) *s++ = '0';
        !          21737:        *s = 0;
        !          21738:        return(buf);
        !          21739: }
        !          21740: 0707070000000003341006440044230044230000010000000474560133300003300000001455string/fmtuid.cUgsfGgsf/*
        !          21741:  * G. S. Fowler
        !          21742:  * AT&T Bell Laboratories
        !          21743:  *
        !          21744:  * uid number -> name
        !          21745:  */
        !          21746: 
        !          21747: #include <stdio.h>
        !          21748: #include <hash.h>
        !          21749: #define getpwuid       _SYS_getpwuid
        !          21750: #include <pwd.h>
        !          21751: #undef getpwuid
        !          21752: 
        !          21753: extern char*           strdup();
        !          21754: 
        !          21755: extern struct passwd*  getpwuid();
        !          21756: 
        !          21757: /*
        !          21758:  * return uid name given uid number
        !          21759:  */
        !          21760: 
        !          21761: char*
        !          21762: fmtuid(uid)
        !          21763: int    uid;
        !          21764: {
        !          21765:        register char*          name;
        !          21766:        register struct passwd* pw;
        !          21767: 
        !          21768:        static HASHTABLE*       uidtab;
        !          21769:        static char             buf[sizeof(int) * 3 + 1];
        !          21770: 
        !          21771:        if (!uidtab && !(uidtab = hashalloc((HASHTABLE*)0, HASH_set, HASH_ALLOCATE, HASH_namesize, sizeof(uid), HASH_name, "uidnum", 0))) (void)sprintf(name = buf, "%d", uid);
        !          21772:        else if (!(name = hashget(uidtab, &uid)))
        !          21773:        {
        !          21774:                if (pw = getpwuid(uid)) name = pw->pw_name;
        !          21775:                else (void)sprintf(name = buf, "%d", uid);
        !          21776:                (void)hashput(uidtab, (char*)0, name = strdup(name));
        !          21777:        }
        !          21778:        return(name);
        !          21779: }
        !          21780: 0707070000000003351006440044230044230000010000000475445740200003400000001123string/gethalf.cUgsfGgsf/*
        !          21781:  * Glenn Fowler
        !          21782:  * AT&T Bell Laboratories
        !          21783:  *
        !          21784:  * internal representation conversion support
        !          21785:  */
        !          21786: 
        !          21787: #include <swap.h>
        !          21788: #include <limits.h>
        !          21789: 
        !          21790: /*
        !          21791:  * construct a short from buffer p according to swap op {BYTE,HALF}
        !          21792:  */
        !          21793: 
        !          21794: #define GETHALF(p,B0,B1)       ((p[B0]<<(CHAR_BIT))|(p[B1]))
        !          21795: 
        !          21796: #if __STDC__ || __cplusplus
        !          21797: int
        !          21798: gethalf(register int op, const char* p)
        !          21799: #else
        !          21800: int
        !          21801: gethalf(op, p)
        !          21802: register int   op;
        !          21803: char*          p;
        !          21804: #endif
        !          21805: {
        !          21806:        register unsigned char* b;
        !          21807: 
        !          21808:        b = (unsigned char*)p;
        !          21809:        switch (op)
        !          21810:        {
        !          21811:        case 0:
        !          21812:        case HALF:
        !          21813:                return(GETHALF(b, 0, 1));
        !          21814:        case BYTE:
        !          21815:        case BYTE|HALF:
        !          21816:                return(GETHALF(b, 1, 0));
        !          21817:        }
        !          21818:        return(0);
        !          21819: }
        !          21820: 0707070000000003361006440044230044230000010000000475445754300003400000001366string/getlong.cUgsfGgsf/*
        !          21821:  * Glenn Fowler
        !          21822:  * AT&T Bell Laboratories
        !          21823:  *
        !          21824:  * internal representation conversion support
        !          21825:  */
        !          21826: 
        !          21827: #include <swap.h>
        !          21828: #include <limits.h>
        !          21829: 
        !          21830: /*
        !          21831:  * construct a long from buffer p according to swap op {HALF,LONG}
        !          21832:  */
        !          21833: 
        !          21834: #define GETLONG(p,B0,B1,B2,B3) ((((long)p[B0])<<(CHAR_BIT*3))|(((long)p[B1])<<(CHAR_BIT*2))|(((long)p[B2])<<(CHAR_BIT))|(((long)p[B3])))
        !          21835: 
        !          21836: #if __STDC__ || __cplusplus
        !          21837: long
        !          21838: getlong(register int op, const char* p)
        !          21839: #else
        !          21840: long
        !          21841: getlong(op, p)
        !          21842: register int   op;
        !          21843: char*          p;
        !          21844: #endif
        !          21845: {
        !          21846:        register unsigned char* b;
        !          21847: 
        !          21848:        b = (unsigned char*)p;
        !          21849:        switch (op)
        !          21850:        {
        !          21851:        case 0:
        !          21852:                return(GETLONG(b, 0, 1, 2, 3));
        !          21853:        case BYTE:
        !          21854:                return(GETLONG(b, 1, 0, 3, 2));
        !          21855:        case HALF:
        !          21856:                return(GETLONG(b, 2, 3, 0, 1));
        !          21857:        case BYTE|HALF:
        !          21858:                return(GETLONG(b, 3, 2, 1, 0));
        !          21859:        }
        !          21860:        return(0);
        !          21861: }
        !          21862: 0707070000000003371006440044230044230000010000000441570120400003300000000461string/memdup.cUgsfGgsf#include "FEATURE/memdup"
        !          21863: 
        !          21864: #ifdef _lib_memdup
        !          21865: 
        !          21866: int    _lib_dummy;
        !          21867: 
        !          21868: #else
        !          21869: 
        !          21870: /*
        !          21871:  * return a copy of s of n chars using malloc
        !          21872:  */
        !          21873: 
        !          21874: extern char*   malloc();
        !          21875: extern char*   memcpy();
        !          21876: 
        !          21877: char*
        !          21878: memdup(s, n)
        !          21879: register char* s;
        !          21880: register int   n;
        !          21881: {
        !          21882:        register char*  t;
        !          21883: 
        !          21884:        return((t = malloc(n)) ? memcpy(t, s, n) : 0);
        !          21885: }
        !          21886: 
        !          21887: #endif
        !          21888: 0707070000000003401006440044230044230000010000000445376040600003400000001455string/memswap.cUgsfGgsf/*
        !          21889:  * Glenn Fowler
        !          21890:  * AT&T Bell Laboratories
        !          21891:  *
        !          21892:  * internal representation conversion support
        !          21893:  */
        !          21894: 
        !          21895: #include <swap.h>
        !          21896: 
        !          21897: /*
        !          21898:  * swap buffer b of n bytes according to swap op {BYTE,HALF} in place
        !          21899:  */
        !          21900: 
        !          21901: char*
        !          21902: memswap(op, b, n)
        !          21903: int            op;
        !          21904: char*          b;
        !          21905: register int   n;
        !          21906: {
        !          21907:        register char*  p;
        !          21908:        register int    c;
        !          21909: 
        !          21910:        p = b;
        !          21911:        switch (op)
        !          21912:        {
        !          21913:        case BYTE:
        !          21914:                n = (n + 1) / 2;
        !          21915:                while (n--)
        !          21916:                {
        !          21917:                        c = *p;
        !          21918:                        *p = *(p + 1);
        !          21919:                        *(p + 1) = c;
        !          21920:                        p += 2;
        !          21921:                }
        !          21922:                break;
        !          21923:        case HALF:
        !          21924:                n = (n + 3) / 4;
        !          21925:                while (n--)
        !          21926:                {
        !          21927:                        c = *p;
        !          21928:                        *p = *(p + 2);
        !          21929:                        *(p + 2) = c;
        !          21930:                        c = *(p + 3);
        !          21931:                        *(p + 3) = *(p + 1);
        !          21932:                        *(p + 1) = c;
        !          21933:                        p += 4;
        !          21934:                }
        !          21935:                break;
        !          21936:        case BYTE|HALF:
        !          21937:                n = (n + 3) / 4;
        !          21938:                while (n--)
        !          21939:                {
        !          21940:                        c = *p;
        !          21941:                        *p = *(p + 3);
        !          21942:                        *(p + 3) = c;
        !          21943:                        c = *(p + 1);
        !          21944:                        *(p + 1) = *(p + 2);
        !          21945:                        *(p + 2) = c;
        !          21946:                        p += 4;
        !          21947:                }
        !          21948:                break;
        !          21949:        }
        !          21950:        return(b);
        !          21951: }
        !          21952: 0707070000000003411006440044230044230000010000000462626502300003500000001340string/modedata.cUgsfGgsf/*
        !          21953:  * G. S. Fowler
        !          21954:  * AT&T Bell Laboratories
        !          21955:  *
        !          21956:  * fmtmode() and strperm() readonly data
        !          21957:  */
        !          21958: 
        !          21959: #include "modelib.h"
        !          21960: 
        !          21961: #include <sys/types.h>
        !          21962: #include <sys/stat.h>
        !          21963: 
        !          21964: struct modeop  modetab[MODELEN] =
        !          21965: {
        !          21966:        0170000, 12, 0000000, 0, "?pc?d?b?-Cl?s???",
        !          21967:        0000400,  8, 0000000, 0, "-r",
        !          21968:        0000200,  7, 0000000, 0, "-w",
        !          21969:        0004000, 10, 0000100, 6, "-xSs",
        !          21970:        0000040,  5, 0000000, 0, "-r",
        !          21971:        0000020,  4, 0000000, 0, "-w",
        !          21972: #ifdef S_ICCTYP
        !          21973:        0003000,  8, 0000010, 3, "-x-xSs-x",
        !          21974: #else
        !          21975: #ifdef S_ENFMT
        !          21976:        0002000,  9, 0000010, 3, "-xls",
        !          21977: #else
        !          21978:        0002000,  9, 0000010, 3, "-xSs",
        !          21979: #endif
        !          21980: #endif
        !          21981:        0000004,  2, 0000000, 0, "-r",
        !          21982:        0000002,  1, 0000000, 0, "-w",
        !          21983: #ifdef S_ICCTYP
        !          21984:        0003000,  8, 0000001, 0, "-xyY-xeE",
        !          21985: #else
        !          21986:        0001000,  8, 0000001, 0, "-xTt",
        !          21987: #endif
        !          21988: };
        !          21989: 0707070000000003421006440044230044230000010000000462626505100003400000001010string/modelib.hUgsfGgsf/*
        !          21990:  * G. S. Fowler
        !          21991:  * AT&T Bell Laboratories
        !          21992:  *
        !          21993:  * fmtmode() and strperm() common definitions
        !          21994:  */
        !          21995: 
        !          21996: #ifndef __LIBMODE_H__
        !          21997: #define __LIBMODE_H__
        !          21998: 
        !          21999: #define MODELEN        10
        !          22000: 
        !          22001: #define modetab        _mode_table_    /* data hiding                          */
        !          22002: 
        !          22003: struct modeop                  /* ops for each char in mode string     */
        !          22004: {
        !          22005:        int     mask1;          /* first mask                           */
        !          22006:        int     shift1;         /* first shift count                    */
        !          22007:        int     mask2;          /* second mask                          */
        !          22008:        int     shift2;         /* second shift count                   */
        !          22009:        char*   name;           /* mode char using mask/shift as index  */
        !          22010: };
        !          22011: 
        !          22012: extern struct modeop   modetab[];
        !          22013: 
        !          22014: #endif
        !          22015: 0707070000000003431006440044230044230000010000000434221053700003400000000735string/puthalf.cUgsfGgsf/*
        !          22016:  * Glenn Fowler
        !          22017:  * AT&T Bell Laboratories
        !          22018:  *
        !          22019:  * internal representation conversion support
        !          22020:  */
        !          22021: 
        !          22022: #include <swap.h>
        !          22023: #include <limits.h>
        !          22024: 
        !          22025: /*
        !          22026:  * put a short into buffer p according to swap op {HALF,LONG}
        !          22027:  */
        !          22028: 
        !          22029: #define PUTHALF(p,n,B0,B1)     (p[B0]=n>>(CHAR_BIT),p[B1]=n)
        !          22030: 
        !          22031: void
        !          22032: puthalf(op, p, n)
        !          22033: register int   op;
        !          22034: register char* p;
        !          22035: register int   n;
        !          22036: {
        !          22037:        switch (op)
        !          22038:        {
        !          22039:        case 0:
        !          22040:        case HALF:
        !          22041:                PUTHALF(p, n, 0, 1);
        !          22042:                break;
        !          22043:        case BYTE:
        !          22044:        case BYTE|HALF:
        !          22045:                PUTHALF(p, n, 1, 0);
        !          22046:                break;
        !          22047:        }
        !          22048: }
        !          22049: 0707070000000003441006440044230044230000010000000434221037400003400000001147string/putlong.cUgsfGgsf/*
        !          22050:  * Glenn Fowler
        !          22051:  * AT&T Bell Laboratories
        !          22052:  *
        !          22053:  * internal representation conversion support
        !          22054:  */
        !          22055: 
        !          22056: #include <swap.h>
        !          22057: #include <limits.h>
        !          22058: 
        !          22059: /*
        !          22060:  * put a long into buffer p according to swap op {HALF,LONG}
        !          22061:  */
        !          22062: 
        !          22063: #define PUTLONG(p,n,B0,B1,B2,B3) (p[B0]=n>>(CHAR_BIT*3),p[B1]=n>>(CHAR_BIT*2),p[B2]=n>>(CHAR_BIT),p[B3]=n)
        !          22064: 
        !          22065: void
        !          22066: putlong(op, p, n)
        !          22067: register int   op;
        !          22068: register char* p;
        !          22069: register long  n;
        !          22070: {
        !          22071:        switch (op)
        !          22072:        {
        !          22073:        case 0:
        !          22074:                PUTLONG(p, n, 0, 1, 2, 3);
        !          22075:                break;
        !          22076:        case BYTE:
        !          22077:                PUTLONG(p, n, 1, 0, 3, 2);
        !          22078:                break;
        !          22079:        case HALF:
        !          22080:                PUTLONG(p, n, 2, 3, 0, 1);
        !          22081:                break;
        !          22082:        case BYTE|HALF:
        !          22083:                PUTLONG(p, n, 3, 2, 1, 0);
        !          22084:                break;
        !          22085:        }
        !          22086: }
        !          22087: 0707070000000003451006440044230044230000010000000414141335100003400000000266string/strcopy.cUgsfGgsf/*
        !          22088:  * copy t into s, return a pointer to the end of s ('\0')
        !          22089:  */
        !          22090: 
        !          22091: char*
        !          22092: strcopy(s, t)
        !          22093: register char* s;
        !          22094: register char* t;
        !          22095: {
        !          22096:        if (!t) return(s);
        !          22097:        while (*s++ = *t++);
        !          22098:        return(--s);
        !          22099: }
        !          22100: 0707070000000003461006440044230044230000010000000441570121100003300000000512string/strdup.cUgsfGgsf#include "FEATURE/strdup"
        !          22101: 
        !          22102: #ifdef _lib_strdup
        !          22103: 
        !          22104: int    _lib_dummy;
        !          22105: 
        !          22106: #else
        !          22107: 
        !          22108: /*
        !          22109:  * return a copy of s using malloc
        !          22110:  */
        !          22111: 
        !          22112: extern char*   malloc();
        !          22113: extern char*   memcpy();
        !          22114: 
        !          22115: extern int     strlen();
        !          22116: 
        !          22117: char*
        !          22118: strdup(s)
        !          22119: register char  *s;
        !          22120: {
        !          22121:        register char*  t;
        !          22122:        register int    n;
        !          22123: 
        !          22124:        return((t = malloc(n = strlen(s) + 1)) ? memcpy(t, s, n) : 0);
        !          22125: }
        !          22126: 
        !          22127: #endif
        !          22128: 0707070000000003471006440044230044230000010000000462647553000003700000001663string/strelapsed.cUgsfGgsf/*
        !          22129:  * Glenn Fowler
        !          22130:  * AT&T Bell Laboratories
        !          22131:  *
        !          22132:  * parse elapsed time in 1/n secs from s
        !          22133:  * compatible with fmtelapsed()
        !          22134:  * if e!=0 then it is set to first unrecognized char
        !          22135:  */
        !          22136: 
        !          22137: #include <ctype.h>
        !          22138: 
        !          22139: unsigned long
        !          22140: strelapsed(s, e, n)
        !          22141: register char* s;
        !          22142: char**         e;
        !          22143: int            n;
        !          22144: {
        !          22145:        register int            c;
        !          22146:        register unsigned long  v;
        !          22147:        unsigned long           t = 0;
        !          22148:        int                     f = 0;
        !          22149:        int                     m;
        !          22150:        char*                   last;
        !          22151: 
        !          22152:        while (isspace(*s)) s++;
        !          22153:        while (*(last = s))
        !          22154:        {
        !          22155:                v = 0;
        !          22156:                while ((c = *s++) >= '0' && c <= '9')
        !          22157:                        v = v * 10 + c - '0';
        !          22158:                v *= n;
        !          22159:                if (c == '.')
        !          22160:                        for (m = n; (c = *s++) >= '0' && c <= '9';)
        !          22161:                                f += (m /= 10) * (c - '0');
        !          22162:                switch (c)
        !          22163:                {
        !          22164:                case 'S':
        !          22165:                        v *= 20;
        !          22166:                case 'Y':
        !          22167:                        v *= 12;
        !          22168:                case 'M':
        !          22169:                        v *= 4;
        !          22170:                case 'w':
        !          22171:                        v *= 7;
        !          22172:                case 'd':
        !          22173:                        v *= 24;
        !          22174:                case 'h':
        !          22175:                        v *= 60;
        !          22176:                case 'm':
        !          22177:                        v *= 60;
        !          22178:                        break;
        !          22179:                case '0':
        !          22180:                        s--;
        !          22181:                case 's':
        !          22182:                        v += f;
        !          22183:                        f = 0;
        !          22184:                        break;
        !          22185:                default:
        !          22186:                        goto done;
        !          22187:                }
        !          22188:                t += v;
        !          22189:        }
        !          22190:  done:
        !          22191:        if (e) *e = last;
        !          22192:        return(t);
        !          22193: }
        !          22194: 0707070000000003501006440044230044230000010000000475335032200003500000001032string/strerror.cUgsfGgsf/*
        !          22195:  * G. S. Fowler
        !          22196:  * AT&T Bell Laboratories
        !          22197:  *
        !          22198:  * return error message string given errno
        !          22199:  */
        !          22200: 
        !          22201: #include "FEATURE/strerror"
        !          22202: 
        !          22203: #ifdef _lib_strerror
        !          22204: 
        !          22205: int    _lib_dummy;
        !          22206: 
        !          22207: #else
        !          22208: 
        !          22209: /*
        !          22210:  * the define/undef makes the non-macro sprintf visible below (huh?)
        !          22211:  */
        !          22212: 
        !          22213: #define _stdsprintf    sprintf
        !          22214: #include <stdio.h>
        !          22215: #undef sprintf
        !          22216: 
        !          22217: char*
        !          22218: strerror(err)
        !          22219: int    err;
        !          22220: {
        !          22221:        static char     msg[28];
        !          22222: 
        !          22223:        extern int      sys_nerr;
        !          22224:        extern char*    sys_errlist[];
        !          22225: 
        !          22226:        if (err > 0 && err <= sys_nerr) return(sys_errlist[err]);
        !          22227:        (void)sprintf(msg, "Error %d", err);
        !          22228:        return(msg);
        !          22229: }
        !          22230: 
        !          22231: #endif
        !          22232: 0707070000000003511006440044230044230000010000000414141276200003300000000745string/stresc.cUgsfGgsf/*
        !          22233:  * G. S. Fowler
        !          22234:  * AT&T Bell Laboratories
        !          22235:  *
        !          22236:  * convert \x character constants in s in place
        !          22237:  * the length of the converted s is returned (may have imbedded \0's)
        !          22238:  */
        !          22239: 
        !          22240: extern int     chresc(/* char* string, char** next */);
        !          22241: 
        !          22242: int
        !          22243: stresc(s)
        !          22244: register char* s;
        !          22245: {
        !          22246:        register char*  t;
        !          22247:        register int    c;
        !          22248:        char*           b;
        !          22249:        char*           p;
        !          22250: 
        !          22251:        b = t = s;
        !          22252:        for (;;)
        !          22253:        {
        !          22254:                switch (c = *s++)
        !          22255:                {
        !          22256:                case '\\':
        !          22257:                        c = chresc(s - 1, &p);
        !          22258:                        s = p;
        !          22259:                        break;
        !          22260:                case 0:
        !          22261:                        *t = 0;
        !          22262:                        return(t - b);
        !          22263:                }
        !          22264:                *t++ = c;
        !          22265:        }
        !          22266: }
        !          22267: 0707070000000003521006440044230044230000010000000466675504700003400000011764string/streval.cUgsfGgsf/*
        !          22268:  * G. S. Fowler
        !          22269:  * D. G. Korn
        !          22270:  * AT&T Bell Laboratories
        !          22271:  *
        !          22272:  * long integer arithmetic expression evaluator
        !          22273:  * long constants may be represented as:
        !          22274:  *
        !          22275:  *     0ooo            octal
        !          22276:  *     0[xX]hhh        hexadecimal
        !          22277:  *     ddd             decimal
        !          22278:  *     n#ccc           base n, 2 <= b <= 36
        !          22279:  *
        !          22280:  * NOTE: all operands are evaluated as both the parse
        !          22281:  *      and evaluation are done on the fly
        !          22282:  */
        !          22283: 
        !          22284: #include <ctype.h>
        !          22285: 
        !          22286: #define getchr()       (*cur.nextchr++)
        !          22287: #define peekchr()      (*cur.nextchr)
        !          22288: #define ungetchr()     (cur.nextchr--)
        !          22289: 
        !          22290: #define pushchr(s)     {struct vars old;old=cur;cur.nextchr=(s);cur.errmsg=0
        !          22291: #define popchr()       cur=old;}
        !          22292: #define error(msg)     return(seterror(msg))
        !          22293: 
        !          22294: struct vars                    /* vars stacked per invocation          */
        !          22295: {
        !          22296:        char*   nextchr;        /* next char in current expression      */
        !          22297:        char*   errchr;         /* next char after error                */
        !          22298:        char*   errmsg;         /* error message text                   */
        !          22299: };
        !          22300: 
        !          22301: static struct vars     cur;
        !          22302: 
        !          22303: static long    (*convert)();   /* external conversion routine          */
        !          22304: 
        !          22305: static long    expr();         /* subexpression evaluator              */
        !          22306: static long    seterror();     /* set error message string             */
        !          22307: 
        !          22308: extern long    strton();
        !          22309: 
        !          22310: /*
        !          22311:  * evaluate an integer arithmetic expression in s
        !          22312:  *
        !          22313:  * (long)(*convert)(char* string, char** end) is a user supplied
        !          22314:  * conversion routine that is called when unknown chars are encountered
        !          22315:  * in s string points to the part to be converted and end is adjusted to
        !          22316:  * point to the next non-converted character; if string is 0 then end
        !          22317:  * points to an error message string
        !          22318:  *
        !          22319:  * NOTE: (*convert)() may call streval()
        !          22320:  */
        !          22321: 
        !          22322: long
        !          22323: streval(s, end, conv)
        !          22324: char*  s;
        !          22325: char** end;
        !          22326: long   (*conv)();
        !          22327: {
        !          22328:        long    n;
        !          22329: 
        !          22330:        pushchr(s);
        !          22331:        convert = conv;
        !          22332:        n = expr(0);
        !          22333:        if (peekchr() == ':') (void)seterror("invalid use of :");
        !          22334:        if (cur.errmsg)
        !          22335:        {
        !          22336:                if (convert) (void)(*convert)((char*)0, &cur.errmsg);
        !          22337:                cur.nextchr = cur.errchr;
        !          22338:                n = 0;
        !          22339:        }
        !          22340:        if (end) *end = cur.nextchr;
        !          22341:        popchr();
        !          22342:        return(n);
        !          22343: }
        !          22344: 
        !          22345: /*   
        !          22346:  * evaluate a subexpression with precedence
        !          22347:  */
        !          22348: 
        !          22349: static long
        !          22350: expr(precedence)
        !          22351: register int   precedence;
        !          22352: {
        !          22353:        register int    c;
        !          22354:        register long   n;
        !          22355:        register long   x;
        !          22356:        char*           pos;
        !          22357:        int             operand = 1;
        !          22358: 
        !          22359:        while (isspace(c = getchr()));
        !          22360:        switch (c)
        !          22361:        {
        !          22362:        case 0:
        !          22363:                ungetchr();
        !          22364:                error("more tokens expected");
        !          22365:        case '-':
        !          22366:                n = -expr(12);
        !          22367:                break;
        !          22368:        case '+':
        !          22369:                n = expr(12);
        !          22370:                break;
        !          22371:        case '!':
        !          22372:                n = !expr(12);
        !          22373:                break;
        !          22374:        case '~':
        !          22375:                n = ~expr(12);
        !          22376:                break;
        !          22377:        default:
        !          22378:                ungetchr();
        !          22379:                n = 0;
        !          22380:                operand = 0;
        !          22381:                break;
        !          22382:        }
        !          22383:        for (;;)
        !          22384:        {
        !          22385:                switch (c = getchr())
        !          22386:                {
        !          22387:                case 0:
        !          22388:                        goto done;
        !          22389:                case ')':
        !          22390:                        if (!precedence) error("too many )'s");
        !          22391:                        goto done;
        !          22392:                case '(':
        !          22393:                        n = expr(1);
        !          22394:                        if (getchr() != ')')
        !          22395:                        {
        !          22396:                                ungetchr();
        !          22397:                                error("closing ) expected");
        !          22398:                        }
        !          22399:                gotoperand:
        !          22400:                        if (operand) error("operator expected");
        !          22401:                        operand = 1;
        !          22402:                        continue;
        !          22403:                case '?':
        !          22404:                        if (precedence > 1) goto done;
        !          22405:                        if (peekchr() == ':')
        !          22406:                        {
        !          22407:                                getchr();
        !          22408:                                x = expr(2);
        !          22409:                                if (!n) n = x;
        !          22410:                        }
        !          22411:                        else
        !          22412:                        {
        !          22413:                                x = expr(2);
        !          22414:                                if (getchr() != ':')
        !          22415:                                {
        !          22416:                                        ungetchr();
        !          22417:                                        error(": expected for ? operator");
        !          22418:                                }
        !          22419:                                if (n)
        !          22420:                                {
        !          22421:                                        n = x;
        !          22422:                                        (void)expr(2);
        !          22423:                                }
        !          22424:                                else n = expr(2);
        !          22425:                        }
        !          22426:                        break;
        !          22427:                case ':':
        !          22428:                        goto done;
        !          22429:                case '|':
        !          22430:                        if (peekchr() == '|')
        !          22431:                        {
        !          22432:                                if (precedence > 2) goto done;
        !          22433:                                getchr();
        !          22434:                                x = expr(3);
        !          22435:                                n = n || x;
        !          22436:                        }
        !          22437:                        else
        !          22438:                        {
        !          22439:                                if (precedence > 3) goto done;
        !          22440:                                x = expr(4);
        !          22441:                                n |= x;
        !          22442:                        }
        !          22443:                        break;
        !          22444:                case '^':
        !          22445:                        if (precedence > 4) goto done;
        !          22446:                        x = expr(5);
        !          22447:                        n ^= x;
        !          22448:                        break;
        !          22449:                case '&':
        !          22450:                        if (peekchr() == '&')
        !          22451:                        {
        !          22452:                                if (precedence > 2) goto done;
        !          22453:                                getchr();
        !          22454:                                x = expr(3);
        !          22455:                                n = n && x;
        !          22456:                        }
        !          22457:                        else
        !          22458:                        {
        !          22459:                                if (precedence > 5) goto done;
        !          22460:                                x = expr(6);
        !          22461:                                n &= x;
        !          22462:                        }
        !          22463:                        break;
        !          22464:                case '=':
        !          22465:                case '!':
        !          22466:                        if (peekchr() != '=') error("operator syntax error");
        !          22467:                        if (precedence > 6) goto done;
        !          22468:                        getchr();
        !          22469:                        x = expr(7);
        !          22470:                        if (c == '=') n = n == x;
        !          22471:                        else n = n != x;
        !          22472:                        break;
        !          22473:                case '<':
        !          22474:                case '>':
        !          22475:                        if (peekchr() == c)
        !          22476:                        {
        !          22477:                                if (precedence > 8) goto done;
        !          22478:                                getchr();
        !          22479:                                x = expr(9);
        !          22480:                                if (c == '<') n <<= x;
        !          22481:                                else n >>= x;
        !          22482:                        }
        !          22483:                        else
        !          22484:                        {
        !          22485:                                if (precedence > 7) goto done;
        !          22486:                                if (peekchr() == '=')
        !          22487:                                {
        !          22488:                                        getchr();
        !          22489:                                        x = expr(8);
        !          22490:                                        if (c == '<') n = n <= x;
        !          22491:                                        else n = n >= x;
        !          22492:                                }
        !          22493:                                else
        !          22494:                                {
        !          22495:                                        x = expr(8);
        !          22496:                                        if (c == '<') n = n < x;
        !          22497:                                        else n = n > x;
        !          22498:                                }
        !          22499:                        }
        !          22500:                        break;
        !          22501:                case '+':
        !          22502:                case '-':
        !          22503:                        if (precedence > 9) goto done;
        !          22504:                        x = expr(10);
        !          22505:                        if (c == '+') n +=  x;
        !          22506:                        else n -= x;
        !          22507:                        break;
        !          22508:                case '*':
        !          22509:                case '/':
        !          22510:                case '%':
        !          22511:                        if (precedence > 10) goto done;
        !          22512:                        x = expr(11);
        !          22513:                        if (c == '*') n *= x;
        !          22514:                        else if (x == 0) error("divide by zero");
        !          22515:                        else if (c == '/') n /= x;
        !          22516:                        else n %= x;
        !          22517:                        break;
        !          22518:                default:
        !          22519:                        if (isspace(c)) continue;
        !          22520:                        pos = --cur.nextchr;
        !          22521:                        if (isdigit(c)) n = strton(cur.nextchr, &cur.nextchr, 0);
        !          22522:                        else if (convert) n = (*convert)(cur.nextchr, &cur.nextchr);
        !          22523:                        if (cur.nextchr == pos) error("syntax error");
        !          22524:                        goto gotoperand;
        !          22525:                }
        !          22526:                if (cur.errmsg) return(0);
        !          22527:                if (!operand) error("operand expected");
        !          22528:        }
        !          22529:  done:
        !          22530:        ungetchr();
        !          22531:        if (!operand) error("operand expected");
        !          22532:        return(n);
        !          22533: }
        !          22534: 
        !          22535: /*
        !          22536:  * set error message string
        !          22537:  */
        !          22538: 
        !          22539: static long
        !          22540: seterror(msg)
        !          22541: char*  msg;
        !          22542: {
        !          22543:        if (!cur.errmsg) cur.errmsg = msg;
        !          22544:        cur.errchr = cur.nextchr;
        !          22545:        cur.nextchr = "";
        !          22546:        return(0);
        !          22547: }
        !          22548: 0707070000000003531006440044230044230000010000000474561126300003300000002131string/strgid.cUgsfGgsf/*
        !          22549:  * G. S. Fowler
        !          22550:  * AT&T Bell Laboratories
        !          22551:  *
        !          22552:  * gid name -> number
        !          22553:  */
        !          22554: 
        !          22555: #include <hash.h>
        !          22556: 
        !          22557: #define getpwnam       _SYS_getpwnam
        !          22558: #define getgrnam       _SYS_getgrnam
        !          22559: #include <pwd.h>
        !          22560: #include <grp.h>
        !          22561: #undef getpwnam
        !          22562: #undef getgrnam
        !          22563: extern struct passwd*  getpwnam();
        !          22564: extern struct group*   getgrnam();
        !          22565: 
        !          22566: typedef struct
        !          22567: {
        !          22568:        HASH_HEADER;
        !          22569:        int     id;
        !          22570: } bucket;
        !          22571: 
        !          22572: /*
        !          22573:  * return gid number given gid/uid name
        !          22574:  * gid attempted first, then uid->pw_gid
        !          22575:  * -1 on first error for a given name
        !          22576:  * -2 on subsequent errors for a given name
        !          22577:  */
        !          22578: 
        !          22579: int
        !          22580: strgid(name)
        !          22581: char*  name;
        !          22582: {
        !          22583:        register struct group*  gr;
        !          22584:        register struct passwd* pw;
        !          22585:        register bucket*        b;
        !          22586: 
        !          22587:        static HASHTABLE*       gidtab;
        !          22588: 
        !          22589:        if (!gidtab && !(gidtab = hashalloc((HASHTABLE*)0, HASH_set, HASH_ALLOCATE, HASH_name, "gidnam", 0))) return(-1);
        !          22590:        if (b = (bucket*)hashlook(gidtab, name, HASH_LOOKUP|HASH_FIXED, (char*)sizeof(bucket))) return(b->id);
        !          22591:        if (!(b = (bucket*)hashlook(gidtab, (char*)0, HASH_CREATE|HASH_FIXED, (char*)sizeof(bucket)))) return(-1);
        !          22592:        if (gr = getgrnam(name)) return(b->id = gr->gr_gid);
        !          22593:        if (pw = getpwnam(name)) return(b->id = pw->pw_gid);
        !          22594:        b->id = -2;
        !          22595:        return(-1);
        !          22596: }
        !          22597: 0707070000000003541006440044230044230000010000000472462027300003500000017615string/strmatch.cUgsfGgsf/*
        !          22598:  * D. G. Korn
        !          22599:  * G. S. Fowler
        !          22600:  * AT&T Bell Laboratories
        !          22601:  *
        !          22602:  * match shell file patterns -- derived from Bourne and Korn shell gmatch()
        !          22603:  *
        !          22604:  *     sh pattern      egrep RE        description
        !          22605:  *     ----------      --------        -----------
        !          22606:  *     *               .*              0 or more chars
        !          22607:  *     ?               .               any single char
        !          22608:  *     [.]             [.]             char class
        !          22609:  *     [!.]            [^.]            negated char class
        !          22610:  *     [[:.:]]         [[:.:]]         ctype class
        !          22611:  *     [[=.=]]         [[=.=]]         equivalence class
        !          22612:  *     *(.)            (.)*            0 or more of
        !          22613:  *     +(.)            (.)+            1 or more of
        !          22614:  *     ?(.)            (.)?            0 or 1 of
        !          22615:  *     (.)             (.)             1 of
        !          22616:  *     @(.)            (.)             1 of
        !          22617:  *     a|b             a|b             a or b
        !          22618:  *     a&b                             a and b
        !          22619:  *     !(.)                            none of
        !          22620:  *
        !          22621:  * \ used to escape metacharacters
        !          22622:  *
        !          22623:  *     *, ?, (, |, &, ), [, \ must be \'d outside of [...]
        !          22624:  *     only ] must be \'d inside [...]
        !          22625:  *
        !          22626:  * BUG: unbalanced ) terminates top level pattern
        !          22627:  */
        !          22628: 
        !          22629: #include <ctype.h>
        !          22630: 
        !          22631: #ifndef isequiv
        !          22632: #define isequiv(a,s)   ((a)==(s))
        !          22633: #endif
        !          22634: 
        !          22635: #ifndef isxdigit
        !          22636: #define isxdigit(c)    ((c)>='0'&&(c)<='9'||(c)>='a'&&(c)<='f'||(c)>='A'&&(c)<='F')
        !          22637: #endif
        !          22638: 
        !          22639: #define CODE(n,c1,c2,c3,c4,c5) (((n)<<25)|(((c1)-'a')<<20)|(((c2)-'a')<<15)|(((c3)-'a')<<10)|(((c4)-'a')<<5)|((c5)-'a'))
        !          22640: 
        !          22641: #ifdef MULTIBYTE
        !          22642: 
        !          22643: #include "national.h"
        !          22644: 
        !          22645: #define REGISTER
        !          22646: 
        !          22647: #define C_MASK         (3<<(7*ESS_MAXCHAR))    /* character classes    */
        !          22648: #define getchar(x)     mb_getchar((unsigned char**)(&(x)))
        !          22649: 
        !          22650: static int             mb_getchar();
        !          22651: 
        !          22652: #else
        !          22653: 
        !          22654: #define REGISTER       register
        !          22655: 
        !          22656: #define getchar(x)     (*x++)
        !          22657: 
        !          22658: #endif
        !          22659: 
        !          22660: #define getsource(s,e) (((s)>=(e))?0:getchar(s))
        !          22661: 
        !          22662: static char*           endmatch;
        !          22663: static int             minmatch;
        !          22664: 
        !          22665: static int             grpmatch();
        !          22666: static int             onematch();
        !          22667: static char*           gobble();
        !          22668: 
        !          22669: /*
        !          22670:  * strmatch compares the string s with the shell pattern p
        !          22671:  * returns 1 for match 0 otherwise
        !          22672:  */
        !          22673: 
        !          22674: int
        !          22675: strmatch(s, p)
        !          22676: register char* s;
        !          22677: char*          p;
        !          22678: {
        !          22679:        minmatch = 0;
        !          22680:        return(grpmatch(s, p, s + strlen(s), (char*)0));
        !          22681: }
        !          22682: 
        !          22683: /*
        !          22684:  * leading substring match
        !          22685:  * first char after end of substring returned
        !          22686:  * 0 returned if no match
        !          22687:  * m: (0-min, 1-max) match
        !          22688:  */
        !          22689: 
        !          22690: char*
        !          22691: submatch(s, p, m)
        !          22692: register char* s;
        !          22693: char*          p;
        !          22694: int            m;
        !          22695: {
        !          22696:        endmatch = 0;
        !          22697:        minmatch = !m;
        !          22698:        (void)grpmatch(s, p, s + strlen(s), (char*)0);
        !          22699:        return(endmatch);
        !          22700: }
        !          22701: 
        !          22702: /*
        !          22703:  * match any pattern in a group
        !          22704:  * | and & subgroups are parsed here
        !          22705:  */
        !          22706: 
        !          22707: static int
        !          22708: grpmatch(s, p, e, g)
        !          22709: char*          s;
        !          22710: register char* p;
        !          22711: char*          e;
        !          22712: char*          g;
        !          22713: {
        !          22714:        register char*  a;
        !          22715: 
        !          22716:        do
        !          22717:        {
        !          22718:                a = p;
        !          22719:                do
        !          22720:                {
        !          22721:                        if (!onematch(s, a, e, g)) break;
        !          22722:                } while (a = gobble(a, '&'));
        !          22723:                if (!a) return(1);
        !          22724:        } while (p = gobble(p, '|'));
        !          22725:        return(0);
        !          22726: }
        !          22727: 
        !          22728: /*
        !          22729:  * match a single pattern
        !          22730:  * e is the end (0) of the substring in s
        !          22731:  * g marks the start of a repeated subgroup pattern
        !          22732:  */
        !          22733: 
        !          22734: static int
        !          22735: onematch(s, p, e, g)
        !          22736: char*          s;
        !          22737: REGISTER char* p;
        !          22738: char*          e;
        !          22739: char*          g;
        !          22740: {
        !          22741:        register int    pc;
        !          22742:        register int    sc;
        !          22743:        register int    n;
        !          22744:        char*           olds;
        !          22745:        char*           oldp;
        !          22746: 
        !          22747:        do
        !          22748:        {
        !          22749:                olds = s;
        !          22750:                sc = getsource(s, e);
        !          22751:                switch (pc = getchar(p))
        !          22752:                {
        !          22753:                case '(':
        !          22754:                case '*':
        !          22755:                case '?':
        !          22756:                case '+':
        !          22757:                case '@':
        !          22758:                case '!':
        !          22759:                        if (pc == '(' || *p == '(')
        !          22760:                        {
        !          22761:                                char*   subp;
        !          22762: 
        !          22763:                                s = olds;
        !          22764:                                oldp = p - 1;
        !          22765:                                subp = p + (pc != '(');
        !          22766:                                if (!(p = gobble(subp, 0))) return(0);
        !          22767:                                if (pc == '*' || pc == '?' || pc == '+' && oldp == g)
        !          22768:                                {
        !          22769:                                        if (onematch(s, p, e, (char*)0)) return(1);
        !          22770:                                        if (!sc || !getsource(s, e)) return(0);
        !          22771:                                }
        !          22772:                                if (pc == '*' || pc == '+') p = oldp;
        !          22773:                                pc = (pc != '!');
        !          22774:                                do
        !          22775:                                {
        !          22776:                                        if (grpmatch(olds, subp, s, (char*)0) == pc && onematch(s, p, e, oldp)) return(1);
        !          22777:                                } while (s < e && getchar(s));
        !          22778:                                return(0);
        !          22779:                        }
        !          22780:                        else if (pc == '*')
        !          22781:                        {
        !          22782:                                /*
        !          22783:                                 * several stars are the same as one
        !          22784:                                 */
        !          22785: 
        !          22786:                                while (*p == '*')
        !          22787:                                        if (*(p + 1) == '(') break;
        !          22788:                                        else p++;
        !          22789:                                oldp = p;
        !          22790:                                switch (pc = getchar(p))
        !          22791:                                {
        !          22792:                                case '@':
        !          22793:                                case '!':
        !          22794:                                case '+':
        !          22795:                                        n = *p == '(';
        !          22796:                                        break;
        !          22797:                                case '(':
        !          22798:                                case '[':
        !          22799:                                case '?':
        !          22800:                                case '*':
        !          22801:                                        n = 1;
        !          22802:                                        break;
        !          22803:                                case 0:
        !          22804:                                        endmatch = minmatch ? olds : e;
        !          22805:                                        /*FALLTHROUGH*/
        !          22806:                                case '|':
        !          22807:                                case '&':
        !          22808:                                case ')':
        !          22809:                                        return(1);
        !          22810:                                case '\\':
        !          22811:                                        if (!(pc = getchar(p))) return(0);
        !          22812:                                        /*FALLTHROUGH*/
        !          22813:                                default:
        !          22814:                                        n = 0;
        !          22815:                                        break;
        !          22816:                                }
        !          22817:                                p = oldp;
        !          22818:                                for (;;)
        !          22819:                                {
        !          22820:                                        if ((n || pc == sc) && onematch(olds, p, e, (char*)0)) return(1);
        !          22821:                                        if (!sc) return(0);
        !          22822:                                        olds = s;
        !          22823:                                        sc = getsource(s, e);
        !          22824:                                }
        !          22825:                        }
        !          22826:                        else if (pc != '?' && pc != sc) return(0);
        !          22827:                        break;
        !          22828:                case 0:
        !          22829:                        endmatch = olds;
        !          22830:                        if (minmatch) return(1);
        !          22831:                        /*FALLTHROUGH*/
        !          22832:                case '|':
        !          22833:                case '&':
        !          22834:                case ')':
        !          22835:                        return(!sc);
        !          22836:                case '[':
        !          22837:                        {
        !          22838:                                int     ok = 0;
        !          22839:                                int     invert;
        !          22840: 
        !          22841:                                n = 0;
        !          22842:                                if (invert = *p == '!') p++;
        !          22843:                                for (;;)
        !          22844:                                {
        !          22845:                                        if (!(pc = getchar(p))) return(0);
        !          22846:                                        else if (pc == '[' && (*p == ':' || *p == '='))
        !          22847:                                        {
        !          22848:                                                char*   v;
        !          22849:                                                int     x = 0;
        !          22850: 
        !          22851:                                                n = getchar(p);
        !          22852:                                                v = p;
        !          22853:                                                for (;;)
        !          22854:                                                {
        !          22855:                                                        if (!(pc = getchar(p))) return(0);
        !          22856:                                                        if (pc == n && *p == ']') break;
        !          22857:                                                        x++;
        !          22858:                                                }
        !          22859:                                                pc = getchar(p);
        !          22860:                                                if (ok) /* skip */;
        !          22861:                                                else if (n == ':') switch (CODE(x, v[0], v[1], v[2], v[3], v[4]))
        !          22862:                                                {
        !          22863:                                                case CODE(5,'a','l','n','u','m'):
        !          22864:                                                        if (isalnum(sc)) ok = 1;
        !          22865:                                                        break;
        !          22866:                                                case CODE(5,'a','l','p','h','a'):
        !          22867:                                                        if (isalpha(sc)) ok = 1;
        !          22868:                                                        break;
        !          22869:                                                case CODE(5,'c','n','t','r','l'):
        !          22870:                                                        if (iscntrl(sc)) ok = 1;
        !          22871:                                                        break;
        !          22872:                                                case CODE(5,'d','i','g','i','t'):
        !          22873:                                                        if (isdigit(sc)) ok = 1;
        !          22874:                                                        break;
        !          22875:                                                case CODE(5,'g','r','a','p','h'):
        !          22876:                                                        if (isgraph(sc)) ok = 1;
        !          22877:                                                        break;
        !          22878:                                                case CODE(5,'l','o','w','e','r'):
        !          22879:                                                        if (islower(sc)) ok = 1;
        !          22880:                                                        break;
        !          22881:                                                case CODE(5,'p','r','i','n','t'):
        !          22882:                                                        if (isprint(sc)) ok = 1;
        !          22883:                                                        break;
        !          22884:                                                case CODE(5,'p','u','n','c','t'):
        !          22885:                                                        if (ispunct(sc)) ok = 1;
        !          22886:                                                        break;
        !          22887:                                                case CODE(5,'s','p','a','c','e'):
        !          22888:                                                        if (isspace(sc)) ok = 1;
        !          22889:                                                        break;
        !          22890:                                                case CODE(5,'u','p','p','e','r'):
        !          22891:                                                        if (isupper(sc)) ok = 1;
        !          22892:                                                        break;
        !          22893:                                                case CODE(6,'x','d','i','g','i'):
        !          22894:                                                        if (v[5] != 't') return(0);
        !          22895:                                                        if (isxdigit(sc)) ok = 1;
        !          22896:                                                        break;
        !          22897:                                                default:
        !          22898:                                                        return(0);
        !          22899:                                                }
        !          22900:                                                else
        !          22901:                                                {
        !          22902:                                                        pc = getchar(v);
        !          22903:                                                        if (isequiv(sc, pc)) ok = 1;
        !          22904:                                                }
        !          22905:                                                n = 1;
        !          22906:                                        }
        !          22907:                                        else if (pc == ']' && n)
        !          22908:                                        {
        !          22909:                                                if (ok != invert) break;
        !          22910:                                                return(0);
        !          22911:                                        }
        !          22912:                                        else if (pc == '-' && n && *p != ']')
        !          22913:                                        {
        !          22914:                                                if (!(pc = getchar(p)) || pc == '\\' && !(pc = getchar(p))) return(0);
        !          22915: #ifdef MULTIBYTE
        !          22916:                                                /*
        !          22917:                                                 * must be in same char set
        !          22918:                                                 */
        !          22919: 
        !          22920:                                                if ((n & C_MASK) != (pc & C_MASK))
        !          22921:                                                {
        !          22922:                                                        if (sc == pc) ok = 1;
        !          22923:                                                }
        !          22924:                                                else
        !          22925: #endif
        !          22926:                                                if (sc >= n && sc <= pc || sc == pc) ok = 1;
        !          22927:                                        }
        !          22928:                                        else if (pc == '\\' && !(pc = getchar(p))) return(0);
        !          22929:                                        else
        !          22930:                                        {
        !          22931:                                                if (sc == pc) ok = 1;
        !          22932:                                                n = pc;
        !          22933:                                        }
        !          22934:                                }
        !          22935:                        }
        !          22936:                        break;
        !          22937:                case '\\':
        !          22938:                        if (!(pc = getchar(p))) return(0);
        !          22939:                        /*FALLTHROUGH*/
        !          22940:                default:
        !          22941:                        if (pc != sc) return(0);
        !          22942:                        break;
        !          22943:                }
        !          22944:        } while (sc);
        !          22945:        return(0);
        !          22946: }
        !          22947: 
        !          22948: /*
        !          22949:  * gobble chars up to <sub> or ) keeping track of (...) and [...]
        !          22950:  * sub must be one of { '|', '&', 0 }
        !          22951:  * 0 returned if s runs out
        !          22952:  */
        !          22953: 
        !          22954: static char*
        !          22955: gobble(s, sub)
        !          22956: register char* s;
        !          22957: register int   sub;
        !          22958: {
        !          22959:        register int    p = 0;
        !          22960:        register char*  b = 0;
        !          22961: 
        !          22962:        for (;;) switch (getchar(s))
        !          22963:        {
        !          22964:        case '\\':
        !          22965:                if (getchar(s)) break;
        !          22966:                /*FALLTHROUGH*/
        !          22967:        case 0:
        !          22968:                return(0);
        !          22969:        case '[':
        !          22970:                if (!b) b = s;
        !          22971:                break;
        !          22972:        case ']':
        !          22973:                if (b && b != (s - 1)) b = 0;
        !          22974:                break;
        !          22975:        case '(':
        !          22976:                if (!b) p++;
        !          22977:                break;
        !          22978:        case ')':
        !          22979:                if (!b && p-- <= 0) return(sub ? 0 : s);
        !          22980:                break;
        !          22981:        case '&':
        !          22982:                if (!b && !p && sub == '&') return(s);
        !          22983:                break;
        !          22984:        case '|':
        !          22985:                if (!b && !p)
        !          22986:                {
        !          22987:                        if (sub == '|') return(s);
        !          22988:                        else if (sub == '&') return(0);
        !          22989:                }
        !          22990:                break;
        !          22991:        }
        !          22992: }
        !          22993: 
        !          22994: #ifdef MULTIBYTE
        !          22995: 
        !          22996: /*
        !          22997:  * return the next char in (*address) which may be from one to three bytes
        !          22998:  * the character set designation is in the bits defined by C_MASK
        !          22999:  */
        !          23000: 
        !          23001: static int
        !          23002: mb_getchar(address)
        !          23003: unsigned char**        address;
        !          23004: {
        !          23005:        register unsigned char* cp = *(unsigned char**)address;
        !          23006:        register int            c = *cp++;
        !          23007:        register int            size;
        !          23008:        int                     d;
        !          23009: 
        !          23010:        if (size = echarset(c))
        !          23011:        {
        !          23012:                d = (size == 1 ? c : 0);
        !          23013:                c = size;
        !          23014:                size = in_csize(c);
        !          23015:                c <<= 7 * (ESS_MAXCHAR - size);
        !          23016:                if (d)
        !          23017:                {
        !          23018:                        size--;
        !          23019:                        c = (c << 7) | (d & ~HIGHBIT);
        !          23020:                }
        !          23021:                while (size-- > 0)
        !          23022:                        c = (c << 7) | ((*cp++) & ~HIGHBIT);
        !          23023:        }
        !          23024:        *address = cp;
        !          23025:        return(c);
        !          23026: }
        !          23027: 
        !          23028: #endif
        !          23029: 0707070000000003551006440044230044230000010000000474537722500003400000000765string/strmode.cUgsfGgsf/*
        !          23030:  * G. S. Fowler
        !          23031:  * AT&T Bell Laboratories
        !          23032:  *
        !          23033:  * return file mode bits given ls -l style file mode string
        !          23034:  */
        !          23035: 
        !          23036: #include "modelib.h"
        !          23037: 
        !          23038: int
        !          23039: strmode(s)
        !          23040: register char* s;
        !          23041: {
        !          23042:        register int            c;
        !          23043:        register char*          t;
        !          23044:        register struct modeop* p;
        !          23045:        int                     mode;
        !          23046: 
        !          23047:        mode = 0;
        !          23048:        for (p = modetab; (c = *s++) && p < &modetab[MODELEN]; p++)
        !          23049:                for (t = p->name; *t; t++)
        !          23050:                        if (*t == c)
        !          23051:                        {
        !          23052:                                c = t - p->name;
        !          23053:                                mode |= (p->mask1 & (c << p->shift1)) | (p->mask2 & (c << p->shift2));
        !          23054:                                break;
        !          23055:                        }
        !          23056:        return(mode);
        !          23057: }
        !          23058: 0707070000000003561006440044230044230000010000000473411030000003300000002755string/stropt.cUgsfGgsf/*
        !          23059:  * Glenn Fowler
        !          23060:  * AT&T Bell Laboratories
        !          23061:  */
        !          23062: 
        !          23063: #include <namval.h>
        !          23064: #include <ctype.h>
        !          23065: 
        !          23066: /*
        !          23067:  * parse option expression in s using options in tab
        !          23068:  * options match
        !          23069:  *
        !          23070:  *     [no]name[=['"]value["']] ...
        !          23071:  *
        !          23072:  * f is called for each option
        !          23073:  *
        !          23074:  *     (*f)(void* a, struct namval* p, int n, char* v)
        !          23075:  *
        !          23076:  *     a       from stropt
        !          23077:  *     p       matching tab entry
        !          23078:  *     n       0 if option had ``no'' prefix
        !          23079:  *     v       option value pointer
        !          23080:  *
        !          23081:  * for unmatched options p has the sentinel tab value
        !          23082:  *
        !          23083:  * names in s may be shorter than tab names
        !          23084:  * longer names must have a prefix that matches a tab name
        !          23085:  * the first match is returned
        !          23086:  */
        !          23087: 
        !          23088: int
        !          23089: stropt(s, tab, f, a)
        !          23090: register char* s;
        !          23091: struct namval* tab;
        !          23092: int            (*f)();
        !          23093: char*          a;
        !          23094: {
        !          23095:        register char*  v;
        !          23096:        register char*  t;
        !          23097:        struct namval*  p;
        !          23098:        int             c;
        !          23099:        int             n;
        !          23100:        struct namval   u;
        !          23101: 
        !          23102:        if (s) for (;;)
        !          23103:        {
        !          23104:                while (isspace(*s)) s++;
        !          23105:                if (*s == 'n' && *(s + 1) == 'o')
        !          23106:                {
        !          23107:                        s += 2;
        !          23108:                        n = 0;
        !          23109:                }
        !          23110:                else n = 1;
        !          23111:                if (!*s) break;
        !          23112:                for (p = tab; t = p->name; p++)
        !          23113:                {
        !          23114:                        for (v = s; *t && *t++ == *v; v++);
        !          23115:                        if (!*t || isspace(*v) || *v == '=') break;
        !          23116:                }
        !          23117:                if (!t)
        !          23118:                {
        !          23119:                        u.name = v = s;
        !          23120:                        u.value = p->value;
        !          23121:                        p = &u;
        !          23122:                }
        !          23123:                while (*v && !isspace(*v) && *v != '=') v++;
        !          23124:                if (*v == '=')
        !          23125:                {
        !          23126:                        if (t) t = 0;
        !          23127:                        else *(t = v) = 0;
        !          23128:                        s = ++v;
        !          23129:                        if ((c = *s) != '"' && c != '\'') while (*s && !isspace(*s)) s++;
        !          23130:                        else
        !          23131:                        {
        !          23132:                                v++;
        !          23133:                                while (*++s && *s != c);
        !          23134:                        }
        !          23135:                }
        !          23136:                else
        !          23137:                {
        !          23138:                        s = v;
        !          23139:                        t = 0;
        !          23140:                }
        !          23141:                c = *s;
        !          23142:                *s = 0;
        !          23143:                n = (*f)(a, p, n, v);
        !          23144:                if (*s = c) s++;
        !          23145:                if (t) *t = '=';
        !          23146:                if (n) return(n);
        !          23147:        }
        !          23148:        return(0);
        !          23149: }
        !          23150: 0707070000000003571006440044230044230000010000000462626317300003400000003714string/strperm.cUgsfGgsf/*
        !          23151:  * G. S. Fowler
        !          23152:  * AT&T Bell Laboratories
        !          23153:  *
        !          23154:  * apply file permission expression expr to perm
        !          23155:  *
        !          23156:  * each expression term must match
        !          23157:  *
        !          23158:  *     [ugoa]*[-&+|=]?[rwxst0-7]*
        !          23159:  *
        !          23160:  * terms may be combined using ,
        !          23161:  *
        !          23162:  * if non-null, e points to the first unrecognized char in expr
        !          23163:  */
        !          23164: 
        !          23165: #include <ls.h>
        !          23166: 
        !          23167: int
        !          23168: strperm(expr, e, perm)
        !          23169: char*          expr;
        !          23170: char**         e;
        !          23171: register int   perm;
        !          23172: {
        !          23173:        register int    c;
        !          23174:        register int    typ;
        !          23175:        register int    who;
        !          23176:        int             num;
        !          23177:        int             op;
        !          23178: 
        !          23179:        for (;;)
        !          23180:        {
        !          23181:                op = num = who = typ = 0;
        !          23182:                for (;;)
        !          23183:                {
        !          23184:                        switch (c = *expr++)
        !          23185:                        {
        !          23186:                        case 'u':
        !          23187:                                who |= S_ISVTX|S_ISUID|S_IRWXU;
        !          23188:                                continue;
        !          23189:                        case 'g':
        !          23190:                                who |= S_ISVTX|S_ISGID|S_IRWXG;
        !          23191:                                continue;
        !          23192:                        case 'o':
        !          23193:                                who |= S_ISVTX|S_IRWXO;
        !          23194:                                continue;
        !          23195:                        case 'a':
        !          23196:                                who = S_ISVTX|S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO;
        !          23197:                                continue;
        !          23198:                        default:
        !          23199:                                if (c >= '0' && c <= '7') c = '=';
        !          23200:                                expr--;
        !          23201:                                /*FALLTHROUGH*/
        !          23202:                        case '=':
        !          23203:                        case '+':
        !          23204:                        case '|':
        !          23205:                        case '-':
        !          23206:                        case '&':
        !          23207:                                op = c;
        !          23208:                                for (;;)
        !          23209:                                {
        !          23210:                                        switch (c = *expr++)
        !          23211:                                        {
        !          23212:                                        case 'r':
        !          23213:                                                typ |= S_IRUSR|S_IRGRP|S_IROTH;
        !          23214:                                                continue;
        !          23215:                                        case 'w':
        !          23216:                                                typ |= S_IWUSR|S_IWGRP|S_IWOTH;
        !          23217:                                                continue;
        !          23218:                                        case 'x':
        !          23219:                                                typ |= S_IXUSR|S_IXGRP|S_IXOTH;
        !          23220:                                                continue;
        !          23221:                                        case 's':
        !          23222:                                                typ |= S_ISUID|S_ISGID;
        !          23223:                                                continue;
        !          23224:                                        case 't':
        !          23225:                                                typ |= S_ISVTX;
        !          23226:                                                continue;
        !          23227:                                        case ',':
        !          23228:                                        case 0:
        !          23229:                                                if (who) typ &= who;
        !          23230:                                                switch (op)
        !          23231:                                                {
        !          23232:                                                default:
        !          23233:                                                        perm &= ~who;
        !          23234:                                                        /*FALLTHROUGH*/
        !          23235:                                                case '+':
        !          23236:                                                case '|':
        !          23237:                                                        perm |= typ;
        !          23238:                                                        break;
        !          23239:                                                case '-':
        !          23240:                                                        perm &= ~typ;
        !          23241:                                                        break;
        !          23242:                                                case '&':
        !          23243:                                                        perm &= typ;
        !          23244:                                                        break;
        !          23245:                                                }
        !          23246:                                                if (c) break;
        !          23247:                                                /*FALLTHROUGH*/
        !          23248:                                        default:
        !          23249:                                                if (c < '0' || c > '7')
        !          23250:                                                {
        !          23251:                                                        if (e) *e = expr - 1;
        !          23252:                                                        return(perm);
        !          23253:                                                }
        !          23254:                                                num = (num <<= 3) | (c - '0');
        !          23255:                                                if (*expr < '0' || *expr > '7')
        !          23256:                                                {
        !          23257:                                                        typ |= num;
        !          23258:                                                        num = 0;
        !          23259:                                                }
        !          23260:                                                continue;
        !          23261:                                        }
        !          23262:                                        break;
        !          23263:                                }
        !          23264:                                break;
        !          23265:                        }
        !          23266:                        break;
        !          23267:                }
        !          23268:        }
        !          23269: }
        !          23270: 0707070000000003601006440044230044230000010000000474114313700003600000001071string/strsignal.cUgsfGgsf/*
        !          23271:  * G. S. Fowler
        !          23272:  * AT&T Bell Laboratories
        !          23273:  *
        !          23274:  * if sig>=0 then return signal text for signal sig
        !          23275:  * otherwise return signal name for signal -sig
        !          23276:  *
        !          23277:  * data defined in sigdata.c
        !          23278:  */
        !          23279: 
        !          23280: #include <stdio.h>
        !          23281: 
        !          23282: extern int     sig_max;
        !          23283: 
        !          23284: extern char*   sig_name[];
        !          23285: extern char*   sig_text[];
        !          23286: 
        !          23287: char*
        !          23288: strsignal(sig)
        !          23289: register int   sig;
        !          23290: {
        !          23291:        static char                     buf[20];
        !          23292: 
        !          23293:        if (sig >= 0)
        !          23294:        {
        !          23295:                if (sig <= sig_max) return(sig_text[sig]);
        !          23296:                (void)sprintf(buf, "Signal %d", sig);
        !          23297:        }
        !          23298:        else
        !          23299:        {
        !          23300:                sig = -sig;
        !          23301:                if (sig <= sig_max) return(sig_name[sig]);
        !          23302:                (void)sprintf(buf, "%d", sig);
        !          23303:        }
        !          23304:        return(buf);
        !          23305: }
        !          23306: 0707070000000003611006440044230044230000010000000474114315000003400000003572string/strtape.cUgsfGgsf/*
        !          23307:  * local device pathname for portable tape unit specification is returned
        !          23308:  * if e is non-null then it is set to the next unused char in s
        !          23309:  *
        !          23310:  *     <unit><density>[<no-rewind>]
        !          23311:  *     {0-7}[l,m,h][n]
        !          23312:  */
        !          23313: 
        !          23314: #include <stdio.h>
        !          23315: 
        !          23316: char*
        !          23317: strtape(s, e)
        !          23318: register char* s;
        !          23319: register char**        e;
        !          23320: {
        !          23321:        int             mtunit;
        !          23322:        int             mtdensity;
        !          23323:        char*           mtrewind;
        !          23324: 
        !          23325:        static char     tapefile[sizeof("/dev/Xrmt/XXX")];
        !          23326: 
        !          23327:        switch (*s)
        !          23328:        {
        !          23329:        case '0':
        !          23330:        case '1':
        !          23331:        case '2':
        !          23332:        case '3':
        !          23333:        case '4':
        !          23334:        case '5':
        !          23335:        case '6':
        !          23336:        case '7':
        !          23337:                mtunit = *s++;
        !          23338:                break;
        !          23339:        default:
        !          23340:                mtunit = '1';
        !          23341:                break;
        !          23342:        }
        !          23343:        if (!access("/dev/rmt/.", 0))
        !          23344:        {
        !          23345:                /*
        !          23346:                 * system V
        !          23347:                 */
        !          23348: 
        !          23349:                switch (*s)
        !          23350:                {
        !          23351:                case 'l':
        !          23352:                case 'm':
        !          23353:                case 'h':
        !          23354:                        mtdensity = *s++;
        !          23355:                        break;
        !          23356:                default:
        !          23357:                        mtdensity = 'm';
        !          23358:                        break;
        !          23359:                }
        !          23360:                switch (*s)
        !          23361:                {
        !          23362:                case 'n':
        !          23363:                        mtrewind = "n";
        !          23364:                        s++;
        !          23365:                        break;
        !          23366:                default:
        !          23367:                        mtrewind = "";
        !          23368:                        break;
        !          23369:                }
        !          23370:                (void)sprintf(tapefile, "/dev/rmt/%c%c%s", mtunit, mtdensity, mtrewind);
        !          23371:                if (access(tapefile, 0)) (void)sprintf(tapefile, "/dev/rmt/ctape%c%s", mtunit, mtrewind);
        !          23372:                if (access(tapefile, 0)) (void)sprintf(tapefile, "/dev/rmt/%c%c%s", mtunit, mtdensity, mtrewind);
        !          23373:        }
        !          23374:        else if (!access("/dev/nrmt0", 0))
        !          23375:        {
        !          23376:                /*
        !          23377:                 * 9th edition
        !          23378:                 */
        !          23379: 
        !          23380:                switch (*s)
        !          23381:                {
        !          23382:                case 'l':
        !          23383:                        mtunit = '0';
        !          23384:                        s++;
        !          23385:                        break;
        !          23386:                case 'm':
        !          23387:                        mtunit = '1';
        !          23388:                        s++;
        !          23389:                        break;
        !          23390:                case 'h':
        !          23391:                        mtunit = '2';
        !          23392:                        s++;
        !          23393:                        break;
        !          23394:                }
        !          23395:                switch (*s)
        !          23396:                {
        !          23397:                case 'n':
        !          23398:                        mtrewind = "n";
        !          23399:                        s++;
        !          23400:                        break;
        !          23401:                default:
        !          23402:                        mtrewind = "";
        !          23403:                        break;
        !          23404:                }
        !          23405:                (void)sprintf(tapefile, "/dev/%srmt%c", mtrewind, mtunit);
        !          23406:        }
        !          23407:        else
        !          23408:        {
        !          23409:                /*
        !          23410:                 * BSD
        !          23411:                 */
        !          23412: 
        !          23413:                mtunit -= '0';
        !          23414:                switch (*s)
        !          23415:                {
        !          23416:                case 'l':
        !          23417:                        s++;
        !          23418:                        break;
        !          23419:                case 'm':
        !          23420:                        mtunit |= 010;
        !          23421:                        s++;
        !          23422:                        break;
        !          23423:                case 'h':
        !          23424:                        mtunit |= 020;
        !          23425:                        s++;
        !          23426:                        break;
        !          23427:                default:
        !          23428:                        mtunit |= 010;
        !          23429:                        break;
        !          23430:                }
        !          23431:                switch (*s)
        !          23432:                {
        !          23433:                case 'n':
        !          23434:                        mtunit |= 040;
        !          23435:                        s++;
        !          23436:                        break;
        !          23437:                }
        !          23438:                (void)sprintf(tapefile, "/dev/rmt%d", mtunit);
        !          23439:        }
        !          23440:        if (e) *e = s;
        !          23441:        return(tapefile);
        !          23442: }
        !          23443: 0707070000000003621006440044230044230000010000000466627672300003300000002331string/strton.cUgsfGgsf/*
        !          23444:  * AT&T Bell Laboratories
        !          23445:  *
        !          23446:  * convert string to long integer
        !          23447:  * if non-null e will point to first unrecognized char in s
        !          23448:  * if m>1 and no multipler was specified then the result is multiplied by m
        !          23449:  *
        !          23450:  * integer numbers are of the form:
        !          23451:  *
        !          23452:  *     [sign][base][number][multiplier]
        !          23453:  *
        !          23454:  *     base:           nnn#            base nnn
        !          23455:  *                     0[xX]           hex
        !          23456:  *                     0               octal
        !          23457:  *                     [1-9]           decimal
        !          23458:  *
        !          23459:  *     number:         [0-9a-zA-Z]*
        !          23460:  *
        !          23461:  *     multiplier:     .               pseudo-float (100) + subsequent digits
        !          23462:  *                     [bB]            block (512)
        !          23463:  *                     [cC]            char (1)
        !          23464:  *                     [gG]            giga (1024*1024*1024)
        !          23465:  *                     [kK]            kilo (1024)
        !          23466:  *                     [mM]            mega (1024*1024)
        !          23467:  */
        !          23468: 
        !          23469: long
        !          23470: strton(s, e, m)
        !          23471: register char* s;
        !          23472: char**         e;
        !          23473: int            m;
        !          23474: {
        !          23475:        register long   n;
        !          23476:        register int    neg;
        !          23477:        char*           p;
        !          23478: 
        !          23479:        extern long     strtol();
        !          23480: 
        !          23481:        if (neg = (n = strtol(s, &p, 0)) < 0) n = -n;
        !          23482:        if (*p == '#') n = strtol(++p, &p, n);
        !          23483:        switch (*p++)
        !          23484:        {
        !          23485:        case 'b':
        !          23486:        case 'B':
        !          23487:                n *= 512;
        !          23488:                break;
        !          23489:        case 'c':
        !          23490:        case 'C':
        !          23491:                break;
        !          23492:        case 'g':
        !          23493:        case 'G':
        !          23494:                n *= 1024 * 1024 * 1024;
        !          23495:                break;
        !          23496:        case 'k':
        !          23497:        case 'K':
        !          23498:                n *= 1024;
        !          23499:                break;
        !          23500:        case 'm':
        !          23501:        case 'M':
        !          23502:                n *= 1024 * 1024;
        !          23503:                break;
        !          23504:        case '.':
        !          23505:                n *= 100;
        !          23506:                for (m = 10; *p >= '0' && *p <= '9'; m /= 10) 
        !          23507:                        n += m * (*p++ - '0');
        !          23508:                break;
        !          23509:        default:
        !          23510:                p--;
        !          23511:                if (m > 1) n *= m;
        !          23512:                break;
        !          23513:        }
        !          23514:        if (e) *e = p;
        !          23515:        return(neg ? -n : n);
        !          23516: }
        !          23517: 0707070000000003631006440044230044230000010000000474561124100003300000001570string/struid.cUgsfGgsf/*
        !          23518:  * G. S. Fowler
        !          23519:  * AT&T Bell Laboratories
        !          23520:  *
        !          23521:  * uid name -> number
        !          23522:  */
        !          23523: 
        !          23524: #include <hash.h>
        !          23525: #define getpwnam       _SYS_getpwnam
        !          23526: #include <pwd.h>
        !          23527: #undef getpwnam
        !          23528: extern struct passwd*  getpwnam();
        !          23529: 
        !          23530: typedef struct
        !          23531: {
        !          23532:        HASH_HEADER;
        !          23533:        int     id;
        !          23534: } bucket;
        !          23535: 
        !          23536: /*
        !          23537:  * return uid number given uid name
        !          23538:  * -1 on first error for a given name
        !          23539:  * -2 on subsequent errors for a given name
        !          23540:  */
        !          23541: 
        !          23542: int
        !          23543: struid(name)
        !          23544: char*  name;
        !          23545: {
        !          23546:        register struct passwd* pw;
        !          23547:        register bucket*        b;
        !          23548: 
        !          23549:        static HASHTABLE*       uidtab;
        !          23550: 
        !          23551:        if (!uidtab && !(uidtab = hashalloc((HASHTABLE*)0, HASH_set, HASH_ALLOCATE, HASH_name, "uidnam", 0))) return(-1);
        !          23552:        if (b = (bucket*)hashlook(uidtab, name, HASH_LOOKUP|HASH_FIXED, (char*)sizeof(bucket))) return(b->id);
        !          23553:        if (!(b = (bucket*)hashlook(uidtab, (char*)0, HASH_CREATE|HASH_FIXED, (char*)sizeof(bucket)))) return(-1);
        !          23554:        if (pw = getpwnam(name)) return(b->id = pw->pw_uid);
        !          23555:        b->id = -2;
        !          23556:        return(-1);
        !          23557: }
        !          23558: 0707070000000003641006440044230044230000010000000471771124000003000000003626string/tok.cUgsfGgsf/*
        !          23559:  * Glenn Fowler
        !          23560:  * AT&T Bell Laboratories
        !          23561:  *
        !          23562:  * token stream routines
        !          23563:  */
        !          23564: 
        !          23565: struct tok                             /* token stream state           */
        !          23566: {
        !          23567:        union
        !          23568:        {
        !          23569:        char*           end;            /* end ('\0') of last token     */
        !          23570:        struct tok*     nxt;            /* next in free list            */
        !          23571:        }               ptr;
        !          23572:        char            chr;            /* replace *end with this       */
        !          23573:        char            flg;            /* ==0 => don't restore string  */
        !          23574: };
        !          23575: 
        !          23576: typedef struct tok TOK;
        !          23577: 
        !          23578: static struct tok*     freelist;
        !          23579: 
        !          23580: extern char*           malloc();
        !          23581: 
        !          23582: /*
        !          23583:  * open a new token stream on s
        !          23584:  * if f==0 then string is not restored
        !          23585:  */
        !          23586: 
        !          23587: char*
        !          23588: tokopen(s, f)
        !          23589: register char* s;
        !          23590: int            f;
        !          23591: {
        !          23592:        register TOK*   p;
        !          23593: 
        !          23594:        if (p = freelist) freelist = freelist->ptr.nxt;
        !          23595:        else if (!(p = (TOK*)malloc(sizeof(TOK)))) return(0);
        !          23596:        p->chr = *(p->ptr.end = s);
        !          23597:        p->flg = f;
        !          23598:        return((char*)p);
        !          23599: }
        !          23600: 
        !          23601: /*
        !          23602:  * close a token stream
        !          23603:  * restore the string to its original state
        !          23604:  */
        !          23605: 
        !          23606: void
        !          23607: tokclose(u)
        !          23608: char*  u;
        !          23609: {
        !          23610:        register TOK*   p = (TOK*)u;
        !          23611: 
        !          23612:        if (p->flg) *p->ptr.end = p->chr;
        !          23613:        p->ptr.nxt = freelist;
        !          23614:        freelist = p;
        !          23615: }
        !          23616: 
        !          23617: /*
        !          23618:  * return next space separated token
        !          23619:  * "\n" is returned as a token
        !          23620:  * 0 returned when no tokens remain
        !          23621:  * "..." and '...' quotes are honored with \ escapes
        !          23622:  */
        !          23623: 
        !          23624: char*
        !          23625: tokread(u)
        !          23626: char*  u;
        !          23627: {
        !          23628:        register TOK*   p = (TOK*)u;
        !          23629:        register char*  s;
        !          23630:        register char*  r;
        !          23631:        register int    q;
        !          23632:        register int    c;
        !          23633: 
        !          23634:        /*
        !          23635:         * restore string on each call
        !          23636:         */
        !          23637: 
        !          23638:        if (!p->chr) return(0);
        !          23639:        s = p->ptr.end;
        !          23640:        if (p->flg) *s = p->chr;
        !          23641:        else if (!*s) s++;
        !          23642: 
        !          23643:        /*
        !          23644:         * skip leading space
        !          23645:         */
        !          23646: 
        !          23647:        while (*s == ' ' || *s == '\t') s++;
        !          23648:        if (!*s)
        !          23649:        {
        !          23650:                p->ptr.end = s;
        !          23651:                p->chr = 0;
        !          23652:                return(0);
        !          23653:        }
        !          23654: 
        !          23655:        /*
        !          23656:         * find the end of this token
        !          23657:         */
        !          23658: 
        !          23659:        r = s;
        !          23660:        q = 0;
        !          23661:        for (;;) switch (c = *r++)
        !          23662:        {
        !          23663:        case '\n':
        !          23664:                if (s == (r - 1) && !q) r++;
        !          23665:                /*FALLTHROUGH*/
        !          23666:        case ' ':
        !          23667:        case '\t':
        !          23668:                if (q) break;
        !          23669:                /*FALLTHROUGH*/
        !          23670:        case 0:
        !          23671:                if (s == --r)
        !          23672:                {
        !          23673:                        p->ptr.end = r;
        !          23674:                        p->chr = 0;
        !          23675:                }
        !          23676:                else
        !          23677:                {
        !          23678:                        p->chr = *(p->ptr.end = r);
        !          23679:                        *r = 0;
        !          23680:                }
        !          23681:                return(s);
        !          23682:        case '\\':
        !          23683:                if (*r) r++;
        !          23684:                break;
        !          23685:        case '"':
        !          23686:        case '\'':
        !          23687:                if (c == q) q = 0;
        !          23688:                else if (!q) q = c;
        !          23689:                break;
        !          23690:        }
        !          23691: }
        !          23692: 0707070000000003651006440044230044230000010000000474236214100002700000012474tm/tmdata.cUgsfGgsf/*
        !          23693:  * Glenn Fowler
        !          23694:  * AT&T Bell Laboratories
        !          23695:  *
        !          23696:  * time conversion support readonly data
        !          23697:  */
        !          23698: 
        !          23699: #include <tm.h>
        !          23700: 
        !          23701: /*
        !          23702:  * default format strings -- must agree with TM_* indices
        !          23703:  */
        !          23704: 
        !          23705: static char*           format[] =
        !          23706: {
        !          23707:        "Jan",          "Feb",          "Mar",          "Apr",
        !          23708:        "May",          "Jun",          "Jul",          "Aug",
        !          23709:        "Sep",          "Oct",          "Nov",          "Dec",
        !          23710: 
        !          23711:        "January",      "February",     "March",        "April",
        !          23712:        "May",          "June",         "July",         "August",
        !          23713:        "September",    "October",      "November",     "December",
        !          23714: 
        !          23715:        "Sun",          "Mon",          "Tue",          "Wed",
        !          23716:        "Thu",          "Fri",          "Sat",
        !          23717: 
        !          23718:        "Sunday",       "Monday",       "Tuesday",      "Wednesday",
        !          23719:        "Thursday",     "Friday",       "Saturday",
        !          23720: 
        !          23721:        "%H:%M:%S",     "%m/%d/%y",     "%a %b %e %T %Z %Y",
        !          23722: 
        !          23723:        "AM",           "PM",
        !          23724: 
        !          23725:        "GMT",          "UTC",          "UCT",          "CUT",
        !          23726: 
        !          23727:        "DST",          "",             "",             "",
        !          23728: 
        !          23729:        "s",            "es",           "",             "",
        !          23730: 
        !          23731:        "second",       "minute",       "hour",         "day",
        !          23732:        "week",         "month",        "year",
        !          23733: 
        !          23734:        "midnight",     "morning",      "noon",         "evening",
        !          23735: 
        !          23736:        "yesterday",    "today",        "tomorrow",
        !          23737: 
        !          23738:        "last",         "ago",          "past",
        !          23739:        "this",         "now",          "current",
        !          23740:        "next",         "hence",        "coming",
        !          23741:        "exactly",      "",             "",
        !          23742: 
        !          23743:        "at",           "on",           "in",           "",
        !          23744: };
        !          23745: 
        !          23746: /*
        !          23747:  * format[] lex type classes
        !          23748:  */
        !          23749: 
        !          23750: static char            lex[] =
        !          23751: {
        !          23752:        TM_MONTH_3,     TM_MONTH_3,     TM_MONTH_3,     TM_MONTH_3,
        !          23753:        TM_MONTH_3,     TM_MONTH_3,     TM_MONTH_3,     TM_MONTH_3,
        !          23754:        TM_MONTH_3,     TM_MONTH_3,     TM_MONTH_3,     TM_MONTH_3,
        !          23755: 
        !          23756:        TM_MONTH,       TM_MONTH,       TM_MONTH,       TM_MONTH,
        !          23757:        TM_MONTH,       TM_MONTH,       TM_MONTH,       TM_MONTH,
        !          23758:        TM_MONTH,       TM_MONTH,       TM_MONTH,       TM_MONTH,
        !          23759: 
        !          23760:        TM_DAY_3,       TM_DAY_3,       TM_DAY_3,       TM_DAY_3,
        !          23761:        TM_DAY_3,       TM_DAY_3,       TM_DAY_3,
        !          23762: 
        !          23763:        TM_DAY,         TM_DAY,         TM_DAY,         TM_DAY,
        !          23764:        TM_DAY,         TM_DAY,         TM_DAY,
        !          23765: 
        !          23766:        TM_TIME,        TM_DATE,        TM_DEFAULT,
        !          23767: 
        !          23768:        TM_MERIDIAN,    TM_MERIDIAN,
        !          23769: 
        !          23770:        TM_UT,          TM_UT,          TM_UT,          TM_UT,
        !          23771:        TM_DT,          TM_DT,          TM_DT,          TM_DT,
        !          23772: 
        !          23773:        TM_SUFFIXES,    TM_SUFFIXES,    TM_SUFFIXES,    TM_SUFFIXES,
        !          23774: 
        !          23775:        TM_PARTS,       TM_PARTS,       TM_PARTS,       TM_PARTS,
        !          23776:        TM_PARTS,       TM_PARTS,       TM_PARTS,
        !          23777: 
        !          23778:        TM_HOURS,       TM_HOURS,       TM_HOURS,       TM_HOURS,
        !          23779: 
        !          23780:        TM_DAYS,        TM_DAYS,        TM_DAYS,
        !          23781: 
        !          23782:        TM_LAST,        TM_LAST,        TM_LAST,
        !          23783:        TM_THIS,        TM_THIS,        TM_THIS,
        !          23784:        TM_NEXT,        TM_NEXT,        TM_NEXT,
        !          23785:        TM_EXACT,       TM_EXACT,       TM_EXACT,
        !          23786: 
        !          23787:        TM_NOISE,       TM_NOISE,       TM_NOISE,       TM_NOISE,
        !          23788: };
        !          23789: 
        !          23790: /*
        !          23791:  * output format digits
        !          23792:  */
        !          23793: 
        !          23794: static char    digit[] = "0123456789";
        !          23795: 
        !          23796: /*
        !          23797:  * number of days in month i
        !          23798:  */
        !          23799: 
        !          23800: static short   days[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
        !          23801: 
        !          23802: /*
        !          23803:  * sum of days in months before month i
        !          23804:  */
        !          23805: 
        !          23806: static short   sum[] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
        !          23807: 
        !          23808: /*
        !          23809:  * leap second time_t and accumulated adjustments
        !          23810:  * (reverse order -- biased for recent dates)
        !          23811:  *
        !          23812:  * tl.time is the seconds since the epoch for the leap event
        !          23813:  *
        !          23814:  *     adding:         the first additional second
        !          23815:  *     subtracting:    the first dissappearing second
        !          23816:  */
        !          23817: 
        !          23818: static struct tl       leap[] =
        !          23819: {
        !          23820:          662688015,   16,              /* Dec 31 23:59:60 GMT 1990 */
        !          23821:          631152014,   15,              /* Dec 31 23:59:60 GMT 1989 */
        !          23822:          567993613,   14,              /* Dec 31 23:59:60 GMT 1987 */
        !          23823:          489024012,   13,              /* Jun 30 23:59:60 GMT 1985 */
        !          23824:          425865611,   12,              /* Jun 30 23:59:60 GMT 1983 */
        !          23825:          394329610,   11,              /* Jun 30 23:59:60 GMT 1982 */
        !          23826:          362793609,   10,              /* Jun 30 23:59:60 GMT 1981 */
        !          23827:          315532808,    9,              /* Dec 31 23:59:60 GMT 1979 */
        !          23828:          283996807,    8,              /* Dec 31 23:59:60 GMT 1978 */
        !          23829:          252460806,    7,              /* Dec 31 23:59:60 GMT 1977 */
        !          23830:          220924805,    6,              /* Dec 31 23:59:60 GMT 1976 */
        !          23831:          189302404,    5,              /* Dec 31 23:59:60 GMT 1975 */
        !          23832:          157766403,    4,              /* Dec 31 23:59:60 GMT 1974 */
        !          23833:          126230402,    3,              /* Dec 31 23:59:60 GMT 1973 */
        !          23834:           94694401,    2,              /* Dec 31 23:59:60 GMT 1972 */
        !          23835:           78796800,    1,              /* Jun 30 23:59:60 GMT 1972 */
        !          23836:                  0,    0,              /* can reference (tl+1)     */
        !          23837:                  0,    0
        !          23838: };
        !          23839: 
        !          23840: /*
        !          23841:  * time zones
        !          23842:  *
        !          23843:  * the UTC entries must be first
        !          23844:  *
        !          23845:  * zones with the same type are contiguous with all but the
        !          23846:  * first entry for the type having a null type
        !          23847:  *
        !          23848:  * tz.standard is the sentinel
        !          23849:  */
        !          23850: 
        !          23851: static struct tz       zone[] =
        !          23852: {
        !          23853:  0,    "GMT",  0,       ( 0 * 60),          0, /* UTC                  */
        !          23854:  0,    "UCT",  0,       ( 0 * 60),          0, /* UTC                  */
        !          23855:  0,    "UTC",  0,       ( 0 * 60),          0, /* UTC                  */
        !          23856:  0,    "CUT",  0,       ( 0 * 60),          0, /* UTC                  */
        !          23857:  "USA",        "HST",  0,       (10 * 60),          0, /* Hawaii               */
        !          23858:  0,    "YST",  "YDT",   ( 9 * 60),     TM_DST, /* Yukon                */
        !          23859:  0,    "PST",  "PDT",   ( 8 * 60),     TM_DST, /* Pacific              */
        !          23860:  0,    "PST",  "PPET",  ( 8 * 60),     TM_DST, /* Pacific pres elect   */
        !          23861:  0,    "MST",  "MDT",   ( 7 * 60),     TM_DST, /* Mountain             */
        !          23862:  0,    "CST",  "CDT",   ( 6 * 60),     TM_DST, /* Central              */
        !          23863:  0,    "EST",  "EDT",   ( 5 * 60),     TM_DST, /* Eastern              */
        !          23864:  "CAN",        "AST",  "ADT",   ( 4 * 60),     TM_DST, /* Atlantic             */
        !          23865:  0,    "NST",  0,       ( 3 * 60 + 30),     0, /* Newfoundland         */
        !          23866:  "GBR",        "",     "BST",   ( 0 * 60),     TM_DST, /* British Summer       */
        !          23867:  "EUR",        "WET",  0,       ( 0 * 60),     TM_DST, /* Western Eurpoean     */
        !          23868:  0,    "CET",  0,      -( 1 * 60),     TM_DST, /* Central European     */
        !          23869:  0,    "MET",  0,      -( 1 * 60),     TM_DST, /* Middle European      */
        !          23870:  0,    "EET",  0,      -( 2 * 60),     TM_DST, /* Eastern Eurpoean     */
        !          23871:  "ISR",        "IST",  "IDT",  -( 3 * 60),     TM_DST, /* Israel               */
        !          23872:  "CHN",        "HKT",  0,      -( 8 * 60),          0, /* Hong Kong            */
        !          23873:  "KOR",        "KST",  "KDT",  -( 8 * 60),     TM_DST, /* Korea                */
        !          23874:  "SNG",        "SST",  0,      -( 8 * 60),          0, /* Singapore            */
        !          23875:  "JPN",        "JST",  0,      -( 9 * 60),          0, /* Japan                */
        !          23876:  "AUS",        "AWST", 0,      -( 8 * 60),          0, /* Australia Western    */
        !          23877:  0,    "WST",  0,      -( 8 * 60),          0, /* Australia Western    */
        !          23878:  0,    "ACST", 0,      -( 9 * 60 + 30),TM_DST, /* Australia Central    */
        !          23879:  0,    "CST",  0,      -( 9 * 60 + 30),TM_DST, /* Australia Central    */
        !          23880:  0,    "AEST", 0,      -(10 * 60),     TM_DST, /* Australia Eastern    */
        !          23881:  0,    "EST",  0,      -(10 * 60),     TM_DST, /* Australia Eastern    */
        !          23882:  "NZL",        "NZST", "NZDT", -(12 * 60),     TM_DST, /* New Zealand          */
        !          23883:  0,    0,      0,      0,                   0
        !          23884: };
        !          23885: 
        !          23886: struct tmdata tm_data = { format, lex, digit, days, sum, leap, zone };
        !          23887: 0707070000000003661006440044230044230000010000000475446227400002700000020134tm/tmdate.cUgsfGgsf/*
        !          23888:  * Glenn Fowler
        !          23889:  * AT&T Bell Laboratories
        !          23890:  *
        !          23891:  * time conversion support
        !          23892:  *
        !          23893:  * relative times inspired by Steve Bellovin's netnews getdate(3)
        !          23894:  */
        !          23895: 
        !          23896: #include <tm.h>
        !          23897: #include <ctype.h>
        !          23898: 
        !          23899: #define twodig(s,n)    (n = (*s++ - '0') * 10, n += *s++ - '0')
        !          23900: 
        !          23901: #define BREAK          (1<<0)
        !          23902: #define DAY            (1<<1)
        !          23903: #define EXACT          (1<<2)
        !          23904: #define HOLD           (1<<3)
        !          23905: #define HOUR           (1<<4)
        !          23906: #define LAST           (1<<5)
        !          23907: #define MDAY           (1<<6)
        !          23908: #define MONTH          (1<<7)
        !          23909: #define NEXT           (1<<8)
        !          23910: #define THIS           (1<<9)
        !          23911: #define YEAR           (1<<10)
        !          23912: #define YYMMDDHHMMSS   (1<<11)
        !          23913: #define ZONE           (1<<12)
        !          23914: 
        !          23915: #if __STDC__ || __cplusplus
        !          23916: #if __cplusplus
        !          23917: extern "C" {
        !          23918: #endif
        !          23919: extern long            strtol(const char*, char**, int);
        !          23920: #if __cplusplus
        !          23921: }
        !          23922: #endif
        !          23923: #else
        !          23924: extern long            strtol();
        !          23925: #endif
        !          23926: 
        !          23927: /*
        !          23928:  * parse date expression in s and return time_t value
        !          23929:  *
        !          23930:  * if non-null, e points to the first invalid sequence in s
        !          23931:  * clock provides default values
        !          23932:  */
        !          23933: 
        !          23934: time_t
        !          23935: #if __STDC__ || __cplusplus
        !          23936: tmdate(register const char* s, char** e, time_t* clock)
        !          23937: #else
        !          23938: tmdate(s, e, clock)
        !          23939: register char* s;
        !          23940: char**         e;
        !          23941: time_t*                clock;
        !          23942: #endif
        !          23943: {
        !          23944:        register struct tm*     tm;
        !          23945:        register int            n;
        !          23946:        int                     state;
        !          23947:        time_t                  now;
        !          23948:        char*                   t;
        !          23949:        char*                   last;
        !          23950:        char*                   type;
        !          23951:        int                     dst;
        !          23952:        int                     zone;
        !          23953:        int                     i;
        !          23954:        int                     j;
        !          23955:        int                     k;
        !          23956:        int                     l;
        !          23957:        int                     m;
        !          23958: 
        !          23959:  reset:
        !          23960: 
        !          23961:        /*
        !          23962:         * use clock for defaults
        !          23963:         */
        !          23964: 
        !          23965:        tm = tmmake(clock);
        !          23966:        dst = TM_DST;
        !          23967:        state = 0;
        !          23968:        type = 0;
        !          23969:        zone = 0;
        !          23970: 
        !          23971:        /*
        !          23972:         * get <weekday year month day hour minutes seconds ?[ds]t [ap]m>
        !          23973:         */
        !          23974: 
        !          23975:        for (;;)
        !          23976:        {
        !          23977:                state &= (state & HOLD) ? ~(HOLD) : ~(EXACT|LAST|NEXT|THIS);
        !          23978:                n = -1;
        !          23979:                while (isspace(*s) || *s == ',' || *s == '-') s++;
        !          23980:                if (!*(last = (char*)s)) break;
        !          23981:                if (*s == '#')
        !          23982:                {
        !          23983:                        if (!isdigit(*++s)) break;
        !          23984:                        now = strtol(s, &t, 0);
        !          23985:                        clock = &now;
        !          23986:                        s = t;
        !          23987:                        goto reset;
        !          23988:                }
        !          23989:                if (isdigit(*s))
        !          23990:                {
        !          23991:                        n = strtol(s, &t, 10);
        !          23992:                        if (!(state & (LAST|NEXT|THIS)) && (!*t && (t - s) > 4 || *t == '.' && (t - s) == 4))
        !          23993:                        {
        !          23994:                                /*
        !          23995:                                 * old date(1) format
        !          23996:                                 *
        !          23997:                                 *      [yy[mm]]ddhhmm[.ss]
        !          23998:                                 *      hhmm.ss
        !          23999:                                 */
        !          24000: 
        !          24001:                                if (state & YYMMDDHHMMSS) break;
        !          24002:                                state |= YYMMDDHHMMSS;
        !          24003:                                if ((t - s) < 10) m = tm->tm_year;
        !          24004:                                else if (twodig(s, m) < 38) m += 100;
        !          24005:                                if ((t - s) < 8) l = tm->tm_mon;
        !          24006:                                else if (twodig(s, l) <= 0 || l > 12) break;
        !          24007:                                if ((t - s) < 6) k = tm->tm_mon;
        !          24008:                                else if (twodig(s, k) < 1 || k > 31) break;
        !          24009:                                if ((t - s) < 4) break;
        !          24010:                                if (twodig(s, j) > 24) break;
        !          24011:                                if (twodig(s, i) > 59) break;
        !          24012:                                if ((t - s) == 2) twodig(s, n);
        !          24013:                                else if (t - s) break;
        !          24014:                                else if (*t != '.') n = 0;
        !          24015:                                else n = strtol(t + 1, &t, 10);
        !          24016:                                if (n > (59 + TM_MAXLEAP)) break;
        !          24017:                                tm->tm_year = m;
        !          24018:                                tm->tm_mon = l - 1;
        !          24019:                                tm->tm_mday = k;
        !          24020:                                tm->tm_hour = j;
        !          24021:                                tm->tm_min = i;
        !          24022:                                tm->tm_sec = n;
        !          24023:                                s = t;
        !          24024:                                continue;
        !          24025:                        }
        !          24026:                        s = t;
        !          24027:                        if (*s == ':')
        !          24028:                        {
        !          24029:                                if ((state & HOUR) || n > 24 || *s++ != ':' || !isdigit(*s)) break;
        !          24030:                                i = n;
        !          24031:                                n = strtol(s, &t, 10);
        !          24032:                                s = t;
        !          24033:                                if (n > 59) break;
        !          24034:                                j = n;
        !          24035:                                if (*s == ':')
        !          24036:                                {
        !          24037:                                        if (!isdigit(*++s)) break;
        !          24038:                                        n = strtol(s, &t, 10);
        !          24039:                                        s = t;
        !          24040:                                        if (n > (59 + TM_MAXLEAP)) break;
        !          24041:                                }
        !          24042:                                else n = 0;
        !          24043:                                tm->tm_sec = n;
        !          24044:                                tm->tm_min = j;
        !          24045:                                tm->tm_hour = i;
        !          24046:                                continue;
        !          24047:                        }
        !          24048:                }
        !          24049:                while (isspace(*s) || *s == ',' || *s == '-') s++;
        !          24050:                if (isalpha(*s))
        !          24051:                {
        !          24052:                        if ((j = tmlex(s, &t, tm_info.format, TM_NFORM, tm_info.format + TM_SUFFIXES, TM_PARTS - TM_SUFFIXES)) >= 0)
        !          24053:                        {
        !          24054:                                s = t;
        !          24055:                                switch (tm_data.lex[j])
        !          24056:                                {
        !          24057:                                case TM_EXACT:
        !          24058:                                        state |= HOLD|EXACT;
        !          24059:                                        continue;
        !          24060:                                case TM_LAST:
        !          24061:                                        state |= HOLD|LAST;
        !          24062:                                        continue;
        !          24063:                                case TM_THIS:
        !          24064:                                        state |= HOLD|THIS;
        !          24065:                                        n = 0;
        !          24066:                                        continue;
        !          24067:                                case TM_NEXT:
        !          24068:                                        state |= HOLD|NEXT;
        !          24069:                                        continue;
        !          24070:                                case TM_MERIDIAN:
        !          24071:                                        if (n > 0)
        !          24072:                                        {
        !          24073:                                                if (n > 24) goto done;
        !          24074:                                                tm->tm_hour = n;
        !          24075:                                        }
        !          24076:                                        if (j == TM_MERIDIAN)
        !          24077:                                        {
        !          24078:                                                if (tm->tm_hour == 12) tm->tm_hour = 0;
        !          24079:                                        }
        !          24080:                                        else if (tm->tm_hour < 12) tm->tm_hour += 12;
        !          24081:                                        if (n > 0) goto clear_min;
        !          24082:                                        continue;
        !          24083:                                case TM_DAY_3:
        !          24084:                                        j += TM_DAY - TM_DAY_3;
        !          24085:                                        /*FALLTHROUGH*/
        !          24086:                                case TM_DAY:
        !          24087:                                case TM_PARTS:
        !          24088:                                case TM_HOURS:
        !          24089:                                case TM_DAYS:
        !          24090:                                        if (n == -1) n = 1;
        !          24091:                                        if (!(state & (LAST|NEXT|THIS))) for (;;)
        !          24092:                                        {
        !          24093:                                                while (isspace(*s) || *s == ',') s++;
        !          24094:                                                if ((k = tmlex(s, &t, tm_info.format + TM_LAST, TM_NOISE - TM_LAST, (char**)0, 0)) >= 0)
        !          24095:                                                {
        !          24096:                                                        s = t;
        !          24097:                                                        if (k <= 2) state |= LAST;
        !          24098:                                                        else if (k <= 5) state |= THIS;
        !          24099:                                                        else if (k <= 8) state |= NEXT;
        !          24100:                                                        else state |= EXACT;
        !          24101:                                                }
        !          24102:                                                else break;
        !          24103:                                        }
        !          24104:                                        if (state & LAST) n = -n;
        !          24105:                                        else if (!(state & NEXT)) n--;
        !          24106:                                        switch (j)
        !          24107:                                        {
        !          24108:                                        case TM_DAYS+0:
        !          24109:                                                tm->tm_mday--;
        !          24110:                                                goto clear_hour;
        !          24111:                                        case TM_DAYS+1:
        !          24112:                                                goto clear_hour;
        !          24113:                                        case TM_DAYS+2:
        !          24114:                                                tm->tm_mday++;
        !          24115:                                                goto clear_hour;
        !          24116:                                        case TM_PARTS+0:
        !          24117:                                                tm->tm_sec += n;
        !          24118:                                                continue;
        !          24119:                                        case TM_PARTS+1:
        !          24120:                                                tm->tm_min += n;
        !          24121:                                                goto clear_sec;
        !          24122:                                        case TM_PARTS+2:
        !          24123:                                                tm->tm_hour += n;
        !          24124:                                                goto clear_min;
        !          24125:                                        case TM_PARTS+3:
        !          24126:                                                tm->tm_mday += n;
        !          24127:                                                goto clear_hour;
        !          24128:                                        case TM_PARTS+4:
        !          24129:                                                tm->tm_mday += 7 * n - tm->tm_wday + 1;
        !          24130:                                                goto clear_hour;
        !          24131:                                        case TM_PARTS+5:
        !          24132:                                                tm->tm_mon += n;
        !          24133:                                                goto clear_mday;
        !          24134:                                        case TM_PARTS+6:
        !          24135:                                                tm->tm_year += n;
        !          24136:                                                goto clear_mon;
        !          24137:                                        case TM_HOURS+0:
        !          24138:                                                tm->tm_mday += n;
        !          24139:                                                goto clear_hour;
        !          24140:                                        case TM_HOURS+1:
        !          24141:                                                tm->tm_mday += n;
        !          24142:                                                tm->tm_hour = 6;
        !          24143:                                                goto clear_min;
        !          24144:                                        case TM_HOURS+2:
        !          24145:                                                tm->tm_mday += n;
        !          24146:                                                tm->tm_hour = 12;
        !          24147:                                                goto clear_min;
        !          24148:                                        case TM_HOURS+3:
        !          24149:                                                tm->tm_mday += n;
        !          24150:                                                tm->tm_hour = 18;
        !          24151:                                                goto clear_min;
        !          24152:                                        default:
        !          24153:                                                j -= tm->tm_wday + TM_DAY;
        !          24154:                                                if (state & (LAST|NEXT|THIS))
        !          24155:                                                {
        !          24156:                                                        if (j < 0) j += 7;
        !          24157:                                                }
        !          24158:                                                else if (j > 0) j -= 7;
        !          24159:                                                tm->tm_mday += j + n * 7;
        !          24160:                                                if (state & (LAST|NEXT|THIS)) goto clear_hour;
        !          24161:                                                continue;
        !          24162:                                        }
        !          24163:                                        break;
        !          24164:                                case TM_MONTH_3:
        !          24165:                                        j += TM_MONTH - TM_MONTH_3;
        !          24166:                                        /*FALLTHROUGH*/
        !          24167:                                case TM_MONTH:
        !          24168:                                        if (state & MONTH) goto done;
        !          24169:                                        state |= MONTH;
        !          24170:                                        i = tm->tm_mon;
        !          24171:                                        tm->tm_mon = j - TM_MONTH;
        !          24172:                                        if (n < 0)
        !          24173:                                        {
        !          24174:                                                while (isspace(*s) || *s == ',' || *s == '-') s++;
        !          24175:                                                if (isdigit(*s))
        !          24176:                                                {
        !          24177:                                                        n = strtol(s, &t, 10);
        !          24178:                                                        if (n <= 31) s = t;
        !          24179:                                                        else n = -1;
        !          24180:                                                }
        !          24181:                                        }
        !          24182:                                        if (n >= 0)
        !          24183:                                        {
        !          24184:                                                if (n > 31) goto done;
        !          24185:                                                state |= MDAY;
        !          24186:                                                tm->tm_mday = n;
        !          24187:                                        }
        !          24188:                                        if (state & (LAST|NEXT|THIS))
        !          24189:                                        {
        !          24190:                                                n = i;
        !          24191:                                                goto rel_month;
        !          24192:                                        }
        !          24193:                                        continue;
        !          24194:                                case TM_UT:
        !          24195:                                        if (state & ZONE) goto done;
        !          24196:                                        state |= ZONE;
        !          24197:                                        zone += tmgoff(s, &t, 0);
        !          24198:                                        s = t;
        !          24199:                                        continue;
        !          24200:                                case TM_DT:
        !          24201:                                        if (!dst) goto done;
        !          24202:                                        if (!(state & ZONE))
        !          24203:                                        {
        !          24204:                                                dst = tm_info.local.dst;
        !          24205:                                                zone = tm_info.local.west;
        !          24206:                                        }
        !          24207:                                        zone += tmgoff(s, &t, dst);
        !          24208:                                        s = t;
        !          24209:                                        dst = 0;
        !          24210:                                        state |= ZONE;
        !          24211:                                        continue;
        !          24212:                                case TM_NOISE:
        !          24213:                                        continue;
        !          24214:                                }
        !          24215:                        }
        !          24216:                        if (!(state & ZONE) && (j = tmzone(s, &t, type, &dst)) != TM_LOCALZONE)
        !          24217:                        {
        !          24218:                                s = t;
        !          24219:                                zone += j;
        !          24220:                                state |= ZONE;
        !          24221:                                continue;
        !          24222:                        }
        !          24223:                        if (!type && (type = tmtype(s, &t)))
        !          24224:                        {
        !          24225:                                s = t;
        !          24226:                                continue;
        !          24227:                        }
        !          24228:                        state |= BREAK;
        !          24229:                }
        !          24230:                else if (*s == '/')
        !          24231:                {
        !          24232:                        if (!isdigit(*++s) || (state & MONTH) || n == 0 || n > 12) break;
        !          24233:                        i = n - 1;
        !          24234:                        n = strtol(s, &t, 10);
        !          24235:                        s = t;
        !          24236:                        if (n <= 0 || n > 31) break;
        !          24237:                        if (*s == '/' && !isdigit(*(s + 1))) break;
        !          24238:                        state |= MONTH|MDAY;
        !          24239:                        if (*s == '/') s++;
        !          24240:                        tm->tm_mday = n;
        !          24241:                        n = tm->tm_mon;
        !          24242:                        tm->tm_mon = i;
        !          24243:                        if (state & (LAST|NEXT|THIS))
        !          24244:                        {
        !          24245:                        rel_month:
        !          24246:                                if (state & LAST) tm->tm_year -= (tm->tm_mon < n) ? 0 : 1;
        !          24247:                                else tm->tm_year += ((state & NEXT) ? 1 : 0) + ((tm->tm_mon < n) ? 1 : 0);
        !          24248:                                if (state & MDAY) goto clear_hour;
        !          24249:                                goto clear_mday;
        !          24250:                        }
        !          24251:                        continue;
        !          24252:                }
        !          24253:                if (n < 0 || (state & YEAR)) break;
        !          24254:                state |= YEAR;
        !          24255:                if (n > 1900) n -= 1900;
        !          24256:                if (n < 38) n += 100;
        !          24257:                tm->tm_year = n;
        !          24258:                if (state & BREAK)
        !          24259:                {
        !          24260:                        last = t;
        !          24261:                        break;
        !          24262:                }
        !          24263:                continue;
        !          24264:        clear_mon:
        !          24265:                if (state & EXACT) continue;
        !          24266:                tm->tm_mon = 0;
        !          24267:        clear_mday:
        !          24268:                if (state & EXACT) continue;
        !          24269:                tm->tm_mday = 1;
        !          24270:        clear_hour:
        !          24271:                if (state & EXACT) continue;
        !          24272:                tm->tm_hour = 0;
        !          24273:        clear_min:
        !          24274:                if (state & EXACT) continue;
        !          24275:                tm->tm_min = 0;
        !          24276:        clear_sec:
        !          24277:                if (state & EXACT) continue;
        !          24278:                tm->tm_sec = 0;
        !          24279:        }
        !          24280:  done:
        !          24281:        if (e) *e = last;
        !          24282:        return(tmtime(tmfix(tm), (state & ZONE) ? zone : TM_LOCALZONE));
        !          24283: }
        !          24284: 0707070000000003671006440044230044230000010000000460420200600002600000002370tm/tmfix.cUgsfGgsf/*
        !          24285:  * Glenn Fowler
        !          24286:  * AT&T Bell Laboratories
        !          24287:  *
        !          24288:  * time conversion support
        !          24289:  */
        !          24290: 
        !          24291: #include <tm.h>
        !          24292: 
        !          24293: /*
        !          24294:  * correct out of bounds fields in tp
        !          24295:  *
        !          24296:  * tm_wday, tm_yday and tm_isdst are not changed
        !          24297:  * as these can be computed from the other fields
        !          24298:  *
        !          24299:  * tp is the return value
        !          24300:  */
        !          24301: 
        !          24302: struct tm*
        !          24303: #if __STDC__ || __cplusplus
        !          24304: tmfix(register struct tm* tp)
        !          24305: #else
        !          24306: tmfix(tp)
        !          24307: register struct tm*    tp;
        !          24308: #endif
        !          24309: {
        !          24310:        register int    n;
        !          24311: 
        !          24312:        if ((n = tp->tm_sec) < 0)
        !          24313:        {
        !          24314:                tp->tm_min -= (59 - n) / 60;
        !          24315:                tp->tm_sec = 60 - (-n) % 60;
        !          24316:        }
        !          24317:        else if (n > (59 + TM_MAXLEAP))
        !          24318:        {
        !          24319:                tp->tm_min += n / 60;
        !          24320:                tp->tm_sec %= 60;
        !          24321:        }
        !          24322:        if ((n = tp->tm_min) < 0)
        !          24323:        {
        !          24324:                tp->tm_hour -= (59 - n) / 60;
        !          24325:                tp->tm_min = 60 - (-n) % 60;
        !          24326:        }
        !          24327:        else if (n > 59)
        !          24328:        {
        !          24329:                tp->tm_hour += n / 60;
        !          24330:                tp->tm_min %= 60;
        !          24331:        }
        !          24332:        if ((n = tp->tm_hour) < 0)
        !          24333:        {
        !          24334:                tp->tm_mday -= (23 - n) / 24;
        !          24335:                tp->tm_hour = 24 - (-n) % 24;
        !          24336:        }
        !          24337:        else if (n > 59)
        !          24338:        {
        !          24339:                tp->tm_mday += n / 24;
        !          24340:                tp->tm_mday %= 24;
        !          24341:        }
        !          24342:        while (tp->tm_mday < 1)
        !          24343:        {
        !          24344:                if (--tp->tm_mon < 0)
        !          24345:                {
        !          24346:                        tp->tm_mon = 11;
        !          24347:                        tp->tm_year--;
        !          24348:                }
        !          24349:                tp->tm_mday += tm_data.days[tp->tm_mon];
        !          24350:        }
        !          24351:        while (tp->tm_mday > (n = tm_data.days[tp->tm_mon] + (tp->tm_mon == 1 && !(tp->tm_year % 4))))
        !          24352:        {
        !          24353:                tp->tm_mday -= n;
        !          24354:                if (++tp->tm_mon > 11)
        !          24355:                {
        !          24356:                        tp->tm_mon = 0;
        !          24357:                        tp->tm_year++;
        !          24358:                }
        !          24359:        }
        !          24360:        return(tp);
        !          24361: }
        !          24362: 0707070000000003701006440044230044230000010000000475446222500002700000013770tm/tmform.cUgsfGgsf/*
        !          24363:  * Glenn Fowler
        !          24364:  * AT&T Bell Laboratories
        !          24365:  *
        !          24366:  * time conversion support
        !          24367:  */
        !          24368: 
        !          24369: #include <tm.h>
        !          24370: #include <stdio.h>
        !          24371: 
        !          24372: #define elements(x)    (sizeof(x)/sizeof(x[0]))
        !          24373: #define warped(t,n)    ((t)<((n)-6L*30L*24L*60L*60L)||(t)>((n)+60L*60L))
        !          24374: 
        !          24375: #if __STDC__ || __cplusplus
        !          24376: static char*           number(char*, long, int);
        !          24377: #else
        !          24378: static char*           number();
        !          24379: #endif
        !          24380: 
        !          24381: extern time_t          time();
        !          24382: 
        !          24383: /*
        !          24384:  * format date given clock
        !          24385:  * end of buf is returned
        !          24386:  */
        !          24387: 
        !          24388: char*
        !          24389: #if __STDC__ || __cplusplus
        !          24390: tmform(char* buf, const char* format, time_t* clock)
        !          24391: #else
        !          24392: tmform(buf, format, clock)
        !          24393: char*          buf;
        !          24394: char*          format;
        !          24395: time_t*                clock;
        !          24396: #endif
        !          24397: {
        !          24398:        register char*  cp;
        !          24399:        register char*  p;
        !          24400:        register int    n;
        !          24401:        int             c;
        !          24402:        int             i;
        !          24403:        int             flags;
        !          24404:        struct tm*      tp;
        !          24405:        char*           stack[4];
        !          24406:        char**          sp;
        !          24407:        time_t          now;
        !          24408: 
        !          24409:        tp = tmmake(clock);
        !          24410:        if (!format || !*format) format = tm_info.deformat;
        !          24411:        flags = tm_info.flags;
        !          24412:        sp = &stack[0];
        !          24413:        cp = buf;
        !          24414:        for (;;)
        !          24415:        {
        !          24416:                if (!(c = *format++))
        !          24417:                {
        !          24418:                        if (sp <= &stack[0]) break;
        !          24419:                        format = *--sp;
        !          24420:                        continue;
        !          24421:                }
        !          24422:                if (c != '%')
        !          24423:                {
        !          24424:                        *cp++ = c;
        !          24425:                        continue;
        !          24426:                }
        !          24427:                switch (*format++)
        !          24428:                {
        !          24429:                case 0:
        !          24430:                        format--;
        !          24431:                        continue;
        !          24432:                case '%':
        !          24433:                        *cp++ = '%';
        !          24434:                        continue;
        !          24435:                case '?':
        !          24436:                        if (tm_info.deformat != tm_info.format[TM_DEFAULT]) format = tm_info.deformat;
        !          24437:                        else if (!*format) format = tm_info.format[TM_DEFAULT];
        !          24438:                        continue;
        !          24439:                case 'a':       /* abbreviated day of week name */
        !          24440:                        n = TM_DAY_3 + tp->tm_wday;
        !          24441:                        goto index;
        !          24442:                case 'A':       /* day of week name */
        !          24443:                        n = TM_DAY + tp->tm_wday;
        !          24444:                        goto index;
        !          24445:                case 'b':       /* abbreviated month name */
        !          24446:                case 'h':
        !          24447:                        n = TM_MONTH_3 + tp->tm_mon;
        !          24448:                        goto index;
        !          24449:                case 'B':       /* month name */
        !          24450:                        n = TM_MONTH + tp->tm_mon;
        !          24451:                        goto index;
        !          24452:                case 'c':       /* `ctime(3)' date sans newline */
        !          24453:                        p = "%a %b %e %T %Y";
        !          24454:                        goto push;
        !          24455:                case 'C':       /* `date(1)' date */
        !          24456:                        p = "%a %b %e %T %Z %Y";
        !          24457:                        goto push;
        !          24458:                case 'd':       /* day of month */
        !          24459:                        cp = number(cp, (long)tp->tm_mday, 2);
        !          24460:                        continue;
        !          24461:                case 'D':       /* date */
        !          24462:                        p = "%m/%d/%y";
        !          24463:                        goto push;
        !          24464:                case 'E':       /* no pad day of month */
        !          24465:                        cp = number(cp, (long)tp->tm_mday, 0);
        !          24466:                        continue;
        !          24467:                case 'e':       /* blank padded day of month */
        !          24468:                        cp = number(cp, (long)tp->tm_mday, -2);
        !          24469:                        continue;
        !          24470:                case 'H':       /* hour (0 - 23) */
        !          24471:                        cp = number(cp, (long)tp->tm_hour, 2);
        !          24472:                        continue;
        !          24473:                case 'i':       /* international `date(1)' date */
        !          24474:                        p = "%a %b %e %T %z %Z %Y";
        !          24475:                        goto push;
        !          24476:                case 'I':       /* hour (0 - 12) */
        !          24477:                        if ((n = tp->tm_hour) > 12) n -= 12;
        !          24478:                        else if (n == 0) n = 12;
        !          24479:                        cp = number(cp, (long)n, 2);
        !          24480:                        continue;
        !          24481:                case 'J':       /* Julian date (0 offset) */
        !          24482:                        cp = number(cp, (long)tp->tm_yday, 3);
        !          24483:                        continue;
        !          24484:                case 'j':       /* Julian date (1 offset) */
        !          24485:                        cp = number(cp, (long)(tp->tm_yday + 1), 3);
        !          24486:                        continue;
        !          24487:                case 'l':       /* `ls -l' date */
        !          24488:                        p = "%b %e %H:%M";
        !          24489:                        if (clock)
        !          24490:                        {
        !          24491:                                (void)time(&now);
        !          24492:                                if (warped(*clock, now)) p = "%b %e  %Y";
        !          24493:                        }
        !          24494:                        goto push;
        !          24495:                case 'm':       /* month number */
        !          24496:                        cp = number(cp, (long)(tp->tm_mon + 1), 2);
        !          24497:                        continue;
        !          24498:                case 'M':       /* minutes */
        !          24499:                        cp = number(cp, (long)tp->tm_min, 2);
        !          24500:                        continue;
        !          24501:                case 'n':
        !          24502:                        *cp++ = '\n';
        !          24503:                        continue;
        !          24504:                case 'o':       /* TM_DEFAULT override */
        !          24505:                        p = tm_info.deformat;
        !          24506:                        goto push;
        !          24507:                case 'O':       /* TM_DEFAULT */
        !          24508:                        p = tm_info.format[TM_DEFAULT];
        !          24509:                        goto push;
        !          24510:                case 'p':       /* meridian */
        !          24511:                        n = TM_MERIDIAN + (tp->tm_hour >= 12);
        !          24512:                        goto index;
        !          24513:                case 'r':
        !          24514:                        p = "%I:%M:%S %p";
        !          24515:                        goto push;
        !          24516:                case 'R':
        !          24517:                        p = "%H:%M";
        !          24518:                        goto push;
        !          24519:                case 'S':       /* seconds */
        !          24520:                        cp = number(cp, (long)tp->tm_sec, 2);
        !          24521:                        continue;
        !          24522:                case 't':
        !          24523:                        *cp++ = '\t';
        !          24524:                        continue;
        !          24525:                case 'T':
        !          24526:                        p = "%H:%M:%S";
        !          24527:                        goto push;
        !          24528:                case 'U':       /* week number, Sunday as first day */
        !          24529:                        i = tp->tm_yday - tp->tm_wday;
        !          24530:                week:
        !          24531:                        if (i >= -3 )
        !          24532:                        {
        !          24533:                                n = (i + 1) / 7 + 1;
        !          24534:                                if (i % 7 >= 4) n++;
        !          24535:                        }
        !          24536:                        else n = 52;
        !          24537:                        cp = number(cp, (long)n, 2);
        !          24538:                        continue;
        !          24539:                case 'w':       /* weekday number */
        !          24540:                        cp = number(cp, (long)tp->tm_wday, 0);
        !          24541:                        continue;
        !          24542:                case 'W':       /* week number, Monday as first day */
        !          24543:                        if (tp->tm_wday == 0) i = tp->tm_yday - 6;
        !          24544:                        else i = tp->tm_yday - tp->tm_wday + 1;
        !          24545:                        goto week;
        !          24546:                case 'x':
        !          24547:                        p = tm_info.format[TM_DATE];
        !          24548:                        goto push;
        !          24549:                case 'X':
        !          24550:                        p = tm_info.format[TM_TIME];
        !          24551:                        goto push;
        !          24552:                case 'y':       /* year in the form yy */
        !          24553:                        cp = number(cp, (long)tp->tm_year, 2);
        !          24554:                        continue;
        !          24555:                case 'Y':       /* year in the form ccyy */
        !          24556:                        cp = number(cp, (long)(1900 + tp->tm_year), 4);
        !          24557:                        continue;
        !          24558:                case 'z':       /* time zone type */
        !          24559:                        if (!(tm_info.flags & TM_UTC) && (p = tm_info.local.type)) goto string;
        !          24560:                        continue;
        !          24561:                case 'Z':       /* time zone */
        !          24562:                        p = (tm_info.flags & TM_UTC) ? tm_info.format[TM_UT] : tp->tm_isdst ? tm_info.local.daylight : tm_info.local.standard;
        !          24563:                        goto string;
        !          24564:                case '-':
        !          24565:                case '+':
        !          24566:                        switch (*format++)
        !          24567:                        {
        !          24568:                        case 0:
        !          24569:                                format--;
        !          24570:                                continue;
        !          24571:                        case 'l':
        !          24572:                                n = TM_LEAP;
        !          24573:                                break;
        !          24574:                        case 'u':
        !          24575:                                n = TM_UTC;
        !          24576:                                break;
        !          24577:                        }
        !          24578:                        if (c == '+')
        !          24579:                        {
        !          24580:                                if (!(tm_info.flags & n))
        !          24581:                                {
        !          24582:                                        tm_info.flags |= n;
        !          24583:                                        tp = tmmake(clock);
        !          24584:                                }
        !          24585:                        }
        !          24586:                        else if (tm_info.flags & n)
        !          24587:                        {
        !          24588:                                tm_info.flags &= ~n;
        !          24589:                                tp = tmmake(clock);
        !          24590:                        }
        !          24591:                        continue;
        !          24592:                case '#':       /* seconds since the epoch */
        !          24593:                        if (clock) now = *clock;
        !          24594:                        else (void)time(&now);
        !          24595:                        cp = number(cp, (long)now, 0);
        !          24596:                        continue;
        !          24597:                default:
        !          24598:                        *cp++ = c;
        !          24599:                        *cp++ = *(format - 1);
        !          24600:                        continue;
        !          24601:                }
        !          24602:        index:
        !          24603:                p = tm_info.format[n];
        !          24604:        string:
        !          24605:                while (*cp = *p++) cp++;
        !          24606:                continue;
        !          24607:        push:
        !          24608:                if (sp < &stack[elements(stack)])
        !          24609:                {
        !          24610:                        *sp++ = (char*)format;
        !          24611:                        format = p;
        !          24612:                }
        !          24613:                continue;
        !          24614:        }
        !          24615:        tm_info.flags = flags;
        !          24616:        *cp = 0;
        !          24617:        return(cp);
        !          24618: }
        !          24619: 
        !          24620: /*
        !          24621:  * format n with padding p into s
        !          24622:  * return end of s
        !          24623:  *
        !          24624:  * p:  <0      blank padding
        !          24625:  *      0      no padding
        !          24626:  *     >0      0 padding
        !          24627:  */
        !          24628: 
        !          24629: static char*
        !          24630: #if __STDC__ || __cplusplus
        !          24631: number(register char* s, register long n, register int p)
        !          24632: #else
        !          24633: number(s, n, p)
        !          24634: register char* s;
        !          24635: register long  n;
        !          24636: register int   p;
        !          24637: #endif
        !          24638: {
        !          24639: #ifdef cray
        !          24640:        char    format[32];
        !          24641: 
        !          24642:        if (p > 0) (void)sprintf(format, "%%0%dlu", p);
        !          24643:        else if (p < 0) (void)sprintf(format, "%%%dlu", -p);
        !          24644:        else (void)sprintf(format, "%%lu");
        !          24645:        (void)sprintf(s, format, n);
        !          24646: #else
        !          24647:        if (p > 0) (void)sprintf(s, "%0*lu", p, n);
        !          24648:        else if (p < 0) (void)sprintf(s, "%*lu", -p, n);
        !          24649:        else (void)sprintf(s, "%lu", n);
        !          24650: #endif
        !          24651:        while (*s) s++;
        !          24652:        return(s);
        !          24653: }
        !          24654: 0707070000000003711006440044230044230000010000000475446175200002700000001657tm/tmgoff.cUgsfGgsf/*
        !          24655:  * Glenn Fowler
        !          24656:  * AT&T Bell Laboratories
        !          24657:  *
        !          24658:  * time conversion support
        !          24659:  */
        !          24660: 
        !          24661: #include <tm.h>
        !          24662: #include <ctype.h>
        !          24663: 
        !          24664: #if __STDC__ || __cplusplus
        !          24665: #if __cplusplus
        !          24666: extern "C" {
        !          24667: #endif
        !          24668: extern long            strtol(const char*, char**, int);
        !          24669: #if __cplusplus
        !          24670: }
        !          24671: #endif
        !          24672: #else
        !          24673: extern long            strtol();
        !          24674: #endif
        !          24675: 
        !          24676: /*
        !          24677:  * return minutes offset from [[-+]hh[:mm[:ss]]] expression
        !          24678:  *
        !          24679:  * if e is non-null then it points to the first unrecognized char in s
        !          24680:  * d returned if no offset in s
        !          24681:  */
        !          24682: 
        !          24683: int
        !          24684: #if __STDC__ || __cplusplus
        !          24685: tmgoff(register const char* s, char** e, int d)
        !          24686: #else
        !          24687: tmgoff(s, e, d)
        !          24688: register char* s;
        !          24689: char**         e;
        !          24690: int            d;
        !          24691: #endif
        !          24692: {
        !          24693:        register int    n;
        !          24694:        char*           t;
        !          24695: 
        !          24696:        if (isdigit(n = *s) || n == '-' || n == '+')
        !          24697:        {
        !          24698:                n = strtol(s, &t, 10);
        !          24699:                if (t > s)
        !          24700:                {
        !          24701:                        n *= 60;
        !          24702:                        if (*t == ':') n += (n < 0 ? -1 : 1) * strtol(t + 1, &t, 10);
        !          24703:                        if (*t == ':') (void)strtol(t + 1, &t, 10);
        !          24704:                }
        !          24705:                else n = d;
        !          24706:        }
        !          24707:        else
        !          24708:        {
        !          24709:                n = d;
        !          24710:                t = (char*)s;
        !          24711:        }
        !          24712:        if (e) *e = t;
        !          24713:        return(n);
        !          24714: }
        !          24715: 0707070000000003721006440044230044230000010000000475434564600002700000012467tm/tminit.cUgsfGgsf/*
        !          24716:  * Glenn Fowler
        !          24717:  * AT&T Bell Laboratories
        !          24718:  *
        !          24719:  * time conversion support
        !          24720:  */
        !          24721: 
        !          24722: #include <tm.h>
        !          24723: #include <ctype.h>
        !          24724: #include <namval.h>
        !          24725: 
        !          24726: #define TM_type                (-1)
        !          24727: 
        !          24728: static struct namval   options[] =
        !          24729: {
        !          24730:        "adjust",       TM_ADJUST,
        !          24731:        "format",       TM_DEFAULT,
        !          24732:        "leap",         TM_LEAP,
        !          24733:        "type",         TM_type,
        !          24734:        "utc",          TM_UTC,
        !          24735:        0,              0
        !          24736: };
        !          24737: 
        !          24738: struct tminfo          tm_info;
        !          24739: 
        !          24740: char*                  tzname[2];      /* POSIX time zone names        */
        !          24741: 
        !          24742: #if __STDC__ || __cplusplus
        !          24743: #if __cplusplus
        !          24744: extern "C" {
        !          24745: #endif
        !          24746: static int             tzwest(time_t*, int*);
        !          24747: static int             tmopt(char*, struct namval*, int, const char*);
        !          24748: 
        !          24749: extern char*           getenv(const char*);
        !          24750: extern char*           strchr(const char*, int);
        !          24751: extern char*           strdup(const char*);
        !          24752: extern void            stropt(char*, struct namval*, int (*)(char*, struct namval*, int, const char*), char*);
        !          24753: #if __cplusplus
        !          24754: }
        !          24755: #endif
        !          24756: #else
        !          24757: static int             tzwest();
        !          24758: static int             tmopt();
        !          24759: 
        !          24760: extern char*           getenv();
        !          24761: extern char*           strchr();
        !          24762: extern char*           strdup();
        !          24763: #endif
        !          24764: 
        !          24765: /*
        !          24766:  * initialize tm data
        !          24767:  */
        !          24768: 
        !          24769: void
        !          24770: tminit()
        !          24771: {
        !          24772:        register struct tz*     zp;
        !          24773:        register int            n;
        !          24774:        register char*          s;
        !          24775:        int                     i;
        !          24776:        int                     m;
        !          24777:        int                     isdst;
        !          24778:        char*                   t;
        !          24779:        struct tm*              tp;
        !          24780:        time_t                  now;
        !          24781:        char                    buf[20];
        !          24782: 
        !          24783:        /*
        !          24784:         * only do this stuff once
        !          24785:         */
        !          24786: 
        !          24787:        if (tm_info.local.standard) return;
        !          24788: 
        !          24789:        /*
        !          24790:         * tm_info.format language support goes here
        !          24791:         */
        !          24792: 
        !          24793:        tm_info.format = tm_data.format;
        !          24794:        tm_info.deformat = tm_data.format[TM_DEFAULT];
        !          24795: 
        !          24796:        /*
        !          24797:         * tm_info.local
        !          24798:         */
        !          24799: 
        !          24800:        (void)time(&now);
        !          24801:        n = tzwest(&now, &isdst);
        !          24802: 
        !          24803:        /*
        !          24804:         * compute local DST offset by roaming
        !          24805:         * through the last 12 months until tzwest() changes
        !          24806:         */
        !          24807: 
        !          24808:        for (i = 0; i < 12; i++)
        !          24809:        {
        !          24810:                now -= 31 * 24 * 60 * 60;
        !          24811:                if ((m = tzwest(&now, &isdst)) != n)
        !          24812:                {
        !          24813:                        if (!isdst)
        !          24814:                        {
        !          24815:                                isdst = n;
        !          24816:                                n = m;
        !          24817:                                m = isdst;
        !          24818:                        }
        !          24819:                        m -= n;
        !          24820:                        break;
        !          24821:                }
        !          24822:        }
        !          24823:        tm_info.local.west = n;
        !          24824:        tm_info.local.dst = m;
        !          24825: 
        !          24826:        /*
        !          24827:         * now get the time zone names
        !          24828:         */
        !          24829: 
        !          24830:        if (tzname[0])
        !          24831:        {
        !          24832:                /*
        !          24833:                 * POSIX
        !          24834:                 */
        !          24835: 
        !          24836:                tm_info.local.standard = tzname[0];
        !          24837:                tm_info.local.daylight = tzname[1];
        !          24838:        }
        !          24839:        else if ((s = getenv("TZNAME")) && *s && (s = strdup(s)))
        !          24840:        {
        !          24841:                /*
        !          24842:                 * BSD
        !          24843:                 */
        !          24844: 
        !          24845:                tm_info.local.standard = s;
        !          24846:                if (s = strchr(s, ',')) *s++ = 0;
        !          24847:                else s = "";
        !          24848:                tm_info.local.daylight = s;
        !          24849:        }
        !          24850:        else if ((s = getenv("TZ")) && *s && *s != ':' && (s = strdup(s)))
        !          24851:        {
        !          24852:                /*
        !          24853:                 * POSIX style but skipped by localtime()
        !          24854:                 */
        !          24855: 
        !          24856:                tm_info.local.standard = s;
        !          24857:                if (*++s && *++s && *++s)
        !          24858:                {
        !          24859:                        *s++ = 0;
        !          24860:                        (void)tmgoff(s, &t, 0);
        !          24861:                        s = t;
        !          24862:                }
        !          24863:                else s = "";
        !          24864:                tm_info.local.daylight = s;
        !          24865:        }
        !          24866:        else
        !          24867:        {
        !          24868:                /*
        !          24869:                 * tm_data.zone table lookup
        !          24870:                 */
        !          24871: 
        !          24872:                t = 0;
        !          24873:                for (zp = &tm_data.zone[0]; zp->standard; zp++)
        !          24874:                {
        !          24875:                        if (zp->type) t = zp->type;
        !          24876:                        if (zp->west == n && zp->dst == m)
        !          24877:                        {
        !          24878:                                tm_info.local.type = t;
        !          24879:                                tm_info.local.standard = zp->standard;
        !          24880:                                if (!(s = zp->daylight))
        !          24881:                                {
        !          24882:                                        s = tmpoff(buf, zp->standard, 0, 0);
        !          24883:                                        *s++ = ' ';
        !          24884:                                        (void)tmpoff(s, tm_info.format[TM_DT], m, TM_DST);
        !          24885:                                        s = strdup(buf);
        !          24886:                                }
        !          24887:                                tm_info.local.daylight = s;
        !          24888:                                break;
        !          24889:                        }
        !          24890:                }
        !          24891:                if (!zp->standard)
        !          24892:                {
        !          24893:                        /*
        !          24894:                         * not in the table
        !          24895:                         */
        !          24896: 
        !          24897:                        s = tmpoff(buf, tm_info.format[TM_UT], n, 0);
        !          24898:                        tm_info.local.standard = strdup(buf);
        !          24899:                        *s++ = ' ';
        !          24900:                        (void)tmpoff(s, tm_info.format[TM_UT], m, TM_DST);
        !          24901:                        tm_info.local.daylight = strdup(buf);
        !          24902:                }
        !          24903:        }
        !          24904: 
        !          24905:        /*
        !          24906:         * set the options
        !          24907:         */
        !          24908: 
        !          24909:        stropt(getenv("TM_OPTIONS"), options, tmopt, (char*)0);
        !          24910: 
        !          24911:        /*
        !          24912:         * the time zone type is probably related to the locale
        !          24913:         */
        !          24914: 
        !          24915:        if (!tm_info.local.type)
        !          24916:        {
        !          24917:                s = tm_info.local.standard;
        !          24918:                t = 0;
        !          24919:                for (zp = &tm_data.zone[0]; zp->standard; zp++)
        !          24920:                {
        !          24921:                        if (zp->type) t = zp->type;
        !          24922:                        if (tmword(s, (char**)0, zp->standard, (char**)0, 0))
        !          24923:                        {
        !          24924:                                tm_info.local.type = t;
        !          24925:                                break;
        !          24926:                        }
        !          24927:                }
        !          24928:        }
        !          24929: 
        !          24930:        /*
        !          24931:         * tm_info.flags
        !          24932:         */
        !          24933: 
        !          24934:        if (!(tm_info.flags & TM_ADJUST))
        !          24935:        {
        !          24936:                now = (time_t)78811200;         /* Jun 30 1972 23:59:60 */
        !          24937:                tp = (struct tm*)localtime(&now);
        !          24938:                if (tp->tm_sec != 60) tm_info.flags |= TM_ADJUST;
        !          24939:        }
        !          24940:        if (!(tm_info.flags & TM_UTC))
        !          24941:        {
        !          24942:                s = tm_info.local.standard;
        !          24943:                for (zp = &tm_data.zone[0]; !zp->type && zp->standard; zp++)
        !          24944:                        if (tmword(s, (char**)0, zp->standard, (char**)0, 0))
        !          24945:                        {
        !          24946:                                tm_info.flags |= TM_UTC;
        !          24947:                                break;
        !          24948:                        }
        !          24949:        }
        !          24950: }
        !          24951: 
        !          24952: /*
        !          24953:  * stropt() option handler
        !          24954:  */
        !          24955: 
        !          24956: /*ARGSUSED*/
        !          24957: static int
        !          24958: #if __STDC__ || __cplusplus
        !          24959: tmopt(char* a, struct namval* p, int n, const char* v)
        !          24960: #else
        !          24961: tmopt(a, p, n, v)
        !          24962: char*          a;
        !          24963: struct namval* p;
        !          24964: int            n;
        !          24965: char*          v;
        !          24966: #endif
        !          24967: {
        !          24968:        char*   s;
        !          24969: 
        !          24970:        switch (p->value)
        !          24971:        {
        !          24972:        case TM_DEFAULT:
        !          24973:                tm_info.deformat = (n && (n = strlen(v)) > 0 && (n < 2 || v[n-2] != '%' || v[n-1] != '?')) ? strdup(v) : tm_info.format[TM_DEFAULT];
        !          24974:                break;
        !          24975:        case TM_type:
        !          24976:                tm_info.local.type = (n && *v) ? ((s = tmtype(v, (char**)0)) ? s : strdup(v)) : 0;
        !          24977:                break;
        !          24978:        default:
        !          24979:                if (n) tm_info.flags |= p->value;
        !          24980:                else tm_info.flags &= ~p->value;
        !          24981:                break;
        !          24982:        }
        !          24983:        return(0);
        !          24984: }
        !          24985: 
        !          24986: /*
        !          24987:  * return minutes west of GMT for local time clock
        !          24988:  *
        !          24989:  * isdst will point to non-zero if DST is in effect
        !          24990:  * this routine also kicks in the local initialization
        !          24991:  */
        !          24992: 
        !          24993: static int
        !          24994: #if __STDC__ || __cplusplus
        !          24995: tzwest(time_t* clock, int* isdst)
        !          24996: #else
        !          24997: tzwest(clock, isdst)
        !          24998: time_t*        clock;
        !          24999: int*   isdst;
        !          25000: #endif
        !          25001: {
        !          25002:        register struct tm*     tp;
        !          25003:        register int            n;
        !          25004:        register int            m;
        !          25005:        int                     h;
        !          25006: 
        !          25007:        /*
        !          25008:         * convert to GMT assuming local time
        !          25009:         */
        !          25010: 
        !          25011:        tp = (struct tm*)gmtime(clock);
        !          25012:        n = tp->tm_yday;
        !          25013:        h = tp->tm_hour;
        !          25014:        m = tp->tm_min;
        !          25015: 
        !          25016:        /*
        !          25017:         * localtime() handles DST and GMT offset
        !          25018:         */
        !          25019: 
        !          25020:        tp = (struct tm*)localtime(clock);
        !          25021:        if (n = tp->tm_yday - n)
        !          25022:        {
        !          25023:                if (n > 1) n = -1;
        !          25024:                else if (n < -1) n = 1;
        !          25025:        }
        !          25026:        *isdst = tp->tm_isdst;
        !          25027:        return((h - tp->tm_hour - n * 24) * 60 + m - tp->tm_min);
        !          25028: }
        !          25029: 0707070000000003731006440044230044230000010000000444527264400002700000001036tm/tmleap.cUgsfGgsf/*
        !          25030:  * Glenn Fowler
        !          25031:  * AT&T Bell Laboratories
        !          25032:  *
        !          25033:  * time conversion support
        !          25034:  */
        !          25035: 
        !          25036: #include <tm.h>
        !          25037: 
        !          25038: /*
        !          25039:  * return clock with leap seconds adjusted
        !          25040:  * for direct localtime() access
        !          25041:  */
        !          25042: 
        !          25043: time_t
        !          25044: #if __STDC__ || __cplusplus
        !          25045: tmleap(register time_t* clock)
        !          25046: #else
        !          25047: tmleap(clock)
        !          25048: register time_t*       clock;
        !          25049: #endif
        !          25050: {
        !          25051:        register struct tl*     lp;
        !          25052:        time_t                  now;
        !          25053: 
        !          25054:        tmset();
        !          25055:        if (clock) now = *clock;
        !          25056:        else (void)time(&now);
        !          25057:        if (tm_info.flags & TM_ADJUST)
        !          25058:        {
        !          25059:                for (lp = &tm_data.leap[0]; now < (lp->time - lp->total); lp++);
        !          25060:                now += lp->total;
        !          25061:        }
        !          25062:        return(now);
        !          25063: }
        !          25064: 0707070000000003741006440044230044230000010000000475434572700002600000001531tm/tmlex.cUgsfGgsf/*
        !          25065:  * Glenn Fowler
        !          25066:  * AT&T Bell Laboratories
        !          25067:  *
        !          25068:  * time conversion support
        !          25069:  */
        !          25070: 
        !          25071: #include <tm.h>
        !          25072: #include <ctype.h>
        !          25073: 
        !          25074: /*
        !          25075:  * return the tab table index that matches s ignoring case and .'s
        !          25076:  *
        !          25077:  * ntab and nsuf are the number of elements in tab and suf,
        !          25078:  * -1 for 0 sentinel
        !          25079:  *
        !          25080:  * all isalpha() chars in str must match
        !          25081:  * suf is a table of nsuf valid str suffixes 
        !          25082:  * if e is non-null then it will point to first unmatched char in str
        !          25083:  * which will always be non-isalpha()
        !          25084:  */
        !          25085: 
        !          25086: int
        !          25087: #if __STDC__ || __cplusplus
        !          25088: tmlex(register const char* s, char** e, char** tab, register int ntab, char** suf, int nsuf)
        !          25089: #else
        !          25090: tmlex(s, e, tab, ntab, suf, nsuf)
        !          25091: register char* s;
        !          25092: char**         e;
        !          25093: char**         tab;
        !          25094: register int   ntab;
        !          25095: char**         suf;
        !          25096: int            nsuf;
        !          25097: #endif
        !          25098: {
        !          25099:        register char** p;
        !          25100: 
        !          25101:        for (p = tab; ntab-- && *p; p++)
        !          25102:                if (tmword(s, e, *p, suf, nsuf))
        !          25103:                        return(p - tab);
        !          25104:        return(-1);
        !          25105: }
        !          25106: 0707070000000003751006440044230044230000010000000444527267200002700000001505tm/tmmake.cUgsfGgsf/*
        !          25107:  * Glenn Fowler
        !          25108:  * AT&T Bell Laboratories
        !          25109:  *
        !          25110:  * time conversion support
        !          25111:  */
        !          25112: 
        !          25113: #include <tm.h>
        !          25114: 
        !          25115: /*
        !          25116:  * return tm struct for clock
        !          25117:  * leap seconds accounted for in return value
        !          25118:  */
        !          25119: 
        !          25120: struct tm*
        !          25121: #if __STDC__ || __cplusplus
        !          25122: tmmake(time_t* clock)
        !          25123: #else
        !          25124: tmmake(clock)
        !          25125: time_t*        clock;
        !          25126: #endif
        !          25127: {
        !          25128:        register struct tm*     tp;
        !          25129:        register struct tl*     lp;
        !          25130:        int                     leapsec;
        !          25131:        time_t                  now;
        !          25132: 
        !          25133:        tmset();
        !          25134:        if (clock) now = *clock;
        !          25135:        else (void)time(&now);
        !          25136:        leapsec = 0;
        !          25137:        if ((tm_info.flags & (TM_ADJUST|TM_LEAP)) == (TM_ADJUST|TM_LEAP) && now > 0)
        !          25138:        {
        !          25139:                for (lp = &tm_data.leap[0]; now < lp->time; lp++);
        !          25140:                if (lp->total)
        !          25141:                {
        !          25142:                        if (now == lp->time && (leapsec = (lp->total - (lp+1)->total)) < 0) leapsec = 0;
        !          25143:                        now -= lp->total;
        !          25144:                }
        !          25145:        }
        !          25146:        tp = (tm_info.flags & TM_UTC) ? (struct tm*)gmtime(&now) : (struct tm*)localtime(&now);
        !          25147:        tp->tm_sec += leapsec;
        !          25148:        return(tp);
        !          25149: }
        !          25150: 0707070000000003761006440044230044230000010000000475434575400002700000001217tm/tmpoff.cUgsfGgsf/*
        !          25151:  * Glenn Fowler
        !          25152:  * AT&T Bell Laboratories
        !          25153:  *
        !          25154:  * time conversion support
        !          25155:  */
        !          25156: 
        !          25157: #include <tm.h>
        !          25158: #include <stdio.h>
        !          25159: 
        !          25160: /*
        !          25161:  * append p and hh:mm part of n to s
        !          25162:  *
        !          25163:  * n ignored if n==d
        !          25164:  * end of s is returned
        !          25165:  */
        !          25166: 
        !          25167: char*
        !          25168: #if __STDC__ || __cplusplus
        !          25169: tmpoff(register char* s, register const char* p, register int n, int d)
        !          25170: #else
        !          25171: tmpoff(s, p, n, d)
        !          25172: register char* s;
        !          25173: register char* p;
        !          25174: register int   n;
        !          25175: int            d;
        !          25176: #endif
        !          25177: {
        !          25178:        while (*s = *p++) s++;
        !          25179:        if (n != d)
        !          25180:        {
        !          25181:                if (n < 0)
        !          25182:                {
        !          25183:                        n = -n;
        !          25184:                        *s++ = '-';
        !          25185:                }
        !          25186:                else *s++ = '+';
        !          25187:                (void)sprintf(s, "%d", n / 60);
        !          25188:                while (*++s);
        !          25189:                if (n %= 60)
        !          25190:                {
        !          25191:                        (void)sprintf(s, ":%02d", n);
        !          25192:                        while (*++s);
        !          25193:                }
        !          25194:        }
        !          25195:        return(s);
        !          25196: }
        !          25197: 0707070000000003771006440044230044230000010000000444527276500002700000002633tm/tmtime.cUgsfGgsf/*
        !          25198:  * Glenn Fowler
        !          25199:  * AT&T Bell Laboratories
        !          25200:  *
        !          25201:  * time conversion support
        !          25202:  */
        !          25203: 
        !          25204: #include <tm.h>
        !          25205: 
        !          25206: /*
        !          25207:  * convert struct tm to time_t
        !          25208:  *
        !          25209:  * if west==TM_LOCALZONE then the local timezone is used
        !          25210:  * otherwise west is the number of minutes west
        !          25211:  * of GMT with DST taken into account
        !          25212:  */
        !          25213: 
        !          25214: time_t
        !          25215: #if __STDC__ || __cplusplus
        !          25216: tmtime(register struct tm* tp, int west)
        !          25217: #else
        !          25218: tmtime(tp, west)
        !          25219: register struct tm*    tp;
        !          25220: int                    west;
        !          25221: #endif
        !          25222: {
        !          25223:        register time_t         clock;
        !          25224:        register struct tl*     lp;
        !          25225:        int                     n;
        !          25226:        int                     sec;
        !          25227:        time_t                  now;
        !          25228: 
        !          25229:        tmset();
        !          25230:        clock = (tp->tm_year * (4 * 365 + 1) - 69) / 4 - 70 * 365;
        !          25231:        if ((n = tp->tm_mon) > 11) n = 11;
        !          25232:        if (n > 1 && !(tp->tm_year % 4)) clock++;
        !          25233:        clock += tm_data.sum[n] + tp->tm_mday - 1;
        !          25234:        clock *= 24;
        !          25235:        clock += tp->tm_hour;
        !          25236:        clock *= 60;
        !          25237:        clock += tp->tm_min;
        !          25238:        clock *= 60;
        !          25239:        clock += sec = tp->tm_sec;
        !          25240:        if (!(tm_info.flags & TM_UTC))
        !          25241:        {
        !          25242:                /*
        !          25243:                 * time zone adjustments
        !          25244:                 */
        !          25245: 
        !          25246:                if (west == TM_LOCALZONE)
        !          25247:                {
        !          25248:                        clock += tm_info.local.west * 60;
        !          25249:                        now = clock;
        !          25250:                        if (tmmake(&now)->tm_isdst) clock += tm_info.local.dst * 60;
        !          25251:                }
        !          25252:                else clock += west * 60;
        !          25253:        }
        !          25254:        if (tm_info.flags & TM_LEAP)
        !          25255:        {
        !          25256:                /*
        !          25257:                 * leap second adjustments
        !          25258:                 */
        !          25259: 
        !          25260:                if (clock > 0)
        !          25261:                {
        !          25262:                        for (lp = &tm_data.leap[0]; clock < lp->time - (lp+1)->total; lp++);
        !          25263:                        clock += lp->total;
        !          25264:                        n = lp->total - (lp+1)->total;
        !          25265:                        if (clock <= (lp->time + n) && (n > 0 && sec > 59 || n < 0 && sec > (59 + n) && sec <= 59)) clock -= n;
        !          25266:                }
        !          25267:        }
        !          25268:        return(clock);
        !          25269: }
        !          25270: 0707070000000004001006440044230044230000010000000475434616600002700000001216tm/tmtype.cUgsfGgsf/*
        !          25271:  * Glenn Fowler
        !          25272:  * AT&T Bell Laboratories
        !          25273:  *
        !          25274:  * time conversion support
        !          25275:  */
        !          25276: 
        !          25277: #include <tm.h>
        !          25278: 
        !          25279: /*
        !          25280:  * return the tm_data.zone[] time zone type name for s
        !          25281:  *
        !          25282:  * if e is non-null then it will point to the first
        !          25283:  * unmatched char in s
        !          25284:  *
        !          25285:  * 0 returned for no match
        !          25286:  */
        !          25287: 
        !          25288: char*
        !          25289: #if __STDC__ || __cplusplus
        !          25290: tmtype(register const char* s, char** e)
        !          25291: #else
        !          25292: tmtype(s, e)
        !          25293: register char* s;
        !          25294: char**         e;
        !          25295: #endif
        !          25296: {
        !          25297:        register struct tz*     zp;
        !          25298:        register char*          t;
        !          25299: 
        !          25300:        tmset();
        !          25301:        zp = &tm_info.local;
        !          25302:        do
        !          25303:        {
        !          25304:                if ((t = zp->type) && tmword(s, e, t, (char**)0, 0)) return(t);
        !          25305:                if (zp == &tm_info.local) zp = &tm_data.zone[0];
        !          25306:                else zp++;
        !          25307:        } while (zp->standard);
        !          25308:        return(0);
        !          25309: }
        !          25310: 0707070000000004011006440044230044230000010000000475447574200002700000002326tm/tmword.cUgsfGgsf/*
        !          25311:  * Glenn Fowler
        !          25312:  * AT&T Bell Laboratories
        !          25313:  *
        !          25314:  * time conversion support
        !          25315:  */
        !          25316: 
        !          25317: #include <tm.h>
        !          25318: #include <ctype.h>
        !          25319: 
        !          25320: /*
        !          25321:  * match s against t ignoring case and .'s
        !          25322:  *
        !          25323:  * suf is an n element table of suffixes that may trail s
        !          25324:  * if all isalpha() chars in s match then 1 is returned
        !          25325:  * and if e is non-null it will point to the first unmatched
        !          25326:  * char in s, otherwise 0 is returned
        !          25327:  */
        !          25328: 
        !          25329: int
        !          25330: #if __STDC__ || __cplusplus
        !          25331: tmword(register const char* s, char** e, register const char* t, char** suf, int n)
        !          25332: #else
        !          25333: tmword(s, e, t, suf, n)
        !          25334: register char* s;
        !          25335: char**         e;
        !          25336: register char* t;
        !          25337: char**         suf;
        !          25338: int            n;
        !          25339: #endif
        !          25340: {
        !          25341:        register int    c;
        !          25342: #if __STDC__ || __cplusplus
        !          25343:        const char*     b;
        !          25344: #else
        !          25345:        char*           b;
        !          25346: #endif
        !          25347: 
        !          25348:        if (*s && *t)
        !          25349:        {
        !          25350:                b = s;
        !          25351:                while (c = *s++)
        !          25352:                {
        !          25353:                        if (c != '.')
        !          25354:                        {
        !          25355:                                if (!isalpha(c) || c != *t && (islower(c) ? toupper(c) : tolower(c)) != *t) break;
        !          25356:                                t++;
        !          25357:                        }
        !          25358:                }
        !          25359:                s--;
        !          25360:                if (!isalpha(c))
        !          25361:                {
        !          25362:                        if (e) *e = (char*)s;
        !          25363:                        return(1);
        !          25364:                }
        !          25365:                if (!*t && s > (b + 1))
        !          25366:                {
        !          25367:                        b = s;
        !          25368:                        while (n-- && (t = *suf++))
        !          25369:                        {
        !          25370:                                s = b;
        !          25371:                                while (isalpha(c = *s++) && (c == *t || (islower(c) ? toupper(c) : tolower(c)) == *t)) t++;
        !          25372:                                if (!*t && !isalpha(c))
        !          25373:                                {
        !          25374:                                        if (e) *e = (char*)s - 1;
        !          25375:                                        return(1);
        !          25376:                                }
        !          25377:                        }
        !          25378:                }
        !          25379:        }
        !          25380:        return(0);
        !          25381: }
        !          25382: 0707070000000004021006440044230044230000010000000475446240000002700000002352tm/tmzone.cUgsfGgsf/*
        !          25383:  * Glenn Fowler
        !          25384:  * AT&T Bell Laboratories
        !          25385:  *
        !          25386:  * time conversion support
        !          25387:  */
        !          25388: 
        !          25389: #include <tm.h>
        !          25390: 
        !          25391: /*
        !          25392:  * return minutes west of GMT for timezone name and type
        !          25393:  *
        !          25394:  * if type==0 then all time zone types match
        !          25395:  * otherwise type must be a value returned by tmtype()
        !          25396:  *
        !          25397:  * if end is non-null then it will point to the next
        !          25398:  * unmatched char in name
        !          25399:  *
        !          25400:  * if dst is non-null then it will point to the DST
        !          25401:  * offset for standard zones and 0 for daylight zones
        !          25402:  *
        !          25403:  * TM_LOCALZONE returned for no match
        !          25404:  */
        !          25405: 
        !          25406: int
        !          25407: #if __STDC__ || __cplusplus
        !          25408: tmzone(register const char* name, char** end, const char* type, int* dst)
        !          25409: #else
        !          25410: tmzone(name, end, type, dst)
        !          25411: register char* name;
        !          25412: char**         end;
        !          25413: char*          type;
        !          25414: int*           dst;
        !          25415: #endif
        !          25416: {
        !          25417:        register struct tz*     zp;
        !          25418:        register char*          prev;
        !          25419: 
        !          25420:        tmset();
        !          25421:        zp = &tm_info.local;
        !          25422:        prev = 0;
        !          25423:        do
        !          25424:        {
        !          25425:                if (zp->type) prev = zp->type;
        !          25426:                if (!type || type == prev || !prev)
        !          25427:                {
        !          25428:                        if (tmword(name, end, zp->standard, (char**)0, 0))
        !          25429:                        {
        !          25430:                                if (dst) *dst = zp->dst;
        !          25431:                                return(zp->west);
        !          25432:                        }
        !          25433:                        if (zp->dst && zp->daylight && tmword(name, end, zp->daylight, (char**)0, 0))
        !          25434:                        {
        !          25435:                                if (dst) *dst = 0;
        !          25436:                                return(zp->west + zp->dst);
        !          25437:                        }
        !          25438:                }
        !          25439:                if (zp == &tm_info.local) zp = &tm_data.zone[0];
        !          25440:                else zp++;
        !          25441:        } while (zp->standard);
        !          25442:        return(TM_LOCALZONE);
        !          25443: }
        !          25444: 0707070000000004031006440044230044230000010000000452433643200003100000001741vec/vecargs.cUgsfGgsf/*
        !          25445:  * G. S. Fowler
        !          25446:  * AT&T Bell Laboratories
        !          25447:  *
        !          25448:  * string vector argv insertion
        !          25449:  */
        !          25450: 
        !          25451: #include <ctype.h>
        !          25452: 
        !          25453: extern char*   malloc();
        !          25454: extern void    vecfree();
        !          25455: 
        !          25456: /*
        !          25457:  * insert the string vector vec between
        !          25458:  * (*argvp)[0] and (*argvp)[1], sliding (*argvp)[1] ... over
        !          25459:  * null and blank args are deleted
        !          25460:  *
        !          25461:  * vecfree(vec) always called
        !          25462:  *
        !          25463:  * -1 returned if insertion failed
        !          25464:  */
        !          25465: 
        !          25466: int
        !          25467: vecargs(vec, argcp, argvp)
        !          25468: register char**        vec;
        !          25469: int*           argcp;
        !          25470: char***                argvp;
        !          25471: {
        !          25472:        register char** argv;
        !          25473:        register char** oargv;
        !          25474:        char**          ovec;
        !          25475:        char*           s;
        !          25476:        int             num;
        !          25477: 
        !          25478:        if (!vec) return(-1);
        !          25479:        if ((num = (char**)(*(vec - 1)) - vec) > 0)
        !          25480:        {
        !          25481:                if (!(argv = (char**)malloc((num + *argcp + 1) * sizeof(char*))))
        !          25482:                {
        !          25483:                        vecfree(vec, 0);
        !          25484:                        return(-1);
        !          25485:                }
        !          25486:                oargv = *argvp;
        !          25487:                *argvp = argv;
        !          25488:                *argv++ = *oargv++;
        !          25489:                ovec = vec;
        !          25490:                while (s = *argv = *vec++)
        !          25491:                {
        !          25492:                        while (isspace(*s)) s++;
        !          25493:                        if (*s) argv++;
        !          25494:                }
        !          25495:                vecfree(ovec, 1);
        !          25496:                while (*argv = *oargv++) argv++;
        !          25497:                *argcp = argv - *argvp;
        !          25498:        }
        !          25499:        else vecfree(vec, 0);
        !          25500:        return(0);
        !          25501: }
        !          25502: 0707070000000004041006440044230044230000010000000452433442300003100000001246vec/vecfile.cUgsfGgsf/*
        !          25503:  * Glenn Fowler
        !          25504:  * AT&T Bell Laboratories
        !          25505:  *
        !          25506:  * string vector load support
        !          25507:  */
        !          25508: 
        !          25509: #include <sys/types.h>
        !          25510: #include <sys/stat.h>
        !          25511: 
        !          25512: extern char**  vecload();
        !          25513: extern int     close();
        !          25514: extern int     fstat();
        !          25515: extern char*   malloc();
        !          25516: extern int     open();
        !          25517: 
        !          25518: /*
        !          25519:  * load a string vector from lines in file
        !          25520:  */
        !          25521: 
        !          25522: char**
        !          25523: vecfile(file)
        !          25524: char*  file;
        !          25525: {
        !          25526:        register int    n;
        !          25527:        register char*  buf;
        !          25528:        register char** vec;
        !          25529:        int             fd;
        !          25530:        struct stat     st;
        !          25531: 
        !          25532:        vec = 0;
        !          25533:        if ((fd = open(file, 0)) >= 0)
        !          25534:        {
        !          25535:                if (!fstat(fd, &st) && (n = st.st_size) > 0 && (buf = malloc(n + 1)))
        !          25536:                {
        !          25537:                        if (read(fd, buf, n) == n)
        !          25538:                        {
        !          25539:                                buf[n] = 0;
        !          25540:                                vec = vecload(buf);
        !          25541:                        }
        !          25542:                        if (!vec) free(buf);
        !          25543:                }
        !          25544:                (void)close(fd);
        !          25545:        }
        !          25546:        return(vec);
        !          25547: }
        !          25548: 0707070000000004051006440044230044230000010000000452433425200003100000000641vec/vecfree.cUgsfGgsf/*
        !          25549:  * Glenn Fowler
        !          25550:  * AT&T Bell Laboratories
        !          25551:  *
        !          25552:  * file to string vector support
        !          25553:  */
        !          25554: 
        !          25555: extern void    free();
        !          25556: 
        !          25557: /*
        !          25558:  * free a string vector generated by vecload()
        !          25559:  *
        !          25560:  * retain!=0 frees the string pointers but retains the string data
        !          25561:  * in this case the data is permanently allocated
        !          25562:  */
        !          25563: 
        !          25564: void
        !          25565: vecfree(vec, retain)
        !          25566: register char**        vec;
        !          25567: int            retain;
        !          25568: {
        !          25569:        if (vec)
        !          25570:        {
        !          25571:                if (*(vec -= 2) && !retain) free(*vec);
        !          25572:                free(vec);
        !          25573:        }
        !          25574: }
        !          25575: 0707070000000004061006440044230044230000010000000452435623600003100000002115vec/vecload.cUgsfGgsf/*
        !          25576:  * Glenn Fowler
        !          25577:  * AT&T Bell Laboratories
        !          25578:  *
        !          25579:  * string vector load support
        !          25580:  */
        !          25581: 
        !          25582: extern char**  malloc();
        !          25583: 
        !          25584: /*
        !          25585:  * load a string vector from lines in buf
        !          25586:  * buf may be modified on return
        !          25587:  *
        !          25588:  * each line in buf is treated as a new vector element
        !          25589:  * lines with # as first char are comments
        !          25590:  * \ as the last char joins consecutive lines
        !          25591:  *
        !          25592:  * the vector ends with a 0 sentinel
        !          25593:  *
        !          25594:  * the string array pointer is returned
        !          25595:  */
        !          25596: 
        !          25597: char**
        !          25598: vecload(buf)
        !          25599: char*  buf;
        !          25600: {
        !          25601:        register char*  s;
        !          25602:        register int    n;
        !          25603:        register char** p;
        !          25604:        char**          vec;
        !          25605: 
        !          25606:        vec = 0;
        !          25607:        n = (*buf == '#') ? -1 : 0;
        !          25608:        for (s = buf;; s++)
        !          25609:        {
        !          25610:                if (*s == '\n')
        !          25611:                {
        !          25612:                        if (s > buf && *(s - 1) == '\\') *(s - 1) = *s = ' ';
        !          25613:                        else
        !          25614:                        {
        !          25615:                                *s = 0;
        !          25616:                                if (*(s + 1) != '#')
        !          25617:                                {
        !          25618:                                        n++;
        !          25619:                                        if (!*(s + 1)) break;
        !          25620:                                }
        !          25621:                        }
        !          25622:                }
        !          25623:                else if (!*s)
        !          25624:                {
        !          25625:                        n++;
        !          25626:                        break;
        !          25627:                }
        !          25628:        }
        !          25629:        if (n < 0) n = 0;
        !          25630:        if (p = (char**)malloc((n + 3) * sizeof(char*)))
        !          25631:        {
        !          25632:                *p++ = s = buf;
        !          25633:                vec = ++p;
        !          25634:                if (n > 0) for (;;)
        !          25635:                {
        !          25636:                        if (*s != '#')
        !          25637:                        {
        !          25638:                                *p++ = s;
        !          25639:                                if (--n <= 0) break;
        !          25640:                        }
        !          25641:                        while (*s) s++;
        !          25642:                        s++;
        !          25643:                }
        !          25644:                *p = 0;
        !          25645:                *(vec - 1) = (char*)p;
        !          25646:        }
        !          25647:        return(vec);
        !          25648: }
        !          25649: 0707070000000004071006440044230044230000010000000460214101600003300000000566vec/vecstring.cUgsfGgsf/*
        !          25650:  * Glenn Fowler
        !          25651:  * AT&T Bell Laboratories
        !          25652:  *
        !          25653:  * string vector load support
        !          25654:  */
        !          25655: 
        !          25656: extern char**  vecload();
        !          25657: extern char*   strdup();
        !          25658: 
        !          25659: /*
        !          25660:  * load a string vector from lines in str
        !          25661:  */
        !          25662: 
        !          25663: char**
        !          25664: vecstring(str)
        !          25665: char*  str;
        !          25666: {
        !          25667:        register char*  buf;
        !          25668:        register char** vec;
        !          25669: 
        !          25670:        if (!str || !*str || !(buf = strdup(str))) vec = 0;
        !          25671:        else if (!(vec = vecload(buf))) free(buf);
        !          25672:        return(vec);
        !          25673: }
        !          25674: 0707070000000004101006440044230044230000010000000475522432300002300000432567MamfileUgsfGgsfnote # # make abstract machine file generated from Makefile # #
        !          25675: setv AS as
        !          25676: setv ASFLAGS
        !          25677: setv AR ar
        !          25678: setv ARFLAGS cr
        !          25679: setv CC cc
        !          25680: setv CCFLAGS "-O"
        !          25681: setv CPP "$CC -E"
        !          25682: setv CPIO cpio
        !          25683: setv CPIOFLAGS
        !          25684: setv F77 f77
        !          25685: setv INSTALLROOT $HOME
        !          25686: setv LD ld
        !          25687: setv LDFLAGS 
        !          25688: setv LEX lex
        !          25689: setv LEXFLAGS
        !          25690: setv LPR lpr
        !          25691: setv LPRFLAGS
        !          25692: setv M4FLAGS 
        !          25693: setv MAKE nmake
        !          25694: setv MAKEFLAGS
        !          25695: setv PR pr
        !          25696: setv PRFLAGS
        !          25697: setv TAR tar
        !          25698: setv YACC yacc
        !          25699: setv YACCFLAGS -d
        !          25700: make install
        !          25701: make all
        !          25702: make libx.a
        !          25703: attr arch
        !          25704: make opendir.o
        !          25705: make dir/opendir.c
        !          25706: attr perm
        !          25707: attr scan
        !          25708: make /usr/include/errno.h
        !          25709: attr perm
        !          25710: attr scan
        !          25711: attr impl
        !          25712: make /usr/include/sys/errno.h
        !          25713: attr perm
        !          25714: attr scan
        !          25715: attr impl
        !          25716: done /usr/include/sys/errno.h
        !          25717: done /usr/include/errno.h
        !          25718: make dir/dirlib.h
        !          25719: attr perm
        !          25720: attr scan
        !          25721: attr impl
        !          25722: make include/hash.h
        !          25723: attr perm
        !          25724: attr scan
        !          25725: attr impl
        !          25726: done include/hash.h
        !          25727: make limits.h
        !          25728: make mkhdr
        !          25729: make port/mkhdr.sh
        !          25730: attr perm
        !          25731: attr scan
        !          25732: done port/mkhdr.sh
        !          25733: prev port/mkhdr.sh
        !          25734: exec case '' in
        !          25735: .... "")       cp port/mkhdr.sh mkhdr
        !          25736: ....   ;;
        !          25737: .... *)        {
        !          25738: ....   i=`(read x; echo $x) < port/mkhdr.sh`
        !          25739: ....   case $i in
        !          25740: ....   \#!*)   echo $i ;;
        !          25741: ....   esac
        !          25742: ....   echo 
        !          25743: ....   cat port/mkhdr.sh
        !          25744: ....   } > mkhdr
        !          25745: ....   ;;
        !          25746: .... esac
        !          25747: .... chmod u+w,+x mkhdr
        !          25748: done mkhdr
        !          25749: make genhdr
        !          25750: make genhdr.o
        !          25751: make port/genhdr.c
        !          25752: attr perm
        !          25753: attr scan
        !          25754: make lclstdio.h
        !          25755: prev mkhdr
        !          25756: exec mkhdr lclstdio "" "$CC" $CCFLAGS   > lclstdio.h
        !          25757: attr scan
        !          25758: attr impl
        !          25759: done lclstdio.h
        !          25760: make lcldirent.h
        !          25761: prev mkhdr
        !          25762: exec mkhdr lcldirent "" "$CC" $CCFLAGS   > lcldirent.h
        !          25763: attr scan
        !          25764: attr impl
        !          25765: done lcldirent.h
        !          25766: make lclparam.h
        !          25767: prev mkhdr
        !          25768: exec mkhdr lclparam "" "$CC" $CCFLAGS   > lclparam.h
        !          25769: attr scan
        !          25770: attr impl
        !          25771: done lclparam.h
        !          25772: make lcllimits.h
        !          25773: prev mkhdr
        !          25774: exec mkhdr lcllimits "" "$CC" $CCFLAGS   > lcllimits.h
        !          25775: attr scan
        !          25776: attr impl
        !          25777: done lcllimits.h
        !          25778: make FEATURE/getdents
        !          25779: exec : generate local FEATURE information for getdents
        !          25780: .... set -
        !          25781: .... if        test ! -d FEATURE
        !          25782: .... then      rm -rf FEATURE
        !          25783: ....   mkdir FEATURE
        !          25784: .... fi
        !          25785: .... {
        !          25786: .... echo '/* local info for getdents */'
        !          25787: .... case "getdents" in
        !          25788: .... *.*)      f=getdents
        !          25789: ....   i=getdents
        !          25790: ....   ;;
        !          25791: .... *)        f=getdents
        !          25792: ....   i=getdents
        !          25793: ....   echo "#undef $i
        !          25794: ....           int $i;" > x.${!-$$}.c
        !          25795: ....   cmd=:
        !          25796: ....   opt=
        !          25797: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          25798: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          25799: ....           then    opt=-Bstatic
        !          25800: ....           else    cmd=x.${!-$$}.x
        !          25801: ....           fi
        !          25802: ....   fi
        !          25803: ....   echo "#undef $i
        !          25804: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          25805: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          25806: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          25807: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          25808: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          25809: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          25810: ....           fi
        !          25811: ....   fi
        !          25812: ....   ;;
        !          25813: .... esac
        !          25814: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          25815: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          25816: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          25817: .... fi
        !          25818: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          25819: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          25820: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          25821: .... fi
        !          25822: .... for j in / /usr/
        !          25823: .... do        for i in bin etc ucb
        !          25824: ....   do      if      test -f $j$i/$f
        !          25825: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          25826: ....                   break 2
        !          25827: ....           fi
        !          25828: ....   done
        !          25829: .... done
        !          25830: .... } > FEATURE/getdents
        !          25831: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          25832: attr scan
        !          25833: attr impl
        !          25834: done FEATURE/getdents
        !          25835: make FEATURE/dir
        !          25836: exec : generate local FEATURE information for dir
        !          25837: .... set -
        !          25838: .... if        test ! -d FEATURE
        !          25839: .... then      rm -rf FEATURE
        !          25840: ....   mkdir FEATURE
        !          25841: .... fi
        !          25842: .... {
        !          25843: .... echo '/* local info for dir */'
        !          25844: .... case "dir" in
        !          25845: .... *.*)      f=dir
        !          25846: ....   i=dir
        !          25847: ....   ;;
        !          25848: .... *)        f=dir
        !          25849: ....   i=dir
        !          25850: ....   echo "#undef $i
        !          25851: ....           int $i;" > x.${!-$$}.c
        !          25852: ....   cmd=:
        !          25853: ....   opt=
        !          25854: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          25855: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          25856: ....           then    opt=-Bstatic
        !          25857: ....           else    cmd=x.${!-$$}.x
        !          25858: ....           fi
        !          25859: ....   fi
        !          25860: ....   echo "#undef $i
        !          25861: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          25862: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          25863: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          25864: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          25865: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          25866: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          25867: ....           fi
        !          25868: ....   fi
        !          25869: ....   ;;
        !          25870: .... esac
        !          25871: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          25872: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          25873: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          25874: .... fi
        !          25875: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          25876: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          25877: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          25878: .... fi
        !          25879: .... for j in / /usr/
        !          25880: .... do        for i in bin etc ucb
        !          25881: ....   do      if      test -f $j$i/$f
        !          25882: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          25883: ....                   break 2
        !          25884: ....           fi
        !          25885: ....   done
        !          25886: .... done
        !          25887: .... } > FEATURE/dir
        !          25888: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          25889: attr scan
        !          25890: attr impl
        !          25891: done FEATURE/dir
        !          25892: done port/genhdr.c
        !          25893: prev port/genhdr.c
        !          25894: exec $CC $CCFLAGS -I.  -c port/genhdr.c
        !          25895: done genhdr.o
        !          25896: exec $CC $CCFLAGS  $LDFLAGS   -o genhdr genhdr.o 
        !          25897: done genhdr
        !          25898: exec mkhdr limits " genhdr" "$CC" $CCFLAGS   > limits.h
        !          25899: attr scan
        !          25900: attr impl
        !          25901: prev lcllimits.h
        !          25902: done limits.h
        !          25903: make dirent.h
        !          25904: prev mkhdr
        !          25905: prev genhdr
        !          25906: exec mkhdr dirent " genhdr" "$CC" $CCFLAGS   > dirent.h
        !          25907: attr scan
        !          25908: attr impl
        !          25909: prev lcldirent.h
        !          25910: done dirent.h
        !          25911: make fsinfo.h
        !          25912: prev mkhdr
        !          25913: prev genhdr
        !          25914: exec mkhdr fsinfo " genhdr" "$CC" $CCFLAGS   > fsinfo.h
        !          25915: attr scan
        !          25916: attr impl
        !          25917: done fsinfo.h
        !          25918: prev lclparam.h
        !          25919: make preroot.h
        !          25920: prev mkhdr
        !          25921: exec mkhdr preroot "" "$CC" $CCFLAGS   > preroot.h
        !          25922: attr scan
        !          25923: attr impl
        !          25924: done preroot.h
        !          25925: done dir/dirlib.h
        !          25926: done dir/opendir.c
        !          25927: prev dir/opendir.c
        !          25928: exec $CC $CCFLAGS -I. -Idir -Iinclude  -c dir/opendir.c
        !          25929: done opendir.o
        !          25930: make readdir.o
        !          25931: make dir/readdir.c
        !          25932: attr perm
        !          25933: attr scan
        !          25934: prev dir/dirlib.h
        !          25935: done dir/readdir.c
        !          25936: prev dir/readdir.c
        !          25937: exec $CC $CCFLAGS -I. -Idir -Iinclude  -c dir/readdir.c
        !          25938: done readdir.o
        !          25939: make rewinddir.o
        !          25940: make dir/rewinddir.c
        !          25941: attr perm
        !          25942: attr scan
        !          25943: prev dir/dirlib.h
        !          25944: done dir/rewinddir.c
        !          25945: prev dir/rewinddir.c
        !          25946: exec $CC $CCFLAGS -I. -Idir -Iinclude  -c dir/rewinddir.c
        !          25947: done rewinddir.o
        !          25948: make seekdir.o
        !          25949: make dir/seekdir.c
        !          25950: attr perm
        !          25951: attr scan
        !          25952: prev dir/dirlib.h
        !          25953: done dir/seekdir.c
        !          25954: prev dir/seekdir.c
        !          25955: exec $CC $CCFLAGS -I. -Idir -Iinclude  -c dir/seekdir.c
        !          25956: done seekdir.o
        !          25957: make telldir.o
        !          25958: make dir/telldir.c
        !          25959: attr perm
        !          25960: attr scan
        !          25961: prev dir/dirlib.h
        !          25962: done dir/telldir.c
        !          25963: prev dir/telldir.c
        !          25964: exec $CC $CCFLAGS -I. -Idir -Iinclude  -c dir/telldir.c
        !          25965: done telldir.o
        !          25966: make getcwd.o
        !          25967: make misc/getcwd.c
        !          25968: attr perm
        !          25969: attr scan
        !          25970: prev limits.h
        !          25971: prev /usr/include/errno.h
        !          25972: prev dirent.h
        !          25973: make /usr/include/sys/stat.h
        !          25974: done /usr/include/sys/stat.h
        !          25975: make /usr/include/sys/types.h
        !          25976: done /usr/include/sys/types.h
        !          25977: done misc/getcwd.c
        !          25978: prev misc/getcwd.c
        !          25979: exec $CC $CCFLAGS -I.  -c misc/getcwd.c
        !          25980: done getcwd.o
        !          25981: make setcwd.o
        !          25982: make misc/setcwd.c
        !          25983: attr perm
        !          25984: attr scan
        !          25985: prev /usr/include/errno.h
        !          25986: prev limits.h
        !          25987: done misc/setcwd.c
        !          25988: prev misc/setcwd.c
        !          25989: setv DEBUG -UDEBUG
        !          25990: exec $CC $CCFLAGS -I. "$DEBUG" -c misc/setcwd.c
        !          25991: done setcwd.o
        !          25992: make getshell.o
        !          25993: make misc/getshell.c
        !          25994: attr perm
        !          25995: attr scan
        !          25996: done misc/getshell.c
        !          25997: prev misc/getshell.c
        !          25998: exec $CC $CCFLAGS   -c misc/getshell.c
        !          25999: done getshell.o
        !          26000: make hashalloc.o
        !          26001: make hash/hashalloc.c
        !          26002: attr perm
        !          26003: attr scan
        !          26004: make hash/hashlib.h
        !          26005: attr perm
        !          26006: attr scan
        !          26007: attr impl
        !          26008: prev include/hash.h
        !          26009: prev limits.h
        !          26010: done hash/hashlib.h
        !          26011: done hash/hashalloc.c
        !          26012: prev hash/hashalloc.c
        !          26013: exec $CC $CCFLAGS -I. -Ihash -Iinclude  -c hash/hashalloc.c
        !          26014: done hashalloc.o
        !          26015: make hashdump.o
        !          26016: make hash/hashdump.c
        !          26017: attr perm
        !          26018: attr scan
        !          26019: prev hash/hashlib.h
        !          26020: make include/stdio.h
        !          26021: done include/stdio.h
        !          26022: done hash/hashdump.c
        !          26023: prev hash/hashdump.c
        !          26024: exec $CC $CCFLAGS -I. -Ihash -Iinclude  -c hash/hashdump.c
        !          26025: done hashdump.o
        !          26026: make hashfree.o
        !          26027: make hash/hashfree.c
        !          26028: attr perm
        !          26029: attr scan
        !          26030: prev hash/hashlib.h
        !          26031: done hash/hashfree.c
        !          26032: prev hash/hashfree.c
        !          26033: exec $CC $CCFLAGS -I. -Ihash -Iinclude  -c hash/hashfree.c
        !          26034: done hashfree.o
        !          26035: make hashlook.o
        !          26036: make hash/hashlook.c
        !          26037: attr perm
        !          26038: attr scan
        !          26039: prev hash/hashlib.h
        !          26040: done hash/hashlook.c
        !          26041: prev hash/hashlook.c
        !          26042: exec $CC $CCFLAGS -I. -Ihash -Iinclude  -c hash/hashlook.c
        !          26043: done hashlook.o
        !          26044: make hashscan.o
        !          26045: make hash/hashscan.c
        !          26046: attr perm
        !          26047: attr scan
        !          26048: prev hash/hashlib.h
        !          26049: done hash/hashscan.c
        !          26050: prev hash/hashscan.c
        !          26051: exec $CC $CCFLAGS -I. -Ihash -Iinclude  -c hash/hashscan.c
        !          26052: done hashscan.o
        !          26053: make hashsize.o
        !          26054: make hash/hashsize.c
        !          26055: attr perm
        !          26056: attr scan
        !          26057: prev hash/hashlib.h
        !          26058: done hash/hashsize.c
        !          26059: prev hash/hashsize.c
        !          26060: exec $CC $CCFLAGS -I. -Ihash -Iinclude  -c hash/hashsize.c
        !          26061: done hashsize.o
        !          26062: make hashwalk.o
        !          26063: make hash/hashwalk.c
        !          26064: attr perm
        !          26065: attr scan
        !          26066: prev hash/hashlib.h
        !          26067: done hash/hashwalk.c
        !          26068: prev hash/hashwalk.c
        !          26069: exec $CC $CCFLAGS -I. -Ihash -Iinclude  -c hash/hashwalk.c
        !          26070: done hashwalk.o
        !          26071: make memhash.o
        !          26072: make hash/memhash.c
        !          26073: attr perm
        !          26074: attr scan
        !          26075: prev hash/hashlib.h
        !          26076: done hash/memhash.c
        !          26077: prev hash/memhash.c
        !          26078: exec $CC $CCFLAGS -I. -Ihash -Iinclude  -c hash/memhash.c
        !          26079: done memhash.o
        !          26080: make memsum.o
        !          26081: make hash/memsum.c
        !          26082: attr perm
        !          26083: attr scan
        !          26084: prev hash/hashlib.h
        !          26085: done hash/memsum.c
        !          26086: prev hash/memsum.c
        !          26087: exec $CC $CCFLAGS -I. -Ihash -Iinclude  -c hash/memsum.c
        !          26088: done memsum.o
        !          26089: make strhash.o
        !          26090: make hash/strhash.c
        !          26091: attr perm
        !          26092: attr scan
        !          26093: prev hash/hashlib.h
        !          26094: done hash/strhash.c
        !          26095: prev hash/strhash.c
        !          26096: exec $CC $CCFLAGS -I. -Ihash -Iinclude  -c hash/strhash.c
        !          26097: done strhash.o
        !          26098: make strsum.o
        !          26099: make hash/strsum.c
        !          26100: attr perm
        !          26101: attr scan
        !          26102: prev hash/hashlib.h
        !          26103: done hash/strsum.c
        !          26104: prev hash/strsum.c
        !          26105: exec $CC $CCFLAGS -I. -Ihash -Iinclude  -c hash/strsum.c
        !          26106: done strsum.o
        !          26107: make cvtatoe.o
        !          26108: make misc/cvtatoe.c
        !          26109: attr perm
        !          26110: attr scan
        !          26111: done misc/cvtatoe.c
        !          26112: prev misc/cvtatoe.c
        !          26113: exec $CC $CCFLAGS   -c misc/cvtatoe.c
        !          26114: done cvtatoe.o
        !          26115: make cvtetoa.o
        !          26116: make misc/cvtetoa.c
        !          26117: attr perm
        !          26118: attr scan
        !          26119: done misc/cvtetoa.c
        !          26120: prev misc/cvtetoa.c
        !          26121: exec $CC $CCFLAGS   -c misc/cvtetoa.c
        !          26122: done cvtetoa.o
        !          26123: make chresc.o
        !          26124: make string/chresc.c
        !          26125: attr perm
        !          26126: attr scan
        !          26127: done string/chresc.c
        !          26128: prev string/chresc.c
        !          26129: exec $CC $CCFLAGS   -c string/chresc.c
        !          26130: done chresc.o
        !          26131: make ctoi.o
        !          26132: make string/ctoi.c
        !          26133: attr perm
        !          26134: attr scan
        !          26135: prev limits.h
        !          26136: done string/ctoi.c
        !          26137: prev string/ctoi.c
        !          26138: exec $CC $CCFLAGS -I.  -c string/ctoi.c
        !          26139: done ctoi.o
        !          26140: make streval.o
        !          26141: make string/streval.c
        !          26142: attr perm
        !          26143: attr scan
        !          26144: make /usr/include/ctype.h
        !          26145: attr perm
        !          26146: attr scan
        !          26147: attr impl
        !          26148: done /usr/include/ctype.h
        !          26149: done string/streval.c
        !          26150: prev string/streval.c
        !          26151: exec $CC $CCFLAGS   -c string/streval.c
        !          26152: done streval.o
        !          26153: make strmatch.o
        !          26154: make string/strmatch.c
        !          26155: attr perm
        !          26156: attr scan
        !          26157: prev /usr/include/ctype.h
        !          26158: done string/strmatch.c
        !          26159: prev string/strmatch.c
        !          26160: exec $CC $CCFLAGS   -c string/strmatch.c
        !          26161: done strmatch.o
        !          26162: make strcopy.o
        !          26163: make string/strcopy.c
        !          26164: attr perm
        !          26165: attr scan
        !          26166: done string/strcopy.c
        !          26167: prev string/strcopy.c
        !          26168: exec $CC $CCFLAGS   -c string/strcopy.c
        !          26169: done strcopy.o
        !          26170: make strmode.o
        !          26171: make string/strmode.c
        !          26172: attr perm
        !          26173: attr scan
        !          26174: make string/modelib.h
        !          26175: attr perm
        !          26176: attr scan
        !          26177: attr impl
        !          26178: done string/modelib.h
        !          26179: done string/strmode.c
        !          26180: prev string/strmode.c
        !          26181: exec $CC $CCFLAGS -Istring  -c string/strmode.c
        !          26182: done strmode.o
        !          26183: make stresc.o
        !          26184: make string/stresc.c
        !          26185: attr perm
        !          26186: attr scan
        !          26187: done string/stresc.c
        !          26188: prev string/stresc.c
        !          26189: exec $CC $CCFLAGS   -c string/stresc.c
        !          26190: done stresc.o
        !          26191: make stropt.o
        !          26192: make string/stropt.c
        !          26193: attr perm
        !          26194: attr scan
        !          26195: prev /usr/include/ctype.h
        !          26196: make include/namval.h
        !          26197: attr perm
        !          26198: attr scan
        !          26199: attr impl
        !          26200: done include/namval.h
        !          26201: done string/stropt.c
        !          26202: prev string/stropt.c
        !          26203: exec $CC $CCFLAGS -Iinclude  -c string/stropt.c
        !          26204: done stropt.o
        !          26205: make strtape.o
        !          26206: make string/strtape.c
        !          26207: attr perm
        !          26208: attr scan
        !          26209: prev include/stdio.h
        !          26210: done string/strtape.c
        !          26211: prev string/strtape.c
        !          26212: exec $CC $CCFLAGS -Iinclude  -c string/strtape.c
        !          26213: done strtape.o
        !          26214: make tok.o
        !          26215: make string/tok.c
        !          26216: attr perm
        !          26217: attr scan
        !          26218: done string/tok.c
        !          26219: prev string/tok.c
        !          26220: exec $CC $CCFLAGS   -c string/tok.c
        !          26221: done tok.o
        !          26222: make pathaccess.o
        !          26223: make misc/pathaccess.c
        !          26224: attr perm
        !          26225: attr scan
        !          26226: prev /usr/include/sys/stat.h
        !          26227: prev /usr/include/sys/types.h
        !          26228: prev limits.h
        !          26229: done misc/pathaccess.c
        !          26230: prev misc/pathaccess.c
        !          26231: exec $CC $CCFLAGS -I.  -c misc/pathaccess.c
        !          26232: done pathaccess.o
        !          26233: make pathcanon.o
        !          26234: make misc/pathcanon.c
        !          26235: attr perm
        !          26236: attr scan
        !          26237: done misc/pathcanon.c
        !          26238: prev misc/pathcanon.c
        !          26239: exec $CC $CCFLAGS   -c misc/pathcanon.c
        !          26240: done pathcanon.o
        !          26241: make pathcheck.o
        !          26242: make misc/pathcheck.c
        !          26243: attr perm
        !          26244: attr scan
        !          26245: done misc/pathcheck.c
        !          26246: prev misc/pathcheck.c
        !          26247: exec $CC $CCFLAGS   -c misc/pathcheck.c
        !          26248: done pathcheck.o
        !          26249: make pathpath.o
        !          26250: make misc/pathpath.c
        !          26251: attr perm
        !          26252: attr scan
        !          26253: done misc/pathpath.c
        !          26254: prev misc/pathpath.c
        !          26255: exec $CC $CCFLAGS   -c misc/pathpath.c
        !          26256: done pathpath.o
        !          26257: make pathkey.o
        !          26258: make misc/pathkey.c
        !          26259: attr perm
        !          26260: attr scan
        !          26261: prev include/stdio.h
        !          26262: prev preroot.h
        !          26263: prev /usr/include/ctype.h
        !          26264: prev limits.h
        !          26265: done misc/pathkey.c
        !          26266: prev misc/pathkey.c
        !          26267: exec $CC $CCFLAGS -I. -Iinclude  -c misc/pathkey.c
        !          26268: done pathkey.o
        !          26269: make pathprobe.o
        !          26270: make misc/pathprobe.c
        !          26271: attr perm
        !          26272: attr scan
        !          26273: make include/ls.h
        !          26274: attr perm
        !          26275: attr scan
        !          26276: attr impl
        !          26277: prev fsinfo.h
        !          26278: done include/ls.h
        !          26279: prev limits.h
        !          26280: done misc/pathprobe.c
        !          26281: prev misc/pathprobe.c
        !          26282: exec $CC $CCFLAGS -I. -Iinclude  -c misc/pathprobe.c
        !          26283: done pathprobe.o
        !          26284: make pathtemp.o
        !          26285: make misc/pathtemp.c
        !          26286: attr perm
        !          26287: attr scan
        !          26288: done misc/pathtemp.c
        !          26289: prev misc/pathtemp.c
        !          26290: exec $CC $CCFLAGS   -c misc/pathtemp.c
        !          26291: done pathtemp.o
        !          26292: make cmdargs.o
        !          26293: make misc/cmdargs.c
        !          26294: attr perm
        !          26295: attr scan
        !          26296: make include/option.h
        !          26297: attr perm
        !          26298: attr scan
        !          26299: attr impl
        !          26300: done include/option.h
        !          26301: done misc/cmdargs.c
        !          26302: prev misc/cmdargs.c
        !          26303: exec $CC $CCFLAGS -Iinclude  -c misc/cmdargs.c
        !          26304: done cmdargs.o
        !          26305: make fs3d.o
        !          26306: make misc/fs3d.c
        !          26307: attr perm
        !          26308: attr scan
        !          26309: done misc/fs3d.c
        !          26310: prev misc/fs3d.c
        !          26311: exec $CC $CCFLAGS   -c misc/fs3d.c
        !          26312: done fs3d.o
        !          26313: make ftwalk.o
        !          26314: make misc/ftwalk.c
        !          26315: attr perm
        !          26316: attr scan
        !          26317: make include/ftwalk.h
        !          26318: attr perm
        !          26319: attr scan
        !          26320: attr impl
        !          26321: done include/ftwalk.h
        !          26322: prev /usr/include/errno.h
        !          26323: prev limits.h
        !          26324: prev dirent.h
        !          26325: prev /usr/include/sys/stat.h
        !          26326: prev /usr/include/sys/types.h
        !          26327: done misc/ftwalk.c
        !          26328: prev misc/ftwalk.c
        !          26329: exec $CC $CCFLAGS -I. -Iinclude  -c misc/ftwalk.c
        !          26330: done ftwalk.o
        !          26331: make perror.o
        !          26332: make misc/perror.c
        !          26333: attr perm
        !          26334: attr scan
        !          26335: make FEATURE/strerror
        !          26336: exec : generate local FEATURE information for strerror
        !          26337: .... set -
        !          26338: .... if        test ! -d FEATURE
        !          26339: .... then      rm -rf FEATURE
        !          26340: ....   mkdir FEATURE
        !          26341: .... fi
        !          26342: .... {
        !          26343: .... echo '/* local info for strerror */'
        !          26344: .... case "strerror" in
        !          26345: .... *.*)      f=strerror
        !          26346: ....   i=strerror
        !          26347: ....   ;;
        !          26348: .... *)        f=strerror
        !          26349: ....   i=strerror
        !          26350: ....   echo "#undef $i
        !          26351: ....           int $i;" > x.${!-$$}.c
        !          26352: ....   cmd=:
        !          26353: ....   opt=
        !          26354: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          26355: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          26356: ....           then    opt=-Bstatic
        !          26357: ....           else    cmd=x.${!-$$}.x
        !          26358: ....           fi
        !          26359: ....   fi
        !          26360: ....   echo "#undef $i
        !          26361: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          26362: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          26363: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          26364: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          26365: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          26366: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          26367: ....           fi
        !          26368: ....   fi
        !          26369: ....   ;;
        !          26370: .... esac
        !          26371: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          26372: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          26373: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          26374: .... fi
        !          26375: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          26376: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          26377: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          26378: .... fi
        !          26379: .... for j in / /usr/
        !          26380: .... do        for i in bin etc ucb
        !          26381: ....   do      if      test -f $j$i/$f
        !          26382: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          26383: ....                   break 2
        !          26384: ....           fi
        !          26385: ....   done
        !          26386: .... done
        !          26387: .... } > FEATURE/strerror
        !          26388: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          26389: attr scan
        !          26390: attr impl
        !          26391: done FEATURE/strerror
        !          26392: prev include/stdio.h
        !          26393: done misc/perror.c
        !          26394: prev misc/perror.c
        !          26395: exec $CC $CCFLAGS -I. -Iinclude  -c misc/perror.c
        !          26396: done perror.o
        !          26397: make putenv.o
        !          26398: make misc/putenv.c
        !          26399: attr perm
        !          26400: attr scan
        !          26401: done misc/putenv.c
        !          26402: prev misc/putenv.c
        !          26403: exec $CC $CCFLAGS   -c misc/putenv.c
        !          26404: done putenv.o
        !          26405: make calloc.o
        !          26406: make misc/calloc.c
        !          26407: attr perm
        !          26408: attr scan
        !          26409: make FEATURE/bzero
        !          26410: exec : generate local FEATURE information for bzero
        !          26411: .... set -
        !          26412: .... if        test ! -d FEATURE
        !          26413: .... then      rm -rf FEATURE
        !          26414: ....   mkdir FEATURE
        !          26415: .... fi
        !          26416: .... {
        !          26417: .... echo '/* local info for bzero */'
        !          26418: .... case "bzero" in
        !          26419: .... *.*)      f=bzero
        !          26420: ....   i=bzero
        !          26421: ....   ;;
        !          26422: .... *)        f=bzero
        !          26423: ....   i=bzero
        !          26424: ....   echo "#undef $i
        !          26425: ....           int $i;" > x.${!-$$}.c
        !          26426: ....   cmd=:
        !          26427: ....   opt=
        !          26428: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          26429: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          26430: ....           then    opt=-Bstatic
        !          26431: ....           else    cmd=x.${!-$$}.x
        !          26432: ....           fi
        !          26433: ....   fi
        !          26434: ....   echo "#undef $i
        !          26435: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          26436: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          26437: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          26438: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          26439: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          26440: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          26441: ....           fi
        !          26442: ....   fi
        !          26443: ....   ;;
        !          26444: .... esac
        !          26445: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          26446: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          26447: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          26448: .... fi
        !          26449: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          26450: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          26451: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          26452: .... fi
        !          26453: .... for j in / /usr/
        !          26454: .... do        for i in bin etc ucb
        !          26455: ....   do      if      test -f $j$i/$f
        !          26456: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          26457: ....                   break 2
        !          26458: ....           fi
        !          26459: ....   done
        !          26460: .... done
        !          26461: .... } > FEATURE/bzero
        !          26462: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          26463: attr scan
        !          26464: attr impl
        !          26465: done FEATURE/bzero
        !          26466: done misc/calloc.c
        !          26467: prev misc/calloc.c
        !          26468: exec $CC $CCFLAGS -I.  -c misc/calloc.c
        !          26469: done calloc.o
        !          26470: make malloc.o
        !          26471: make misc/malloc.c
        !          26472: attr perm
        !          26473: attr scan
        !          26474: make FEATURE/bcopy
        !          26475: exec : generate local FEATURE information for bcopy
        !          26476: .... set -
        !          26477: .... if        test ! -d FEATURE
        !          26478: .... then      rm -rf FEATURE
        !          26479: ....   mkdir FEATURE
        !          26480: .... fi
        !          26481: .... {
        !          26482: .... echo '/* local info for bcopy */'
        !          26483: .... case "bcopy" in
        !          26484: .... *.*)      f=bcopy
        !          26485: ....   i=bcopy
        !          26486: ....   ;;
        !          26487: .... *)        f=bcopy
        !          26488: ....   i=bcopy
        !          26489: ....   echo "#undef $i
        !          26490: ....           int $i;" > x.${!-$$}.c
        !          26491: ....   cmd=:
        !          26492: ....   opt=
        !          26493: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          26494: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          26495: ....           then    opt=-Bstatic
        !          26496: ....           else    cmd=x.${!-$$}.x
        !          26497: ....           fi
        !          26498: ....   fi
        !          26499: ....   echo "#undef $i
        !          26500: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          26501: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          26502: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          26503: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          26504: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          26505: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          26506: ....           fi
        !          26507: ....   fi
        !          26508: ....   ;;
        !          26509: .... esac
        !          26510: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          26511: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          26512: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          26513: .... fi
        !          26514: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          26515: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          26516: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          26517: .... fi
        !          26518: .... for j in / /usr/
        !          26519: .... do        for i in bin etc ucb
        !          26520: ....   do      if      test -f $j$i/$f
        !          26521: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          26522: ....                   break 2
        !          26523: ....           fi
        !          26524: ....   done
        !          26525: .... done
        !          26526: .... } > FEATURE/bcopy
        !          26527: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          26528: attr scan
        !          26529: attr impl
        !          26530: done FEATURE/bcopy
        !          26531: done misc/malloc.c
        !          26532: prev misc/malloc.c
        !          26533: exec $CC $CCFLAGS -I. "$DEBUG" -c misc/malloc.c
        !          26534: done malloc.o
        !          26535: make getnamval.o
        !          26536: make misc/getnamval.c
        !          26537: attr perm
        !          26538: attr scan
        !          26539: prev include/namval.h
        !          26540: done misc/getnamval.c
        !          26541: prev misc/getnamval.c
        !          26542: exec $CC $CCFLAGS -Iinclude  -c misc/getnamval.c
        !          26543: done getnamval.o
        !          26544: make optget.o
        !          26545: make misc/optget.c
        !          26546: attr perm
        !          26547: attr scan
        !          26548: done misc/optget.c
        !          26549: prev misc/optget.c
        !          26550: exec $CC $CCFLAGS   -c misc/optget.c
        !          26551: done optget.o
        !          26552: make hsort.o
        !          26553: make misc/hsort.c
        !          26554: attr perm
        !          26555: attr scan
        !          26556: done misc/hsort.c
        !          26557: prev misc/hsort.c
        !          26558: exec $CC $CCFLAGS   -c misc/hsort.c
        !          26559: done hsort.o
        !          26560: make query.o
        !          26561: make misc/query.c
        !          26562: attr perm
        !          26563: attr scan
        !          26564: prev include/stdio.h
        !          26565: done misc/query.c
        !          26566: prev misc/query.c
        !          26567: exec $CC $CCFLAGS -Iinclude  -c misc/query.c
        !          26568: done query.o
        !          26569: make error.o
        !          26570: make misc/error.c
        !          26571: attr perm
        !          26572: attr scan
        !          26573: make include/sfio.h
        !          26574: done include/sfio.h
        !          26575: make sig.h
        !          26576: prev mkhdr
        !          26577: exec mkhdr sig "" "$CC" $CCFLAGS   > sig.h
        !          26578: attr scan
        !          26579: attr impl
        !          26580: done sig.h
        !          26581: prev include/namval.h
        !          26582: make include/error.h
        !          26583: attr perm
        !          26584: attr scan
        !          26585: attr impl
        !          26586: done include/error.h
        !          26587: prev /usr/include/ctype.h
        !          26588: done misc/error.c
        !          26589: prev misc/error.c
        !          26590: exec $CC $CCFLAGS -I. -Iinclude  -c misc/error.c
        !          26591: done error.o
        !          26592: make liberror.o
        !          26593: make misc/liberror.c
        !          26594: attr perm
        !          26595: attr scan
        !          26596: prev include/error.h
        !          26597: done misc/liberror.c
        !          26598: prev misc/liberror.c
        !          26599: exec $CC $CCFLAGS -Iinclude  -c misc/liberror.c
        !          26600: done liberror.o
        !          26601: make strerror.o
        !          26602: make string/strerror.c
        !          26603: attr perm
        !          26604: attr scan
        !          26605: prev FEATURE/strerror
        !          26606: done string/strerror.c
        !          26607: prev string/strerror.c
        !          26608: exec $CC $CCFLAGS -I. -Iinclude  -c string/strerror.c
        !          26609: done strerror.o
        !          26610: make strsignal.o
        !          26611: make string/strsignal.c
        !          26612: attr perm
        !          26613: attr scan
        !          26614: prev include/stdio.h
        !          26615: done string/strsignal.c
        !          26616: prev string/strsignal.c
        !          26617: exec $CC $CCFLAGS -Iinclude  -c string/strsignal.c
        !          26618: done strsignal.o
        !          26619: make fmtelapsed.o
        !          26620: make string/fmtelapsed.c
        !          26621: attr perm
        !          26622: attr scan
        !          26623: prev include/stdio.h
        !          26624: done string/fmtelapsed.c
        !          26625: prev string/fmtelapsed.c
        !          26626: exec $CC $CCFLAGS -Iinclude  -c string/fmtelapsed.c
        !          26627: done fmtelapsed.o
        !          26628: make fmtls.o
        !          26629: make string/fmtls.c
        !          26630: attr perm
        !          26631: attr scan
        !          26632: prev include/stdio.h
        !          26633: make include/tm.h
        !          26634: attr perm
        !          26635: attr scan
        !          26636: attr impl
        !          26637: done include/tm.h
        !          26638: prev include/ls.h
        !          26639: done string/fmtls.c
        !          26640: prev string/fmtls.c
        !          26641: exec $CC $CCFLAGS -I. -Iinclude  -c string/fmtls.c
        !          26642: done fmtls.o
        !          26643: make fmtmode.o
        !          26644: make string/fmtmode.c
        !          26645: attr perm
        !          26646: attr scan
        !          26647: prev string/modelib.h
        !          26648: done string/fmtmode.c
        !          26649: prev string/fmtmode.c
        !          26650: exec $CC $CCFLAGS -Istring  -c string/fmtmode.c
        !          26651: done fmtmode.o
        !          26652: make fmtperm.o
        !          26653: make string/fmtperm.c
        !          26654: attr perm
        !          26655: attr scan
        !          26656: prev include/ls.h
        !          26657: done string/fmtperm.c
        !          26658: prev string/fmtperm.c
        !          26659: exec $CC $CCFLAGS -I. -Iinclude  -c string/fmtperm.c
        !          26660: done fmtperm.o
        !          26661: make fmtuid.o
        !          26662: make string/fmtuid.c
        !          26663: attr perm
        !          26664: attr scan
        !          26665: make /usr/include/pwd.h
        !          26666: attr perm
        !          26667: attr scan
        !          26668: attr impl
        !          26669: done /usr/include/pwd.h
        !          26670: prev include/hash.h
        !          26671: prev include/stdio.h
        !          26672: done string/fmtuid.c
        !          26673: prev string/fmtuid.c
        !          26674: exec $CC $CCFLAGS -Iinclude  -c string/fmtuid.c
        !          26675: done fmtuid.o
        !          26676: make fmtgid.o
        !          26677: make string/fmtgid.c
        !          26678: attr perm
        !          26679: attr scan
        !          26680: make /usr/include/grp.h
        !          26681: attr perm
        !          26682: attr scan
        !          26683: attr impl
        !          26684: done /usr/include/grp.h
        !          26685: prev include/hash.h
        !          26686: prev include/stdio.h
        !          26687: done string/fmtgid.c
        !          26688: prev string/fmtgid.c
        !          26689: exec $CC $CCFLAGS -Iinclude  -c string/fmtgid.c
        !          26690: done fmtgid.o
        !          26691: make strelapsed.o
        !          26692: make string/strelapsed.c
        !          26693: attr perm
        !          26694: attr scan
        !          26695: prev /usr/include/ctype.h
        !          26696: done string/strelapsed.c
        !          26697: prev string/strelapsed.c
        !          26698: exec $CC $CCFLAGS   -c string/strelapsed.c
        !          26699: done strelapsed.o
        !          26700: make strperm.o
        !          26701: make string/strperm.c
        !          26702: attr perm
        !          26703: attr scan
        !          26704: prev include/ls.h
        !          26705: done string/strperm.c
        !          26706: prev string/strperm.c
        !          26707: exec $CC $CCFLAGS -I. -Iinclude  -c string/strperm.c
        !          26708: done strperm.o
        !          26709: make struid.o
        !          26710: make string/struid.c
        !          26711: attr perm
        !          26712: attr scan
        !          26713: prev /usr/include/pwd.h
        !          26714: prev include/hash.h
        !          26715: done string/struid.c
        !          26716: prev string/struid.c
        !          26717: exec $CC $CCFLAGS -Iinclude  -c string/struid.c
        !          26718: done struid.o
        !          26719: make strgid.o
        !          26720: make string/strgid.c
        !          26721: attr perm
        !          26722: attr scan
        !          26723: prev /usr/include/grp.h
        !          26724: prev /usr/include/pwd.h
        !          26725: prev include/hash.h
        !          26726: done string/strgid.c
        !          26727: prev string/strgid.c
        !          26728: exec $CC $CCFLAGS -Iinclude  -c string/strgid.c
        !          26729: done strgid.o
        !          26730: make stack.o
        !          26731: make misc/stack.c
        !          26732: attr perm
        !          26733: attr scan
        !          26734: make include/stack.h
        !          26735: attr perm
        !          26736: attr scan
        !          26737: attr impl
        !          26738: done include/stack.h
        !          26739: done misc/stack.c
        !          26740: prev misc/stack.c
        !          26741: exec $CC $CCFLAGS -Iinclude  -c misc/stack.c
        !          26742: done stack.o
        !          26743: make stak.o
        !          26744: make misc/stak.c
        !          26745: attr perm
        !          26746: attr scan
        !          26747: make include/stak.h
        !          26748: attr perm
        !          26749: attr scan
        !          26750: attr impl
        !          26751: done include/stak.h
        !          26752: done misc/stak.c
        !          26753: prev misc/stak.c
        !          26754: exec $CC $CCFLAGS -Iinclude  -c misc/stak.c
        !          26755: done stak.o
        !          26756: make memswap.o
        !          26757: make string/memswap.c
        !          26758: attr perm
        !          26759: attr scan
        !          26760: make include/swap.h
        !          26761: attr perm
        !          26762: attr scan
        !          26763: attr impl
        !          26764: done include/swap.h
        !          26765: done string/memswap.c
        !          26766: prev string/memswap.c
        !          26767: exec $CC $CCFLAGS -Iinclude  -c string/memswap.c
        !          26768: done memswap.o
        !          26769: make gethalf.o
        !          26770: make string/gethalf.c
        !          26771: attr perm
        !          26772: attr scan
        !          26773: prev limits.h
        !          26774: prev include/swap.h
        !          26775: done string/gethalf.c
        !          26776: prev string/gethalf.c
        !          26777: exec $CC $CCFLAGS -I. -Iinclude  -c string/gethalf.c
        !          26778: done gethalf.o
        !          26779: make getlong.o
        !          26780: make string/getlong.c
        !          26781: attr perm
        !          26782: attr scan
        !          26783: prev limits.h
        !          26784: prev include/swap.h
        !          26785: done string/getlong.c
        !          26786: prev string/getlong.c
        !          26787: exec $CC $CCFLAGS -I. -Iinclude  -c string/getlong.c
        !          26788: done getlong.o
        !          26789: make puthalf.o
        !          26790: make string/puthalf.c
        !          26791: attr perm
        !          26792: attr scan
        !          26793: prev limits.h
        !          26794: prev include/swap.h
        !          26795: done string/puthalf.c
        !          26796: prev string/puthalf.c
        !          26797: exec $CC $CCFLAGS -I. -Iinclude  -c string/puthalf.c
        !          26798: done puthalf.o
        !          26799: make putlong.o
        !          26800: make string/putlong.c
        !          26801: attr perm
        !          26802: attr scan
        !          26803: prev limits.h
        !          26804: prev include/swap.h
        !          26805: done string/putlong.c
        !          26806: prev string/putlong.c
        !          26807: exec $CC $CCFLAGS -I. -Iinclude  -c string/putlong.c
        !          26808: done putlong.o
        !          26809: make fgetline.o
        !          26810: make misc/fgetline.c
        !          26811: attr perm
        !          26812: attr scan
        !          26813: prev include/stdio.h
        !          26814: done misc/fgetline.c
        !          26815: prev misc/fgetline.c
        !          26816: exec $CC $CCFLAGS -Iinclude  -c misc/fgetline.c
        !          26817: done fgetline.o
        !          26818: make sigcrit.o
        !          26819: make misc/sigcrit.c
        !          26820: attr perm
        !          26821: attr scan
        !          26822: make FEATURE/sigsetmask
        !          26823: exec : generate local FEATURE information for sigsetmask
        !          26824: .... set -
        !          26825: .... if        test ! -d FEATURE
        !          26826: .... then      rm -rf FEATURE
        !          26827: ....   mkdir FEATURE
        !          26828: .... fi
        !          26829: .... {
        !          26830: .... echo '/* local info for sigsetmask */'
        !          26831: .... case "sigsetmask" in
        !          26832: .... *.*)      f=sigsetmask
        !          26833: ....   i=sigsetmask
        !          26834: ....   ;;
        !          26835: .... *)        f=sigsetmask
        !          26836: ....   i=sigsetmask
        !          26837: ....   echo "#undef $i
        !          26838: ....           int $i;" > x.${!-$$}.c
        !          26839: ....   cmd=:
        !          26840: ....   opt=
        !          26841: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          26842: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          26843: ....           then    opt=-Bstatic
        !          26844: ....           else    cmd=x.${!-$$}.x
        !          26845: ....           fi
        !          26846: ....   fi
        !          26847: ....   echo "#undef $i
        !          26848: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          26849: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          26850: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          26851: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          26852: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          26853: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          26854: ....           fi
        !          26855: ....   fi
        !          26856: ....   ;;
        !          26857: .... esac
        !          26858: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          26859: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          26860: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          26861: .... fi
        !          26862: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          26863: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          26864: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          26865: .... fi
        !          26866: .... for j in / /usr/
        !          26867: .... do        for i in bin etc ucb
        !          26868: ....   do      if      test -f $j$i/$f
        !          26869: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          26870: ....                   break 2
        !          26871: ....           fi
        !          26872: ....   done
        !          26873: .... done
        !          26874: .... } > FEATURE/sigsetmask
        !          26875: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          26876: attr scan
        !          26877: attr impl
        !          26878: done FEATURE/sigsetmask
        !          26879: prev sig.h
        !          26880: done misc/sigcrit.c
        !          26881: prev misc/sigcrit.c
        !          26882: exec $CC $CCFLAGS -I.  -c misc/sigcrit.c
        !          26883: done sigcrit.o
        !          26884: make sigunblock.o
        !          26885: make comp/sigunblock.c
        !          26886: attr perm
        !          26887: attr scan
        !          26888: prev sig.h
        !          26889: make FEATURE/sigunblock
        !          26890: exec : generate local FEATURE information for sigunblock
        !          26891: .... set -
        !          26892: .... if        test ! -d FEATURE
        !          26893: .... then      rm -rf FEATURE
        !          26894: ....   mkdir FEATURE
        !          26895: .... fi
        !          26896: .... {
        !          26897: .... echo '/* local info for sigunblock */'
        !          26898: .... case "sigunblock" in
        !          26899: .... *.*)      f=sigunblock
        !          26900: ....   i=sigunblock
        !          26901: ....   ;;
        !          26902: .... *)        f=sigunblock
        !          26903: ....   i=sigunblock
        !          26904: ....   echo "#undef $i
        !          26905: ....           int $i;" > x.${!-$$}.c
        !          26906: ....   cmd=:
        !          26907: ....   opt=
        !          26908: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          26909: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          26910: ....           then    opt=-Bstatic
        !          26911: ....           else    cmd=x.${!-$$}.x
        !          26912: ....           fi
        !          26913: ....   fi
        !          26914: ....   echo "#undef $i
        !          26915: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          26916: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          26917: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          26918: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          26919: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          26920: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          26921: ....           fi
        !          26922: ....   fi
        !          26923: ....   ;;
        !          26924: .... esac
        !          26925: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          26926: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          26927: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          26928: .... fi
        !          26929: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          26930: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          26931: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          26932: .... fi
        !          26933: .... for j in / /usr/
        !          26934: .... do        for i in bin etc ucb
        !          26935: ....   do      if      test -f $j$i/$f
        !          26936: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          26937: ....                   break 2
        !          26938: ....           fi
        !          26939: ....   done
        !          26940: .... done
        !          26941: .... } > FEATURE/sigunblock
        !          26942: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          26943: attr scan
        !          26944: attr impl
        !          26945: done FEATURE/sigunblock
        !          26946: done comp/sigunblock.c
        !          26947: prev comp/sigunblock.c
        !          26948: exec $CC $CCFLAGS -I.  -c comp/sigunblock.c
        !          26949: done sigunblock.o
        !          26950: make cmdopen.o
        !          26951: make misc/cmdopen.c
        !          26952: attr perm
        !          26953: attr scan
        !          26954: make misc/cmdlib.h
        !          26955: attr perm
        !          26956: attr scan
        !          26957: attr impl
        !          26958: prev /usr/include/errno.h
        !          26959: prev include/stdio.h
        !          26960: prev limits.h
        !          26961: done misc/cmdlib.h
        !          26962: done misc/cmdopen.c
        !          26963: prev misc/cmdopen.c
        !          26964: exec $CC $CCFLAGS -I. -Imisc -Iinclude  -c misc/cmdopen.c
        !          26965: done cmdopen.o
        !          26966: make cmdclose.o
        !          26967: make misc/cmdclose.c
        !          26968: attr perm
        !          26969: attr scan
        !          26970: prev misc/cmdlib.h
        !          26971: done misc/cmdclose.c
        !          26972: prev misc/cmdclose.c
        !          26973: exec $CC $CCFLAGS -I. -Imisc -Iinclude  -c misc/cmdclose.c
        !          26974: done cmdclose.o
        !          26975: make cmdrun.o
        !          26976: make misc/cmdrun.c
        !          26977: attr perm
        !          26978: attr scan
        !          26979: done misc/cmdrun.c
        !          26980: prev misc/cmdrun.c
        !          26981: exec $CC $CCFLAGS   -c misc/cmdrun.c
        !          26982: done cmdrun.o
        !          26983: make cmdwait.o
        !          26984: make misc/cmdwait.c
        !          26985: attr perm
        !          26986: attr scan
        !          26987: prev misc/cmdlib.h
        !          26988: done misc/cmdwait.c
        !          26989: prev misc/cmdwait.c
        !          26990: exec $CC $CCFLAGS -I. -Imisc -Iinclude  -c misc/cmdwait.c
        !          26991: done cmdwait.o
        !          26992: make cmdkill.o
        !          26993: make misc/cmdkill.c
        !          26994: attr perm
        !          26995: attr scan
        !          26996: prev misc/cmdlib.h
        !          26997: done misc/cmdkill.c
        !          26998: prev misc/cmdkill.c
        !          26999: exec $CC $CCFLAGS -I. -Imisc -Iinclude  -c misc/cmdkill.c
        !          27000: done cmdkill.o
        !          27001: make recomp.o
        !          27002: make re/recomp.c
        !          27003: attr perm
        !          27004: attr scan
        !          27005: make re/relib.h
        !          27006: attr perm
        !          27007: attr scan
        !          27008: attr impl
        !          27009: prev limits.h
        !          27010: make include/re.h
        !          27011: attr perm
        !          27012: attr scan
        !          27013: attr impl
        !          27014: done include/re.h
        !          27015: done re/relib.h
        !          27016: done re/recomp.c
        !          27017: prev re/recomp.c
        !          27018: exec $CC $CCFLAGS -I. -Ire -Iinclude "$DEBUG" -c re/recomp.c
        !          27019: done recomp.o
        !          27020: make reerror.o
        !          27021: make re/reerror.c
        !          27022: attr perm
        !          27023: attr scan
        !          27024: prev include/error.h
        !          27025: prev include/re.h
        !          27026: done re/reerror.c
        !          27027: prev re/reerror.c
        !          27028: exec $CC $CCFLAGS -Iinclude  -c re/reerror.c
        !          27029: done reerror.o
        !          27030: make reexec.o
        !          27031: make re/reexec.c
        !          27032: attr perm
        !          27033: attr scan
        !          27034: prev /usr/include/ctype.h
        !          27035: prev re/relib.h
        !          27036: done re/reexec.c
        !          27037: prev re/reexec.c
        !          27038: exec $CC $CCFLAGS -I. -Ire -Iinclude "$DEBUG" -c re/reexec.c
        !          27039: done reexec.o
        !          27040: make resub.o
        !          27041: make re/resub.c
        !          27042: attr perm
        !          27043: attr scan
        !          27044: prev /usr/include/ctype.h
        !          27045: prev re/relib.h
        !          27046: done re/resub.c
        !          27047: prev re/resub.c
        !          27048: exec $CC $CCFLAGS -I. -Ire -Iinclude  -c re/resub.c
        !          27049: done resub.o
        !          27050: make tmdate.o
        !          27051: make tm/tmdate.c
        !          27052: attr perm
        !          27053: attr scan
        !          27054: prev /usr/include/ctype.h
        !          27055: prev include/tm.h
        !          27056: done tm/tmdate.c
        !          27057: prev tm/tmdate.c
        !          27058: exec $CC $CCFLAGS -Iinclude  -c tm/tmdate.c
        !          27059: done tmdate.o
        !          27060: make tmfix.o
        !          27061: make tm/tmfix.c
        !          27062: attr perm
        !          27063: attr scan
        !          27064: prev include/tm.h
        !          27065: done tm/tmfix.c
        !          27066: prev tm/tmfix.c
        !          27067: exec $CC $CCFLAGS -Iinclude  -c tm/tmfix.c
        !          27068: done tmfix.o
        !          27069: make tmform.o
        !          27070: make tm/tmform.c
        !          27071: attr perm
        !          27072: attr scan
        !          27073: prev include/stdio.h
        !          27074: prev include/tm.h
        !          27075: done tm/tmform.c
        !          27076: prev tm/tmform.c
        !          27077: exec $CC $CCFLAGS -Iinclude  -c tm/tmform.c
        !          27078: done tmform.o
        !          27079: make tmgoff.o
        !          27080: make tm/tmgoff.c
        !          27081: attr perm
        !          27082: attr scan
        !          27083: prev /usr/include/ctype.h
        !          27084: prev include/tm.h
        !          27085: done tm/tmgoff.c
        !          27086: prev tm/tmgoff.c
        !          27087: exec $CC $CCFLAGS -Iinclude  -c tm/tmgoff.c
        !          27088: done tmgoff.o
        !          27089: make tminit.o
        !          27090: make tm/tminit.c
        !          27091: attr perm
        !          27092: attr scan
        !          27093: prev include/namval.h
        !          27094: prev /usr/include/ctype.h
        !          27095: prev include/tm.h
        !          27096: done tm/tminit.c
        !          27097: prev tm/tminit.c
        !          27098: exec $CC $CCFLAGS -Iinclude  -c tm/tminit.c
        !          27099: done tminit.o
        !          27100: make tmleap.o
        !          27101: make tm/tmleap.c
        !          27102: attr perm
        !          27103: attr scan
        !          27104: prev include/tm.h
        !          27105: done tm/tmleap.c
        !          27106: prev tm/tmleap.c
        !          27107: exec $CC $CCFLAGS -Iinclude  -c tm/tmleap.c
        !          27108: done tmleap.o
        !          27109: make tmlex.o
        !          27110: make tm/tmlex.c
        !          27111: attr perm
        !          27112: attr scan
        !          27113: prev /usr/include/ctype.h
        !          27114: prev include/tm.h
        !          27115: done tm/tmlex.c
        !          27116: prev tm/tmlex.c
        !          27117: exec $CC $CCFLAGS -Iinclude  -c tm/tmlex.c
        !          27118: done tmlex.o
        !          27119: make tmmake.o
        !          27120: make tm/tmmake.c
        !          27121: attr perm
        !          27122: attr scan
        !          27123: prev include/tm.h
        !          27124: done tm/tmmake.c
        !          27125: prev tm/tmmake.c
        !          27126: exec $CC $CCFLAGS -Iinclude  -c tm/tmmake.c
        !          27127: done tmmake.o
        !          27128: make tmpoff.o
        !          27129: make tm/tmpoff.c
        !          27130: attr perm
        !          27131: attr scan
        !          27132: prev include/stdio.h
        !          27133: prev include/tm.h
        !          27134: done tm/tmpoff.c
        !          27135: prev tm/tmpoff.c
        !          27136: exec $CC $CCFLAGS -Iinclude  -c tm/tmpoff.c
        !          27137: done tmpoff.o
        !          27138: make tmtime.o
        !          27139: make tm/tmtime.c
        !          27140: attr perm
        !          27141: attr scan
        !          27142: prev include/tm.h
        !          27143: done tm/tmtime.c
        !          27144: prev tm/tmtime.c
        !          27145: exec $CC $CCFLAGS -Iinclude  -c tm/tmtime.c
        !          27146: done tmtime.o
        !          27147: make tmtype.o
        !          27148: make tm/tmtype.c
        !          27149: attr perm
        !          27150: attr scan
        !          27151: prev include/tm.h
        !          27152: done tm/tmtype.c
        !          27153: prev tm/tmtype.c
        !          27154: exec $CC $CCFLAGS -Iinclude  -c tm/tmtype.c
        !          27155: done tmtype.o
        !          27156: make tmword.o
        !          27157: make tm/tmword.c
        !          27158: attr perm
        !          27159: attr scan
        !          27160: prev /usr/include/ctype.h
        !          27161: prev include/tm.h
        !          27162: done tm/tmword.c
        !          27163: prev tm/tmword.c
        !          27164: exec $CC $CCFLAGS -Iinclude  -c tm/tmword.c
        !          27165: done tmword.o
        !          27166: make tmzone.o
        !          27167: make tm/tmzone.c
        !          27168: attr perm
        !          27169: attr scan
        !          27170: prev include/tm.h
        !          27171: done tm/tmzone.c
        !          27172: prev tm/tmzone.c
        !          27173: exec $CC $CCFLAGS -Iinclude  -c tm/tmzone.c
        !          27174: done tmzone.o
        !          27175: make vecargs.o
        !          27176: make vec/vecargs.c
        !          27177: attr perm
        !          27178: attr scan
        !          27179: prev /usr/include/ctype.h
        !          27180: done vec/vecargs.c
        !          27181: prev vec/vecargs.c
        !          27182: exec $CC $CCFLAGS   -c vec/vecargs.c
        !          27183: done vecargs.o
        !          27184: make vecfile.o
        !          27185: make vec/vecfile.c
        !          27186: attr perm
        !          27187: attr scan
        !          27188: prev /usr/include/sys/stat.h
        !          27189: prev /usr/include/sys/types.h
        !          27190: done vec/vecfile.c
        !          27191: prev vec/vecfile.c
        !          27192: exec $CC $CCFLAGS   -c vec/vecfile.c
        !          27193: done vecfile.o
        !          27194: make vecfree.o
        !          27195: make vec/vecfree.c
        !          27196: attr perm
        !          27197: attr scan
        !          27198: done vec/vecfree.c
        !          27199: prev vec/vecfree.c
        !          27200: exec $CC $CCFLAGS   -c vec/vecfree.c
        !          27201: done vecfree.o
        !          27202: make vecload.o
        !          27203: make vec/vecload.c
        !          27204: attr perm
        !          27205: attr scan
        !          27206: done vec/vecload.c
        !          27207: prev vec/vecload.c
        !          27208: exec $CC $CCFLAGS   -c vec/vecload.c
        !          27209: done vecload.o
        !          27210: make vecstring.o
        !          27211: make vec/vecstring.c
        !          27212: attr perm
        !          27213: attr scan
        !          27214: done vec/vecstring.c
        !          27215: prev vec/vecstring.c
        !          27216: exec $CC $CCFLAGS   -c vec/vecstring.c
        !          27217: done vecstring.o
        !          27218: make getsymlink.o
        !          27219: make misc/getsymlink.c
        !          27220: attr perm
        !          27221: attr scan
        !          27222: make misc/univlib.h
        !          27223: attr perm
        !          27224: attr scan
        !          27225: attr impl
        !          27226: prev /usr/include/errno.h
        !          27227: prev limits.h
        !          27228: make FEATURE/universe
        !          27229: exec : generate local FEATURE information for universe
        !          27230: .... set -
        !          27231: .... if        test ! -d FEATURE
        !          27232: .... then      rm -rf FEATURE
        !          27233: ....   mkdir FEATURE
        !          27234: .... fi
        !          27235: .... {
        !          27236: .... echo '/* local info for universe */'
        !          27237: .... case "universe" in
        !          27238: .... *.*)      f=universe
        !          27239: ....   i=universe
        !          27240: ....   ;;
        !          27241: .... *)        f=universe
        !          27242: ....   i=universe
        !          27243: ....   echo "#undef $i
        !          27244: ....           int $i;" > x.${!-$$}.c
        !          27245: ....   cmd=:
        !          27246: ....   opt=
        !          27247: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          27248: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          27249: ....           then    opt=-Bstatic
        !          27250: ....           else    cmd=x.${!-$$}.x
        !          27251: ....           fi
        !          27252: ....   fi
        !          27253: ....   echo "#undef $i
        !          27254: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          27255: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          27256: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          27257: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          27258: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          27259: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          27260: ....           fi
        !          27261: ....   fi
        !          27262: ....   ;;
        !          27263: .... esac
        !          27264: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          27265: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          27266: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          27267: .... fi
        !          27268: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          27269: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          27270: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          27271: .... fi
        !          27272: .... for j in / /usr/
        !          27273: .... do        for i in bin etc ucb
        !          27274: ....   do      if      test -f $j$i/$f
        !          27275: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          27276: ....                   break 2
        !          27277: ....           fi
        !          27278: ....   done
        !          27279: .... done
        !          27280: .... } > FEATURE/universe
        !          27281: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          27282: attr scan
        !          27283: attr impl
        !          27284: done FEATURE/universe
        !          27285: done misc/univlib.h
        !          27286: done misc/getsymlink.c
        !          27287: prev misc/getsymlink.c
        !          27288: exec $CC $CCFLAGS -I. -Imisc -Iinclude  -c misc/getsymlink.c
        !          27289: done getsymlink.o
        !          27290: make putsymlink.o
        !          27291: make misc/putsymlink.c
        !          27292: attr perm
        !          27293: attr scan
        !          27294: prev misc/univlib.h
        !          27295: done misc/putsymlink.c
        !          27296: prev misc/putsymlink.c
        !          27297: exec $CC $CCFLAGS -I. -Imisc -Iinclude  -c misc/putsymlink.c
        !          27298: done putsymlink.o
        !          27299: make univdata.o
        !          27300: make misc/univdata.c
        !          27301: attr perm
        !          27302: attr scan
        !          27303: prev misc/univlib.h
        !          27304: done misc/univdata.c
        !          27305: prev misc/univdata.c
        !          27306: exec $CC $CCFLAGS -I. -Imisc -Iinclude  -c misc/univdata.c
        !          27307: done univdata.o
        !          27308: make getuniv.o
        !          27309: make misc/getuniv.c
        !          27310: attr perm
        !          27311: attr scan
        !          27312: prev misc/univlib.h
        !          27313: done misc/getuniv.c
        !          27314: prev misc/getuniv.c
        !          27315: exec $CC $CCFLAGS -I. -Imisc -Iinclude  -c misc/getuniv.c
        !          27316: done getuniv.o
        !          27317: make setuniv.o
        !          27318: make misc/setuniv.c
        !          27319: attr perm
        !          27320: attr scan
        !          27321: prev misc/univlib.h
        !          27322: done misc/setuniv.c
        !          27323: prev misc/setuniv.c
        !          27324: exec $CC $CCFLAGS -I. -Imisc -Iinclude  -c misc/setuniv.c
        !          27325: done setuniv.o
        !          27326: make winsize.o
        !          27327: make port/winsize.c
        !          27328: attr perm
        !          27329: attr scan
        !          27330: make FEATURE/jioctl
        !          27331: exec : generate local FEATURE information for jioctl
        !          27332: .... set -
        !          27333: .... if        test ! -d FEATURE
        !          27334: .... then      rm -rf FEATURE
        !          27335: ....   mkdir FEATURE
        !          27336: .... fi
        !          27337: .... {
        !          27338: .... echo '/* local info for jioctl */'
        !          27339: .... case "jioctl" in
        !          27340: .... *.*)      f=jioctl
        !          27341: ....   i=jioctl
        !          27342: ....   ;;
        !          27343: .... *)        f=jioctl
        !          27344: ....   i=jioctl
        !          27345: ....   echo "#undef $i
        !          27346: ....           int $i;" > x.${!-$$}.c
        !          27347: ....   cmd=:
        !          27348: ....   opt=
        !          27349: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          27350: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          27351: ....           then    opt=-Bstatic
        !          27352: ....           else    cmd=x.${!-$$}.x
        !          27353: ....           fi
        !          27354: ....   fi
        !          27355: ....   echo "#undef $i
        !          27356: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          27357: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          27358: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          27359: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          27360: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          27361: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          27362: ....           fi
        !          27363: ....   fi
        !          27364: ....   ;;
        !          27365: .... esac
        !          27366: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          27367: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          27368: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          27369: .... fi
        !          27370: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          27371: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          27372: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          27373: .... fi
        !          27374: .... for j in / /usr/
        !          27375: .... do        for i in bin etc ucb
        !          27376: ....   do      if      test -f $j$i/$f
        !          27377: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          27378: ....                   break 2
        !          27379: ....           fi
        !          27380: ....   done
        !          27381: .... done
        !          27382: .... } > FEATURE/jioctl
        !          27383: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          27384: attr scan
        !          27385: attr impl
        !          27386: done FEATURE/jioctl
        !          27387: make ttyinfo.h
        !          27388: prev mkhdr
        !          27389: exec mkhdr ttyinfo "" "$CC" $CCFLAGS   > ttyinfo.h
        !          27390: attr scan
        !          27391: attr impl
        !          27392: done ttyinfo.h
        !          27393: done port/winsize.c
        !          27394: prev port/winsize.c
        !          27395: exec $CC $CCFLAGS -I.  -c port/winsize.c
        !          27396: done winsize.o
        !          27397: make fclex.o
        !          27398: make port/fclex.c
        !          27399: attr perm
        !          27400: attr scan
        !          27401: make /usr/include/fcntl.h
        !          27402: attr perm
        !          27403: attr scan
        !          27404: attr impl
        !          27405: done /usr/include/fcntl.h
        !          27406: prev /usr/include/errno.h
        !          27407: done port/fclex.c
        !          27408: prev port/fclex.c
        !          27409: exec $CC $CCFLAGS   -c port/fclex.c
        !          27410: done fclex.o
        !          27411: make sigdata.o
        !          27412: make port/sigdata.c
        !          27413: attr perm
        !          27414: attr scan
        !          27415: make sigdata.h
        !          27416: prev mkhdr
        !          27417: prev genhdr
        !          27418: exec mkhdr sigdata " genhdr" "$CC" $CCFLAGS   > sigdata.h
        !          27419: attr scan
        !          27420: attr impl
        !          27421: done sigdata.h
        !          27422: done port/sigdata.c
        !          27423: prev port/sigdata.c
        !          27424: exec $CC $CCFLAGS -I.  -c port/sigdata.c
        !          27425: done sigdata.o
        !          27426: make touch.o
        !          27427: make port/touch.c
        !          27428: attr perm
        !          27429: attr scan
        !          27430: make FEATURE/utime
        !          27431: exec : generate local FEATURE information for utime
        !          27432: .... set -
        !          27433: .... if        test ! -d FEATURE
        !          27434: .... then      rm -rf FEATURE
        !          27435: ....   mkdir FEATURE
        !          27436: .... fi
        !          27437: .... {
        !          27438: .... echo '/* local info for utime */'
        !          27439: .... case "utime" in
        !          27440: .... *.*)      f=utime
        !          27441: ....   i=utime
        !          27442: ....   ;;
        !          27443: .... *)        f=utime
        !          27444: ....   i=utime
        !          27445: ....   echo "#undef $i
        !          27446: ....           int $i;" > x.${!-$$}.c
        !          27447: ....   cmd=:
        !          27448: ....   opt=
        !          27449: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          27450: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          27451: ....           then    opt=-Bstatic
        !          27452: ....           else    cmd=x.${!-$$}.x
        !          27453: ....           fi
        !          27454: ....   fi
        !          27455: ....   echo "#undef $i
        !          27456: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          27457: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          27458: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          27459: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          27460: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          27461: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          27462: ....           fi
        !          27463: ....   fi
        !          27464: ....   ;;
        !          27465: .... esac
        !          27466: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          27467: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          27468: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          27469: .... fi
        !          27470: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          27471: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          27472: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          27473: .... fi
        !          27474: .... for j in / /usr/
        !          27475: .... do        for i in bin etc ucb
        !          27476: ....   do      if      test -f $j$i/$f
        !          27477: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          27478: ....                   break 2
        !          27479: ....           fi
        !          27480: ....   done
        !          27481: .... done
        !          27482: .... } > FEATURE/utime
        !          27483: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          27484: attr scan
        !          27485: attr impl
        !          27486: done FEATURE/utime
        !          27487: prev /usr/include/errno.h
        !          27488: prev /usr/include/sys/stat.h
        !          27489: prev /usr/include/sys/types.h
        !          27490: done port/touch.c
        !          27491: prev port/touch.c
        !          27492: exec $CC $CCFLAGS -I.  -c port/touch.c
        !          27493: done touch.o
        !          27494: make lpstat.o
        !          27495: make misc/lpstat.c
        !          27496: attr perm
        !          27497: attr scan
        !          27498: prev /usr/include/sys/stat.h
        !          27499: prev /usr/include/sys/types.h
        !          27500: done misc/lpstat.c
        !          27501: prev misc/lpstat.c
        !          27502: exec $CC $CCFLAGS   -c misc/lpstat.c
        !          27503: done lpstat.o
        !          27504: make memcmp.o
        !          27505: make comp/memcmp.c
        !          27506: attr perm
        !          27507: attr scan
        !          27508: make FEATURE/memcmp
        !          27509: exec : generate local FEATURE information for memcmp
        !          27510: .... set -
        !          27511: .... if        test ! -d FEATURE
        !          27512: .... then      rm -rf FEATURE
        !          27513: ....   mkdir FEATURE
        !          27514: .... fi
        !          27515: .... {
        !          27516: .... echo '/* local info for memcmp */'
        !          27517: .... case "memcmp" in
        !          27518: .... *.*)      f=memcmp
        !          27519: ....   i=memcmp
        !          27520: ....   ;;
        !          27521: .... *)        f=memcmp
        !          27522: ....   i=memcmp
        !          27523: ....   echo "#undef $i
        !          27524: ....           int $i;" > x.${!-$$}.c
        !          27525: ....   cmd=:
        !          27526: ....   opt=
        !          27527: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          27528: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          27529: ....           then    opt=-Bstatic
        !          27530: ....           else    cmd=x.${!-$$}.x
        !          27531: ....           fi
        !          27532: ....   fi
        !          27533: ....   echo "#undef $i
        !          27534: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          27535: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          27536: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          27537: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          27538: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          27539: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          27540: ....           fi
        !          27541: ....   fi
        !          27542: ....   ;;
        !          27543: .... esac
        !          27544: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          27545: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          27546: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          27547: .... fi
        !          27548: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          27549: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          27550: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          27551: .... fi
        !          27552: .... for j in / /usr/
        !          27553: .... do        for i in bin etc ucb
        !          27554: ....   do      if      test -f $j$i/$f
        !          27555: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          27556: ....                   break 2
        !          27557: ....           fi
        !          27558: ....   done
        !          27559: .... done
        !          27560: .... } > FEATURE/memcmp
        !          27561: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          27562: attr scan
        !          27563: attr impl
        !          27564: done FEATURE/memcmp
        !          27565: done comp/memcmp.c
        !          27566: prev comp/memcmp.c
        !          27567: exec $CC $CCFLAGS -I.  -c comp/memcmp.c
        !          27568: done memcmp.o
        !          27569: make memcpy.o
        !          27570: make comp/memcpy.c
        !          27571: attr perm
        !          27572: attr scan
        !          27573: make FEATURE/bcopy
        !          27574: done FEATURE/bcopy
        !          27575: make FEATURE/memcpy
        !          27576: exec : generate local FEATURE information for memcpy
        !          27577: .... set -
        !          27578: .... if        test ! -d FEATURE
        !          27579: .... then      rm -rf FEATURE
        !          27580: ....   mkdir FEATURE
        !          27581: .... fi
        !          27582: .... {
        !          27583: .... echo '/* local info for memcpy */'
        !          27584: .... case "memcpy" in
        !          27585: .... *.*)      f=memcpy
        !          27586: ....   i=memcpy
        !          27587: ....   ;;
        !          27588: .... *)        f=memcpy
        !          27589: ....   i=memcpy
        !          27590: ....   echo "#undef $i
        !          27591: ....           int $i;" > x.${!-$$}.c
        !          27592: ....   cmd=:
        !          27593: ....   opt=
        !          27594: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          27595: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          27596: ....           then    opt=-Bstatic
        !          27597: ....           else    cmd=x.${!-$$}.x
        !          27598: ....           fi
        !          27599: ....   fi
        !          27600: ....   echo "#undef $i
        !          27601: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          27602: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          27603: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          27604: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          27605: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          27606: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          27607: ....           fi
        !          27608: ....   fi
        !          27609: ....   ;;
        !          27610: .... esac
        !          27611: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          27612: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          27613: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          27614: .... fi
        !          27615: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          27616: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          27617: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          27618: .... fi
        !          27619: .... for j in / /usr/
        !          27620: .... do        for i in bin etc ucb
        !          27621: ....   do      if      test -f $j$i/$f
        !          27622: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          27623: ....                   break 2
        !          27624: ....           fi
        !          27625: ....   done
        !          27626: .... done
        !          27627: .... } > FEATURE/memcpy
        !          27628: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          27629: attr scan
        !          27630: attr impl
        !          27631: done FEATURE/memcpy
        !          27632: done comp/memcpy.c
        !          27633: prev comp/memcpy.c
        !          27634: exec $CC $CCFLAGS -I.  -c comp/memcpy.c
        !          27635: done memcpy.o
        !          27636: make memdup.o
        !          27637: make string/memdup.c
        !          27638: attr perm
        !          27639: attr scan
        !          27640: make FEATURE/memdup
        !          27641: exec : generate local FEATURE information for memdup
        !          27642: .... set -
        !          27643: .... if        test ! -d FEATURE
        !          27644: .... then      rm -rf FEATURE
        !          27645: ....   mkdir FEATURE
        !          27646: .... fi
        !          27647: .... {
        !          27648: .... echo '/* local info for memdup */'
        !          27649: .... case "memdup" in
        !          27650: .... *.*)      f=memdup
        !          27651: ....   i=memdup
        !          27652: ....   ;;
        !          27653: .... *)        f=memdup
        !          27654: ....   i=memdup
        !          27655: ....   echo "#undef $i
        !          27656: ....           int $i;" > x.${!-$$}.c
        !          27657: ....   cmd=:
        !          27658: ....   opt=
        !          27659: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          27660: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          27661: ....           then    opt=-Bstatic
        !          27662: ....           else    cmd=x.${!-$$}.x
        !          27663: ....           fi
        !          27664: ....   fi
        !          27665: ....   echo "#undef $i
        !          27666: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          27667: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          27668: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          27669: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          27670: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          27671: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          27672: ....           fi
        !          27673: ....   fi
        !          27674: ....   ;;
        !          27675: .... esac
        !          27676: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          27677: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          27678: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          27679: .... fi
        !          27680: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          27681: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          27682: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          27683: .... fi
        !          27684: .... for j in / /usr/
        !          27685: .... do        for i in bin etc ucb
        !          27686: ....   do      if      test -f $j$i/$f
        !          27687: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          27688: ....                   break 2
        !          27689: ....           fi
        !          27690: ....   done
        !          27691: .... done
        !          27692: .... } > FEATURE/memdup
        !          27693: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          27694: attr scan
        !          27695: attr impl
        !          27696: done FEATURE/memdup
        !          27697: done string/memdup.c
        !          27698: prev string/memdup.c
        !          27699: exec $CC $CCFLAGS -I.  -c string/memdup.c
        !          27700: done memdup.o
        !          27701: make memset.o
        !          27702: make comp/memset.c
        !          27703: attr perm
        !          27704: attr scan
        !          27705: make FEATURE/memset
        !          27706: exec : generate local FEATURE information for memset
        !          27707: .... set -
        !          27708: .... if        test ! -d FEATURE
        !          27709: .... then      rm -rf FEATURE
        !          27710: ....   mkdir FEATURE
        !          27711: .... fi
        !          27712: .... {
        !          27713: .... echo '/* local info for memset */'
        !          27714: .... case "memset" in
        !          27715: .... *.*)      f=memset
        !          27716: ....   i=memset
        !          27717: ....   ;;
        !          27718: .... *)        f=memset
        !          27719: ....   i=memset
        !          27720: ....   echo "#undef $i
        !          27721: ....           int $i;" > x.${!-$$}.c
        !          27722: ....   cmd=:
        !          27723: ....   opt=
        !          27724: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          27725: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          27726: ....           then    opt=-Bstatic
        !          27727: ....           else    cmd=x.${!-$$}.x
        !          27728: ....           fi
        !          27729: ....   fi
        !          27730: ....   echo "#undef $i
        !          27731: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          27732: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          27733: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          27734: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          27735: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          27736: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          27737: ....           fi
        !          27738: ....   fi
        !          27739: ....   ;;
        !          27740: .... esac
        !          27741: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          27742: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          27743: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          27744: .... fi
        !          27745: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          27746: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          27747: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          27748: .... fi
        !          27749: .... for j in / /usr/
        !          27750: .... do        for i in bin etc ucb
        !          27751: ....   do      if      test -f $j$i/$f
        !          27752: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          27753: ....                   break 2
        !          27754: ....           fi
        !          27755: ....   done
        !          27756: .... done
        !          27757: .... } > FEATURE/memset
        !          27758: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          27759: attr scan
        !          27760: attr impl
        !          27761: done FEATURE/memset
        !          27762: done comp/memset.c
        !          27763: prev comp/memset.c
        !          27764: exec $CC $CCFLAGS -I.  -c comp/memset.c
        !          27765: done memset.o
        !          27766: make mkdir.o
        !          27767: make comp/mkdir.c
        !          27768: attr perm
        !          27769: attr scan
        !          27770: make FEATURE/mkdir
        !          27771: exec : generate local FEATURE information for mkdir
        !          27772: .... set -
        !          27773: .... if        test ! -d FEATURE
        !          27774: .... then      rm -rf FEATURE
        !          27775: ....   mkdir FEATURE
        !          27776: .... fi
        !          27777: .... {
        !          27778: .... echo '/* local info for mkdir */'
        !          27779: .... case "mkdir" in
        !          27780: .... *.*)      f=mkdir
        !          27781: ....   i=mkdir
        !          27782: ....   ;;
        !          27783: .... *)        f=mkdir
        !          27784: ....   i=mkdir
        !          27785: ....   echo "#undef $i
        !          27786: ....           int $i;" > x.${!-$$}.c
        !          27787: ....   cmd=:
        !          27788: ....   opt=
        !          27789: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          27790: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          27791: ....           then    opt=-Bstatic
        !          27792: ....           else    cmd=x.${!-$$}.x
        !          27793: ....           fi
        !          27794: ....   fi
        !          27795: ....   echo "#undef $i
        !          27796: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          27797: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          27798: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          27799: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          27800: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          27801: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          27802: ....           fi
        !          27803: ....   fi
        !          27804: ....   ;;
        !          27805: .... esac
        !          27806: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          27807: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          27808: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          27809: .... fi
        !          27810: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          27811: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          27812: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          27813: .... fi
        !          27814: .... for j in / /usr/
        !          27815: .... do        for i in bin etc ucb
        !          27816: ....   do      if      test -f $j$i/$f
        !          27817: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          27818: ....                   break 2
        !          27819: ....           fi
        !          27820: ....   done
        !          27821: .... done
        !          27822: .... } > FEATURE/mkdir
        !          27823: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          27824: attr scan
        !          27825: attr impl
        !          27826: done FEATURE/mkdir
        !          27827: done comp/mkdir.c
        !          27828: prev comp/mkdir.c
        !          27829: exec $CC $CCFLAGS -I.  -c comp/mkdir.c
        !          27830: done mkdir.o
        !          27831: make rmdir.o
        !          27832: make comp/rmdir.c
        !          27833: attr perm
        !          27834: attr scan
        !          27835: make FEATURE/rmdir
        !          27836: exec : generate local FEATURE information for rmdir
        !          27837: .... set -
        !          27838: .... if        test ! -d FEATURE
        !          27839: .... then      rm -rf FEATURE
        !          27840: ....   mkdir FEATURE
        !          27841: .... fi
        !          27842: .... {
        !          27843: .... echo '/* local info for rmdir */'
        !          27844: .... case "rmdir" in
        !          27845: .... *.*)      f=rmdir
        !          27846: ....   i=rmdir
        !          27847: ....   ;;
        !          27848: .... *)        f=rmdir
        !          27849: ....   i=rmdir
        !          27850: ....   echo "#undef $i
        !          27851: ....           int $i;" > x.${!-$$}.c
        !          27852: ....   cmd=:
        !          27853: ....   opt=
        !          27854: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          27855: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          27856: ....           then    opt=-Bstatic
        !          27857: ....           else    cmd=x.${!-$$}.x
        !          27858: ....           fi
        !          27859: ....   fi
        !          27860: ....   echo "#undef $i
        !          27861: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          27862: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          27863: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          27864: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          27865: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          27866: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          27867: ....           fi
        !          27868: ....   fi
        !          27869: ....   ;;
        !          27870: .... esac
        !          27871: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          27872: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          27873: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          27874: .... fi
        !          27875: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          27876: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          27877: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          27878: .... fi
        !          27879: .... for j in / /usr/
        !          27880: .... do        for i in bin etc ucb
        !          27881: ....   do      if      test -f $j$i/$f
        !          27882: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          27883: ....                   break 2
        !          27884: ....           fi
        !          27885: ....   done
        !          27886: .... done
        !          27887: .... } > FEATURE/rmdir
        !          27888: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          27889: attr scan
        !          27890: attr impl
        !          27891: done FEATURE/rmdir
        !          27892: done comp/rmdir.c
        !          27893: prev comp/rmdir.c
        !          27894: exec $CC $CCFLAGS -I.  -c comp/rmdir.c
        !          27895: done rmdir.o
        !          27896: make remove.o
        !          27897: make comp/remove.c
        !          27898: attr perm
        !          27899: attr scan
        !          27900: make FEATURE/remove
        !          27901: exec : generate local FEATURE information for remove
        !          27902: .... set -
        !          27903: .... if        test ! -d FEATURE
        !          27904: .... then      rm -rf FEATURE
        !          27905: ....   mkdir FEATURE
        !          27906: .... fi
        !          27907: .... {
        !          27908: .... echo '/* local info for remove */'
        !          27909: .... case "remove" in
        !          27910: .... *.*)      f=remove
        !          27911: ....   i=remove
        !          27912: ....   ;;
        !          27913: .... *)        f=remove
        !          27914: ....   i=remove
        !          27915: ....   echo "#undef $i
        !          27916: ....           int $i;" > x.${!-$$}.c
        !          27917: ....   cmd=:
        !          27918: ....   opt=
        !          27919: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          27920: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          27921: ....           then    opt=-Bstatic
        !          27922: ....           else    cmd=x.${!-$$}.x
        !          27923: ....           fi
        !          27924: ....   fi
        !          27925: ....   echo "#undef $i
        !          27926: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          27927: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          27928: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          27929: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          27930: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          27931: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          27932: ....           fi
        !          27933: ....   fi
        !          27934: ....   ;;
        !          27935: .... esac
        !          27936: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          27937: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          27938: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          27939: .... fi
        !          27940: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          27941: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          27942: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          27943: .... fi
        !          27944: .... for j in / /usr/
        !          27945: .... do        for i in bin etc ucb
        !          27946: ....   do      if      test -f $j$i/$f
        !          27947: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          27948: ....                   break 2
        !          27949: ....           fi
        !          27950: ....   done
        !          27951: .... done
        !          27952: .... } > FEATURE/remove
        !          27953: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          27954: attr scan
        !          27955: attr impl
        !          27956: done FEATURE/remove
        !          27957: done comp/remove.c
        !          27958: prev comp/remove.c
        !          27959: exec $CC $CCFLAGS -I.  -c comp/remove.c
        !          27960: done remove.o
        !          27961: make rename.o
        !          27962: make comp/rename.c
        !          27963: attr perm
        !          27964: attr scan
        !          27965: make FEATURE/rename
        !          27966: exec : generate local FEATURE information for rename
        !          27967: .... set -
        !          27968: .... if        test ! -d FEATURE
        !          27969: .... then      rm -rf FEATURE
        !          27970: ....   mkdir FEATURE
        !          27971: .... fi
        !          27972: .... {
        !          27973: .... echo '/* local info for rename */'
        !          27974: .... case "rename" in
        !          27975: .... *.*)      f=rename
        !          27976: ....   i=rename
        !          27977: ....   ;;
        !          27978: .... *)        f=rename
        !          27979: ....   i=rename
        !          27980: ....   echo "#undef $i
        !          27981: ....           int $i;" > x.${!-$$}.c
        !          27982: ....   cmd=:
        !          27983: ....   opt=
        !          27984: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          27985: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          27986: ....           then    opt=-Bstatic
        !          27987: ....           else    cmd=x.${!-$$}.x
        !          27988: ....           fi
        !          27989: ....   fi
        !          27990: ....   echo "#undef $i
        !          27991: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          27992: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          27993: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          27994: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          27995: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          27996: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          27997: ....           fi
        !          27998: ....   fi
        !          27999: ....   ;;
        !          28000: .... esac
        !          28001: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          28002: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28003: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          28004: .... fi
        !          28005: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          28006: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28007: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          28008: .... fi
        !          28009: .... for j in / /usr/
        !          28010: .... do        for i in bin etc ucb
        !          28011: ....   do      if      test -f $j$i/$f
        !          28012: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          28013: ....                   break 2
        !          28014: ....           fi
        !          28015: ....   done
        !          28016: .... done
        !          28017: .... } > FEATURE/rename
        !          28018: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          28019: attr scan
        !          28020: attr impl
        !          28021: done FEATURE/rename
        !          28022: done comp/rename.c
        !          28023: prev comp/rename.c
        !          28024: exec $CC $CCFLAGS -I.  -c comp/rename.c
        !          28025: done rename.o
        !          28026: make link.o
        !          28027: make comp/link.c
        !          28028: attr perm
        !          28029: attr scan
        !          28030: make FEATURE/link
        !          28031: exec : generate local FEATURE information for link
        !          28032: .... set -
        !          28033: .... if        test ! -d FEATURE
        !          28034: .... then      rm -rf FEATURE
        !          28035: ....   mkdir FEATURE
        !          28036: .... fi
        !          28037: .... {
        !          28038: .... echo '/* local info for link */'
        !          28039: .... case "link" in
        !          28040: .... *.*)      f=link
        !          28041: ....   i=link
        !          28042: ....   ;;
        !          28043: .... *)        f=link
        !          28044: ....   i=link
        !          28045: ....   echo "#undef $i
        !          28046: ....           int $i;" > x.${!-$$}.c
        !          28047: ....   cmd=:
        !          28048: ....   opt=
        !          28049: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28050: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28051: ....           then    opt=-Bstatic
        !          28052: ....           else    cmd=x.${!-$$}.x
        !          28053: ....           fi
        !          28054: ....   fi
        !          28055: ....   echo "#undef $i
        !          28056: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          28057: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          28058: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          28059: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          28060: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          28061: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          28062: ....           fi
        !          28063: ....   fi
        !          28064: ....   ;;
        !          28065: .... esac
        !          28066: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          28067: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28068: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          28069: .... fi
        !          28070: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          28071: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28072: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          28073: .... fi
        !          28074: .... for j in / /usr/
        !          28075: .... do        for i in bin etc ucb
        !          28076: ....   do      if      test -f $j$i/$f
        !          28077: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          28078: ....                   break 2
        !          28079: ....           fi
        !          28080: ....   done
        !          28081: .... done
        !          28082: .... } > FEATURE/link
        !          28083: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          28084: attr scan
        !          28085: attr impl
        !          28086: done FEATURE/link
        !          28087: done comp/link.c
        !          28088: prev comp/link.c
        !          28089: exec $CC $CCFLAGS -I.  -c comp/link.c
        !          28090: done link.o
        !          28091: make unlink.o
        !          28092: make comp/unlink.c
        !          28093: attr perm
        !          28094: attr scan
        !          28095: make FEATURE/unlink
        !          28096: exec : generate local FEATURE information for unlink
        !          28097: .... set -
        !          28098: .... if        test ! -d FEATURE
        !          28099: .... then      rm -rf FEATURE
        !          28100: ....   mkdir FEATURE
        !          28101: .... fi
        !          28102: .... {
        !          28103: .... echo '/* local info for unlink */'
        !          28104: .... case "unlink" in
        !          28105: .... *.*)      f=unlink
        !          28106: ....   i=unlink
        !          28107: ....   ;;
        !          28108: .... *)        f=unlink
        !          28109: ....   i=unlink
        !          28110: ....   echo "#undef $i
        !          28111: ....           int $i;" > x.${!-$$}.c
        !          28112: ....   cmd=:
        !          28113: ....   opt=
        !          28114: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28115: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28116: ....           then    opt=-Bstatic
        !          28117: ....           else    cmd=x.${!-$$}.x
        !          28118: ....           fi
        !          28119: ....   fi
        !          28120: ....   echo "#undef $i
        !          28121: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          28122: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          28123: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          28124: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          28125: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          28126: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          28127: ....           fi
        !          28128: ....   fi
        !          28129: ....   ;;
        !          28130: .... esac
        !          28131: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          28132: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28133: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          28134: .... fi
        !          28135: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          28136: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28137: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          28138: .... fi
        !          28139: .... for j in / /usr/
        !          28140: .... do        for i in bin etc ucb
        !          28141: ....   do      if      test -f $j$i/$f
        !          28142: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          28143: ....                   break 2
        !          28144: ....           fi
        !          28145: ....   done
        !          28146: .... done
        !          28147: .... } > FEATURE/unlink
        !          28148: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          28149: attr scan
        !          28150: attr impl
        !          28151: done FEATURE/unlink
        !          28152: done comp/unlink.c
        !          28153: prev comp/unlink.c
        !          28154: exec $CC $CCFLAGS -I.  -c comp/unlink.c
        !          28155: done unlink.o
        !          28156: make strtok.o
        !          28157: make comp/strtok.c
        !          28158: attr perm
        !          28159: attr scan
        !          28160: make FEATURE/strtok
        !          28161: exec : generate local FEATURE information for strtok
        !          28162: .... set -
        !          28163: .... if        test ! -d FEATURE
        !          28164: .... then      rm -rf FEATURE
        !          28165: ....   mkdir FEATURE
        !          28166: .... fi
        !          28167: .... {
        !          28168: .... echo '/* local info for strtok */'
        !          28169: .... case "strtok" in
        !          28170: .... *.*)      f=strtok
        !          28171: ....   i=strtok
        !          28172: ....   ;;
        !          28173: .... *)        f=strtok
        !          28174: ....   i=strtok
        !          28175: ....   echo "#undef $i
        !          28176: ....           int $i;" > x.${!-$$}.c
        !          28177: ....   cmd=:
        !          28178: ....   opt=
        !          28179: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28180: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28181: ....           then    opt=-Bstatic
        !          28182: ....           else    cmd=x.${!-$$}.x
        !          28183: ....           fi
        !          28184: ....   fi
        !          28185: ....   echo "#undef $i
        !          28186: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          28187: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          28188: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          28189: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          28190: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          28191: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          28192: ....           fi
        !          28193: ....   fi
        !          28194: ....   ;;
        !          28195: .... esac
        !          28196: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          28197: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28198: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          28199: .... fi
        !          28200: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          28201: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28202: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          28203: .... fi
        !          28204: .... for j in / /usr/
        !          28205: .... do        for i in bin etc ucb
        !          28206: ....   do      if      test -f $j$i/$f
        !          28207: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          28208: ....                   break 2
        !          28209: ....           fi
        !          28210: ....   done
        !          28211: .... done
        !          28212: .... } > FEATURE/strtok
        !          28213: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          28214: attr scan
        !          28215: attr impl
        !          28216: done FEATURE/strtok
        !          28217: done comp/strtok.c
        !          28218: prev comp/strtok.c
        !          28219: exec $CC $CCFLAGS -I.  -c comp/strtok.c
        !          28220: done strtok.o
        !          28221: make strspn.o
        !          28222: make comp/strspn.c
        !          28223: attr perm
        !          28224: attr scan
        !          28225: make FEATURE/strspn
        !          28226: exec : generate local FEATURE information for strspn
        !          28227: .... set -
        !          28228: .... if        test ! -d FEATURE
        !          28229: .... then      rm -rf FEATURE
        !          28230: ....   mkdir FEATURE
        !          28231: .... fi
        !          28232: .... {
        !          28233: .... echo '/* local info for strspn */'
        !          28234: .... case "strspn" in
        !          28235: .... *.*)      f=strspn
        !          28236: ....   i=strspn
        !          28237: ....   ;;
        !          28238: .... *)        f=strspn
        !          28239: ....   i=strspn
        !          28240: ....   echo "#undef $i
        !          28241: ....           int $i;" > x.${!-$$}.c
        !          28242: ....   cmd=:
        !          28243: ....   opt=
        !          28244: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28245: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28246: ....           then    opt=-Bstatic
        !          28247: ....           else    cmd=x.${!-$$}.x
        !          28248: ....           fi
        !          28249: ....   fi
        !          28250: ....   echo "#undef $i
        !          28251: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          28252: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          28253: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          28254: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          28255: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          28256: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          28257: ....           fi
        !          28258: ....   fi
        !          28259: ....   ;;
        !          28260: .... esac
        !          28261: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          28262: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28263: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          28264: .... fi
        !          28265: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          28266: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28267: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          28268: .... fi
        !          28269: .... for j in / /usr/
        !          28270: .... do        for i in bin etc ucb
        !          28271: ....   do      if      test -f $j$i/$f
        !          28272: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          28273: ....                   break 2
        !          28274: ....           fi
        !          28275: ....   done
        !          28276: .... done
        !          28277: .... } > FEATURE/strspn
        !          28278: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          28279: attr scan
        !          28280: attr impl
        !          28281: done FEATURE/strspn
        !          28282: done comp/strspn.c
        !          28283: prev comp/strspn.c
        !          28284: exec $CC $CCFLAGS -I.  -c comp/strspn.c
        !          28285: done strspn.o
        !          28286: make strpbrk.o
        !          28287: make comp/strpbrk.c
        !          28288: attr perm
        !          28289: attr scan
        !          28290: make FEATURE/strpbrk
        !          28291: exec : generate local FEATURE information for strpbrk
        !          28292: .... set -
        !          28293: .... if        test ! -d FEATURE
        !          28294: .... then      rm -rf FEATURE
        !          28295: ....   mkdir FEATURE
        !          28296: .... fi
        !          28297: .... {
        !          28298: .... echo '/* local info for strpbrk */'
        !          28299: .... case "strpbrk" in
        !          28300: .... *.*)      f=strpbrk
        !          28301: ....   i=strpbrk
        !          28302: ....   ;;
        !          28303: .... *)        f=strpbrk
        !          28304: ....   i=strpbrk
        !          28305: ....   echo "#undef $i
        !          28306: ....           int $i;" > x.${!-$$}.c
        !          28307: ....   cmd=:
        !          28308: ....   opt=
        !          28309: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28310: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28311: ....           then    opt=-Bstatic
        !          28312: ....           else    cmd=x.${!-$$}.x
        !          28313: ....           fi
        !          28314: ....   fi
        !          28315: ....   echo "#undef $i
        !          28316: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          28317: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          28318: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          28319: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          28320: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          28321: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          28322: ....           fi
        !          28323: ....   fi
        !          28324: ....   ;;
        !          28325: .... esac
        !          28326: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          28327: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28328: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          28329: .... fi
        !          28330: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          28331: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28332: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          28333: .... fi
        !          28334: .... for j in / /usr/
        !          28335: .... do        for i in bin etc ucb
        !          28336: ....   do      if      test -f $j$i/$f
        !          28337: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          28338: ....                   break 2
        !          28339: ....           fi
        !          28340: ....   done
        !          28341: .... done
        !          28342: .... } > FEATURE/strpbrk
        !          28343: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          28344: attr scan
        !          28345: attr impl
        !          28346: done FEATURE/strpbrk
        !          28347: done comp/strpbrk.c
        !          28348: prev comp/strpbrk.c
        !          28349: exec $CC $CCFLAGS -I.  -c comp/strpbrk.c
        !          28350: done strpbrk.o
        !          28351: make strdup.o
        !          28352: make string/strdup.c
        !          28353: attr perm
        !          28354: attr scan
        !          28355: make FEATURE/strdup
        !          28356: exec : generate local FEATURE information for strdup
        !          28357: .... set -
        !          28358: .... if        test ! -d FEATURE
        !          28359: .... then      rm -rf FEATURE
        !          28360: ....   mkdir FEATURE
        !          28361: .... fi
        !          28362: .... {
        !          28363: .... echo '/* local info for strdup */'
        !          28364: .... case "strdup" in
        !          28365: .... *.*)      f=strdup
        !          28366: ....   i=strdup
        !          28367: ....   ;;
        !          28368: .... *)        f=strdup
        !          28369: ....   i=strdup
        !          28370: ....   echo "#undef $i
        !          28371: ....           int $i;" > x.${!-$$}.c
        !          28372: ....   cmd=:
        !          28373: ....   opt=
        !          28374: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28375: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28376: ....           then    opt=-Bstatic
        !          28377: ....           else    cmd=x.${!-$$}.x
        !          28378: ....           fi
        !          28379: ....   fi
        !          28380: ....   echo "#undef $i
        !          28381: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          28382: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          28383: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          28384: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          28385: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          28386: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          28387: ....           fi
        !          28388: ....   fi
        !          28389: ....   ;;
        !          28390: .... esac
        !          28391: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          28392: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28393: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          28394: .... fi
        !          28395: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          28396: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28397: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          28398: .... fi
        !          28399: .... for j in / /usr/
        !          28400: .... do        for i in bin etc ucb
        !          28401: ....   do      if      test -f $j$i/$f
        !          28402: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          28403: ....                   break 2
        !          28404: ....           fi
        !          28405: ....   done
        !          28406: .... done
        !          28407: .... } > FEATURE/strdup
        !          28408: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          28409: attr scan
        !          28410: attr impl
        !          28411: done FEATURE/strdup
        !          28412: done string/strdup.c
        !          28413: prev string/strdup.c
        !          28414: exec $CC $CCFLAGS -I.  -c string/strdup.c
        !          28415: done strdup.o
        !          28416: make strchr.o
        !          28417: make comp/strchr.c
        !          28418: attr perm
        !          28419: attr scan
        !          28420: make FEATURE/index
        !          28421: exec : generate local FEATURE information for index
        !          28422: .... set -
        !          28423: .... if        test ! -d FEATURE
        !          28424: .... then      rm -rf FEATURE
        !          28425: ....   mkdir FEATURE
        !          28426: .... fi
        !          28427: .... {
        !          28428: .... echo '/* local info for index */'
        !          28429: .... case "index" in
        !          28430: .... *.*)      f=index
        !          28431: ....   i=index
        !          28432: ....   ;;
        !          28433: .... *)        f=index
        !          28434: ....   i=index
        !          28435: ....   echo "#undef $i
        !          28436: ....           int $i;" > x.${!-$$}.c
        !          28437: ....   cmd=:
        !          28438: ....   opt=
        !          28439: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28440: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28441: ....           then    opt=-Bstatic
        !          28442: ....           else    cmd=x.${!-$$}.x
        !          28443: ....           fi
        !          28444: ....   fi
        !          28445: ....   echo "#undef $i
        !          28446: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          28447: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          28448: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          28449: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          28450: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          28451: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          28452: ....           fi
        !          28453: ....   fi
        !          28454: ....   ;;
        !          28455: .... esac
        !          28456: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          28457: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28458: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          28459: .... fi
        !          28460: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          28461: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28462: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          28463: .... fi
        !          28464: .... for j in / /usr/
        !          28465: .... do        for i in bin etc ucb
        !          28466: ....   do      if      test -f $j$i/$f
        !          28467: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          28468: ....                   break 2
        !          28469: ....           fi
        !          28470: ....   done
        !          28471: .... done
        !          28472: .... } > FEATURE/index
        !          28473: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          28474: attr scan
        !          28475: attr impl
        !          28476: done FEATURE/index
        !          28477: make FEATURE/strchr
        !          28478: exec : generate local FEATURE information for strchr
        !          28479: .... set -
        !          28480: .... if        test ! -d FEATURE
        !          28481: .... then      rm -rf FEATURE
        !          28482: ....   mkdir FEATURE
        !          28483: .... fi
        !          28484: .... {
        !          28485: .... echo '/* local info for strchr */'
        !          28486: .... case "strchr" in
        !          28487: .... *.*)      f=strchr
        !          28488: ....   i=strchr
        !          28489: ....   ;;
        !          28490: .... *)        f=strchr
        !          28491: ....   i=strchr
        !          28492: ....   echo "#undef $i
        !          28493: ....           int $i;" > x.${!-$$}.c
        !          28494: ....   cmd=:
        !          28495: ....   opt=
        !          28496: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28497: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28498: ....           then    opt=-Bstatic
        !          28499: ....           else    cmd=x.${!-$$}.x
        !          28500: ....           fi
        !          28501: ....   fi
        !          28502: ....   echo "#undef $i
        !          28503: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          28504: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          28505: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          28506: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          28507: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          28508: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          28509: ....           fi
        !          28510: ....   fi
        !          28511: ....   ;;
        !          28512: .... esac
        !          28513: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          28514: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28515: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          28516: .... fi
        !          28517: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          28518: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28519: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          28520: .... fi
        !          28521: .... for j in / /usr/
        !          28522: .... do        for i in bin etc ucb
        !          28523: ....   do      if      test -f $j$i/$f
        !          28524: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          28525: ....                   break 2
        !          28526: ....           fi
        !          28527: ....   done
        !          28528: .... done
        !          28529: .... } > FEATURE/strchr
        !          28530: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          28531: attr scan
        !          28532: attr impl
        !          28533: done FEATURE/strchr
        !          28534: done comp/strchr.c
        !          28535: prev comp/strchr.c
        !          28536: exec $CC $CCFLAGS -I.  -c comp/strchr.c
        !          28537: done strchr.o
        !          28538: make strrchr.o
        !          28539: make comp/strrchr.c
        !          28540: attr perm
        !          28541: attr scan
        !          28542: make FEATURE/rindex
        !          28543: exec : generate local FEATURE information for rindex
        !          28544: .... set -
        !          28545: .... if        test ! -d FEATURE
        !          28546: .... then      rm -rf FEATURE
        !          28547: ....   mkdir FEATURE
        !          28548: .... fi
        !          28549: .... {
        !          28550: .... echo '/* local info for rindex */'
        !          28551: .... case "rindex" in
        !          28552: .... *.*)      f=rindex
        !          28553: ....   i=rindex
        !          28554: ....   ;;
        !          28555: .... *)        f=rindex
        !          28556: ....   i=rindex
        !          28557: ....   echo "#undef $i
        !          28558: ....           int $i;" > x.${!-$$}.c
        !          28559: ....   cmd=:
        !          28560: ....   opt=
        !          28561: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28562: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28563: ....           then    opt=-Bstatic
        !          28564: ....           else    cmd=x.${!-$$}.x
        !          28565: ....           fi
        !          28566: ....   fi
        !          28567: ....   echo "#undef $i
        !          28568: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          28569: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          28570: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          28571: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          28572: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          28573: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          28574: ....           fi
        !          28575: ....   fi
        !          28576: ....   ;;
        !          28577: .... esac
        !          28578: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          28579: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28580: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          28581: .... fi
        !          28582: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          28583: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28584: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          28585: .... fi
        !          28586: .... for j in / /usr/
        !          28587: .... do        for i in bin etc ucb
        !          28588: ....   do      if      test -f $j$i/$f
        !          28589: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          28590: ....                   break 2
        !          28591: ....           fi
        !          28592: ....   done
        !          28593: .... done
        !          28594: .... } > FEATURE/rindex
        !          28595: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          28596: attr scan
        !          28597: attr impl
        !          28598: done FEATURE/rindex
        !          28599: make FEATURE/strrchr
        !          28600: exec : generate local FEATURE information for strrchr
        !          28601: .... set -
        !          28602: .... if        test ! -d FEATURE
        !          28603: .... then      rm -rf FEATURE
        !          28604: ....   mkdir FEATURE
        !          28605: .... fi
        !          28606: .... {
        !          28607: .... echo '/* local info for strrchr */'
        !          28608: .... case "strrchr" in
        !          28609: .... *.*)      f=strrchr
        !          28610: ....   i=strrchr
        !          28611: ....   ;;
        !          28612: .... *)        f=strrchr
        !          28613: ....   i=strrchr
        !          28614: ....   echo "#undef $i
        !          28615: ....           int $i;" > x.${!-$$}.c
        !          28616: ....   cmd=:
        !          28617: ....   opt=
        !          28618: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28619: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28620: ....           then    opt=-Bstatic
        !          28621: ....           else    cmd=x.${!-$$}.x
        !          28622: ....           fi
        !          28623: ....   fi
        !          28624: ....   echo "#undef $i
        !          28625: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          28626: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          28627: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          28628: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          28629: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          28630: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          28631: ....           fi
        !          28632: ....   fi
        !          28633: ....   ;;
        !          28634: .... esac
        !          28635: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          28636: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28637: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          28638: .... fi
        !          28639: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          28640: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28641: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          28642: .... fi
        !          28643: .... for j in / /usr/
        !          28644: .... do        for i in bin etc ucb
        !          28645: ....   do      if      test -f $j$i/$f
        !          28646: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          28647: ....                   break 2
        !          28648: ....           fi
        !          28649: ....   done
        !          28650: .... done
        !          28651: .... } > FEATURE/strrchr
        !          28652: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          28653: attr scan
        !          28654: attr impl
        !          28655: done FEATURE/strrchr
        !          28656: done comp/strrchr.c
        !          28657: prev comp/strrchr.c
        !          28658: exec $CC $CCFLAGS -I.  -c comp/strrchr.c
        !          28659: done strrchr.o
        !          28660: make strtod.o
        !          28661: make comp/strtod.c
        !          28662: attr perm
        !          28663: attr scan
        !          28664: make FEATURE/strtod
        !          28665: exec : generate local FEATURE information for strtod
        !          28666: .... set -
        !          28667: .... if        test ! -d FEATURE
        !          28668: .... then      rm -rf FEATURE
        !          28669: ....   mkdir FEATURE
        !          28670: .... fi
        !          28671: .... {
        !          28672: .... echo '/* local info for strtod */'
        !          28673: .... case "strtod" in
        !          28674: .... *.*)      f=strtod
        !          28675: ....   i=strtod
        !          28676: ....   ;;
        !          28677: .... *)        f=strtod
        !          28678: ....   i=strtod
        !          28679: ....   echo "#undef $i
        !          28680: ....           int $i;" > x.${!-$$}.c
        !          28681: ....   cmd=:
        !          28682: ....   opt=
        !          28683: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28684: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28685: ....           then    opt=-Bstatic
        !          28686: ....           else    cmd=x.${!-$$}.x
        !          28687: ....           fi
        !          28688: ....   fi
        !          28689: ....   echo "#undef $i
        !          28690: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          28691: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          28692: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          28693: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          28694: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          28695: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          28696: ....           fi
        !          28697: ....   fi
        !          28698: ....   ;;
        !          28699: .... esac
        !          28700: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          28701: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28702: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          28703: .... fi
        !          28704: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          28705: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28706: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          28707: .... fi
        !          28708: .... for j in / /usr/
        !          28709: .... do        for i in bin etc ucb
        !          28710: ....   do      if      test -f $j$i/$f
        !          28711: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          28712: ....                   break 2
        !          28713: ....           fi
        !          28714: ....   done
        !          28715: .... done
        !          28716: .... } > FEATURE/strtod
        !          28717: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          28718: attr scan
        !          28719: attr impl
        !          28720: done FEATURE/strtod
        !          28721: done comp/strtod.c
        !          28722: prev comp/strtod.c
        !          28723: exec $CC $CCFLAGS -I.  -c comp/strtod.c
        !          28724: done strtod.o
        !          28725: make strtol.o
        !          28726: make comp/strtol.c
        !          28727: attr perm
        !          28728: attr scan
        !          28729: make FEATURE/strtol
        !          28730: exec : generate local FEATURE information for strtol
        !          28731: .... set -
        !          28732: .... if        test ! -d FEATURE
        !          28733: .... then      rm -rf FEATURE
        !          28734: ....   mkdir FEATURE
        !          28735: .... fi
        !          28736: .... {
        !          28737: .... echo '/* local info for strtol */'
        !          28738: .... case "strtol" in
        !          28739: .... *.*)      f=strtol
        !          28740: ....   i=strtol
        !          28741: ....   ;;
        !          28742: .... *)        f=strtol
        !          28743: ....   i=strtol
        !          28744: ....   echo "#undef $i
        !          28745: ....           int $i;" > x.${!-$$}.c
        !          28746: ....   cmd=:
        !          28747: ....   opt=
        !          28748: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28749: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28750: ....           then    opt=-Bstatic
        !          28751: ....           else    cmd=x.${!-$$}.x
        !          28752: ....           fi
        !          28753: ....   fi
        !          28754: ....   echo "#undef $i
        !          28755: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          28756: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          28757: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          28758: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          28759: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          28760: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          28761: ....           fi
        !          28762: ....   fi
        !          28763: ....   ;;
        !          28764: .... esac
        !          28765: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          28766: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28767: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          28768: .... fi
        !          28769: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          28770: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28771: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          28772: .... fi
        !          28773: .... for j in / /usr/
        !          28774: .... do        for i in bin etc ucb
        !          28775: ....   do      if      test -f $j$i/$f
        !          28776: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          28777: ....                   break 2
        !          28778: ....           fi
        !          28779: ....   done
        !          28780: .... done
        !          28781: .... } > FEATURE/strtol
        !          28782: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          28783: attr scan
        !          28784: attr impl
        !          28785: done FEATURE/strtol
        !          28786: done comp/strtol.c
        !          28787: prev comp/strtol.c
        !          28788: exec $CC $CCFLAGS -I.  -c comp/strtol.c
        !          28789: done strtol.o
        !          28790: make strton.o
        !          28791: make string/strton.c
        !          28792: attr perm
        !          28793: attr scan
        !          28794: done string/strton.c
        !          28795: prev string/strton.c
        !          28796: exec $CC $CCFLAGS   -c string/strton.c
        !          28797: done strton.o
        !          28798: make sigsetmask.o
        !          28799: make comp/sigsetmask.c
        !          28800: attr perm
        !          28801: attr scan
        !          28802: prev FEATURE/sigsetmask
        !          28803: done comp/sigsetmask.c
        !          28804: prev comp/sigsetmask.c
        !          28805: exec $CC $CCFLAGS -I.  -c comp/sigsetmask.c
        !          28806: done sigsetmask.o
        !          28807: make mktemp.o
        !          28808: make comp/mktemp.c
        !          28809: attr perm
        !          28810: attr scan
        !          28811: make FEATURE/mktemp
        !          28812: exec : generate local FEATURE information for mktemp
        !          28813: .... set -
        !          28814: .... if        test ! -d FEATURE
        !          28815: .... then      rm -rf FEATURE
        !          28816: ....   mkdir FEATURE
        !          28817: .... fi
        !          28818: .... {
        !          28819: .... echo '/* local info for mktemp */'
        !          28820: .... case "mktemp" in
        !          28821: .... *.*)      f=mktemp
        !          28822: ....   i=mktemp
        !          28823: ....   ;;
        !          28824: .... *)        f=mktemp
        !          28825: ....   i=mktemp
        !          28826: ....   echo "#undef $i
        !          28827: ....           int $i;" > x.${!-$$}.c
        !          28828: ....   cmd=:
        !          28829: ....   opt=
        !          28830: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28831: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28832: ....           then    opt=-Bstatic
        !          28833: ....           else    cmd=x.${!-$$}.x
        !          28834: ....           fi
        !          28835: ....   fi
        !          28836: ....   echo "#undef $i
        !          28837: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          28838: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          28839: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          28840: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          28841: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          28842: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          28843: ....           fi
        !          28844: ....   fi
        !          28845: ....   ;;
        !          28846: .... esac
        !          28847: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          28848: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28849: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          28850: .... fi
        !          28851: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          28852: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28853: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          28854: .... fi
        !          28855: .... for j in / /usr/
        !          28856: .... do        for i in bin etc ucb
        !          28857: ....   do      if      test -f $j$i/$f
        !          28858: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          28859: ....                   break 2
        !          28860: ....           fi
        !          28861: ....   done
        !          28862: .... done
        !          28863: .... } > FEATURE/mktemp
        !          28864: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          28865: attr scan
        !          28866: attr impl
        !          28867: done FEATURE/mktemp
        !          28868: done comp/mktemp.c
        !          28869: prev comp/mktemp.c
        !          28870: exec $CC $CCFLAGS -I.  -c comp/mktemp.c
        !          28871: done mktemp.o
        !          28872: make tmpnam.o
        !          28873: make comp/tmpnam.c
        !          28874: attr perm
        !          28875: attr scan
        !          28876: make FEATURE/tmpnam
        !          28877: exec : generate local FEATURE information for tmpnam
        !          28878: .... set -
        !          28879: .... if        test ! -d FEATURE
        !          28880: .... then      rm -rf FEATURE
        !          28881: ....   mkdir FEATURE
        !          28882: .... fi
        !          28883: .... {
        !          28884: .... echo '/* local info for tmpnam */'
        !          28885: .... case "tmpnam" in
        !          28886: .... *.*)      f=tmpnam
        !          28887: ....   i=tmpnam
        !          28888: ....   ;;
        !          28889: .... *)        f=tmpnam
        !          28890: ....   i=tmpnam
        !          28891: ....   echo "#undef $i
        !          28892: ....           int $i;" > x.${!-$$}.c
        !          28893: ....   cmd=:
        !          28894: ....   opt=
        !          28895: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28896: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28897: ....           then    opt=-Bstatic
        !          28898: ....           else    cmd=x.${!-$$}.x
        !          28899: ....           fi
        !          28900: ....   fi
        !          28901: ....   echo "#undef $i
        !          28902: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          28903: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          28904: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          28905: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          28906: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          28907: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          28908: ....           fi
        !          28909: ....   fi
        !          28910: ....   ;;
        !          28911: .... esac
        !          28912: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          28913: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28914: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          28915: .... fi
        !          28916: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          28917: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28918: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          28919: .... fi
        !          28920: .... for j in / /usr/
        !          28921: .... do        for i in bin etc ucb
        !          28922: ....   do      if      test -f $j$i/$f
        !          28923: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          28924: ....                   break 2
        !          28925: ....           fi
        !          28926: ....   done
        !          28927: .... done
        !          28928: .... } > FEATURE/tmpnam
        !          28929: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          28930: attr scan
        !          28931: attr impl
        !          28932: done FEATURE/tmpnam
        !          28933: done comp/tmpnam.c
        !          28934: prev comp/tmpnam.c
        !          28935: exec $CC $CCFLAGS -I. -Iinclude  -c comp/tmpnam.c
        !          28936: done tmpnam.o
        !          28937: make vfork.o
        !          28938: make comp/vfork.c
        !          28939: attr perm
        !          28940: attr scan
        !          28941: make FEATURE/vfork
        !          28942: exec : generate local FEATURE information for vfork
        !          28943: .... set -
        !          28944: .... if        test ! -d FEATURE
        !          28945: .... then      rm -rf FEATURE
        !          28946: ....   mkdir FEATURE
        !          28947: .... fi
        !          28948: .... {
        !          28949: .... echo '/* local info for vfork */'
        !          28950: .... case "vfork" in
        !          28951: .... *.*)      f=vfork
        !          28952: ....   i=vfork
        !          28953: ....   ;;
        !          28954: .... *)        f=vfork
        !          28955: ....   i=vfork
        !          28956: ....   echo "#undef $i
        !          28957: ....           int $i;" > x.${!-$$}.c
        !          28958: ....   cmd=:
        !          28959: ....   opt=
        !          28960: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28961: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          28962: ....           then    opt=-Bstatic
        !          28963: ....           else    cmd=x.${!-$$}.x
        !          28964: ....           fi
        !          28965: ....   fi
        !          28966: ....   echo "#undef $i
        !          28967: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          28968: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          28969: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          28970: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          28971: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          28972: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          28973: ....           fi
        !          28974: ....   fi
        !          28975: ....   ;;
        !          28976: .... esac
        !          28977: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          28978: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28979: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          28980: .... fi
        !          28981: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          28982: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          28983: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          28984: .... fi
        !          28985: .... for j in / /usr/
        !          28986: .... do        for i in bin etc ucb
        !          28987: ....   do      if      test -f $j$i/$f
        !          28988: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          28989: ....                   break 2
        !          28990: ....           fi
        !          28991: ....   done
        !          28992: .... done
        !          28993: .... } > FEATURE/vfork
        !          28994: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          28995: attr scan
        !          28996: attr impl
        !          28997: done FEATURE/vfork
        !          28998: done comp/vfork.c
        !          28999: prev comp/vfork.c
        !          29000: exec $CC $CCFLAGS -I.  -c comp/vfork.c
        !          29001: done vfork.o
        !          29002: make killpg.o
        !          29003: make comp/killpg.c
        !          29004: attr perm
        !          29005: attr scan
        !          29006: make FEATURE/killpg
        !          29007: exec : generate local FEATURE information for killpg
        !          29008: .... set -
        !          29009: .... if        test ! -d FEATURE
        !          29010: .... then      rm -rf FEATURE
        !          29011: ....   mkdir FEATURE
        !          29012: .... fi
        !          29013: .... {
        !          29014: .... echo '/* local info for killpg */'
        !          29015: .... case "killpg" in
        !          29016: .... *.*)      f=killpg
        !          29017: ....   i=killpg
        !          29018: ....   ;;
        !          29019: .... *)        f=killpg
        !          29020: ....   i=killpg
        !          29021: ....   echo "#undef $i
        !          29022: ....           int $i;" > x.${!-$$}.c
        !          29023: ....   cmd=:
        !          29024: ....   opt=
        !          29025: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29026: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29027: ....           then    opt=-Bstatic
        !          29028: ....           else    cmd=x.${!-$$}.x
        !          29029: ....           fi
        !          29030: ....   fi
        !          29031: ....   echo "#undef $i
        !          29032: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          29033: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          29034: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          29035: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          29036: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          29037: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          29038: ....           fi
        !          29039: ....   fi
        !          29040: ....   ;;
        !          29041: .... esac
        !          29042: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          29043: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29044: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          29045: .... fi
        !          29046: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          29047: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29048: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          29049: .... fi
        !          29050: .... for j in / /usr/
        !          29051: .... do        for i in bin etc ucb
        !          29052: ....   do      if      test -f $j$i/$f
        !          29053: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          29054: ....                   break 2
        !          29055: ....           fi
        !          29056: ....   done
        !          29057: .... done
        !          29058: .... } > FEATURE/killpg
        !          29059: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          29060: attr scan
        !          29061: attr impl
        !          29062: done FEATURE/killpg
        !          29063: done comp/killpg.c
        !          29064: prev comp/killpg.c
        !          29065: exec $CC $CCFLAGS -I.  -c comp/killpg.c
        !          29066: done killpg.o
        !          29067: make lstat.o
        !          29068: make comp/lstat.c
        !          29069: attr perm
        !          29070: attr scan
        !          29071: make FEATURE/lstat
        !          29072: exec : generate local FEATURE information for lstat
        !          29073: .... set -
        !          29074: .... if        test ! -d FEATURE
        !          29075: .... then      rm -rf FEATURE
        !          29076: ....   mkdir FEATURE
        !          29077: .... fi
        !          29078: .... {
        !          29079: .... echo '/* local info for lstat */'
        !          29080: .... case "lstat" in
        !          29081: .... *.*)      f=lstat
        !          29082: ....   i=lstat
        !          29083: ....   ;;
        !          29084: .... *)        f=lstat
        !          29085: ....   i=lstat
        !          29086: ....   echo "#undef $i
        !          29087: ....           int $i;" > x.${!-$$}.c
        !          29088: ....   cmd=:
        !          29089: ....   opt=
        !          29090: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29091: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29092: ....           then    opt=-Bstatic
        !          29093: ....           else    cmd=x.${!-$$}.x
        !          29094: ....           fi
        !          29095: ....   fi
        !          29096: ....   echo "#undef $i
        !          29097: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          29098: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          29099: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          29100: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          29101: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          29102: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          29103: ....           fi
        !          29104: ....   fi
        !          29105: ....   ;;
        !          29106: .... esac
        !          29107: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          29108: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29109: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          29110: .... fi
        !          29111: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          29112: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29113: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          29114: .... fi
        !          29115: .... for j in / /usr/
        !          29116: .... do        for i in bin etc ucb
        !          29117: ....   do      if      test -f $j$i/$f
        !          29118: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          29119: ....                   break 2
        !          29120: ....           fi
        !          29121: ....   done
        !          29122: .... done
        !          29123: .... } > FEATURE/lstat
        !          29124: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          29125: attr scan
        !          29126: attr impl
        !          29127: done FEATURE/lstat
        !          29128: done comp/lstat.c
        !          29129: prev comp/lstat.c
        !          29130: exec $CC $CCFLAGS -I.  -c comp/lstat.c
        !          29131: done lstat.o
        !          29132: make readlink.o
        !          29133: make comp/readlink.c
        !          29134: attr perm
        !          29135: attr scan
        !          29136: make FEATURE/readlink
        !          29137: exec : generate local FEATURE information for readlink
        !          29138: .... set -
        !          29139: .... if        test ! -d FEATURE
        !          29140: .... then      rm -rf FEATURE
        !          29141: ....   mkdir FEATURE
        !          29142: .... fi
        !          29143: .... {
        !          29144: .... echo '/* local info for readlink */'
        !          29145: .... case "readlink" in
        !          29146: .... *.*)      f=readlink
        !          29147: ....   i=readlink
        !          29148: ....   ;;
        !          29149: .... *)        f=readlink
        !          29150: ....   i=readlink
        !          29151: ....   echo "#undef $i
        !          29152: ....           int $i;" > x.${!-$$}.c
        !          29153: ....   cmd=:
        !          29154: ....   opt=
        !          29155: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29156: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29157: ....           then    opt=-Bstatic
        !          29158: ....           else    cmd=x.${!-$$}.x
        !          29159: ....           fi
        !          29160: ....   fi
        !          29161: ....   echo "#undef $i
        !          29162: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          29163: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          29164: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          29165: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          29166: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          29167: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          29168: ....           fi
        !          29169: ....   fi
        !          29170: ....   ;;
        !          29171: .... esac
        !          29172: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          29173: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29174: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          29175: .... fi
        !          29176: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          29177: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29178: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          29179: .... fi
        !          29180: .... for j in / /usr/
        !          29181: .... do        for i in bin etc ucb
        !          29182: ....   do      if      test -f $j$i/$f
        !          29183: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          29184: ....                   break 2
        !          29185: ....           fi
        !          29186: ....   done
        !          29187: .... done
        !          29188: .... } > FEATURE/readlink
        !          29189: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          29190: attr scan
        !          29191: attr impl
        !          29192: done FEATURE/readlink
        !          29193: done comp/readlink.c
        !          29194: prev comp/readlink.c
        !          29195: exec $CC $CCFLAGS -I.  -c comp/readlink.c
        !          29196: done readlink.o
        !          29197: make symlink.o
        !          29198: make comp/symlink.c
        !          29199: attr perm
        !          29200: attr scan
        !          29201: make FEATURE/symlink
        !          29202: exec : generate local FEATURE information for symlink
        !          29203: .... set -
        !          29204: .... if        test ! -d FEATURE
        !          29205: .... then      rm -rf FEATURE
        !          29206: ....   mkdir FEATURE
        !          29207: .... fi
        !          29208: .... {
        !          29209: .... echo '/* local info for symlink */'
        !          29210: .... case "symlink" in
        !          29211: .... *.*)      f=symlink
        !          29212: ....   i=symlink
        !          29213: ....   ;;
        !          29214: .... *)        f=symlink
        !          29215: ....   i=symlink
        !          29216: ....   echo "#undef $i
        !          29217: ....           int $i;" > x.${!-$$}.c
        !          29218: ....   cmd=:
        !          29219: ....   opt=
        !          29220: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29221: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29222: ....           then    opt=-Bstatic
        !          29223: ....           else    cmd=x.${!-$$}.x
        !          29224: ....           fi
        !          29225: ....   fi
        !          29226: ....   echo "#undef $i
        !          29227: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          29228: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          29229: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          29230: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          29231: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          29232: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          29233: ....           fi
        !          29234: ....   fi
        !          29235: ....   ;;
        !          29236: .... esac
        !          29237: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          29238: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29239: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          29240: .... fi
        !          29241: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          29242: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29243: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          29244: .... fi
        !          29245: .... for j in / /usr/
        !          29246: .... do        for i in bin etc ucb
        !          29247: ....   do      if      test -f $j$i/$f
        !          29248: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          29249: ....                   break 2
        !          29250: ....           fi
        !          29251: ....   done
        !          29252: .... done
        !          29253: .... } > FEATURE/symlink
        !          29254: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          29255: attr scan
        !          29256: attr impl
        !          29257: done FEATURE/symlink
        !          29258: done comp/symlink.c
        !          29259: prev comp/symlink.c
        !          29260: exec $CC $CCFLAGS -I.  -c comp/symlink.c
        !          29261: done symlink.o
        !          29262: make setpgid.o
        !          29263: make comp/setpgid.c
        !          29264: attr perm
        !          29265: attr scan
        !          29266: make FEATURE/setpgid
        !          29267: exec : generate local FEATURE information for setpgid
        !          29268: .... set -
        !          29269: .... if        test ! -d FEATURE
        !          29270: .... then      rm -rf FEATURE
        !          29271: ....   mkdir FEATURE
        !          29272: .... fi
        !          29273: .... {
        !          29274: .... echo '/* local info for setpgid */'
        !          29275: .... case "setpgid" in
        !          29276: .... *.*)      f=setpgid
        !          29277: ....   i=setpgid
        !          29278: ....   ;;
        !          29279: .... *)        f=setpgid
        !          29280: ....   i=setpgid
        !          29281: ....   echo "#undef $i
        !          29282: ....           int $i;" > x.${!-$$}.c
        !          29283: ....   cmd=:
        !          29284: ....   opt=
        !          29285: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29286: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29287: ....           then    opt=-Bstatic
        !          29288: ....           else    cmd=x.${!-$$}.x
        !          29289: ....           fi
        !          29290: ....   fi
        !          29291: ....   echo "#undef $i
        !          29292: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          29293: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          29294: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          29295: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          29296: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          29297: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          29298: ....           fi
        !          29299: ....   fi
        !          29300: ....   ;;
        !          29301: .... esac
        !          29302: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          29303: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29304: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          29305: .... fi
        !          29306: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          29307: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29308: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          29309: .... fi
        !          29310: .... for j in / /usr/
        !          29311: .... do        for i in bin etc ucb
        !          29312: ....   do      if      test -f $j$i/$f
        !          29313: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          29314: ....                   break 2
        !          29315: ....           fi
        !          29316: ....   done
        !          29317: .... done
        !          29318: .... } > FEATURE/setpgid
        !          29319: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          29320: attr scan
        !          29321: attr impl
        !          29322: done FEATURE/setpgid
        !          29323: done comp/setpgid.c
        !          29324: prev comp/setpgid.c
        !          29325: exec $CC $CCFLAGS -I.  -c comp/setpgid.c
        !          29326: done setpgid.o
        !          29327: make atexit.o
        !          29328: make comp/atexit.c
        !          29329: attr perm
        !          29330: attr scan
        !          29331: make FEATURE/_cleanup
        !          29332: exec : generate local FEATURE information for _cleanup
        !          29333: .... set -
        !          29334: .... if        test ! -d FEATURE
        !          29335: .... then      rm -rf FEATURE
        !          29336: ....   mkdir FEATURE
        !          29337: .... fi
        !          29338: .... {
        !          29339: .... echo '/* local info for _cleanup */'
        !          29340: .... case "_cleanup" in
        !          29341: .... *.*)      f=_cleanup
        !          29342: ....   i=_cleanup
        !          29343: ....   ;;
        !          29344: .... *)        f=_cleanup
        !          29345: ....   i=_cleanup
        !          29346: ....   echo "#undef $i
        !          29347: ....           int $i;" > x.${!-$$}.c
        !          29348: ....   cmd=:
        !          29349: ....   opt=
        !          29350: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29351: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29352: ....           then    opt=-Bstatic
        !          29353: ....           else    cmd=x.${!-$$}.x
        !          29354: ....           fi
        !          29355: ....   fi
        !          29356: ....   echo "#undef $i
        !          29357: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          29358: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          29359: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          29360: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          29361: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          29362: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          29363: ....           fi
        !          29364: ....   fi
        !          29365: ....   ;;
        !          29366: .... esac
        !          29367: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          29368: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29369: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          29370: .... fi
        !          29371: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          29372: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29373: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          29374: .... fi
        !          29375: .... for j in / /usr/
        !          29376: .... do        for i in bin etc ucb
        !          29377: ....   do      if      test -f $j$i/$f
        !          29378: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          29379: ....                   break 2
        !          29380: ....           fi
        !          29381: ....   done
        !          29382: .... done
        !          29383: .... } > FEATURE/_cleanup
        !          29384: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          29385: attr scan
        !          29386: attr impl
        !          29387: done FEATURE/_cleanup
        !          29388: make FEATURE/on_exit
        !          29389: exec : generate local FEATURE information for on_exit
        !          29390: .... set -
        !          29391: .... if        test ! -d FEATURE
        !          29392: .... then      rm -rf FEATURE
        !          29393: ....   mkdir FEATURE
        !          29394: .... fi
        !          29395: .... {
        !          29396: .... echo '/* local info for on_exit */'
        !          29397: .... case "on_exit" in
        !          29398: .... *.*)      f=on_exit
        !          29399: ....   i=on_exit
        !          29400: ....   ;;
        !          29401: .... *)        f=on_exit
        !          29402: ....   i=on_exit
        !          29403: ....   echo "#undef $i
        !          29404: ....           int $i;" > x.${!-$$}.c
        !          29405: ....   cmd=:
        !          29406: ....   opt=
        !          29407: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29408: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29409: ....           then    opt=-Bstatic
        !          29410: ....           else    cmd=x.${!-$$}.x
        !          29411: ....           fi
        !          29412: ....   fi
        !          29413: ....   echo "#undef $i
        !          29414: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          29415: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          29416: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          29417: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          29418: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          29419: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          29420: ....           fi
        !          29421: ....   fi
        !          29422: ....   ;;
        !          29423: .... esac
        !          29424: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          29425: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29426: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          29427: .... fi
        !          29428: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          29429: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29430: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          29431: .... fi
        !          29432: .... for j in / /usr/
        !          29433: .... do        for i in bin etc ucb
        !          29434: ....   do      if      test -f $j$i/$f
        !          29435: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          29436: ....                   break 2
        !          29437: ....           fi
        !          29438: ....   done
        !          29439: .... done
        !          29440: .... } > FEATURE/on_exit
        !          29441: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          29442: attr scan
        !          29443: attr impl
        !          29444: done FEATURE/on_exit
        !          29445: make FEATURE/onexit
        !          29446: exec : generate local FEATURE information for onexit
        !          29447: .... set -
        !          29448: .... if        test ! -d FEATURE
        !          29449: .... then      rm -rf FEATURE
        !          29450: ....   mkdir FEATURE
        !          29451: .... fi
        !          29452: .... {
        !          29453: .... echo '/* local info for onexit */'
        !          29454: .... case "onexit" in
        !          29455: .... *.*)      f=onexit
        !          29456: ....   i=onexit
        !          29457: ....   ;;
        !          29458: .... *)        f=onexit
        !          29459: ....   i=onexit
        !          29460: ....   echo "#undef $i
        !          29461: ....           int $i;" > x.${!-$$}.c
        !          29462: ....   cmd=:
        !          29463: ....   opt=
        !          29464: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29465: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29466: ....           then    opt=-Bstatic
        !          29467: ....           else    cmd=x.${!-$$}.x
        !          29468: ....           fi
        !          29469: ....   fi
        !          29470: ....   echo "#undef $i
        !          29471: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          29472: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          29473: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          29474: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          29475: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          29476: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          29477: ....           fi
        !          29478: ....   fi
        !          29479: ....   ;;
        !          29480: .... esac
        !          29481: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          29482: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29483: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          29484: .... fi
        !          29485: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          29486: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29487: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          29488: .... fi
        !          29489: .... for j in / /usr/
        !          29490: .... do        for i in bin etc ucb
        !          29491: ....   do      if      test -f $j$i/$f
        !          29492: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          29493: ....                   break 2
        !          29494: ....           fi
        !          29495: ....   done
        !          29496: .... done
        !          29497: .... } > FEATURE/onexit
        !          29498: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          29499: attr scan
        !          29500: attr impl
        !          29501: done FEATURE/onexit
        !          29502: make FEATURE/atexit
        !          29503: exec : generate local FEATURE information for atexit
        !          29504: .... set -
        !          29505: .... if        test ! -d FEATURE
        !          29506: .... then      rm -rf FEATURE
        !          29507: ....   mkdir FEATURE
        !          29508: .... fi
        !          29509: .... {
        !          29510: .... echo '/* local info for atexit */'
        !          29511: .... case "atexit" in
        !          29512: .... *.*)      f=atexit
        !          29513: ....   i=atexit
        !          29514: ....   ;;
        !          29515: .... *)        f=atexit
        !          29516: ....   i=atexit
        !          29517: ....   echo "#undef $i
        !          29518: ....           int $i;" > x.${!-$$}.c
        !          29519: ....   cmd=:
        !          29520: ....   opt=
        !          29521: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29522: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29523: ....           then    opt=-Bstatic
        !          29524: ....           else    cmd=x.${!-$$}.x
        !          29525: ....           fi
        !          29526: ....   fi
        !          29527: ....   echo "#undef $i
        !          29528: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          29529: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          29530: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          29531: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          29532: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          29533: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          29534: ....           fi
        !          29535: ....   fi
        !          29536: ....   ;;
        !          29537: .... esac
        !          29538: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          29539: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29540: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          29541: .... fi
        !          29542: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          29543: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29544: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          29545: .... fi
        !          29546: .... for j in / /usr/
        !          29547: .... do        for i in bin etc ucb
        !          29548: ....   do      if      test -f $j$i/$f
        !          29549: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          29550: ....                   break 2
        !          29551: ....           fi
        !          29552: ....   done
        !          29553: .... done
        !          29554: .... } > FEATURE/atexit
        !          29555: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          29556: attr scan
        !          29557: attr impl
        !          29558: done FEATURE/atexit
        !          29559: done comp/atexit.c
        !          29560: prev comp/atexit.c
        !          29561: exec $CC $CCFLAGS -I.  -c comp/atexit.c
        !          29562: done atexit.o
        !          29563: make getdents.o
        !          29564: make comp/getdents.c
        !          29565: attr perm
        !          29566: attr scan
        !          29567: prev FEATURE/dir
        !          29568: make FEATURE/readdir
        !          29569: exec : generate local FEATURE information for readdir
        !          29570: .... set -
        !          29571: .... if        test ! -d FEATURE
        !          29572: .... then      rm -rf FEATURE
        !          29573: ....   mkdir FEATURE
        !          29574: .... fi
        !          29575: .... {
        !          29576: .... echo '/* local info for readdir */'
        !          29577: .... case "readdir" in
        !          29578: .... *.*)      f=readdir
        !          29579: ....   i=readdir
        !          29580: ....   ;;
        !          29581: .... *)        f=readdir
        !          29582: ....   i=readdir
        !          29583: ....   echo "#undef $i
        !          29584: ....           int $i;" > x.${!-$$}.c
        !          29585: ....   cmd=:
        !          29586: ....   opt=
        !          29587: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29588: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29589: ....           then    opt=-Bstatic
        !          29590: ....           else    cmd=x.${!-$$}.x
        !          29591: ....           fi
        !          29592: ....   fi
        !          29593: ....   echo "#undef $i
        !          29594: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          29595: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          29596: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          29597: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          29598: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          29599: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          29600: ....           fi
        !          29601: ....   fi
        !          29602: ....   ;;
        !          29603: .... esac
        !          29604: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          29605: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29606: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          29607: .... fi
        !          29608: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          29609: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29610: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          29611: .... fi
        !          29612: .... for j in / /usr/
        !          29613: .... do        for i in bin etc ucb
        !          29614: ....   do      if      test -f $j$i/$f
        !          29615: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          29616: ....                   break 2
        !          29617: ....           fi
        !          29618: ....   done
        !          29619: .... done
        !          29620: .... } > FEATURE/readdir
        !          29621: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          29622: attr scan
        !          29623: attr impl
        !          29624: done FEATURE/readdir
        !          29625: make FEATURE/dirread
        !          29626: exec : generate local FEATURE information for dirread
        !          29627: .... set -
        !          29628: .... if        test ! -d FEATURE
        !          29629: .... then      rm -rf FEATURE
        !          29630: ....   mkdir FEATURE
        !          29631: .... fi
        !          29632: .... {
        !          29633: .... echo '/* local info for dirread */'
        !          29634: .... case "dirread" in
        !          29635: .... *.*)      f=dirread
        !          29636: ....   i=dirread
        !          29637: ....   ;;
        !          29638: .... *)        f=dirread
        !          29639: ....   i=dirread
        !          29640: ....   echo "#undef $i
        !          29641: ....           int $i;" > x.${!-$$}.c
        !          29642: ....   cmd=:
        !          29643: ....   opt=
        !          29644: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29645: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29646: ....           then    opt=-Bstatic
        !          29647: ....           else    cmd=x.${!-$$}.x
        !          29648: ....           fi
        !          29649: ....   fi
        !          29650: ....   echo "#undef $i
        !          29651: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          29652: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          29653: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          29654: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          29655: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          29656: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          29657: ....           fi
        !          29658: ....   fi
        !          29659: ....   ;;
        !          29660: .... esac
        !          29661: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          29662: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29663: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          29664: .... fi
        !          29665: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          29666: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29667: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          29668: .... fi
        !          29669: .... for j in / /usr/
        !          29670: .... do        for i in bin etc ucb
        !          29671: ....   do      if      test -f $j$i/$f
        !          29672: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          29673: ....                   break 2
        !          29674: ....           fi
        !          29675: ....   done
        !          29676: .... done
        !          29677: .... } > FEATURE/dirread
        !          29678: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          29679: attr scan
        !          29680: attr impl
        !          29681: done FEATURE/dirread
        !          29682: make FEATURE/getdirentries
        !          29683: exec : generate local FEATURE information for getdirentries
        !          29684: .... set -
        !          29685: .... if        test ! -d FEATURE
        !          29686: .... then      rm -rf FEATURE
        !          29687: ....   mkdir FEATURE
        !          29688: .... fi
        !          29689: .... {
        !          29690: .... echo '/* local info for getdirentries */'
        !          29691: .... case "getdirentries" in
        !          29692: .... *.*)      f=getdirentries
        !          29693: ....   i=getdirentries
        !          29694: ....   ;;
        !          29695: .... *)        f=getdirentries
        !          29696: ....   i=getdirentries
        !          29697: ....   echo "#undef $i
        !          29698: ....           int $i;" > x.${!-$$}.c
        !          29699: ....   cmd=:
        !          29700: ....   opt=
        !          29701: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29702: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29703: ....           then    opt=-Bstatic
        !          29704: ....           else    cmd=x.${!-$$}.x
        !          29705: ....           fi
        !          29706: ....   fi
        !          29707: ....   echo "#undef $i
        !          29708: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          29709: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          29710: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          29711: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          29712: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          29713: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          29714: ....           fi
        !          29715: ....   fi
        !          29716: ....   ;;
        !          29717: .... esac
        !          29718: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          29719: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29720: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          29721: .... fi
        !          29722: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          29723: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29724: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          29725: .... fi
        !          29726: .... for j in / /usr/
        !          29727: .... do        for i in bin etc ucb
        !          29728: ....   do      if      test -f $j$i/$f
        !          29729: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          29730: ....                   break 2
        !          29731: ....           fi
        !          29732: ....   done
        !          29733: .... done
        !          29734: .... } > FEATURE/getdirentries
        !          29735: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          29736: attr scan
        !          29737: attr impl
        !          29738: done FEATURE/getdirentries
        !          29739: prev dirent.h
        !          29740: prev fsinfo.h
        !          29741: prev FEATURE/getdents
        !          29742: done comp/getdents.c
        !          29743: prev comp/getdents.c
        !          29744: exec $CC $CCFLAGS -I.  -c comp/getdents.c
        !          29745: done getdents.o
        !          29746: make getwd.o
        !          29747: make misc/getwd.c
        !          29748: attr perm
        !          29749: attr scan
        !          29750: prev limits.h
        !          29751: done misc/getwd.c
        !          29752: prev misc/getwd.c
        !          29753: exec $CC $CCFLAGS -I.  -c misc/getwd.c
        !          29754: done getwd.o
        !          29755: make copy.o
        !          29756: make port/copy.c
        !          29757: attr perm
        !          29758: attr scan
        !          29759: make FEATURE/mmap
        !          29760: exec : generate local FEATURE information for mmap
        !          29761: .... set -
        !          29762: .... if        test ! -d FEATURE
        !          29763: .... then      rm -rf FEATURE
        !          29764: ....   mkdir FEATURE
        !          29765: .... fi
        !          29766: .... {
        !          29767: .... echo '/* local info for mmap */'
        !          29768: .... case "mmap" in
        !          29769: .... *.*)      f=mmap
        !          29770: ....   i=mmap
        !          29771: ....   ;;
        !          29772: .... *)        f=mmap
        !          29773: ....   i=mmap
        !          29774: ....   echo "#undef $i
        !          29775: ....           int $i;" > x.${!-$$}.c
        !          29776: ....   cmd=:
        !          29777: ....   opt=
        !          29778: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29779: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29780: ....           then    opt=-Bstatic
        !          29781: ....           else    cmd=x.${!-$$}.x
        !          29782: ....           fi
        !          29783: ....   fi
        !          29784: ....   echo "#undef $i
        !          29785: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          29786: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          29787: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          29788: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          29789: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          29790: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          29791: ....           fi
        !          29792: ....   fi
        !          29793: ....   ;;
        !          29794: .... esac
        !          29795: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          29796: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29797: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          29798: .... fi
        !          29799: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          29800: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29801: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          29802: .... fi
        !          29803: .... for j in / /usr/
        !          29804: .... do        for i in bin etc ucb
        !          29805: ....   do      if      test -f $j$i/$f
        !          29806: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          29807: ....                   break 2
        !          29808: ....           fi
        !          29809: ....   done
        !          29810: .... done
        !          29811: .... } > FEATURE/mmap
        !          29812: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          29813: attr scan
        !          29814: attr impl
        !          29815: done FEATURE/mmap
        !          29816: done port/copy.c
        !          29817: prev port/copy.c
        !          29818: exec $CC $CCFLAGS -I.  -c port/copy.c
        !          29819: done copy.o
        !          29820: make dup2.o
        !          29821: make comp/dup2.c
        !          29822: attr perm
        !          29823: attr scan
        !          29824: make FEATURE/dup2
        !          29825: exec : generate local FEATURE information for dup2
        !          29826: .... set -
        !          29827: .... if        test ! -d FEATURE
        !          29828: .... then      rm -rf FEATURE
        !          29829: ....   mkdir FEATURE
        !          29830: .... fi
        !          29831: .... {
        !          29832: .... echo '/* local info for dup2 */'
        !          29833: .... case "dup2" in
        !          29834: .... *.*)      f=dup2
        !          29835: ....   i=dup2
        !          29836: ....   ;;
        !          29837: .... *)        f=dup2
        !          29838: ....   i=dup2
        !          29839: ....   echo "#undef $i
        !          29840: ....           int $i;" > x.${!-$$}.c
        !          29841: ....   cmd=:
        !          29842: ....   opt=
        !          29843: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29844: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29845: ....           then    opt=-Bstatic
        !          29846: ....           else    cmd=x.${!-$$}.x
        !          29847: ....           fi
        !          29848: ....   fi
        !          29849: ....   echo "#undef $i
        !          29850: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          29851: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          29852: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          29853: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          29854: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          29855: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          29856: ....           fi
        !          29857: ....   fi
        !          29858: ....   ;;
        !          29859: .... esac
        !          29860: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          29861: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29862: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          29863: .... fi
        !          29864: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          29865: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29866: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          29867: .... fi
        !          29868: .... for j in / /usr/
        !          29869: .... do        for i in bin etc ucb
        !          29870: ....   do      if      test -f $j$i/$f
        !          29871: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          29872: ....                   break 2
        !          29873: ....           fi
        !          29874: ....   done
        !          29875: .... done
        !          29876: .... } > FEATURE/dup2
        !          29877: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          29878: attr scan
        !          29879: attr impl
        !          29880: done FEATURE/dup2
        !          29881: done comp/dup2.c
        !          29882: prev comp/dup2.c
        !          29883: exec $CC $CCFLAGS -I.  -c comp/dup2.c
        !          29884: done dup2.o
        !          29885: make errno.o
        !          29886: make comp/errno.c
        !          29887: attr perm
        !          29888: attr scan
        !          29889: done comp/errno.c
        !          29890: prev comp/errno.c
        !          29891: exec $CC $CCFLAGS   -c comp/errno.c
        !          29892: done errno.o
        !          29893: make sgetl.o
        !          29894: make comp/sgetl.c
        !          29895: attr perm
        !          29896: attr scan
        !          29897: prev limits.h
        !          29898: make FEATURE/sgetl
        !          29899: exec : generate local FEATURE information for sgetl
        !          29900: .... set -
        !          29901: .... if        test ! -d FEATURE
        !          29902: .... then      rm -rf FEATURE
        !          29903: ....   mkdir FEATURE
        !          29904: .... fi
        !          29905: .... {
        !          29906: .... echo '/* local info for sgetl */'
        !          29907: .... case "sgetl" in
        !          29908: .... *.*)      f=sgetl
        !          29909: ....   i=sgetl
        !          29910: ....   ;;
        !          29911: .... *)        f=sgetl
        !          29912: ....   i=sgetl
        !          29913: ....   echo "#undef $i
        !          29914: ....           int $i;" > x.${!-$$}.c
        !          29915: ....   cmd=:
        !          29916: ....   opt=
        !          29917: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29918: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29919: ....           then    opt=-Bstatic
        !          29920: ....           else    cmd=x.${!-$$}.x
        !          29921: ....           fi
        !          29922: ....   fi
        !          29923: ....   echo "#undef $i
        !          29924: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          29925: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          29926: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          29927: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          29928: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          29929: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          29930: ....           fi
        !          29931: ....   fi
        !          29932: ....   ;;
        !          29933: .... esac
        !          29934: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          29935: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29936: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          29937: .... fi
        !          29938: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          29939: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          29940: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          29941: .... fi
        !          29942: .... for j in / /usr/
        !          29943: .... do        for i in bin etc ucb
        !          29944: ....   do      if      test -f $j$i/$f
        !          29945: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          29946: ....                   break 2
        !          29947: ....           fi
        !          29948: ....   done
        !          29949: .... done
        !          29950: .... } > FEATURE/sgetl
        !          29951: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          29952: attr scan
        !          29953: attr impl
        !          29954: done FEATURE/sgetl
        !          29955: done comp/sgetl.c
        !          29956: prev comp/sgetl.c
        !          29957: exec $CC $CCFLAGS -I.  -c comp/sgetl.c
        !          29958: done sgetl.o
        !          29959: make sputl.o
        !          29960: make comp/sputl.c
        !          29961: attr perm
        !          29962: attr scan
        !          29963: prev limits.h
        !          29964: make FEATURE/sputl
        !          29965: exec : generate local FEATURE information for sputl
        !          29966: .... set -
        !          29967: .... if        test ! -d FEATURE
        !          29968: .... then      rm -rf FEATURE
        !          29969: ....   mkdir FEATURE
        !          29970: .... fi
        !          29971: .... {
        !          29972: .... echo '/* local info for sputl */'
        !          29973: .... case "sputl" in
        !          29974: .... *.*)      f=sputl
        !          29975: ....   i=sputl
        !          29976: ....   ;;
        !          29977: .... *)        f=sputl
        !          29978: ....   i=sputl
        !          29979: ....   echo "#undef $i
        !          29980: ....           int $i;" > x.${!-$$}.c
        !          29981: ....   cmd=:
        !          29982: ....   opt=
        !          29983: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29984: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          29985: ....           then    opt=-Bstatic
        !          29986: ....           else    cmd=x.${!-$$}.x
        !          29987: ....           fi
        !          29988: ....   fi
        !          29989: ....   echo "#undef $i
        !          29990: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          29991: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          29992: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          29993: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          29994: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          29995: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          29996: ....           fi
        !          29997: ....   fi
        !          29998: ....   ;;
        !          29999: .... esac
        !          30000: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          30001: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          30002: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          30003: .... fi
        !          30004: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          30005: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          30006: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          30007: .... fi
        !          30008: .... for j in / /usr/
        !          30009: .... do        for i in bin etc ucb
        !          30010: ....   do      if      test -f $j$i/$f
        !          30011: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          30012: ....                   break 2
        !          30013: ....           fi
        !          30014: ....   done
        !          30015: .... done
        !          30016: .... } > FEATURE/sputl
        !          30017: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          30018: attr scan
        !          30019: attr impl
        !          30020: done FEATURE/sputl
        !          30021: done comp/sputl.c
        !          30022: prev comp/sputl.c
        !          30023: exec $CC $CCFLAGS -I.  -c comp/sputl.c
        !          30024: done sputl.o
        !          30025: make getpreroot.o
        !          30026: make preroot/getpreroot.c
        !          30027: attr perm
        !          30028: attr scan
        !          30029: prev limits.h
        !          30030: prev dirent.h
        !          30031: prev preroot.h
        !          30032: done preroot/getpreroot.c
        !          30033: prev preroot/getpreroot.c
        !          30034: exec $CC $CCFLAGS -I. -Iinclude  -c preroot/getpreroot.c
        !          30035: done getpreroot.o
        !          30036: make ispreroot.o
        !          30037: make preroot/ispreroot.c
        !          30038: attr perm
        !          30039: attr scan
        !          30040: prev preroot.h
        !          30041: done preroot/ispreroot.c
        !          30042: prev preroot/ispreroot.c
        !          30043: exec $CC $CCFLAGS -I.  -c preroot/ispreroot.c
        !          30044: done ispreroot.o
        !          30045: make realopen.o
        !          30046: make preroot/realopen.c
        !          30047: attr perm
        !          30048: attr scan
        !          30049: prev limits.h
        !          30050: prev preroot.h
        !          30051: done preroot/realopen.c
        !          30052: prev preroot/realopen.c
        !          30053: exec $CC $CCFLAGS -I.  -c preroot/realopen.c
        !          30054: done realopen.o
        !          30055: make setpreroot.o
        !          30056: make preroot/setpreroot.c
        !          30057: attr perm
        !          30058: attr scan
        !          30059: prev limits.h
        !          30060: prev preroot.h
        !          30061: done preroot/setpreroot.c
        !          30062: prev preroot/setpreroot.c
        !          30063: exec $CC $CCFLAGS -I. -Iinclude  -c preroot/setpreroot.c
        !          30064: done setpreroot.o
        !          30065: make mount.o
        !          30066: make comp/mount.c
        !          30067: attr perm
        !          30068: attr scan
        !          30069: make FEATURE/mount
        !          30070: exec : generate local FEATURE information for mount
        !          30071: .... set -
        !          30072: .... if        test ! -d FEATURE
        !          30073: .... then      rm -rf FEATURE
        !          30074: ....   mkdir FEATURE
        !          30075: .... fi
        !          30076: .... {
        !          30077: .... echo '/* local info for mount */'
        !          30078: .... case "mount" in
        !          30079: .... *.*)      f=mount
        !          30080: ....   i=mount
        !          30081: ....   ;;
        !          30082: .... *)        f=mount
        !          30083: ....   i=mount
        !          30084: ....   echo "#undef $i
        !          30085: ....           int $i;" > x.${!-$$}.c
        !          30086: ....   cmd=:
        !          30087: ....   opt=
        !          30088: ....   if      $CC $CCFLAGS   -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          30089: ....   then    if      $CC $CCFLAGS   -Bstatic -o x.${!-$$}.x x.${!-$$}.c > /dev/null 2>&1
        !          30090: ....           then    opt=-Bstatic
        !          30091: ....           else    cmd=x.${!-$$}.x
        !          30092: ....           fi
        !          30093: ....   fi
        !          30094: ....   echo "#undef $i
        !          30095: ....           extern int $i();static int ((*i)())=$i;main(){exit(i==(int((*)()))0);}" > x.${!-$$}.c
        !          30096: ....   if      $CC $CCFLAGS   $opt -c x.${!-$$}.c > /dev/null 2>&1
        !          30097: ....   then    if      { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o && $cmd ;} > /dev/null 2>&1
        !          30098: ....           then    echo "#define   _lib_$i 1       /* $i() in default lib(s) */"
        !          30099: ....           elif    { $CC $CCFLAGS   $opt -o x.${!-$$}.x x.${!-$$}.o -lm && $cmd ;} > /dev/null 2>&1
        !          30100: ....           then    echo "#define   _mth_$i 1       /* $i() in math lib */"
        !          30101: ....           fi
        !          30102: ....   fi
        !          30103: ....   ;;
        !          30104: .... esac
        !          30105: .... echo "#include \"$f.h\"" > x.${!-$$}.c
        !          30106: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          30107: .... then      echo "#define   _hdr_$i 1       /* #include \"$f.h\" ok */"
        !          30108: .... fi
        !          30109: .... echo "#include \"sys/$f.h\"" > x.${!-$$}.c
        !          30110: .... if        $CC $CCFLAGS   -E x.${!-$$}.c > /dev/null 2>&1
        !          30111: .... then      echo "#define   _sys_$i 1       /* #include \"sys/$f.h\" ok */"
        !          30112: .... fi
        !          30113: .... for j in / /usr/
        !          30114: .... do        for i in bin etc ucb
        !          30115: ....   do      if      test -f $j$i/$f
        !          30116: ....           then    echo "#define   _bin_$f 1       /* $f in ?(/usr)/(bin|etc|ucb) */"
        !          30117: ....                   break 2
        !          30118: ....           fi
        !          30119: ....   done
        !          30120: .... done
        !          30121: .... } > FEATURE/mount
        !          30122: .... rm -rf x.${!-$$}.c x.${!-$$}.o x.${!-$$}.x
        !          30123: attr scan
        !          30124: attr impl
        !          30125: done FEATURE/mount
        !          30126: done comp/mount.c
        !          30127: prev comp/mount.c
        !          30128: exec $CC $CCFLAGS -I.  -c comp/mount.c
        !          30129: done mount.o
        !          30130: make popen.o
        !          30131: make comp/popen.c
        !          30132: attr perm
        !          30133: attr scan
        !          30134: prev include/stdio.h
        !          30135: done comp/popen.c
        !          30136: prev comp/popen.c
        !          30137: exec $CC $CCFLAGS -Iinclude  -c comp/popen.c
        !          30138: done popen.o
        !          30139: make system.o
        !          30140: make comp/system.c
        !          30141: attr perm
        !          30142: attr scan
        !          30143: done comp/system.c
        !          30144: prev comp/system.c
        !          30145: exec $CC $CCFLAGS   -c comp/system.c
        !          30146: done system.o
        !          30147: make iblocks.o
        !          30148: make port/iblocks.c
        !          30149: attr perm
        !          30150: attr scan
        !          30151: prev fsinfo.h
        !          30152: prev lclparam.h
        !          30153: done port/iblocks.c
        !          30154: prev port/iblocks.c
        !          30155: exec $CC $CCFLAGS -I.  -c port/iblocks.c
        !          30156: done iblocks.o
        !          30157: make modedata.o
        !          30158: make string/modedata.c
        !          30159: attr perm
        !          30160: attr scan
        !          30161: prev /usr/include/sys/stat.h
        !          30162: prev /usr/include/sys/types.h
        !          30163: prev string/modelib.h
        !          30164: done string/modedata.c
        !          30165: prev string/modedata.c
        !          30166: exec $CC $CCFLAGS -Istring  -c string/modedata.c
        !          30167: done modedata.o
        !          30168: make tmdata.o
        !          30169: make tm/tmdata.c
        !          30170: attr perm
        !          30171: attr scan
        !          30172: prev include/tm.h
        !          30173: done tm/tmdata.c
        !          30174: prev tm/tmdata.c
        !          30175: exec $CC $CCFLAGS -Iinclude  -c tm/tmdata.c
        !          30176: done tmdata.o
        !          30177: make sfclose.o
        !          30178: make sfio/sfclose.c
        !          30179: attr perm
        !          30180: attr scan
        !          30181: make sfio/sfhdr.h
        !          30182: attr perm
        !          30183: attr scan
        !          30184: attr impl
        !          30185: make FEATURE/on_exit
        !          30186: done FEATURE/on_exit
        !          30187: make FEATURE/onexit
        !          30188: done FEATURE/onexit
        !          30189: prev FEATURE/atexit
        !          30190: prev FEATURE/bcopy
        !          30191: done sfio/sfhdr.h
        !          30192: done sfio/sfclose.c
        !          30193: prev sfio/sfclose.c
        !          30194: setv LIBX -DLIBX
        !          30195: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfclose.c
        !          30196: done sfclose.o
        !          30197: make sfclrlock.o
        !          30198: make sfio/sfclrlock.c
        !          30199: attr perm
        !          30200: attr scan
        !          30201: prev sfio/sfhdr.h
        !          30202: done sfio/sfclrlock.c
        !          30203: prev sfio/sfclrlock.c
        !          30204: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfclrlock.c
        !          30205: done sfclrlock.o
        !          30206: make sfcvt.o
        !          30207: make sfio/sfcvt.c
        !          30208: attr perm
        !          30209: attr scan
        !          30210: prev sfio/sfhdr.h
        !          30211: done sfio/sfcvt.c
        !          30212: prev sfio/sfcvt.c
        !          30213: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfcvt.c
        !          30214: done sfcvt.o
        !          30215: make sfdlen.o
        !          30216: make sfio/sfdlen.c
        !          30217: attr perm
        !          30218: attr scan
        !          30219: prev sfio/sfhdr.h
        !          30220: done sfio/sfdlen.c
        !          30221: prev sfio/sfdlen.c
        !          30222: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfdlen.c
        !          30223: done sfdlen.o
        !          30224: make sfdopen.o
        !          30225: make sfio/sfdopen.c
        !          30226: attr perm
        !          30227: attr scan
        !          30228: prev sfio/sfhdr.h
        !          30229: done sfio/sfdopen.c
        !          30230: prev sfio/sfdopen.c
        !          30231: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfdopen.c
        !          30232: done sfdopen.o
        !          30233: make sfexcept.o
        !          30234: make sfio/sfexcept.c
        !          30235: attr perm
        !          30236: attr scan
        !          30237: prev sfio/sfhdr.h
        !          30238: done sfio/sfexcept.c
        !          30239: prev sfio/sfexcept.c
        !          30240: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfexcept.c
        !          30241: done sfexcept.o
        !          30242: make sfextern.o
        !          30243: make sfio/sfextern.c
        !          30244: attr perm
        !          30245: attr scan
        !          30246: prev sfio/sfhdr.h
        !          30247: done sfio/sfextern.c
        !          30248: prev sfio/sfextern.c
        !          30249: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfextern.c
        !          30250: done sfextern.o
        !          30251: make sffilbuf.o
        !          30252: make sfio/sffilbuf.c
        !          30253: attr perm
        !          30254: attr scan
        !          30255: prev sfio/sfhdr.h
        !          30256: done sfio/sffilbuf.c
        !          30257: prev sfio/sffilbuf.c
        !          30258: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sffilbuf.c
        !          30259: done sffilbuf.o
        !          30260: make sfflsbuf.o
        !          30261: make sfio/sfflsbuf.c
        !          30262: attr perm
        !          30263: attr scan
        !          30264: prev sfio/sfhdr.h
        !          30265: done sfio/sfflsbuf.c
        !          30266: prev sfio/sfflsbuf.c
        !          30267: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfflsbuf.c
        !          30268: done sfflsbuf.o
        !          30269: make sfgetd.o
        !          30270: make sfio/sfgetd.c
        !          30271: attr perm
        !          30272: attr scan
        !          30273: prev sfio/sfhdr.h
        !          30274: done sfio/sfgetd.c
        !          30275: prev sfio/sfgetd.c
        !          30276: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfgetd.c
        !          30277: done sfgetd.o
        !          30278: make sfgetl.o
        !          30279: make sfio/sfgetl.c
        !          30280: attr perm
        !          30281: attr scan
        !          30282: prev sfio/sfhdr.h
        !          30283: done sfio/sfgetl.c
        !          30284: prev sfio/sfgetl.c
        !          30285: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfgetl.c
        !          30286: done sfgetl.o
        !          30287: make sfgets.o
        !          30288: make sfio/sfgets.c
        !          30289: attr perm
        !          30290: attr scan
        !          30291: prev sfio/sfhdr.h
        !          30292: done sfio/sfgets.c
        !          30293: prev sfio/sfgets.c
        !          30294: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfgets.c
        !          30295: done sfgets.o
        !          30296: make sfgetu.o
        !          30297: make sfio/sfgetu.c
        !          30298: attr perm
        !          30299: attr scan
        !          30300: prev sfio/sfhdr.h
        !          30301: done sfio/sfgetu.c
        !          30302: prev sfio/sfgetu.c
        !          30303: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfgetu.c
        !          30304: done sfgetu.o
        !          30305: make sfllen.o
        !          30306: make sfio/sfllen.c
        !          30307: attr perm
        !          30308: attr scan
        !          30309: prev sfio/sfhdr.h
        !          30310: done sfio/sfllen.c
        !          30311: prev sfio/sfllen.c
        !          30312: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfllen.c
        !          30313: done sfllen.o
        !          30314: make sfmode.o
        !          30315: make sfio/sfmode.c
        !          30316: attr perm
        !          30317: attr scan
        !          30318: prev sfio/sfhdr.h
        !          30319: done sfio/sfmode.c
        !          30320: prev sfio/sfmode.c
        !          30321: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfmode.c
        !          30322: done sfmode.o
        !          30323: make sfmove.o
        !          30324: make sfio/sfmove.c
        !          30325: attr perm
        !          30326: attr scan
        !          30327: prev sfio/sfhdr.h
        !          30328: done sfio/sfmove.c
        !          30329: prev sfio/sfmove.c
        !          30330: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfmove.c
        !          30331: done sfmove.o
        !          30332: make sfnew.o
        !          30333: make sfio/sfnew.c
        !          30334: attr perm
        !          30335: attr scan
        !          30336: prev sfio/sfhdr.h
        !          30337: done sfio/sfnew.c
        !          30338: prev sfio/sfnew.c
        !          30339: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfnew.c
        !          30340: done sfnew.o
        !          30341: make sfnotify.o
        !          30342: make sfio/sfnotify.c
        !          30343: attr perm
        !          30344: attr scan
        !          30345: prev sfio/sfhdr.h
        !          30346: done sfio/sfnotify.c
        !          30347: prev sfio/sfnotify.c
        !          30348: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfnotify.c
        !          30349: done sfnotify.o
        !          30350: make sfnputc.o
        !          30351: make sfio/sfnputc.c
        !          30352: attr perm
        !          30353: attr scan
        !          30354: prev sfio/sfhdr.h
        !          30355: done sfio/sfnputc.c
        !          30356: prev sfio/sfnputc.c
        !          30357: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfnputc.c
        !          30358: done sfnputc.o
        !          30359: make sfopen.o
        !          30360: make sfio/sfopen.c
        !          30361: attr perm
        !          30362: attr scan
        !          30363: prev sfio/sfhdr.h
        !          30364: done sfio/sfopen.c
        !          30365: prev sfio/sfopen.c
        !          30366: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfopen.c
        !          30367: done sfopen.o
        !          30368: make sfpeek.o
        !          30369: make sfio/sfpeek.c
        !          30370: attr perm
        !          30371: attr scan
        !          30372: prev sfio/sfhdr.h
        !          30373: done sfio/sfpeek.c
        !          30374: prev sfio/sfpeek.c
        !          30375: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfpeek.c
        !          30376: done sfpeek.o
        !          30377: make sfpool.o
        !          30378: make sfio/sfpool.c
        !          30379: attr perm
        !          30380: attr scan
        !          30381: prev sfio/sfhdr.h
        !          30382: done sfio/sfpool.c
        !          30383: prev sfio/sfpool.c
        !          30384: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfpool.c
        !          30385: done sfpool.o
        !          30386: make sfpopen.o
        !          30387: make sfio/sfpopen.c
        !          30388: attr perm
        !          30389: attr scan
        !          30390: prev FEATURE/vfork
        !          30391: prev sfio/sfhdr.h
        !          30392: done sfio/sfpopen.c
        !          30393: prev sfio/sfpopen.c
        !          30394: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfpopen.c
        !          30395: done sfpopen.o
        !          30396: make sfprintf.o
        !          30397: make sfio/sfprintf.c
        !          30398: attr perm
        !          30399: attr scan
        !          30400: prev sfio/sfhdr.h
        !          30401: done sfio/sfprintf.c
        !          30402: prev sfio/sfprintf.c
        !          30403: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfprintf.c
        !          30404: done sfprintf.o
        !          30405: make sfputd.o
        !          30406: make sfio/sfputd.c
        !          30407: attr perm
        !          30408: attr scan
        !          30409: prev sfio/sfhdr.h
        !          30410: done sfio/sfputd.c
        !          30411: prev sfio/sfputd.c
        !          30412: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfputd.c
        !          30413: done sfputd.o
        !          30414: make sfputl.o
        !          30415: make sfio/sfputl.c
        !          30416: attr perm
        !          30417: attr scan
        !          30418: prev sfio/sfhdr.h
        !          30419: done sfio/sfputl.c
        !          30420: prev sfio/sfputl.c
        !          30421: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfputl.c
        !          30422: done sfputl.o
        !          30423: make sfputs.o
        !          30424: make sfio/sfputs.c
        !          30425: attr perm
        !          30426: attr scan
        !          30427: prev sfio/sfhdr.h
        !          30428: done sfio/sfputs.c
        !          30429: prev sfio/sfputs.c
        !          30430: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfputs.c
        !          30431: done sfputs.o
        !          30432: make sfputu.o
        !          30433: make sfio/sfputu.c
        !          30434: attr perm
        !          30435: attr scan
        !          30436: prev sfio/sfhdr.h
        !          30437: done sfio/sfputu.c
        !          30438: prev sfio/sfputu.c
        !          30439: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfputu.c
        !          30440: done sfputu.o
        !          30441: make sfread.o
        !          30442: make sfio/sfread.c
        !          30443: attr perm
        !          30444: attr scan
        !          30445: prev sfio/sfhdr.h
        !          30446: done sfio/sfread.c
        !          30447: prev sfio/sfread.c
        !          30448: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfread.c
        !          30449: done sfread.o
        !          30450: make sfscanf.o
        !          30451: make sfio/sfscanf.c
        !          30452: attr perm
        !          30453: attr scan
        !          30454: prev sfio/sfhdr.h
        !          30455: done sfio/sfscanf.c
        !          30456: prev sfio/sfscanf.c
        !          30457: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfscanf.c
        !          30458: done sfscanf.o
        !          30459: make sfseek.o
        !          30460: make sfio/sfseek.c
        !          30461: attr perm
        !          30462: attr scan
        !          30463: prev sfio/sfhdr.h
        !          30464: done sfio/sfseek.c
        !          30465: prev sfio/sfseek.c
        !          30466: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfseek.c
        !          30467: done sfseek.o
        !          30468: make sfsetbuf.o
        !          30469: make sfio/sfsetbuf.c
        !          30470: attr perm
        !          30471: attr scan
        !          30472: prev fsinfo.h
        !          30473: prev sfio/sfhdr.h
        !          30474: done sfio/sfsetbuf.c
        !          30475: prev sfio/sfsetbuf.c
        !          30476: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfsetbuf.c
        !          30477: done sfsetbuf.o
        !          30478: make sfsetdisc.o
        !          30479: make sfio/sfsetdisc.c
        !          30480: attr perm
        !          30481: attr scan
        !          30482: prev sfio/sfhdr.h
        !          30483: done sfio/sfsetdisc.c
        !          30484: prev sfio/sfsetdisc.c
        !          30485: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfsetdisc.c
        !          30486: done sfsetdisc.o
        !          30487: make sfset.o
        !          30488: make sfio/sfset.c
        !          30489: attr perm
        !          30490: attr scan
        !          30491: prev sfio/sfhdr.h
        !          30492: done sfio/sfset.c
        !          30493: prev sfio/sfset.c
        !          30494: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfset.c
        !          30495: done sfset.o
        !          30496: make sfstack.o
        !          30497: make sfio/sfstack.c
        !          30498: attr perm
        !          30499: attr scan
        !          30500: prev sfio/sfhdr.h
        !          30501: done sfio/sfstack.c
        !          30502: prev sfio/sfstack.c
        !          30503: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfstack.c
        !          30504: done sfstack.o
        !          30505: make sfstrtod.o
        !          30506: make sfio/sfstrtod.c
        !          30507: attr perm
        !          30508: attr scan
        !          30509: prev sfio/sfhdr.h
        !          30510: done sfio/sfstrtod.c
        !          30511: prev sfio/sfstrtod.c
        !          30512: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfstrtod.c
        !          30513: done sfstrtod.o
        !          30514: make sfsync.o
        !          30515: make sfio/sfsync.c
        !          30516: attr perm
        !          30517: attr scan
        !          30518: prev sfio/sfhdr.h
        !          30519: done sfio/sfsync.c
        !          30520: prev sfio/sfsync.c
        !          30521: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfsync.c
        !          30522: done sfsync.o
        !          30523: make sftable.o
        !          30524: make sfio/sftable.c
        !          30525: attr perm
        !          30526: attr scan
        !          30527: prev sfio/sfhdr.h
        !          30528: done sfio/sftable.c
        !          30529: prev sfio/sftable.c
        !          30530: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sftable.c
        !          30531: done sftable.o
        !          30532: make sftell.o
        !          30533: make sfio/sftell.c
        !          30534: attr perm
        !          30535: attr scan
        !          30536: prev sfio/sfhdr.h
        !          30537: done sfio/sftell.c
        !          30538: prev sfio/sftell.c
        !          30539: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sftell.c
        !          30540: done sftell.o
        !          30541: make sftmpfile.o
        !          30542: make sfio/sftmpfile.c
        !          30543: attr perm
        !          30544: attr scan
        !          30545: prev sfio/sfhdr.h
        !          30546: done sfio/sftmpfile.c
        !          30547: prev sfio/sftmpfile.c
        !          30548: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sftmpfile.c
        !          30549: done sftmpfile.o
        !          30550: make sfungetc.o
        !          30551: make sfio/sfungetc.c
        !          30552: attr perm
        !          30553: attr scan
        !          30554: prev sfio/sfhdr.h
        !          30555: done sfio/sfungetc.c
        !          30556: prev sfio/sfungetc.c
        !          30557: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfungetc.c
        !          30558: done sfungetc.o
        !          30559: make sfvprintf.o
        !          30560: make sfio/sfvprintf.c
        !          30561: attr perm
        !          30562: attr scan
        !          30563: prev sfio/sfhdr.h
        !          30564: done sfio/sfvprintf.c
        !          30565: prev sfio/sfvprintf.c
        !          30566: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfvprintf.c
        !          30567: done sfvprintf.o
        !          30568: make sfvscanf.o
        !          30569: make sfio/sfvscanf.c
        !          30570: attr perm
        !          30571: attr scan
        !          30572: prev sfio/sfhdr.h
        !          30573: done sfio/sfvscanf.c
        !          30574: prev sfio/sfvscanf.c
        !          30575: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfvscanf.c
        !          30576: done sfvscanf.o
        !          30577: make sfwrite.o
        !          30578: make sfio/sfwrite.c
        !          30579: attr perm
        !          30580: attr scan
        !          30581: prev sfio/sfhdr.h
        !          30582: done sfio/sfwrite.c
        !          30583: prev sfio/sfwrite.c
        !          30584: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/sfwrite.c
        !          30585: done sfwrite.o
        !          30586: make _sfclearerr.o
        !          30587: make sfio/_sfclearerr.c
        !          30588: attr perm
        !          30589: attr scan
        !          30590: make sfio/_sfhdr.h
        !          30591: attr perm
        !          30592: attr scan
        !          30593: attr impl
        !          30594: prev sfio/sfhdr.h
        !          30595: done sfio/_sfhdr.h
        !          30596: done sfio/_sfclearerr.c
        !          30597: prev sfio/_sfclearerr.c
        !          30598: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/_sfclearerr.c
        !          30599: done _sfclearerr.o
        !          30600: make _sffileno.o
        !          30601: make sfio/_sffileno.c
        !          30602: attr perm
        !          30603: attr scan
        !          30604: prev sfio/_sfhdr.h
        !          30605: done sfio/_sffileno.c
        !          30606: prev sfio/_sffileno.c
        !          30607: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/_sffileno.c
        !          30608: done _sffileno.o
        !          30609: make _sforigin.o
        !          30610: make sfio/_sforigin.c
        !          30611: attr perm
        !          30612: attr scan
        !          30613: prev sfio/_sfhdr.h
        !          30614: done sfio/_sforigin.c
        !          30615: prev sfio/_sforigin.c
        !          30616: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/_sforigin.c
        !          30617: done _sforigin.o
        !          30618: make _sfputl.o
        !          30619: make sfio/_sfputl.c
        !          30620: attr perm
        !          30621: attr scan
        !          30622: prev sfio/_sfhdr.h
        !          30623: done sfio/_sfputl.c
        !          30624: prev sfio/_sfputl.c
        !          30625: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/_sfputl.c
        !          30626: done _sfputl.o
        !          30627: make _sftmp.o
        !          30628: make sfio/_sftmp.c
        !          30629: attr perm
        !          30630: attr scan
        !          30631: prev sfio/_sfhdr.h
        !          30632: done sfio/_sftmp.c
        !          30633: prev sfio/_sftmp.c
        !          30634: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/_sftmp.c
        !          30635: done _sftmp.o
        !          30636: make _sfecvt.o
        !          30637: make sfio/_sfecvt.c
        !          30638: attr perm
        !          30639: attr scan
        !          30640: prev sfio/_sfhdr.h
        !          30641: done sfio/_sfecvt.c
        !          30642: prev sfio/_sfecvt.c
        !          30643: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/_sfecvt.c
        !          30644: done _sfecvt.o
        !          30645: make _sfgetc.o
        !          30646: make sfio/_sfgetc.c
        !          30647: attr perm
        !          30648: attr scan
        !          30649: prev sfio/_sfhdr.h
        !          30650: done sfio/_sfgetc.c
        !          30651: prev sfio/_sfgetc.c
        !          30652: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/_sfgetc.c
        !          30653: done _sfgetc.o
        !          30654: make _sfpeek.o
        !          30655: make sfio/_sfpeek.c
        !          30656: attr perm
        !          30657: attr scan
        !          30658: prev sfio/_sfhdr.h
        !          30659: done sfio/_sfpeek.c
        !          30660: prev sfio/_sfpeek.c
        !          30661: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/_sfpeek.c
        !          30662: done _sfpeek.o
        !          30663: make _sfputu.o
        !          30664: make sfio/_sfputu.c
        !          30665: attr perm
        !          30666: attr scan
        !          30667: prev sfio/_sfhdr.h
        !          30668: done sfio/_sfputu.c
        !          30669: prev sfio/_sfputu.c
        !          30670: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/_sfputu.c
        !          30671: done _sfputu.o
        !          30672: make _sfulen.o
        !          30673: make sfio/_sfulen.c
        !          30674: attr perm
        !          30675: attr scan
        !          30676: prev sfio/_sfhdr.h
        !          30677: done sfio/_sfulen.c
        !          30678: prev sfio/_sfulen.c
        !          30679: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/_sfulen.c
        !          30680: done _sfulen.o
        !          30681: make _sfeof.o
        !          30682: make sfio/_sfeof.c
        !          30683: attr perm
        !          30684: attr scan
        !          30685: prev sfio/_sfhdr.h
        !          30686: done sfio/_sfeof.c
        !          30687: prev sfio/_sfeof.c
        !          30688: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/_sfeof.c
        !          30689: done _sfeof.o
        !          30690: make _sfgetl.o
        !          30691: make sfio/_sfgetl.c
        !          30692: attr perm
        !          30693: attr scan
        !          30694: prev sfio/_sfhdr.h
        !          30695: done sfio/_sfgetl.c
        !          30696: prev sfio/_sfgetl.c
        !          30697: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/_sfgetl.c
        !          30698: done _sfgetl.o
        !          30699: make _sfpushed.o
        !          30700: make sfio/_sfpushed.c
        !          30701: attr perm
        !          30702: attr scan
        !          30703: prev sfio/_sfhdr.h
        !          30704: done sfio/_sfpushed.c
        !          30705: prev sfio/_sfpushed.c
        !          30706: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/_sfpushed.c
        !          30707: done _sfpushed.o
        !          30708: make _sfslen.o
        !          30709: make sfio/_sfslen.c
        !          30710: attr perm
        !          30711: attr scan
        !          30712: prev sfio/_sfhdr.h
        !          30713: done sfio/_sfslen.c
        !          30714: prev sfio/_sfslen.c
        !          30715: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/_sfslen.c
        !          30716: done _sfslen.o
        !          30717: make _sferror.o
        !          30718: make sfio/_sferror.c
        !          30719: attr perm
        !          30720: attr scan
        !          30721: prev sfio/_sfhdr.h
        !          30722: done sfio/_sferror.c
        !          30723: prev sfio/_sferror.c
        !          30724: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/_sferror.c
        !          30725: done _sferror.o
        !          30726: make _sfgetu.o
        !          30727: make sfio/_sfgetu.c
        !          30728: attr perm
        !          30729: attr scan
        !          30730: prev sfio/_sfhdr.h
        !          30731: done sfio/_sfgetu.c
        !          30732: prev sfio/_sfgetu.c
        !          30733: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/_sfgetu.c
        !          30734: done _sfgetu.o
        !          30735: make _sfputc.o
        !          30736: make sfio/_sfputc.c
        !          30737: attr perm
        !          30738: attr scan
        !          30739: prev sfio/_sfhdr.h
        !          30740: done sfio/_sfputc.c
        !          30741: prev sfio/_sfputc.c
        !          30742: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/_sfputc.c
        !          30743: done _sfputc.o
        !          30744: make _sffcvt.o
        !          30745: make sfio/_sffcvt.c
        !          30746: attr perm
        !          30747: attr scan
        !          30748: prev sfio/_sfhdr.h
        !          30749: done sfio/_sffcvt.c
        !          30750: prev sfio/_sffcvt.c
        !          30751: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/_sffcvt.c
        !          30752: done _sffcvt.o
        !          30753: make _sfputd.o
        !          30754: make sfio/_sfputd.c
        !          30755: attr perm
        !          30756: attr scan
        !          30757: prev sfio/_sfhdr.h
        !          30758: done sfio/_sfputd.c
        !          30759: prev sfio/_sfputd.c
        !          30760: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/_sfputd.c
        !          30761: done _sfputd.o
        !          30762: make _sfsync.o
        !          30763: make sfio/_sfsync.c
        !          30764: attr perm
        !          30765: attr scan
        !          30766: prev sfio/_sfhdr.h
        !          30767: done sfio/_sfsync.c
        !          30768: prev sfio/_sfsync.c
        !          30769: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c sfio/_sfsync.c
        !          30770: done _sfsync.o
        !          30771: make stdgets.o
        !          30772: make stdio/stdgets.c
        !          30773: attr perm
        !          30774: attr scan
        !          30775: prev include/stdio.h
        !          30776: prev sfio/sfhdr.h
        !          30777: done stdio/stdgets.c
        !          30778: prev stdio/stdgets.c
        !          30779: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c stdio/stdgets.c
        !          30780: done stdgets.o
        !          30781: make stdprintf.o
        !          30782: make stdio/stdprintf.c
        !          30783: attr perm
        !          30784: attr scan
        !          30785: prev include/stdio.h
        !          30786: prev sfio/sfhdr.h
        !          30787: done stdio/stdprintf.c
        !          30788: prev stdio/stdprintf.c
        !          30789: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c stdio/stdprintf.c
        !          30790: done stdprintf.o
        !          30791: make stdscanf.o
        !          30792: make stdio/stdscanf.c
        !          30793: attr perm
        !          30794: attr scan
        !          30795: prev include/stdio.h
        !          30796: prev sfio/sfhdr.h
        !          30797: done stdio/stdscanf.c
        !          30798: prev stdio/stdscanf.c
        !          30799: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c stdio/stdscanf.c
        !          30800: done stdscanf.o
        !          30801: make stdsetvbuf.o
        !          30802: make stdio/stdsetvbuf.c
        !          30803: attr perm
        !          30804: attr scan
        !          30805: prev include/stdio.h
        !          30806: prev sfio/sfhdr.h
        !          30807: done stdio/stdsetvbuf.c
        !          30808: prev stdio/stdsetvbuf.c
        !          30809: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c stdio/stdsetvbuf.c
        !          30810: done stdsetvbuf.o
        !          30811: make stdsprintf.o
        !          30812: make stdio/stdsprintf.c
        !          30813: attr perm
        !          30814: attr scan
        !          30815: prev include/stdio.h
        !          30816: prev sfio/sfhdr.h
        !          30817: done stdio/stdsprintf.c
        !          30818: prev stdio/stdsprintf.c
        !          30819: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c stdio/stdsprintf.c
        !          30820: done stdsprintf.o
        !          30821: make stdvsprintf.o
        !          30822: make stdio/stdvsprintf.c
        !          30823: attr perm
        !          30824: attr scan
        !          30825: prev sfio/sfhdr.h
        !          30826: done stdio/stdvsprintf.c
        !          30827: prev stdio/stdvsprintf.c
        !          30828: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c stdio/stdvsprintf.c
        !          30829: done stdvsprintf.o
        !          30830: make stdvsscanf.o
        !          30831: make stdio/stdvsscanf.c
        !          30832: attr perm
        !          30833: attr scan
        !          30834: prev sfio/sfhdr.h
        !          30835: done stdio/stdvsscanf.c
        !          30836: prev stdio/stdvsscanf.c
        !          30837: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c stdio/stdvsscanf.c
        !          30838: done stdvsscanf.o
        !          30839: make sprintf.o
        !          30840: make stdio/sprintf.c
        !          30841: attr perm
        !          30842: attr scan
        !          30843: prev stdio/stdsprintf.c
        !          30844: prev include/stdio.h
        !          30845: prev sfio/sfhdr.h
        !          30846: done stdio/sprintf.c
        !          30847: prev stdio/sprintf.c
        !          30848: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c stdio/sprintf.c
        !          30849: done sprintf.o
        !          30850: make vsprintf.o
        !          30851: make stdio/vsprintf.c
        !          30852: attr perm
        !          30853: attr scan
        !          30854: prev stdio/stdvsprintf.c
        !          30855: prev include/stdio.h
        !          30856: prev sfio/sfhdr.h
        !          30857: done stdio/vsprintf.c
        !          30858: prev stdio/vsprintf.c
        !          30859: exec $CC $CCFLAGS -I. -Isfio -Iinclude "$LIBX" -c stdio/vsprintf.c
        !          30860: done vsprintf.o
        !          30861: exec $AR cr libx.a opendir.o readdir.o rewinddir.o seekdir.o telldir.o getcwd.o setcwd.o getshell.o hashalloc.o hashdump.o hashfree.o hashlook.o hashscan.o hashsize.o hashwalk.o memhash.o memsum.o strhash.o strsum.o cvtatoe.o cvtetoa.o chresc.o ctoi.o streval.o strmatch.o strcopy.o strmode.o stresc.o stropt.o strtape.o tok.o pathaccess.o pathcanon.o pathcheck.o pathpath.o pathkey.o pathprobe.o pathtemp.o cmdargs.o fs3d.o ftwalk.o perror.o putenv.o calloc.o malloc.o getnamval.o optget.o hsort.o query.o error.o liberror.o strerror.o strsignal.o fmtelapsed.o fmtls.o fmtmode.o fmtperm.o fmtuid.o fmtgid.o strelapsed.o strperm.o struid.o strgid.o stack.o stak.o memswap.o gethalf.o getlong.o puthalf.o putlong.o fgetline.o sigcrit.o sigunblock.o cmdopen.o cmdclose.o cmdrun.o cmdwait.o cmdkill.o recomp.o reerror.o reexec.o resub.o tmdate.o tmfix.o tmform.o tmgoff.o tminit.o tmleap.o tmlex.o tmmake.o tmpoff.o tmtime.o tmtype.o tmword.o tmzone.o vecargs.o vecfile.o vecfree.o vecload.o vecstring.o getsymlink.o putsymlink.o univdata.o getuniv.o setuniv.o winsize.o fclex.o sigdata.o touch.o lpstat.o memcmp.o memcpy.o memdup.o memset.o mkdir.o rmdir.o remove.o rename.o link.o unlink.o strtok.o strspn.o strpbrk.o strdup.o strchr.o strrchr.o strtod.o strtol.o strton.o sigsetmask.o mktemp.o tmpnam.o vfork.o killpg.o lstat.o readlink.o symlink.o setpgid.o atexit.o getdents.o getwd.o copy.o dup2.o errno.o sgetl.o sputl.o getpreroot.o ispreroot.o realopen.o setpreroot.o mount.o popen.o system.o iblocks.o modedata.o tmdata.o sfclose.o sfclrlock.o sfcvt.o sfdlen.o sfdopen.o sfexcept.o sfextern.o sffilbuf.o sfflsbuf.o sfgetd.o sfgetl.o sfgets.o sfgetu.o sfllen.o sfmode.o sfmove.o sfnew.o sfnotify.o sfnputc.o sfopen.o sfpeek.o sfpool.o sfpopen.o sfprintf.o sfputd.o sfputl.o sfputs.o sfputu.o sfread.o sfscanf.o sfseek.o sfsetbuf.o sfsetdisc.o sfset.o sfstack.o sfstrtod.o sfsync.o sftable.o sftell.o sftmpfile.o sfungetc.o sfvprintf.o sfvscanf.o sfwrite.o _sfclearerr.o _sffileno.o _sforigin.o _sfputl.o _sftmp.o _sfecvt.o _sfgetc.o _sfpeek.o _sfputu.o _sfulen.o _sfeof.o _sfgetl.o _sfpushed.o _sfslen.o _sferror.o _sfgetu.o _sfputc.o _sffcvt.o _sfputd.o _sfsync.o stdgets.o stdprintf.o stdscanf.o stdsetvbuf.o stdsprintf.o stdvsprintf.o stdvsscanf.o sprintf.o vsprintf.o
        !          30862: exec (ranlib libx.a) >/dev/null 2>&1 || true
        !          30863: done libx.a
        !          30864: prev mkhdr
        !          30865: prev genhdr
        !          30866: done all
        !          30867: make $INSTALLROOT/lib
        !          30868: exec if         test ! -d $INSTALLROOT/lib
        !          30869: .... then      rm -rf $INSTALLROOT/lib && mkdir  $INSTALLROOT/lib                                  || { rm -rf $INSTALLROOT && mkdir  $INSTALLROOT && mkdir  $INSTALLROOT/lib                                      ;} || true
        !          30870: .... fi
        !          30871: done $INSTALLROOT/lib
        !          30872: make $INSTALLROOT/lib/libx.a
        !          30873: attr arch
        !          30874: prev libx.a
        !          30875: exec { cp libx.a $INSTALLROOT/lib/libx.a 2>/dev/null                               ;} || true
        !          30876: exec (ranlib $INSTALLROOT/lib/libx.a) >/dev/null 2>&1 || true
        !          30877: done $INSTALLROOT/lib/libx.a
        !          30878: make $INSTALLROOT/man/man3
        !          30879: exec if         test ! -d $INSTALLROOT/man/man3
        !          30880: .... then      rm -rf $INSTALLROOT/man/man3 && mkdir  $INSTALLROOT/man/man3                                || { rm -rf $INSTALLROOT/man && mkdir  $INSTALLROOT/man && mkdir  $INSTALLROOT/man/man3                                 ;} || true
        !          30881: .... fi
        !          30882: done $INSTALLROOT/man/man3
        !          30883: make $INSTALLROOT/man/man3/hash.3
        !          30884: make man/hash.3
        !          30885: attr perm
        !          30886: done man/hash.3
        !          30887: exec { cp man/hash.3 $INSTALLROOT/man/man3/hash.3 2>/dev/null                                      ;} || true
        !          30888: done $INSTALLROOT/man/man3/hash.3
        !          30889: make $INSTALLROOT/man/man3/ftwalk.3
        !          30890: make man/ftwalk.3
        !          30891: attr perm
        !          30892: done man/ftwalk.3
        !          30893: exec { cp man/ftwalk.3 $INSTALLROOT/man/man3/ftwalk.3 2>/dev/null                                  ;} || true
        !          30894: done $INSTALLROOT/man/man3/ftwalk.3
        !          30895: make $INSTALLROOT/man/man3/re.3
        !          30896: make man/re.3
        !          30897: attr perm
        !          30898: done man/re.3
        !          30899: exec { cp man/re.3 $INSTALLROOT/man/man3/re.3 2>/dev/null                                  ;} || true
        !          30900: done $INSTALLROOT/man/man3/re.3
        !          30901: make $INSTALLROOT/man/man3/sfio.3
        !          30902: make man/sfio.3
        !          30903: attr perm
        !          30904: done man/sfio.3
        !          30905: exec { cp man/sfio.3 $INSTALLROOT/man/man3/sfio.3 2>/dev/null                                      ;} || true
        !          30906: done $INSTALLROOT/man/man3/sfio.3
        !          30907: make $INSTALLROOT/man/man3/stak.3
        !          30908: make man/stak.3
        !          30909: attr perm
        !          30910: done man/stak.3
        !          30911: exec { cp man/stak.3 $INSTALLROOT/man/man3/stak.3 2>/dev/null                                      ;} || true
        !          30912: done $INSTALLROOT/man/man3/stak.3
        !          30913: make $INSTALLROOT/man/man3/tm.3
        !          30914: make man/tm.3
        !          30915: attr perm
        !          30916: done man/tm.3
        !          30917: exec { cp man/tm.3 $INSTALLROOT/man/man3/tm.3 2>/dev/null                                  ;} || true
        !          30918: done $INSTALLROOT/man/man3/tm.3
        !          30919: make $INSTALLROOT/include
        !          30920: exec if         test ! -d $INSTALLROOT/include
        !          30921: .... then      rm -rf $INSTALLROOT/include && mkdir  $INSTALLROOT/include                                  || { rm -rf $INSTALLROOT && mkdir  $INSTALLROOT && mkdir  $INSTALLROOT/include                                  ;} || true
        !          30922: .... fi
        !          30923: done $INSTALLROOT/include
        !          30924: make $INSTALLROOT/include/error.h
        !          30925: prev include/error.h
        !          30926: exec { cp include/error.h $INSTALLROOT/include/error.h 2>/dev/null                                 ;} || true
        !          30927: done $INSTALLROOT/include/error.h
        !          30928: make $INSTALLROOT/include/ftwalk.h
        !          30929: prev include/ftwalk.h
        !          30930: exec { cp include/ftwalk.h $INSTALLROOT/include/ftwalk.h 2>/dev/null                               ;} || true
        !          30931: done $INSTALLROOT/include/ftwalk.h
        !          30932: make $INSTALLROOT/include/hash.h
        !          30933: prev include/hash.h
        !          30934: exec { cp include/hash.h $INSTALLROOT/include/hash.h 2>/dev/null                                   ;} || true
        !          30935: done $INSTALLROOT/include/hash.h
        !          30936: make $INSTALLROOT/include/hashpart.h
        !          30937: exec { cp include/hashpart.h $INSTALLROOT/include/hashpart.h 2>/dev/null                                   ;} || true
        !          30938: done $INSTALLROOT/include/hashpart.h
        !          30939: make $INSTALLROOT/include/ls.h
        !          30940: exec { cp include/ls.h $INSTALLROOT/include/ls.h 2>/dev/null                               ;} || true
        !          30941: done $INSTALLROOT/include/ls.h
        !          30942: make $INSTALLROOT/include/namval.h
        !          30943: prev include/namval.h
        !          30944: exec { cp include/namval.h $INSTALLROOT/include/namval.h 2>/dev/null                               ;} || true
        !          30945: done $INSTALLROOT/include/namval.h
        !          30946: make $INSTALLROOT/include/option.h
        !          30947: exec { cp include/option.h $INSTALLROOT/include/option.h 2>/dev/null                               ;} || true
        !          30948: done $INSTALLROOT/include/option.h
        !          30949: make $INSTALLROOT/include/re.h
        !          30950: prev include/re.h
        !          30951: exec { cp include/re.h $INSTALLROOT/include/re.h 2>/dev/null                               ;} || true
        !          30952: done $INSTALLROOT/include/re.h
        !          30953: make $INSTALLROOT/include/sfio.h
        !          30954: exec { cp include/sfio.h $INSTALLROOT/include/sfio.h 2>/dev/null                                   ;} || true
        !          30955: done $INSTALLROOT/include/sfio.h
        !          30956: make $INSTALLROOT/include/stack.h
        !          30957: prev include/stack.h
        !          30958: exec { cp include/stack.h $INSTALLROOT/include/stack.h 2>/dev/null                                 ;} || true
        !          30959: done $INSTALLROOT/include/stack.h
        !          30960: make $INSTALLROOT/include/stak.h
        !          30961: prev include/stak.h
        !          30962: exec { cp include/stak.h $INSTALLROOT/include/stak.h 2>/dev/null                                   ;} || true
        !          30963: done $INSTALLROOT/include/stak.h
        !          30964: make $INSTALLROOT/include/stdio.h
        !          30965: prev include/stdio.h
        !          30966: exec { cp include/stdio.h $INSTALLROOT/include/stdio.h 2>/dev/null                                 ;} || true
        !          30967: done $INSTALLROOT/include/stdio.h
        !          30968: make $INSTALLROOT/include/swap.h
        !          30969: prev include/swap.h
        !          30970: exec { cp include/swap.h $INSTALLROOT/include/swap.h 2>/dev/null                                   ;} || true
        !          30971: done $INSTALLROOT/include/swap.h
        !          30972: make $INSTALLROOT/include/tar.h
        !          30973: make include/tar.h
        !          30974: attr perm
        !          30975: done include/tar.h
        !          30976: exec { cp include/tar.h $INSTALLROOT/include/tar.h 2>/dev/null                                     ;} || true
        !          30977: done $INSTALLROOT/include/tar.h
        !          30978: make $INSTALLROOT/include/tm.h
        !          30979: prev include/tm.h
        !          30980: exec { cp include/tm.h $INSTALLROOT/include/tm.h 2>/dev/null                               ;} || true
        !          30981: done $INSTALLROOT/include/tm.h
        !          30982: make $INSTALLROOT/include/align.h
        !          30983: make align.h
        !          30984: prev mkhdr
        !          30985: prev genhdr
        !          30986: exec mkhdr align " genhdr" "$CC" $CCFLAGS   > align.h
        !          30987: done align.h
        !          30988: exec { cp align.h $INSTALLROOT/include/align.h 2>/dev/null                                 ;} || true
        !          30989: done $INSTALLROOT/include/align.h
        !          30990: make $INSTALLROOT/include/dirent.h
        !          30991: prev dirent.h
        !          30992: exec { cp dirent.h $INSTALLROOT/include/dirent.h 2>/dev/null                               ;} || true
        !          30993: done $INSTALLROOT/include/dirent.h
        !          30994: make $INSTALLROOT/include/fsinfo.h
        !          30995: prev fsinfo.h
        !          30996: exec { cp fsinfo.h $INSTALLROOT/include/fsinfo.h 2>/dev/null                               ;} || true
        !          30997: done $INSTALLROOT/include/fsinfo.h
        !          30998: make $INSTALLROOT/include/limits.h
        !          30999: prev limits.h
        !          31000: exec { cp limits.h $INSTALLROOT/include/limits.h 2>/dev/null                               ;} || true
        !          31001: done $INSTALLROOT/include/limits.h
        !          31002: make $INSTALLROOT/include/sigdata.h
        !          31003: prev sigdata.h
        !          31004: exec { cp sigdata.h $INSTALLROOT/include/sigdata.h 2>/dev/null                                     ;} || true
        !          31005: done $INSTALLROOT/include/sigdata.h
        !          31006: make $INSTALLROOT/include/lcldirent.h
        !          31007: prev lcldirent.h
        !          31008: exec { cp lcldirent.h $INSTALLROOT/include/lcldirent.h 2>/dev/null                                 ;} || true
        !          31009: done $INSTALLROOT/include/lcldirent.h
        !          31010: make $INSTALLROOT/include/lcllimits.h
        !          31011: prev lcllimits.h
        !          31012: exec { cp lcllimits.h $INSTALLROOT/include/lcllimits.h 2>/dev/null                                 ;} || true
        !          31013: done $INSTALLROOT/include/lcllimits.h
        !          31014: make $INSTALLROOT/include/lclparam.h
        !          31015: prev lclparam.h
        !          31016: exec { cp lclparam.h $INSTALLROOT/include/lclparam.h 2>/dev/null                                   ;} || true
        !          31017: done $INSTALLROOT/include/lclparam.h
        !          31018: make $INSTALLROOT/include/lclstdio.h
        !          31019: prev lclstdio.h
        !          31020: exec { cp lclstdio.h $INSTALLROOT/include/lclstdio.h 2>/dev/null                                   ;} || true
        !          31021: done $INSTALLROOT/include/lclstdio.h
        !          31022: make $INSTALLROOT/include/preroot.h
        !          31023: prev preroot.h
        !          31024: exec { cp preroot.h $INSTALLROOT/include/preroot.h 2>/dev/null                                     ;} || true
        !          31025: done $INSTALLROOT/include/preroot.h
        !          31026: make $INSTALLROOT/include/sig.h
        !          31027: prev sig.h
        !          31028: exec { cp sig.h $INSTALLROOT/include/sig.h 2>/dev/null                                     ;} || true
        !          31029: done $INSTALLROOT/include/sig.h
        !          31030: make $INSTALLROOT/include/ttyinfo.h
        !          31031: prev ttyinfo.h
        !          31032: exec { cp ttyinfo.h $INSTALLROOT/include/ttyinfo.h 2>/dev/null                                     ;} || true
        !          31033: done $INSTALLROOT/include/ttyinfo.h
        !          31034: done install
        !          31035: 0707070000000000000000000000000000000000010000000000000000000001300000000000TRAILER!!!

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.