home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 January: Mac OS SDK / Dev.CD Jan 96 SDK / Dev.CD Jan 96 SDK1.toast / Development Kits (Disc 1) / AOCE / Development Tools / Sample Code / Catalog Service Access Module / DTS Sample CSAM / Src / ThinkCallCompletion.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-03  |  1.5 KB  |  52 lines  |  [TEXT/KAHL]

  1. /*                                ThinkCallCompletion.c                            */
  2. /*
  3.  * ThinkCallCompletion.c
  4.  * Copyright © 1992-93 Apple Computer Inc. All Rights Reserved.
  5.  *
  6.  * This function is called by the driver when the request
  7.  * completes. If the user has defined a completion routine,
  8.  * it restores A5 and calls the user's routine as if it
  9.  * were defined as
  10.  *        void
  11.  *        UserCompletion(
  12.  *            ParmBlkPtr            pb
  13.  *        );
  14.  * For convenience, the ioResult code is in D0, and the condition
  15.  * codes are set on the ioResult.
  16.  *
  17.  * This file is compiled by Think C. See MPWCallCompletion.a
  18.  * for the original (definitive) source
  19.  *
  20.  * Author:        Martin Minow
  21.  *                Apple Computer Inc.
  22.  *                Cupertino, CA, USA
  23.  * InterNet:        minow@apple.com
  24.  * AppleLink:    MINOW
  25.  */
  26. #include "DTSSampleCSAM.h"
  27.  
  28. typedef struct AuthDirParamBlock {
  29.     AuthDirParamHeader
  30. } AuthDirParamBlock;
  31.  
  32. void                CallCompletion(
  33.         ParmBlkPtr            pb
  34.     )
  35. {
  36.         asm {
  37.                 move.l        pb,a0                ; a0 -> parameter block
  38.                 move.w        AuthDirParamBlock.ioResult(a0),d0        ; d0 == ioResult
  39.                 move.l        AuthDirParamBlock.ioCompletion(a0),d1    ; User's completion
  40.                 beq.s        @exit                ; Exit if none
  41.                 move.l        a5,-(sp)            ; Save current A5
  42.                 move.l        AuthDirParamBlock.saveA5(a0),a5            ; Restore user A5
  43.                 link        a6,#0                ; Establish a stack frame context
  44.                 move.l        a0,-(sp)            ; Push call parameter
  45.                 move.l        d1,a1                ; Locate the function
  46.                 tst.w        d0                    ; Set condition codes
  47.                 jsr            (a1)                ; Call user completion
  48.                 unlk        a6                    ; Clean out the stack
  49.                 move.l        (sp)+,a5            ; Restore current A5
  50. @exit:            ;
  51.         }
  52. }