Browse Source

--- Merging r15214 into '.':
U packages/gdbint/src/gdbint.pp
--- Merging r15127 into '.':
U rtl/objpas/classes/streams.inc
--- Merging r15215 into '.':
U packages/fcl-base/src/fptemplate.pp
--- Merging r15323 into '.':
U packages/fcl-db/src/base/bufdataset.pas
--- Merging r15509 into '.':
U rtl/objpas/sysutils/sysformt.inc
A tests/webtbs/tw16787.pp
--- Merging r15515 into '.':
U rtl/inc/heap.inc
--- Merging r15528 into '.':
U packages/fcl-web/src/base/webpage.pp
U packages/fcl-web/src/base/fphtml.pp
--- Merging r15543 into '.':
U rtl/inc/genmath.inc
A tests/webtbs/tw16863.pp
--- Merging r15545 into '.':
U rtl/inc/sstrings.inc
--- Merging r15565 into '.':
U packages/fcl-web/src/base/fphttp.pp
U packages/fcl-web/src/base/custweb.pp
--- Merging r15566 into '.':
U packages/fcl-web/src/base/websession.pp
--- Merging r15567 into '.':
U packages/fcl-web/src/base/custfcgi.pp
--- Merging r15568 into '.':
U packages/fcl-web/src/webdata/fpwebdata.pp
--- Merging r15569 into '.':
G packages/fcl-web/src/webdata/fpwebdata.pp
--- Merging r15571 into '.':
U packages/fcl-web/src/webdata/sqldbwebdata.pp
--- Merging r15572 into '.':
U packages/fcl-web/src/webdata/extjsjson.pp
--- Merging r15577 into '.':
G packages/fcl-web/src/webdata/extjsjson.pp
--- Merging r15580 into '.':
U packages/pthreads/src/pthrsnos.inc
--- Merging r15586 into '.':
U packages/fcl-base/src/unix/eventlog.inc
U packages/fcl-base/src/eventlog.pp
U packages/fcl-base/src/dummy/eventlog.inc
U packages/fcl-base/src/win/eventlog.inc
--- Merging r15587 into '.':
U packages/fcl-base/src/os2/eventlog.inc
--- Merging r15588 into '.':
U packages/fcl-extra/src/daemonapp.pp
U packages/fcl-extra/src/unix/daemonapp.inc
U packages/fcl-extra/src/win/daemonapp.inc
--- Merging r15610 into '.':
U packages/openal/examples/Makefile.fpc
C packages/openal/examples/Makefile
A packages/openal/examples/wavopenal.pas
--- Merging r15611 into '.':
U packages/openal/src/openal.pas
--- Merging r15615 into '.':
G packages/fcl-web/src/base/custfcgi.pp
--- Merging r15888 into '.':
U packages/gdbint/src/gdbcon.pp
--- Merging r15892 into '.':
U packages/gdbint/gen-gdblib-inc.sh
Summary of conflicts:
Text conflicts: 1

# revisions: 15214,15127,15215,15323,15509,15515,15528,15543,15545,15565,15566,15567,15568,15569,15571,15572,15577,15580,15586,15587,15588,15610,15611,15615,15779,15888,15892
------------------------------------------------------------------------
r15214 | pierre | 2010-05-03 16:29:19 +0200 (Mon, 03 May 2010) | 1 line
Changed paths:
M /trunk/packages/gdbint/src/gdbint.pp

* add batch_flag to avoid libgdb.a/main.o integration
------------------------------------------------------------------------
------------------------------------------------------------------------
r15127 | paul | 2010-04-10 19:50:29 +0200 (Sat, 10 Apr 2010) | 3 lines
Changed paths:
M /trunk/rtl/objpas/classes/streams.inc

rtl: minor changes for TStreamAdapter:
- return STG_E_INVALIDPOINTER instead of E_INVLIDARG for Read,Write as msdn requires
- return STG_E_INVALIDFUNCTION instead of E_INVLIDARG for Seek as msdn requires
------------------------------------------------------------------------
------------------------------------------------------------------------
r15215 | joost | 2010-05-03 16:30:11 +0200 (Mon, 03 May 2010) | 1 line
Changed paths:
M /trunk/packages/fcl-base/src/fptemplate.pp

* Added ability to list values by index instead of name
------------------------------------------------------------------------
------------------------------------------------------------------------
r15323 | joost | 2010-05-25 21:21:25 +0200 (Tue, 25 May 2010) | 1 line
Changed paths:
M /trunk/packages/fcl-db/src/base/bufdataset.pas

* Use the datasets the filter in TBufDataset.Locate
------------------------------------------------------------------------
------------------------------------------------------------------------
r15509 | jonas | 2010-07-02 21:59:58 +0200 (Fri, 02 Jul 2010) | 2 lines
Changed paths:
M /trunk/rtl/objpas/sysutils/sysformt.inc
A /trunk/tests/webtbs/tw16787.pp

* also support variants for %s in sysutils.format (mantis #16787)

------------------------------------------------------------------------
------------------------------------------------------------------------
r15515 | jonas | 2010-07-03 14:45:55 +0200 (Sat, 03 Jul 2010) | 6 lines
Changed paths:
M /trunk/rtl/inc/heap.inc

* prefetch heap status in sysfreemem
* re-layouted code in sysfreemem_fixed so that the most likely case is on
the fall-through path
* moved dec(poc^.used) in sysfreemem_fixed earlier so that it doesn't
cause a dependency stall for the "if poc^.used<=0" test later

------------------------------------------------------------------------
------------------------------------------------------------------------
r15528 | joost | 2010-07-05 15:59:20 +0200 (Mon, 05 Jul 2010) | 1 line
Changed paths:
M /trunk/packages/fcl-web/src/base/fphtml.pp
M /trunk/packages/fcl-web/src/base/webpage.pp

* Added ALoaded parameter to MessageBox
------------------------------------------------------------------------
------------------------------------------------------------------------
r15543 | jonas | 2010-07-10 14:15:13 +0200 (Sat, 10 Jul 2010) | 2 lines
Changed paths:
M /trunk/rtl/inc/genmath.inc
A /trunk/tests/webtbs/tw16863.pp

* fixed real48 to double conversion for 0.0 (patch by "jeng", mantis #16863)

------------------------------------------------------------------------
------------------------------------------------------------------------
r15545 | daniel | 2010-07-10 17:38:45 +0200 (Sat, 10 Jul 2010) | 3 lines
Changed paths:
M /trunk/rtl/inc/sstrings.inc

* Fix/improve the value of "code" that is returned for val(string,enum,code) in
case the string is not recognized.

------------------------------------------------------------------------
------------------------------------------------------------------------
r15565 | michael | 2010-07-14 16:26:09 +0200 (Wed, 14 Jul 2010) | 1 line
Changed paths:
M /trunk/packages/fcl-web/src/base/custweb.pp
M /trunk/packages/fcl-web/src/base/fphttp.pp

* Added support for modules that do not have a stream associated with them; they are created with CreateNew
------------------------------------------------------------------------
------------------------------------------------------------------------
r15566 | michael | 2010-07-14 16:28:41 +0200 (Wed, 14 Jul 2010) | 1 line
Changed paths:
M /trunk/packages/fcl-web/src/base/websession.pp

* Include trailing path delimiter. Check if session exists; Added some debug statements (in CGIDebug conditional)
------------------------------------------------------------------------
------------------------------------------------------------------------
r15567 | michael | 2010-07-14 16:31:50 +0200 (Wed, 14 Jul 2010) | 1 line
Changed paths:
M /trunk/packages/fcl-web/src/base/custfcgi.pp

* Implemented ProtocolOptions and OnUnknownRecord to handle unknown FastCGI records
------------------------------------------------------------------------
------------------------------------------------------------------------
r15568 | michael | 2010-07-14 16:33:41 +0200 (Wed, 14 Jul 2010) | 1 line
Changed paths:
M /trunk/packages/fcl-web/src/webdata/fpwebdata.pp

* Actually implemented Options (readonly, disable edit/delete/insert
------------------------------------------------------------------------
------------------------------------------------------------------------
r15569 | michael | 2010-07-14 16:34:33 +0200 (Wed, 14 Jul 2010) | 1 line
Changed paths:
M /trunk/packages/fcl-web/src/webdata/fpwebdata.pp

Disabled debug define
------------------------------------------------------------------------
------------------------------------------------------------------------
r15571 | michael | 2010-07-14 16:35:36 +0200 (Wed, 14 Jul 2010) | 1 line
Changed paths:
M /trunk/packages/fcl-web/src/webdata/sqldbwebdata.pp

* Implemented OnParamValue event
------------------------------------------------------------------------
------------------------------------------------------------------------
r15572 | michael | 2010-07-14 16:36:30 +0200 (Wed, 14 Jul 2010) | 1 line
Changed paths:
M /trunk/packages/fcl-web/src/webdata/extjsjson.pp

* Always send date/time in fixed format, send used format as well in metadata
------------------------------------------------------------------------
------------------------------------------------------------------------
r15577 | michael | 2010-07-15 10:24:49 +0200 (Thu, 15 Jul 2010) | 1 line
Changed paths:
M /trunk/packages/fcl-web/src/webdata/extjsjson.pp

* Removed debug conditional
------------------------------------------------------------------------
------------------------------------------------------------------------
r15580 | jonas | 2010-07-15 14:02:48 +0200 (Thu, 15 Jul 2010) | 1 line
Changed paths:
M /trunk/packages/pthreads/src/pthrsnos.inc

* fixed pthread_create signature
------------------------------------------------------------------------
------------------------------------------------------------------------
r15586 | joost | 2010-07-16 18:14:29 +0200 (Fri, 16 Jul 2010) | 1 line
Changed paths:
M /trunk/packages/fcl-base/src/dummy/eventlog.inc
M /trunk/packages/fcl-base/src/eventlog.pp
M /trunk/packages/fcl-base/src/unix/eventlog.inc
M /trunk/packages/fcl-base/src/win/eventlog.inc

* Added the ability to un-register the eventlog message-file
------------------------------------------------------------------------
------------------------------------------------------------------------
r15587 | joost | 2010-07-16 18:16:08 +0200 (Fri, 16 Jul 2010) | 1 line
Changed paths:
M /trunk/packages/fcl-base/src/os2/eventlog.inc

* Forgot to commit OS/2 file in r15586
------------------------------------------------------------------------
------------------------------------------------------------------------
r15588 | joost | 2010-07-16 18:35:47 +0200 (Fri, 16 Jul 2010) | 6 lines
Changed paths:
M /trunk/packages/fcl-extra/src/daemonapp.pp
M /trunk/packages/fcl-extra/src/unix/daemonapp.inc
M /trunk/packages/fcl-extra/src/win/daemonapp.inc

* Show help-message with default actions when no action is given, IsConsole
is true and there is no OnRun event handler
* Use TCustumApplication.Log method for logging
* Because the logger was freed before exceptions were shown, exceptions were
never logged. Now they are.

------------------------------------------------------------------------
------------------------------------------------------------------------
r15610 | jonas | 2010-07-19 16:15:23 +0200 (Mon, 19 Jul 2010) | 4 lines
Changed paths:
M /trunk/packages/openal/examples/Makefile
M /trunk/packages/openal/examples/Makefile.fpc
A /trunk/packages/openal/examples/wavopenal.pas

+ wavopenal example to play a wav file by Dmitry Boyarintsev (mantis #16961)
* only compile madopenal.pas for platforms for which the "mad" package
gets compiled

------------------------------------------------------------------------
------------------------------------------------------------------------
r15611 | jonas | 2010-07-19 16:16:42 +0200 (Mon, 19 Jul 2010) | 3 lines
Changed paths:
M /trunk/packages/openal/src/openal.pas

* use the framework version of OpenAL for Mac OS X (based on patch by
Dmitry Boyarintsev, mantis #16961)

------------------------------------------------------------------------
------------------------------------------------------------------------
r15615 | joost | 2010-07-20 11:41:26 +0200 (Tue, 20 Jul 2010) | 1 line
Changed paths:
M /trunk/packages/fcl-web/src/base/custfcgi.pp

* Added TCustomFCgiApplication.Address property to change listen-ip-address
------------------------------------------------------------------------
------------------------------------------------------------------------
r15779 | marco | 2010-08-11 13:05:59 +0200 (Wed, 11 Aug 2010) | 2 lines
Changed paths:
M /trunk/rtl/win/wininc/struct.inc

* textmetricA variants, delphi compat.

------------------------------------------------------------------------
------------------------------------------------------------------------
r15888 | pierre | 2010-08-24 15:15:18 +0200 (Tue, 24 Aug 2010) | 1 line
Changed paths:
M /trunk/packages/gdbint/src/gdbcon.pp

Use ptrint to cast a pointer to an integer
------------------------------------------------------------------------
------------------------------------------------------------------------
r15892 | pierre | 2010-08-24 16:24:17 +0200 (Tue, 24 Aug 2010) | 1 line
Changed paths:
M /trunk/packages/gdbint/gen-gdblib-inc.sh

* Try to get script to work for freebsd
------------------------------------------------------------------------

git-svn-id: branches/fixes_2_4@16393 -

marco 14 years ago
parent
commit
188a88be99
35 changed files with 1056 additions and 347 deletions
  1. 3 0
      .gitattributes
  2. 6 0
      packages/fcl-base/src/dummy/eventlog.inc
  3. 1 0
      packages/fcl-base/src/eventlog.pp
  4. 28 0
      packages/fcl-base/src/fptemplate.pp
  5. 6 0
      packages/fcl-base/src/os2/eventlog.inc
  6. 6 0
      packages/fcl-base/src/unix/eventlog.inc
  7. 14 3
      packages/fcl-base/src/win/eventlog.inc
  8. 21 7
      packages/fcl-db/src/base/bufdataset.pas
  9. 73 43
      packages/fcl-extra/src/daemonapp.pp
  10. 1 1
      packages/fcl-extra/src/unix/daemonapp.inc
  11. 7 8
      packages/fcl-extra/src/win/daemonapp.inc
  12. 77 17
      packages/fcl-web/src/base/custfcgi.pp
  13. 4 1
      packages/fcl-web/src/base/custweb.pp
  14. 11 9
      packages/fcl-web/src/base/fphtml.pp
  15. 7 4
      packages/fcl-web/src/base/fphttp.pp
  16. 2 2
      packages/fcl-web/src/base/webpage.pp
  17. 14 5
      packages/fcl-web/src/base/websession.pp
  18. 63 1
      packages/fcl-web/src/webdata/extjsjson.pp
  19. 23 0
      packages/fcl-web/src/webdata/fpwebdata.pp
  20. 30 11
      packages/fcl-web/src/webdata/sqldbwebdata.pp
  21. 19 3
      packages/gdbint/gen-gdblib-inc.sh
  22. 1 1
      packages/gdbint/src/gdbcon.pp
  23. 14 0
      packages/gdbint/src/gdbint.pp
  24. 114 148
      packages/openal/examples/Makefile
  25. 6 2
      packages/openal/examples/Makefile.fpc
  26. 330 0
      packages/openal/examples/wavopenal.pas
  27. 4 2
      packages/openal/src/openal.pas
  28. 1 2
      packages/pthreads/src/pthrsnos.inc
  29. 7 0
      rtl/inc/genmath.inc
  30. 33 24
      rtl/inc/heap.inc
  31. 42 14
      rtl/inc/sstrings.inc
  32. 41 37
      rtl/objpas/classes/streams.inc
  33. 5 2
      rtl/objpas/sysutils/sysformt.inc
  34. 34 0
      tests/webtbs/tw16787.pp
  35. 8 0
      tests/webtbs/tw16863.pp

+ 3 - 0
.gitattributes

@@ -4097,6 +4097,7 @@ packages/openal/examples/Makefile svneol=native#text/plain
 packages/openal/examples/Makefile.fpc svneol=native#text/plain
 packages/openal/examples/Makefile.fpc svneol=native#text/plain
 packages/openal/examples/captureplaybackopenal.pas svneol=native#text/plain
 packages/openal/examples/captureplaybackopenal.pas svneol=native#text/plain
 packages/openal/examples/madopenal.pas svneol=native#text/plain
 packages/openal/examples/madopenal.pas svneol=native#text/plain
+packages/openal/examples/wavopenal.pas svneol=native#text/plain
 packages/openal/fpmake.pp svneol=native#text/plain
 packages/openal/fpmake.pp svneol=native#text/plain
 packages/openal/src/alch.inc svneol=native#text/plain
 packages/openal/src/alch.inc svneol=native#text/plain
 packages/openal/src/alexth.inc svneol=native#text/plain
 packages/openal/src/alexth.inc svneol=native#text/plain
@@ -9658,7 +9659,9 @@ tests/webtbs/tw1634.pp svneol=native#text/plain
 tests/webtbs/tw16377.pp svneol=native#text/plain
 tests/webtbs/tw16377.pp svneol=native#text/plain
 tests/webtbs/tw1658.pp svneol=native#text/plain
 tests/webtbs/tw1658.pp svneol=native#text/plain
 tests/webtbs/tw1677.pp svneol=native#text/plain
 tests/webtbs/tw1677.pp svneol=native#text/plain
+tests/webtbs/tw16787.pp svneol=native#text/plain
 tests/webtbs/tw1681.pp svneol=native#text/plain
 tests/webtbs/tw1681.pp svneol=native#text/plain
+tests/webtbs/tw16863.pp svneol=native#text/plain
 tests/webtbs/tw1696.pp svneol=native#text/plain
 tests/webtbs/tw1696.pp svneol=native#text/plain
 tests/webtbs/tw1699.pp svneol=native#text/plain
 tests/webtbs/tw1699.pp svneol=native#text/plain
 tests/webtbs/tw1709.pp svneol=native#text/plain
 tests/webtbs/tw1709.pp svneol=native#text/plain

+ 6 - 0
packages/fcl-base/src/dummy/eventlog.inc

@@ -44,6 +44,12 @@ begin
   Result:=True;
   Result:=True;
 end;
 end;
 
 
+Function TEventLog.UnRegisterMessageFile : Boolean;
+
+begin
+  Result:=True;
+end;
+
 function TEventLog.MapTypeToCategory(EventType: TEventType): Word;
 function TEventLog.MapTypeToCategory(EventType: TEventType): Word;
 begin
 begin
   Result:=0;
   Result:=0;

+ 1 - 0
packages/fcl-base/src/eventlog.pp

@@ -70,6 +70,7 @@ Type
     Destructor Destroy; override;
     Destructor Destroy; override;
     Function EventTypeToString(E : TEventType) : String;
     Function EventTypeToString(E : TEventType) : String;
     Function RegisterMessageFile(AFileName : String) : Boolean; virtual;
     Function RegisterMessageFile(AFileName : String) : Boolean; virtual;
+    Function UnRegisterMessageFile : Boolean; virtual;
     Procedure Log (EventType : TEventType; Msg : String); {$ifndef fpc }Overload;{$endif}
     Procedure Log (EventType : TEventType; Msg : String); {$ifndef fpc }Overload;{$endif}
     Procedure Log (EventType : TEventType; Fmt : String; Args : Array of const); {$ifndef fpc }Overload;{$endif}
     Procedure Log (EventType : TEventType; Fmt : String; Args : Array of const); {$ifndef fpc }Overload;{$endif}
     Procedure Log (Msg : String); {$ifndef fpc }Overload;{$endif}
     Procedure Log (Msg : String); {$ifndef fpc }Overload;{$endif}

+ 28 - 0
packages/fcl-base/src/fptemplate.pp

@@ -61,7 +61,10 @@ Type
     FOnGetParam: TGetParamEvent;                           //Event handler to use for templates containing simple tags only (ex: {Name})
     FOnGetParam: TGetParamEvent;                           //Event handler to use for templates containing simple tags only (ex: {Name})
     FOnReplaceTag: TReplaceTagEvent;                       //Event handler to use for templates containing tags with parameters (ex: <#TagName paramname1="paramvalue1" paramname2="paramvalue2">)
     FOnReplaceTag: TReplaceTagEvent;                       //Event handler to use for templates containing tags with parameters (ex: <#TagName paramname1="paramvalue1" paramname2="paramvalue2">)
     function GetDelimiter(Index: integer): TParseDelimiter;
     function GetDelimiter(Index: integer): TParseDelimiter;
+    function GetNameByIndex(index : Integer): String;
     function GetValue(Key : String): String;
     function GetValue(Key : String): String;
+    function GetValueByIndex(index : Integer): String;
+    function GetValueCount: Integer;
     procedure SetDelimiter(Index: integer; const AValue: TParseDelimiter);
     procedure SetDelimiter(Index: integer; const AValue: TParseDelimiter);
     procedure SetValue(Key : String; const AValue: String);
     procedure SetValue(Key : String; const AValue: String);
     Function IntParseString(Src : String) : String;
     Function IntParseString(Src : String) : String;
@@ -83,6 +86,9 @@ Type
     Property ParamEndDelimiter : TParseDelimiter Index 4 Read GetDelimiter Write SetDelimiter;
     Property ParamEndDelimiter : TParseDelimiter Index 4 Read GetDelimiter Write SetDelimiter;
     Property ParamValueSeparator : TParseDelimiter Index 5 Read GetDelimiter Write SetDelimiter;
     Property ParamValueSeparator : TParseDelimiter Index 5 Read GetDelimiter Write SetDelimiter;
     Property Values[Key : String] : String Read GetValue Write SetValue; // Contains static values.                          //used only when AllowTagParams = false
     Property Values[Key : String] : String Read GetValue Write SetValue; // Contains static values.                          //used only when AllowTagParams = false
+    Property ValuesByIndex[index : Integer] : String Read GetValueByIndex; // Contains static values.                        //used only when AllowTagParams = false
+    Property NamesByIndex[index : Integer] : String Read GetNameByIndex;  // Contains static values.                        //used only when AllowTagParams = false
+    Property ValueCount: Integer Read GetValueCount;                                                                         //used only when AllowTagParams = false
     Property Recursive : Boolean Read FRecursive Write FRecursive;                                                           //used only when AllowTagParams = false
     Property Recursive : Boolean Read FRecursive Write FRecursive;                                                           //used only when AllowTagParams = false
     Property AllowTagParams : Boolean Read FAllowTagParams Write FAllowTagParams;
     Property AllowTagParams : Boolean Read FAllowTagParams Write FAllowTagParams;
   end;
   end;
@@ -178,6 +184,21 @@ begin
     end;
     end;
 end;
 end;
 
 
+function TTemplateParser.GetValueByIndex(index : Integer): String;
+begin
+  Result:='';
+  If Assigned(FValues) then
+    Result:=TStringItem(FValues.Objects[index]).Value;
+end;
+
+function TTemplateParser.GetValueCount: Integer;
+begin
+  if assigned(FValues) then
+    result := FValues.Count
+  else
+    result := 0;
+end;
+
 function TTemplateParser.GetDelimiter(Index: integer): TParseDelimiter;
 function TTemplateParser.GetDelimiter(Index: integer): TParseDelimiter;
 begin
 begin
   case Index of
   case Index of
@@ -190,6 +211,13 @@ begin
   end;
   end;
 end;
 end;
 
 
+function TTemplateParser.GetNameByIndex(index : Integer): String;
+begin
+  Result:='';
+  If Assigned(FValues) then
+    Result:=FValues.ValueFromIndex[index];
+end;
+
 procedure TTemplateParser.SetDelimiter(Index: integer;
 procedure TTemplateParser.SetDelimiter(Index: integer;
   const AValue: TParseDelimiter);
   const AValue: TParseDelimiter);
 begin
 begin

+ 6 - 0
packages/fcl-base/src/os2/eventlog.inc

@@ -228,6 +228,12 @@ begin
   Result:=True;
   Result:=True;
 end;
 end;
 
 
+Function TEventLog.UnRegisterMessageFile : Boolean;
+
+begin
+  Result:=True;
+end;
+
 function TEventLog.MapTypeToCategory(EventType: TEventType): Word;
 function TEventLog.MapTypeToCategory(EventType: TEventType): Word;
 begin
 begin
   Result:=0;
   Result:=0;

+ 6 - 0
packages/fcl-base/src/unix/eventlog.inc

@@ -95,6 +95,12 @@ begin
   Result:=True;
   Result:=True;
 end;
 end;
 
 
+Function TEventLog.UnRegisterMessageFile : Boolean;
+
+begin
+  Result:=True;
+end;
+
 function TEventLog.MapTypeToCategory(EventType: TEventType): Word;
 function TEventLog.MapTypeToCategory(EventType: TEventType): Word;
 begin
 begin
   Result:=0;
   Result:=0;

+ 14 - 3
packages/fcl-base/src/win/eventlog.inc

@@ -15,6 +15,9 @@
 
 
 uses windows;
 uses windows;
 
 
+const
+  SKeyEventLog = 'SYSTEM\CurrentControlSet\Services\EventLog\Application\%s';
+
 Function TEventLog.DefaultFileName : String;
 Function TEventLog.DefaultFileName : String;
 
 
 begin
 begin
@@ -70,7 +73,6 @@ end;
 Function TEventLog.RegisterMessageFile(AFileName : String) : Boolean;
 Function TEventLog.RegisterMessageFile(AFileName : String) : Boolean;
 
 
 Const
 Const
-  SKeyEventLog = 'SYSTEM\CurrentControlSet\Services\EventLog\Application\%s';
   SKeyCategoryCount       = 'CategoryCount';
   SKeyCategoryCount       = 'CategoryCount';
   SKeyEventMessageFile    = 'EventMessageFile';
   SKeyEventMessageFile    = 'EventMessageFile';
   SKeyCategoryMessageFile = 'CategoryMessageFile';
   SKeyCategoryMessageFile = 'CategoryMessageFile';
@@ -85,8 +87,6 @@ Var
 begin
 begin
   SecurityAttributes:=nil;
   SecurityAttributes:=nil;
   CheckIdentification;
   CheckIdentification;
-  If AFileName='' then
-    AFileName:=ParamStr(0);
   ELKey:=Format(SKeyEventLog,[IDentification]);
   ELKey:=Format(SKeyEventLog,[IDentification]);
   Result:=RegCreateKeyExA(HKEY_LOCAL_MACHINE,
   Result:=RegCreateKeyExA(HKEY_LOCAL_MACHINE,
                           PChar(ELKey),0,'',
                           PChar(ELKey),0,'',
@@ -96,6 +96,8 @@ begin
                           pdword(@Disposition))=ERROR_SUCCESS;
                           pdword(@Disposition))=ERROR_SUCCESS;
   If Result then
   If Result then
     begin
     begin
+      If AFileName='' then
+        AFileName:=ParamStr(0);
       Value:=4;
       Value:=4;
       Result:=Result and (RegSetValueExA(Handle,PChar(SKeyCategoryCount),0,REG_DWORD,@Value,sizeof(DWORD))=ERROR_SUCCESS);
       Result:=Result and (RegSetValueExA(Handle,PChar(SKeyCategoryCount),0,REG_DWORD,@Value,sizeof(DWORD))=ERROR_SUCCESS);
       Value:=7;
       Value:=7;
@@ -105,6 +107,15 @@ begin
     end;
     end;
 end;
 end;
 
 
+Function TEventLog.UnRegisterMessageFile : Boolean;
+
+Var
+  ELKey : String;
+begin
+  ELKey:=Format(SKeyEventLog,[IDentification]);
+  Result:=RegDeleteKeyA(HKEY_LOCAL_MACHINE,pchar(ELKey));
+end;
+
 function TEventLog.MapTypeToCategory(EventType: TEventType): Word;
 function TEventLog.MapTypeToCategory(EventType: TEventType): Word;
 begin
 begin
   If (EventType=ETCustom) then
   If (EventType=ETCustom) then

+ 21 - 7
packages/fcl-db/src/base/bufdataset.pas

@@ -446,7 +446,7 @@ type
     procedure SetMaxIndexesCount(const AValue: Integer);
     procedure SetMaxIndexesCount(const AValue: Integer);
     procedure SetPacketRecords(aValue : integer);
     procedure SetPacketRecords(aValue : integer);
     function  IntAllocRecordBuffer: PChar;
     function  IntAllocRecordBuffer: PChar;
-    procedure DoFilterRecord(var Acceptable: Boolean);
+    procedure DoFilterRecord(out Acceptable: Boolean);
     procedure ParseFilter(const AFilter: string);
     procedure ParseFilter(const AFilter: string);
     procedure IntLoadFielddefsFromFile;
     procedure IntLoadFielddefsFromFile;
     procedure IntLoadRecordsFromFile;
     procedure IntLoadRecordsFromFile;
@@ -2796,7 +2796,7 @@ begin
     FMaxIndexesCount := FIndexesCount;
     FMaxIndexesCount := FIndexesCount;
 end;
 end;
 
 
-procedure TCustomBufDataset.DoFilterRecord(var Acceptable: Boolean);
+procedure TCustomBufDataset.DoFilterRecord(out Acceptable: Boolean);
 begin
 begin
   Acceptable := true;
   Acceptable := true;
   // check user filter
   // check user filter
@@ -2935,7 +2935,7 @@ var CurrLinkItem    : PBufRecLinkItem;
     FieldNr         : Integer;
     FieldNr         : Integer;
     StoreDSState    : TDataSetState;
     StoreDSState    : TDataSetState;
     FilterBuffer    : PChar;
     FilterBuffer    : PChar;
-
+    FiltAcceptable  : boolean;
 
 
 begin
 begin
   Result := False;
   Result := False;
@@ -2967,21 +2967,35 @@ begin
   CurrLinkItem := (FCurrentIndex as TDoubleLinkedBufIndex).FFirstRecBuf;
   CurrLinkItem := (FCurrentIndex as TDoubleLinkedBufIndex).FFirstRecBuf;
   FilterBuffer:=IntAllocRecordBuffer;
   FilterBuffer:=IntAllocRecordBuffer;
   move((FCurrentIndex as TDoubleLinkedBufIndex).FLastRecBuf^,FilterBuffer^,FRecordsize+sizeof(TBufRecLinkItem)*FMaxIndexesCount);
   move((FCurrentIndex as TDoubleLinkedBufIndex).FLastRecBuf^,FilterBuffer^,FRecordsize+sizeof(TBufRecLinkItem)*FMaxIndexesCount);
-  RestoreState(StoreDSState);
 
 
   // Iterate through the records until a match is found
   // Iterate through the records until a match is found
   while (CurrLinkItem <> (FCurrentIndex as TDoubleLinkedBufIndex).FLastRecBuf) do
   while (CurrLinkItem <> (FCurrentIndex as TDoubleLinkedBufIndex).FLastRecBuf) do
     begin
     begin
     if (IndexCompareRecords(FilterBuffer,CurrLinkItem,DBCompareStruct) = 0) then
     if (IndexCompareRecords(FilterBuffer,CurrLinkItem,DBCompareStruct) = 0) then
       begin
       begin
-      Result := True;
-      break;
+      if Filtered then
+        begin
+        FFilterBuffer:=pointer(CurrLinkItem)+(sizeof(TBufRecLinkItem)*MaxIndexesCount);
+        // The dataset-state is still dsFilter at this point, so we don't have to set it.
+        DoFilterRecord(FiltAcceptable);
+        if FiltAcceptable then
+          begin
+          Result := True;
+          break;
+          end;
+        end
+      else
+        begin
+        Result := True;
+        break;
+        end;
       end;
       end;
     CurrLinkItem := CurrLinkItem[(FCurrentIndex as TDoubleLinkedBufIndex).IndNr].next;
     CurrLinkItem := CurrLinkItem[(FCurrentIndex as TDoubleLinkedBufIndex).IndNr].next;
     if CurrLinkItem = (FCurrentIndex as TDoubleLinkedBufIndex).FLastRecBuf then
     if CurrLinkItem = (FCurrentIndex as TDoubleLinkedBufIndex).FLastRecBuf then
       getnextpacket;
       getnextpacket;
     end;
     end;
-    
+
+  RestoreState(StoreDSState);
   FreeRecordBuffer(FilterBuffer);
   FreeRecordBuffer(FilterBuffer);
 
 
   // If a match is found, jump to the found record
   // If a match is found, jump to the found record

+ 73 - 43
packages/fcl-extra/src/daemonapp.pp

@@ -329,7 +329,7 @@ Type
   private
   private
     FGUIHandle: THandle;
     FGUIHandle: THandle;
     FGUIMainLoop: TGuiLoopEvent;
     FGUIMainLoop: TGuiLoopEvent;
-    FLogger: TEventLog;
+    FEventLog: TEventLog;
     FMapper : TCustomDaemonMapper;
     FMapper : TCustomDaemonMapper;
     FOnRun: TNotifyEvent;
     FOnRun: TNotifyEvent;
     FRunMode: TDaemonRunMode;
     FRunMode: TDaemonRunMode;
@@ -357,20 +357,22 @@ Type
     Procedure CreateServiceMapper(Var AMapper : TCustomDaemonMapper); virtual;
     Procedure CreateServiceMapper(Var AMapper : TCustomDaemonMapper); virtual;
     Procedure CreateDaemonInstance(Var ADaemon : TCustomDaemon; DaemonDef : TDaemonDef); virtual;
     Procedure CreateDaemonInstance(Var ADaemon : TCustomDaemon; DaemonDef : TDaemonDef); virtual;
     Procedure RemoveController(AController : TDaemonController); virtual;
     Procedure RemoveController(AController : TDaemonController); virtual;
-    procedure SetupLogger;
-    procedure StopLogger;
+    Function GetEventLog: TEventLog; virtual;
     Procedure DoRun; override;
     Procedure DoRun; override;
     Property SysData : TObject Read FSysData Write FSysData;
     Property SysData : TObject Read FSysData Write FSysData;
   Public
   Public
+    destructor Destroy; override;
     Procedure ShowException(E : Exception); override;
     Procedure ShowException(E : Exception); override;
     Function CreateDaemon(DaemonDef : TDaemonDef) : TCustomDaemon;
     Function CreateDaemon(DaemonDef : TDaemonDef) : TCustomDaemon;
     Procedure StopDaemons(Force : Boolean);
     Procedure StopDaemons(Force : Boolean);
     procedure InstallDaemons;
     procedure InstallDaemons;
     procedure RunDaemons;
     procedure RunDaemons;
     procedure UnInstallDaemons;
     procedure UnInstallDaemons;
+    procedure ShowHelp;
     procedure CreateForm(InstanceClass: TComponentClass; var Reference); virtual;
     procedure CreateForm(InstanceClass: TComponentClass; var Reference); virtual;
+    procedure Log(EventType: TEventType; Msg: String); override;
     Property  OnRun : TNotifyEvent Read FOnRun Write FOnRun;
     Property  OnRun : TNotifyEvent Read FOnRun Write FOnRun;
-    Property Logger : TEventLog Read FLogger;
+    Property EventLog : TEventLog Read GetEventLog;
     Property GUIMainLoop : TGuiLoopEvent Read FGUIMainLoop Write FGuiMainLoop;
     Property GUIMainLoop : TGuiLoopEvent Read FGUIMainLoop Write FGuiMainLoop;
     Property GuiHandle : THandle Read FGUIHandle Write FGUIHandle;
     Property GuiHandle : THandle Read FGUIHandle Write FGUIHandle;
     Property RunMode : TDaemonRunMode Read FRunMode;
     Property RunMode : TDaemonRunMode Read FRunMode;
@@ -392,7 +394,7 @@ Procedure DaemonError(Fmt : String; Args : Array of const);
 Resourcestring
 Resourcestring
   SErrNoServiceMapper           = 'No daemon mapper class registered.';
   SErrNoServiceMapper           = 'No daemon mapper class registered.';
   SErrOnlyOneMapperAllowed      = 'Not changing daemon mapper class %s with %s: Only 1 mapper allowed.';
   SErrOnlyOneMapperAllowed      = 'Not changing daemon mapper class %s with %s: Only 1 mapper allowed.';
-  SErrNothingToDo               = 'Options do not allow determining what needs to be done.';
+  SErrNothingToDo               = 'No command given, use ''%s -h'' for usage.';
   SErrDuplicateName             = 'Duplicate daemon name: %s';
   SErrDuplicateName             = 'Duplicate daemon name: %s';
   SErrUnknownDaemonClass        = 'Unknown daemon class name: %s';
   SErrUnknownDaemonClass        = 'Unknown daemon class name: %s';
   SErrDaemonStartFailed         = 'Failed to start daemon %s : %s';
   SErrDaemonStartFailed         = 'Failed to start daemon %s : %s';
@@ -404,7 +406,12 @@ Resourcestring
   SErrNoDaemonDefForStatus      = '%s: No daemon definition for status report';
   SErrNoDaemonDefForStatus      = '%s: No daemon definition for status report';
   SErrWindowClass               = 'Could not register window class';
   SErrWindowClass               = 'Could not register window class';
   SErrApplicationAlreadyCreated = 'An application instance of class %s was already created.';
   SErrApplicationAlreadyCreated = 'An application instance of class %s was already created.';
-  
+  SHelpUsage                    = 'Usage: %s [command]';
+  SHelpCommand                  = 'Where command is one of the following:';
+  SHelpInstall                  = 'To install the program as a service';
+  SHelpUnInstall                = 'To uninstall the service';
+  SHelpRun                      = 'To run the service';
+
 { $define svcdebug}
 { $define svcdebug}
 
 
 {$ifdef svcdebug}
 {$ifdef svcdebug}
@@ -647,12 +654,12 @@ end;
 
 
 procedure TCustomDaemon.LogMessage(Msg: String);
 procedure TCustomDaemon.LogMessage(Msg: String);
 begin
 begin
-  Application.Logger.Error(Msg);
+  Application.Log(etInfo,Msg);
 end;
 end;
 
 
 function TCustomDaemon.GetLogger: TEventLog;
 function TCustomDaemon.GetLogger: TEventLog;
 begin
 begin
-  Result:=Application.Logger;
+  Result:=Application.EventLog;
 end;
 end;
 
 
 procedure TCustomDaemon.SetStatus(const AValue: TCurrentStatus);
 procedure TCustomDaemon.SetStatus(const AValue: TCurrentStatus);
@@ -756,6 +763,7 @@ Var
 
 
 begin
 begin
   FrunMode:=drmInstall;
   FrunMode:=drmInstall;
+  EventLog.RegisterMessageFile('');
   SysStartInstallDaemons;
   SysStartInstallDaemons;
   try
   try
     FMapper.DoOnInstall;
     FMapper.DoOnInstall;
@@ -787,6 +795,7 @@ Var
 
 
 begin
 begin
   FrunMode:=drmUnInstall;
   FrunMode:=drmUnInstall;
+  EventLog.UnRegisterMessageFile;
   SysStartUnInstallDaemons;
   SysStartUnInstallDaemons;
   Try
   Try
     FMapper.DoOnUnInstall;
     FMapper.DoOnUnInstall;
@@ -810,6 +819,15 @@ begin
   end;
   end;
 end;
 end;
 
 
+procedure TCustomDaemonApplication.ShowHelp;
+begin
+  writeln(Format(SHelpUsage,[ParamStr(0)]));
+  writeln(SHelpCommand);
+  writeln('  -i --install   '+SHelpInstall);
+  writeln('  -u --uninstall '+SHelpUnInstall);
+  writeln('  -r --run       '+SHelpRun);
+end;
+
 procedure TCustomDaemonApplication.CreateForm(InstanceClass: TComponentClass;
 procedure TCustomDaemonApplication.CreateForm(InstanceClass: TComponentClass;
   var Reference);
   var Reference);
   
   
@@ -830,6 +848,11 @@ begin
   end;
   end;
 end;
 end;
 
 
+procedure TCustomDaemonApplication.Log(EventType: TEventType; Msg: String);
+begin
+  EventLog.Log(EventType,Msg);
+end;
+
 Procedure TCustomDaemonApplication.RunDaemons;
 Procedure TCustomDaemonApplication.RunDaemons;
 
 
 Var
 Var
@@ -855,57 +878,65 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure TCustomDaemonApplication.SetupLogger;
+function TCustomDaemonApplication.GetEventLog: TEventLog;
 
 
 begin
 begin
-  FLogger:=TEventlog.Create(Self);
-  FLogger.RegisterMessageFile('');
+  if not assigned(FEventLog) then
+    begin
+    FEventLog:=TEventlog.Create(Self);
+    FEventLog.RaiseExceptionOnError:=true;
+    FEventLog.RegisterMessageFile('');
+    end;
+  result := FEventLog;
 end;
 end;
 
 
-procedure TCustomDaemonApplication.StopLogger;
+destructor TCustomDaemonApplication.Destroy;
 
 
 begin
 begin
-  Flogger.Active:=False;
-  FreeAndNil(Flogger);
+  if assigned(FEventLog) then
+    FEventLog.Free;
 end;
 end;
 
 
 procedure TCustomDaemonApplication.DoRun;
 procedure TCustomDaemonApplication.DoRun;
 
 
 begin
 begin
-  SetupLogger;
-  Try
-    try
-      If Not Assigned(MapperClass) then
-        DaemonError(SErrNoServiceMapper);
-      CreateServiceMapper(FMapper);
-      If InstallRun then
-        InstallDaemons
-      else If UnInstallRun then
-        UnInstallDaemons
-      else if RunDaemonsRun then
-        RunDaemons
-      else if Assigned(OnRun) then
-       OnRun(Self)
+  try
+    If Not Assigned(MapperClass) then
+      DaemonError(SErrNoServiceMapper);
+    CreateServiceMapper(FMapper);
+    if InstallRun then
+      InstallDaemons
+    else If UnInstallRun then
+      UnInstallDaemons
+    else if RunDaemonsRun then
+      RunDaemons
+    else if Assigned(OnRun) then
+     OnRun(Self)
+    else if HasOption('h','help') then
+      begin
+      if IsConsole then
+        ShowHelp;
+      end
+    else
+      begin
+      if IsConsole then
+        ShowHelp
       else
       else
-        DaemonError(SErrNothingToDo);
-      {$ifdef svcdebug}DebugLog('Terminating');{$endif svcdebug}
-      Terminate;
-      {$ifdef svcdebug}DebugLog('Terminated');{$endif svcdebug}
-    except
-      Terminate;
-      Raise
-    end;
-  Finally
-    StopLogger;
+        DaemonError(SErrNothingToDo,[ParamStr(0)]);
+      end;
+    {$ifdef svcdebug}DebugLog('Terminating');{$endif svcdebug}
+    Terminate;
+    {$ifdef svcdebug}DebugLog('Terminated');{$endif svcdebug}
+  except
+    Terminate;
+    Raise
   end;
   end;
 end;
 end;
 
 
 procedure TCustomDaemonApplication.ShowException(E: Exception);
 procedure TCustomDaemonApplication.ShowException(E: Exception);
 begin
 begin
-  If assigned(Flogger) then
-    FLogger.Error(E.Message)
-  else
-   inherited ShowException(E)
+  Log(etError,E.Message);
+  inherited ShowException(E)
 end;
 end;
 
 
 Procedure TCustomDaemonApplication.CreateDaemonInstance(Var ADaemon : TCustomDaemon; DaemonDef : TDaemonDef); 
 Procedure TCustomDaemonApplication.CreateDaemonInstance(Var ADaemon : TCustomDaemon; DaemonDef : TDaemonDef); 
@@ -1185,7 +1216,6 @@ begin
         S:=SStatus[ACode]
         S:=SStatus[ACode]
       else
       else
         S:=Format(SCustomCode,[ACode]);
         S:=Format(SCustomCode,[ACode]);
-      Application.Logger.Error(SControlFailed,[S,E.Message]);
       end;
       end;
   end;
   end;
 end;
 end;

+ 1 - 1
packages/fcl-extra/src/unix/daemonapp.inc

@@ -196,7 +196,7 @@ begin
     With FDaemon do
     With FDaemon do
       S:=Format(SDaemonStatus,[Definition.DisplayName,
       S:=Format(SDaemonStatus,[Definition.DisplayName,
                                CurrentStatusNames[Status]]);
                                CurrentStatusNames[Status]]);
-  Application.Logger.Info(S);
+  Application.Log(etInfo,S);
 end;
 end;
 
 
 { ---------------------------------------------------------------------
 { ---------------------------------------------------------------------

+ 7 - 8
packages/fcl-extra/src/win/daemonapp.inc

@@ -37,8 +37,7 @@ begin
   If (Nil<>lpContext) then
   If (Nil<>lpContext) then
     TDaemonController(lpContext).Controller(dwControl,dwEventType,lpEventData)
     TDaemonController(lpContext).Controller(dwControl,dwEventType,lpEventData)
   else
   else
-    If Assigned(Application.Logger) then
-      Application.Logger.Error(SerrNoControlContext,[dwControl,dwEventType,ptrint(lpEventData)]);
+    Application.Log(etError,Format(SerrNoControlContext,[dwControl,dwEventType,ptrint(lpEventData)]));
 end;
 end;
 
 
 Procedure ServiceMainEntry(Argc : DWord; Args : Pchar); stdcall;
 Procedure ServiceMainEntry(Argc : DWord; Args : Pchar); stdcall;
@@ -427,7 +426,7 @@ begin
     {$ifdef svcdebug}DebugLog('SysRun Terminating');{$endif svcdebug}
     {$ifdef svcdebug}DebugLog('SysRun Terminating');{$endif svcdebug}
     Terminate;
     Terminate;
     If (RV<>0) then
     If (RV<>0) then
-      Logger.Error(SErrServiceManagerStartFailed,[SysErrorMessage(RV)]);
+      Log(etError,Format(SErrServiceManagerStartFailed,[SysErrorMessage(RV)]));
   Finally
   Finally
     FreeMem(P);
     FreeMem(P);
   end;
   end;
@@ -504,7 +503,7 @@ begin
     FParams.Add(StrPas(Args[I]));
     FParams.Add(StrPas(Args[I]));
   H:=RegisterServiceCtrlHandlerEx(Args[0],@ServiceControlHandlerEntry,Self);
   H:=RegisterServiceCtrlHandlerEx(Args[0],@ServiceControlHandlerEntry,Self);
   if (H=0) then
   if (H=0) then
-    Application.Logger.Error(SErrRegisterHandler,[getlasterror]);
+    Application.Log(etError,Format(SErrRegisterHandler,[getlasterror]));
   FSysData:=TSCMData.Create(H);
   FSysData:=TSCMData.Create(H);
   FDaemon.Status:=csStartPending;
   FDaemon.Status:=csStartPending;
   Try
   Try
@@ -567,13 +566,13 @@ Const
 begin
 begin
   If not Assigned(FDaemon) then
   If not Assigned(FDaemon) then
     begin
     begin
-    Application.Logger.Error(SErrNoDaemonForStatus,[Name]);
+    Application.Log(etError,Format(SErrNoDaemonForStatus,[Name]));
     Exit;
     Exit;
     end;
     end;
   DD:=FDaemon.Definition;
   DD:=FDaemon.Definition;
   If not Assigned(DD) then
   If not Assigned(DD) then
     begin
     begin
-    Application.Logger.Error(SErrNoDaemonDefForStatus,[Name]);
+    Application.Log(etError,Format(SErrNoDaemonDefForStatus,[Name]));
     Exit;
     Exit;
     end;
     end;
   DD.LogStatusReport:=True;
   DD.LogStatusReport:=True;
@@ -583,7 +582,7 @@ begin
     With FDaemon do
     With FDaemon do
       begin
       begin
       S:=Format(SDaemonStatus,[Definition.DisplayName, CurrentStatusNames[Status]]);
       S:=Format(SDaemonStatus,[Definition.DisplayName, CurrentStatusNames[Status]]);
-      Application.Logger.Info(S);
+      Application.Log(etInfo,S);
       {$ifdef svcdebug}DebugLog(S);{$endif svcdebug}
       {$ifdef svcdebug}DebugLog(S);{$endif svcdebug}
       end;
       end;
   FillChar(SS,SizeOf(SS),0);
   FillChar(SS,SizeOf(SS),0);
@@ -609,7 +608,7 @@ begin
     else
     else
       dwWin32ExitCode := WB.Win32ErrCode;
       dwWin32ExitCode := WB.Win32ErrCode;
     if not SetServiceStatus(TSCMData(FSysData).FHandle, SS) then
     if not SetServiceStatus(TSCMData(FSysData).FHandle, SS) then
-      Application.Logger.Error(SysErrorMessage(GetLastError));
+      Application.Log(etError,SysErrorMessage(GetLastError));
   end;
   end;
 end;
 end;
 
 

+ 77 - 17
packages/fcl-web/src/base/custfcgi.pp

@@ -26,13 +26,22 @@ uses
 Type
 Type
   { TFCGIRequest }
   { TFCGIRequest }
   TCustomFCgiApplication = Class;
   TCustomFCgiApplication = Class;
+  TFCGIRequest = Class;
+  TFCGIResponse = Class;
+
+  TProtocolOption = (poNoPadding,poStripContentLength, poFailonUnknownRecord );
+  TProtocolOptions = Set of TProtocolOption;
+
+  TUnknownRecordEvent = Procedure (ARequest : TFCGIRequest; AFCGIRecord: PFCGI_Header) Of Object;
 
 
   TFCGIRequest = Class(TCGIRequest)
   TFCGIRequest = Class(TCGIRequest)
   Private
   Private
     FHandle: THandle;
     FHandle: THandle;
     FKeepConnectionAfterRequest: boolean;
     FKeepConnectionAfterRequest: boolean;
+    FPO: TProtoColOptions;
     FRequestID : Word;
     FRequestID : Word;
     FCGIParams : TSTrings;
     FCGIParams : TSTrings;
+    FUR: TUnknownRecordEvent;
     procedure GetNameValuePairsFromContentRecord(const ARecord : PFCGI_ContentRecord; NameValueList : TStrings);
     procedure GetNameValuePairsFromContentRecord(const ARecord : PFCGI_ContentRecord; NameValueList : TStrings);
   Protected
   Protected
     Function GetFieldValue(Index : Integer) : String; override;
     Function GetFieldValue(Index : Integer) : String; override;
@@ -43,16 +52,22 @@ Type
     property RequestID : word read FRequestID write FRequestID;
     property RequestID : word read FRequestID write FRequestID;
     property Handle : THandle read FHandle write FHandle;
     property Handle : THandle read FHandle write FHandle;
     property KeepConnectionAfterRequest : boolean read FKeepConnectionAfterRequest;
     property KeepConnectionAfterRequest : boolean read FKeepConnectionAfterRequest;
+    Property ProtocolOptions : TProtoColOptions read FPO Write FPO;
+    Property OnUnknownRecord : TUnknownRecordEvent Read FUR Write FUR;
   end;
   end;
 
 
   { TFCGIResponse }
   { TFCGIResponse }
 
 
   TFCGIResponse = Class(TCGIResponse)
   TFCGIResponse = Class(TCGIResponse)
   private
   private
+    FNoPadding: Boolean;
+    FPO: TProtoColOptions;
+    FStripCL: Boolean;
     procedure Write_FCGIRecord(ARecord : PFCGI_Header);
     procedure Write_FCGIRecord(ARecord : PFCGI_Header);
   Protected
   Protected
     Procedure DoSendHeaders(Headers : TStrings); override;
     Procedure DoSendHeaders(Headers : TStrings); override;
     Procedure DoSendContent; override;
     Procedure DoSendContent; override;
+    Property ProtocolOptions : TProtoColOptions Read FPO Write FPO;
   end;
   end;
 
 
   TReqResp = record
   TReqResp = record
@@ -64,10 +79,13 @@ Type
 
 
   TCustomFCgiApplication = Class(TCustomWebApplication)
   TCustomFCgiApplication = Class(TCustomWebApplication)
   Private
   Private
+    FOnUnknownRecord: TUnknownRecordEvent;
+    FPO: TProtoColOptions;
     FRequestsArray : Array of TReqResp;
     FRequestsArray : Array of TReqResp;
     FRequestsAvail : integer;
     FRequestsAvail : integer;
     FHandle : THandle;
     FHandle : THandle;
     Socket: longint;
     Socket: longint;
+    FAddress: string;
     FPort: integer;
     FPort: integer;
     function Read_FCGIRecord : PFCGI_Header;
     function Read_FCGIRecord : PFCGI_Header;
   protected
   protected
@@ -77,6 +95,9 @@ Type
     constructor Create(AOwner: TComponent); override;
     constructor Create(AOwner: TComponent); override;
     destructor Destroy; override;
     destructor Destroy; override;
     property Port: integer read FPort write FPort;
     property Port: integer read FPort write FPort;
+    property Address: string read FAddress write FAddress;
+    Property ProtocolOptions : TProtoColOptions Read FPO Write FPO;
+    Property OnUnknownRecord : TUnknownRecordEvent Read FOnUnknownRecord Write FOnUnknownRecord;
   end;
   end;
 
 
 ResourceString
 ResourceString
@@ -146,6 +167,12 @@ begin
                           FContentRead:=True;
                           FContentRead:=True;
                           end;
                           end;
                         end;
                         end;
+  else
+    if Assigned(FUR) then
+      FUR(Self,AFCGIRecord)
+    else
+      if poFailonUnknownRecord in FPO then
+        Raise EFPWebError.CreateFmt('Unknown FASTCGI record type: %s',[AFCGIRecord^.reqtype]);
   end;
   end;
 end;
 end;
 
 
@@ -194,6 +221,7 @@ begin
     end;
     end;
 end;
 end;
 
 
+
 Function TFCGIRequest.GetFieldValue(Index : Integer) : String;
 Function TFCGIRequest.GetFieldValue(Index : Integer) : String;
 
 
 Type THttpToCGI = array[1..CGIVarCount] of byte;
 Type THttpToCGI = array[1..CGIVarCount] of byte;
@@ -270,14 +298,26 @@ var
   pl : byte;
   pl : byte;
   str : String;
   str : String;
   ARespRecord : PFCGI_ContentRecord;
   ARespRecord : PFCGI_ContentRecord;
+  I : Integer;
 
 
 begin
 begin
-  str := Headers.Text;
+  For I:=Headers.Count-1 downto 0 do
+    If (Headers[i]='') then
+      Headers.Delete(I);
+  // IndexOfName Does not work ?
+  If (poStripContentLength in ProtocolOptions) then
+    For I:=Headers.Count-1 downto 0 do
+      If (Pos('Content-Length',Headers[i])<>0)  then
+        Headers.Delete(i);
+  str := Headers.Text+sLineBreak;
   cl := length(str);
   cl := length(str);
-  pl := (cl mod 8);
-
+  if ((cl mod 8)=0) or (poNoPadding in ProtocolOptions) then
+    pl:=0
+  else
+    pl := 8-(cl mod 8);
   ARespRecord:=nil;
   ARespRecord:=nil;
   Getmem(ARespRecord,8+cl+pl);
   Getmem(ARespRecord,8+cl+pl);
+  FillChar(ARespRecord^,8+cl+pl,0);
   ARespRecord^.header.version:=FCGI_VERSION_1;
   ARespRecord^.header.version:=FCGI_VERSION_1;
   ARespRecord^.header.reqtype:=FCGI_STDOUT;
   ARespRecord^.header.reqtype:=FCGI_STDOUT;
   ARespRecord^.header.paddingLength:=pl;
   ARespRecord^.header.paddingLength:=pl;
@@ -305,10 +345,11 @@ begin
     end
     end
   else
   else
     str := Contents.Text;
     str := Contents.Text;
-
   cl := length(str);
   cl := length(str);
-  pl := (cl mod 8);
-
+  if ((cl mod 8)=0) or (poNoPadding in ProtocolOptions) then
+    pl:=0
+  else
+    pl := 8-(cl mod 8);
   ARespRecord:=Nil;
   ARespRecord:=Nil;
   Getmem(ARespRecord,8+cl+pl);
   Getmem(ARespRecord,8+cl+pl);
   ARespRecord^.header.version:=FCGI_VERSION_1;
   ARespRecord^.header.version:=FCGI_VERSION_1;
@@ -317,8 +358,10 @@ begin
   ARespRecord^.header.contentLength:=NtoBE(cl);
   ARespRecord^.header.contentLength:=NtoBE(cl);
   ARespRecord^.header.requestId:=NToBE(TFCGIRequest(Request).RequestID);
   ARespRecord^.header.requestId:=NToBE(TFCGIRequest(Request).RequestID);
   move(str[1],ARespRecord^.ContentData,cl);
   move(str[1],ARespRecord^.ContentData,cl);
+
   Write_FCGIRecord(PFCGI_Header(ARespRecord));
   Write_FCGIRecord(PFCGI_Header(ARespRecord));
   Freemem(ARespRecord);
   Freemem(ARespRecord);
+  FillChar(EndRequest,SizeOf(FCGI_EndRequestRecord),0);
 
 
   EndRequest.header.version:=FCGI_VERSION_1;
   EndRequest.header.version:=FCGI_VERSION_1;
   EndRequest.header.reqtype:=FCGI_END_REQUEST;
   EndRequest.header.reqtype:=FCGI_END_REQUEST;
@@ -342,8 +385,11 @@ end;
 destructor TCustomFCgiApplication.Destroy;
 destructor TCustomFCgiApplication.Destroy;
 begin
 begin
   SetLength(FRequestsArray,0);
   SetLength(FRequestsArray,0);
-  if port<>0 then
-    fpshutdown(Socket,2);
+  if (Socket<>0) then
+    begin
+    CloseSocket(Socket);
+    Socket:=0;
+    end;
   inherited Destroy;
   inherited Destroy;
 end;
 end;
 
 
@@ -353,7 +399,7 @@ begin
     begin
     begin
     Assert(ARequest=Request);
     Assert(ARequest=Request);
     Assert(AResponse=Response);
     Assert(AResponse=Response);
-    if not TFCGIRequest(ARequest).KeepConnectionAfterRequest then
+    if (not TFCGIRequest(ARequest).KeepConnectionAfterRequest) then
       begin
       begin
       fpshutdown(FHandle,SHUT_RDWR);
       fpshutdown(FHandle,SHUT_RDWR);
       CloseSocket(FHandle);
       CloseSocket(FHandle);
@@ -409,7 +455,7 @@ end;
 
 
 function TCustomFCgiApplication.WaitForRequest(out ARequest: TRequest; out AResponse: TResponse): boolean;
 function TCustomFCgiApplication.WaitForRequest(out ARequest: TRequest; out AResponse: TResponse): boolean;
 var
 var
-  Address       : TInetSockAddr;
+  IAddress      : TInetSockAddr;
   AddressLength : tsocklen;
   AddressLength : tsocklen;
   ARequestID    : word;
   ARequestID    : word;
   AFCGI_Record  : PFCGI_Header;
   AFCGI_Record  : PFCGI_Header;
@@ -417,7 +463,7 @@ var
 
 
 begin
 begin
   Result := False;
   Result := False;
-  AddressLength:=Sizeof(Address);
+  AddressLength:=Sizeof(IAddress);
 
 
   if Socket=0 then
   if Socket=0 then
     begin
     begin
@@ -425,14 +471,25 @@ begin
       begin
       begin
       Socket := fpsocket(AF_INET,SOCK_STREAM,0);
       Socket := fpsocket(AF_INET,SOCK_STREAM,0);
       if Socket=-1 then
       if Socket=-1 then
-        raise Exception.CreateFmt(SNoSocket,[socketerror]);
-      Address.sin_family:=AF_INET;
-      Address.sin_port:=htons(Port);
-      Address.sin_addr.s_addr:=0;
-      if fpbind(Socket,@Address,AddressLength)=-1 then
+        raise EFPWebError.CreateFmt(SNoSocket,[socketerror]);
+      IAddress.sin_family:=AF_INET;
+      IAddress.sin_port:=htons(Port);
+      if FAddress<>'' then
+        Iaddress.sin_addr := StrToHostAddr(FAddress)
+      else
+        IAddress.sin_addr.s_addr:=0;
+      if fpbind(Socket,@IAddress,AddressLength)=-1 then
+        begin
+        CloseSocket(socket);
+        Socket:=0;
         raise Exception.CreateFmt(SBindFailed,[port,socketerror]);
         raise Exception.CreateFmt(SBindFailed,[port,socketerror]);
+        end;
       if fplisten(Socket,1)=-1 then
       if fplisten(Socket,1)=-1 then
+        begin
+        CloseSocket(socket);
+        Socket:=0;
         raise Exception.CreateFmt(SListenFailed,[port,socketerror]);
         raise Exception.CreateFmt(SListenFailed,[port,socketerror]);
+        end;
       end
       end
     else
     else
       Socket:=StdInputHandle;
       Socket:=StdInputHandle;
@@ -440,7 +497,7 @@ begin
 
 
   if FHandle=-1 then
   if FHandle=-1 then
     begin
     begin
-    FHandle:=fpaccept(Socket,psockaddr(@Address),@AddressLength);
+    FHandle:=fpaccept(Socket,psockaddr(@IAddress),@AddressLength);
     if FHandle=-1 then
     if FHandle=-1 then
       raise Exception.CreateFmt(SNoInputHandle,[socketerror]);
       raise Exception.CreateFmt(SNoInputHandle,[socketerror]);
     end;
     end;
@@ -463,12 +520,15 @@ begin
       ATempRequest:=TFCGIRequest.Create;
       ATempRequest:=TFCGIRequest.Create;
       ATempRequest.RequestID:=ARequestID;
       ATempRequest.RequestID:=ARequestID;
       ATempRequest.Handle:=FHandle;
       ATempRequest.Handle:=FHandle;
+      ATempRequest.ProtocolOptions:=Self.Protocoloptions;
+      ATempRequest.OnUnknownRecord:=Self.OnUnknownRecord;
       FRequestsArray[ARequestID].Request := ATempRequest;
       FRequestsArray[ARequestID].Request := ATempRequest;
       end;
       end;
     if FRequestsArray[ARequestID].Request.ProcessFCGIRecord(AFCGI_Record) then
     if FRequestsArray[ARequestID].Request.ProcessFCGIRecord(AFCGI_Record) then
       begin
       begin
       ARequest:=FRequestsArray[ARequestID].Request;
       ARequest:=FRequestsArray[ARequestID].Request;
       FRequestsArray[ARequestID].Response := TFCGIResponse.Create(ARequest);
       FRequestsArray[ARequestID].Response := TFCGIResponse.Create(ARequest);
+      FRequestsArray[ARequestID].Response.ProtocolOptions:=Self.ProtocolOptions;
       AResponse:=FRequestsArray[ARequestID].Response;
       AResponse:=FRequestsArray[ARequestID].Response;
       Result := True;
       Result := True;
       Break;
       Break;

+ 4 - 1
packages/fcl-web/src/base/custweb.pp

@@ -264,7 +264,10 @@ begin
       end;
       end;
     M:=FindModule(MC); // Check if a module exists already
     M:=FindModule(MC); // Check if a module exists already
     If (M=Nil) then
     If (M=Nil) then
-      M:=MC.Create(Self);
+      if Mi.SkipStreaming then
+        M:=MC.CreateNew(Self)
+      else
+        M:=MC.Create(Self);
     SetBaseURL(M,MN,ARequest);
     SetBaseURL(M,MN,ARequest);
     if M.Kind=wkOneShot then
     if M.Kind=wkOneShot then
       begin
       begin

+ 11 - 9
packages/fcl-web/src/base/fphtml.pp

@@ -38,7 +38,7 @@ type
   end;
   end;
   TWebButtons = array of TWebButton;
   TWebButtons = array of TWebButton;
 
 
-  TMessageBoxHandler = function(Sender: TObject; AText: String; Buttons: TWebButtons): string of object;
+  TMessageBoxHandler = function(Sender: TObject; AText: String; Buttons: TWebButtons; Loaded: string = ''): string of object;
   TWebController = class;
   TWebController = class;
   THTMLContentProducer = class;
   THTMLContentProducer = class;
 
 
@@ -53,7 +53,7 @@ type
     constructor Create(const AWebController: TWebController); virtual;
     constructor Create(const AWebController: TWebController); virtual;
     destructor Destroy; override;
     destructor Destroy; override;
     procedure AddScriptLine(ALine: String); virtual;
     procedure AddScriptLine(ALine: String); virtual;
-    procedure MessageBox(AText: String; Buttons: TWebButtons); virtual;
+    procedure MessageBox(AText: String; Buttons: TWebButtons; Loaded: string = ''); virtual;
     procedure RedrawContentProducer(AContentProducer: THTMLContentProducer); virtual;
     procedure RedrawContentProducer(AContentProducer: THTMLContentProducer); virtual;
     procedure CallServerEvent(AHTMLContentProducer: THTMLContentProducer; AEvent: Integer; APostVariable: string = ''); virtual;
     procedure CallServerEvent(AHTMLContentProducer: THTMLContentProducer; AEvent: Integer; APostVariable: string = ''); virtual;
     procedure Clear; virtual;
     procedure Clear; virtual;
@@ -92,8 +92,8 @@ type
     procedure CleanupAfterRequest; virtual;
     procedure CleanupAfterRequest; virtual;
     procedure BeforeGenerateHead; virtual;
     procedure BeforeGenerateHead; virtual;
     procedure BindJavascriptCallstackToElement(AComponent: TComponent; AnElement: THtmlCustomElement; AnEvent: string); virtual; abstract;
     procedure BindJavascriptCallstackToElement(AComponent: TComponent; AnElement: THtmlCustomElement; AnEvent: string); virtual; abstract;
-    function MessageBox(AText: String; Buttons: TWebButtons): string; virtual;
-    function DefaultMessageBoxHandler(Sender: TObject; AText: String; Buttons: TWebButtons): string; virtual; abstract;
+    function MessageBox(AText: String; Buttons: TWebButtons; ALoaded: string = ''): string; virtual;
+    function DefaultMessageBoxHandler(Sender: TObject; AText: String; Buttons: TWebButtons;  ALoaded: string = ''): string; virtual; abstract;
     function CreateNewScript: TStringList; virtual; abstract;
     function CreateNewScript: TStringList; virtual; abstract;
     procedure FreeScript(var AScript: TStringList); virtual; abstract;
     procedure FreeScript(var AScript: TStringList); virtual; abstract;
     property ScriptFileReferences: TStringList read GetScriptFileReferences;
     property ScriptFileReferences: TStringList read GetScriptFileReferences;
@@ -433,6 +433,8 @@ const SimpleOkButton: array[0..0] of TWebButton = ((buttontype: btok;caption: 'O
 
 
 const jseButtonClick = 1000;
 const jseButtonClick = 1000;
       jseInputChange = 1001;
       jseInputChange = 1001;
+      jseFormReset   = 1002;
+      jseFormSubmit  = 1003;
 
 
 implementation
 implementation
 Uses
 Uses
@@ -469,9 +471,9 @@ begin
   FScript.Add(ALine);
   FScript.Add(ALine);
 end;
 end;
 
 
-procedure TJavaScriptStack.MessageBox(AText: String; Buttons: TWebButtons);
+procedure TJavaScriptStack.MessageBox(AText: String; Buttons: TWebButtons; Loaded: string = '');
 begin
 begin
-  AddScriptLine(WebController.MessageBox(AText,Buttons));
+  AddScriptLine(WebController.MessageBox(AText,Buttons,Loaded));
 end;
 end;
 
 
 procedure TJavaScriptStack.RedrawContentProducer(AContentProducer: THTMLContentProducer);
 procedure TJavaScriptStack.RedrawContentProducer(AContentProducer: THTMLContentProducer);
@@ -1231,12 +1233,12 @@ begin
   // do nothing
   // do nothing
 end;
 end;
 
 
-function TWebController.MessageBox(AText: String; Buttons: TWebButtons): string;
+function TWebController.MessageBox(AText: String; Buttons: TWebButtons; ALoaded: string = ''): string;
 begin
 begin
   if assigned(MessageBoxHandler) then
   if assigned(MessageBoxHandler) then
-    result := MessageBoxHandler(self,AText,Buttons)
+    result := MessageBoxHandler(self,AText,Buttons,ALoaded)
   else
   else
-    result := DefaultMessageBoxHandler(self,AText,Buttons);
+    result := DefaultMessageBoxHandler(self,AText,Buttons,ALoaded);
 end;
 end;
 
 
 function TWebController.GetRequest: TRequest;
 function TWebController.GetRequest: TRequest;

+ 7 - 4
packages/fcl-web/src/base/fphttp.pp

@@ -120,9 +120,11 @@ Type
   private
   private
     FModuleClass: TCustomHTTPModuleClass;
     FModuleClass: TCustomHTTPModuleClass;
     FModuleName: String;
     FModuleName: String;
+    FSkipStreaming: Boolean;
   Public
   Public
     Property ModuleClass : TCustomHTTPModuleClass Read FModuleClass Write FModuleClass;
     Property ModuleClass : TCustomHTTPModuleClass Read FModuleClass Write FModuleClass;
     Property ModuleName : String Read FModuleName Write FModuleName;
     Property ModuleName : String Read FModuleName Write FModuleName;
+    Property SkipStreaming : Boolean Read FSkipStreaming Write FSkipStreaming;
   end;
   end;
 
 
   { TModuleFactory }
   { TModuleFactory }
@@ -140,8 +142,8 @@ Type
 
 
   EFPHTTPError = Class(Exception);
   EFPHTTPError = Class(Exception);
 
 
-Procedure RegisterHTTPModule(ModuleClass : TCustomHTTPModuleClass);
-Procedure RegisterHTTPModule(Const ModuleName : String; ModuleClass : TCustomHTTPModuleClass);
+Procedure RegisterHTTPModule(ModuleClass : TCustomHTTPModuleClass; SkipStreaming : Boolean = False);
+Procedure RegisterHTTPModule(Const ModuleName : String; ModuleClass : TCustomHTTPModuleClass; SkipStreaming : Boolean = False);
 
 
 Var
 Var
   ModuleFactory : TModuleFactory;
   ModuleFactory : TModuleFactory;
@@ -202,13 +204,13 @@ begin
 end;
 end;
 
 
 
 
-procedure RegisterHTTPModule(ModuleClass: TCustomHTTPModuleClass);
+procedure RegisterHTTPModule(ModuleClass: TCustomHTTPModuleClass; SkipStreaming : Boolean = False);
 begin
 begin
   RegisterHTTPModule(ModuleClass.ClassName,ModuleClass);
   RegisterHTTPModule(ModuleClass.ClassName,ModuleClass);
 end;
 end;
 
 
 procedure RegisterHTTPModule(const ModuleName: String;
 procedure RegisterHTTPModule(const ModuleName: String;
-  ModuleClass: TCustomHTTPModuleClass);
+  ModuleClass: TCustomHTTPModuleClass; SkipStreaming : Boolean = False);
   
   
 Var
 Var
   I : Integer;
   I : Integer;
@@ -224,6 +226,7 @@ begin
   else
   else
     MI:=ModuleFactory[I];
     MI:=ModuleFactory[I];
   MI.ModuleClass:=ModuleClass;
   MI.ModuleClass:=ModuleClass;
+  MI.SkipStreaming:=SkipStreaming;
 end;
 end;
 
 
 { THTTPContentProducer }
 { THTTPContentProducer }

+ 2 - 2
packages/fcl-web/src/base/webpage.pp

@@ -34,7 +34,7 @@ type
     function GetUrl(ParamNames, ParamValues, KeepParams: array of string; Action: string = ''): string; override;
     function GetUrl(ParamNames, ParamValues, KeepParams: array of string; Action: string = ''): string; override;
     procedure BindJavascriptCallstackToElement(AComponent: TComponent; AnElement: THtmlCustomElement; AnEvent: string); override;
     procedure BindJavascriptCallstackToElement(AComponent: TComponent; AnElement: THtmlCustomElement; AnEvent: string); override;
     procedure AddScriptFileReference(AScriptFile: String); override;
     procedure AddScriptFileReference(AScriptFile: String); override;
-    function DefaultMessageBoxHandler(Sender: TObject; AText: String; Buttons: TWebButtons): string; override;
+    function DefaultMessageBoxHandler(Sender: TObject; AText: String; Buttons: TWebButtons; ALoaded: string = ''): string; override;
     function CreateNewScript: TStringList; override;
     function CreateNewScript: TStringList; override;
     procedure FreeScript(var AScript: TStringList); override;
     procedure FreeScript(var AScript: TStringList); override;
   end;
   end;
@@ -345,7 +345,7 @@ begin
 end;
 end;
 
 
 function TStandardWebController.DefaultMessageBoxHandler(Sender: TObject;
 function TStandardWebController.DefaultMessageBoxHandler(Sender: TObject;
-  AText: String; Buttons: TWebButtons): string;
+  AText: String; Buttons: TWebButtons; ALoaded: string = ''): string;
 var i : integer;
 var i : integer;
     HasCancel: boolean;
     HasCancel: boolean;
     OnOk: string;
     OnOk: string;

+ 14 - 5
packages/fcl-web/src/base/websession.pp

@@ -125,7 +125,10 @@ begin
 {$ifdef cgidebug}SendMethodEnter('GetDefaultSession');{$endif}
 {$ifdef cgidebug}SendMethodEnter('GetDefaultSession');{$endif}
   Result:=Nil;
   Result:=Nil;
   If (GlobalSessionDir='') then
   If (GlobalSessionDir='') then
-    GlobalSessionDir:=IncludeTrailingPathDelimiter(GetTempDir(True));
+    GlobalSessionDir:=IncludeTrailingPathDelimiter(GetTempDir(True))
+  else
+    GlobalSessionDir:=IncludeTrailingPathDelimiter(GlobalSessionDir);
+{$ifdef cgidebug}SendDebug('GetDefaultSession, session dir: '+GlobalSessionDir);{$endif}
   If Assigned(OnGetDefaultSession) then
   If Assigned(OnGetDefaultSession) then
     OnGetDefaultSession(Result);
     OnGetDefaultSession(Result);
   if (Result=Nil) then
   if (Result=Nil) then
@@ -257,8 +260,9 @@ begin
     If Assigned(OnNewSession) then
     If Assigned(OnNewSession) then
       OnNewSession(Self);
       OnNewSession(Self);
     GetSessionID;
     GetSessionID;
-{$ifdef cgidebug}SendDebug('Creating new Ini file : '+SessionID);{$endif}
-    FIniFile:=TMemIniFile.Create(IncludeTrailingPathDelimiter(SessionDir)+SessionID);
+    S:=IncludeTrailingPathDelimiter(SessionDir)+SessionID;
+{$ifdef cgidebug}SendDebug('Creating new Ini file : '+S);{$endif}
+    FIniFile:=TMemIniFile.Create(S);
     FIniFile.WriteDateTime(SSession,KeyStart,Now);
     FIniFile.WriteDateTime(SSession,KeyStart,Now);
     FIniFile.WriteInteger(SSession,KeyTimeOut,Self.TimeOutMinutes);
     FIniFile.WriteInteger(SSession,KeyTimeOut,Self.TimeOutMinutes);
     FSessionStarted:=True;
     FSessionStarted:=True;
@@ -342,8 +346,13 @@ procedure TSessionHTTPModule.CheckSession(ARequest : TRequest);
 
 
 begin
 begin
 {$ifdef cgidebug}SendMethodEnter('SessionHTTPModule('+Name+').CheckSession');{$endif}
 {$ifdef cgidebug}SendMethodEnter('SessionHTTPModule('+Name+').CheckSession');{$endif}
-  If CreateSession and Assigned(Session) then
-    Session.InitSession(ARequest,FOnNewSession,FOnSessionExpired);
+  If CreateSession then
+    begin
+    If (FSession=Nil) then
+      FSession:=GetDefaultSession;
+    if Assigned(Session) then
+      Session.InitSession(ARequest,FOnNewSession,FOnSessionExpired);
+    end;
 {$ifdef cgidebug}SendMethodExit('SessionHTTPModule('+Name+').CheckSession');{$endif}
 {$ifdef cgidebug}SendMethodExit('SessionHTTPModule('+Name+').CheckSession');{$endif}
 end;
 end;
 
 

+ 63 - 1
packages/fcl-web/src/webdata/extjsjson.pp

@@ -59,6 +59,10 @@ Const
   SDefFieldNameProperty = 'name';
   SDefFieldNameProperty = 'name';
   SDefDirectionProperty = 'direction';
   SDefDirectionProperty = 'direction';
   SDefSortInfoProperty  = 'sortInfo';
   SDefSortInfoProperty  = 'sortInfo';
+  SIdProperty           = 'idProperty';
+  SSuccessProperty      = 'successProperty';
+  SRootProperty         = 'root';
+  STotalProperty        = 'totalProperty';
   SDefAscDesc : Array[Boolean] of string = ('ASC','DESC');
   SDefAscDesc : Array[Boolean] of string = ('ASC','DESC');
 
 
 function TExtJSJSONDataFormatter.GetDataContentType: String;
 function TExtJSJSONDataFormatter.GetDataContentType: String;
@@ -86,6 +90,16 @@ begin
       Result:=O.Items[O.Add(AFieldName,F.AsBoolean)];
       Result:=O.Items[O.Add(AFieldName,F.AsBoolean)];
     ftLargeint:
     ftLargeint:
       Result:=O.Items[O.Add(AFieldName,F.AsLargeInt)];
       Result:=O.Items[O.Add(AFieldName,F.AsLargeInt)];
+    ftDate:
+      Result:=O.Items[O.Add(AFieldName,FormatDateTime('yyyy-mm-dd',F.AsDateTime))];
+    ftDateTime:
+      Result:=O.Items[O.Add(AFieldName,FormatDateTime('yyyy-mm-dd hh":"nn":"ss',F.AsDateTime))];
+    ftTime:
+      Result:=O.Items[O.Add(AFieldName,FormatDateTime('hh":"nn":"ss',F.AsDateTime))];
+    ftMemo,
+    ftFmtMemo,
+    ftWideMemo,
+    ftBlob :O.Items[O.Add(AFieldName,F.AsString)];
   else
   else
     Result:=O.Items[O.Add(AFieldName,F.DisplayText)];
     Result:=O.Items[O.Add(AFieldName,F.DisplayText)];
   end;
   end;
@@ -109,12 +123,22 @@ end;
 
 
 Function TExtJSJSONDataFormatter.GetJSONMetaData: TJSONObject;
 Function TExtJSJSONDataFormatter.GetJSONMetaData: TJSONObject;
 
 
+  Function DefReplace(S : String) : String;
+
+  begin
+    Result:=StringReplace(Result,'/',DateSeparator,[rfReplaceAll]);
+    Result:=StringReplace(Result,':',TimeSeparator,[rfReplaceAll]);
+    Result:=StringReplace(Result,'hh','H',[rfReplaceAll]);
+    Result:=StringReplace(Result,'nn','i',[rfReplaceAll]);
+    Result:=StringReplace(S,'n','i',[rfReplaceAll]);
+  end;
+
 Var
 Var
   F : TJSONArray;
   F : TJSONArray;
   Fi : TField;
   Fi : TField;
   I : Integer;
   I : Integer;
   O : TJSONObject;
   O : TJSONObject;
-  SF : String;
+  SF,FT : String;
 
 
 begin
 begin
   If (SortField='') then
   If (SortField='') then
@@ -130,12 +154,50 @@ begin
       Fi:=Dataset.Fields[i];
       Fi:=Dataset.Fields[i];
       O:=TJSONObject.Create();
       O:=TJSONObject.Create();
       O.Add(SDefFieldNameProperty,Fi.FieldName);
       O.Add(SDefFieldNameProperty,Fi.FieldName);
+      Ft:='';
+      Case Fi.DataType of
+        ftInteger,
+        ftSmallint,
+        ftWord,
+        ftLargeInt : FT:='int';
+        ftCurrency,
+        ftFloat,
+        ftBCD : FT:='float';
+        ftBoolean : ft:='boolean';
+        ftDate,
+        ftDateTime,
+        ftTimeStamp,
+        ftTime : ft:='date';
+        ftString,
+        ftMemo,
+        ftFmtMemo,
+        ftFixedChar,
+        ftWideString,
+        ftWideMemo : ft:='string'
+      end;
+      if (FT<>'') then
+        begin
+        O.Add('type',FT);
+        if (FT='date') then
+          // Needs improving
+          Case Fi.DataType of
+            ftDate : O.Add('dateFormat','Y-m-d');
+            ftTime : O.Add('dateFormat','h:i:s');
+            ftDateTime,
+            ftTimeStamp : O.Add('dateFormat','Y-m-d h:i:s');
+          end;
+        end;
       F.Add(O);
       F.Add(O);
       end;
       end;
     O:=TJSONObject.Create();
     O:=TJSONObject.Create();
     O.Add(SDefFieldProperty,SF);
     O.Add(SDefFieldProperty,SF);
     O.Add(SDefDirectionProperty,SDefAscDesc[SortDescending]);
     O.Add(SDefDirectionProperty,SDefAscDesc[SortDescending]);
     Result.Add(SDefSortInfoProperty,O);
     Result.Add(SDefSortInfoProperty,O);
+ {$ifdef wmdebug}senddebug('ID property: '+Provider.IDFieldName);{$endif}
+    Result.Add(SIdProperty,Provider.IDFieldName);
+    Result.Add(SSuccessProperty, SuccessProperty);
+    Result.Add(SRootProperty, RowsProperty);
+    Result.Add(STotalProperty, totalProperty)
   except
   except
     Result.free;
     Result.free;
     Raise;
     Raise;

+ 23 - 0
packages/fcl-web/src/webdata/fpwebdata.pp

@@ -468,6 +468,8 @@ type
     Property OnGetInputAdaptor;
     Property OnGetInputAdaptor;
     Property OnGetProvider;
     Property OnGetProvider;
     Property OnContent;
     Property OnContent;
+    Property OnNewSession;
+    Property OnSessionExpired;
   end;
   end;
 
 
 Var
 Var
@@ -499,6 +501,11 @@ Resourcestring
   SErrDuplicateHTTPDataProducer = 'Duplicate web data output content producer name: "%s"';
   SErrDuplicateHTTPDataProducer = 'Duplicate web data output content producer name: "%s"';
   SErrUnknownInputAdaptor = 'Unknown web data input adaptor name: "%s"';
   SErrUnknownInputAdaptor = 'Unknown web data input adaptor name: "%s"';
   SErrUnknownHTTPDataProducer = 'Unknown web data output content producer name: "%s"';
   SErrUnknownHTTPDataProducer = 'Unknown web data output content producer name: "%s"';
+  SErrActionNotAllowed = 'Options of provider %s do not allow %s.';
+  SEditing   = 'editing';
+  SDeleting  = 'deleting';
+  SInserting = 'inserting';
+
 
 
 { TCustomWebdataInputAdaptor }
 { TCustomWebdataInputAdaptor }
 
 
@@ -736,6 +743,8 @@ end;
 procedure TFPCustomWebDataProvider.Update;
 procedure TFPCustomWebDataProvider.Update;
 begin
 begin
   {$ifdef wmdebug}SendDebug('TFPCustomWebDataProvider.Update enter');{$endif}
   {$ifdef wmdebug}SendDebug('TFPCustomWebDataProvider.Update enter');{$endif}
+  If ((Options * [wdpReadOnly,wdpDisableEdit])<>[]) then
+    Raise EFPHTTPError.CreateFmt(SErrActionNotAllowed,[Name,SEditing]);
   CheckAdaptor;
   CheckAdaptor;
   DoUpdate;
   DoUpdate;
   {$ifdef wmdebug}SendDebug('TFPCustomWebDataProvider.Update leave');{$endif}
   {$ifdef wmdebug}SendDebug('TFPCustomWebDataProvider.Update leave');{$endif}
@@ -743,14 +752,22 @@ end;
 
 
 procedure TFPCustomWebDataProvider.Delete;
 procedure TFPCustomWebDataProvider.Delete;
 begin
 begin
+  {$ifdef wmdebug}SendDebug('TFPCustomWebDataProvider.Delete enter');{$endif}
+  If ((Options * [wdpReadOnly,wdpDisableDelete])<>[]) then
+    Raise EFPHTTPError.CreateFmt(SErrActionNotAllowed,[Name,SDeleting]);
   CheckAdaptor;
   CheckAdaptor;
   DoDelete;
   DoDelete;
+  {$ifdef wmdebug}SendDebug('TFPCustomWebDataProvider.Delete leave');{$endif}
 end;
 end;
 
 
 procedure TFPCustomWebDataProvider.Insert;
 procedure TFPCustomWebDataProvider.Insert;
 begin
 begin
+  {$ifdef wmdebug}SendDebug('TFPCustomWebDataProvider.Insert enter');{$endif}
+  If ((Options * [wdpReadOnly,wdpDisableInsert])<>[]) then
+    Raise EFPHTTPError.CreateFmt(SErrActionNotAllowed,[Name,SInserting]);
   CheckAdaptor;
   CheckAdaptor;
   DoInsert;
   DoInsert;
+  {$ifdef wmdebug}SendDebug('TFPCustomWebDataProvider.Insert leave');{$endif}
 end;
 end;
 
 
 procedure TFPCustomWebDataProvider.ApplyParams;
 procedure TFPCustomWebDataProvider.ApplyParams;
@@ -1635,6 +1652,11 @@ begin
   FRequest:=ARequest;
   FRequest:=ARequest;
   FResponse:=AResponse;
   FResponse:=AResponse;
   try
   try
+    {$ifdef wmdebug}SendDebug('Checking session');{$endif}
+    CheckSession(ARequest);
+    {$ifdef wmdebug}SendDebug('Init session');{$endif}
+    InitSession(AResponse);
+    {$ifdef wmdebug}SendDebug('Getting providername');{$endif}
     ProviderName:=Request.GetNextPathInfo;
     ProviderName:=Request.GetNextPathInfo;
     {$ifdef wmdebug}SendDebug('Handlerequest, providername : '+Providername);{$endif}
     {$ifdef wmdebug}SendDebug('Handlerequest, providername : '+Providername);{$endif}
     AProvider:=GetProvider(ProviderName,AContainer);
     AProvider:=GetProvider(ProviderName,AContainer);
@@ -1649,6 +1671,7 @@ begin
         wdaInsert  : InsertWebdata(AProvider);
         wdaInsert  : InsertWebdata(AProvider);
         wdaDelete  : DeleteWebData(AProvider);
         wdaDelete  : DeleteWebData(AProvider);
       end;
       end;
+      UpdateSession(AResponse);
     finally
     finally
       If (AContainer=Nil) then
       If (AContainer=Nil) then
         begin
         begin

+ 30 - 11
packages/fcl-web/src/webdata/sqldbwebdata.pp

@@ -12,21 +12,23 @@ Type
   { TCustomSQLDBWebDataProvider }
   { TCustomSQLDBWebDataProvider }
   TNewIDEvent = Procedure(Sender : TObject; Out AID : String) of object;
   TNewIDEvent = Procedure(Sender : TObject; Out AID : String) of object;
   TGetParamTypeEvent = Procedure (Sender : TObject; Const ParamName,AValue : String; Var AType : TFieldtype) of object;
   TGetParamTypeEvent = Procedure (Sender : TObject; Const ParamName,AValue : String; Var AType : TFieldtype) of object;
+  TGetParamValueEvent = Procedure (Sender : TObject; P : TParam; Var Handled : Boolean) of object;
 
 
   TCustomSQLDBWebDataProvider = Class(TFPCustomWebDataProvider)
   TCustomSQLDBWebDataProvider = Class(TFPCustomWebDataProvider)
   private
   private
     FIDFieldName: String;
     FIDFieldName: String;
     FOnGetNewID: TNewIDEvent;
     FOnGetNewID: TNewIDEvent;
+    FOnGetParamValue: TGetParamValueEvent;
     FSQLS : Array[0..3] of TStringList;
     FSQLS : Array[0..3] of TStringList;
     FConnection: TSQLConnection;
     FConnection: TSQLConnection;
     FQuery : TSQLQuery;
     FQuery : TSQLQuery;
     FLastNewID : String;
     FLastNewID : String;
     FOnGetParamType : TGetParamTypeEvent;
     FOnGetParamType : TGetParamTypeEvent;
-    procedure CheckDataset;
     function GetS(AIndex: integer): TStrings;
     function GetS(AIndex: integer): TStrings;
     procedure SetConnection(const AValue: TSQLConnection);
     procedure SetConnection(const AValue: TSQLConnection);
     procedure SetS(AIndex: integer; const AValue: TStrings);
     procedure SetS(AIndex: integer; const AValue: TStrings);
   Protected
   Protected
+    function CheckDataset : Boolean; virtual;
     function CreateQuery(AOwner: TComponent; ATransaction: TSQLTransaction; ASQL: Tstrings): TSQLQuery;
     function CreateQuery(AOwner: TComponent; ATransaction: TSQLTransaction; ASQL: Tstrings): TSQLQuery;
     function GetParamType(P: TParam; const AValue: String): TFieldType; virtual;
     function GetParamType(P: TParam; const AValue: String): TFieldType; virtual;
     procedure SetTypedParam(P: TParam; Const AValue: String); virtual;
     procedure SetTypedParam(P: TParam; Const AValue: String); virtual;
@@ -37,6 +39,7 @@ Type
     Procedure DoDelete; override;
     Procedure DoDelete; override;
     Procedure DoInsert; override;
     Procedure DoInsert; override;
     Procedure DoApplyParams; override;
     Procedure DoApplyParams; override;
+    Function SQLQuery : TSQLQuery;
     Function GetDataset : TDataset; override;
     Function GetDataset : TDataset; override;
     Function GetNewID : String;
     Function GetNewID : String;
     Function IDFieldValue : String; override;
     Function IDFieldValue : String; override;
@@ -48,6 +51,7 @@ Type
     Property Connection : TSQLConnection Read FConnection Write SetConnection;
     Property Connection : TSQLConnection Read FConnection Write SetConnection;
     Property OnGetNewID : TNewIDEvent Read FOnGetNewID Write FOnGetNewID;
     Property OnGetNewID : TNewIDEvent Read FOnGetNewID Write FOnGetNewID;
     property OnGetParameterType : TGetParamTypeEvent Read FOnGetParamType Write FOnGetParamType;
     property OnGetParameterType : TGetParamTypeEvent Read FOnGetParamType Write FOnGetParamType;
+    property OnGetParameterValue : TGetParamValueEvent Read FOnGetParamValue Write FOnGetParamValue;
   Public
   Public
     Constructor Create(AOwner : TComponent); override;
     Constructor Create(AOwner : TComponent); override;
     Destructor Destroy; override;
     Destructor Destroy; override;
@@ -63,6 +67,7 @@ Type
     Property IDFieldName;
     Property IDFieldName;
     Property OnGetNewID;
     Property OnGetNewID;
     property OnGetParameterType;
     property OnGetParameterType;
+    property OnGetParameterValue;
     Property Options;
     Property Options;
   end;
   end;
 
 
@@ -206,13 +211,14 @@ begin
   Result.SQL.Assign(ASQL);
   Result.SQL.Assign(ASQL);
 end;
 end;
 
 
-procedure TCustomSQLDBWebDataProvider.CheckDataset;
+Function TCustomSQLDBWebDataProvider.CheckDataset : boolean;
 
 
 begin
 begin
 {$ifdef wmdebug}SendDebug('Entering CheckDataset');{$endif}
 {$ifdef wmdebug}SendDebug('Entering CheckDataset');{$endif}
   If (Trim(SelectSQL.Text)='') then
   If (Trim(SelectSQL.Text)='') then
     Raise EFPHTTPError.CreateFmt(SErrNoSelectSQL,[Self.Name]);
     Raise EFPHTTPError.CreateFmt(SErrNoSelectSQL,[Self.Name]);
-  If (FQuery=Nil) then
+  Result:=FQuery=Nil;
+  If (Result) then
     FQuery:=CreateQuery(Nil,Nil,SelectSQL)
     FQuery:=CreateQuery(Nil,Nil,SelectSQL)
   else if not FQuery.Active then
   else if not FQuery.Active then
     FQuery.SQL.Assign(SelectSQL);
     FQuery.SQL.Assign(SelectSQL);
@@ -311,20 +317,28 @@ var
   I: Integer;
   I: Integer;
   P : TParam;
   P : TParam;
   S : String;
   S : String;
+  B : Boolean;
+
 
 
 begin
 begin
 {$ifdef wmdebug}SendDebug('Entering ApplySQLPArams');{$endif}
 {$ifdef wmdebug}SendDebug('Entering ApplySQLPArams');{$endif}
   For I:=0 to AQuery.Params.Count-1 do
   For I:=0 to AQuery.Params.Count-1 do
     begin
     begin
     P:=AQuery.Params[i];
     P:=AQuery.Params[i];
-    If (P.Name=IDFieldName) and DoNewID then
-      SetTypedParam(P,GetNewID)
-    else If Adaptor.TryFieldValue(P.Name,S) then
-      SetTypedParam(P,S)
-    else If Adaptor.TryParamValue(P.Name,S) then
-      SetTypedParam(P,S)
-    else
-      P.Clear;
+    B:=Assigned(FOnGetParamValue);
+    if B then
+      FOnGetParamValue(Self,P,B);
+    if not B then
+      begin
+      If (P.Name=IDFieldName) and DoNewID then
+        SetTypedParam(P,GetNewID)
+      else If Adaptor.TryFieldValue(P.Name,S) then
+        SetTypedParam(P,S)
+      else If Adaptor.TryParamValue(P.Name,S) then
+        SetTypedParam(P,S)
+      else
+        P.Clear;
+      end;
     end;
     end;
 {$ifdef wmdebug}SendDebug('Exiting ApplySQLPArams');{$endif}
 {$ifdef wmdebug}SendDebug('Exiting ApplySQLPArams');{$endif}
 end;
 end;
@@ -336,6 +350,11 @@ begin
   ApplySQLParams(FQuery);
   ApplySQLParams(FQuery);
 end;
 end;
 
 
+function TCustomSQLDBWebDataProvider.SQLQuery: TSQLQuery;
+begin
+  Result:=FQuery;
+end;
+
 function TCustomSQLDBWebDataProvider.GetDataset: TDataset;
 function TCustomSQLDBWebDataProvider.GetDataset: TDataset;
 begin
 begin
 {$ifdef wmdebug}SendDebug('Get dataset: checking dataset');{$endif}
 {$ifdef wmdebug}SendDebug('Get dataset: checking dataset');{$endif}

+ 19 - 3
packages/gdbint/gen-gdblib-inc.sh

@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 
 if [ "$1" != "" ]; then
 if [ "$1" != "" ]; then
   destdir=$1
   destdir=$1
@@ -18,7 +18,13 @@ fi
 echo "Deleting gdb${EXEEXT} to force recompile"
 echo "Deleting gdb${EXEEXT} to force recompile"
 rm -f gdb${EXEEXT}
 rm -f gdb${EXEEXT}
 echo "Rebuilding gdb${EXEEXT}"
 echo "Rebuilding gdb${EXEEXT}"
-make gdb${EXEEXT} | tee make.log
+MAKE=`which gmake`
+
+if [ "${MAKE}" == "" ]; then
+  MAKE=make
+fi
+
+${MAKE} gdb${EXEEXT} | tee make.log
 
 
 gdb_full_version=`sed -n "s:.*version.*\"\(.*\)\".*:\1:p" version.c`
 gdb_full_version=`sed -n "s:.*version.*\"\(.*\)\".*:\1:p" version.c`
 gdbcvs=`sed -n "s:.*version.*\"\(.*\)cvs\(.*\)\".*:\1cvs\2:p" version.c`
 gdbcvs=`sed -n "s:.*version.*\"\(.*\)cvs\(.*\)\".*:\1cvs\2:p" version.c`
@@ -61,7 +67,7 @@ if ( doprint == 1 ) {
 echo Creating ./copy-libs.sh script
 echo Creating ./copy-libs.sh script
 cat comp-cmd.log |gawk -v destdir=${destdir} -v libdir=${libdir} '
 cat comp-cmd.log |gawk -v destdir=${destdir} -v libdir=${libdir} '
 BEGIN {
 BEGIN {
-  print "#!/bin/bash"
+  print "#!/usr/bin/env bash"
   print "# copy-libs.sh generated by awk script"
   print "# copy-libs.sh generated by awk script"
   print "if [ \"$1\" != \"\" ]; then"
   print "if [ \"$1\" != \"\" ]; then"
   print "  destdir=$1"
   print "  destdir=$1"
@@ -84,6 +90,10 @@ BEGIN {
   staticlib = gensub (/([^ ]*)(lib[^ ]*\.a)/,"\\1\\2 ","g",list[i]);
   staticlib = gensub (/([^ ]*)(lib[^ ]*\.a)/,"\\1\\2 ","g",list[i]);
   print "cp " staticlib " ${destdir}";
   print "cp " staticlib " ${destdir}";
   }
   }
+  if ( list[i] ~ /lib[^ ]*\.so/ ) {
+  dynamiclib = gensub (/([^ ]*)(lib[^ ]*\.so)/,"\\1\\2 ","g",list[i]);
+  print "echo " dynamiclib " found";
+  }
   if ( list[i] ~ /-l/ ) {
   if ( list[i] ~ /-l/ ) {
   systemlib = gensub (/-l([^ ]*)/,"lib\\1.a ","g",list[i]);
   systemlib = gensub (/-l([^ ]*)/,"lib\\1.a ","g",list[i]);
   print "systemlib=`find " libdir " -name " systemlib "`" ;
   print "systemlib=`find " libdir " -name " systemlib "`" ;
@@ -124,6 +134,12 @@ BEGIN {
     use_mingw=1
     use_mingw=1
     }
     }
   }
   }
+  if ( list[i] ~ /lib[^ ]*\.so/ ) {
+    dynamiclib = gensub (/([^ ]*)(lib[^ ]*\.so)/,"{$LINKLIB \\2} { found in \\1 }","g",list[i]);
+    librarypath = gensub (/([^ ]*)(lib[^ ]*\.so)/,"{$LIBRARYPATH \\1} { for \\2 }","g",list[i]);
+    print dynamiclib;
+    print librarypath;
+  }
   if ( list[i] ~ /-l/ ) {
   if ( list[i] ~ /-l/ ) {
     systemlib = gensub (/-l([^ ]*)/,"{$LINKLIB \\1} { with -l gcc option}","g",list[i]);
     systemlib = gensub (/-l([^ ]*)/,"{$LINKLIB \\1} { with -l gcc option}","g",list[i]);
     print systemlib;
     print systemlib;

+ 1 - 1
packages/gdbint/src/gdbcon.pp

@@ -330,7 +330,7 @@ var p : pchar;
 begin
 begin
   p:=gdberrorbuf.buf;
   p:=gdberrorbuf.buf;
   if (p^=#0) and got_error then
   if (p^=#0) and got_error then
-    GetError:=pchar(longint(gdboutputbuf.buf)+gdboutputbuf.idx)
+    GetError:=pchar(ptrint(gdboutputbuf.buf)+gdboutputbuf.idx)
   else
   else
     GetError:=p;
     GetError:=p;
 end;
 end;

+ 14 - 0
packages/gdbint/src/gdbint.pp

@@ -120,6 +120,19 @@ interface
   {$define GDB_HAS_BP_NONE}
   {$define GDB_HAS_BP_NONE}
 {$endif def GDB_V608}
 {$endif def GDB_V608}
 
 
+{ 7.2.x }
+{$ifdef GDB_V702}
+  {$info using gdb 7.2.x}
+  {$define GDB_V7}
+{$endif def GDB_V702}
+
+{ 7.1.x }
+{$ifdef GDB_V701}
+  {$info using gdb 7.1.x}
+  {$define GDB_V7}
+{$endif def GDB_V701}
+
+
 
 
 { 7.0.x }
 { 7.0.x }
 {$ifdef GDB_V700}
 {$ifdef GDB_V700}
@@ -2974,6 +2987,7 @@ var gdb_sysroot  : pchar; cvar;public;
     return_child_result : longbool;cvar;public;
     return_child_result : longbool;cvar;public;
     return_child_result_value : longint;cvar;public;
     return_child_result_value : longint;cvar;public;
     batch_silent : longbool;cvar;public;
     batch_silent : longbool;cvar;public;
+    batch_flag : longbool;cvar;public;
 {$endif}
 {$endif}
 {$ifdef GDB_HAS_DEBUG_FILE_DIRECTORY}
 {$ifdef GDB_HAS_DEBUG_FILE_DIRECTORY}
 var
 var

+ 114 - 148
packages/openal/examples/Makefile

@@ -2,7 +2,7 @@
 # Don't edit, this file is generated by FPCMake Version 2.0.0 [2010/08/25]
 # Don't edit, this file is generated by FPCMake Version 2.0.0 [2010/08/25]
 #
 #
 default: all
 default: all
-MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-solaris x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded mipsel-linux
+MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian i386-nativent m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-solaris x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded mipsel-linux
 BSDs = freebsd netbsd openbsd darwin
 BSDs = freebsd netbsd openbsd darwin
 UNIXs = linux $(BSDs) solaris qnx haiku
 UNIXs = linux $(BSDs) solaris qnx haiku
 LIMIT83fs = go32v2 os2 emx watcom
 LIMIT83fs = go32v2 os2 emx watcom
@@ -265,184 +265,187 @@ UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
 endif
 endif
 PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
 PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
 ifeq ($(FULL_TARGET),i386-linux)
 ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal  madopenal
 endif
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
 ifeq ($(FULL_TARGET),i386-go32v2)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),i386-win32)
 ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal  madopenal
 endif
 endif
 ifeq ($(FULL_TARGET),i386-os2)
 ifeq ($(FULL_TARGET),i386-os2)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
 ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),i386-beos)
 ifeq ($(FULL_TARGET),i386-beos)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),i386-haiku)
 ifeq ($(FULL_TARGET),i386-haiku)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
 ifeq ($(FULL_TARGET),i386-netbsd)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),i386-solaris)
 ifeq ($(FULL_TARGET),i386-solaris)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
 ifeq ($(FULL_TARGET),i386-qnx)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netware)
 ifeq ($(FULL_TARGET),i386-netware)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
 ifeq ($(FULL_TARGET),i386-openbsd)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
 ifeq ($(FULL_TARGET),i386-wdosx)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),i386-darwin)
 ifeq ($(FULL_TARGET),i386-darwin)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),i386-emx)
 ifeq ($(FULL_TARGET),i386-emx)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
 ifeq ($(FULL_TARGET),i386-watcom)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
 ifeq ($(FULL_TARGET),i386-netwlibc)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),i386-wince)
 ifeq ($(FULL_TARGET),i386-wince)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),i386-embedded)
 ifeq ($(FULL_TARGET),i386-embedded)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),i386-symbian)
 ifeq ($(FULL_TARGET),i386-symbian)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
+endif
+ifeq ($(FULL_TARGET),i386-nativent)
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
 ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal  madopenal
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
 ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
 ifeq ($(FULL_TARGET),m68k-netbsd)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
 ifeq ($(FULL_TARGET),m68k-amiga)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
 ifeq ($(FULL_TARGET),m68k-atari)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
 ifeq ($(FULL_TARGET),m68k-openbsd)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
 ifeq ($(FULL_TARGET),m68k-palmos)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-embedded)
 ifeq ($(FULL_TARGET),m68k-embedded)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
 ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal  madopenal
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
 ifeq ($(FULL_TARGET),powerpc-netbsd)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-amiga)
 ifeq ($(FULL_TARGET),powerpc-amiga)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
 ifeq ($(FULL_TARGET),powerpc-macos)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
 ifeq ($(FULL_TARGET),powerpc-darwin)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
 ifeq ($(FULL_TARGET),powerpc-morphos)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 ifeq ($(FULL_TARGET),powerpc-embedded)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
 ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal  madopenal
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
 ifeq ($(FULL_TARGET),sparc-netbsd)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-solaris)
 ifeq ($(FULL_TARGET),sparc-solaris)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-embedded)
 ifeq ($(FULL_TARGET),sparc-embedded)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
 ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal  madopenal
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-solaris)
 ifeq ($(FULL_TARGET),x86_64-solaris)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 ifeq ($(FULL_TARGET),x86_64-darwin)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-win64)
 ifeq ($(FULL_TARGET),x86_64-win64)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-embedded)
 ifeq ($(FULL_TARGET),x86_64-embedded)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),arm-linux)
 ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal  madopenal
 endif
 endif
 ifeq ($(FULL_TARGET),arm-palmos)
 ifeq ($(FULL_TARGET),arm-palmos)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),arm-darwin)
 ifeq ($(FULL_TARGET),arm-darwin)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),arm-wince)
 ifeq ($(FULL_TARGET),arm-wince)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),arm-gba)
 ifeq ($(FULL_TARGET),arm-gba)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),arm-nds)
 ifeq ($(FULL_TARGET),arm-nds)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),arm-embedded)
 ifeq ($(FULL_TARGET),arm-embedded)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),arm-symbian)
 ifeq ($(FULL_TARGET),arm-symbian)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
 ifeq ($(FULL_TARGET),powerpc64-linux)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal  madopenal
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-darwin)
 ifeq ($(FULL_TARGET),powerpc64-darwin)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-embedded)
 ifeq ($(FULL_TARGET),powerpc64-embedded)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),avr-embedded)
 ifeq ($(FULL_TARGET),avr-embedded)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),armeb-linux)
 ifeq ($(FULL_TARGET),armeb-linux)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal  madopenal
 endif
 endif
 ifeq ($(FULL_TARGET),armeb-embedded)
 ifeq ($(FULL_TARGET),armeb-embedded)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal
 endif
 endif
 ifeq ($(FULL_TARGET),mipsel-linux)
 ifeq ($(FULL_TARGET),mipsel-linux)
-override TARGET_PROGRAMS+=madopenal captureplaybackopenal
+override TARGET_PROGRAMS+=captureplaybackopenal wavopenal  madopenal
 endif
 endif
 override INSTALL_FPCPACKAGE=y
 override INSTALL_FPCPACKAGE=y
 ifdef REQUIRE_UNITSDIR
 ifdef REQUIRE_UNITSDIR
@@ -787,6 +790,10 @@ ifeq ($(OS_TARGET),symbian)
 SHAREDLIBEXT=.dll
 SHAREDLIBEXT=.dll
 SHORTSUFFIX=symbian
 SHORTSUFFIX=symbian
 endif
 endif
+ifeq ($(OS_TARGET),NativeNT)
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=nativent
+endif
 else
 else
 ifeq ($(OS_TARGET),go32v1)
 ifeq ($(OS_TARGET),go32v1)
 PPUEXT=.pp1
 PPUEXT=.pp1
@@ -1211,21 +1218,20 @@ else
 TAROPT=vz
 TAROPT=vz
 TAREXT=.tar.gz
 TAREXT=.tar.gz
 endif
 endif
-override REQUIRE_PACKAGES=rtl openal mad oggvorbis a52 dts modplug matroska
+override REQUIRE_PACKAGES=rtl openal oggvorbis a52 dts modplug matroska
 ifeq ($(FULL_TARGET),i386-linux)
 ifeq ($(FULL_TARGET),i386-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_MODPLUG=1
 REQUIRE_PACKAGES_MODPLUG=1
 REQUIRE_PACKAGES_MATROSKA=1
 REQUIRE_PACKAGES_MATROSKA=1
+REQUIRE_PACKAGES_MAD=1
 endif
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
 ifeq ($(FULL_TARGET),i386-go32v2)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1235,17 +1241,16 @@ endif
 ifeq ($(FULL_TARGET),i386-win32)
 ifeq ($(FULL_TARGET),i386-win32)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_MODPLUG=1
 REQUIRE_PACKAGES_MODPLUG=1
 REQUIRE_PACKAGES_MATROSKA=1
 REQUIRE_PACKAGES_MATROSKA=1
+REQUIRE_PACKAGES_MAD=1
 endif
 endif
 ifeq ($(FULL_TARGET),i386-os2)
 ifeq ($(FULL_TARGET),i386-os2)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1255,7 +1260,6 @@ endif
 ifeq ($(FULL_TARGET),i386-freebsd)
 ifeq ($(FULL_TARGET),i386-freebsd)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1265,7 +1269,6 @@ endif
 ifeq ($(FULL_TARGET),i386-beos)
 ifeq ($(FULL_TARGET),i386-beos)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1275,7 +1278,6 @@ endif
 ifeq ($(FULL_TARGET),i386-haiku)
 ifeq ($(FULL_TARGET),i386-haiku)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1285,7 +1287,6 @@ endif
 ifeq ($(FULL_TARGET),i386-netbsd)
 ifeq ($(FULL_TARGET),i386-netbsd)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1295,7 +1296,6 @@ endif
 ifeq ($(FULL_TARGET),i386-solaris)
 ifeq ($(FULL_TARGET),i386-solaris)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1305,7 +1305,6 @@ endif
 ifeq ($(FULL_TARGET),i386-qnx)
 ifeq ($(FULL_TARGET),i386-qnx)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1315,7 +1314,6 @@ endif
 ifeq ($(FULL_TARGET),i386-netware)
 ifeq ($(FULL_TARGET),i386-netware)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1325,7 +1323,6 @@ endif
 ifeq ($(FULL_TARGET),i386-openbsd)
 ifeq ($(FULL_TARGET),i386-openbsd)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1335,7 +1332,6 @@ endif
 ifeq ($(FULL_TARGET),i386-wdosx)
 ifeq ($(FULL_TARGET),i386-wdosx)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1345,7 +1341,6 @@ endif
 ifeq ($(FULL_TARGET),i386-darwin)
 ifeq ($(FULL_TARGET),i386-darwin)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1355,7 +1350,6 @@ endif
 ifeq ($(FULL_TARGET),i386-emx)
 ifeq ($(FULL_TARGET),i386-emx)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1365,7 +1359,6 @@ endif
 ifeq ($(FULL_TARGET),i386-watcom)
 ifeq ($(FULL_TARGET),i386-watcom)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1375,7 +1368,6 @@ endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
 ifeq ($(FULL_TARGET),i386-netwlibc)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1385,7 +1377,6 @@ endif
 ifeq ($(FULL_TARGET),i386-wince)
 ifeq ($(FULL_TARGET),i386-wince)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1395,7 +1386,6 @@ endif
 ifeq ($(FULL_TARGET),i386-embedded)
 ifeq ($(FULL_TARGET),i386-embedded)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1405,7 +1395,15 @@ endif
 ifeq ($(FULL_TARGET),i386-symbian)
 ifeq ($(FULL_TARGET),i386-symbian)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
+REQUIRE_PACKAGES_OGGVORBIS=1
+REQUIRE_PACKAGES_A52=1
+REQUIRE_PACKAGES_DTS=1
+REQUIRE_PACKAGES_MODPLUG=1
+REQUIRE_PACKAGES_MATROSKA=1
+endif
+ifeq ($(FULL_TARGET),i386-nativent)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1415,17 +1413,16 @@ endif
 ifeq ($(FULL_TARGET),m68k-linux)
 ifeq ($(FULL_TARGET),m68k-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_MODPLUG=1
 REQUIRE_PACKAGES_MODPLUG=1
 REQUIRE_PACKAGES_MATROSKA=1
 REQUIRE_PACKAGES_MATROSKA=1
+REQUIRE_PACKAGES_MAD=1
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
 ifeq ($(FULL_TARGET),m68k-freebsd)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1435,7 +1432,6 @@ endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
 ifeq ($(FULL_TARGET),m68k-netbsd)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1445,7 +1441,6 @@ endif
 ifeq ($(FULL_TARGET),m68k-amiga)
 ifeq ($(FULL_TARGET),m68k-amiga)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1455,7 +1450,6 @@ endif
 ifeq ($(FULL_TARGET),m68k-atari)
 ifeq ($(FULL_TARGET),m68k-atari)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1465,7 +1459,6 @@ endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
 ifeq ($(FULL_TARGET),m68k-openbsd)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1475,7 +1468,6 @@ endif
 ifeq ($(FULL_TARGET),m68k-palmos)
 ifeq ($(FULL_TARGET),m68k-palmos)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1485,7 +1477,6 @@ endif
 ifeq ($(FULL_TARGET),m68k-embedded)
 ifeq ($(FULL_TARGET),m68k-embedded)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1495,17 +1486,16 @@ endif
 ifeq ($(FULL_TARGET),powerpc-linux)
 ifeq ($(FULL_TARGET),powerpc-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_MODPLUG=1
 REQUIRE_PACKAGES_MODPLUG=1
 REQUIRE_PACKAGES_MATROSKA=1
 REQUIRE_PACKAGES_MATROSKA=1
+REQUIRE_PACKAGES_MAD=1
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
 ifeq ($(FULL_TARGET),powerpc-netbsd)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1515,7 +1505,6 @@ endif
 ifeq ($(FULL_TARGET),powerpc-amiga)
 ifeq ($(FULL_TARGET),powerpc-amiga)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1525,7 +1514,6 @@ endif
 ifeq ($(FULL_TARGET),powerpc-macos)
 ifeq ($(FULL_TARGET),powerpc-macos)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1535,7 +1523,6 @@ endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
 ifeq ($(FULL_TARGET),powerpc-darwin)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1545,7 +1532,6 @@ endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
 ifeq ($(FULL_TARGET),powerpc-morphos)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1555,7 +1541,6 @@ endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 ifeq ($(FULL_TARGET),powerpc-embedded)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1565,17 +1550,16 @@ endif
 ifeq ($(FULL_TARGET),sparc-linux)
 ifeq ($(FULL_TARGET),sparc-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_MODPLUG=1
 REQUIRE_PACKAGES_MODPLUG=1
 REQUIRE_PACKAGES_MATROSKA=1
 REQUIRE_PACKAGES_MATROSKA=1
+REQUIRE_PACKAGES_MAD=1
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
 ifeq ($(FULL_TARGET),sparc-netbsd)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1585,7 +1569,6 @@ endif
 ifeq ($(FULL_TARGET),sparc-solaris)
 ifeq ($(FULL_TARGET),sparc-solaris)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1595,7 +1578,6 @@ endif
 ifeq ($(FULL_TARGET),sparc-embedded)
 ifeq ($(FULL_TARGET),sparc-embedded)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1605,17 +1587,16 @@ endif
 ifeq ($(FULL_TARGET),x86_64-linux)
 ifeq ($(FULL_TARGET),x86_64-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_MODPLUG=1
 REQUIRE_PACKAGES_MODPLUG=1
 REQUIRE_PACKAGES_MATROSKA=1
 REQUIRE_PACKAGES_MATROSKA=1
+REQUIRE_PACKAGES_MAD=1
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1625,7 +1606,6 @@ endif
 ifeq ($(FULL_TARGET),x86_64-solaris)
 ifeq ($(FULL_TARGET),x86_64-solaris)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1635,7 +1615,6 @@ endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 ifeq ($(FULL_TARGET),x86_64-darwin)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1645,7 +1624,6 @@ endif
 ifeq ($(FULL_TARGET),x86_64-win64)
 ifeq ($(FULL_TARGET),x86_64-win64)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1655,7 +1633,6 @@ endif
 ifeq ($(FULL_TARGET),x86_64-embedded)
 ifeq ($(FULL_TARGET),x86_64-embedded)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1665,17 +1642,16 @@ endif
 ifeq ($(FULL_TARGET),arm-linux)
 ifeq ($(FULL_TARGET),arm-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_MODPLUG=1
 REQUIRE_PACKAGES_MODPLUG=1
 REQUIRE_PACKAGES_MATROSKA=1
 REQUIRE_PACKAGES_MATROSKA=1
+REQUIRE_PACKAGES_MAD=1
 endif
 endif
 ifeq ($(FULL_TARGET),arm-palmos)
 ifeq ($(FULL_TARGET),arm-palmos)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1685,7 +1661,6 @@ endif
 ifeq ($(FULL_TARGET),arm-darwin)
 ifeq ($(FULL_TARGET),arm-darwin)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1695,7 +1670,6 @@ endif
 ifeq ($(FULL_TARGET),arm-wince)
 ifeq ($(FULL_TARGET),arm-wince)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1705,7 +1679,6 @@ endif
 ifeq ($(FULL_TARGET),arm-gba)
 ifeq ($(FULL_TARGET),arm-gba)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1715,7 +1688,6 @@ endif
 ifeq ($(FULL_TARGET),arm-nds)
 ifeq ($(FULL_TARGET),arm-nds)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1725,7 +1697,6 @@ endif
 ifeq ($(FULL_TARGET),arm-embedded)
 ifeq ($(FULL_TARGET),arm-embedded)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1735,7 +1706,6 @@ endif
 ifeq ($(FULL_TARGET),arm-symbian)
 ifeq ($(FULL_TARGET),arm-symbian)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1745,17 +1715,16 @@ endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
 ifeq ($(FULL_TARGET),powerpc64-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_MODPLUG=1
 REQUIRE_PACKAGES_MODPLUG=1
 REQUIRE_PACKAGES_MATROSKA=1
 REQUIRE_PACKAGES_MATROSKA=1
+REQUIRE_PACKAGES_MAD=1
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-darwin)
 ifeq ($(FULL_TARGET),powerpc64-darwin)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1765,7 +1734,6 @@ endif
 ifeq ($(FULL_TARGET),powerpc64-embedded)
 ifeq ($(FULL_TARGET),powerpc64-embedded)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1775,7 +1743,6 @@ endif
 ifeq ($(FULL_TARGET),avr-embedded)
 ifeq ($(FULL_TARGET),avr-embedded)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1785,17 +1752,16 @@ endif
 ifeq ($(FULL_TARGET),armeb-linux)
 ifeq ($(FULL_TARGET),armeb-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_MODPLUG=1
 REQUIRE_PACKAGES_MODPLUG=1
 REQUIRE_PACKAGES_MATROSKA=1
 REQUIRE_PACKAGES_MATROSKA=1
+REQUIRE_PACKAGES_MAD=1
 endif
 endif
 ifeq ($(FULL_TARGET),armeb-embedded)
 ifeq ($(FULL_TARGET),armeb-embedded)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
@@ -1805,12 +1771,12 @@ endif
 ifeq ($(FULL_TARGET),mipsel-linux)
 ifeq ($(FULL_TARGET),mipsel-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_OPENAL=1
 REQUIRE_PACKAGES_OPENAL=1
-REQUIRE_PACKAGES_MAD=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_OGGVORBIS=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_A52=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_DTS=1
 REQUIRE_PACKAGES_MODPLUG=1
 REQUIRE_PACKAGES_MODPLUG=1
 REQUIRE_PACKAGES_MATROSKA=1
 REQUIRE_PACKAGES_MATROSKA=1
+REQUIRE_PACKAGES_MAD=1
 endif
 endif
 ifdef REQUIRE_PACKAGES_RTL
 ifdef REQUIRE_PACKAGES_RTL
 PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/Makefile.fpc,$(PACKAGESDIR))))))
 PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/Makefile.fpc,$(PACKAGESDIR))))))
@@ -1864,32 +1830,6 @@ ifdef UNITDIR_OPENAL
 override COMPILER_UNITDIR+=$(UNITDIR_OPENAL)
 override COMPILER_UNITDIR+=$(UNITDIR_OPENAL)
 endif
 endif
 endif
 endif
-ifdef REQUIRE_PACKAGES_MAD
-PACKAGEDIR_MAD:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /mad/Makefile.fpc,$(PACKAGESDIR))))))
-ifneq ($(PACKAGEDIR_MAD),)
-ifneq ($(wildcard $(PACKAGEDIR_MAD)/units/$(TARGETSUFFIX)),)
-UNITDIR_MAD=$(PACKAGEDIR_MAD)/units/$(TARGETSUFFIX)
-else
-UNITDIR_MAD=$(PACKAGEDIR_MAD)
-endif
-ifdef CHECKDEPEND
-$(PACKAGEDIR_MAD)/$(FPCMADE):
-	$(MAKE) -C $(PACKAGEDIR_MAD) $(FPCMADE)
-override ALLDEPENDENCIES+=$(PACKAGEDIR_MAD)/$(FPCMADE)
-endif
-else
-PACKAGEDIR_MAD=
-UNITDIR_MAD:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /mad/Package.fpc,$(UNITSDIR)))))
-ifneq ($(UNITDIR_MAD),)
-UNITDIR_MAD:=$(firstword $(UNITDIR_MAD))
-else
-UNITDIR_MAD=
-endif
-endif
-ifdef UNITDIR_MAD
-override COMPILER_UNITDIR+=$(UNITDIR_MAD)
-endif
-endif
 ifdef REQUIRE_PACKAGES_OGGVORBIS
 ifdef REQUIRE_PACKAGES_OGGVORBIS
 PACKAGEDIR_OGGVORBIS:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /oggvorbis/Makefile.fpc,$(PACKAGESDIR))))))
 PACKAGEDIR_OGGVORBIS:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /oggvorbis/Makefile.fpc,$(PACKAGESDIR))))))
 ifneq ($(PACKAGEDIR_OGGVORBIS),)
 ifneq ($(PACKAGEDIR_OGGVORBIS),)
@@ -2020,6 +1960,32 @@ ifdef UNITDIR_MATROSKA
 override COMPILER_UNITDIR+=$(UNITDIR_MATROSKA)
 override COMPILER_UNITDIR+=$(UNITDIR_MATROSKA)
 endif
 endif
 endif
 endif
+ifdef REQUIRE_PACKAGES_MAD
+PACKAGEDIR_MAD:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /mad/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_MAD),)
+ifneq ($(wildcard $(PACKAGEDIR_MAD)/units/$(TARGETSUFFIX)),)
+UNITDIR_MAD=$(PACKAGEDIR_MAD)/units/$(TARGETSUFFIX)
+else
+UNITDIR_MAD=$(PACKAGEDIR_MAD)
+endif
+ifdef CHECKDEPEND
+$(PACKAGEDIR_MAD)/$(FPCMADE):
+	$(MAKE) -C $(PACKAGEDIR_MAD) $(FPCMADE)
+override ALLDEPENDENCIES+=$(PACKAGEDIR_MAD)/$(FPCMADE)
+endif
+else
+PACKAGEDIR_MAD=
+UNITDIR_MAD:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /mad/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_MAD),)
+UNITDIR_MAD:=$(firstword $(UNITDIR_MAD))
+else
+UNITDIR_MAD=
+endif
+endif
+ifdef UNITDIR_MAD
+override COMPILER_UNITDIR+=$(UNITDIR_MAD)
+endif
+endif
 ifndef NOCPUDEF
 ifndef NOCPUDEF
 override FPCOPTDEF=$(ARCH)
 override FPCOPTDEF=$(ARCH)
 endif
 endif

+ 6 - 2
packages/openal/examples/Makefile.fpc

@@ -3,10 +3,14 @@
 #
 #
 
 
 [target]
 [target]
-programs=madopenal captureplaybackopenal
+programs=captureplaybackopenal wavopenal
+programs_linux=madopenal
+programs_win32=madopenal
 
 
 [require]
 [require]
-packages=openal mad oggvorbis a52 dts modplug matroska
+packages=openal oggvorbis a52 dts modplug matroska
+packages_linux=mad
+packages_win32=mad
 
 
 [install]
 [install]
 fpcpackage=y
 fpcpackage=y

+ 330 - 0
packages/openal/examples/wavopenal.pas

@@ -0,0 +1,330 @@
+(* WavOpenAL - OpenAL wave playing example
+
+ Copyright (c) 2010 Dmitry Boyarintsev
+
+ 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.
+
+  WaveOpenAL is based on MadOpenAL playing sample.
+  Yhe wavopenal program accepts a single .wav file name as a parameter and
+  plays it using openal until the end.
+
+*)
+program wavopenal;
+
+{$mode objfpc}
+
+uses
+  classes, sysutils, openal;
+
+// WAVE UTILS   
+  
+type
+  TRiffHeader = packed record
+    ID      : array [0..3] of char;
+    Size    : LongWord;
+    Format  : array [0..3] of char;
+  end;
+
+  TWaveFormat = packed record
+    ID            : array [0..3] of char;
+    Size          : LongWord;
+    Format        : Word;
+    Channels      : Word;
+    SampleRate    : LongWord;
+    ByteRate      : LongWord;
+    BlockAlign    : Word;
+    BitsPerSample : Word;
+  end;
+
+  TDataChunk = packed record
+    Id      : array [0..3] of char;
+    Size    : LongWord;
+  end;
+
+type
+
+  { TWaveReader }
+
+  TWaveReader = class(TObject)
+  private
+    loaded    : Boolean;
+    chunkdata : TDataChunk;
+    chunkpos  : Int64;
+    pos       : Int64;
+    eof       : Boolean;
+    fStream   : TStream;
+
+  public
+    fmt   : TWaveFormat;
+    function LoadFromStream(AStream: TStream): Boolean;
+    function ReadBuf(var Buffer; BufferSize: Integer): Integer;
+  end;
+
+const
+  ID_RIFF = 'RIFF';
+  ID_WAVE = 'WAVE';
+  ID_fmt  = 'fmt ';
+  ID_data = 'data';
+
+{ TWaveReader }
+
+function TWaveReader.LoadFromStream(AStream:TStream):Boolean;
+var
+  riff  : TRiffHeader;
+begin
+  fStream:=AStream;
+  loaded:=True;
+  try
+    Result:=fStream.Read(riff, sizeof(riff))=sizeof(riff);
+    riff.Size:=LEtoN(riff.Size);
+    Result:=Result and (riff.ID=ID_RIFF) and (riff.Format=ID_WAVE);
+    if not Result then Exit;
+
+    Result:=fStream.Read(fmt, sizeof(fmt))=sizeof(fmt);
+    fmt.Size:=LEtoN(fmt.Size);
+    fmt.Format:=LEtoN(fmt.Format);
+    fmt.Channels:=LEtoN(fmt.Channels);
+    fmt.SampleRate:=LEtoN(fmt.SampleRate);
+    fmt.ByteRate:=LEtoN(fmt.ByteRate);
+    fmt.BlockAlign:=LEtoN(fmt.BlockAlign);
+    fmt.BitsPerSample:=LEtoN(fmt.BitsPerSample);
+    
+    Result:=fmt.ID=ID_fmt;
+    pos:=-1;
+  except
+    Result:=False;
+    Exit;
+  end;
+end;
+
+function Min(a,b: Integer): Integer;
+begin
+  if a<b then Result:=a
+  else Result:=b;
+end;
+
+function TWaveReader.ReadBuf(var Buffer;BufferSize:Integer):Integer;
+var
+  sz  : Integer;
+  p   : PByteArray;
+  i   : Integer;
+begin
+  FillChar(Buffer, BufferSize, 0);
+  Result:=0;
+  // all data read
+  if eof then Exit; 
+
+  p:=@Buffer;
+  i:=0;
+  while (not eof) and (i<bufferSize) do begin
+    if chunkpos>=chunkdata.Size then begin
+      if pos<0 then
+        fstream.Position:=sizeof(TRiffHeader)+Int64(fmt.Size)+sizeof(TDataChunk)
+     else
+        fstream.Position:=pos+chunkdata.size+SizeOf(chunkdata);
+
+      eof:=pos>=fStream.Size;
+      if not eof then begin
+        pos:=fStream.Position;
+        sz:=fstream.Read(chunkdata, sizeof(chunkdata));
+        chunkdata.Size:=LEtoN(chunkdata.Size);
+        if (sz<>sizeof(chunkdata)) or (chunkdata.Id<>ID_data) then
+          chunkpos:=chunkdata.Size
+        else
+          chunkpos:=0;
+      end;
+    end else begin
+      sz:=Min(BufferSize, chunkdata.Size-chunkpos);
+      fStream.Position:=pos+sizeof(chunkdata)+chunkpos;
+      sz:=fStream.Read(p[i], sz);
+      if sz<0 then Exit;
+      inc(chunkpos, sz);
+      inc(i, sz);
+    end;
+  end;
+  Result:=i;
+end;
+  
+// ------------------------ OPEN AL ----------------------
+
+var
+  source     : TStream;
+  codec_bs   : Longword;
+
+// openal
+const
+  // Note: if you lower the al_bufcount, then you have to modify the al_polltime also!
+  al_bufcount           = 4;
+  al_polltime           = 100;
+
+var
+  al_device   : PALCdevice;
+  al_context  : PALCcontext;
+  al_source   : ALuint;
+  al_format   : Integer;
+  al_buffers  : array[0..al_bufcount-1] of ALuint;
+  al_bufsize  : Longword;
+  al_readbuf  : Pointer;
+  al_rate     : Longword;
+  
+  wave       : TWaveReader;
+
+procedure alPlay;
+var
+  i: Integer;
+begin
+  alSourceStop(al_source);
+  alSourceRewind(al_source);
+  alSourcei(al_source, AL_BUFFER, 0);
+
+  for i := 0 to al_bufcount - 1 do
+  begin
+    if wave.ReadBuf(al_readbuf^, al_bufsize) = 0 then
+      Break;
+
+    alBufferData(al_buffers[i], al_format, al_readbuf, al_bufsize, al_rate);
+    alSourceQueueBuffers(al_source, 1, @al_buffers[i]);
+  end;
+
+  // Under windows, AL_LOOPING = AL_TRUE breaks queueing, no idea why
+  alSourcei(al_source, AL_LOOPING, AL_FALSE);
+  alSourcePlay(al_source);
+end;
+
+procedure alStop;
+begin
+  alSourceStop(al_source);
+  alSourceRewind(al_source);
+  alSourcei(al_source, AL_BUFFER, 0);
+end;
+
+function alProcess: Boolean;
+var
+  processed : ALint;
+  buffer    : ALuint;
+  sz        : Integer;
+begin
+  alGetSourcei(al_source, AL_BUFFERS_PROCESSED, processed);
+  while (processed > 0) and (processed <= al_bufcount) do
+  begin
+    Write('.');
+
+    alSourceUnqueueBuffers(al_source, 1, @buffer);
+
+    sz:=wave.ReadBuf(al_readbuf^, al_bufsize);
+    if sz <= 0 then
+    begin
+      Exit(False);
+    end;
+
+    alBufferData(buffer, al_format, al_readbuf, sz, al_rate);
+    alSourceQueueBuffers(al_source, 1, @buffer);
+
+    Dec(processed);
+  end;
+
+  Result := True;
+end;
+
+
+var
+  Filename: String;
+  queued  : Integer;
+  done    : Boolean;
+begin
+  // define codec
+  if (ParamCount<=0) or not FileExists(ParamStr(1)) then begin
+    writeln('please specify .wav file name');
+    Exit;
+  end;
+  FileName:=ParamStr(1);
+
+  source := TFileStream.Create(Filename, fmOpenRead);
+
+  // inittialize codec
+  wave:=TWaveReader.Create;
+  if not wave.LoadFromStream(source) then begin
+    writeln('unable to read WAVE format');
+    Exit;
+  end;
+  if wave.fmt.Format<>1 then begin
+    writeln('WAVE file is using compression. Cannot play sorry. Please provide uncompressed .wav');
+    Exit;
+  end;
+  if wave.fmt.Channels=2 then begin
+    if wave.fmt.BitsPerSample=8 then al_format:=AL_FORMAT_STEREO8
+    else al_format:=AL_FORMAT_STEREO16
+  end else begin
+    if wave.fmt.BitsPerSample=8 then al_format:=AL_FORMAT_MONO8
+    else al_format:=AL_FORMAT_MONO16
+  end;
+  
+  codec_bs:=2*wave.fmt.Channels;
+
+  //al_bufsize := 20000 - (20000 mod codec_bs);
+  al_bufsize := 20000 - (20000 mod codec_bs);
+  al_rate:=wave.fmt.SampleRate;
+  WriteLn('Blocksize    : ', codec_bs);
+  WriteLn('Rate         : ', wave.fmt.SampleRate);
+  WriteLn('Channels     : ', wave.fmt.Channels);
+  WriteLn('OpenAL Buffers     : ', al_bufcount);
+  WriteLn('OpenAL Buffer Size : ', al_bufsize);
+
+  // init openal
+  al_device := alcOpenDevice(nil);
+  al_context := alcCreateContext(al_device, nil);
+  alcMakeContextCurrent(al_context);
+
+  alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED);
+  alGenSources(1, @al_source);
+  alGenBuffers(al_bufcount, @al_buffers);
+
+  GetMem(al_readbuf, al_bufsize);
+
+
+  // play loop
+  alPlay;
+
+  done:=False;
+  queued:=0;
+  repeat
+    if alProcess then begin
+      alGetSourcei(al_source, AL_BUFFERS_QUEUED, queued);
+      done:=queued=0;
+    end;
+    Sleep(al_polltime);
+  until done;
+
+  alStop;
+
+  // finalize openal
+  alDeleteSources(1, @al_source);
+  alDeleteBuffers(al_bufcount, @al_buffers);
+  alcDestroyContext(al_context);
+  alcCloseDevice(al_device);
+  FreeMem(al_readbuf);
+
+
+  // finalize codec
+  wave.Free;
+  
+  // close file
+  source.Free;
+end.

+ 4 - 2
packages/openal/src/openal.pas

@@ -16,7 +16,7 @@ uses
   {$DEFINE DYNLINK}
   {$DEFINE DYNLINK}
 {$ENDIF}
 {$ENDIF}
 
 
-{$IFDEF DYNLINK}
+{$IF Defined(DYNLINK)}
 const
 const
 {$IF Defined(WINDOWS)}
 {$IF Defined(WINDOWS)}
   openallib = 'openal32.dll';
   openallib = 'openal32.dll';
@@ -25,6 +25,8 @@ const
 {$ELSE}
 {$ELSE}
   {$MESSAGE ERROR 'DYNLINK not supported'}
   {$MESSAGE ERROR 'DYNLINK not supported'}
 {$IFEND}
 {$IFEND}
+{$ELSEIF Defined(Darwin)}
+{$linkframework OpenAL}
 {$ELSE}
 {$ELSE}
   {$LINKLIB openal}
   {$LINKLIB openal}
 {$ENDIF}
 {$ENDIF}
@@ -35,4 +37,4 @@ const
 
 
 implementation
 implementation
 
 
-end.
+end.

+ 1 - 2
packages/pthreads/src/pthrsnos.inc

@@ -190,7 +190,6 @@ const
 type
 type
    _Voidfp = procedure (_para1:pointer);cdecl;
    _Voidfp = procedure (_para1:pointer);cdecl;
   _fp = procedure;cdecl;
   _fp = procedure;cdecl;
-  P_Voidfp = ^_Voidfp;
 
 
 
 
 procedure __pthread_cleanup_push(_para1:_Voidfp; _para2:pointer; _para3:caddr_t; _para4:P_cleanup_t);cdecl;external External_library name '__pthread_cleanup_push';
 procedure __pthread_cleanup_push(_para1:_Voidfp; _para2:pointer; _para3:caddr_t; _para4:P_cleanup_t);cdecl;external External_library name '__pthread_cleanup_push';
@@ -226,7 +225,7 @@ function pthread_attr_setschedparam(_RESTRICT_KYWD1:Ppthread_attr_t; _RESTRICT_K
 (* Const before type ignored *)
 (* Const before type ignored *)
 function pthread_attr_getschedparam(_RESTRICT_KYWD1:Ppthread_attr_t; _RESTRICT_KYWD2:Psched_param):longint;cdecl;external External_library name 'pthread_attr_getschedparam';
 function pthread_attr_getschedparam(_RESTRICT_KYWD1:Ppthread_attr_t; _RESTRICT_KYWD2:Psched_param):longint;cdecl;external External_library name 'pthread_attr_getschedparam';
 (* Const before type ignored *)
 (* Const before type ignored *)
-function pthread_create(_RESTRICT_KYWD1:Ppthread_t; _RESTRICT_KYWD2:Ppthread_attr_t; _para3:P_Voidfp ; _RESTRICT_KYWD3:pointer):longint;cdecl;external External_library name 'pthread_create';
+function pthread_create(_RESTRICT_KYWD1:Ppthread_t; _RESTRICT_KYWD2:Ppthread_attr_t; _para3:_Voidfp ; _RESTRICT_KYWD3:pointer):longint;cdecl;external External_library name 'pthread_create';
 function pthread_once(_para1:Ppthread_once_t; _para2:_fp ):longint;cdecl;external External_library name 'pthread_once';
 function pthread_once(_para1:Ppthread_once_t; _para2:_fp ):longint;cdecl;external External_library name 'pthread_once';
 function pthread_join(_para1:pthread_t; _para2:Ppointer):longint;cdecl;external External_library name 'pthread_join';
 function pthread_join(_para1:pthread_t; _para2:Ppointer):longint;cdecl;external External_library name 'pthread_join';
 function pthread_detach(_para1:pthread_t):longint;cdecl;external External_library name 'pthread_detach';
 function pthread_detach(_para1:pthread_t):longint;cdecl;external External_library name 'pthread_detach';

+ 7 - 0
rtl/inc/genmath.inc

@@ -1403,6 +1403,13 @@ function fpc_int64_to_double(i : int64): double; compilerproc;
          exponent : word;
          exponent : word;
 
 
       begin
       begin
+         { check for zero }
+         if r[0]=0 then
+           begin
+             real2double:=0.0;
+             exit;
+           end;
+
          { copy mantissa }
          { copy mantissa }
          res[0]:=0;
          res[0]:=0;
          res[1]:=r[1] shl 5;
          res[1]:=r[1] shl 5;

+ 33 - 24
rtl/inc/heap.inc

@@ -1059,34 +1059,42 @@ var
   chunksize: ptruint;
   chunksize: ptruint;
   poc: poschunk;
   poc: poschunk;
   pmc_next: pmemchunk_fixed;
   pmc_next: pmemchunk_fixed;
+  pocfreelists: pfreelists;
 begin
 begin
   poc := poschunk(pointer(pmc)-(pmc^.size shr fixedoffsetshift));
   poc := poschunk(pointer(pmc)-(pmc^.size shr fixedoffsetshift));
+  { start memory access to poc^.freelists already }
+  pocfreelists := poc^.freelists;
   chunksize := pmc^.size and fixedsizemask;
   chunksize := pmc^.size and fixedsizemask;
-  if loc_freelists <> poc^.freelists then
-  begin
-    { deallocated in wrong thread! add to to-be-freed list of correct thread }
-    waitfree_fixed(pmc, poc);
-    exit(chunksize);
-  end;
+  if loc_freelists = pocfreelists then
+    begin
+      { decrease used blocks count (well in advance of poc^.used check below,
+        to avoid stalling due to a dependency) }
+      dec(poc^.used);
 
 
-  dec(loc_freelists^.internal_status.currheapused, chunksize);
-  { insert the block in its freelist }
-  chunkindex := chunksize shr blockshift;
-  pmc_next := loc_freelists^.fixedlists[chunkindex];
-  pmc^.prev_fixed := nil;
-  pmc^.next_fixed := pmc_next;
-  if assigned(pmc_next) then
-    pmc_next^.prev_fixed := pmc;
-  loc_freelists^.fixedlists[chunkindex] := pmc;
-  { decrease used blocks count }
-  dec(poc^.used);
-  if poc^.used <= 0 then
+      { insert the block in its freelist }
+      chunkindex := chunksize shr blockshift;
+      pmc_next := loc_freelists^.fixedlists[chunkindex];
+      pmc^.prev_fixed := nil;
+      pmc^.next_fixed := pmc_next;
+      if assigned(pmc_next) then
+        pmc_next^.prev_fixed := pmc;
+      loc_freelists^.fixedlists[chunkindex] := pmc;
+
+      dec(loc_freelists^.internal_status.currheapused, chunksize);
+
+      if poc^.used <= 0 then
+        begin
+          { decrease used blocks count }
+          if poc^.used<0 then
+            HandleError(204);
+          { osblock can be freed? }
+          append_to_oslist(poc);
+        end;
+    end
+  else
     begin
     begin
-      { decrease used blocks count }
-      if poc^.used<0 then
-        HandleError(204);
-      { osblock can be freed? }
-      append_to_oslist(poc);
+      { deallocated in wrong thread! add to to-be-freed list of correct thread }
+      waitfree_fixed(pmc, poc);
     end;
     end;
   result := chunksize;
   result := chunksize;
 end;
 end;
@@ -1103,13 +1111,13 @@ begin
     exit(chunksize);
     exit(chunksize);
   end;
   end;
 
 
-  dec(loc_freelists^.internal_status.currheapused, chunksize);
   { insert the block in it's freelist }
   { insert the block in it's freelist }
   pmcv^.size := pmcv^.size and (not usedflag);
   pmcv^.size := pmcv^.size and (not usedflag);
   append_to_list_var(pmcv);
   append_to_list_var(pmcv);
   pmcv := try_concat_free_chunk(pmcv);
   pmcv := try_concat_free_chunk(pmcv);
   if (pmcv^.size and (firstblockflag or lastblockflag)) = (firstblockflag or lastblockflag) then
   if (pmcv^.size and (firstblockflag or lastblockflag)) = (firstblockflag or lastblockflag) then
     append_to_oslist_var(pmcv);
     append_to_oslist_var(pmcv);
+  dec(loc_freelists^.internal_status.currheapused, chunksize);
   result := chunksize;
   result := chunksize;
 end;
 end;
 
 
@@ -1138,6 +1146,7 @@ begin
 {$endif}
 {$endif}
   { loc_freelists is a threadvar, so it can be worth it to prefetch }
   { loc_freelists is a threadvar, so it can be worth it to prefetch }
   loc_freelists := @freelists;
   loc_freelists := @freelists;
+  prefetch(loc_freelists^.internal_status.currheapused);
   { check if this is a fixed- or var-sized chunk }
   { check if this is a fixed- or var-sized chunk }
   if (pmc^.size and fixedsizeflag) = 0 then
   if (pmc^.size and fixedsizeflag) = 0 then
     result := sysfreemem_var(loc_freelists, pmemchunk_var(p-sizeof(tmemchunk_var_hdr)))
     result := sysfreemem_var(loc_freelists, pmemchunk_var(p-sizeof(tmemchunk_var_hdr)))

+ 42 - 14
rtl/inc/sstrings.inc

@@ -1177,6 +1177,37 @@ end;
 {$endif}
 {$endif}
 
 
 function fpc_val_enum_shortstr(str2ordindex:pointer;const s:shortstring;out code:valsint):longint; [public, alias:'FPC_VAL_ENUM_SHORTSTR']; compilerproc;
 function fpc_val_enum_shortstr(str2ordindex:pointer;const s:shortstring;out code:valsint):longint; [public, alias:'FPC_VAL_ENUM_SHORTSTR']; compilerproc;
+    
+    function string_compare(const s1,s2:shortstring):sizeint;
+    
+    {We cannot use the > and < operators to compare a string here, because we if the string is
+     not found in the enum, we need to return the position of error in "code". Code equals the
+     highest matching character of all string compares, which is only known inside the string
+     comparison.}
+    
+    var i,l:byte;
+        c1,c2:char;
+    
+    begin
+      l:=length(s1);
+      if length(s1)>length(s2) then
+        l:=length(s2);
+      i:=1;
+      while i<=l do
+        begin
+          c1:=s1[i];
+          c2:=s2[i];
+          if c1<>c2 then
+            break;
+          inc(i);
+        end;
+      if i>code then
+        code:=i;
+      if i<=l then
+        string_compare:=byte(c1)-byte(c2)
+      else
+        string_compare:=length(s1)-length(s2);
+    end;
 
 
 type  Tsorted_array={$ifndef FPC_REQUIRES_PROPER_ALIGNMENT}packed{$endif}record
 type  Tsorted_array={$ifndef FPC_REQUIRES_PROPER_ALIGNMENT}packed{$endif}record
         o:longint;
         o:longint;
@@ -1184,6 +1215,7 @@ type  Tsorted_array={$ifndef FPC_REQUIRES_PROPER_ALIGNMENT}packed{$endif}record
       end;
       end;
 
 
 var l,h,m:cardinal;
 var l,h,m:cardinal;
+    c:sizeint;
     sorted_array:^Tsorted_array;
     sorted_array:^Tsorted_array;
     spaces:byte;
     spaces:byte;
     t:shortstring;
     t:shortstring;
@@ -1194,6 +1226,7 @@ begin
   {Val for numbers accepts spaces at the start, so lets do the same
   {Val for numbers accepts spaces at the start, so lets do the same
    for enums. Skip spaces at the start of the string.}
    for enums. Skip spaces at the start of the string.}
   spaces:=1;
   spaces:=1;
+  code:=1;
   while (spaces<=length(s)) and (s[spaces]=' ')  do
   while (spaces<=length(s)) and (s[spaces]=' ')  do
     inc(spaces);
     inc(spaces);
   t:=upcase(copy(s,spaces,255));
   t:=upcase(copy(s,spaces,255));
@@ -1203,28 +1236,23 @@ begin
   h:=Pcardinal(str2ordindex)^;
   h:=Pcardinal(str2ordindex)^;
   repeat
   repeat
     m:=(l+h) div 2;
     m:=(l+h) div 2;
-    if t>upcase(sorted_array[m-1].s^) then
+    c:=string_compare(t,upcase(sorted_array[m-1].s^));
+    if c>0 then
       l:=m+1
       l:=m+1
-    else if t<upcase(sorted_array[m-1].s^) then
+    else if c<0 then
       h:=m-1
       h:=m-1
     else
     else
       break;
       break;
     if l>h then
     if l>h then
-      goto error;
+      begin
+        {Not found...}
+        inc(code,spaces-1); {Add skipped spaces again.}
+        {The result of val in case of error is undefined, don't assign a function result.}
+        exit;
+      end;
   until false;
   until false;
   code:=0;
   code:=0;
   fpc_val_enum_shortstr:=sorted_array[m-1].o;
   fpc_val_enum_shortstr:=sorted_array[m-1].o;
-  exit;
-error:
-  {Not found. Find first error position. Take care of the string length.}
-  code:=1;
-  while (code<=length(s)) and (s[code]=sorted_array[m].s^[code]) do
-    inc(code);
-  if code>length(s) then
-    code:=length(s)+1;
-  inc(code,spaces-1); {Add skipped spaces again.}
-  {The result of val in case of error is undefined, don't assign a function
-   result.}
 end;
 end;
 
 
 {Redeclare fpc_val_enum_shortstr for internal use in the system unit.}
 {Redeclare fpc_val_enum_shortstr for internal use in the system unit.}

+ 41 - 37
rtl/objpas/classes/streams.inc

@@ -853,15 +853,15 @@ var
   readcount: Longint;
   readcount: Longint;
 begin
 begin
   if m_bReverted then
   if m_bReverted then
-      begin
-        Result := STG_E_REVERTED;
-        Exit;
-      end;
+    begin
+      Result := STG_E_REVERTED;
+      Exit;
+    end;
   if pv = nil then
   if pv = nil then
-  begin
-    Result := E_INVALIDARG;
-    Exit;
-  end;
+    begin
+      Result := STG_E_INVALIDPOINTER;
+      Exit;
+    end;
 
 
   readcount := FStream.Read(pv^, cb);
   readcount := FStream.Read(pv^, cb);
   if pcbRead <> nil then pcbRead^ := readcount;
   if pcbRead <> nil then pcbRead^ := readcount;
@@ -873,15 +873,15 @@ var
   writecount: Longint;
   writecount: Longint;
 begin
 begin
   if m_bReverted then
   if m_bReverted then
-      begin
-        Result := STG_E_REVERTED;
-        Exit;
-      end;
+    begin
+      Result := STG_E_REVERTED;
+      Exit;
+    end;
   if pv = nil then
   if pv = nil then
-  begin
-    Result := E_INVALIDARG;
-    Exit;
-  end;
+    begin
+      Result := STG_E_INVALIDPOINTER;
+      Exit;
+    end;
 
 
   writecount := FStream.Write(pv^, cb);
   writecount := FStream.Write(pv^, cb);
   if pcbWritten <> nil then pcbWritten^ := writecount;
   if pcbWritten <> nil then pcbWritten^ := writecount;
@@ -893,15 +893,19 @@ var
   newpos: Int64;
   newpos: Int64;
 begin
 begin
   if m_bReverted then
   if m_bReverted then
-      begin
-        Result := STG_E_REVERTED;
-        Exit;
-      end;
+    begin
+      Result := STG_E_REVERTED;
+      Exit;
+    end;
   case dwOrigin of
   case dwOrigin of
     STREAM_SEEK_SET: newpos := FStream.Seek(dlibMove, soBeginning);
     STREAM_SEEK_SET: newpos := FStream.Seek(dlibMove, soBeginning);
     STREAM_SEEK_CUR: newpos := FStream.Seek(dlibMove, soCurrent);
     STREAM_SEEK_CUR: newpos := FStream.Seek(dlibMove, soCurrent);
     STREAM_SEEK_END: newpos := FStream.Seek(dlibMove, soEnd);
     STREAM_SEEK_END: newpos := FStream.Seek(dlibMove, soEnd);
-    else begin Result := E_INVALIDARG; exit; end;
+    else 
+      begin 
+        Result := STG_E_INVALIDFUNCTION; 
+        Exit; 
+      end;
   end;
   end;
   if @libNewPosition <> nil then
   if @libNewPosition <> nil then
     libNewPosition := newpos;
     libNewPosition := newpos;
@@ -911,10 +915,10 @@ end;
 function TStreamAdapter.SetSize(libNewSize: Largeint): HResult; stdcall;
 function TStreamAdapter.SetSize(libNewSize: Largeint): HResult; stdcall;
 begin
 begin
   if m_bReverted then
   if m_bReverted then
-      begin
-        Result := STG_E_REVERTED;
-        Exit;
-      end;
+    begin
+      Result := STG_E_REVERTED;
+      Exit;
+    end;
   if libNewSize<0 then
   if libNewSize<0 then
     begin
     begin
       Result := STG_E_INVALIDFUNCTION;
       Result := STG_E_INVALIDFUNCTION;
@@ -936,10 +940,10 @@ var
   buffer : array[0..1023] of byte;
   buffer : array[0..1023] of byte;
 begin
 begin
   if m_bReverted then
   if m_bReverted then
-      begin
-        Result := STG_E_REVERTED;
-        Exit;
-      end;
+    begin
+      Result := STG_E_REVERTED;
+      Exit;
+    end;
 
 
   // the method is similar to TStream.CopyFrom => use CopyFrom implementation
   // the method is similar to TStream.CopyFrom => use CopyFrom implementation
   cbWritten := 0;
   cbWritten := 0;
@@ -994,10 +998,10 @@ end;
 function TStreamAdapter.Stat(out statstg: TStatStg; grfStatFlag: Longint): HResult; stdcall;
 function TStreamAdapter.Stat(out statstg: TStatStg; grfStatFlag: Longint): HResult; stdcall;
 begin
 begin
   if m_bReverted then
   if m_bReverted then
-      begin
-        Result := STG_E_REVERTED;
-        Exit;
-      end;
+    begin
+      Result := STG_E_REVERTED;
+      Exit;
+    end;
   if grfStatFlag in [STATFLAG_DEFAULT,STATFLAG_NOOPEN,STATFLAG_NONAME] then
   if grfStatFlag in [STATFLAG_DEFAULT,STATFLAG_NOOPEN,STATFLAG_NONAME] then
   begin
   begin
     if @statstg <> nil then
     if @statstg <> nil then
@@ -1021,10 +1025,10 @@ end;
 function TStreamAdapter.Clone(out stm: IStream): HResult; stdcall;
 function TStreamAdapter.Clone(out stm: IStream): HResult; stdcall;
 begin
 begin
   if m_bReverted then
   if m_bReverted then
-      begin
-        Result := STG_E_REVERTED;
-        Exit;
-      end;
+    begin
+      Result := STG_E_REVERTED;
+      Exit;
+    end;
   // don't raise an exception here return error value that function is not implemented
   // don't raise an exception here return error value that function is not implemented
   // to implement this we need a clone method for TStream class
   // to implement this we need a clone method for TStream class
   Result := STG_E_UNIMPLEMENTEDFUNCTION;
   Result := STG_E_UNIMPLEMENTEDFUNCTION;

+ 5 - 2
rtl/objpas/sysutils/sysformt.inc

@@ -298,8 +298,11 @@ begin
                   if CheckArg(vtWidestring,false) then
                   if CheckArg(vtWidestring,false) then
                     hs:=WideString(Args[doarg].VWideString)
                     hs:=WideString(Args[doarg].VWideString)
                 else
                 else
-                  if CheckArg(vtAnsiString,true) then
-                    hs:=ansistring(Args[doarg].VAnsiString);
+                  if CheckArg(vtAnsiString,false) then
+                    hs:=ansistring(Args[doarg].VAnsiString)
+                else
+                  if CheckArg(vtVariant,true) then
+                    hs:=Args[doarg].VVariant^;
                 Index:=Length(hs);
                 Index:=Length(hs);
                 If (Prec<>-1) and (Index>Prec) then
                 If (Prec<>-1) and (Index>Prec) then
                   Index:=Prec;
                   Index:=Prec;

+ 34 - 0
tests/webtbs/tw16787.pp

@@ -0,0 +1,34 @@
+{$ifdef fpc}{$mode objfpc}{$h+}{$endif}
+uses
+  Variants, SysUtils;
+
+var
+  v: Variant;
+  code: integer;
+
+begin
+  code := 0;
+  v := 10;
+  try
+    writeln(Format('%s', [v]));
+  except
+    ShowException(exceptObject, exceptAddr);
+    code := code or 1;
+  end;  
+  v := 'foo';
+  try
+    writeln(Format('%s', [v]));
+  except
+    ShowException(exceptObject, exceptAddr);
+    code := code or 2;
+  end;  
+  v := 1.5;
+  try
+    writeln(Format('%s', [v]));
+  except
+    ShowException(exceptObject, exceptAddr);
+    code := code or 4;
+  end;
+  Halt(code);
+end.
+

+ 8 - 0
tests/webtbs/tw16863.pp

@@ -0,0 +1,8 @@
+var
+    d : double;
+    r : real48 = ($0, $0, $0, $0, $0, $0); 
+BEGIN
+    d := r;
+    if d<>0.0 then
+      halt(1);
+END.