File: appstream.pas

package info (click to toggle)
licenserecon 12.0
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 372 kB
  • sloc: pascal: 1,375; makefile: 33; perl: 31; xml: 9; sh: 2
file content (50 lines) | stat: -rw-r--r-- 1,089 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Reconcile DEP-5 debian/copyright to licensecheck
//
// Copyright : 2024 P Blackman
// License   : BSD-2-clause
//
// Extract the license for an appstream metadata file
//  (workaround for https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1051840 )

unit appstream;
{$mode delphi}

interface

function GetMetadataLicense (Fname : AnsiString) : String;


implementation uses StrUtils, support;

function GetMetadataLicense (Fname : AnsiString) : String;

const Maxlines : Integer = 100;
var Lines,
    lpos : Integer;
    Line : AnsiString;
    afile : Text;

begin
    result := '';
    Lines := 0;
    if OpenFile (FName, afile) then
    begin
        while not EOF (afile) and (Lines < MaxLines) do
        begin
            Readln (afile, Line);
            lpos := NPos ('<metadata_license>', Line, 1);

            if lpos > 0 then
            begin
                Result := ExtractSubstr(Line, lpos, ['<']);

                Lines := MaxLines // terminate loop
            end
            else
                inc (Lines);
        end;
        Close (afile);
     end;
end;

end.