~ubuntu-branches/debian/lenny/fpc/lenny

« back to all changes in this revision

Viewing changes to fpcsrc/packages/extra/cdrom/cdromlin.inc

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-05-17 17:12:11 UTC
  • mfrom: (3.1.9 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080517171211-9qi33xhd9evfa0kg
Tags: 2.2.0-dfsg1-9
[ Torsten Werner ]
* Add Mazen Neifer to Uploaders field.

[ Mazen Neifer ]
* Moved FPC sources into a version dependent directory from /usr/share/fpcsrc
  to /usr/share/fpcsrc/${FPCVERSION}. This allow installing more than on FPC
  release.
* Fixed far call issue in compiler preventing building huge binearies.
  (closes: #477743)
* Updated building dependencies, recomennded and suggested packages.
* Moved fppkg to fp-utils as it is just a helper tool and is not required by
  compiler.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
uses
 
2
  baseunix,
 
3
  unix,
 
4
  lincd;
 
5
 
 
6
Function ReadCDTOC(Device : String; Var CDTOC : Array of TTocEntry) : Integer;
 
7
 
 
8
Var
 
9
  I,Drive    : Integer;
 
10
  tochdr   : Tcdrom_tochdr;
 
11
  tocentry : tcdrom_tocentry;
 
12
 
 
13
begin
 
14
  drive:=fpOpen(Device, Open_RDONLY or Open_NONBLOCK);
 
15
  if drive<0 then
 
16
    begin
 
17
    Result:=-1;
 
18
    Exit;
 
19
    end;
 
20
  if fpioctl(drive, CDROMREADTOCHDR, @tochdr)<>0 then
 
21
    begin
 
22
    Result:=-1;
 
23
    Exit;
 
24
    end;
 
25
  If (tochdr.cdth_trk1-tochdr.cdth_trk0)>High(CDToc) then
 
26
    Result:=-2
 
27
  else
 
28
    begin
 
29
    Result:=0;
 
30
    for i := tochdr.cdth_trk0 to tochdr.cdth_trk1 do
 
31
      begin
 
32
      tocentry.cdte_track := i;
 
33
      tocentry.cdte_format := CDROM_MSF;
 
34
      fpIOCtl(drive, CDROMREADTOCENTRY, @tocentry);
 
35
      // We should do some error checking here actually.
 
36
      With cdtoc[result] do
 
37
        begin
 
38
        min := tocentry.cdte_addr.msf.minute;
 
39
        sec := tocentry.cdte_addr.msf.second;
 
40
        frame := tocentry.cdte_addr.msf.frame;
 
41
        inc(frame,min*60*75);
 
42
        inc(frame,sec*75);
 
43
        end;
 
44
      Inc(result);
 
45
      end;
 
46
    tocentry.cdte_track := $AA;
 
47
    tocentry.cdte_format := CDROM_MSF;
 
48
    fpIOCtl(drive, CDROMREADTOCENTRY, @tocentry);
 
49
    With cdtoc[Result] do
 
50
      begin
 
51
      Min := tocentry.cdte_addr.msf.minute;
 
52
      sec := tocentry.cdte_addr.msf.second;
 
53
      frame := tocentry.cdte_addr.msf.frame;
 
54
      inc(frame, min*60*75);
 
55
      inc(frame, sec*75);
 
56
      end;
 
57
    end;
 
58
  fpClose(drive);
 
59
end;
 
60
 
 
61
{ ---------------------------------------------------------------------
 
62
    /etc/fstab scanning.
 
63
  ---------------------------------------------------------------------}
 
64
 
 
65
Function ExtractDevice(S : String) : String;
 
66
 
 
67
Var
 
68
  P,L : Integer;
 
69
 
 
70
begin
 
71
  Result:='';
 
72
  P:=Pos('#',S);
 
73
  If P<>0 then
 
74
    S:=Copy(S,1,P-1);
 
75
  If Length(S)>0 then
 
76
    begin
 
77
    P:=1;
 
78
    While (P<=Length(S)) and (S[P] in [#9,' ']) do
 
79
      Inc(p);
 
80
    L:=P;
 
81
    While (L<=Length(S)) and (Not (S[L] in [#9,' '])) do
 
82
      Inc(L);
 
83
    If L>P then
 
84
      Result:=Copy(S,P,L-P);
 
85
    end;
 
86
end;
 
87
 
 
88
Function TestFSTab(var Devices : Array of String) : Integer;
 
89
 
 
90
Var
 
91
  fstab : text;
 
92
  Line : String;
 
93
 
 
94
begin
 
95
  Result:=0;
 
96
  Assign(FSTab,'/etc/fstab');
 
97
  {$i-}
 
98
  Reset(fstab);
 
99
  {$i+}
 
100
  If IOResult=0 then
 
101
    begin
 
102
    While Not EOF(fstab) do
 
103
      begin
 
104
      ReadLn(fsTab,Line);
 
105
      Line:=ExtractDevice(Line);
 
106
      If IsCdDevice(Line) and (Result<=High(Devices)) then
 
107
        begin
 
108
        Devices[Result]:=Line;
 
109
        inc(Result);
 
110
        end;
 
111
      end;
 
112
    Close(fstab);
 
113
    end
 
114
  else
 
115
    Result:=-1;
 
116
end;
 
117
 
 
118
Function GetCDRomDevices(Var Devices : Array of string) : Integer;
 
119
 
 
120
Var
 
121
  S : String;
 
122
 
 
123
begin
 
124
  Result:=TestFSTab(Devices);
 
125
  If (Result<1) then
 
126
    begin
 
127
    S:=DetectCD;
 
128
    If (S<>'') then
 
129
      begin
 
130
      Devices[0]:=S;
 
131
      Result:=1;
 
132
      end;
 
133
    end
 
134
end;
 
135
 
 
136