From f0a0e086dd91bf999a1adb272da3407b9a0dd72b Mon Sep 17 00:00:00 2001 From: "J. Peter Mugaas" Date: Tue, 1 Oct 2024 05:45:25 -0400 Subject: [PATCH 1/3] Fix for missing const for unmodified string warning from Pascal Analyzer. --- Lib/Core/IdCmdTCPServer.pas | 4 ++-- Lib/Core/IdCommandHandlers.pas | 8 ++++---- Lib/Core/IdIOHandler.pas | 8 ++++---- Lib/Core/IdTCPConnection.pas | 4 ++-- Lib/Protocols/IdFTP.pas | 10 +++++----- Lib/Protocols/IdFTPCommon.pas | 16 ++++++++-------- Lib/Protocols/IdFTPServer.pas | 8 ++++---- Lib/Protocols/IdGlobalProtocols.pas | 8 ++++---- Lib/Protocols/IdHeaderList.pas | 12 ++++++------ 9 files changed, 39 insertions(+), 39 deletions(-) diff --git a/Lib/Core/IdCmdTCPServer.pas b/Lib/Core/IdCmdTCPServer.pas index 1bd03abe2..8e76338d3 100644 --- a/Lib/Core/IdCmdTCPServer.pas +++ b/Lib/Core/IdCmdTCPServer.pas @@ -200,7 +200,7 @@ TIdCmdTCPServer = class(TIdTCPServer) function DoExecute(AContext: TIdContext): Boolean; override; procedure DoMaxConnectionsExceeded(AIOHandler: TIdIOHandler); override; // This is here to allow servers to override this functionality, such as IMAP4 server - procedure DoReplyUnknownCommand(AContext: TIdContext; ALine: string); virtual; + procedure DoReplyUnknownCommand(AContext: TIdContext; const ALine: string); virtual; function GetExceptionReply: TIdReply; function GetGreeting: TIdReply; function GetHelpReply: TIdReply; @@ -313,7 +313,7 @@ function TIdCmdTCPServer.DoExecute(AContext: TIdContext): Boolean; // the return value is used to determine if the DoExecute needs to be called again by the thread end; -procedure TIdCmdTCPServer.DoReplyUnknownCommand(AContext: TIdContext; ALine: string); +procedure TIdCmdTCPServer.DoReplyUnknownCommand(AContext: TIdContext; const ALine: string); var LReply: TIdReply; begin diff --git a/Lib/Core/IdCommandHandlers.pas b/Lib/Core/IdCommandHandlers.pas index fb05d3bc3..06243a526 100644 --- a/Lib/Core/IdCommandHandlers.pas +++ b/Lib/Core/IdCommandHandlers.pas @@ -204,8 +204,8 @@ TIdCommandHandler = class(TCollectionItem) procedure SetResponse(AValue: TStrings); public function Check(const AData: string; AContext: TIdContext): boolean; virtual; - procedure DoCommand(const AData: string; AContext: TIdContext; AUnparsedParams: string); virtual; - procedure DoParseParams(AUnparsedParams: string; AParams: TStrings); virtual; + procedure DoCommand(const AData: string; AContext: TIdContext; const AUnparsedParams: string); virtual; + procedure DoParseParams(const AUnparsedParams: string; AParams: TStrings); virtual; constructor Create(ACollection: TCollection); override; destructor Destroy; override; // function GetNamePath: string; override; @@ -418,7 +418,7 @@ procedure TIdCommandHandlers.SetItem(AIndex: Integer; const AValue: TIdCommandHa { TIdCommandHandler } -procedure TIdCommandHandler.DoCommand(const AData: string; AContext: TIdContext; AUnparsedParams: string); +procedure TIdCommandHandler.DoCommand(const AData: string; AContext: TIdContext; const AUnparsedParams: string); var LCommand: TIdCommand; begin @@ -513,7 +513,7 @@ procedure TIdCommandHandler.DoCommand(const AData: string; AContext: TIdContext; end; end; -procedure TIdCommandHandler.DoParseParams(AUnparsedParams: string; AParams: TStrings); +procedure TIdCommandHandler.DoParseParams(const AUnparsedParams: string; AParams: TStrings); // AUnparsedParams is not preparsed and is completely left up to the command handler. This will // allow for future expansion such as multiple delimiters etc, and allow the logic to properly // remain in each of the command handler implementations. In the future there may be a base type diff --git a/Lib/Core/IdIOHandler.pas b/Lib/Core/IdIOHandler.pas index 06b165780..8c64518fb 100644 --- a/Lib/Core/IdIOHandler.pas +++ b/Lib/Core/IdIOHandler.pas @@ -652,7 +652,7 @@ TIdIOHandler = class(TIdComponent) function ReadLn(AByteEncoding: IIdTextEncoding = nil {$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF} ): string; overload; // .Net overload - function ReadLn(ATerminator: string; AByteEncoding: IIdTextEncoding + function ReadLn(const ATerminator: string; AByteEncoding: IIdTextEncoding {$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF} ): string; overload; function ReadLn(ATerminator: string; ATimeout: Integer = IdTimeoutDefault; @@ -672,7 +672,7 @@ TIdIOHandler = class(TIdComponent) {$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF} ): string; virtual; // Added for retrieving lines over 16K long} - function ReadLnSplit(var AWasSplit: Boolean; ATerminator: string = LF; + function ReadLnSplit(var AWasSplit: Boolean; const ATerminator: string = LF; ATimeout: Integer = IdTimeoutDefault; AMaxLineLength: Integer = -1; AByteEncoding: IIdTextEncoding = nil {$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF} @@ -1428,7 +1428,7 @@ function TIdIOHandler.ReadLn(AByteEncoding: IIdTextEncoding = nil ); end; -function TIdIOHandler.ReadLn(ATerminator: string; AByteEncoding: IIdTextEncoding +function TIdIOHandler.ReadLn(const ATerminator: string; AByteEncoding: IIdTextEncoding {$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF} ): string; {$IFDEF USE_CLASSINLINE}inline;{$ENDIF} @@ -1588,7 +1588,7 @@ function TIdIOHandler.ReadLnRFC(var VMsgEnd: Boolean; const ALineTerminator: str VMsgEnd := False; end; -function TIdIOHandler.ReadLnSplit(var AWasSplit: Boolean; ATerminator: string = LF; +function TIdIOHandler.ReadLnSplit(var AWasSplit: Boolean; const ATerminator: string = LF; ATimeout: Integer = IdTimeoutDefault; AMaxLineLength: Integer = -1; AByteEncoding: IIdTextEncoding = nil {$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF} diff --git a/Lib/Core/IdTCPConnection.pas b/Lib/Core/IdTCPConnection.pas index 7a7bfdffe..35e985e99 100644 --- a/Lib/Core/IdTCPConnection.pas +++ b/Lib/Core/IdTCPConnection.pas @@ -429,7 +429,7 @@ TIdTCPConnection = class(TIdComponent) procedure RaiseExceptionForLastCmdResult(AException: TClassIdException); overload; virtual; // These are extended GetResponses, so see the comments for GetResponse - function SendCmd(AOut: string; const AResponse: Int16 = -1; + function SendCmd(const AOut: string; const AResponse: Int16 = -1; AEncoding: IIdTextEncoding = nil): Int16; overload; function SendCmd(AOut: string; const AResponse: array of Int16; AEncoding: IIdTextEncoding = nil): Int16; overload; virtual; @@ -794,7 +794,7 @@ procedure TIdTCPConnection.WriteHeader(AHeader: TStrings); end; end; -function TIdTCPConnection.SendCmd(AOut: string; const AResponse: Int16 = -1; +function TIdTCPConnection.SendCmd(const AOut: string; const AResponse: Int16 = -1; AEncoding: IIdTextEncoding = nil): Int16; begin if AResponse < 0 then begin diff --git a/Lib/Protocols/IdFTP.pas b/Lib/Protocols/IdFTP.pas index e6ebf3cc5..28e44c09b 100644 --- a/Lib/Protocols/IdFTP.pas +++ b/Lib/Protocols/IdFTP.pas @@ -942,7 +942,7 @@ TIdFTP = class(TIdExplicitTLSClient) procedure FileStructure(AStructure: TIdFTPDataStructure); procedure Get(const ASourceFile: string; ADest: TStream; AResume: Boolean = false); overload; procedure Get(const ASourceFile, ADestFile: string; const ACanOverwrite: boolean = false; AResume: Boolean = false); overload; - procedure Help(AHelpContents: TStrings; ACommand: String = ''); + procedure Help(AHelpContents: TStrings; const ACommand: String = ''); procedure KillDataChannel; virtual; //.NET Overload procedure List; overload; @@ -979,7 +979,7 @@ TIdFTP = class(TIdExplicitTLSClient) procedure Site(const ACommand: string); function Size(const AFileName: String): Int64; procedure Status(AStatusList: TStrings); - procedure StructureMount(APath: String); + procedure StructureMount(const APath: String); procedure TransferMode(ATransferMode: TIdFTPTransferMode); procedure ReInitialize(ADelay: UInt32 = 10); procedure SetLang(const ALangTag : String); @@ -2415,7 +2415,7 @@ procedure TIdFTP.StoreUnique(const ASourceFile: string; const AStartPos: TIdStre procedure TIdFTP.SendInternalPassive(const ACmd: String; var VIP: string; var VPort: TIdPort); - function IsRoutableAddress(AIP: string): Boolean; + function IsRoutableAddress(const AIP: string): Boolean; begin Result := not TextStartsWith(AIP, '127') and // Loopback 127.0.0.0-127.255.255.255 not TextStartsWith(AIP, '10.') and // Private 10.0.0.0-10.255.255.255 @@ -2620,7 +2620,7 @@ procedure TIdFTP.Status(AStatusList: TStrings); end; end; -procedure TIdFTP.Help(AHelpContents: TStrings; ACommand: String = ''); {do not localize} +procedure TIdFTP.Help(AHelpContents: TStrings; const ACommand: String = ''); {do not localize} begin if SendCmd(TrimRight('HELP ' + ACommand), [211, 214, 500]) <> 500 then begin {do not localize} AHelpContents.Text := LastCmdResult.Text.Text; @@ -2635,7 +2635,7 @@ function TIdFTP.CheckAccount: Boolean; Result := FAccount <> ''; end; -procedure TIdFTP.StructureMount(APath: String); +procedure TIdFTP.StructureMount(const APath: String); begin SendCmd('SMNT ' + APath, [202, 250, 500]); {do not localize} end; diff --git a/Lib/Protocols/IdFTPCommon.pas b/Lib/Protocols/IdFTPCommon.pas index 0ab8950e5..92380d15a 100644 --- a/Lib/Protocols/IdFTPCommon.pas +++ b/Lib/Protocols/IdFTPCommon.pas @@ -425,7 +425,7 @@ function IndyIsRelativePath(const APathName : String): Boolean; function IndyGetFileExt(const AFileName : String) : String; function StripInitPathDelim(const AStr : String): String; function IsNavPath(const APath : String): Boolean; -function RemoveDuplicatePathSyms(APath : String): String; +function RemoveDuplicatePathSyms(const APath : String): String; {*** EPLF time stamp processing @@ -501,7 +501,7 @@ function FTPMDTMToGMTDateTime(const ATimeStamp : String):TDateTime; ***} {Unix} -function IsValidUnixPerms(AData : String; const AStrict : Boolean = False) : Boolean; +function IsValidUnixPerms(const AData : String; const AStrict : Boolean = False) : Boolean; function IsUnixLsErr(const AData: String): Boolean; function IsUnixExec(const LUPer, LGPer, LOPer : String): Boolean; function IsUnixHiddenFile(const AFileName : String): Boolean; @@ -530,7 +530,7 @@ function ExtractQVNETFileName(const AData : String): String; function ExtractRecFormat(const ARecFM : String): String; //Determines if the line is part of a VM/BFS list - also used by WindowsNT parser //because two columns are shared -function IsVMBFS(AData : String) : Boolean; +function IsVMBFS(const AData : String) : Boolean; {IBM VSE} function DispositionCodeToTIdVSEPQDisposition(const ADisp : Char) : TIdVSEPQDisposition; function TIdVSEPQDispositionDispositionCode(const ADisp : TIdVSEPQDisposition) : Char; @@ -538,7 +538,7 @@ function TIdVSEPQDispositionDispositionCode(const ADisp : TIdVSEPQDisposition) : {EPLF and MLST/MLSD support} function ParseFacts(AData : String; AResults : TStrings; const AFactDelim : String = ';'; const ANameDelim : String=' '): String; -function ParseFactsMLS(AData : String; AResults : TStrings; +function ParseFactsMLS(const AData : String; AResults : TStrings; const AFactDelim : String = ';'; const ANameDelim : String = ' '): String; {Sterling Commerce support routines} @@ -1120,7 +1120,7 @@ function IsNavPath(const APath : String): Boolean; ('/','\','/','/'); } -function RemoveDuplicatePathSyms(APath : String): String; +function RemoveDuplicatePathSyms(const APath : String): String; {$IFDEF USE_INLINE} inline; {$ENDIF} begin //Result := StringsReplace(APath, TrailingPathCorrectionOrg, TrailingPathCorrectionNew); @@ -1836,7 +1836,7 @@ function AS400Date(const AData: String): TDateTime; //=== platform stuff //===== Unix -function IsValidUnixPerms(AData : String; const AStrict : Boolean = False) : Boolean; +function IsValidUnixPerms(const AData : String; const AStrict : Boolean = False) : Boolean; {$IFDEF USE_INLINE} inline; {$ENDIF} //Stict mode is for things such as Novell Netware Unix Print Services FTP Deamon //which are not quite like Unix. @@ -2383,7 +2383,7 @@ function TIdVSEPQDispositionDispositionCode(const ADisp : TIdVSEPQDisposition) : end; end; -function IsVMBFS(AData : String) : Boolean; +function IsVMBFS(const AData : String) : Boolean; {$IFDEF USE_INLINE} inline; {$ENDIF} var s : TStringList; @@ -2425,7 +2425,7 @@ function ParseFacts(AData : String; AResults : TStrings; end; //===== MLSD Parse facts, this has to be different because of different charsets -function ParseFactsMLS(AData : String; AResults : TStrings; +function ParseFactsMLS(const AData : String; AResults : TStrings; const AFactDelim : String = ';'; const ANameDelim : String = ' '): String; {$IFDEF USE_INLINE} inline; {$ENDIF} var diff --git a/Lib/Protocols/IdFTPServer.pas b/Lib/Protocols/IdFTPServer.pas index 14bed6927..740d72635 100644 --- a/Lib/Protocols/IdFTPServer.pas +++ b/Lib/Protocols/IdFTPServer.pas @@ -1019,7 +1019,7 @@ TIdFTPServer = class(TIdExplicitTLSServer) //command reply common code procedure CmdNotImplemented(ASender : TIdCommand); procedure CmdFileActionAborted(ASender : TIdCommand); - procedure CmdSyntaxError(AContext: TIdContext; ALine: string; const AReply : TIdReply = nil); overload; + procedure CmdSyntaxError(AContext: TIdContext; const ALine: string; const AReply : TIdReply = nil); overload; procedure CmdSyntaxError(ASender : TIdCommand); overload; procedure CmdInvalidParams(ASender: TIdCommand); procedure CmdInvalidParamNum(ASender:TIdCommand); @@ -1185,7 +1185,7 @@ TIdFTPServer = class(TIdExplicitTLSServer) function GetReplyClass: TIdReplyClass; override; function GetRepliesClass: TIdRepliesClass; override; procedure InitComponent; override; - procedure DoReplyUnknownCommand(AContext: TIdContext; ALine: string); override; + procedure DoReplyUnknownCommand(AContext: TIdContext; const ALine: string); override; // overriden so we can close active transfers during a shutdown procedure DoTerminateContext(AContext: TIdContext); override; //overriden so we can handle telnet sequences @@ -6671,7 +6671,7 @@ function TIdFTPServer.ReadCommandLine(AContext: TIdContext): string; Result := BytesToString(LLine, 0, MaxInt, LContext.Connection.IOHandler.DefStringEncoding); end; -procedure TIdFTPServer.DoReplyUnknownCommand(AContext: TIdContext; ALine: string); +procedure TIdFTPServer.DoReplyUnknownCommand(AContext: TIdContext; const ALine: string); begin CmdSyntaxError(AContext, ALine); end; @@ -6685,7 +6685,7 @@ procedure TIdFTPServer.DoTerminateContext(AContext: TIdContext); end; end; -procedure TIdFTPServer.CmdSyntaxError(AContext: TIdContext; ALine: string; const AReply : TIdReply = nil); +procedure TIdFTPServer.CmdSyntaxError(AContext: TIdContext; const ALine: string; const AReply : TIdReply = nil); var LTmp : String; LReply : TIdReply; diff --git a/Lib/Protocols/IdGlobalProtocols.pas b/Lib/Protocols/IdGlobalProtocols.pas index 48e7cb4ce..fc63be211 100644 --- a/Lib/Protocols/IdGlobalProtocols.pas +++ b/Lib/Protocols/IdGlobalProtocols.pas @@ -403,7 +403,7 @@ EIdExtensionAlreadyExists = class(EIdException); // TODO: IdStrings have optimized SplitColumns* functions, can we remove it? function ABNFToText(const AText : String) : String; function BinStrToInt(const ABinary: String): Integer; - function BreakApart(BaseString, BreakString: string; StringList: TStrings): TStrings; + function BreakApart(BaseString : String; const BreakString: string; StringList: TStrings): TStrings; function UInt32ToFourChar(AValue : UInt32): string; function LongWordToFourChar(AValue : UInt32): string; {$IFDEF HAS_DEPRECATED}deprecated{$IFDEF HAS_DEPRECATED_MSG} 'Use UInt32ToFourChar()'{$ENDIF};{$ENDIF} function CharRange(const AMin, AMax : Char): String; @@ -489,7 +489,7 @@ EIdExtensionAlreadyExists = class(EIdException); function GetGMTOffsetStr(const S: string): string; function GmtOffsetStrToDateTime(const S: string): TDateTime; function GMTToLocalDateTime(S: string): TDateTime; - function CookieStrToLocalDateTime(S: string): TDateTime; + function CookieStrToLocalDateTime(const S: string): TDateTime; function IdGetDefaultCharSet : TIdCharSet; function IntToBin(Value: UInt32): string; function IndyComputerName : String; // DotNet: see comments regarding GDotNetComputerName below @@ -1385,7 +1385,7 @@ function FTPLocalDateTimeToMLS(const ATimeStamp : TDateTime; const AIncludeMSecs end; -function BreakApart(BaseString, BreakString: string; StringList: TStrings): TStrings; +function BreakApart(BaseString : String; const BreakString: string; StringList: TStrings): TStrings; var EndOfCurrentString: integer; begin @@ -2800,7 +2800,7 @@ function TryStrToInt(const S: string; out Value: Integer): Boolean; {$ENDIF} { Using the algorithm defined in RFC 6265 section 5.1.1 } -function CookieStrToLocalDateTime(S: string): TDateTime; +function CookieStrToLocalDateTime(const S: string): TDateTime; const { delimiter = %x09 / %x20-2F / %x3B-40 / %x5B-60 / %x7B-7E diff --git a/Lib/Protocols/IdHeaderList.pas b/Lib/Protocols/IdHeaderList.pas index 811a27e33..242fa5313 100644 --- a/Lib/Protocols/IdHeaderList.pas +++ b/Lib/Protocols/IdHeaderList.pas @@ -83,10 +83,10 @@ TIdHeaderList = class(TStringList) {This deletes lines which were folded} Procedure DeleteFoldedLines(Index : Integer); {This folds one line into several lines} - function FoldLine(AString : string): TStrings; {$IFDEF HAS_DEPRECATED}deprecated{$IFDEF HAS_DEPRECATED_MSG} 'Use FoldLineToList()'{$ENDIF};{$ENDIF} - procedure FoldLineToList(AString : string; ALines: TStrings); + function FoldLine(const AString : string): TStrings; {$IFDEF HAS_DEPRECATED}deprecated{$IFDEF HAS_DEPRECATED_MSG} 'Use FoldLineToList()'{$ENDIF};{$ENDIF} + procedure FoldLineToList(const AString : string; ALines: TStrings); {Folds lines and inserts them into a position, Index} - procedure FoldAndInsert(AString : String; Index : Integer); + procedure FoldAndInsert(const AString : String; Index : Integer); {Name property get method} function GetName(Index: Integer): string; {Value property get method} @@ -261,7 +261,7 @@ procedure TIdHeaderList.Extract(const AName: string; ADest: TStrings); end; end; -procedure TIdHeaderList.FoldAndInsert(AString : String; Index: Integer); +procedure TIdHeaderList.FoldAndInsert(const AString : String; Index: Integer); var LStrs : TStrings; idx : Integer; @@ -284,7 +284,7 @@ procedure TIdHeaderList.FoldAndInsert(AString : String; Index: Integer); end; {$I IdDeprecatedImplBugOff.inc} -function TIdHeaderList.FoldLine(AString : string): TStrings; +function TIdHeaderList.FoldLine(const AString : string): TStrings; {$I IdDeprecatedImplBugOn.inc} begin Result := TStringList.Create; @@ -296,7 +296,7 @@ function TIdHeaderList.FoldLine(AString : string): TStrings; end; end; -procedure TIdHeaderList.FoldLineToList(AString : string; ALines: TStrings); +procedure TIdHeaderList.FoldLineToList(const AString : string; ALines: TStrings); var s : String; begin From d792fff88050ad97324881cd2b59830be28d85f3 Mon Sep 17 00:00:00 2001 From: "J. Peter Mugaas" Date: Wed, 2 Oct 2024 00:42:50 -0400 Subject: [PATCH 2/3] Adjust units for minor API change and fix compiler warnings in TOPS20 FTP List parser. --- Lib/Core/IdCmdTCPClient.pas | 4 ++-- Lib/Protocols/IdFTPListParseTOPS20.pas | 5 +++-- Lib/Protocols/IdIMAP4Server.pas | 4 ++-- Lib/Protocols/IdIRC.pas | 21 ++++++++++++++------- Lib/Protocols/IdPOP3Server.pas | 4 ++-- Lib/Protocols/IdSMTPServer.pas | 4 ++-- Lib/Protocols/IdURI.pas | 4 ++-- 7 files changed, 27 insertions(+), 19 deletions(-) diff --git a/Lib/Core/IdCmdTCPClient.pas b/Lib/Core/IdCmdTCPClient.pas index 2d887477e..2fca97f0d 100644 --- a/Lib/Core/IdCmdTCPClient.pas +++ b/Lib/Core/IdCmdTCPClient.pas @@ -154,7 +154,7 @@ TIdCmdTCPClient = class(TIdTCPClient) procedure DoAfterCommandHandler(ASender: TIdCommandHandlers; AContext: TIdContext); procedure DoBeforeCommandHandler(ASender: TIdCommandHandlers; var AData: string; AContext: TIdContext); - procedure DoReplyUnknownCommand(AContext: TIdContext; ALine: string); virtual; + procedure DoReplyUnknownCommand(AContext: TIdContext; const ALine: string); virtual; function GetCmdHandlerClass: TIdCommandHandlerClass; virtual; procedure InitComponent; override; procedure SetCommandHandlers(AValue: TIdCommandHandlers); @@ -273,7 +273,7 @@ procedure TIdCmdTCPClient.DoBeforeCommandHandler(ASender: TIdCommandHandlers; end; end; -procedure TIdCmdTCPClient.DoReplyUnknownCommand(AContext: TIdContext; ALine: string); +procedure TIdCmdTCPClient.DoReplyUnknownCommand(AContext: TIdContext; const ALine: string); begin end; diff --git a/Lib/Protocols/IdFTPListParseTOPS20.pas b/Lib/Protocols/IdFTPListParseTOPS20.pas index 8003c1612..426fade64 100644 --- a/Lib/Protocols/IdFTPListParseTOPS20.pas +++ b/Lib/Protocols/IdFTPListParseTOPS20.pas @@ -140,8 +140,9 @@ class function TIdFTPLPTOPS20.CheckListing(AListing: TStrings; Result := IsHHMMSS(s, ':'); {do not localize} end; s := LParts[3]; - - Result := IsDDMonthYY(Fetch(s), '-'); {do not localize} + if Result then begin + Result := IsDDMonthYY(Fetch(s), '-'); {do not localize} + end; if Result then begin Result := IsHHMMSS(s, ':'); {do not localize} end; diff --git a/Lib/Protocols/IdIMAP4Server.pas b/Lib/Protocols/IdIMAP4Server.pas index 207a127c2..96445ed0a 100644 --- a/Lib/Protocols/IdIMAP4Server.pas +++ b/Lib/Protocols/IdIMAP4Server.pas @@ -359,7 +359,7 @@ TIdIMAP4Server = class(TIdExplicitTLSServer) procedure SendUnsupportedCommand(ASender: TIdCommand); procedure SendIncorrectNumberOfParameters(ASender: TIdCommand); procedure SendUnassignedDefaultMechanism(ASender: TIdCommand); - procedure DoReplyUnknownCommand(AContext: TIdContext; AText: string); override; + procedure DoReplyUnknownCommand(AContext: TIdContext; const AText: string); override; procedure SendErrorOpenedReadOnly(ASender: TIdCommand); procedure SendOkReply(ASender: TIdCommand; const AText: string); procedure SendBadReply(ASender: TIdCommand; const AText: string); overload; @@ -658,7 +658,7 @@ function TIdIMAP4PeerContext.GetUsingTLS: Boolean; end; end; -procedure TIdIMAP4Server.DoReplyUnknownCommand(AContext: TIdContext; AText: string); +procedure TIdIMAP4Server.DoReplyUnknownCommand(AContext: TIdContext; const AText: string); //AText is ignored by TIdIMAP4Server var LText: string; diff --git a/Lib/Protocols/IdIRC.pas b/Lib/Protocols/IdIRC.pas index dfcf4aa1b..329eb9257 100644 --- a/Lib/Protocols/IdIRC.pas +++ b/Lib/Protocols/IdIRC.pas @@ -239,7 +239,7 @@ TIdIRC = class(TIdCmdTCPClient) procedure ParseDCC(AContext: TIdContext; const ADCC: String); //Command handlers procedure DoBeforeCmd(ASender: TIdCommandHandlers; var AData: string; AContext: TIdContext); - procedure DoReplyUnknownCommand(AContext: TIdContext; ALine: string); override; + procedure DoReplyUnknownCommand(AContext: TIdContext; const ALine: string); override; procedure DoBounce(ASender: TIdCommand; ALegacy: Boolean); procedure CommandPRIVMSG(ASender: TIdCommand); procedure CommandNOTICE(ASender: TIdCommand); @@ -673,16 +673,21 @@ procedure ExtractCTCPs(var AText: String; CTCPs: TStrings); type TIdIRCCommandHandler = class(TIdCommandHandler) public - procedure DoParseParams(AUnparsedParams: string; AParams: TStrings); override; + procedure DoParseParams(const AUnparsedParams: string; AParams: TStrings); override; end; -procedure TIdIRCCommandHandler.DoParseParams(AUnparsedParams: string; AParams: TStrings); +procedure TIdIRCCommandHandler.DoParseParams(const AUnparsedParams: string; AParams: TStrings); +var LParams : String; begin + LParams := AUnparsedParams; AParams.BeginUpdate; try AParams.Clear; - while AUnparsedParams <> '' do begin - AParams.Add(FetchIRCParam(AUnparsedParams)); + if AUnparsedParams <> '' then begin + LParams := AUnparsedParams; + while LParams <> '' do begin + AParams.Add(FetchIRCParam(LParams)); + end; end; finally AParams.EndUpdate; @@ -1478,11 +1483,13 @@ procedure TIdIRC.DoBeforeCmd(ASender: TIdCommandHandlers; var AData: string; ACo end; end; -procedure TIdIRC.DoReplyUnknownCommand(AContext: TIdContext; ALine: string); +procedure TIdIRC.DoReplyUnknownCommand(AContext: TIdContext; const ALine: string); var ACmdCode: Integer; + LLine : String; begin - ACmdCode := IndyStrToInt(Fetch(ALine, ' '), -1); + LLine := ALine; + ACmdCode := IndyStrToInt(Fetch(LLine, ' '), -1); // case ACmdCode of 6, diff --git a/Lib/Protocols/IdPOP3Server.pas b/Lib/Protocols/IdPOP3Server.pas index 51b099546..a14b2e29b 100644 --- a/Lib/Protocols/IdPOP3Server.pas +++ b/Lib/Protocols/IdPOP3Server.pas @@ -293,7 +293,7 @@ TIdPOP3Server = class(TIdExplicitTLSServer) function CreateReplyUnknownCommand: TIdReply; override; procedure InitializeCommandHandlers; override; - procedure DoReplyUnknownCommand(AContext: TIdContext; ALine: string); override; + procedure DoReplyUnknownCommand(AContext: TIdContext; const ALine: string); override; function GetReplyClass: TIdReplyClass; override; function GetRepliesClass: TIdRepliesClass; override; procedure SendGreeting(AContext : TIdContext; AGreeting : TIdReply); override; @@ -327,7 +327,7 @@ implementation IdSSL, IdStack, SysUtils; -procedure TIdPOP3Server.DoReplyUnknownCommand(AContext: TIdContext; ALine: string); +procedure TIdPOP3Server.DoReplyUnknownCommand(AContext: TIdContext; const ALine: string); var LReply: TIdReply; LLine : String; diff --git a/Lib/Protocols/IdSMTPServer.pas b/Lib/Protocols/IdSMTPServer.pas index 7bb675d67..84a72687d 100644 --- a/Lib/Protocols/IdSMTPServer.pas +++ b/Lib/Protocols/IdSMTPServer.pas @@ -211,7 +211,7 @@ TIdSMTPServer = class(TIdExplicitTLSServer) function GetReplyClass: TIdReplyClass; override; function GetRepliesClass: TIdRepliesClass; override; procedure InitComponent; override; - procedure DoReplyUnknownCommand(AContext: TIdContext; ALine: string); override; + procedure DoReplyUnknownCommand(AContext: TIdContext; const ALine: string); override; procedure InitializeCommandHandlers; override; // procedure DoReset(AContext: TIdSMTPServerContext; AIsTLSReset: Boolean = False); @@ -390,7 +390,7 @@ procedure TIdSMTPServer.CommandEHLO(ASender: TIdCommand); end; end; -procedure TIdSMTPServer.DoReplyUnknownCommand(AContext: TIdContext; ALine: string); +procedure TIdSMTPServer.DoReplyUnknownCommand(AContext: TIdContext; const ALine: string); begin CmdSyntaxError(AContext, ALine); end; diff --git a/Lib/Protocols/IdURI.pas b/Lib/Protocols/IdURI.pas index fe43fbd50..83a839252 100644 --- a/Lib/Protocols/IdURI.pas +++ b/Lib/Protocols/IdURI.pas @@ -99,7 +99,7 @@ TIdURI = class function GetFullURI(const AOptionalFields: TIdURIOptionalFieldsSet = [ofAuthInfo, ofBookmark]): String; function GetPathAndParams: String; class procedure NormalizePath(var APath: string); - class function URLDecode(ASrc: string; AByteEncoding: IIdTextEncoding = nil + class function URLDecode(const ASrc: string; AByteEncoding: IIdTextEncoding = nil {$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF} ): string; class function URLEncode(const ASrc: string; AByteEncoding: IIdTextEncoding = nil @@ -338,7 +338,7 @@ function TIdURI.GetURI: String; Result := GetFullURI([]); end; -class function TIdURI.URLDecode(ASrc: string; AByteEncoding: IIdTextEncoding = nil +class function TIdURI.URLDecode(const ASrc: string; AByteEncoding: IIdTextEncoding = nil {$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF} ): string; var From f8ee46c40ee5a0951127f142bf7a2a0df97c2d2c Mon Sep 17 00:00:00 2001 From: "J. Peter Mugaas" Date: Wed, 2 Oct 2024 10:10:56 -0400 Subject: [PATCH 3/3] More string to const string fixes. --- Lib/Protocols/IdAuthentication.pas | 4 +- Lib/Protocols/IdCoderHeader.pas | 8 +- Lib/Protocols/IdDNSCommon.pas | 8 +- Lib/Protocols/IdDNSResolver.pas | 9 +- Lib/Protocols/IdDNSServer.pas | 55 ++++----- Lib/Protocols/IdDateTimeStamp.pas | 8 +- Lib/Protocols/IdEchoUDP.pas | 4 +- Lib/Protocols/IdFinger.pas | 4 +- Lib/Protocols/IdGopher.pas | 79 +++++++------ Lib/Protocols/IdGopherServer.pas | 20 ++-- Lib/Protocols/IdHL7.pas | 8 +- Lib/Protocols/IdHTTP.pas | 96 ++++++++-------- Lib/Protocols/IdIMAP4.pas | 128 ++++++++++----------- Lib/Protocols/IdIMAP4Server.pas | 12 +- Lib/Protocols/IdIPWatch.pas | 4 +- Lib/Protocols/IdIdentServer.pas | 8 +- Lib/Protocols/IdMessage.pas | 4 +- Lib/Protocols/IdMessageParts.pas | 13 ++- Lib/Protocols/IdNNTP.pas | 161 ++++++++++++++------------- Lib/Protocols/IdRemoteCMDClient.pas | 4 +- Lib/Protocols/IdRemoteCMDServer.pas | 8 +- Lib/Protocols/IdReplyIMAP4.pas | 4 +- Lib/Protocols/IdSMTP.pas | 8 +- Lib/Protocols/IdSMTPRelay.pas | 4 +- Lib/Protocols/IdSMTPServer.pas | 4 +- Lib/Protocols/IdSNMP.pas | 12 +- Lib/Protocols/IdSNPP.pas | 12 +- Lib/Protocols/IdSocksServer.pas | 2 +- Lib/Protocols/IdTrivialFTPBase.pas | 8 +- Lib/Protocols/IdTrivialFTPServer.pas | 4 +- Lib/Protocols/IdVCard.pas | 14 +-- 31 files changed, 367 insertions(+), 350 deletions(-) diff --git a/Lib/Protocols/IdAuthentication.pas b/Lib/Protocols/IdAuthentication.pas index ea7010b83..da1d2e26f 100644 --- a/Lib/Protocols/IdAuthentication.pas +++ b/Lib/Protocols/IdAuthentication.pas @@ -68,7 +68,7 @@ TIdAuthentication = class(TPersistent) FAuthParams: TIdHeaderList; FCharset: string; - function ReadAuthInfo(AuthName: String): String; + function ReadAuthInfo(const AuthName: String): String; function DoNext: TIdAuthWhatsNext; virtual; abstract; procedure SetAuthParams(AValue: TIdHeaderList); function GetPassword: String; @@ -226,7 +226,7 @@ procedure TIdAuthentication.SetAuthParams(AValue: TIdHeaderList); FAuthParams.Assign(AValue); end; -function TIdAuthentication.ReadAuthInfo(AuthName: String): String; +function TIdAuthentication.ReadAuthInfo(const AuthName: String): String; Var i: Integer; begin diff --git a/Lib/Protocols/IdCoderHeader.pas b/Lib/Protocols/IdCoderHeader.pas index 7dc5ad9ad..de1cfbe1d 100644 --- a/Lib/Protocols/IdCoderHeader.pas +++ b/Lib/Protocols/IdCoderHeader.pas @@ -105,13 +105,13 @@ interface // Procs function EncodeAddressItem(EmailAddr: TIdEmailAddressItem; const HeaderEncoding: Char; const MimeCharSet: string; AUseAddressForNameIfNameMissing: Boolean = False): string; - function EncodeHeader(const Header: string; Specials: String; const HeaderEncoding: Char; + function EncodeHeader(const Header: string; const Specials: String; const HeaderEncoding: Char; const MimeCharSet: string): string; function EncodeAddress(EmailAddr: TIdEMailAddressList; const HeaderEncoding: Char; const MimeCharSet: string; AUseAddressForNameIfNameMissing: Boolean = False): string; function DecodeHeader(const Header: string): string; procedure DecodeAddress(EMailAddr: TIdEmailAddressItem); - procedure DecodeAddresses(AEMails: String; EMailAddr: TIdEmailAddressList); + procedure DecodeAddresses(const AEMails: String; EMailAddr: TIdEmailAddressList); implementation @@ -385,7 +385,7 @@ procedure DecodeAddress(EMailAddr : TIdEmailAddressItem); EMailAddr.Name := UnquotedStr(DecodeHeader(EMailAddr.Name)); end; -procedure DecodeAddresses(AEMails : String; EMailAddr: TIdEmailAddressList); +procedure DecodeAddresses(const AEMails : String; EMailAddr: TIdEmailAddressList); var idx : Integer; begin @@ -412,7 +412,7 @@ function EncodeAddress(EmailAddr: TIdEMailAddressList; const HeaderEncoding: Cha end; { encode a header field if non-ASCII characters are used } -function EncodeHeader(const Header: string; Specials: String; const HeaderEncoding: Char; +function EncodeHeader(const Header: string; const Specials: String; const HeaderEncoding: Char; const MimeCharSet: string): string; const SPACES = [Ord(' '), 9, 13, 10]; {Do not Localize} diff --git a/Lib/Protocols/IdDNSCommon.pas b/Lib/Protocols/IdDNSCommon.pas index f94c8c51e..c1c5c4217 100644 --- a/Lib/Protocols/IdDNSCommon.pas +++ b/Lib/Protocols/IdDNSCommon.pas @@ -380,7 +380,7 @@ TIdTextModeResourceRecord = class(TObject) property RRDatas : TStrings read FRRDatas write SetRRDatas; property TTL : integer read FTTL write SetTTL; property TimeOut : string read FTimeOut write FTimeOut; - function ifAddFullName(AFullName: string; AGivenName: string = ''): boolean; + function ifAddFullName(const AFullName: string; const AGivenName: string = ''): boolean; function GetValue(const AName: String): String; procedure SetValue(const AName: String; const AValue: String); function ItemCount : Integer; @@ -610,7 +610,7 @@ function ConvertToCanonical6IP(const OrgIP : String) : string; function IPv6AAAAToDNSStr(const AIPv6Address : String): TIdBytes; function GetErrorStr(const Code, Id: Integer): String; function GetRCodeStr(RCode : Integer): String; -function ReplaceSpecString(Source, Target, NewString : string; ReplaceAll : boolean = True) : string; +function ReplaceSpecString(const Source, Target, NewString : string; ReplaceAll : boolean = True) : string; function IsBig5(ch1, ch2: Char) : Boolean; implementation @@ -1292,7 +1292,7 @@ procedure TIdTextModeResourceRecord.SetValue(const AName: String; const AValue: RRDatas.Values[AName] := AValue; end; -function TIdTextModeResourceRecord.ifAddFullName(AFullName, AGivenName: string): boolean; +function TIdTextModeResourceRecord.ifAddFullName(const AFullName, AGivenName: string): boolean; var LTailString, LBackString, LDestination : string; LTS, LRR : integer; @@ -1994,7 +1994,7 @@ constructor TIdRR_Error.Create; inherited CreateInit('', TypeCode_Error); {do not localize} end; -function ReplaceSpecString(Source, Target, NewString : string; ReplaceAll : boolean = True) : string; +function ReplaceSpecString(const Source, Target, NewString : string; ReplaceAll : boolean = True) : string; var FixingString, MiddleString, FixedString : string; begin diff --git a/Lib/Protocols/IdDNSResolver.pas b/Lib/Protocols/IdDNSResolver.pas index e707411e5..c3810ecd6 100644 --- a/Lib/Protocols/IdDNSResolver.pas +++ b/Lib/Protocols/IdDNSResolver.pas @@ -545,11 +545,11 @@ TIdDNSResolver = class(TIdTCPConnection) procedure ClearInternalQuery; destructor Destroy; override; procedure ParseAnswers(DNSHeader: TDNSHeader; Answer: TIdBytes; ResetResult: Boolean = True); - procedure CreateQuery(ADomain: string; SOARR : TIdRR_SOA; QueryClass:integer = Class_IN); + procedure CreateQuery(const ADomain: string; SOARR : TIdRR_SOA; QueryClass:integer = Class_IN); procedure FillResult(AResult: TIdBytes; checkID : boolean = true; ResetResult : boolean = true); procedure FillResultWithOutCheckId(AResult: TIdBytes); {$IFDEF HAS_DEPRECATED}deprecated{$IFDEF HAS_DEPRECATED_MSG} 'Use FillResult() with checkID=False'{$ENDIF};{$ENDIF} - procedure Resolve(ADomain: string; SOARR : TIdRR_SOA = nil; QClass: integer = Class_IN); + procedure Resolve(const ADomain: string; SOARR : TIdRR_SOA = nil; QClass: integer = Class_IN); property QueryResult: TQueryResult read FQueryResult; property InternalQuery: TIdBytes read FInternalQuery write SetInternalQuery; property PlainTextResult: TIdBytes read FPlainTextResult write SetPlainTextResult; @@ -1202,13 +1202,14 @@ procedure TIdDNSResolver.ClearInternalQuery; FQuestionLength := 0; end; -procedure TIdDNSResolver.CreateQuery(ADomain: string; SOARR : TIdRR_SOA; +procedure TIdDNSResolver.CreateQuery(const ADomain: string; SOARR : TIdRR_SOA; QueryClass:integer=1); function DoDomainName(ADNS : String): TIdBytes; var BufStr : String; LLen : Byte; + LDNS : String; begin SetLength(Result, 0); while Length(ADNS) > 0 do begin @@ -1596,7 +1597,7 @@ procedure TIdDNSResolver.ParseAnswers(DNSHeader: TDNSHeader; Answer: TIdBytes; end; end; -procedure TIdDNSResolver.Resolve(ADomain: string; SOARR : TIdRR_SOA = nil; +procedure TIdDNSResolver.Resolve(const ADomain: string; SOARR : TIdRR_SOA = nil; QClass: integer = Class_IN); var UDP_Tunnel : TIdUDPClient; diff --git a/Lib/Protocols/IdDNSServer.pas b/Lib/Protocols/IdDNSServer.pas index 91f72d6db..542dd9b91 100644 --- a/Lib/Protocols/IdDNSServer.pas +++ b/Lib/Protocols/IdDNSServer.pas @@ -421,8 +421,8 @@ TIdDNTreeNode = class(TIdMWayTreeNode) procedure RemoveChild(Index : Integer); procedure SortChildren; procedure Clear; - procedure SaveToFile(Filename : String); - function IndexByLabel(CLabel : String): Integer; + procedure SaveToFile(const Filename : String); + function IndexByLabel(const CLabel : String): Integer; function IndexByNode(ANode : TIdDNTreeNode) : Integer; end; @@ -460,11 +460,11 @@ TIdDNS_ProcessThread = class(TIdThread) WildCardOrgName: string = ''); procedure ExternalSearch(ADNSResolver: TIdDNSResolver; Header: TDNSHeader; Question: TIdBytes; var Answer: TIdBytes); - function CompleteQuery(DNSHeader: TDNSHeader; Question: string; + function CompleteQuery(DNSHeader: TDNSHeader; const Question: string; OriginalQuestion: TIdBytes; var Answer : TIdBytes; QType, QClass : UInt16; DNSResolver : TIdDNSResolver) : string; - procedure SaveToCache(ResourceRecord : TIdBytes; QueryName : string; OriginalQType : UInt16); - function SearchTree(Root : TIdDNTreeNode; QName : String; QType : UInt16): TIdDNTreeNode; + procedure SaveToCache(ResourceRecord : TIdBytes; const QueryName : string; OriginalQType : UInt16); + function SearchTree(Root : TIdDNTreeNode; const QName : String; QType : UInt16): TIdDNTreeNode; procedure Run; override; procedure QueryDomain; @@ -522,8 +522,8 @@ TIdDNS_UDPServer = class(TIdUDPServer) procedure SetHanded_DomainList(const Value: TStrings); procedure InternalSearch(Header: TDNSHeader; QName: string; QType: UInt16; var Answer: TIdBytes; IfMainQuestion: boolean; IsSearchCache: Boolean = False; - IsAdditional: Boolean = False; IsWildCard : Boolean = False; - WildCardOrgName: string = ''); + IsAdditional: Boolean = False; const IsWildCard : Boolean = False; + const WildCardOrgName: string = ''); procedure ExternalSearch(ADNSResolver: TIdDNSResolver; Header: TDNSHeader; Question: TIdBytes; var Answer: TIdBytes); //modified in May 2004 by Dennies Chang. @@ -541,16 +541,16 @@ TIdDNS_UDPServer = class(TIdUDPServer) public destructor Destroy; override; function AXFR(Header : TDNSHeader; Question : string; var Answer : TIdBytes) : string; - function CompleteQuery(DNSHeader: TDNSHeader; Question: string; + function CompleteQuery(DNSHeader: TDNSHeader; const Question: string; OriginalQuestion: TIdBytes; var Answer : TIdBytes; QType, QClass : UInt16; DNSResolver : TIdDNSResolver) : string; {$IFDEF HAS_DEPRECATED}deprecated;{$ENDIF} - function LoadZoneFromMasterFile(MasterFileName : String) : boolean; + function LoadZoneFromMasterFile(const MasterFileName : String) : boolean; function LoadZoneStrings(FileStrings: TStrings; Filename : String; TreeRoot : TIdDNTreeNode): Boolean; - function SearchTree(Root : TIdDNTreeNode; QName : String; QType : UInt16): TIdDNTreeNode; + function SearchTree(Root : TIdDNTreeNode; const QName : String; QType : UInt16): TIdDNTreeNode; procedure UpdateTree(TreeRoot : TIdDNTreeNode; RR : TIdTextModeResourceRecord); overload; - function FindNodeFullName(Root : TIdDNTreeNode; QName : String; QType : UInt16) : string; - function FindHandedNodeByName(QName : String; QType : UInt16) : TIdDNTreeNode; + function FindNodeFullName(Root : TIdDNTreeNode; const QName : String; QType : UInt16) : string; + function FindHandedNodeByName(const QName : String; QType : UInt16) : TIdDNTreeNode; procedure UpdateTree(TreeRoot : TIdDNTreeNode; RR : TResultRecord); overload; property RootDNS_NET : TStrings read FRootDNS_NET write SetRootDNS_NET; @@ -858,7 +858,7 @@ function TIdDNTreeNode.GetNode(Index: Integer): TIdDNTreeNode; Result := TIdDNTreeNode(SubTree.Items[Index]); end; -function TIdDNTreeNode.IndexByLabel(CLabel: String): Integer; +function TIdDNTreeNode.IndexByLabel(const CLabel: String): Integer; begin Result := FChildIndex.IndexOf(CLabel); end; @@ -885,7 +885,7 @@ procedure TIdDNTreeNode.RemoveChild(Index: Integer); FChildIndex.Delete(Index); end; -procedure TIdDNTreeNode.SaveToFile(Filename: String); +procedure TIdDNTreeNode.SaveToFile(const Filename: String); var DNSs : TStrings; begin @@ -934,7 +934,7 @@ procedure TIdDNTreeNode.SortChildren; { TIdDNSServer } {$I IdDeprecatedImplBugOff.inc} -function TIdDNS_UDPServer.CompleteQuery(DNSHeader : TDNSHeader; Question: string; +function TIdDNS_UDPServer.CompleteQuery(DNSHeader : TDNSHeader; const Question: string; OriginalQuestion: TIdBytes; var Answer: TIdBytes; QType, QClass: UInt16; DNSResolver : TIdDNSResolver): string; {$I IdDeprecatedImplBugOn.inc} @@ -1115,12 +1115,12 @@ procedure TIdDNS_UDPServer.ExternalSearch(ADNSResolver : TIdDNSResolver; end; end; -function TIdDNS_UDPServer.FindHandedNodeByName(QName: String; QType: UInt16): TIdDNTreeNode; +function TIdDNS_UDPServer.FindHandedNodeByName(const QName: String; QType: UInt16): TIdDNTreeNode; begin Result := SearchTree(Handed_Tree, QName, QType); end; -function TIdDNS_UDPServer.FindNodeFullName(Root: TIdDNTreeNode; QName: String; QType : UInt16): string; +function TIdDNS_UDPServer.FindNodeFullName(Root: TIdDNTreeNode; const QName: String; QType : UInt16): string; var MyNode : TIdDNTreeNode; begin @@ -1132,7 +1132,7 @@ function TIdDNS_UDPServer.FindNodeFullName(Root: TIdDNTreeNode; QName: String; Q end; end; -function TIdDNS_UDPServer.LoadZoneFromMasterFile(MasterFileName: String): Boolean; +function TIdDNS_UDPServer.LoadZoneFromMasterFile(const MasterFileName: String): Boolean; var FileStrings : TStrings; begin @@ -1157,7 +1157,7 @@ function TIdDNS_UDPServer.LoadZoneStrings(FileStrings: TStrings; Filename : Stri var TagList : TStrings; - function IsMSDNSFileName(theFileName : String; var DN: string) : Boolean; + function IsMSDNSFileName(const theFileName : String; var DN: string) : Boolean; var namepart : TStrings; Fullname : string; @@ -1947,7 +1947,7 @@ procedure TIdDNS_UDPServer.SaveToCache(ResourceRecord: TIdBytes; QueryName : str end; end; -function TIdDNS_UDPServer.SearchTree(Root: TIdDNTreeNode; QName: String; QType : UInt16): TIdDNTreeNode; +function TIdDNS_UDPServer.SearchTree(Root: TIdDNTreeNode; const QName: String; QType : UInt16): TIdDNTreeNode; var RRIndex : integer; NodeCursor : TIdDNTreeNode; @@ -2648,10 +2648,11 @@ function TIdDNS_UDPServer.AXFR(Header : TDNSHeader; Question: string; var Answer end; end; -procedure TIdDNS_UDPServer.InternalSearch(Header: TDNSHeader; QName: string; - QType : UInt16; var Answer: TIdBytes; IfMainQuestion : Boolean; - IsSearchCache : Boolean = False; IsAdditional : Boolean = False; - IsWildCard : Boolean = False; WildCardOrgName : string = ''); +procedure TIdDNS_UDPServer.InternalSearch(Header: TDNSHeader; QName: string; QType: UInt16; + var Answer: TIdBytes; IfMainQuestion: boolean; IsSearchCache: Boolean = False; + IsAdditional: Boolean = False; const IsWildCard : Boolean = False; + const WildCardOrgName: string = ''); + var MoreAddrSearch : TStrings; TargetNode : TIdDNTreeNode; @@ -3876,7 +3877,7 @@ procedure TIdDNS_ProcessThread.InternalSearch(Header: TDNSHeader; QName: string; begin end; -procedure TIdDNS_ProcessThread.SaveToCache(ResourceRecord: TIdBytes; QueryName: string; OriginalQType: UInt16); +procedure TIdDNS_ProcessThread.SaveToCache(ResourceRecord: TIdBytes; const QueryName: string; OriginalQType: UInt16); var TempResolver : TIdDNSResolver; Count : Integer; @@ -3908,7 +3909,7 @@ procedure TIdDNS_ProcessThread.SaveToCache(ResourceRecord: TIdBytes; QueryName: end; end; -function TIdDNS_ProcessThread.SearchTree(Root: TIdDNTreeNode; QName: String; QType: UInt16): TIdDNTreeNode; +function TIdDNS_ProcessThread.SearchTree(Root: TIdDNTreeNode; const QName: String; QType: UInt16): TIdDNTreeNode; var RRIndex : integer; NodeCursor : TIdDNTreeNode; @@ -3986,7 +3987,7 @@ function TIdDNS_ProcessThread.SearchTree(Root: TIdDNTreeNode; QName: String; QTy end; function TIdDNS_ProcessThread.CompleteQuery(DNSHeader: TDNSHeader; - Question: string; OriginalQuestion: TIdBytes; var Answer : TIdBytes; + const Question: string; OriginalQuestion: TIdBytes; var Answer : TIdBytes; QType, QClass : UInt16; DNSResolver : TIdDNSResolver) : string; var IsMyDomains : boolean; diff --git a/Lib/Protocols/IdDateTimeStamp.pas b/Lib/Protocols/IdDateTimeStamp.pas index da0a6158b..b59c44aea 100644 --- a/Lib/Protocols/IdDateTimeStamp.pas +++ b/Lib/Protocols/IdDateTimeStamp.pas @@ -415,8 +415,8 @@ TIdDateTimeStamp = class(TIdBaseComponent) function GetWeekOfYear : Integer; procedure SetFromDOSDateTime(ADate, ATime : Word); - procedure SetFromISO8601(AString : String); - procedure SetFromRFC822(AString : String); + procedure SetFromISO8601(const AString : String); + procedure SetFromRFC822(const AString : String); procedure SetFromTDateTime(ADateTime : TDateTime); procedure SetFromTTimeStamp(ATimeStamp : TIdDateTimeStamp); @@ -1154,7 +1154,7 @@ procedure TIdDateTimeStamp.SetTimeFromISO8601(AString: String); end; end; -procedure TIdDateTimeStamp.SetFromISO8601(AString: String); +procedure TIdDateTimeStamp.SetFromISO8601(const AString: String); var i : Integer; begin @@ -1171,7 +1171,7 @@ procedure TIdDateTimeStamp.SetFromISO8601(AString: String); end; end; -procedure TIdDateTimeStamp.SetFromRFC822(AString: String); +procedure TIdDateTimeStamp.SetFromRFC822(const AString: String); begin SetFromTDateTime(StrInternetToDateTime(AString)) end; diff --git a/Lib/Protocols/IdEchoUDP.pas b/Lib/Protocols/IdEchoUDP.pas index ed11472bd..f1f4ca3f3 100644 --- a/Lib/Protocols/IdEchoUDP.pas +++ b/Lib/Protocols/IdEchoUDP.pas @@ -45,7 +45,7 @@ TIdEchoUDP = class(TIdUDPClient) procedure InitComponent; override; public {This sends Text to the peer and returns the reply from the peer} - Function Echo(AText: String): String; + Function Echo(const AText: String): String; {Time taken to send and receive data} Property EchoTime: UInt32 read FEchoTime; published @@ -69,7 +69,7 @@ procedure TIdEchoUDP.InitComponent; Port := IdPORT_ECHO; end; -function TIdEchoUDP.Echo(AText: String): String; +function TIdEchoUDP.Echo(const AText: String): String; var StartTime: TIdTicks; LEncoding: IIdTextEncoding; diff --git a/Lib/Protocols/IdFinger.pas b/Lib/Protocols/IdFinger.pas index bf8242ecf..ea399972e 100644 --- a/Lib/Protocols/IdFinger.pas +++ b/Lib/Protocols/IdFinger.pas @@ -70,7 +70,7 @@ TIdFinger = class(TIdTCPClientCustom) protected FQuery: String; FVerboseOutput: Boolean; - Procedure SetCompleteQuery(AQuery: String); + Procedure SetCompleteQuery(const AQuery: String); Function GetCompleteQuery: String; Procedure InitComponent; override; public @@ -133,7 +133,7 @@ function TIdFinger.GetCompleteQuery: String; Result := FQuery + '@' + Host; {Do not Localize} end; -procedure TIdFinger.SetCompleteQuery(AQuery: String); +procedure TIdFinger.SetCompleteQuery(const AQuery: String); var p : Integer; begin diff --git a/Lib/Protocols/IdGopher.pas b/Lib/Protocols/IdGopher.pas index c2f7f9759..c0841743d 100644 --- a/Lib/Protocols/IdGopher.pas +++ b/Lib/Protocols/IdGopher.pas @@ -215,30 +215,30 @@ TIdGopher = class ( TIdTCPClientCustom ) {This fires an exception for Gopher+ errors} Procedure ProcessGopherError; {This takes parses a string and makes a Menu Item for it} - Function MenuItemFromString ( stLine : String; Menu : TIdGopherMenu) + Function MenuItemFromString ( const stLine : String; Menu : TIdGopherMenu) : TIdGopherMenuItem; {Process the menu while we retreive it} - Function ProcessDirectory ( PreviousData : String = ''; {Do not Localize} + Function ProcessDirectory ( const PreviousData : String = ''; {Do not Localize} const ExpectedLength: Integer = 0) : TIdGopherMenu; {This processes extended Gopher Menues} - Function LoadExtendedDirectory ( PreviousData : String = ''; {Do not Localize} + Function LoadExtendedDirectory ( const PreviousData : String = ''; {Do not Localize} const ExpectedLength: Integer = 0) : TIdGopherMenu; {This processes the file when we retreive it and puts it in ADestStream. } - procedure ProcessFile ( ADestStream : TStream; APreviousData : String = ''; {Do not Localize} + procedure ProcessFile ( ADestStream : TStream; const APreviousData : String = ''; {Do not Localize} const ExpectedLength : Integer = 0); {For Gopher +, we call this routine when we get a -2 length which means, read until you see EOL+.+EOL} Procedure ProcessTextFile ( ADestStream : TStream; - APreviousData: String = ''; const ExpectedLength: Integer = 0); {Do not Localize} + const APreviousData: String = ''; const ExpectedLength: Integer = 0); {Do not Localize} procedure InitComponent; override; public { Public declarations } - Function GetMenu (ASelector : String; IsGopherPlus : Boolean = False; AView : String = '' ) : {Do not Localize} + Function GetMenu (const ASelector : String; IsGopherPlus : Boolean = False; const AView : String = '' ) : {Do not Localize} TIdGopherMenu; - Function Search(ASelector, AQuery : String) : TIdGopherMenu; - procedure GetFile (ASelector : String; ADestStream : TStream; IsGopherPlus : Boolean = False; AView: String = ''); {Do not Localize} - procedure GetTextFile(ASelector : String; ADestStream : TStream; IsGopherPlus : Boolean = False; AView: String = ''); {Do not Localize} - Function GetExtendedMenu (ASelector : String; AView: String = '' ) : TIdGopherMenu; {Do not Localize} + Function Search(const ASelector, AQuery : String) : TIdGopherMenu; + procedure GetFile (const ASelector : String; ADestStream : TStream; IsGopherPlus : Boolean = False; const AView: String = ''); {Do not Localize} + procedure GetTextFile(const ASelector : String; ADestStream : TStream; IsGopherPlus : Boolean = False; const AView: String = ''); {Do not Localize} + Function GetExtendedMenu (const ASelector : String; const AView: String = '' ) : TIdGopherMenu; {Do not Localize} published { Published declarations } property OnMenuItem : TIdGopherMenuEvent read FOnMenuItem write FOnMenuItem; @@ -279,11 +279,13 @@ procedure TIdGopher.ProcessGopherError; LastCmdResult.RaiseReplyError; end; -function TIdGopher.MenuItemFromString(stLine: String; +function TIdGopher.MenuItemFromString(const stLine: String; Menu: TIdGopherMenu): TIdGopherMenuItem; +var LLine : String; begin + LLine := stLine; {just in case a space thows things off} - stLine := Trim(stLine); + LLine := Trim(LLine); if Assigned ( Menu ) then begin Result := Menu.Add; @@ -293,7 +295,7 @@ function TIdGopher.MenuItemFromString(stLine: String; Result := TIdGopherMenuItem.Create( nil ); end; // else .. if Assigned ( Menu ) then {title and Item Type} - Result.Title := Fetch ( stLine, TAB ); + Result.Title := Fetch ( LLine, TAB ); if Length ( Result.Title ) > 0 then begin Result.ItemType := Result.Title [ 1 ]; @@ -305,30 +307,32 @@ function TIdGopher.MenuItemFromString(stLine: String; {drop first charactor because that was the item type indicator} Result.Title := Copy ( Result.Title, 2, Length ( Result.Title ) ); {selector string} - Result.Selector := Fetch ( stLine, TAB ); + Result.Selector := Fetch ( LLine, TAB ); {server} - Result.Server := Fetch ( stLine, TAB ); + Result.Server := Fetch ( LLine, TAB ); {port} - Result.Port := IndyStrToInt ( Fetch ( stLine, TAB ) ); + Result.Port := IndyStrToInt ( Fetch ( LLine, TAB ) ); {is Gopher + Item} - stLine := Fetch ( stLine, TAB ); + LLine := Fetch ( LLine, TAB ); Result.GopherPlusItem := ( (Length ( stLine) > 0 ) and ( stLine [ 1 ] = '+' ) ); {Do not Localize} end; -Function TIdGopher.LoadExtendedDirectory ( PreviousData : String = ''; {Do not Localize} +Function TIdGopher.LoadExtendedDirectory ( const PreviousData : String = ''; {Do not Localize} const ExpectedLength: Integer = 0) : TIdGopherMenu; var stLine : String; gmnu : TIdGopherMenuItem; + LPreviousData : String; begin + LPreviousData := PreviousData; BeginWork(wmRead, ExpectedLength); try Result := TIdGopherMenu.Create; gmnu := nil; repeat - stLine := PreviousData + IOHandler.ReadLn; + stLine := LPreviousData + IOHandler.ReadLn; {we use the Previous data only ONCE} - PreviousData := ''; {Do not Localize} + LPreviousData := ''; {Do not Localize} {we process each line only if it is not the last and the OnMenuItem is assigned} if ( stLine <> '.' ) then {Do not Localize} @@ -366,17 +370,17 @@ function TIdGopher.MenuItemFromString(stLine: String; finally EndWork(wmRead); end; end; -Function TIdGopher.ProcessDirectory ( PreviousData : String = ''; {Do not Localize} +Function TIdGopher.ProcessDirectory (const PreviousData : String = ''; {Do not Localize} const ExpectedLength: Integer = 0) : TIdGopherMenu; var stLine : String; - + LPreviousData : String; begin BeginWork(wmRead,ExpectedLength); try Result := TIdGopherMenu.Create; repeat - stLine := PreviousData + IOHandler.ReadLn; + stLine := LPreviousData + IOHandler.ReadLn; {we use the Previous data only ONCE} - PreviousData := ''; {Do not Localize} + LPreviousData := ''; {Do not Localize} {we process each line only if it is not the last and the OnMenuItem is assigned} if ( stLine <> '.' ) then {Do not Localize} @@ -390,7 +394,7 @@ function TIdGopher.MenuItemFromString(stLine: String; end; //try..finally end; -procedure TIdGopher.ProcessTextFile(ADestStream : TStream; APreviousData: String = ''; {Do not Localize} +procedure TIdGopher.ProcessTextFile(ADestStream : TStream; const APreviousData: String = ''; {Do not Localize} const ExpectedLength: Integer = 0); var LEnc: IIdTextEncoding; @@ -405,7 +409,7 @@ procedure TIdGopher.ProcessTextFile(ADestStream : TStream; APreviousData: String end; //try..finally end; -procedure TIdGopher.ProcessFile ( ADestStream : TStream; APreviousData : String = ''; {Do not Localize} +procedure TIdGopher.ProcessFile ( ADestStream : TStream; const APreviousData : String = ''; {Do not Localize} const ExpectedLength : Integer = 0); var LEnc: IIdTextEncoding; @@ -421,7 +425,7 @@ procedure TIdGopher.ProcessFile ( ADestStream : TStream; APreviousData : String end; end; -Function TIdGopher.Search(ASelector, AQuery : String) : TIdGopherMenu; +Function TIdGopher.Search(const ASelector, AQuery : String) : TIdGopherMenu; begin Connect; try @@ -433,11 +437,12 @@ procedure TIdGopher.ProcessFile ( ADestStream : TStream; APreviousData : String end; {try .. finally .. end } end; -procedure TIdGopher.GetFile (ASelector : String; ADestStream : TStream; +procedure TIdGopher.GetFile (const ASelector : String; ADestStream : TStream; IsGopherPlus : Boolean = False; - AView: String = ''); {Do not Localize} + const AView: String = ''); {Do not Localize} var Reply : Char; + LView : String; LengthBytes : Integer; {legnth of the gopher items} begin Connect; @@ -451,7 +456,7 @@ procedure TIdGopher.GetFile (ASelector : String; ADestStream : TStream; begin {I hope that this drops the size attribute and that this will cause the Views to work, I'm not sure} {Do not Localize} - AView := Trim ( Fetch ( AView, ':' ) ); {Do not Localize} + LView := Trim ( Fetch ( LView, ':' ) ); {Do not Localize} IOHandler.WriteLn ( ASelector + TAB +'+'+ AView ); {Do not Localize} {We read only one byte from the peer} Reply := Char(IOHandler.ReadByte); @@ -486,7 +491,7 @@ procedure TIdGopher.GetFile (ASelector : String; ADestStream : TStream; end; {try .. finally .. end } end; -function TIdGopher.GetMenu ( ASelector : String; IsGopherPlus : Boolean = False; AView : String = '' ) : {Do not Localize} +function TIdGopher.GetMenu ( const ASelector : String; IsGopherPlus : Boolean = False; const AView : String = '' ) : {Do not Localize} TIdGopherMenu; var Reply : Char; @@ -528,7 +533,7 @@ function TIdGopher.GetMenu ( ASelector : String; IsGopherPlus : Boolean = False; end; {try .. finally .. end } end; -Function TIdGopher.GetExtendedMenu(ASelector, AView: String) : TIdGopherMenu; +Function TIdGopher.GetExtendedMenu(const ASelector, AView: String) : TIdGopherMenu; var Reply : Char; LengthBytes : Integer; {legnth of the gopher items} @@ -558,11 +563,12 @@ function TIdGopher.GetMenu ( ASelector : String; IsGopherPlus : Boolean = False; end; {try .. finally .. end } end; -procedure TIdGopher.GetTextFile(ASelector: String; ADestStream: TStream; - IsGopherPlus: Boolean; AView: String); +procedure TIdGopher.GetTextFile(const ASelector: String; ADestStream: TStream; + IsGopherPlus: Boolean; const AView: String); var Reply : Char; LengthBytes : Integer; {length of the gopher items} + LView : String; begin Connect; try @@ -573,10 +579,11 @@ procedure TIdGopher.GetTextFile(ASelector: String; ADestStream: TStream; end // if not IsGopherPlus then else begin + LView := AView; {I hope that this drops the size attribute and that this will cause the Views to work, I'm not sure} {Do not Localize} - AView := Trim ( Fetch ( AView, ':' ) ); {Do not Localize} - IOHandler.WriteLn ( ASelector + TAB +'+'+ AView ); {Do not Localize} + LView := Trim ( Fetch ( LView, ':' ) ); {Do not Localize} + IOHandler.WriteLn ( ASelector + TAB +'+'+ LView ); {Do not Localize} {We read only one byte from the peer} Reply := Char(IOHandler.ReadByte); {Get the additonal reply code for error or success} diff --git a/Lib/Protocols/IdGopherServer.pas b/Lib/Protocols/IdGopherServer.pas index 740d22dfc..9f8534bba 100644 --- a/Lib/Protocols/IdGopherServer.pas +++ b/Lib/Protocols/IdGopherServer.pas @@ -91,11 +91,11 @@ TIdGopherServer = class(TIdCustomTCPServer) constructor Create(AOwner: TComponent); reintroduce; overload; {$ENDIF} function ReturnGopherItem(ItemType : Char; - UserFriendlyName, RealResourceName : String; - HostServer : String; HostPort : TIdPort): String; + const UserFriendlyName, RealResourceName : String; + const HostServer : String; HostPort : TIdPort): String; procedure SendDirectoryEntry(AContext:TIdContext; - ItemType : Char; UserFriendlyName, RealResourceName : String; - HostServer : String; HostPort : TIdPort); + ItemType : Char; const UserFriendlyName, RealResourceName : String; + const HostServer : String; HostPort : TIdPort); published property AdminEmail : String read fAdminEmail write fAdminEmail; property OnRequest: TRequestEvent read fOnRequest write fOnRequest; @@ -159,15 +159,17 @@ function TIdGopherServer.DoExecute(AContext: TIdContext): boolean; end; function TIdGopherServer.ReturnGopherItem(ItemType : Char; - UserFriendlyName, RealResourceName : String; - HostServer : String; HostPort : TIdPort): String; + const UserFriendlyName, RealResourceName : String; + const HostServer : String; HostPort : TIdPort): String; +var LUserFriendlyName : String; begin + LUserFriendlyName := UserFriendlyName; if fTruncateUserFriendly then begin - if (Length(UserFriendlyName) > fTruncateLength) and (fTruncateLength <> 0) then begin - UserFriendlyName := Copy(UserFriendlyName, 1, fTruncateLength); + if (Length(LUserFriendlyName) > fTruncateLength) and (fTruncateLength <> 0) then begin + LUserFriendlyName := Copy(LUserFriendlyName, 1, fTruncateLength); end; end; - Result := ItemType + UserFriendlyName + + Result := ItemType + LUserFriendlyName + TAB + RealResourceName + TAB + HostServer + TAB + IntToStr(HostPort); end; diff --git a/Lib/Protocols/IdHL7.pas b/Lib/Protocols/IdHL7.pas index f295cb3ff..4061b7860 100644 --- a/Lib/Protocols/IdHL7.pas +++ b/Lib/Protocols/IdHL7.pas @@ -163,7 +163,7 @@ EHL7CommunicationError = class(EIdException) protected FInterfaceName: String; public - constructor Create(AnInterfaceName, AMessage: String); + constructor Create(const AnInterfaceName, AMessage: String); property InterfaceName: String read FInterfaceName; end; @@ -320,7 +320,7 @@ TIdHL7 = class(TIdBaseComponent) function GetStatus: TIdHL7Status; function GetStatusDesc: String; - procedure InternalSetStatus(const AStatus: TIdHL7Status; ADesc: String); + procedure InternalSetStatus(const AStatus: TIdHL7Status; const ADesc: String); procedure CheckServerParameters; procedure StartServer; @@ -592,7 +592,7 @@ procedure TIdQueuedMessage.Wait; { EHL7CommunicationError } -constructor EHL7CommunicationError.Create(AnInterfaceName, AMessage: String); +constructor EHL7CommunicationError.Create(const AnInterfaceName, AMessage: String); begin //Assert(AInterfaceName <> '', 'Attempt to create an exception for an unnamed interface') //Assert(AMessage <> '', 'Attempt to create an exception with an empty message') @@ -860,7 +860,7 @@ function TIdHL7.GetStatusDesc: String; end; end; -procedure TIdHL7.InternalSetStatus(const AStatus: TIdHL7Status; ADesc: String); +procedure TIdHL7.InternalSetStatus(const AStatus: TIdHL7Status; const ADesc: String); begin Assert(Assigned(Self)); Assert((AStatus >= Low(TIdHL7Status)) and (AStatus <= High(TIdHL7Status)), 'Value for TIdHL7.CommunicationMode not in range'); {do not localize} diff --git a/Lib/Protocols/IdHTTP.pas b/Lib/Protocols/IdHTTP.pas index a975f38e1..ccaef9a62 100644 --- a/Lib/Protocols/IdHTTP.pas +++ b/Lib/Protocols/IdHTTP.pas @@ -499,7 +499,7 @@ TIdCustomHTTP = class(TIdTCPClientCustom) procedure SetHost(const Value: string); override; procedure SetPort(const Value: integer); override; } - procedure DoRequest(const AMethod: TIdHTTPMethod; AURL: string; + procedure DoRequest(const AMethod: TIdHTTPMethod; const AURL: string; ASource, AResponseContent: TStream; AIgnoreReplies: array of Int16); virtual; function CreateProtocol: TIdHTTPProtocol; virtual; procedure InitComponent; override; @@ -534,56 +534,56 @@ TIdCustomHTTP = class(TIdTCPClientCustom) public destructor Destroy; override; - procedure Delete(AURL: string; AResponseContent: TStream); overload; - function Delete(AURL: string + procedure Delete(const AURL: string; AResponseContent: TStream); overload; + function Delete(const AURL: string {$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF} ): string; overload; - procedure Options(AURL: string; AResponseContent: TStream); overload; - function Options(AURL: string + procedure Options(const AURL: string; AResponseContent: TStream); overload; + function Options(const AURL: string {$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF} ): string; overload; - procedure Get(AURL: string; AResponseContent: TStream); overload; - procedure Get(AURL: string; AResponseContent: TStream; AIgnoreReplies: array of Int16); overload; - function Get(AURL: string + procedure Get(const AURL: string; AResponseContent: TStream); overload; + procedure Get(const AURL: string; AResponseContent: TStream; AIgnoreReplies: array of Int16); overload; + function Get(const AURL: string {$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF} ): string; overload; - function Get(AURL: string; AIgnoreReplies: array of Int16 + function Get(const AURL: string; AIgnoreReplies: array of Int16 {$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF} ): string; overload; - procedure Trace(AURL: string; AResponseContent: TStream); overload; - function Trace(AURL: string + procedure Trace(const AURL: string; AResponseContent: TStream); overload; + function Trace(const AURL: string {$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF} ): string; overload; - procedure Head(AURL: string); + procedure Head(const AURL: string); - function Post(AURL: string; const ASourceFile: String + function Post(const AURL: string; const ASourceFile: String {$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF} ): string; overload; - function Post(AURL: string; ASource: TStrings; AByteEncoding: IIdTextEncoding = nil + function Post(const AURL: string; ASource: TStrings; AByteEncoding: IIdTextEncoding = nil {$IFDEF STRING_IS_ANSI}; ASrcEncoding: IIdTextEncoding = nil; ADestEncoding: IIdTextEncoding = nil{$ENDIF}): string; overload; - function Post(AURL: string; ASource: TStream + function Post(const AURL: string; ASource: TStream {$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF} ): string; overload; - function Post(AURL: string; ASource: TIdMultiPartFormDataStream + function Post(const AURL: string; ASource: TIdMultiPartFormDataStream {$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF} ): string; overload; - procedure Post(AURL: string; const ASourceFile: String; AResponseContent: TStream); overload; - procedure Post(AURL: string; ASource: TStrings; AResponseContent: TStream; AByteEncoding: IIdTextEncoding = nil + procedure Post(const AURL: string; const ASourceFile: String; AResponseContent: TStream); overload; + procedure Post(const AURL: string; ASource: TStrings; AResponseContent: TStream; AByteEncoding: IIdTextEncoding = nil {$IFDEF STRING_IS_ANSI}; ASrcEncoding: IIdTextEncoding = nil{$ENDIF}); overload; - procedure Post(AURL: string; ASource, AResponseContent: TStream); overload; - procedure Post(AURL: string; ASource: TIdMultiPartFormDataStream; AResponseContent: TStream); overload; + procedure Post(const AURL: string; ASource, AResponseContent: TStream); overload; + procedure Post(const AURL: string; ASource: TIdMultiPartFormDataStream; AResponseContent: TStream); overload; - function Put(AURL: string; ASource: TStream + function Put(const AURL: string; ASource: TStream {$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF} ): string; overload; - procedure Put(AURL: string; ASource, AResponseContent: TStream); overload; + procedure Put(const AURL: string; ASource, AResponseContent: TStream); overload; - procedure Patch(AURL: string; ASource, AResponseContent: TStream); overload; - function Patch(AURL: string; ASource: TStream + procedure Patch(const AURL: string; ASource, AResponseContent: TStream); overload; + function Patch(const AURL: string; ASource: TStream {$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF} ): string; overload; @@ -728,12 +728,12 @@ destructor TIdCustomHTTP.Destroy; inherited Destroy; end; -procedure TIdCustomHTTP.Delete(AURL: string; AResponseContent: TStream); +procedure TIdCustomHTTP.Delete(const AURL: string; AResponseContent: TStream); begin DoRequest(Id_HTTPMethodDelete, AURL, nil, AResponseContent, []); end; -function TIdCustomHTTP.Delete(AURL: string +function TIdCustomHTTP.Delete(const AURL: string {$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF} ): string; var @@ -750,12 +750,12 @@ function TIdCustomHTTP.Delete(AURL: string end; end; -procedure TIdCustomHTTP.Options(AURL: string; AResponseContent: TStream); +procedure TIdCustomHTTP.Options(const AURL: string; AResponseContent: TStream); begin DoRequest(Id_HTTPMethodOptions, AURL, nil, AResponseContent, []); end; -function TIdCustomHTTP.Options(AURL: string +function TIdCustomHTTP.Options(const AURL: string {$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF} ): string; var @@ -772,22 +772,22 @@ function TIdCustomHTTP.Options(AURL: string end; end; -procedure TIdCustomHTTP.Get(AURL: string; AResponseContent: TStream); +procedure TIdCustomHTTP.Get(const AURL: string; AResponseContent: TStream); begin Get(AURL, AResponseContent, []); end; -procedure TIdCustomHTTP.Trace(AURL: string; AResponseContent: TStream); +procedure TIdCustomHTTP.Trace(const AURL: string; AResponseContent: TStream); begin DoRequest(Id_HTTPMethodTrace, AURL, nil, AResponseContent, []); end; -procedure TIdCustomHTTP.Head(AURL: string); +procedure TIdCustomHTTP.Head(const AURL: string); begin DoRequest(Id_HTTPMethodHead, AURL, nil, nil, []); end; -procedure TIdCustomHTTP.Post(AURL: string; ASource, AResponseContent: TStream); +procedure TIdCustomHTTP.Post(const AURL: string; ASource, AResponseContent: TStream); var OldProtocol: TIdHTTPProtocolVersion; begin @@ -1033,7 +1033,7 @@ function TIdCustomHTTP.SetRequestParams(ASource: TStrings; AByteEncoding: IIdTex end; end; -function TIdCustomHTTP.Post(AURL: string; const ASourceFile: String +function TIdCustomHTTP.Post(const AURL: string; const ASourceFile: String {$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF} ): string; var @@ -1047,7 +1047,7 @@ function TIdCustomHTTP.Post(AURL: string; const ASourceFile: String end; end; -procedure TIdCustomHTTP.Post(AURL: string; const ASourceFile: String; AResponseContent: TStream); +procedure TIdCustomHTTP.Post(const AURL: string; const ASourceFile: String; AResponseContent: TStream); var LSource: TStream; begin @@ -1059,7 +1059,7 @@ procedure TIdCustomHTTP.Post(AURL: string; const ASourceFile: String; AResponseC end; end; -procedure TIdCustomHTTP.Post(AURL: string; ASource: TStrings; AResponseContent: TStream; +procedure TIdCustomHTTP.Post(const AURL: string; ASource: TStrings; AResponseContent: TStream; AByteEncoding: IIdTextEncoding = nil {$IFDEF STRING_IS_ANSI}; ASrcEncoding: IIdTextEncoding = nil{$ENDIF} ); @@ -1086,7 +1086,7 @@ procedure TIdCustomHTTP.Post(AURL: string; ASource: TStrings; AResponseContent: end; end; -function TIdCustomHTTP.Post(AURL: string; ASource: TStrings; AByteEncoding: IIdTextEncoding = nil +function TIdCustomHTTP.Post(const AURL: string; ASource: TStrings; AByteEncoding: IIdTextEncoding = nil {$IFDEF STRING_IS_ANSI}; ASrcEncoding: IIdTextEncoding = nil; ADestEncoding: IIdTextEncoding = nil{$ENDIF} ): string; var @@ -1103,7 +1103,7 @@ function TIdCustomHTTP.Post(AURL: string; ASource: TStrings; AByteEncoding: IIdT end; end; -function TIdCustomHTTP.Post(AURL: string; ASource: TStream +function TIdCustomHTTP.Post(const AURL: string; ASource: TStream {$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF} ): string; var @@ -1120,12 +1120,12 @@ function TIdCustomHTTP.Post(AURL: string; ASource: TStream end; end; -procedure TIdCustomHTTP.Put(AURL: string; ASource, AResponseContent: TStream); +procedure TIdCustomHTTP.Put(const AURL: string; ASource, AResponseContent: TStream); begin DoRequest(Id_HTTPMethodPut, AURL, ASource, AResponseContent, []); end; -function TIdCustomHTTP.Put(AURL: string; ASource: TStream +function TIdCustomHTTP.Put(const AURL: string; ASource: TStream {$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF} ): string; var @@ -1142,14 +1142,14 @@ function TIdCustomHTTP.Put(AURL: string; ASource: TStream end; end; -function TIdCustomHTTP.Get(AURL: string +function TIdCustomHTTP.Get(const AURL: string {$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF} ): string; begin Result := Get(AURL, []{$IFDEF STRING_IS_ANSI}, ADestEncoding{$ENDIF}); end; -function TIdCustomHTTP.Trace(AURL: string +function TIdCustomHTTP.Trace(const AURL: string {$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF} ): string; var @@ -2543,7 +2543,7 @@ procedure TIdCustomHTTP.SetProxyParams(AValue: TIdProxyConnectionInfo); FProxyParameters.Assign(AValue); end; -procedure TIdCustomHTTP.Post(AURL: string; ASource: TIdMultiPartFormDataStream; +procedure TIdCustomHTTP.Post(const AURL: string; ASource: TIdMultiPartFormDataStream; AResponseContent: TStream); begin Assert(ASource<>nil); @@ -2552,7 +2552,7 @@ procedure TIdCustomHTTP.Post(AURL: string; ASource: TIdMultiPartFormDataStream; Post(AURL, TStream(ASource), AResponseContent); end; -function TIdCustomHTTP.Post(AURL: string; ASource: TIdMultiPartFormDataStream +function TIdCustomHTTP.Post(const AURL: string; ASource: TIdMultiPartFormDataStream {$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF} ): string; begin @@ -3130,7 +3130,7 @@ function TIdCustomHTTP.InternalReadLn: String; end; end; -function TIdCustomHTTP.Get(AURL: string; AIgnoreReplies: array of Int16 +function TIdCustomHTTP.Get(const AURL: string; AIgnoreReplies: array of Int16 {$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF} ): string; var @@ -3147,14 +3147,14 @@ function TIdCustomHTTP.Get(AURL: string; AIgnoreReplies: array of Int16 end; end; -procedure TIdCustomHTTP.Get(AURL: string; AResponseContent: TStream; +procedure TIdCustomHTTP.Get(const AURL: string; AResponseContent: TStream; AIgnoreReplies: array of Int16); begin DoRequest(Id_HTTPMethodGet, AURL, nil, AResponseContent, AIgnoreReplies); end; procedure TIdCustomHTTP.DoRequest(const AMethod: TIdHTTPMethod; - AURL: string; ASource, AResponseContent: TStream; + const AURL: string; ASource, AResponseContent: TStream; AIgnoreReplies: array of Int16); var LResponseLocation: TIdStreamSize; @@ -3251,12 +3251,12 @@ procedure TIdCustomHTTP.DoRequest(const AMethod: TIdHTTPMethod; end; end; -procedure TIdCustomHTTP.Patch(AURL: string; ASource, AResponseContent: TStream); +procedure TIdCustomHTTP.Patch(const AURL: string; ASource, AResponseContent: TStream); begin DoRequest(Id_HTTPMethodPatch, AURL, ASource, AResponseContent, []); end; -function TIdCustomHTTP.Patch(AURL: string; ASource: TStream +function TIdCustomHTTP.Patch(const AURL: string; ASource: TStream {$IFDEF STRING_IS_ANSI}; ADestEncoding: IIdTextEncoding = nil{$ENDIF} ): string; var diff --git a/Lib/Protocols/IdIMAP4.pas b/Lib/Protocols/IdIMAP4.pas index de2db6382..3a93785de 100644 --- a/Lib/Protocols/IdIMAP4.pas +++ b/Lib/Protocols/IdIMAP4.pas @@ -746,10 +746,10 @@ TIdIMAP4 = class(TIdMessageClient) procedure ParseMessagePart(ABodyStructure: string; AMessageParts: TIdMessageParts; AThisMessagePart: TIdMessagePart; AParentMessagePart: TIdMessagePart; APartNumber: integer); - procedure ParseBodyStructureResult(ABodyStructure: string; ATheParts: TIdMessageParts; AImapParts: TIdImapMessageParts); - procedure ParseBodyStructurePart(APartString: string; AThePart: TIdMessagePart; AImapPart: TIdImapMessagePart); - procedure ParseTheLine(ALine: string; APartsList: TStrings); - procedure ParseIntoParts(APartString: string; AParams: TStrings); + procedure ParseBodyStructureResult(const ABodyStructure: string; ATheParts: TIdMessageParts; AImapParts: TIdImapMessageParts); + procedure ParseBodyStructurePart(const APartString: string; AThePart: TIdMessagePart; AImapPart: TIdImapMessagePart); + procedure ParseTheLine(const ALine: string; APartsList: TStrings); + procedure ParseIntoParts(const APartString: string; AParams: TStrings); procedure ParseIntoBrackettedQuotedAndUnquotedParts(APartString: string; AParams: TStrings; AKeepBrackets: Boolean); procedure BreakApartParamsInQuotes(const AParam: string; AParsedList: TStrings); function GetNextWord(AParam: string): string; @@ -757,14 +757,14 @@ TIdIMAP4 = class(TIdMessageClient) procedure ParseExpungeResult (AMB: TIdMailBox; ACmdResultDetails: TStrings); procedure ParseListResult (AMBList: TStrings; ACmdResultDetails: TStrings); procedure ParseLSubResult(AMBList: TStrings; ACmdResultDetails: TStrings); - procedure InternalParseListResult(ACmd: string; AMBList: TStrings; ACmdResultDetails: TStrings); - procedure ParseMailBoxAttributeString(AAttributesList: String; var AAttributes: TIdMailBoxAttributesSet); - procedure ParseMessageFlagString (AFlagsList: String; var AFlags: TIdMessageFlagsSet); + procedure InternalParseListResult(const ACmd: string; AMBList: TStrings; ACmdResultDetails: TStrings); + procedure ParseMailBoxAttributeString(const AAttributesList: String; var AAttributes: TIdMailBoxAttributesSet); + procedure ParseMessageFlagString (const AFlagsList: String; var AFlags: TIdMessageFlagsSet); procedure ParseSelectResult (AMB: TIdMailBox; ACmdResultDetails: TStrings); procedure ParseStatusResult (AMB: TIdMailBox; ACmdResultDetails: TStrings); procedure ParseSearchResult (AMB: TIdMailBox; ACmdResultDetails: TStrings); procedure ParseEnvelopeResult (AMsg: TIdMessage; ACmdResultStr: String); - function ParseLastCmdResult(ALine: string; AExpectedCommand: string; AExpectedIMAPFunction: array of string): Boolean; + function ParseLastCmdResult(ALine: string; const AExpectedCommand: string; AExpectedIMAPFunction: array of string): Boolean; procedure ParseLastCmdResultButAppendInfo(ALine: string); function InternalRetrieve(const AMsgNum: UInt32; AUseUID: Boolean; AUsePeek: Boolean; AMsg: TIdMessage): Boolean; function InternalRetrievePart(const AMsgNum: UInt32; const APartNum: string; @@ -772,18 +772,18 @@ TIdIMAP4 = class(TIdMessageClient) ADestStream: TStream; var ABuffer: {$IFDEF DOTNET}TIdBytes{$ELSE}PByte{$ENDIF}; var ABufferLength: Integer; {NOTE: var args cannot have default params} - ADestFileNameAndPath: string = ''; {Do not Localize} - AContentTransferEncoding: string = 'text'): Boolean; {Do not Localize} + const ADestFileNameAndPath: string = ''; {Do not Localize} + const AContentTransferEncoding: string = 'text'): Boolean; {Do not Localize} //Retrieves the specified number of headers of the selected mailbox to the specified TIdMessageCollection. function InternalRetrieveHeaders(AMsgList: TIdMessageCollection; ACount: Integer): Boolean; //Retrieves the specified number of messages of the selected mailbox to the specified TIdMessageCollection. function InternalRetrieveMsgs(AMsgList: TIdMessageCollection; ACount: Integer): Boolean; function InternalSearchMailBox(const ASearchInfo: array of TIdIMAP4SearchRec; AUseUID: Boolean; const ACharSet: string): Boolean; - function ParseBodyStructureSectionAsEquates(AParam: string): string; - function ParseBodyStructureSectionAsEquates2(AParam: string): string; + function ParseBodyStructureSectionAsEquates(const AParam: string): string; + function ParseBodyStructureSectionAsEquates2(const AParam: string): string; function InternalRetrieveText(const AMsgNum: UInt32; var AText: string; AUseUID: Boolean; AUsePeek: Boolean; AUseFirstPartInsteadOfText: Boolean): Boolean; - function IsCapabilityListed(ACapability: string): Boolean; + function IsCapabilityListed(const ACapability: string): Boolean; function InternalRetrieveEnvelope(const AMsgNum: UInt32; AMsg: TIdMessage; ADestList: TStrings): Boolean; function UIDInternalRetrieveEnvelope(const AMsgUID: String; AMsg: TIdMessage; ADestList: TStrings): Boolean; function InternalRetrievePartHeader(const AMsgNum: UInt32; const APartNum: string; const AUseUID: Boolean; @@ -829,7 +829,7 @@ TIdIMAP4 = class(TIdMessageClient) function AppendMsg(const AMBName: String; AMsg: TIdMessage; AAlternativeHeaders: TIdHeaderList; const AFlags: TIdMessageFlagsSet = []; const AInternalDateTimeGMT: TDateTime = 0.0): Boolean; overload; //The following are used for raw (unparsed) messages in a file or stream... - function AppendMsgNoEncodeFromFile(const AMBName: String; ASourceFile: string; const AFlags: TIdMessageFlagsSet = []; + function AppendMsgNoEncodeFromFile(const AMBName: String; const ASourceFile: string; const AFlags: TIdMessageFlagsSet = []; const AInternalDateTimeGMT: TDateTime = 0.0): Boolean; function AppendMsgNoEncodeFromStream(const AMBName: String; AStream: TStream; const AFlags: TIdMessageFlagsSet = []; const AInternalDateTimeGMT: TDateTime = 0.0): Boolean; @@ -898,8 +898,8 @@ TIdIMAP4 = class(TIdMessageClient) //Retrieves a whole message while marking it read. function Retrieve(const AMsgNum: UInt32; AMsg: TIdMessage): Boolean; //Retrieves a whole message "raw" and saves it to file, while marking it read. - function RetrieveNoDecodeToFile(const AMsgNum: UInt32; ADestFile: string): Boolean; - function RetrieveNoDecodeToFilePeek(const AMsgNum: UInt32; ADestFile: string): Boolean; + function RetrieveNoDecodeToFile(const AMsgNum: UInt32; const ADestFile: string): Boolean; + function RetrieveNoDecodeToFilePeek(const AMsgNum: UInt32; const ADestFile: string): Boolean; function RetrieveNoDecodeToStream(const AMsgNum: UInt32; AStream: TStream): Boolean; function RetrieveNoDecodeToStreamPeek(const AMsgNum: UInt32; AStream: TStream): Boolean; //Retrieves all envelope of the selected mailbox to the specified TIdMessageCollection. @@ -928,7 +928,7 @@ TIdIMAP4 = class(TIdMessageClient) {CC2: Following added for retrieving individual parts of a message...} {Retrieve a specific individual part of a message to a stream (part/sub-part like '2' or '2.3')...} function RetrievePart(const AMsgNum: UInt32; const APartNum: string; - ADestStream: TStream; AContentTransferEncoding: string = 'text'): Boolean; overload; {Do not Localize} + ADestStream: TStream; const AContentTransferEncoding: string = 'text'): Boolean; overload; {Do not Localize} {Retrieve a specific individual part of a message where part is an integer or sub-part like '2.3'...} function RetrievePart(const AMsgNum: UInt32; const APartNum: string; var ABuffer: {$IFDEF DOTNET}TIdBytes{$ELSE}PByte{$ENDIF}; @@ -940,7 +940,7 @@ TIdIMAP4 = class(TIdMessageClient) {Retrieve a specific individual part of a message to a stream (part/sub-part like '2' or '2.3') without marking the message as "read"...} function RetrievePartPeek(const AMsgNum: UInt32; const APartNum: string; - ADestStream: TStream; AContentTransferEncoding: string = 'text'): Boolean; overload; {Do not Localize} + ADestStream: TStream; const AContentTransferEncoding: string = 'text'): Boolean; overload; {Do not Localize} {Retrieve a specific individual part of a message where part is an integer or sub-part like '2.3' without marking the message as "read"...} function RetrievePartPeek(const AMsgNum: UInt32; const APartNum: string; @@ -954,19 +954,19 @@ TIdIMAP4 = class(TIdMessageClient) {CC2: Following added for retrieving individual parts of a message...} {Retrieve a specific individual part of a message where part is an integer (for backward compatibility)...} function RetrievePartToFile(const AMsgNum: UInt32; const APartNum: Integer; - ALength: Integer; ADestFileNameAndPath: string; AContentTransferEncoding: string): Boolean; overload; + ALength: Integer; const ADestFileNameAndPath: string; const AContentTransferEncoding: string): Boolean; overload; {Retrieve a specific individual part of a message where part is an integer or sub-part like '2.3'...} function RetrievePartToFile(const AMsgNum: UInt32; const APartNum: string; - ALength: Integer; ADestFileNameAndPath: string; AContentTransferEncoding: string): Boolean; overload; + ALength: Integer; const ADestFileNameAndPath: string; const AContentTransferEncoding: string): Boolean; overload; {CC2: Following added for retrieving individual parts of a message...} {Retrieve a specific individual part of a message where part is an integer (for backward compatibility) without marking the message as "read"...} function RetrievePartToFilePeek(const AMsgNum: UInt32; const APartNum: Integer; - ALength: Integer; ADestFileNameAndPath: string; AContentTransferEncoding: string): Boolean; overload; + ALength: Integer; const ADestFileNameAndPath: string; const AContentTransferEncoding: string): Boolean; overload; {Retrieve a specific individual part of a message where part is an integer or sub-part like '2.3' without marking the message as "read"...} function RetrievePartToFilePeek(const AMsgNum: UInt32; const APartNum: string; - ALength: Integer; ADestFileNameAndPath: string; AContentTransferEncoding: string): Boolean; overload; + ALength: Integer; const ADestFileNameAndPath: string; const AContentTransferEncoding: string): Boolean; overload; {CC3: Following added for retrieving the text-only part of a message...} function RetrieveText(const AMsgNum: UInt32; var AText: string): Boolean; {CC4: An alternative for retrieving the text-only part of a message which @@ -1003,8 +1003,8 @@ TIdIMAP4 = class(TIdMessageClient) //Retrieves a whole message while marking it read. function UIDRetrieve(const AMsgUID: String; AMsg: TIdMessage): Boolean; //Retrieves a whole message "raw" and saves it to file, while marking it read. - function UIDRetrieveNoDecodeToFile(const AMsgUID: String; ADestFile: string): Boolean; - function UIDRetrieveNoDecodeToFilePeek(const AMsgUID: String; ADestFile: string): Boolean; + function UIDRetrieveNoDecodeToFile(const AMsgUID: String; const ADestFile: string): Boolean; + function UIDRetrieveNoDecodeToFilePeek(const AMsgUID: String; const ADestFile: string): Boolean; function UIDRetrieveNoDecodeToStream(const AMsgUID: String; AStream: TStream): Boolean; function UIDRetrieveNoDecodeToStreamPeek(const AMsgUID: String; AStream: TStream): Boolean; //Retrieves the message envelope, parses it, and discards the envelope. @@ -1022,7 +1022,7 @@ TIdIMAP4 = class(TIdMessageClient) function UIDRetrieveStructure(const AMsgUID: String; AParts: TIdImapMessageParts): Boolean; overload; {Retrieve a specific individual part of a message to a stream (part/sub-part like '2' or '2.3')...} function UIDRetrievePart(const AMsgUID: String; const APartNum: string; - var ADestStream: TStream; AContentTransferEncoding: string = 'text'): Boolean; overload; {Do not Localize} + var ADestStream: TStream; const AContentTransferEncoding: string = 'text'): Boolean; overload; {Do not Localize} {Retrieve a specific individual part of a message where part is an integer or sub-part like '2.3'...} function UIDRetrievePart(const AMsgUID: String; const APartNum: string; var ABuffer: {$IFDEF DOTNET}TIdBytes{$ELSE}PByte{$ENDIF}; @@ -1034,27 +1034,27 @@ TIdIMAP4 = class(TIdMessageClient) {Retrieve a specific individual part of a message to a stream (part/sub-part like '2' or '2.3') without marking the message as "read"...} function UIDRetrievePartPeek(const AMsgUID: String; const APartNum: string; - var ADestStream: TStream; AContentTransferEncoding: string = 'text'): Boolean; overload; {Do not Localize} + var ADestStream: TStream; const AContentTransferEncoding: string = 'text'): Boolean; overload; {Do not Localize} {Retrieve a specific individual part of a message where part is an integer or sub-part like '2.3'...} function UIDRetrievePartPeek(const AMsgUID: String; const APartNum: string; var ABuffer: {$IFDEF DOTNET}TIdBytes{$ELSE}PByte{$ENDIF}; - var ABufferLength: Integer; AContentTransferEncoding: string = 'text'): Boolean; overload; {Do not Localize} + var ABufferLength: Integer; const AContentTransferEncoding: string = 'text'): Boolean; overload; {Do not Localize} {Retrieve a specific individual part of a message where part is an integer (for backward compatibility)...} function UIDRetrievePartPeek(const AMsgUID: String; const APartNum: Integer; var ABuffer: {$IFDEF DOTNET}TIdBytes{$ELSE}PByte{$ENDIF}; - var ABufferLength: Integer; AContentTransferEncoding: string = 'text'): Boolean; overload; {Do not Localize} + var ABufferLength: Integer; const AContentTransferEncoding: string = 'text'): Boolean; overload; {Do not Localize} {Retrieve a specific individual part of a message where part is an integer (for backward compatibility)...} function UIDRetrievePartToFile(const AMsgUID: String; const APartNum: Integer; - ALength: Integer; ADestFileNameAndPath: string; AContentTransferEncoding: string): Boolean; overload; + ALength: Integer; const ADestFileNameAndPath: string; const AContentTransferEncoding: string): Boolean; overload; {Retrieve a specific individual part of a message where part is an integer or sub-part like '2.3'...} function UIDRetrievePartToFile(const AMsgUID: String; const APartNum: string; - ALength: Integer; ADestFileNameAndPath: string; AContentTransferEncoding: string): Boolean; overload; + ALength: Integer; const ADestFileNameAndPath: string; const AContentTransferEncoding: string): Boolean; overload; {Retrieve a specific individual part of a message where part is an integer (for backward compatibility)...} function UIDRetrievePartToFilePeek(const AMsgUID: String; const APartNum: Integer; - ALength: Integer; ADestFileNameAndPath: string; AContentTransferEncoding: string): Boolean; overload; + ALength: Integer; const ADestFileNameAndPath: string; const AContentTransferEncoding: string): Boolean; overload; {Retrieve a specific individual part of a message where part is an integer or sub-part like '2.3'...} function UIDRetrievePartToFilePeek(const AMsgUID: String; const APartNum: string; - ALength: Integer; ADestFileNameAndPath: string; AContentTransferEncoding: string): Boolean; overload; + ALength: Integer; const ADestFileNameAndPath: string; const AContentTransferEncoding: string): Boolean; overload; {Following added for retrieving the text-only part of a message...} function UIDRetrieveText(const AMsgUID: String; var AText: string): Boolean; function UIDRetrieveText2(const AMsgUID: String; var AText: string): Boolean; @@ -2544,7 +2544,7 @@ procedure TIdIMAP4.KeepAlive; SendCmd(NewCmdCounter, IMAP4Commands[cmdNoop], []); end; -function TIdIMAP4.IsCapabilityListed(ACapability: string):Boolean; +function TIdIMAP4.IsCapabilityListed(const ACapability: string):Boolean; begin if not FHasCapa then begin Capability; @@ -3504,7 +3504,7 @@ function TIdIMAP4.AppendMsg(const AMBName: String; AMsg: TIdMessage; AAlternativ end; end; -function TIdIMAP4.AppendMsgNoEncodeFromFile(const AMBName: String; ASourceFile: string; const AFlags: TIdMessageFlagsSet = []; +function TIdIMAP4.AppendMsgNoEncodeFromFile(const AMBName: String; const ASourceFile: string; const AFlags: TIdMessageFlagsSet = []; const AInternalDateTimeGMT: TDateTime = 0.0): Boolean; var LSourceStream: TIdReadFileExclusiveStream; @@ -4081,7 +4081,7 @@ function TIdIMAP4.InternalRetrieveStructure(const AMsgNum: UInt32; AMsg: TIdMess // retrieve a specific individual part of a message function TIdIMAP4.RetrievePart(const AMsgNum: UInt32; const APartNum: string; - ADestStream: TStream; AContentTransferEncoding: string): Boolean; + ADestStream: TStream; const AContentTransferEncoding: string): Boolean; var LDummy1: {$IFDEF DOTNET}TIdBytes{$ELSE}PByte{$ENDIF}; LDummy2: Integer; @@ -4111,7 +4111,7 @@ function TIdIMAP4.RetrievePart(const AMsgNum: UInt32; const APartNum: string; // retrieve a specific individual part of a message function TIdIMAP4.RetrievePartPeek(const AMsgNum: UInt32; const APartNum: string; - ADestStream: TStream; AContentTransferEncoding: string): Boolean; + ADestStream: TStream; const AContentTransferEncoding: string): Boolean; var LDummy1: {$IFDEF DOTNET}TIdBytes{$ELSE}PByte{$ENDIF}; LDummy2: Integer; @@ -4141,7 +4141,7 @@ function TIdIMAP4.RetrievePartPeek(const AMsgNum: UInt32; const APartNum: string // Retrieve a specific individual part of a message function TIdIMAP4.UIDRetrievePart(const AMsgUID: String; const APartNum: string; - var ADestStream: TStream; AContentTransferEncoding: string): Boolean; + var ADestStream: TStream; const AContentTransferEncoding: string): Boolean; var LDummy1: {$IFDEF DOTNET}TIdBytes{$ELSE}PByte{$ENDIF}; LDummy2: Integer; @@ -4171,7 +4171,7 @@ function TIdIMAP4.UIDRetrievePart(const AMsgUID: String; const APartNum: string; // retrieve a specific individual part of a message function TIdIMAP4.UIDRetrievePartPeek(const AMsgUID: String; const APartNum: string; - var ADestStream: TStream; AContentTransferEncoding: string): Boolean; + var ADestStream: TStream; const AContentTransferEncoding: string): Boolean; var LDummy1: {$IFDEF DOTNET}TIdBytes{$ELSE}PByte{$ENDIF}; LDummy2: Integer; @@ -4185,7 +4185,7 @@ function TIdIMAP4.UIDRetrievePartPeek(const AMsgUID: String; const APartNum: str function TIdIMAP4.UIDRetrievePartPeek(const AMsgUID: String; const APartNum: Integer; var ABuffer: {$IFDEF DOTNET}TIdBytes{$ELSE}PByte{$ENDIF}; - var ABufferLength: Integer; AContentTransferEncoding: string): Boolean; + var ABufferLength: Integer; const AContentTransferEncoding: string): Boolean; begin IsImapPartNumberValid(APartNum); Result := UIDRetrievePartPeek(AMsgUID, IntToStr(APartNum), ABuffer, ABufferLength, AContentTransferEncoding); @@ -4193,14 +4193,14 @@ function TIdIMAP4.UIDRetrievePartPeek(const AMsgUID: String; const APartNum: Int function TIdIMAP4.UIDRetrievePartPeek(const AMsgUID: String; const APartNum: string; var ABuffer: {$IFDEF DOTNET}TIdBytes{$ELSE}PByte{$ENDIF}; - var ABufferLength: Integer; AContentTransferEncoding: string): Boolean; + var ABufferLength: Integer; const AContentTransferEncoding: string): Boolean; //Retrieve a specific individual part of a message begin Result := InternalRetrievePart(UIDToUInt32(AMsgUID), APartNum, True, True, nil, ABuffer, ABufferLength, '', AContentTransferEncoding); {Do not Localize} end; function TIdIMAP4.RetrievePartToFile(const AMsgNum: UInt32; const APartNum: Integer; - ALength: Integer; ADestFileNameAndPath: string; AContentTransferEncoding: string): Boolean; + ALength: Integer; const ADestFileNameAndPath: string; const AContentTransferEncoding: string): Boolean; begin IsImapPartNumberValid(APartNum); Result := RetrievePartToFile(AMsgNum, IntToStr(APartNum), ALength, ADestFileNameAndPath, AContentTransferEncoding); @@ -4208,7 +4208,7 @@ function TIdIMAP4.RetrievePartToFile(const AMsgNum: UInt32; const APartNum: Inte // retrieve a specific individual part of a message function TIdIMAP4.RetrievePartToFile(const AMsgNum: UInt32; const APartNum: string; - ALength: Integer; ADestFileNameAndPath: string; AContentTransferEncoding: string): Boolean; + ALength: Integer; const ADestFileNameAndPath: string; const AContentTransferEncoding: string): Boolean; var LDummy: {$IFDEF DOTNET}TIdBytes{$ELSE}PByte{$ENDIF}; begin @@ -4221,7 +4221,7 @@ function TIdIMAP4.RetrievePartToFile(const AMsgNum: UInt32; const APartNum: stri end; function TIdIMAP4.RetrievePartToFilePeek(const AMsgNum: UInt32; const APartNum: Integer; - ALength: Integer; ADestFileNameAndPath: string; AContentTransferEncoding: string): Boolean; + ALength: Integer; const ADestFileNameAndPath: string; const AContentTransferEncoding: string): Boolean; begin IsImapPartNumberValid(APartNum); Result := RetrievePartToFilePeek(AMsgNum, IntToStr(APartNum), ALength, ADestFileNameAndPath, AContentTransferEncoding); @@ -4229,7 +4229,7 @@ function TIdIMAP4.RetrievePartToFilePeek(const AMsgNum: UInt32; const APartNum: // retrieve a specific individual part of a message function TIdIMAP4.RetrievePartToFilePeek(const AMsgNum: UInt32; const APartNum: string; - ALength: Integer; ADestFileNameAndPath: string; AContentTransferEncoding: string): Boolean; + ALength: Integer; const ADestFileNameAndPath: string; const AContentTransferEncoding: string): Boolean; var LDummy: {$IFDEF DOTNET}TIdBytes{$ELSE}PByte{$ENDIF}; begin @@ -4242,7 +4242,7 @@ function TIdIMAP4.RetrievePartToFilePeek(const AMsgNum: UInt32; const APartNum: end; function TIdIMAP4.UIDRetrievePartToFile(const AMsgUID: String; const APartNum: Integer; - ALength: Integer; ADestFileNameAndPath: string; AContentTransferEncoding: string): Boolean; + ALength: Integer; const ADestFileNameAndPath: string; const AContentTransferEncoding: string): Boolean; begin IsImapPartNumberValid(APartNum); Result := UIDRetrievePartToFile(AMsgUID, IntToStr(APartNum), ALength, ADestFileNameAndPath, AContentTransferEncoding); @@ -4250,7 +4250,7 @@ function TIdIMAP4.UIDRetrievePartToFile(const AMsgUID: String; const APartNum: I // retrieve a specific individual part of a message function TIdIMAP4.UIDRetrievePartToFile(const AMsgUID: String; const APartNum: string; - ALength: Integer; ADestFileNameAndPath: string; AContentTransferEncoding: string): Boolean; + ALength: Integer; const ADestFileNameAndPath: string; const AContentTransferEncoding: string): Boolean; var LDummy: {$IFDEF DOTNET}TIdBytes{$ELSE}PByte{$ENDIF}; begin @@ -4263,7 +4263,7 @@ function TIdIMAP4.UIDRetrievePartToFile(const AMsgUID: String; const APartNum: s end; function TIdIMAP4.UIDRetrievePartToFilePeek(const AMsgUID: String; const APartNum: Integer; - ALength: Integer; ADestFileNameAndPath: string; AContentTransferEncoding: string): Boolean; + ALength: Integer; const ADestFileNameAndPath: string; const AContentTransferEncoding: string): Boolean; begin IsImapPartNumberValid(APartNum); Result := UIDRetrievePartToFilePeek(AMsgUID, IntToStr(APartNum), ALength, ADestFileNameAndPath, AContentTransferEncoding); @@ -4271,7 +4271,7 @@ function TIdIMAP4.UIDRetrievePartToFilePeek(const AMsgUID: String; const APartNu // retrieve a specific individual part of a message function TIdIMAP4.UIDRetrievePartToFilePeek(const AMsgUID: String; const APartNum: {Integer} string; - ALength: Integer; ADestFileNameAndPath: string; AContentTransferEncoding: string): Boolean; + ALength: Integer; const ADestFileNameAndPath: string; const AContentTransferEncoding: string): Boolean; var LDummy: {$IFDEF DOTNET}TIdBytes{$ELSE}PByte{$ENDIF}; begin @@ -4289,8 +4289,8 @@ function TIdIMAP4.InternalRetrievePart(const AMsgNum: UInt32; const APartNum: {I AUseUID: Boolean; AUsePeek: Boolean; ADestStream: TStream; var ABuffer: {$IFDEF DOTNET}TIdBytes{$ELSE}PByte{$ENDIF}; var ABufferLength: Integer; {NOTE: var args cannot have default params} - ADestFileNameAndPath: string; - AContentTransferEncoding: string): Boolean; + const ADestFileNameAndPath: string; + const AContentTransferEncoding: string): Boolean; var LCmd: string; bCreatedStream: Boolean; @@ -4701,7 +4701,7 @@ function TIdIMAP4.Retrieve(const AMsgNum: UInt32; AMsg: TIdMessage): Boolean; end; //Retrieves a whole message "raw" and saves it to file, while marking it read. -function TIdIMAP4.RetrieveNoDecodeToFile(const AMsgNum: UInt32; ADestFile: string): Boolean; +function TIdIMAP4.RetrieveNoDecodeToFile(const AMsgNum: UInt32; const ADestFile: string): Boolean; var LMsg: TIdMessage; begin @@ -4733,7 +4733,7 @@ function TIdIMAP4.RetrieveNoDecodeToFile(const AMsgNum: UInt32; ADestFile: stri end; //Retrieves a whole message "raw" and saves it to file -function TIdIMAP4.RetrieveNoDecodeToFilePeek(const AMsgNum: UInt32; ADestFile: string): Boolean; +function TIdIMAP4.RetrieveNoDecodeToFilePeek(const AMsgNum: UInt32; const ADestFile: string): Boolean; var LMsg: TIdMessage; begin @@ -4839,7 +4839,7 @@ function TIdIMAP4.UIDRetrieve(const AMsgUID: String; AMsg: TIdMessage): Boolean; end; //Retrieves a whole message "raw" and saves it to file, while marking it read. -function TIdIMAP4.UIDRetrieveNoDecodeToFile(const AMsgUID: String; ADestFile: string): Boolean; +function TIdIMAP4.UIDRetrieveNoDecodeToFile(const AMsgUID: String; const ADestFile: string): Boolean; var LMsg: TIdMessage; begin @@ -4871,7 +4871,7 @@ function TIdIMAP4.UIDRetrieveNoDecodeToFile(const AMsgUID: String; ADestFile: s end; //Retrieves a whole message "raw" and saves it to file. -function TIdIMAP4.UIDRetrieveNoDecodeToFilePeek(const AMsgUID: String; ADestFile: string): Boolean; +function TIdIMAP4.UIDRetrieveNoDecodeToFilePeek(const AMsgUID: String; const ADestFile: string): Boolean; var LMsg: TIdMessage; begin @@ -5541,7 +5541,7 @@ procedure TIdIMAP4.ParseMessagePart(ABodyStructure: string; "IdIMAP4.zip")) NIL) "mixed" ("boundary" "----=_NextPart_000_0026_01C33A37.33CFE220") NIL NIL) UID 62) } -procedure TIdIMAP4.ParseBodyStructureResult(ABodyStructure: string; ATheParts: TIdMessageParts; AImapParts: TIdImapMessageParts); +procedure TIdIMAP4.ParseBodyStructureResult(const ABodyStructure: string; ATheParts: TIdMessageParts; AImapParts: TIdImapMessageParts); begin {CC7: New code uses a different parsing method that allows for multisection parts.} if AImapParts <> nil then begin //Just sort out the ImapParts version for now @@ -5552,7 +5552,7 @@ procedure TIdIMAP4.ParseBodyStructureResult(ABodyStructure: string; ATheParts: T end; end; -procedure TIdIMAP4.ParseTheLine(ALine: string; APartsList: TStrings); +procedure TIdIMAP4.ParseTheLine(const ALine: string; APartsList: TStrings); var LTempList: TStringList; LN: integer; @@ -5575,7 +5575,7 @@ procedure TIdIMAP4.ParseTheLine(ALine: string; APartsList: TStrings); end; end; -procedure TIdIMAP4.ParseBodyStructurePart(APartString: string; AThePart: TIdMessagePart; +procedure TIdIMAP4.ParseBodyStructurePart(const APartString: string; AThePart: TIdMessagePart; AImapPart: TIdImapMessagePart); {CC3: Function added to support individual part retreival} var @@ -5702,7 +5702,7 @@ function ResolveQuotedSpecials(const AParam: string): string; Result := ReplaceAll(Result, '\\', '\'); end; -procedure TIdIMAP4.ParseIntoParts(APartString: string; AParams: TStrings); +procedure TIdIMAP4.ParseIntoParts(const APartString: string; AParams: TStrings); var LInPart: Integer; LStartPos: Integer; @@ -5915,7 +5915,7 @@ procedure TIdIMAP4.ParseIntoBrackettedQuotedAndUnquotedParts(APartString: string end; end; -function TIdIMAP4.ParseBodyStructureSectionAsEquates(AParam: string): string; +function TIdIMAP4.ParseBodyStructureSectionAsEquates(const AParam: string): string; {Convert: "Name1" "Value1" "Name2" "Value2" to: @@ -5946,7 +5946,7 @@ function TIdIMAP4.ParseBodyStructureSectionAsEquates(AParam: string): string; end; end; -function TIdIMAP4.ParseBodyStructureSectionAsEquates2(AParam: string): string; +function TIdIMAP4.ParseBodyStructureSectionAsEquates2(const AParam: string): string; {Convert: "Name1" ("Name2" "Value2") to: @@ -6102,7 +6102,7 @@ procedure TIdIMAP4.ParseExpungeResult(AMB: TIdMailBox; ACmdResultDetails: TStrin end; end; -procedure TIdIMAP4.ParseMessageFlagString(AFlagsList: String; var AFlags: TIdMessageFlagsSet); +procedure TIdIMAP4.ParseMessageFlagString(const AFlagsList: String; var AFlags: TIdMessageFlagsSet); {CC5: Note this only supports the system flags defined in RFC 2060.} var LSlFlags : TStringList; @@ -6126,7 +6126,7 @@ procedure TIdIMAP4.ParseMessageFlagString(AFlagsList: String; var AFlags: TIdMes end; end; -procedure TIdIMAP4.ParseMailBoxAttributeString(AAttributesList: String; var AAttributes: TIdMailBoxAttributesSet); +procedure TIdIMAP4.ParseMailBoxAttributeString(const AAttributesList: String; var AAttributes: TIdMailBoxAttributesSet); var LSlAttributes : TStringList; Ln : Integer; @@ -6316,7 +6316,7 @@ procedure TIdIMAP4.ParseListResult(AMBList: TStrings; ACmdResultDetails: TString InternalParseListResult(IMAP4Commands[cmdList], AMBList, ACmdResultDetails); end; -procedure TIdIMAP4.InternalParseListResult(ACmd: string; AMBList: TStrings; ACmdResultDetails: TStrings); +procedure TIdIMAP4.InternalParseListResult(const ACmd: string; AMBList: TStrings; ACmdResultDetails: TStrings); var Ln : Integer; LSlRetrieve : TStringList; LStr : String; @@ -6623,7 +6623,7 @@ procedure TIdIMAP4.ParseEnvelopeResult(AMsg: TIdMessage; ACmdResultStr: String); end; end; -function TIdIMAP4.ParseLastCmdResult(ALine: string; AExpectedCommand: string; AExpectedIMAPFunction: array of string): Boolean; +function TIdIMAP4.ParseLastCmdResult(ALine: string; const AExpectedCommand: string; AExpectedIMAPFunction: array of string): Boolean; var LPos: integer; LWord: string; diff --git a/Lib/Protocols/IdIMAP4Server.pas b/Lib/Protocols/IdIMAP4Server.pas index 96445ed0a..92128e03b 100644 --- a/Lib/Protocols/IdIMAP4Server.pas +++ b/Lib/Protocols/IdIMAP4Server.pas @@ -369,14 +369,14 @@ TIdIMAP4Server = class(TIdExplicitTLSServer) // //The following are used internally by the default mechanism... function ExpungeRecords(ASender: TIdCommand): Boolean; - function MessageSetToMessageNumbers(AUseUID: Boolean; ASender: TIdCommand; AMessageNumbers: TStrings; AMessageSet: string): Boolean; + function MessageSetToMessageNumbers(AUseUID: Boolean; ASender: TIdCommand; AMessageNumbers: TStrings; const AMessageSet: string): Boolean; function GetRecordForUID(const AUID: String; AMailBox: TIdMailBox): Int64; procedure ProcessFetch(AUseUID: Boolean; ASender: TIdCommand; AParams: TStrings); procedure ProcessCopy(AUseUID: Boolean; ASender: TIdCommand; AParams: TStrings); function ProcessStore(AUseUID: Boolean; ASender: TIdCommand; AParams: TStrings): Boolean; procedure ProcessSearch(AUseUID: Boolean; ASender: TIdCommand; AParams: TStrings); - function FlagStringToFlagList(AFlagList: TStrings; AFlagString: string): Boolean; - function StripQuotesIfNecessary(AName: string): string; + function FlagStringToFlagList(AFlagList: TStrings; const AFlagString: string): Boolean; + function StripQuotesIfNecessary(const AName: string): string; function ReassembleParams(ASeparator: char; AParams: TStrings; AParamToReassemble: integer): Boolean; function ReinterpretParamAsMailBox(AParams: TStrings; AMailBoxParam: integer): Boolean; function ReinterpretParamAsFlags(AParams: TStrings; AFlagsParam: integer): Boolean; @@ -697,7 +697,7 @@ function TIdIMAP4Server.ExpungeRecords(ASender: TIdCommand): Boolean; end; function TIdIMAP4Server.MessageSetToMessageNumbers(AUseUID: Boolean; ASender: TIdCommand; - AMessageNumbers: TStrings; AMessageSet: string): Boolean; + AMessageNumbers: TStrings; const AMessageSet: string): Boolean; {AMessageNumbers may be '7' or maybe '2:4' (2, 3 & 4) or maybe '2,4,6' (2, 4 & 6) or maybe '1:*'} var @@ -772,7 +772,7 @@ function TIdIMAP4Server.GetRecordForUID(const AUID: String; AMailBox: TIdMailBox Result := -1; end; -function TIdIMAP4Server.StripQuotesIfNecessary(AName: string): string; +function TIdIMAP4Server.StripQuotesIfNecessary(const AName: string): string; begin if Length(AName) > 0 then begin if (AName[1] = '"') and (AName[Length(Result)] = '"') then begin {Do not Localize} @@ -864,7 +864,7 @@ function TIdIMAP4Server.ReinterpretParamAsDataItems(AParams: TStrings; AFlagsPar Result := ReassembleParams('(', AParams, AFlagsParam); {Do not Localize} end; -function TIdIMAP4Server.FlagStringToFlagList(AFlagList: TStrings; AFlagString: string): Boolean; +function TIdIMAP4Server.FlagStringToFlagList(AFlagList: TStrings; const AFlagString: string): Boolean; var LTemp: string; begin diff --git a/Lib/Protocols/IdIPWatch.pas b/Lib/Protocols/IdIPWatch.pas index b6eeba479..5cf8795a0 100644 --- a/Lib/Protocols/IdIPWatch.pas +++ b/Lib/Protocols/IdIPWatch.pas @@ -104,7 +104,7 @@ TIdIPWatch = class(TIdComponent) FThread: TIdIPWatchThread; FWatchInterval: UInt32; // - procedure AddToIPHistoryList(Value: string); + procedure AddToIPHistoryList(const Value: string); procedure CheckStatus(Sender: TObject); procedure Loaded; override; procedure SetActive(Value: Boolean); @@ -153,7 +153,7 @@ implementation { TIdIPWatch } -procedure TIdIPWatch.AddToIPHistoryList(Value: string); +procedure TIdIPWatch.AddToIPHistoryList(const Value: string); begin if (Value = '') or (Value = '127.0.0.1') or (Value = '::1') then {Do not Localize} begin diff --git a/Lib/Protocols/IdIdentServer.pas b/Lib/Protocols/IdIdentServer.pas index ed51395b6..3f0e0aa6d 100644 --- a/Lib/Protocols/IdIdentServer.pas +++ b/Lib/Protocols/IdIdentServer.pas @@ -78,8 +78,8 @@ TIdIdentServer = class(TIdCustomTCPServer) procedure InitComponent; override; public Procedure ReplyError(AContext:TIdContext; AServerPort, AClientPort : TIdPort; AErr : TIdIdentErrorType); - Procedure ReplyIdent(AContext:TIdContext; AServerPort, AClientPort : TIdPort; AOS, AUserName : String; const ACharset : String = ''); {Do not Localize} - Procedure ReplyOther(AContext:TIdContext; AServerPort, AClientPort : TIdPort; AOther : String); + Procedure ReplyIdent(AContext:TIdContext; AServerPort, AClientPort : TIdPort; const AOS, AUserName : String; const ACharset : String = ''); {Do not Localize} + Procedure ReplyOther(AContext:TIdContext; AServerPort, AClientPort : TIdPort; const AOther : String); published property QueryTimeOut : Integer read FQueryTimeOut write FQueryTimeOut default IdDefIdentQueryTimeOut; Property OnIdentQuery : TIdIdentQueryEvent read FOnIdentQuery write FOnIdentQuery; @@ -134,7 +134,7 @@ procedure TIdIdentServer.ReplyError(AContext:TIdContext; AServerPort, end; procedure TIdIdentServer.ReplyIdent(AContext:TIdContext; AServerPort, - AClientPort: TIdPort; AOS, AUserName: String; const ACharset: String); + AClientPort: TIdPort; const AOS, AUserName: String; const ACharset: String); var s : String; begin s := IntToStr(AServerPort)+', '+IntToStr(AClientPort) + ' : USERID : '; {Do not Localize} @@ -146,7 +146,7 @@ procedure TIdIdentServer.ReplyIdent(AContext:TIdContext; AServerPort, end; procedure TIdIdentServer.ReplyOther(AContext:TIdContext; AServerPort, - AClientPort: TIdPort; AOther: String); + AClientPort: TIdPort; const AOther: String); begin AContext.Connection.IOHandler.WriteLn(IntToStr(AServerPort)+', '+IntToStr(AClientPort) + ' : USERID : OTHER : '+AOther); {Do not Localize} end; diff --git a/Lib/Protocols/IdMessage.pas b/Lib/Protocols/IdMessage.pas index ef60a20e0..8b5109d82 100644 --- a/Lib/Protocols/IdMessage.pas +++ b/Lib/Protocols/IdMessage.pas @@ -330,7 +330,7 @@ TIdMIMEBoundary = class(TObject) public constructor Create; destructor Destroy; override; - procedure Push(ABoundary: string; AParentPart: integer); + procedure Push(const ABoundary: string; AParentPart: integer); procedure Pop; procedure Clear; function Count: integer; @@ -594,7 +594,7 @@ procedure TIdMIMEBoundary.Pop; end; end; -procedure TIdMIMEBoundary.Push(ABoundary: string; AParentPart: integer); +procedure TIdMIMEBoundary.Push(const ABoundary: string; AParentPart: integer); begin {CC: Changed implementation to a simple stack} FBoundaryList.Insert(0, ABoundary); diff --git a/Lib/Protocols/IdMessageParts.pas b/Lib/Protocols/IdMessageParts.pas index 7cc563247..6a9d7b5d5 100644 --- a/Lib/Protocols/IdMessageParts.pas +++ b/Lib/Protocols/IdMessageParts.pas @@ -113,8 +113,8 @@ TIdMessagePart = class(TCollectionItem) constructor Create(Collection: TCollection); override; destructor Destroy; override; procedure Assign(Source: TPersistent); override; - function GetCharSet(AHeader: string): String; - function ResolveContentType(AContentType: string): string; //Fixes up ContentType + function GetCharSet(const AHeader: string): String; + function ResolveContentType(const AContentType: string): string; //Fixes up ContentType class function PartType: TIdMessagePartType; virtual; // property IsEncoded: Boolean read FIsEncoded; @@ -235,15 +235,16 @@ function TIdMessagePart.GetContentTransfer: string; Result := Headers.Values['Content-Transfer-Encoding']; {do not localize} end; -function TIdMessagePart.GetCharSet(AHeader: string): String; +function TIdMessagePart.GetCharSet(const AHeader: string): String; begin Result := ExtractHeaderSubItem(AHeader, 'charset', QuoteMIME); {do not localize} end; -function TIdMessagePart.ResolveContentType(AContentType: string): string; +function TIdMessagePart.ResolveContentType(const AContentType: string): string; var LMsg: TIdMessage; LParts: TIdMessageParts; + LContentType : String; begin //This extracts 'text/plain' from 'text/plain; charset="xyz"; boundary="123"' //or, if '', it finds the correct default value for MIME messages. @@ -257,8 +258,8 @@ function TIdMessagePart.ResolveContentType(AContentType: string): string; if Assigned(LMsg) and (LMsg.Encoding = meMIME) then begin //There is an exception if we are a child of multipart/digest... if ParentPart <> -1 then begin - AContentType := LParts.Items[ParentPart].Headers.Values['Content-Type']; {do not localize} - if IsHeaderMediaType(AContentType, 'multipart/digest') then begin {do not localize} + LContentType := LParts.Items[ParentPart].Headers.Values['Content-Type']; {do not localize} + if IsHeaderMediaType(LContentType, 'multipart/digest') then begin {do not localize} Result := 'message/rfc822'; {do not localize} Exit; end; diff --git a/Lib/Protocols/IdNNTP.pas b/Lib/Protocols/IdNNTP.pas index 597a9ae35..549cf74a1 100644 --- a/Lib/Protocols/IdNNTP.pas +++ b/Lib/Protocols/IdNNTP.pas @@ -200,13 +200,13 @@ TIdNNTP = class(TIdMessageClient) procedure AfterConnect; procedure GetCapability; function ConvertDateTimeDist(ADate: TDateTime; AGMT: boolean; - ADistributions: string): string; + const ADistributions: string): string; function GetSupportsTLS : boolean; override; procedure InitComponent; override; - procedure ProcessGroupList(ACmd: string; AResponse: integer; + procedure ProcessGroupList(const ACmd: string; AResponse: integer; ALisTIdEvent: TIdEvenTIdNewsgroupList); - procedure XHDRCommon(AHeader, AParam : String); - procedure XOVERCommon(AParam : String); + procedure XHDRCommon(const AHeader, AParam : String); + procedure XOVERCommon(const AParam : String); procedure StartTLS; public procedure Check(AMsgIDs: TStrings; AResponses: TStrings); @@ -215,65 +215,65 @@ TIdNNTP = class(TIdMessageClient) procedure DisconnectNotifyPeer; override; function GetArticle(AMsg: TIdMessage): Boolean; overload; function GetArticle(AMsgNo: Int64; AMsg: TIdMessage): Boolean; overload; - function GetArticle(AMsgID: string; AMsg: TIdMessage): Boolean; overload; + function GetArticle(const AMsgID: string; AMsg: TIdMessage): Boolean; overload; function GetArticle(AMsg: TStrings): Boolean; overload; function GetArticle(AMsgNo: Int64; AMsg: TStrings): Boolean; overload; - function GetArticle(AMsgID: string; AMsg: TStrings): Boolean; overload; + function GetArticle(const AMsgID: string; AMsg: TStrings): Boolean; overload; function GetArticle(AMsg: TStream): Boolean; overload; function GetArticle(AMsgNo: Int64; AMsg: TStream): Boolean; overload; - function GetArticle(AMsgID: string; AMsg: TStream): Boolean; overload; + function GetArticle(const AMsgID: string; AMsg: TStream): Boolean; overload; function GetBody(AMsg: TIdMessage): Boolean; overload; function GetBody(AMsgNo: Int64; AMsg: TIdMessage): Boolean; overload; - function GetBody(AMsgID: string; AMsg: TIdMessage): Boolean; overload; + function GetBody(const AMsgID: string; AMsg: TIdMessage): Boolean; overload; function GetBody(AMsg: TStrings): Boolean; overload; function GetBody(AMsgNo: Int64; AMsg: TStrings): Boolean; overload; - function GetBody(AMsgID: string; AMsg: TStrings): Boolean; overload; + function GetBody(const AMsgID: string; AMsg: TStrings): Boolean; overload; function GetBody(AMsg: TStream): Boolean; overload; function GetBody(AMsgNo: Int64; AMsg: TStream): Boolean; overload; - function GetBody(AMsgID: string; AMsg: TStream): Boolean; overload; + function GetBody(const AMsgID: string; AMsg: TStream): Boolean; overload; function GetHeader(AMsg: TIdMessage): Boolean; overload; function GetHeader(AMsgNo: Int64; AMsg: TIdMessage): Boolean; overload; - function GetHeader(AMsgID: string; AMsg: TIdMessage): Boolean; overload; + function GetHeader(const AMsgID: string; AMsg: TIdMessage): Boolean; overload; function GetHeader(AMsg: TStrings): Boolean; overload; function GetHeader(AMsgNo: Int64; AMsg: TStrings): Boolean; overload; - function GetHeader(AMsgID: string; AMsg: TStrings): Boolean; overload; + function GetHeader(const AMsgID: string; AMsg: TStrings): Boolean; overload; function GetHeader(AMsg: TStream): Boolean; overload; function GetHeader(AMsgNo: Int64; AMsg: TStream): Boolean; overload; - function GetHeader(AMsgID: string; AMsg: TStream): Boolean; overload; + function GetHeader(const AMsgID: string; AMsg: TStream): Boolean; overload; procedure GetNewsgroupList; overload; procedure GetNewsgroupList(AList: TStrings); overload; procedure GetNewsgroupList(AStream: TStream); overload; procedure GetNewGroupsList(ADate: TDateTime; AGMT: boolean; - ADistributions: string); overload; + const ADistributions: string); overload; procedure GetNewGroupsList(ADate: TDateTime; AGMT: boolean; - ADistributions: string; AList : TStrings); overload; - procedure GetNewNewsList(ANewsgroups: string; - ADate: TDateTime; AGMT: boolean; ADistributions: string); overload; - procedure GetNewNewsList(ANewsgroups: string; ADate: TDateTime; - AGMT: boolean; ADistributions: string; AList : TStrings); overload; + const ADistributions: string; AList : TStrings); overload; + procedure GetNewNewsList(const ANewsgroups: string; + ADate: TDateTime; AGMT: boolean; const ADistributions: string); overload; + procedure GetNewNewsList(const ANewsgroups: string; ADate: TDateTime; + AGMT: boolean; const ADistributions: string; AList : TStrings); overload; procedure GetOverviewFMT(AResponse: TStrings); - function IsExtCmdSupported(AExtension : String) : Boolean; + function IsExtCmdSupported(const AExtension : String) : Boolean; procedure IHAVE(AMsg: TStrings); function Next: Boolean; function Previous: Boolean; - procedure ParseXOVER(Aline: String; var AArticleIndex : Int64; var ASubject, + procedure ParseXOVER(const Aline: String; var AArticleIndex : Int64; var ASubject, AFrom : String; var ADate : TDateTime; var AMsgId, AReferences : String; var AByteCount, ALineCount : Integer; var AExtraData : String); - procedure ParseNewsGroup(ALine : String; out ANewsGroup: string; out AHi, ALo : Int64; + procedure ParseNewsGroup(const ALine : String; out ANewsGroup: string; out AHi, ALo : Int64; out AStatus : String); - procedure ParseXHDRLine(ALine : String; out AMsg : String; out AHeaderData : String); + procedure ParseXHDRLine(const ALine : String; out AMsg : String; out AHeaderData : String); procedure Post(AMsg: TIdMessage); overload; procedure Post(AStream: TStream); overload; function SendCmd(AOut: string; const AResponse: array of Int16; AEncoding: IIdTextEncoding = nil): Int16; override; function SelectArticle(AMsgNo: Int64): Boolean; - procedure SelectGroup(AGroup: string); - function TakeThis(AMsgID: string; AMsg: TStream): string; - procedure XHDR(AHeader: string; AParam: string; AResponse: TStrings); overload; - procedure XHDR(AHeader: string; AParam: string); overload; - procedure XOVER(AParam: string; AResponse: TStrings); overload; - procedure XOVER(AParam: string; AResponse: TStream); overload; - procedure XOVER(AParam: string); overload; + procedure SelectGroup(const AGroup: string); + function TakeThis(const AMsgID: string; AMsg: TStream): string; + procedure XHDR(const AHeader, AParam: string; AResponse: TStrings); overload; + procedure XHDR(const AHeader, AParam: string); overload; + procedure XOVER(const AParam: string; AResponse: TStrings); overload; + procedure XOVER(const AParam: string; AResponse: TStream); overload; + procedure XOVER(const AParam: string); overload; procedure SendAuth; // property ModeResult: TIdModeSetResult read FModeResult write FModeResult; @@ -316,7 +316,7 @@ implementation IdResourceStringsProtocols, IdSSL, SysUtils; -procedure TIdNNTP.ParseXOVER(Aline : String; +procedure TIdNNTP.ParseXOVER(const Aline : String; var AArticleIndex : Int64; var ASubject, AFrom : String; @@ -326,37 +326,40 @@ procedure TIdNNTP.ParseXOVER(Aline : String; var AByteCount, ALineCount : Integer; var AExtraData : String); - +var LLine : String; begin + LLine := ALine; {Strip backspace and tab junk sequences which occur after a tab separator so they don't throw off any code} - ALine := ReplaceAll(ALine, #9#8#9, #9); + LLine := ReplaceAll(LLine, #9#8#9, #9); {Article Index} - AArticleIndex := IndyStrToInt64(Fetch(ALine, #9), 0); + AArticleIndex := IndyStrToInt64(Fetch(LLine, #9), 0); {Subject} - ASubject := Fetch(ALine, #9); + ASubject := Fetch(LLine, #9); {From} - AFrom := Fetch(ALine, #9); + AFrom := Fetch(LLine, #9); {Date} - ADate := GMTToLocalDateTime(Fetch(Aline, #9)); + ADate := GMTToLocalDateTime(Fetch(Lline, #9)); {Message ID} - AMsgId := Fetch(Aline, #9); + AMsgId := Fetch(Lline, #9); {References} - AReferences := Fetch(ALine, #9); + AReferences := Fetch(LLine, #9); {Byte Count} - AByteCount := IndyStrToInt(Fetch(ALine, #9), 0); + AByteCount := IndyStrToInt(Fetch(LLine, #9), 0); {Line Count} - ALineCount := IndyStrToInt(Fetch(ALine, #9), 0); + ALineCount := IndyStrToInt(Fetch(LLine, #9), 0); {Extra data} - AExtraData := ALine; + AExtraData := LLine; end; -procedure TIdNNTP.ParseNewsGroup(ALine : String; out ANewsGroup : String; +procedure TIdNNTP.ParseNewsGroup(const ALine : String; out ANewsGroup : String; out AHi, ALo : Int64; out AStatus : String); +var LLine : String; begin - ANewsgroup := Fetch(ALine, ' '); - AHi := IndyStrToInt64(Fetch(Aline, ' '), 0); - ALo := IndyStrToInt64(Fetch(ALine, ' '), 0); - AStatus := ALine; + LLine := ALine; + ANewsgroup := Fetch(LLine, ' '); + AHi := IndyStrToInt64(Fetch(Lline, ' '), 0); + ALo := IndyStrToInt64(Fetch(LLine, ' '), 0); + AStatus := LLine; end; procedure TIdNNTP.InitComponent; @@ -418,7 +421,7 @@ procedure TIdNNTP.GetOverviewFMT(AResponse: TStrings); Article Number followed by a dash and aother number Remember to select a group first and to issue a GetOverviewFMT so that you can interpret the information sent by the server corectly. } -procedure TIdNNTP.XOVER(AParam: string; AResponse: TStrings); +procedure TIdNNTP.XOVER(const AParam: string; AResponse: TStrings); var LEncoding: IIdTextEncoding; begin @@ -427,7 +430,7 @@ procedure TIdNNTP.XOVER(AParam: string; AResponse: TStrings); IOHandler.Capture(AResponse, LEncoding{$IFDEF STRING_IS_ANSI}, LEncoding{$ENDIF}); end; -procedure TIdNNTP.XOVER(AParam: string; AResponse: TStream); +procedure TIdNNTP.XOVER(const AParam: string; AResponse: TStream); var LEncoding: IIdTextEncoding; begin @@ -442,7 +445,7 @@ procedure TIdNNTP.XOVER(AParam: string; AResponse: TStream); Article Number followed by a dash and aother number Parm is either the Range or the MessageID of the articles you want. They are Mutually Exclusive} -procedure TIdNNTP.XHDR(AHeader: string; AParam: String; AResponse: TStrings); +procedure TIdNNTP.XHDR(const AHeader, AParam: String; AResponse: TStrings); var LEncoding: IIdTextEncoding; begin @@ -479,7 +482,7 @@ procedure TIdNNTP.XHDR(AHeader: string; AParam: String; AResponse: TStrings); IOHandler.Capture(AResponse, LEncoding{$IFDEF STRING_IS_ANSI}, LEncoding{$ENDIF}); end; -procedure TIdNNTP.SelectGroup(AGroup: string); +procedure TIdNNTP.SelectGroup(const AGroup: string); var s: string; begin @@ -598,7 +601,7 @@ procedure TIdNNTP.Check(AMsgIDs: TStrings; AResponses: TStrings); 480 Transfer permission denied 500 Command not understood *) -function TIdNNTP.TakeThis(AMsgID: string; AMsg: TStream): string; +function TIdNNTP.TakeThis(const AMsgID: string; AMsg: TStream): string; // This message assumes AMsg is "raw" and has already taken care of . to .. begin SendCmd('TAKETHIS ' + AMsgID, 239); {do not localize} @@ -677,7 +680,7 @@ procedure TIdNNTP.Post(AStream: TStream); SendCmd('.', 240); end; -procedure TIdNNTP.ProcessGroupList(ACmd: string; AResponse: integer; +procedure TIdNNTP.ProcessGroupList(const ACmd: string; AResponse: integer; ALisTIdEvent: TIdEvenTIdNewsgroupList); var s1, sNewsgroup: string; @@ -709,7 +712,7 @@ procedure TIdNNTP.GetNewsgroupList; end; procedure TIdNNTP.GetNewGroupsList(ADate: TDateTime; AGMT: boolean; - ADistributions: string); + const ADistributions: string); begin if not Assigned(FOnNewGroupsList) then begin raise EIdNNTPNoOnNewGroupsList.Create(RSNNTPNoOnNewGroupsList); @@ -718,8 +721,8 @@ procedure TIdNNTP.GetNewGroupsList(ADate: TDateTime; AGMT: boolean; 231, FOnNewGroupsList); end; -procedure TIdNNTP.GetNewNewsList(ANewsgroups: string; - ADate: TDateTime; AGMT: boolean; ADistributions: string); +procedure TIdNNTP.GetNewNewsList(const ANewsgroups: string; + ADate: TDateTime; AGMT: boolean; const ADistributions: string); var s1: string; CanContinue: Boolean; @@ -820,7 +823,7 @@ procedure TIdNNTP.GetNewsgroupList(AList: TStrings); end; procedure TIdNNTP.GetNewGroupsList(ADate: TDateTime; AGMT: boolean; - ADistributions: string; AList: TStrings); + const ADistributions: string; AList: TStrings); var LEncoding: IIdTextEncoding; begin @@ -829,8 +832,8 @@ procedure TIdNNTP.GetNewGroupsList(ADate: TDateTime; AGMT: boolean; IOHandler.Capture(AList, LEncoding{$IFDEF STRING_IS_ANSI}, LEncoding{$ENDIF}); end; -procedure TIdNNTP.GetNewNewsList(ANewsgroups: string; ADate: TDateTime; - AGMT: boolean; ADistributions: string; AList: TStrings); +procedure TIdNNTP.GetNewNewsList(const ANewsgroups: string; ADate: TDateTime; + AGMT: boolean; const ADistributions: string; AList: TStrings); var LEncoding: IIdTextEncoding; begin @@ -840,7 +843,7 @@ procedure TIdNNTP.GetNewNewsList(ANewsgroups: string; ADate: TDateTime; end; function TIdNNTP.ConvertDateTimeDist(ADate: TDateTime; AGMT: boolean; - ADistributions: string): string; + const ADistributions: string): string; begin Result := FormatDateTime('yymmdd hhnnss', ADate); {do not localize} if AGMT then begin @@ -962,7 +965,7 @@ function TIdNNTP.GetArticle(AMsgNo: Int64; AMsg: TIdMessage): Boolean; end; end; -function TIdNNTP.GetArticle(AMsgID: string; AMsg: TIdMessage): Boolean; +function TIdNNTP.GetArticle(const AMsgID: string; AMsg: TIdMessage): Boolean; begin Result := SendCmd('ARTICLE ' + EnsureMsgIDBrackets(AMsgID), [220, 430]) = 220; {do not localize} if Result then begin @@ -1001,7 +1004,7 @@ function TIdNNTP.GetArticle(AMsgNo: Int64; AMsg: TStrings): Boolean; end; end; -function TIdNNTP.GetArticle(AMsgID: string; AMsg: TStrings): Boolean; +function TIdNNTP.GetArticle(const AMsgID: string; AMsg: TStrings): Boolean; var LEncoding: IIdTextEncoding; begin @@ -1042,7 +1045,7 @@ function TIdNNTP.GetArticle(AMsgNo: Int64; AMsg: TStream): Boolean; end; end; -function TIdNNTP.GetArticle(AMsgID: string; AMsg: TStream): Boolean; +function TIdNNTP.GetArticle(const AMsgID: string; AMsg: TStream): Boolean; var LEncoding: IIdTextEncoding; begin @@ -1080,7 +1083,7 @@ function TIdNNTP.GetBody(AMsgNo: Int64; AMsg: TIdMessage): Boolean; end; end; -function TIdNNTP.GetBody(AMsgID: string; AMsg: TIdMessage): Boolean; +function TIdNNTP.GetBody(const AMsgID: string; AMsg: TIdMessage): Boolean; begin Result := SendCmd('BODY ' + EnsureMsgIDBrackets(AMsgID), [222, 430]) = 222; {do not localize} if Result then begin @@ -1114,7 +1117,7 @@ function TIdNNTP.GetBody(AMsgNo: Int64; AMsg: TStrings): Boolean; end; end; -function TIdNNTP.GetBody(AMsgID: string; AMsg: TStrings): Boolean; +function TIdNNTP.GetBody(const AMsgID: string; AMsg: TStrings): Boolean; var LEncoding: IIdTextEncoding; begin @@ -1149,7 +1152,7 @@ function TIdNNTP.GetBody(AMsgNo: Int64; AMsg: TStream): Boolean; end; end; -function TIdNNTP.GetBody(AMsgID: string; AMsg: TStream): Boolean; +function TIdNNTP.GetBody(const AMsgID: string; AMsg: TStream): Boolean; var LEncoding: IIdTextEncoding; begin @@ -1179,7 +1182,7 @@ function TIdNNTP.GetHeader(AMsgNo: Int64; AMsg: TIdMessage): Boolean; end; end; -function TIdNNTP.GetHeader(AMsgID: string; AMsg: TIdMessage): Boolean; +function TIdNNTP.GetHeader(const AMsgID: string; AMsg: TIdMessage): Boolean; begin Result := SendCmd('HEAD ' + EnsureMsgIDBrackets(AMsgID), [221, 430]) = 221; {do not localize} if Result then begin @@ -1217,7 +1220,7 @@ function TIdNNTP.GetHeader(AMsgNo: Int64; AMsg: TStrings): Boolean; end; end; -function TIdNNTP.GetHeader(AMsgID: string; AMsg: TStrings): Boolean; +function TIdNNTP.GetHeader(const AMsgID: string; AMsg: TStrings): Boolean; var LEncoding: IIdTextEncoding; begin @@ -1258,7 +1261,7 @@ function TIdNNTP.GetHeader(AMsgNo: Int64; AMsg: TStream): Boolean; end; end; -function TIdNNTP.GetHeader(AMsgID: string; AMsg: TStream): Boolean; +function TIdNNTP.GetHeader(const AMsgID: string; AMsg: TStream): Boolean; var LEncoding: IIdTextEncoding; begin @@ -1359,7 +1362,7 @@ procedure TIdNNTP.GetCapability; // Self.FStartTLSSupported := IsExtCmdSupported('STARTTLS'); end; -function TIdNNTP.IsExtCmdSupported(AExtension: String): Boolean; +function TIdNNTP.IsExtCmdSupported(const AExtension: String): Boolean; begin Result := FCapabilities.IndexOf(Trim(UpperCase(AExtension))) > -1; end; @@ -1396,7 +1399,7 @@ function TIdNNTP.GetSupportsTLS: boolean; Result := IsExtCmdSupported('STARTTLS') {do not localize} end; -procedure TIdNNTP.XHDR(AHeader, AParam: string); +procedure TIdNNTP.XHDR(const AHeader, AParam: string); var LLine : String; LMsg, LHeaderData : String; @@ -1424,7 +1427,7 @@ procedure TIdNNTP.XHDR(AHeader, AParam: string); end; end; -procedure TIdNNTP.XOVER(AParam: string); +procedure TIdNNTP.XOVER(const AParam: string); var LLine : String; //for our XOVER data @@ -1461,9 +1464,11 @@ procedure TIdNNTP.XOVER(AParam: string); end; end; -procedure TIdNNTP.ParseXHDRLine(ALine: String; out AMsg, - AHeaderData: String); +procedure TIdNNTP.ParseXHDRLine(const ALine: String; out AMsg, + AHeaderData: String); +var LLine : String; begin + LLine := ALine; //from: RFC 2890 //Each line //containing matched headers returned by the server has an article @@ -1478,11 +1483,11 @@ procedure TIdNNTP.ParseXHDRLine(ALine: String; out AMsg, // (without the header name or the colon and space that follow it) or // metadata item. If the article is specified by message-id rather than // by article range, the article number is given as "0". - AMsg := Fetch(ALine); - AHeaderData := ALine; + AMsg := Fetch(LLine); + AHeaderData := LLine; end; -procedure TIdNNTP.XHDRCommon(AHeader, AParam : String); +procedure TIdNNTP.XHDRCommon(const AHeader, AParam : String); begin if FHDRSupported then begin @@ -1496,7 +1501,7 @@ procedure TIdNNTP.XHDRCommon(AHeader, AParam : String); end; end; -procedure TIdNNTP.XOVERCommon(AParam: String); +procedure TIdNNTP.XOVERCommon(const AParam: String); begin if FOVERSupported then begin SendCmd('OVER '+ AParam, 224); {do not localize} diff --git a/Lib/Protocols/IdRemoteCMDClient.pas b/Lib/Protocols/IdRemoteCMDClient.pas index dd1214ed4..ff5d77184 100644 --- a/Lib/Protocols/IdRemoteCMDClient.pas +++ b/Lib/Protocols/IdRemoteCMDClient.pas @@ -73,7 +73,7 @@ TIdRemoteCMDClient = class(TIdTCPClientCustom) FErrorMessage : String; FErrorReply : Boolean; // - function InternalExec(AParam1, AParam2, ACommand : String) : String; virtual; + function InternalExec(const AParam1, AParam2, ACommand : String) : String; virtual; procedure InitComponent; override; public destructor Destroy; override; @@ -119,7 +119,7 @@ function TIdRemoteCMDClient.Execute(ACommand: String): String; Result := ''; {Do not Localize} end; -function TIdRemoteCMDClient.InternalExec(AParam1, AParam2, ACommand: String) : String; +function TIdRemoteCMDClient.InternalExec(const AParam1, AParam2, ACommand: String) : String; var stdErr : TIdSimpleServer; thr : TIdStdErrThread; diff --git a/Lib/Protocols/IdRemoteCMDServer.pas b/Lib/Protocols/IdRemoteCMDServer.pas index d16df934f..8dfd38b56 100644 --- a/Lib/Protocols/IdRemoteCMDServer.pas +++ b/Lib/Protocols/IdRemoteCMDServer.pas @@ -54,8 +54,8 @@ TIdRemoteCMDServer = class(TIdCustomTCPServer) procedure DoCMD(AThread: TIdContext; AStdError : TIdTCPClient; AParam1, AParam2, ACommand : String); virtual; abstract; public - procedure SendError(AThread : TIdContext;AStdErr : TIdTCPClient; AMsg : String); - procedure SendResults(AThread : TIdContext; AStdErr : TIdTCPClient; AMsg : String); + procedure SendError(AThread : TIdContext;AStdErr : TIdTCPClient; const AMsg : String); + procedure SendResults(AThread : TIdContext; AStdErr : TIdTCPClient; const AMsg : String); end; implementation @@ -149,7 +149,7 @@ function TIdRemoteCMDServer.DoExecute(AThread: TIdContext): boolean; end; procedure TIdRemoteCMDServer.SendError(AThread: TIdContext; - AStdErr: TIdTCPClient; AMsg: String); + AStdErr: TIdTCPClient; const AMsg: String); begin AThread.Connection.IOHandler.Write(#1); if Assigned(AStdErr) then begin @@ -160,7 +160,7 @@ procedure TIdRemoteCMDServer.SendError(AThread: TIdContext; end; procedure TIdRemoteCMDServer.SendResults(AThread: TIdContext; - AStdErr: TIdTCPClient; AMsg: String); + AStdErr: TIdTCPClient; const AMsg: String); begin AThread.Connection.IOHandler.Write(#0 + AMsg) end; diff --git a/Lib/Protocols/IdReplyIMAP4.pas b/Lib/Protocols/IdReplyIMAP4.pas index 7595256c2..61a58886b 100644 --- a/Lib/Protocols/IdReplyIMAP4.pas +++ b/Lib/Protocols/IdReplyIMAP4.pas @@ -169,7 +169,7 @@ TIdReplyIMAP4 = class(TIdReply) // //CLIENT-SIDE (TIdIMAP4) FUNCTIONS... procedure RaiseReplyError; override; - procedure DoReplyError(ADescription: string; AnOffendingLine: string = ''); reintroduce; + procedure DoReplyError(const ADescription: string; const AnOffendingLine: string = ''); reintroduce; procedure RemoveUnsolicitedResponses(AExpectedResponses: array of String); function DoesLineHaveExpectedResponse(ALine: string; AExpectedResponses: array of string): Boolean; {CC: The following decides if AValue is a valid command sequence number @@ -510,7 +510,7 @@ function TIdReplyIMAP4.DoesLineHaveExpectedResponse(ALine: string; AExpectedResp end; end; -procedure TIdReplyIMAP4.DoReplyError(ADescription: string; AnOffendingLine: string); +procedure TIdReplyIMAP4.DoReplyError(const ADescription: string; const AnOffendingLine: string); var LMsg: string; begin diff --git a/Lib/Protocols/IdSMTP.pas b/Lib/Protocols/IdSMTP.pas index 87b9095aa..9dcbe61ec 100644 --- a/Lib/Protocols/IdSMTP.pas +++ b/Lib/Protocols/IdSMTP.pas @@ -241,8 +241,8 @@ TIdSMTP = class(TIdSMTPBase) procedure DisconnectNotifyPeer; override; class procedure QuickSend(const AHost, ASubject, ATo, AFrom, AText: string); overload; {$IFDEF HAS_DEPRECATED}deprecated{$IFDEF HAS_DEPRECATED_MSG} 'Use ContentType overload of QuickSend()'{$ENDIF};{$ENDIF} class procedure QuickSend(const AHost, ASubject, ATo, AFrom, AText, AContentType, ACharset, AContentTransferEncoding: string); overload; - procedure Expand(AUserName : String; AResults : TStrings); virtual; - function Verify(AUserName : String) : String; virtual; + procedure Expand(const AUserName : String; AResults : TStrings); virtual; + function Verify(const AUserName : String) : String; virtual; // property DidAuthenticate: Boolean read FDidAuthenticate; published @@ -398,7 +398,7 @@ procedure TIdSMTP.DisconnectNotifyPeer; SendCmd('QUIT', 221); {Do not Localize} end; -procedure TIdSMTP.Expand(AUserName: String; AResults: TStrings); +procedure TIdSMTP.Expand(const AUserName: String; AResults: TStrings); begin SendCmd('EXPN ' + AUserName, [250, 251]); {Do not Localize} end; @@ -484,7 +484,7 @@ procedure TIdSMTP.SetUseEhlo(const AValue: Boolean); end; End; -function TIdSMTP.Verify(AUserName: string): string; +function TIdSMTP.Verify(const AUserName: string): string; begin SendCmd('VRFY ' + AUserName, [250, 251]); {Do not Localize} Result := LastCmdResult.Text[0]; diff --git a/Lib/Protocols/IdSMTPRelay.pas b/Lib/Protocols/IdSMTPRelay.pas index 488a49db9..f954eb255 100644 --- a/Lib/Protocols/IdSMTPRelay.pas +++ b/Lib/Protocols/IdSMTPRelay.pas @@ -212,7 +212,7 @@ TIdSMTPRelay = class(TIdSMTPBase) FSSLOptions : TIdSSLSupportOptions; FRelaySender: String; procedure Connect(AEMailAddress : TIdEMailAddressItem); reintroduce; - procedure ResolveMXServers(AAddress:String); + procedure ResolveMXServers(const AAddress:String); procedure SetDNSServer(const Value: String); procedure SetOnStatus(const Value: TIdSMTPRelayStatus); procedure SetUseEhlo(const AValue : Boolean); override; @@ -364,7 +364,7 @@ procedure TIdSMTPRelay.ProcessException(AException: Exception; AEMailAddress : T end; end; -procedure TIdSMTPRelay.ResolveMXServers(AAddress: String); +procedure TIdSMTPRelay.ResolveMXServers(const AAddress: String); var IdDNSResolver1: TIdDNSResolver; DnsResource : TResultRecord; diff --git a/Lib/Protocols/IdSMTPServer.pas b/Lib/Protocols/IdSMTPServer.pas index 84a72687d..3a09341a4 100644 --- a/Lib/Protocols/IdSMTPServer.pas +++ b/Lib/Protocols/IdSMTPServer.pas @@ -179,7 +179,7 @@ TIdSMTPServer = class(TIdExplicitTLSServer) } //common reply procs procedure AuthFailed(ASender: TIdCommand); - procedure CmdSyntaxError(AContext: TIdContext; ALine: string; const AReply : TIdReply = nil); overload; + procedure CmdSyntaxError(AContext: TIdContext; const ALine: string; const AReply : TIdReply = nil); overload; procedure CmdSyntaxError(ASender: TIdCommand); overload; procedure BadSequenceError(ASender: TIdCommand); @@ -309,7 +309,7 @@ constructor TIdSMTPServer.Create(AOwner: TComponent); end; {$ENDIF} -procedure TIdSMTPServer.CmdSyntaxError(AContext: TIdContext; ALine: string; +procedure TIdSMTPServer.CmdSyntaxError(AContext: TIdContext; const ALine: string; const AReply: TIdReply); var LTmp : String; diff --git a/Lib/Protocols/IdSNMP.pas b/Lib/Protocols/IdSNMP.pas index a4cce3c07..d1d516876 100644 --- a/Lib/Protocols/IdSNMP.pas +++ b/Lib/Protocols/IdSNMP.pas @@ -138,12 +138,12 @@ TSNMPInfo = class(TObject) destructor Destroy; override; function EncodeTrap: Boolean; function DecodeTrap: Boolean; - procedure DecodeBuf(Buffer: string); + procedure DecodeBuf(const Buffer: string); function EncodeBuf: string; procedure Clear; - procedure MIBAdd(MIB, Value: string; ValueType: Integer = ASN1_OCTSTR); + procedure MIBAdd(const MIB, Value: string; ValueType: Integer = ASN1_OCTSTR); procedure MIBDelete(Index: integer); - function MIBGet(MIB: string): string; + function MIBGet(const MIB: string): string; property Owner : TIdSNMP read fOwner; property Community : string read fCommunity write SetCommunity; @@ -337,7 +337,7 @@ procedure TSNMPInfo.SyncMIB; | Parameters: | | Buffer:string The ASN buffer to decode | *----------------------------------------------------------------------------*) -procedure TSNMPInfo.DecodeBuf(Buffer: string); +procedure TSNMPInfo.DecodeBuf(const Buffer: string); var Pos: integer; endpos,vt: integer; @@ -456,7 +456,7 @@ procedure TSNMPInfo.Clear; | valueType : Integer The Value's type. Optional - defaults to | {Do not Localize} | ASN1_OCTSTR | *----------------------------------------------------------------------------*) -procedure TSNMPInfo.MIBAdd(MIB, Value: string; ValueType: Integer); +procedure TSNMPInfo.MIBAdd(const MIB, Value: string; ValueType: Integer); {$IFNDEF HAS_GENERICS_TList} var x: integer; @@ -510,7 +510,7 @@ procedure TSNMPInfo.MIBDelete(Index: integer); | | | The function returns the string representation of the value. | *----------------------------------------------------------------------------*) -function TSNMPInfo.MIBGet(MIB: string): string; +function TSNMPInfo.MIBGet(const MIB: string): string; var x: integer; begin diff --git a/Lib/Protocols/IdSNPP.pas b/Lib/Protocols/IdSNPP.pas index 6c27adb1f..3c49f6093 100644 --- a/Lib/Protocols/IdSNPP.pas +++ b/Lib/Protocols/IdSNPP.pas @@ -98,14 +98,14 @@ interface TIdSNPP = class(TIdTCPClientCustom) protected - function Pager(APagerId: String): Boolean; - function SNPPMsg(AMsg: String): Boolean; + function Pager(const APagerId: String): Boolean; + function SNPPMsg(const AMsg: String): Boolean; procedure InitComponent; override; public procedure Connect; override; procedure DisconnectNotifyPeer; override; procedure Reset; - procedure SendMessage(APagerId, AMsg: String); + procedure SendMessage(const APagerId, AMsg: String); published property Port default 7777; property Host; @@ -150,7 +150,7 @@ procedure TIdSNPP.DisconnectNotifyPeer; SendCmd('QUIT', 211); {do not localize} end; -function TIdSNPP.Pager(APagerId: String): Boolean; +function TIdSNPP.Pager(const APagerId: String): Boolean; begin Result := False; if SendCmd('PAGER ' + APagerID) = 250 then begin {do not localize} @@ -165,7 +165,7 @@ procedure TIdSNPP.Reset; Writeln('RESET'); {do not localize} end; -procedure TIdSNPP.SendMessage(APagerId, AMsg : String); +procedure TIdSNPP.SendMessage(const APagerId, AMsg : String); begin if (Pos(CR,AMsg)>0) or (Pos(LF,AMsg)>0) then begin @@ -181,7 +181,7 @@ procedure TIdSNPP.SendMessage(APagerId, AMsg : String); end; end; -function TIdSNPP.SNPPMsg(AMsg: String): Boolean; +function TIdSNPP.SNPPMsg(const AMsg: String): Boolean; begin Result := False; if SendCmd('MESS ' + AMsg) = 250 then begin {do not localize} diff --git a/Lib/Protocols/IdSocksServer.pas b/Lib/Protocols/IdSocksServer.pas index 5bfef7adf..69b2f64c1 100644 --- a/Lib/Protocols/IdSocksServer.pas +++ b/Lib/Protocols/IdSocksServer.pas @@ -231,7 +231,7 @@ implementation IdSocketHandle, IdStack; -function IPToBytes(AIP: string; const AIPVersion: TIdIPVersion): TIdBytes; +function IPToBytes(const AIP: string; const AIPVersion: TIdIPVersion): TIdBytes; var LIP: TIdIPAddress; begin diff --git a/Lib/Protocols/IdTrivialFTPBase.pas b/Lib/Protocols/IdTrivialFTPBase.pas index 81aa1a247..3acb91189 100644 --- a/Lib/Protocols/IdTrivialFTPBase.pas +++ b/Lib/Protocols/IdTrivialFTPBase.pas @@ -47,9 +47,9 @@ interface // Procs function MakeActPkt(const BlockNumber: Word): TIdBytes; -procedure SendError(UDPBase: TIdUDPBase; APeerIP: string; const APort: TIdPort; const ErrNumber: Word; const ErrString: string); overload; +procedure SendError(UDPBase: TIdUDPBase; const APeerIP: string; const APort: TIdPort; const ErrNumber: Word; const ErrString: string); overload; procedure SendError(UDPClient: TIdUDPClient; const ErrNumber: Word; const ErrString: string); overload; -procedure SendError(UDPBase: TIdUDPBase; APeerIP: string; const APort: TIdPort; E: Exception); overload; +procedure SendError(UDPBase: TIdUDPBase; const APeerIP: string; const APort: TIdPort; E: Exception); overload; procedure SendError(UDPClient: TIdUDPClient; E: Exception); overload; const // TFTP opcodes @@ -88,7 +88,7 @@ function MakeActPkt(const BlockNumber: Word): TIdBytes; CopyTIdUInt16(GStack.HostToNetwork(BlockNumber), Result, 2); end; -procedure SendError(UDPBase: TIdUDPBase; APeerIP: string; const APort: TIdPort; const ErrNumber: Word; const ErrString: string); +procedure SendError(UDPBase: TIdUDPBase; const APeerIP: string; const APort: TIdPort; const ErrNumber: Word; const ErrString: string); var Buffer, LErrStr: TIdBytes; begin @@ -106,7 +106,7 @@ procedure SendError(UDPClient: TIdUDPClient; const ErrNumber: Word; const ErrStr SendError(UDPClient, UDPClient.Host, UDPClient.Port, ErrNumber, ErrString); end; -procedure SendError(UDPBase: TIdUDPBase; APeerIP: string; const APort: TIdPort; E: Exception); +procedure SendError(UDPBase: TIdUDPBase; const APeerIP: string; const APort: TIdPort; E: Exception); var ErrNumber: Word; begin diff --git a/Lib/Protocols/IdTrivialFTPServer.pas b/Lib/Protocols/IdTrivialFTPServer.pas index da5e2b8de..32bb93d91 100644 --- a/Lib/Protocols/IdTrivialFTPServer.pas +++ b/Lib/Protocols/IdTrivialFTPServer.pas @@ -78,7 +78,7 @@ TIdTrivialFTPServer = class(TIdUDPServer) FOnTransferComplete: TTransferCompleteEvent; FOnReadFile, FOnWriteFile: TAccessFileEvent; - function StrToMode(mode: string): TIdTFTPMode; + function StrToMode(const mode: string): TIdTFTPMode; protected procedure DoReadFile(FileName: String; const Mode: TIdTFTPMode; const PeerInfo: TPeerInfo; RequestedBlockSize: Integer; IncludeTransferSize: Boolean); virtual; @@ -401,7 +401,7 @@ procedure TIdTrivialFTPServer.DoWriteFile(FileName: String; const Mode: TIdTFTPM {$ENDIF} end; -function TIdTrivialFTPServer.StrToMode(mode: string): TIdTFTPMode; +function TIdTrivialFTPServer.StrToMode(const mode: string): TIdTFTPMode; begin case PosInStrArray(mode, ['octet', 'binary', 'netascii'], False) of {Do not Localize} 0, 1: Result := tfOctet; diff --git a/Lib/Protocols/IdVCard.pas b/Lib/Protocols/IdVCard.pas index e7ef7e5b2..5e87856bc 100644 --- a/Lib/Protocols/IdVCard.pas +++ b/Lib/Protocols/IdVCard.pas @@ -513,7 +513,7 @@ function IndyStrToFloat(const AStr: string): Extended; end; {This only adds Value to strs if it is not zero} -procedure AddValueToStrings(strs : TStrings; Value : String); +procedure AddValueToStrings(strs : TStrings; const Value : String); begin if Length(Value) > 0 then begin strs.Add(Value); @@ -1123,7 +1123,7 @@ procedure ParseGeography(Geog : TIdVCardGeog; GeogStr : String); end; {This parses PhoneStr and places the attributes in PhoneObj } -procedure ParseTelephone(PhoneObj : TIdCardPhoneNumber; PhoneStr : String); +procedure ParseTelephone(PhoneObj : TIdCardPhoneNumber; const PhoneStr : String); const TelephoneTypePropertyParameter : array [0..13] of string = ( 'HOME', 'MSG', 'WORK', 'PREF', 'VOICE', 'FAX', {Do not Localize} @@ -1180,7 +1180,7 @@ procedure ParseTelephone(PhoneObj : TIdCardPhoneNumber; PhoneStr : String); end; {This parses AddressStr and places the attributes in AddressObj } -procedure ParseAddress(AddressObj : TIdCardAddressItem; AddressStr : String); +procedure ParseAddress(AddressObj : TIdCardAddressItem; const AddressStr : String); const AttribsArray : array[0..6] of String = ( 'HOME', 'DOM', 'INTL', 'POSTAL', 'PARCEL', 'WORK', 'PREF' {Do not Localize} @@ -1226,7 +1226,7 @@ procedure ParseAddress(AddressObj : TIdCardAddressItem; AddressStr : String); end; {This parses LabelStr and places the attributes in TIdVCardMailingLabelItem } -procedure ParseMailingLabel(LabelObj : TIdVCardMailingLabelItem; LabelStr : String); +procedure ParseMailingLabel(LabelObj : TIdVCardMailingLabelItem; const LabelStr : String); const AttribsArray : array[0..6] of String = ( 'HOME', 'DOM', 'INTL', 'POSTAL', 'PARCEL', 'WORK', 'PREF' {Do not Localize} @@ -1286,7 +1286,7 @@ procedure ParseName(NameObj : TIdVCardName; NameStr : String); end; {This parses EMailStr and places the attributes in EMailObj } -procedure ParseEMailAddress(EMailObj : TIdVCardEMailItem; EMailStr : String); +procedure ParseEMailAddress(EMailObj : TIdVCardEMailItem; const EMailStr : String); var Value : String; Attribs : TStringList; @@ -1464,7 +1464,7 @@ procedure TIdVCard.SetVariablesAfterRead; { TODO : Eliminate embedded vCard } end; - procedure ParseEmbeddedObject(EmObj : TIdVCardEmbeddedObject; StLn : String); + procedure ParseEmbeddedObject(EmObj : TIdVCardEmbeddedObject; const StLn : String); var Value : String; LAttribs : TStringList; @@ -1503,7 +1503,7 @@ procedure TIdVCard.SetVariablesAfterRead; end; end; - function GetDateTimeValue(St: String): TDateTime; + function GetDateTimeValue(const St: String): TDateTime; var LAttribs: String; LDate: TIdISO8601DateComps;