Gehe zu deutscher Webseite

ViaThinkSoft CodeLib

This article is in:
CodeLibProgramming aidsDelphi

Protocols/IdFTP.pas

1. Find:

        IOHandler.DefAnsiEncoding := IIdTextEncoding.Default;
Replace:

        IOHandler.DefAnsiEncoding := IndyTextEncoding_Default;

System/IdGlobal.pas

2. Find:

        EnsureByteEncoding(LBytes, ASrcEncoding, ADestEncoding);
Replace:

        CheckByteEncoding(LBytes, ASrcEncoding, ADestEncoding); // see also http://www.devsuperpage.com/search/Articles.aspx?G=2&ArtID=28638

System\IdStackWindows.pas

3. Find:

        procedure GetSocketOption(ASocket: TIdStackSocketHandle; ALevel: TIdSocketOptionLevel;
          AOptName: TIdSocketOption; var AOptVal; var AOptLen: Integer); override;
        procedure SetSocketOption(ASocket: TIdStackSocketHandle; ALevel: TIdSocketOptionLevel;
          AOptName: TIdSocketOption; const AOptVal; const AOptLen: Integer); override;
Replace:

        procedure GetSocketOption(ASocket: TIdStackSocketHandle; ALevel: TIdSocketOptionLevel;
          AOptName: TIdSocketOption; out AOptVal: integer); override;
        procedure SetSocketOption(ASocket: TIdStackSocketHandle; ALevel: TIdSocketOptionLevel;
          AOptName: TIdSocketOption; AOptVal: integer); override;

4. Find:

        procedure TIdStackWindows.GetSocketOption(ASocket: TIdStackSocketHandle;
          ALevel: TIdSocketOptionLevel; AOptName: TIdSocketOption; var AOptVal;
          var AOptLen: Integer);
        begin
          CheckForSocketError(
            getsockopt(ASocket, ALevel, AOptName,
              {$IFNDEF HAS_PAnsiChar}
              // TODO: use TPtrWrapper here?
              {PAnsiChar}@AOptVal
              {$ELSE}
              PAnsiChar(@AOptVal)
              {$ENDIF},
              AOptLen
            )
          );
        end;
Replace:

        procedure TIdStackWindows.GetSocketOption(ASocket: TIdStackSocketHandle;
          ALevel: TIdSocketOptionLevel; AOptName: TIdSocketOption;
          out AOptVal: Integer);
        var LP : PAnsiChar;
          LLen : Integer;
          LBuf : Integer;
        begin
          LP := Addr(LBuf);
          LLen := SIZE_INTEGER;

          CheckForSocketError({WS}GetSockOpt(ASocket, ALevel, AOptName, LP, LLen));

          AOptVal := LBuf;
        end;

5. Find:

        procedure TIdStackWindows.SetSocketOption(ASocket: TIdStackSocketHandle;
          ALevel: TIdSocketOptionLevel; AOptName: TIdSocketOption; const AOptVal;
          const AOptLen: Integer);
        begin
          CheckForSocketError(
            setsockopt(ASocket, ALevel, Aoptname,
              {$IFNDEF HAS_PAnsiChar}
              // TODO: use TPtrWrapper here?
              {PAnsiChar}@AOptVal
              {$ELSE}
              PAnsiChar(@AOptVal)
              {$ENDIF},
              AOptLen
            )
          );
        end;
Replace:

        procedure TIdStackWindows.SetSocketOption(ASocket: TIdStackSocketHandle;
          ALevel: TIdSocketProtocol; AOptName: TIdSocketOption; AOptVal: Integer);
        begin
          CheckForSocketError(SetSockOpt(ASocket, ALevel, AOptName, PChar(@AOptVal), SIZE_INTEGER));
        end;

System\IdWinsock2.pas

6. Add after the first uses-block:

        type
          UINT32 = Cardinal;
          UINT8 = byte;

Protocols\IdMultipartFormData.pas

7. Find:
CheckByteEncoding(VBytes, CharsetToEncoding(FCharset), IndyTextEncoding_ASCII);
Replace:
CheckByteEncoding(LBytes, CharsetToEncoding(FCharset), IndyTextEncoding_ASCII);
Daniel Marschall
ViaThinkSoft Co-Founder