home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / source / clintsrc.sit / DA.h next >
Text File  |  1990-05-05  |  6KB  |  177 lines

  1. /*========================================================================
  2. ===  DA.h
  3. ===
  4. ===  Greg Anderson
  5. ===  29 Kerr Hall
  6. ===  Social Sciences Computing
  7. ===  University of California at Santa Cruz
  8. ===  Santa Cruz CA  95062
  9. ===
  10. ===  (408) 459-2658
  11. ===  sirkm@ssyx.ucsc.edu
  12. ===
  13. ===  This .h file is included by all .c segments.
  14. ===
  15. ========================================================================*/
  16. extern pascal void AsmClikLoop();
  17.  
  18. #define    maxInCache        14
  19. /*
  20.  *  Size of TCP buffer:
  21.  */
  22. #define TCPBUFSIZE        16000L
  23. #define TCPCTLSIZE        200L
  24.  
  25. #define NOERRORMAGIC    132
  26. /*
  27.  *   Macros:
  28.  */
  29. #define OWNEDRSRCID(id)    (0xC000 | (((-(id)) - 1) << 5))
  30. #define DA_global        ((Globals *)(*dCtl->dCtlStorage))
  31. #define DA_window        (dCtl->dCtlWindow)
  32. #define DA_te            ( ((DocumentPeek)DA_window)->docTE )
  33. #define DA_iList        ( DA_global->itemList )
  34. #define DA_tcp            ( DA_global->tcpCtrl )
  35. #define DA_tcpL            (long *)( DA_tcp )
  36. #define DA_tcpW            (int  *)( DA_tcp )
  37. #define DA_tcpB            (char *)( DA_tcp )
  38.  
  39. #define DA_active        (DA_window != nil)
  40. #define DA_inactive        (DA_window == nil)
  41.  
  42. #define max(a,b)        ( a > b ? a : b )
  43. #define min(a,b)        ( a < b ? a : b )
  44. #define pstrlen(a)        ((short)(unsigned char)(a)[0])
  45.  
  46. /*
  47. #define    APPHEAP        1
  48. #define    SYSHEAP        2
  49. #define    DISK        3
  50. #define    FREEON        4
  51.  */
  52.  
  53. /*
  54.  *  Accessory messages:
  55.  */
  56. #define    accEvent    64
  57. #define    accRun        65
  58. #define accUndo        68
  59. #define accCut        70
  60. #define accCopy        71
  61. #define accPaste    72
  62. #define accClear    73
  63.  
  64. /*----------------------------------------------------------------------
  65. |  A DocumentRecord contains the WindowRecord for one of our document
  66. |  windows, as well as the TEHandle for the text we are editing.
  67. ----------------------------------------------------------------------*/
  68. typedef struct {
  69.     WindowRecord    docWindow;
  70.     TEHandle        docTE;
  71.     ControlHandle    docVScroll;
  72.     ControlHandle    docHScroll;
  73.     ProcPtr            docClik;
  74. } DocumentRecord, *DocumentPeek;
  75.  
  76. /*----------------------------------------------------------------------
  77. |  This structure type holds the global variables used by this desk
  78. |  accessory.
  79. ----------------------------------------------------------------------*/
  80. typedef struct {
  81.     int             rsrcID;         /* Computed rsrc id of owned resources */
  82.     Str255            strBuf;            /* Buffer to read strings into */
  83.     int                windMsg,        /* Which message in window info? */
  84.                     windButton,        /* Which button in window info? */
  85.                     flag;            /* Flag */
  86.     CntrlParam        *tcpCtrl;        /* TCP control record */
  87.     ListHandle        itemList;        /* Scrolling item list handle */
  88.     int                lastService;    /* The last service number requested */
  89.     int                ignoreUntil;    /* Ignore all input until this char recvd */
  90.     /*
  91.      *  Undo stuff
  92.      */
  93.     int                undoType;        /* What are we going to UNDO?  */
  94.     int                undoFrom;        /* Where did the cut / paste happen? */
  95.     int                undoTo;            /* How many characters were pasted in? */
  96.     TEHandle        undoText;        /* The deleted text to replace when UNDO-ing */
  97.     /*
  98.      *  Mac TCP buffers:
  99.      */
  100.     char            tcpBuf[TCPBUFSIZE];
  101. } Globals;
  102.  
  103. /*----------------------------------------------------------------------
  104. |  Prototypes:
  105. ----------------------------------------------------------------------*/
  106. pascal short    DRVROpen(CntrlParam *ctlPB, DCtlPtr dCtl);
  107. void            startDA( DCtlPtr dCtl );
  108. static void        doCtlEvent(EventRecord *event, DCtlPtr dCtl);
  109. void            doCutCopy( DCtlPtr dCtl, int CutOrCopy );
  110. void            doCut( DCtlPtr dCtl );
  111. void            doCopy( DCtlPtr dCtl );
  112. void            doPaste( DCtlPtr dCtl );
  113. void            doClear( DCtlPtr dCtl );
  114. void            doAbort( DCtlPtr dCtl );
  115. void            drawWindow( DCtlPtr dCtl );
  116. void            drawWInfo( DCtlPtr dCtl );
  117. void            changeMsg( DCtlPtr dCtl, int newMsg );
  118.  
  119. void            getLocalUpdateRgn( WindowPtr window, RgnHandle localRgn );
  120. void            doKeyDown( EventRecord *event, DCtlPtr dCtl );
  121. void            doCommandKey( EventRecord *event, DCtlPtr dCtl );
  122. void            pageTE( DCtlPtr dCtl, int direction);
  123. void            addTEstring( DCtlPtr dCtl, char *string );
  124. Boolean            doNew( DCtlPtr dCtl );
  125. Boolean            doCloseWindow( DCtlPtr dCtl );
  126. void            doContentClick( DCtlPtr dCtl, EventRecord *event );
  127. void            doInfoClick( DCtlPtr dCtl,EventRecord *event );
  128. void            doGrowWindow(WindowPtr window,EventRecord *event);
  129. void            doZoomWindow(WindowPtr window,short part);
  130. void            resizeWindow( WindowPtr window );
  131. void            doUpdate( DCtlPtr dCtl );
  132. void            doDeactivate( WindowPtr window );
  133. void            doActivate( DCtlPtr dCtl, Boolean becomingActive );
  134.  
  135. void            getTERect( WindowPtr window, Rect *teRect );
  136. void            getInfoRect( WindowPtr window, Rect *infoRect);
  137. void            getGrowRect( WindowPtr window, Rect *growRect );
  138. void            getZoomRect( WindowPtr window, Rect *zoomRect );
  139. void            adjustViewRect( TEHandle docTE );
  140. TEHandle        makeTE( Rect destRect, Rect viewRect );
  141. void            adjustTE( WindowPtr window );
  142. void            adjustHV( Boolean isVert, ControlHandle control, TEHandle docTE,
  143.                     Boolean canRedraw );
  144. void            adjustScrollValues( WindowPtr window, Boolean canRedraw );
  145. void            adjustScrollSizes( WindowPtr window );
  146. void            adjustScrollbars( WindowPtr window, Boolean needsResize );
  147. pascal void        PascalClikLoop();
  148. pascal ProcPtr    getOldClikLoop();
  149. void            commonAction( ControlHandle control, short *amount );
  150. pascal void        vActionProc( ControlHandle control, short part );
  151. pascal void        hActionProc( ControlHandle control, short part );
  152. void            doIdle( DCtlPtr dCtl );
  153. void            alertUser( DCtlPtr dCtl, short error );
  154. void            alertUser2( DCtlPtr dCtl, short error1, short error2 );
  155. short            selectService( DCtlPtr dCtl, long *inet_addr, char *result );
  156. void            setupList(DCtlPtr dCtl, DialogPtr dlog, long *inet_addr);
  157. char            *checkHostCache( char *walk, char *hostName, long *inet_addr );
  158. void            addHostToCache( DCtlPtr dCtl, char *hostName, char *dotAddr, DialogPtr dlog);
  159. void            findNextLine(char **str);
  160. int                doPopup( DCtlPtr dCtl, DialogPtr dlog, int popItem, Str255 Pstr);
  161.  
  162. StringPtr        text(int index, Globals *globals);
  163. void            getCstr(int index, char *str, Globals *globals);
  164. int                fix_cr(char *str);
  165. void            strcpy(char *a, char *b);
  166. void            straddc(char *a,char c);
  167. int                strlen(char *str);
  168. long            lstrlen(char *str);
  169. char            *P2Cstr(char *cstr,char *pstr);
  170. char            *C2Pstr(char *pstr,char *cstr);
  171.  
  172. OSErr            initTCP();
  173. void            connectToServer( DCtlPtr dCtl, long inet_addr, char *command );
  174. char            connectionState( DCtlPtr dCtl );
  175.  
  176. short            NameToAddr(char *name,long *addr, long timeout);
  177.