IdChargenServer.pas 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. {
  2. $Project$
  3. $Workfile$
  4. $Revision$
  5. $DateUTC$
  6. $Id$
  7. This file is part of the Indy (Internet Direct) project, and is offered
  8. under the dual-licensing agreement described on the Indy website.
  9. (http://www.indyproject.org/)
  10. Copyright:
  11. (c) 1993-2005, Chad Z. Hower and the Indy Pit Crew. All rights reserved.
  12. }
  13. {
  14. $Log$
  15. }
  16. {
  17. Rev 1.4 12/2/2004 4:23:48 PM JPMugaas
  18. Adjusted for changes in Core.
  19. Rev 1.3 1/21/2004 1:49:34 PM JPMugaas
  20. InitComponent
  21. Rev 1.2 1/17/2003 05:35:28 PM JPMugaas
  22. Now compiles with new design.
  23. Rev 1.1 1-1-2003 20:12:40 BGooijen
  24. Changed to support the new TIdContext class
  25. Rev 1.0 11/14/2002 02:14:02 PM JPMugaas
  26. 2000-Apr-17 Kudzu
  27. Converted to Indy
  28. Improved efficiency
  29. }
  30. unit IdChargenServer;
  31. {
  32. Original Author: Ozz Nixon
  33. }
  34. interface
  35. {$i IdCompilerDefines.inc}
  36. uses
  37. IdAssignedNumbers,
  38. IdContext,
  39. IdCustomTCPServer;
  40. Type
  41. TIdChargenServer = class(TIdCustomTCPServer)
  42. protected
  43. function DoExecute(AContext:TIdContext): boolean; override;
  44. procedure InitComponent; override;
  45. published
  46. property DefaultPort default IdPORT_CHARGEN;
  47. end;
  48. implementation
  49. uses
  50. IdIOHandler;
  51. { TIdChargenServer }
  52. procedure TIdChargenServer.InitComponent;
  53. begin
  54. inherited InitComponent;
  55. DefaultPort := IdPORT_CHARGEN;
  56. end;
  57. function TIdChargenServer.DoExecute(AContext:TIdContext): boolean;
  58. var
  59. Counter, Width, Base: integer;
  60. LIOHandler: TIdIOHandler;
  61. begin
  62. Result := true;
  63. Base := 0;
  64. Counter := 1;
  65. Width := 1;
  66. LIOHandler := AContext.Connection.IOHandler;
  67. while LIOHandler.Connected do begin
  68. LIOHandler.Write(Chr(Counter + 31));
  69. Inc(Counter);
  70. Inc(Width);
  71. if Width = 72 then begin
  72. LIOHandler.WriteLn; {Do not Localize}
  73. Width := 1;
  74. Inc(Base);
  75. if Base = 95 then begin
  76. Base := 1;
  77. end;
  78. Counter := Base;
  79. end;
  80. if Counter = 95 then begin
  81. Counter := 1;
  82. end;
  83. end;
  84. end;
  85. end.