home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Mac OS / Communications Toolbox / CTB Sample Code 1.0b16 / CTB Sources / Sources 2 / Terminal Tool for CTB / tval.p < prev    next >
Encoding:
Text File  |  1989-06-27  |  3.0 KB  |  151 lines  |  [TEXT/MPS ]

  1. { *** =================================================== ***
  2.  
  3.     Purpose:        Terminal tool's main validation 
  4.         code module.  Validate and Default called through
  5.         here.  Basic functions simply include validating
  6.         config requests from 'other' sources like changes
  7.         in config strings, dialog items changing, etc.
  8.  
  9.     Module :        tval.p
  10.  
  11.     Authors:        Craig Hotchkiss, Alex Kazim, Byron Han, 
  12.                         Carol Lee
  13.                     Apple Computer, Inc.
  14.                     Networks & Communications
  15.                     20525 Mariani Drive
  16.                     Cupertino, CA 95014
  17.  
  18.     Version :        1.0d1
  19.  
  20.     Date :            9.may.89
  21.  
  22.     History :
  23.         9.may.89    Creation date
  24.  
  25.  
  26.     ©1989 Apple Computer, Inc.  All Rights Reserved.
  27.     This software is proprietary to Apple Computer, Inc.
  28.     It may not be copied, in whole or in part,
  29.     without the written consent of Apple Computer, Inc.
  30.  
  31.   *** =================================================== *** }
  32.     
  33.  
  34.  
  35.  
  36. UNIT TERMINALtval;
  37.  
  38.  
  39. INTERFACE
  40.  
  41.  
  42. USES     MemTypes,
  43.         QuickDraw,
  44.         OSIntf,
  45.         ToolIntf,
  46.         PasLibIntf,
  47.         Lists,
  48.         CRMSerialIntf,
  49.         CRMIntf,
  50.         CTBUtils,
  51.         CMIntf,
  52.         TMIntf,
  53.         FTIntf,
  54.         TerminalTool,
  55.         TermGlobalUnit;
  56.         
  57.         
  58. FUNCTION tvalMAIN(hTerm: TermHandle; message: Integer;
  59.     p1, p2, p3: LongInt) : LongInt;
  60.  
  61.  
  62. IMPLEMENTATION
  63.  
  64.  
  65. FUNCTION TermToolValidate(hTerm: TermHandle): LongInt;
  66.         FORWARD;
  67. PROCEDURE TermToolDefault(pConfig: TerminalPtr);
  68.         FORWARD;
  69.  
  70.         
  71. FUNCTION tvalMAIN(hTerm: TermHandle; message: Integer;
  72.     p1, p2, p3: LongInt) : LongInt;
  73.  
  74. { Here is our main module that simply directs the message
  75. paramater again.  (Message is used by the toolbox to 
  76. tell us what it wants the tool to do.) }
  77.  
  78. VAR
  79.     pConfig: TerminalPtr;
  80.     result : LONGINT;
  81. BEGIN
  82.     result := 0;
  83.     CASE message OF
  84.         TMValidateMsg:
  85.             result := TermToolValidate(hTerm);
  86.         TMDefaultMsg:
  87.             BEGIN
  88.             
  89.             { If p2 is not zero, p1 can't be ready yet.  }
  90.             
  91.             IF p2 <> 0 THEN        
  92.                 BEGIN
  93.                     pConfig := TerminalPtr(NewPtr(SIZEOF(TerminalRecord)));
  94.                     BlockMove(Ptr(@pConfig), Ptr(p1), 4);
  95.                     IF pConfig = NIL THEN
  96.                         BEGIN
  97.                             hTerm^^.errCode := MemError;
  98.                             Exit(tvalMAIN);
  99.                         END;
  100.                 END
  101.             ELSE
  102.                 { Okay to default now because p2 = 0 }
  103.                 BlockMove(Ptr(p1), Ptr(@pConfig), 4);
  104.                 TermToolDefault(pConfig);
  105.             END;
  106.         OTHERWISE
  107.             SysBeep(5);
  108.         END; {case}
  109.         tvalMAIN := result;
  110. END;
  111.  
  112.  
  113.  
  114. FUNCTION TermToolValidate(hTerm: TermHandle): LongInt;
  115.  
  116. { This function always returns a validated message.  Structures
  117. and tool functions should really be validated here. }
  118.  
  119. VAR
  120.     theState: SignedByte;
  121.     pPrivate: TERMINALPrivatePtr;
  122.     pConfig: TerminalPtr;
  123.     theProcID: Integer;
  124. BEGIN
  125.     theState := HGetState(Handle(hTerm));
  126.     HLock(Handle(hTerm));
  127.     pPrivate := TERMINALPrivatePtr(hTerm^^.tmPrivate);
  128.     pConfig := TerminalPtr(hTerm^^.config);
  129.     theProcID := (hTerm^^.procID);
  130.     IF (theProcID < 3) OR (pConfig = NIL) OR (pPrivate = NIL) THEN
  131.         DebugStr('The pipe is blocked from TermToolValidate');
  132.     HSetState(Handle(hTerm), theState);
  133. END;
  134.  
  135.  
  136. PROCEDURE TermToolDefault(pConfig: TerminalPtr);
  137. { Simply set our default values . }
  138. BEGIN
  139.         WITH pConfig^ DO
  140.             BEGIN
  141.                 onlineBoolean := True;
  142.                 screenWidth := True;
  143.                 cursorStyle := True;
  144.             END;
  145. END;
  146.  
  147.  
  148.  
  149.  
  150.  
  151. END.