Annotation of 43BSDReno/contrib/isode-beta/ftam2/ftam-dir.c, revision 1.1

1.1     ! root        1: /* ftam-dir.c - interactive initiator FTAM -- directory management */
        !             2: 
        !             3: #ifndef        lint
        !             4: static char *rcsid = "$Header: /f/osi/ftam2/RCS/ftam-dir.c,v 7.0 89/11/23 21:54:16 mrose Rel $";
        !             5: #endif
        !             6: 
        !             7: /* 
        !             8:  * $Header: /f/osi/ftam2/RCS/ftam-dir.c,v 7.0 89/11/23 21:54:16 mrose Rel $
        !             9:  *
        !            10:  *
        !            11:  * $Log:       ftam-dir.c,v $
        !            12:  * Revision 7.0  89/11/23  21:54:16  mrose
        !            13:  * Release 6.0
        !            14:  * 
        !            15:  */
        !            16: 
        !            17: /*
        !            18:  *                               NOTICE
        !            19:  *
        !            20:  *    Acquisition, use, and distribution of this module and related
        !            21:  *    materials are subject to the restrictions of a license agreement.
        !            22:  *    Consult the Preface in the User's Manual for the full terms of
        !            23:  *    this agreement.
        !            24:  *
        !            25:  */
        !            26: 
        !            27: 
        !            28: #include <stdio.h>
        !            29: #include "ftamuser.h"
        !            30: 
        !            31: /*    DATA */
        !            32: 
        !            33: #ifndef        BRIDGE
        !            34: static char *lcwd = NULL;
        !            35: #endif
        !            36: 
        !            37: 
        !            38: int    fdffnx ();
        !            39: 
        !            40: 
        !            41: #ifndef        SYS5
        !            42: char   *getcwd ();
        !            43: #endif
        !            44: 
        !            45: /*  */
        !            46: 
        !            47: #ifndef        BRIDGE
        !            48: int    f_lcd (vec)
        !            49: char  **vec;
        !            50: {
        !            51:     char   *cp,
        !            52:             cwd[MAXPATHLEN];
        !            53: 
        !            54:     if (*++vec == NULL)
        !            55:        cp = strdup (myhome);
        !            56:     else
        !            57:        if ((cp = xglob1val (*vec, 0)) == NULL)
        !            58:            return OK;
        !            59: 
        !            60:     if (chdir (cp) == NOTOK)
        !            61:        advise (cp, "unable to change to");
        !            62:     else {
        !            63:        if (lcwd)
        !            64:            free (lcwd);
        !            65: 
        !            66:        if (getcwd (cwd, MAXPATHLEN) && strcmp (cp, cwd))
        !            67: #ifdef apollo
        !            68:            printf ("/%s\n", lcwd = strdup (cwd));      /* network root */
        !            69: #else
        !            70:            printf ("%s\n", lcwd = strdup (cwd));
        !            71: #endif
        !            72:        else
        !            73:            lcwd = cp, cp = NULL;
        !            74:     }
        !            75: 
        !            76:     if (cp)
        !            77:        free (cp);
        !            78: 
        !            79:     return OK;
        !            80: }
        !            81: #endif
        !            82: 
        !            83: /*  */
        !            84: 
        !            85: int    f_cd (vec)
        !            86: char  **vec;
        !            87: {
        !            88:     int            silent;
        !            89:     char   *cp,
        !            90:            cwd[MAXPATHLEN];
        !            91: 
        !            92:     silent = strcmp (*vec, "sd") == 0;
        !            93: 
        !            94:     cp = *++vec;
        !            95: 
        !            96:     switch (realstore) {
        !            97:        case RFS_UNKNOWN: 
        !            98:            if (!silent)
        !            99:                advise (NULLCP, rs_unknown);
        !           100: #ifndef        BRIDGE
        !           101:            else
        !           102:                if (rcwd) {
        !           103:                    free (rcwd);
        !           104:                    rcwd = NULL;
        !           105:                }
        !           106: #endif
        !           107:            return OK;
        !           108: 
        !           109:        case RFS_UNIX: 
        !           110:            break;
        !           111: 
        !           112:        default: 
        !           113:            if (!silent)
        !           114:                advise (NULLCP, "%s", rs_support);
        !           115:            return OK;
        !           116:     }
        !           117: 
        !           118:     if (cp) {
        !           119:        if ((cp = xglob1val (cp, 1)) == NULL
        !           120:                || isdir (cp, cwd, silent) == NOTOK)
        !           121:            return OK;
        !           122: 
        !           123:        if (cwd[0]) {
        !           124:            free (cp);
        !           125:            cp = strdup (cwd);
        !           126:        }
        !           127:     }
        !           128: 
        !           129:     if (rcwd)
        !           130:        free (rcwd);
        !           131:     rcwd = cp;
        !           132: 
        !           133:     return OK;
        !           134: }
        !           135: 
        !           136: /*  */
        !           137: 
        !           138: int    isdir (dir, dp, silent)
        !           139: char   *dir,
        !           140:        *dp;
        !           141: int    silent;
        !           142: {
        !           143:     int            result;
        !           144:     struct FTAMgroup    ftgs;
        !           145:     register struct FTAMgroup  *ftg = &ftgs;
        !           146:     struct FTAMindication   ftis;
        !           147:     register struct FTAMindication *fti = &ftis;
        !           148:     struct vfsmap *vf = &vfs[VFS_FDF];
        !           149: 
        !           150:     result = OK;
        !           151:     if (dp)
        !           152:        *dp = NULL;
        !           153: 
        !           154:     if (!vf -> vf_oid || !(units & FUNIT_LIMITED))
        !           155:        return result;
        !           156: 
        !           157:     bzero ((char *) ftg, sizeof *ftg);
        !           158:     ftg -> ftg_flags |= FTG_BEGIN | FTG_END;
        !           159:     ftg -> ftg_threshold = 0;
        !           160: 
        !           161:     ftg -> ftg_flags |= FTG_SELECT;
        !           162:     {
        !           163:        register struct FTAMselect *ftse = &ftg -> ftg_select;
        !           164:        register struct FTAMattributes *fa = &ftse -> ftse_attrs;
        !           165: 
        !           166:        fa -> fa_present = FA_FILENAME;
        !           167:        fa -> fa_nfile = 0;
        !           168:        fa -> fa_files[fa -> fa_nfile++] = dir;
        !           169: 
        !           170:        ftse -> ftse_access = FA_PERM_READATTR;
        !           171:        FCINIT (&ftse -> ftse_conctl);
        !           172:     }
        !           173:     ftg -> ftg_threshold++;
        !           174: 
        !           175:     ftg -> ftg_flags |= FTG_RDATTR;
        !           176:     {
        !           177:        register struct FTAMreadattr   *ftra = &ftg -> ftg_readattr;
        !           178: 
        !           179:        ftra -> ftra_attrnames = FA_FILENAME | FA_CONTENTS;
        !           180:     }
        !           181:     ftg -> ftg_threshold++;
        !           182: 
        !           183:     ftg -> ftg_flags |= FTG_DESELECT;
        !           184:     ftg -> ftg_threshold++;
        !           185: 
        !           186:     if (FManageRequest (ftamfd, ftg, fti) == NOTOK) {
        !           187:        if (!silent)
        !           188:            ftam_advise (&fti -> fti_abort, "F-MANAGE.REQUEST");
        !           189:        return NOTOK;
        !           190:     }
        !           191: 
        !           192:     ftg = &fti -> fti_group;
        !           193: 
        !           194:     if (ftg -> ftg_flags & FTG_SELECT) {
        !           195:        register struct FTAMselect *ftse = &ftg -> ftg_select;
        !           196: 
        !           197:        if (!silent)
        !           198:            ftam_diag (ftse -> ftse_diags, ftse -> ftse_ndiag, 1,
        !           199:                        ftse -> ftse_action);
        !           200:        if (ftse -> ftse_state != FSTATE_SUCCESS)
        !           201:            goto you_lose;
        !           202:     }
        !           203: 
        !           204:     if (ftg -> ftg_flags & FTG_RDATTR) {
        !           205:        register struct FTAMreadattr   *ftra = &ftg -> ftg_readattr;
        !           206:        register struct FTAMattributes *fa = &ftra -> ftra_attrs;
        !           207: 
        !           208:        if (!silent)
        !           209:            ftam_diag (ftra -> ftra_diags, ftra -> ftra_ndiag, 1,
        !           210:                ftra -> ftra_action);
        !           211:        if (ftra -> ftra_action != FACTION_SUCCESS)
        !           212:            fa -> fa_present = 0;
        !           213: 
        !           214:        if ((fa -> fa_present & FA_FILENAME) && fa -> fa_nfile == 1 && dp)
        !           215:            (void) strcpy (dp, fa -> fa_files[0]);
        !           216: 
        !           217:        if (fa -> fa_present & FA_CONTENTS)
        !           218:            if (oid_cmp (vf -> vf_oid, fa -> fa_contents)) {
        !           219:                if (!silent)
        !           220:                    advise (NULLCP, "not a directory");
        !           221:                goto you_lose;
        !           222:            }
        !           223:            else
        !           224:                result = DONE;
        !           225:     }
        !           226: 
        !           227:     if (ftg -> ftg_flags & FTG_DESELECT) {
        !           228:        register struct FTAMdeselect   *ftde = &ftg -> ftg_deselect;
        !           229: 
        !           230:        if (!silent) {
        !           231:            ftam_diag (ftde -> ftde_diags, ftde -> ftde_ndiag, 1,
        !           232:                ftde -> ftde_action);
        !           233:            ftam_chrg (&ftde -> ftde_charges);
        !           234:        }
        !           235:     }
        !           236: 
        !           237:     FTGFREE (ftg);
        !           238:     return result;
        !           239: 
        !           240: you_lose: ;
        !           241:     FTGFREE (ftg);
        !           242:     return NOTOK;
        !           243: }
        !           244: 
        !           245: /*  */
        !           246: 
        !           247: /* ARGSUSED */
        !           248: 
        !           249: int    f_pwd (vec)
        !           250: char  **vec;
        !           251: {
        !           252: #ifndef        BRIDGE
        !           253:     char    cwd[MAXPATHLEN];
        !           254: 
        !           255:     if (lcwd == NULL)
        !           256:        lcwd = strdup (getcwd (cwd, MAXPATHLEN) ? cwd : ".");
        !           257: #ifdef apollo
        !           258:     printf ("local directory: /%s\n", lcwd);   /* network root */
        !           259: #else
        !           260:     printf ("local directory: %s\n", lcwd);
        !           261: #endif
        !           262: #endif
        !           263: 
        !           264:     if (rcwd)
        !           265: #ifndef        BRIDGE
        !           266:        printf ("virtual filestore directory: %s\n", rcwd);
        !           267: #else
        !           268:        (void) sprintf (ftam_error, "virtual filestore directory: %s\n", rcwd);
        !           269: #endif
        !           270: 
        !           271:     return OK;
        !           272: }
        !           273: 
        !           274: /*  */
        !           275: 
        !           276: char   *str2file (s)
        !           277: char   *s;
        !           278: {
        !           279:     register char  *bp;
        !           280:     static int  i = 0;
        !           281:     static char buffer1[BUFSIZ],
        !           282:                 buffer2[BUFSIZ];
        !           283: 
        !           284:     if (!rcwd)
        !           285:        return s;
        !           286: 
        !           287:     bp = (i++ % 2) ? buffer1 : buffer2;
        !           288: 
        !           289:     switch (realstore) {
        !           290:        case RFS_UNIX:
        !           291:            if (*s == '/' || *s == '~')
        !           292:                return s;
        !           293: 
        !           294: #ifdef apollo
        !           295:             if (strcmp (rcwd, "/") == 0 || strcmp (rcwd, "//") == 0)
        !           296:                (void) sprintf (bp, "%s%s", rcwd, s);
        !           297:             else
        !           298: #endif                
        !           299:            (void) sprintf (bp, "%s/%s", rcwd, s);
        !           300:            break;
        !           301: 
        !           302: #ifdef BRIDGE
        !           303:        default:
        !           304:            return s;
        !           305: #endif
        !           306:     }
        !           307: 
        !           308:     return bp;
        !           309: }

unix.superglobalmegacorp.com

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