home *** CD-ROM | disk | FTP | other *** search
- /* CSAM_DSProc.c */
- /*
- * CSAM_DSProc.c
- * Copyright © 1992-93 Apple Computer Inc. All Rights Reserved.
- *
- * The CSAM Manager calls this function to process CSAM events.
- * The simple ones are handled immediately, while the complex
- * calls (those that require additional I/O operations) are
- * enqueued via DirParseCommon().
- */
- /*
- * Edit history
- * 5/27/93 MM kDirMapDNodeNumberToPathName call used the wrong
- * parameter block to return the NULL path.
- * 7/30/93 MM Redid the kDirMapDNodeNumberToPathName stuff.
- */
- #include "DTSSampleCSAM.h"
- #ifdef THINK_C
- #include <ASM.h>
- #endif
-
- pascal OSErr
- CSAM_DSProc(
- register DTSSampleCSAMInfoPtr infoPtr,
- register DirParamBlockPtr pb,
- Boolean async
- )
- {
- short refNum;
- register IconInfoPtr iconPtr;
- IconInfoPtr iconEnd;
- RStringPtr parts[1]; /* kDirMapDNodeNumberToPathName */
- unsigned short lengthOfPathName;
- #define PACK (PARAM.mapDNodeNumberToPathNamePB)
-
- #ifdef THINK_C
- /*
- * Under Think C, we must save and set up the A4 parameter value.
- * This module must exit at the end of the function.
- */
- asm {
- move.l a4,-(sp)
- move.l infoPtr,a0
- move.l OFFSET(DTSSampleCSAMInfo,originalA4)(a0),a4
- }
- #endif
- STATUS = noErr;
- /*
- * Look at the request code. Handle the simple requests here:
- * these cannot initiate additional I/O. The hard ones are
- * queued into the main CSAM handler.
- */
- switch (PARAM.header.reqCode) {
- case kDirGetDirectoryIcon:
- LogText('DCmd', "\pkDirGetDirectoryIcon");
- /*
- * Loop through the icon vector to find* the requested value. If the
- * loop succeeds, STATUS will be reset to noErr.
- */
- STATUS = kOCENoSuchIcon;
- iconEnd = &INFO.icons[kNumIcons];
- for (iconPtr = INFO.icons; iconPtr < iconEnd; iconPtr++) {
- if (iconPtr->iconType == PARAM.getDirectoryIconPB.iconType) {
- /*
- * If the user's buffer is too small, return an error and,
- * en-passant, the correct buffer size.
- * Otherwise, copy the icon to the user's buffer and return
- * the number of bytes we copied.
- */
- if (PARAM.getDirectoryIconPB.bufferSize < iconPtr->iconLength) {
- PARAM.getDirectoryIconPB.bufferSize = iconPtr->iconLength;
- STATUS = kOCEBufferTooSmall;
- }
- else {
- PARAM.getDirectoryIconPB.bufferSize = iconPtr->iconLength;
- BlockMove(
- *(iconPtr->iconData),
- PARAM.getDirectoryIconPB.iconBuffer,
- iconPtr->iconLength
- );
- STATUS = noErr;
- }
- break;
- }
- }
- goto ioComplete;
- case kDirGetDirectoryInfo:
- LogText('DCmd', "\pkDirGetDirectoryInfo");
- PARAM.getDirectoryInfoPB.features = kMyFeatures;
- goto ioComplete;
- case kDirAddDSAMDirectory:
- /*
- * kDirAddDSAMDirectory calls the memory manager, so it
- * must be called synchronously.
- */
- LogText('DCmd', "\pkDirAddDSAMDirectory");
- STATUS = (async) ? paramErr : AddCatalog(infoPtr, pb);
- goto ioComplete;
- case kDirRemoveDirectory:
- /*
- * kDirRemoveDirectory calls the memory manager, so it
- * must be called synchronously.
- */
- LogText('DCmd', "\pkDirRemoveDirectory");
- STATUS = (async) ? paramErr : RemoveCatalog(infoPtr, pb);
- goto ioComplete;
- case kDirMapPathNameToDNodeNumber:
- LogText('DCmd', "\pkDirMapPathNameToDNodeNumber");
- if (PARAM.mapPathNameToDNodeNumberPB.path != NULL)
- STATUS = kOCENoSuchDNode;
- else {
- PARAM.mapPathNameToDNodeNumberPB.dNodeNumber = kRootDNodeNumber;
- }
- goto ioComplete;
- case kDirMapDNodeNumberToPathName:
- LogText('DCmd', "\pkMapDNodeNumberToPathName");
- if (PARAM.mapDNodeNumberToPathNamePB.dNodeNumber != kRootDNodeNumber
- && PARAM.mapDNodeNumberToPathNamePB.dNodeNumber != kNULLDNodeNumber)
- STATUS = kOCENoSuchDNode;
- else {
- /*
- * Build a "null" packed path name.
- */
- lengthOfPathName = OCEPackedPathNameSize(parts, 0);
- #if DEBUG_LOG
- AuditStatusString(
- INFO.auditPtr,
- 'DNPn',
- lengthOfPathName,
- "\plengthOfPathName"
- );
- #endif
- /*
- * Note that this sequence is setup so that you can call
- * DirMapDNodeNumberToPathName with zero for lengthOfPathName
- * and NULL for the path, then allocate memory and re-call it
- * with non-zero, non-NULL, values.
- */
- if (lengthOfPathName > PACK.lengthOfPathName) {
- PACK.lengthOfPathName = lengthOfPathName;
- STATUS = kOCEMoreData;
- }
- else if (PACK.path == NULL)
- STATUS = paramErr;
- else {
- PACK.lengthOfPathName = lengthOfPathName;
- STATUS = OCEPackPathName(
- parts,
- 0,
- PACK.path,
- PACK.lengthOfPathName
- );
- LogStatus('DNPn', STATUS, "\pOCEPackPathName");
- }
- }
- goto ioComplete;
- case kDirGetDNodeAccessControlGet:
- LogText('DCmd', "\pkDirGetDNodeAccessControlGet");
- STATUS = GetRefNumFromRLI(
- infoPtr,
- PARAM.getDNodeAccessControlGetPB.pRLI,
- &refNum
- );
- goto ioComplete;
- case kDirGetAttributeAccessControlGet:
- LogText('DCmd', "\pkDirAttributeAccessControlGet+");
- /* Fall through */
- case kDirGetRecordAccessControlGet:
- LogText('DCmd', "\pkDirRecordAccessControlGet");
- STATUS = GetRefNumFromRLI(
- infoPtr,
- PARAM.getAttributeAccessControlGetPB.aRecord->rli,
- &refNum
- );
- /* goto ioComplete; */
- /*
- * The inline calls conclude here.
- */
- ioComplete:
- LogStatus('DSts', STATUS, "\pCSAM_DSProc @ ioComplete");
- if (pb->header.ioResult == ioBusy)
- LogStatus('DSts', pb->header.ioResult, "\pioResult == ioBusy?");
- CallCompletion((ParmBlkPtr) pb);
- break;
- default:
- /*
- * Call the hard stuff. These calls may initiate further I/O.
- * DirParseCommon returns ioBusy (== one) if it was called
- * asychronously and the request is pending. DirParseCommon
- * will call the user ioCompletion routine, if any.
- */
- DirParseCommon(infoPtr, pb, async);
- break;
- }
- LogStatus('DSts', STATUS, "\pCSAM_DSProc @ return");
- #ifdef THINK_C
- asm {
- move.l (sp)+,a4
- }
- #endif
- return (STATUS);
- #undef PATH
- }