iam-git / ArLan (public) (License: MIT) (since 2021-11-13) (hash sha1)
ArLan is an gopher client for Amiga flavour OSes (originally for AROS). Written in freepascal.

/misc.pas (9f5f66755008c22abc8d9d706be723bed977474b) (3123 bytes) (mode 100755) (type blob)

// here are placed functions taken from somewhere
// They have their own licenses!

unit misc;
{$mode objfpc}{$H+}
interface
uses
  Classes, sysutils, MUIClass.Dialog, // for SaveStringToFile
  ssockets; // for Fetch function

function SaveStringToFile(theString, filePath: AnsiString): boolean;
function Fetch(Addr: string; Port: Integer; What: string): string;

implementation

// Source: FreePascal wiki
// https://wiki.freepascal.org/File_Handling_In_Pascal
// What is license for it?
//
// SaveStringToFile: function to store a string of text into a diskfile.
//   If the function result equals true, the string was written ok.
//   If not then there was some kind of error.
function SaveStringToFile(theString, filePath: AnsiString): boolean;
var
  fsOut: TFileStream;
begin
  // By default assume the writing will fail.
  result := false;

  // Write the given string to a file, catching potential errors in the process.
  try
    fsOut := TFileStream.Create(filePath, fmCreate);
    fsOut.Write(theString[1], length(theString));
    fsOut.Free;

    // At his point it is known that the writing went ok.
    result := true

  except
    on E:Exception do
      ShowMessage('String could not be written. Details: '+ E.ClassName + ': '+ E.Message);
  end
end;


// Fetch function is taken from "Little Gopher Client"'s code.
// http://runtimeterror.com/tools/gopher/
// Its license:
{
Little Gopher Client
Copyright (C) 2016 Kostas Michalopoulos

This software is provided 'as-is', without any express or implied
warranty.  In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not
   claim that you wrote the original software. If you use this software
   in a product, an acknowledgment in the product documentation would be
   appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
   misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.

Kostas Michalopoulos <badsector@runtimeterror.com>
}
function Fetch(Addr: string; Port: Integer; What: string): string;
var
  Conn: TInetSocket = nil;
  Buff: array [0..65535] of AnsiChar;
  Total: array of AnsiChar;
  Got, AllGot: LongInt;
  I: Integer;
begin
  try
    Conn:=TInetSocket.Create(Addr, Port);
    What := What + #13#10;
    Conn.Write((@What[1])^, Length(What));
    AllGot:=0;
    while True do begin
      Got:=Conn.Read(Buff, SizeOf(Buff));
      if Got < 1 then Break;
      SetLength(Total, Length(Total) + Got);
      Move((@Buff[0])^, (@Total[AllGot])^, Got);
      Inc(AllGot, Got);
    end;
    SetLength(Result, AllGot);
    for I:=1 to AllGot do Result[I]:=Total[I - 1];
  except
    ShowMessage('Failed to get data: ' + Exception(ExceptObject).Message, 'Fetch error');
    Result:='';
  end;
  FreeAndNil(Conn);
end;

end.

Mode Type Size Ref File
100755 blob 541 4b340345c4ae30c28b68b5d45dd255e6c6531ed2 ReadMe
100755 blob 17800 0978a58982f582f25a7ecf07180e5e291bc5f8e3 arlan.pas
100755 blob 2379 6c8ad90e7583d80c442f3e6d2abbfeeba6ce016a doublelinked.pas
100755 blob 3123 9f5f66755008c22abc8d9d706be723bed977474b misc.pas
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/iam-git/ArLan

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/iam-git/ArLan

Clone this repository using git:
git clone git://git.rocketgit.com/user/iam-git/ArLan

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main