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

1.1     ! root        1: /* ftamaccess2.c - FPM: respond to file access */
        !             2: 
        !             3: #ifndef        lint
        !             4: static char *rcsid = "$Header: /f/osi/ftam/RCS/ftamaccess2.c,v 7.0 89/11/23 21:53:21 mrose Rel $";
        !             5: #endif
        !             6: 
        !             7: /* 
        !             8:  * $Header: /f/osi/ftam/RCS/ftamaccess2.c,v 7.0 89/11/23 21:53:21 mrose Rel $
        !             9:  *
        !            10:  *
        !            11:  * $Log:       ftamaccess2.c,v $
        !            12:  * Revision 7.0  89/11/23  21:53:21  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: /* LINTLIBRARY */
        !            29: 
        !            30: #include <stdio.h>
        !            31: #include <signal.h>
        !            32: #include "fpkt.h"
        !            33: 
        !            34: /*    F-{LOCATE,ERASE}.RESPONSE */
        !            35: 
        !            36: int    FAccessResponse (sd, action, identity, diag, ndiag, fti)
        !            37: int    sd;
        !            38: int    action;
        !            39: struct FADUidentity *identity; /* F-LOCATE.RESPONSE only */
        !            40: struct FTAMdiagnostic diag[];
        !            41: int    ndiag;
        !            42: struct FTAMindication *fti;
        !            43: {
        !            44:     SBV            smask;
        !            45:     int     result;
        !            46:     register struct ftamblk *fsb;
        !            47: 
        !            48:     switch (action) {
        !            49:        case FACTION_SUCCESS: 
        !            50:        case FACTION_TRANS: 
        !            51:        case FACTION_PERM: 
        !            52:            break;
        !            53: 
        !            54:        default: 
        !            55:            return ftamlose (fti, FS_GEN_NOREASON, 0, NULLCP,
        !            56:                    "bad value for action parameter");
        !            57:     }
        !            58:     toomuchP (diag, ndiag, NFDIAG, "diagnostic");
        !            59:     missingP (fti);
        !            60: 
        !            61:     smask = sigioblock ();
        !            62: 
        !            63:     ftamPsig (fsb, sd);
        !            64: 
        !            65:     result = FAccessResponseAux (fsb, action, identity, diag, ndiag, fti);
        !            66: 
        !            67:     (void) sigiomask (smask);
        !            68: 
        !            69:     return result;
        !            70: }
        !            71: 
        !            72: /*  */
        !            73: 
        !            74: static int  FAccessResponseAux (fsb, action, identity, diag, ndiag, fti)
        !            75: register struct ftamblk *fsb;
        !            76: int    action;
        !            77: struct FADUidentity *identity;
        !            78: struct FTAMdiagnostic diag[];
        !            79: int    ndiag;
        !            80: struct FTAMindication *fti;
        !            81: {
        !            82:     int     result;
        !            83:     PE     pe;
        !            84:     struct PSAPindication   pis;
        !            85:     struct PSAPindication  *pi = &pis;
        !            86:     struct PSAPabort   *pa = &pi -> pi_abort;
        !            87:     register struct type_FTAM_PDU *pdu;
        !            88:     register struct type_FTAM_F__LOCATE__response *loc;
        !            89:     register struct type_FTAM_F__ERASE__response *era;
        !            90: 
        !            91:     if (fsb -> fsb_flags & FSB_INIT)
        !            92:        return ftamlose (fti, FS_GEN (fsb), 0, NULLCP, "not responder");
        !            93:     switch (fsb -> fsb_state) {
        !            94:        case FSB_LOCATE:
        !            95:            break;
        !            96: 
        !            97:        case FSB_ERASE:
        !            98:            if (identity)
        !            99:                return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
        !           100:                            "FADU identity parameter not allowed");
        !           101:            break;
        !           102: 
        !           103:        default:
        !           104:            return ftamlose (fti, FS_GEN (fsb), 0, NULLCP, "wrong state");
        !           105:     }
        !           106: 
        !           107:     pe = NULLPE;
        !           108:     if ((pdu = (struct type_FTAM_PDU *) calloc (1, sizeof *pdu)) == NULL) {
        !           109: no_mem: ;
        !           110:        (void) ftamlose (fti, FS_GEN (fsb), 1, NULLCP, "out of memory");
        !           111: out: ;
        !           112:        if (pe)
        !           113:            pe_free (pe);
        !           114:        if (pdu)
        !           115:            free_FTAM_PDU (pdu);
        !           116:        if (fti -> fti_abort.fta_action == FACTION_PERM)
        !           117:            freefsblk (fsb);
        !           118:        return NOTOK;
        !           119:     }
        !           120:     if (fsb -> fsb_state != FSB_LOCATE) {
        !           121:        pdu -> offset = type_FTAM_PDU_f__erase__response;
        !           122:        if ((era = (struct type_FTAM_F__ERASE__response *)
        !           123:                        calloc (1, sizeof *era)) == NULL)
        !           124:            goto no_mem;
        !           125:        pdu -> un.f__erase__response = era;
        !           126: 
        !           127:        if ((era -> action__result =
        !           128:                (struct type_FTAM_Action__Result *)
        !           129:                        calloc (1, sizeof *era -> action__result)) == NULL)
        !           130:            goto no_mem;
        !           131:        era -> action__result -> parm = action;
        !           132:        if (ndiag > 0
        !           133:                && (era -> diagnostic = diag2fpm (fsb, 0, diag, ndiag, fti))
        !           134:                        == NULL)
        !           135:            goto out;
        !           136:     }
        !           137:     else {
        !           138:        pdu -> offset = type_FTAM_PDU_f__locate__response;
        !           139:        if ((loc = (struct type_FTAM_F__LOCATE__response *)
        !           140:                        calloc (1, sizeof *loc)) == NULL)
        !           141:            goto no_mem;
        !           142:        pdu -> un.f__locate__response = loc;
        !           143: 
        !           144:        if ((loc -> action__result =
        !           145:                (struct type_FTAM_Action__Result *)
        !           146:                        calloc (1, sizeof *loc -> action__result)) == NULL)
        !           147:            goto no_mem;
        !           148:        loc -> action__result -> parm = action;
        !           149:        if (identity
        !           150:                && (loc -> file__access__data__unit__identity =
        !           151:                                faduid2fpm (fsb, identity, fti)) == NULL)
        !           152:            goto out;
        !           153:        if (ndiag > 0
        !           154:                && (loc -> diagnostic = diag2fpm (fsb, 0, diag, ndiag, fti))
        !           155:                        == NULL)
        !           156:            goto out;
        !           157:     }
        !           158: 
        !           159:     if (encode_FTAM_PDU (&pe, 1, 0, NULLCP, pdu) == NOTOK) {
        !           160:        (void) ftamlose (fti, FS_GEN (fsb), 1, NULLCP,
        !           161:                         "error encoding PDU: %s", PY_pepy);
        !           162:        goto out;
        !           163:     }
        !           164: 
        !           165:     pe -> pe_context = fsb -> fsb_id;
        !           166: 
        !           167:     fsbtrace (fsb, (fsb -> fsb_fd, "P-DATA.REQUEST",
        !           168:                    fsb -> fsb_state != FSB_LOCATE ? "F-LOCATE-response"
        !           169:                                        : "F-ERASE-response", pe, 0));
        !           170: 
        !           171:     result = PDataRequest (fsb -> fsb_fd, &pe, 1, pi);
        !           172: 
        !           173:     pe_free (pe);
        !           174:     pe = NULLPE;
        !           175:     free_FTAM_PDU (pdu);
        !           176:     pdu = NULL;
        !           177: 
        !           178:     if (result == NOTOK) {
        !           179:        (void) ps2ftamlose (fsb, fti, "PDataRequest", pa);
        !           180:        goto out;
        !           181:     }
        !           182: 
        !           183:     fsb -> fsb_state = FSB_DATAIDLE;
        !           184: 
        !           185:     return OK;
        !           186: }

unix.superglobalmegacorp.com

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