home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Telephone Manager / Stiletto Sources / ModuleSources / CallbackClear.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-26  |  3.0 KB  |  112 lines  |  [TEXT/MPS ]

  1. /************************************************************************************************/
  2. /*                                                                                                */
  3. /*    Module Name:    CallbackClear                                                                */
  4. /*                                                                                                */
  5. /*    File Name:        CallbackClear.c                                                                */
  6. /*                                                                                                */
  7. /*    © Apple Computer, Inc. 1991-1995                                                            */
  8. /*    All Rights Reserved                                                                            */
  9. /*                                                                                                */
  10. /*    Revision History:                                                                            */
  11. /*                                                                                                */
  12. /*        Date        Who                    Modification                                            */
  13. /*                                                                                                */
  14. /*        1991-08-05    Chris Halim            Original version                                        */
  15. /*        1994-10-26    Jaakko Railo        Version 2.0                                                */
  16. /*                                                                                                */
  17. /************************************************************************************************/
  18.  
  19. /****************************************** DESCRIPTION ******************************************
  20.  
  21. *************************************************************************************************/
  22.  
  23. /******************************************** HEADERS *******************************************/
  24.  
  25. #include "TextUtils.h"
  26.  
  27. #include "TestModule.h"
  28.  
  29. /****************************************** DEFINITIONS *****************************************/
  30.  
  31. #define    rCallbackClearDLOG    10000
  32. #define    kCBRef                3
  33.  
  34. /****************************************** PROTOTYPES ******************************************/
  35.  
  36. short    GetCBRef (short * cbRef);
  37. void     DoTest (CHRSPtr paramPtr);
  38.  
  39. /************************************************************************************************/
  40. /************************************************************************************************/
  41.  
  42.  
  43. pascal short TestModule (CHRSPtr paramPtr)
  44. {
  45.     short    returnValue = noErr;
  46.     
  47.     if (paramPtr->version <= kTestModuleVersion) {
  48.         
  49.         DoTest (paramPtr);
  50.         
  51.     }
  52.     else
  53.         returnValue = kWrongVersion;
  54.         
  55.     return (returnValue);
  56. }
  57.  
  58.  
  59. short    GetCBRef (short * cbRef)
  60. {
  61.     short        itemKind;
  62.     Handle        itemHand;
  63.     Rect        itemRect;
  64.     short        itemHit;
  65.     DialogPtr    theDialog;
  66.     Str255        itemStr;
  67.     long        tlong;
  68.     
  69.     if ((theDialog = GetNewDialog (rCallbackClearDLOG, nil, (WindowPtr)(-1L))) != nil) {
  70.         GetDItem (theDialog, kCBRef, &itemKind, &itemHand, &itemRect);
  71.         SelIText (theDialog, kCBRef, 0, 32767);
  72.         
  73.         ShowWindow (theDialog);
  74.         
  75.         ModalDialog (nil, &itemHit);
  76.         
  77.         if (itemHit == ok) {
  78.             GetDItem (theDialog, kCBRef, &itemKind, &itemHand, &itemRect);
  79.             GetIText (itemHand, itemStr);
  80.             StringToNum (itemStr, &tlong);
  81.             *cbRef = tlong;
  82.         }
  83.         
  84.         DisposeDialog (theDialog);
  85.     }
  86.     else
  87.         itemHit = -1;
  88.     
  89.     return (itemHit);
  90. }
  91.  
  92.  
  93. void DoTest (CHRSPtr paramPtr)
  94. {
  95.     TELHandle    termHand = GetCurrentTELHandle (paramPtr);
  96.     short        itemHit, cbRef;
  97.     OSErr        errCode;
  98.     
  99.     if ((itemHit = GetCBRef (&cbRef)) == ok) {
  100.         
  101.         if ((errCode = TELCallbackClear (termHand, cbRef)) == noErr)
  102.             Print (paramPtr, "TELCallbackClear is called successfully");
  103.         else
  104.             Print (paramPtr, "### TELCallbackClear failed : %d", errCode);
  105.     }
  106.     else
  107.         if (itemHit == -1)
  108.             Print (paramPtr, "### Unable to get a DLOG resource");
  109. }
  110.  
  111.  
  112.