home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / rclesrc.10 / ircle sources / ircle.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-09-05  |  2.9 KB  |  112 lines

  1. {    ircle - Internet Relay Chat client    }
  2. {    File: ircle    }
  3. {    Copyright ⌐ 1992 Olaf Titz (s_titz@iravcl.ira.uka.de)    }
  4.  
  5. {    This program is free software; you can redistribute it and/or modify    }
  6. {    it under the terms of the GNU General Public License as published by    }
  7. {    the Free Software Foundation; either version 2 of the License, or    }
  8. {    (at your option) any later version.    }
  9.  
  10. {    This program is distributed in the hope that it will be useful,    }
  11. {    but WITHOUT ANY WARRANTY; without even the implied warranty of    }
  12. {    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    }
  13. {    GNU General Public License for more details.    }
  14.  
  15. {    You should have received a copy of the GNU General Public License    }
  16. {    along with this program; if not, write to the Free Software    }
  17. {    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.    }
  18.  
  19. program ircle;
  20. { This is a small IRC client for the Macintosh. }
  21. { Written by Olaf Titz (s_titz@iravcl.ira.uka.de), Karlsruhe, July/August 1992. }
  22. { The TCP interface code written  by Peter N.Lewis and Harry Chesley/Apple Computer Inc. }
  23. { Parts of the command protocol handling, and many ideas }
  24. {   derived from IRCII by Michael Sandrof }
  25.  
  26. uses
  27.     TCPTypes, TCPStuff, TCPConnections,{}
  28.     Coroutines, ApplBase, MsgWindows, InputLine, {}
  29.     IRCGlobals, IRCaux, IRCPreferences, IRCInput, {}
  30.     IRCCommands, IRCChannels, IRCSComm, IRCHelp, IRCInit;
  31.  
  32. var
  33.     i: integer;
  34.     fmem, lofmem, t0: longint;
  35.     purged: boolean;
  36.     FMenu: MenuHandle;
  37.  
  38. function Clock (var e: EventRecord): boolean;
  39.     begin
  40.         if abs(e.when - t0) >= 60 then begin
  41.             t0 := e.when;
  42.             UpdateStatusLine
  43.         end;
  44.         Clock := false
  45.     end;
  46.  
  47.  
  48. { CheckMem gets called once in each run through the main event loop. }
  49. { If free memory runs low, first memory is compacted, then an alert is displayed }
  50. { and subsequent memory checking disabled for 30 seconds, or until more memory gets freed, }
  51. { e.g. by closing a window. }
  52. procedure CheckMem;
  53.     var
  54.         i: longint;
  55.     begin
  56.         if fmem < 0 then begin
  57.             getdatetime(i);
  58.             if (abs(i - lofmem) > MEMTIME) or (freemem > HIFREEMEM) then
  59.                 fmem := LOFREEMEM;
  60.         end
  61.         else if freemem < fmem then begin
  62.             if purged then begin
  63.                 fmem := -1;
  64.                 getdatetime(lofmem);
  65.                 i := Alert(A_LOWMEM, nil)
  66.             end
  67.             else begin
  68.                 PurgeMem(maxSize);
  69.                 purged := true
  70.             end
  71.         end
  72.         else
  73.             purged := false;
  74.     end;
  75.  
  76. procedure ExitTCP;
  77.     var
  78.         i: integer;
  79.     begin
  80.         if logging then
  81.             close(logfile);
  82.         FinishEverything
  83.     end;
  84.  
  85. begin
  86.     serverStatus := -1;
  87.     fmem := LOFREEMEM;
  88.     purged := false;
  89.     if InitConnections('') <> noErr then
  90.         i := Alert(A_TCPERR, nil)
  91.     else begin
  92.         IRCInitAll;
  93.         i := ApplTask(@Clock, nullEvent);
  94.         ApplExitproc(@ExitTCP);
  95.         UnloadSeg(@IRCInitAll);
  96.         t0 := -maxlongint;
  97.         FMenu := GetMHandle(fileMenu);
  98.         repeat
  99.             CheckMem;
  100.             if serverStatus = 0 then
  101.                 DisableItem(FMenu, M_F_OPEN)
  102.             else
  103.                 EnableItem(FMenu, M_F_OPEN);
  104.             if GetWRefCon(FrontWindow) = 0 then
  105.                 DisableItem(FMenu, M_F_CLOSE)
  106.             else
  107.                 EnableItem(FMenu, M_F_CLOSE);
  108.             ApplRun;
  109.         until QuitRequest;
  110.         ApplExit
  111.     end;
  112. end.