[fpc-pascal] fpc 2.6.3 building i386 crosscompiler fails

2013-09-17 Thread Lukas Gradl

Hi!

Tried to build the current svn of FPC 2.6.3 (svn Revision 25507) on my  
Linux X86_64-box.


I did:
make distclean
make all FPC=
sudo make install PREFIX= FPC=

This worked so far, now I have the current svn as x86_64 compiler.

Then i did:
make clean
make all CPU_TARGET=i386

This produces an error:
fpmkunit.pp(437,17) Error: Forward declaration not solved "constructor  
TPackageVariant.Create(TCollection);"
fpmkunit.pp(438,16) Error: Forward declaration not solved "destructor  
TPackageVariant.Destroy;"
fpmkunit.pp(452,14) Error: Forward declaration not solved  
"TPackageVariants.GetActivePackageVariant:TPackageVariant;"
fpmkunit.pp(453,14) Error: Forward declaration not solved  
"TPackageVariants.GetDefaultPackageVariant:TPackageVariant;"
fpmkunit.pp(454,15) Error: Forward declaration not solved  
"TPackageVariants.SetActivePackageVariantName(AnsiString);"
fpmkunit.pp(455,15) Error: Forward declaration not solved  
"TPackageVariants.SetDefaultPackageVariantName(AnsiString);"
fpmkunit.pp(457,14) Error: Forward declaration not solved  
"TPackageVariants.GetOwner:TPersistent;"
fpmkunit.pp(459,14) Error: Forward declaration not solved  
"TPackageVariants.Add(AnsiString):TPackageVariant;"

fpmkunit.pp(7319) Fatal: There were 8 errors compiling module, stopping

Anyone an idea why?

regards
Lukas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] "Invalid field size" when using UIB with fpc 2.3.1

2008-09-08 Thread Lukas Gradl

Hi!

Just had to upgrade to fpc 2.3.1 for some reason.
But using fpc 2.3.1 UIB produces an "Invalid field size" error when 
trying to open a UIBDataset.


The same program works when using fpc 2.2.3.

For demonstrating the problem I created the following program:

When trying to open an UIBDataset I get an error: "EDatabaseError : 
Invalid field size : 4828"

Failes with: FPC 2.3.1 svn, UIB latest svn, Firebird 2.0, OS Ubuntu 8.04
Works with: FPC 2.2.3, UIB latest svn, Firebird 2.0, OS Ubuntu 8.04



program Project1;

{$mode Delphi}{$H+}

uses
  Classes, SysUtils, UIB, UIBLib, UIBDataset;

var IDB: TUIBDataBase;
ITrans: TUIBTransaction;
IQuery: TUIBDataSet;

begin
  IDB:=TUIBDataBase.Create(nil);
  ITrans:=TUIBTransaction.Create(nil);
  IQuery:=TUIBDataSet.Create(nil);
  IDB.DatabaseName:='DB.fdb';
  IDB.CharacterSet:=csISO8859_1;
  IDB.LibraryName:='libfbclient.so';
  IDB.UserName:='User';
  IDB.PassWord:='Pass';
  ITrans.DataBase:=IDB;
  ITrans.AutoStart:=false;
  ITrans.AutoStop:=false;
  IDB.Connected:=True;
  ITrans.StartTransaction;
  IQuery.DataBase:=IDB;
  IQuery.Transaction:=ITrans;
  IQuery.SQL.Text:='SELECT "DocID" FROM "Docs";';
  try
IQuery.Open;
  finally
if IQuery.Active then IQuery.Close;
if ITrans.InTransaction then ITrans.RollBack;
IDB.Connected:=False;
  end;
end.

Database-DDL:


CREATE DOMAIN "dm_Key" AS Integer
 DEFAULT 0
 NOT NULL
 CHECK (VALUE>=0)
;
CREATE DOMAIN "dm_TypID" AS Smallint
 DEFAULT 0
 NOT NULL
;

CREATE TABLE "Docs"(
  "DocID" "dm_Key" DEFAULT 0,
  "DocType" "dm_TypID" DEFAULT 0,
  PRIMARY KEY ("DocID")
);


anyone an idea how to proceed? Is this a bug somewhere? In UIB? In fpc? 
In my code?


Regards
Lukas

--

--
software security networks
Lukas Gradl 
Eduard-Bodem-Gasse 9
A - 6020 Innsbruck
Tel: +43-512-214040-0
Fax: +43-512-214040-21
--
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] "Invalid field size" when using UIB with fpc 2.3.1

2008-09-08 Thread Lukas Gradl

Joost,

Thanks for your help.
I could find the problem in uibdataset.pas and fix it. Already sent a 
Bugreport and a fix to the UIB-Forum.


Thanks
Lukas

Joost van der Sluis schrieb:

Op maandag 08-09-2008 om 16:13 uur [tijdzone +0200], schreef Lukas
Gradl:

Just had to upgrade to fpc 2.3.1 for some reason.
But using fpc 2.3.1 UIB produces an "Invalid field size" error when 
trying to open a UIBDataset.


It's a bug in UIB. But it's a bug that most TDataset-descendents suffer
from. That's because the bug is hidden in Delphi. It is also hidden in
fpc's released versions, because it causes too much trouble. But this
"bug" does pop-ups in the development version. Until all
TDataset-descendents I know of have fixed it, it will be hidden in
released versions, though.


The same program works when using fpc 2.2.3.

For demonstrating the problem I created the following program:

When trying to open an UIBDataset I get an error: "EDatabaseError : 
Invalid field size : 4828"


Which is true, 4828 is an invalid field-size for an integer-field. I
guess that UIB doesn't set the field-size properly. In fact, the
'field-size' property should contain the amount of decimals in this
case. So the field-size should be set to 0.

Maybe you can look it up  in UIB where it's set?

Joost

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



--

--
software security networks
Lukas Gradl 
Eduard-Bodem-Gasse 9
A - 6020 Innsbruck
Tel: +43-512-214040-0
Fax: +43-512-214040-21
--
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] UIB on Linux X86_64

2008-09-08 Thread Lukas Gradl

Another problem occured:

When using UIB with fpc on X86_64 field values are always empty (for 
strings) or 0 (for integers).


For demonstrating the problem I created the following program:
Failes with: FPC 2.3.1 svn, UIB latest svn, Firebird 2.0, OS Ubuntu 8.04 
X86_64

OK with: FPC 2.3.1 svn, UIB latest svn, Firebird 2.0, OS Ubuntu 8.04 i386



program Project1;

{$mode Delphi}{$H+}

uses
  Classes, SysUtils, UIB, UIBLib, UIBDataset;

var IDB: TUIBDataBase;
ITrans: TUIBTransaction;
IQuery: TUIBDataSet;

begin
  IDB:=TUIBDataBase.Create(nil);
  ITrans:=TUIBTransaction.Create(nil);
  IQuery:=TUIBDataSet.Create(nil);
  IDB.DatabaseName:='DB.fdb';
  IDB.CharacterSet:=csISO8859_1;
  IDB.LibraryName:='libfbclient.so';
  IDB.UserName:='User';
  IDB.PassWord:='Pass';
  ITrans.DataBase:=IDB;
  ITrans.AutoStart:=false;
  ITrans.AutoStop:=false;
  IDB.Connected:=True;
  ITrans.StartTransaction;
  IQuery.DataBase:=IDB;
  IQuery.Transaction:=ITrans;
  IQuery.SQL.Text:='SELECT "DocID","DocName" FROM "Docs";';
  try
IQuery.Open;
IQuery.First;
while not IQuery.EOF do begin
  Writeln('Line found:'+IQuery.Fields[0].AsString+' 
'+IQuery.Fields[1].AsString);

  IQuery.Next;
end;
  finally
if IQuery.Active then IQuery.Close;
if ITrans.InTransaction then ITrans.RollBack;
IDB.Connected:=False;
  end;
end.


The DB-definition in Firebird 2.0 is as follows:

CREATE DOMAIN "dm_Key" AS Integer
 DEFAULT 0
 NOT NULL
 CHECK (VALUE>=0)
;
CREATE DOMAIN "dm_TypID" AS Smallint
 DEFAULT 0
 NOT NULL
;
CREATE DOMAIN "dm_Text" AS
VARCHAR(80) CHARACTER SET ISO8859_1
DEFAULT ''
COLLATE DE_DE
;

CREATE TABLE "Docs"(
  "DocID" "dm_Key" DEFAULT 0,
  "DocType" "dm_TypID" DEFAULT 0,
  "DocName" "dm_Text",
  PRIMARY KEY ("DocID")
);

INSERT INTO "Docs" ("DocID","DocType","DocName") VALUES 
(1,2,'DocNameTest');



When executed the output should be:

Line found: 1 DocNameTest


but instead you will get:

Line found: 0


Anyone an idea how to proceed?

regards
Lukas

--

--
software security networks
Lukas Gradl 
Eduard-Bodem-Gasse 9
A - 6020 Innsbruck
Tel: +43-512-214040-0
Fax: +43-512-214040-21
--
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] PACKENUM and MINENUMSIZE

2008-09-10 Thread Lukas Gradl

Hi!

Could anyone help me determining the defaults for MINENUMSIZE / PACKENUM?

As far as I could find in the docs it depends on $MODE: for $MODE OBJPAS 
it's 4 but I could'nt find the default for $MODE DELPHI.


Is there a difference between the CPU-Flavor used (i386 contra X64)?

AFAIK this seems to be the problem with UIB in X64 posted earlier but 
I'm not shure so far


regards
Lukas


--

--
software security networks
Lukas Gradl 
Eduard-Bodem-Gasse 9
A - 6020 Innsbruck
Tel: +43-512-214040-0
Fax: +43-512-214040-21
--
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] PACKENUM and MINENUMSIZE

2008-09-11 Thread Lukas Gradl
As far as i can understand the fpc sources it's in compiler/scanner.pas, 
line 359ff:


   { Default enum packing for delphi/tp7 }
   if (m_tp7 in current_settings.modeswitches) or
  (m_delphi in current_settings.modeswitches) then
 current_settings.packenum:=1
   else if (m_mac in current_settings.modeswitches) then
 { compatible with Metrowerks Pascal }
 current_settings.packenum:=2
   else
 current_settings.packenum:=4;

So it would be 1 fpr Delphi and TP7 mode, 2 for mac (don't know that) 
and 4 for all others.


Did a little test program on that. With {$mode objfpc} result is 4, with 
 {$mode delphi} result is 1. (And the most important for me: Its the 
solution to my problem with UIB - will post the reason as an answer to 
that posting!)


program Project1;

{$mode objfpc}
{$H+}

Uses SysUtils;

type
  TEnumTestType = (
etOne,
etTwo,
etThree,
etFour,
etFive,
etSix,
etSeven,
etEight,
etNine,
etTen,
etEleven,
etTwelve,
etThirteen,
etForteen
  );

var
  ET: TEnumTestType;

begin
  writeln(IntToStr(SizeOf(ET)));
end.

Regards
Lukas


Michael Van Canneyt schrieb:


On Thu, 11 Sep 2008, Marco van de Voort wrote:


In our previous episode, Michael Van Canneyt said:

As far as I could find in the docs it depends on $MODE: for $MODE OBJPAS it's
4 but I could'nt find the default for $MODE DELPHI.

Where did you read that this depends on $MODE ?
It just says that the default (contrary to Delphi) is 4.

Then the doc is wrong, since sizeof (enum with one element) is 1 in Delphi
mode.


No problem, if someone would tell me the exact behaviour, I will change it.

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



--

--
software security networks
Lukas Gradl 
Eduard-Bodem-Gasse 9
A - 6020 Innsbruck
Tel: +43-512-214040-0
Fax: +43-512-214040-21
--
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] PACKENUM and MINENUMSIZE

2008-09-11 Thread Lukas Gradl

Forgot to add: No difference between i386 and x64.

regards
Lukas

Lukas Gradl schrieb:
As far as i can understand the fpc sources it's in compiler/scanner.pas, 
line 359ff:


   { Default enum packing for delphi/tp7 }
   if (m_tp7 in current_settings.modeswitches) or
  (m_delphi in current_settings.modeswitches) then
 current_settings.packenum:=1
   else if (m_mac in current_settings.modeswitches) then
 { compatible with Metrowerks Pascal }
 current_settings.packenum:=2
   else
 current_settings.packenum:=4;

So it would be 1 fpr Delphi and TP7 mode, 2 for mac (don't know that) 
and 4 for all others.


Did a little test program on that. With {$mode objfpc} result is 4, with 
 {$mode delphi} result is 1. (And the most important for me: Its the 
solution to my problem with UIB - will post the reason as an answer to 
that posting!)


program Project1;

{$mode objfpc}
{$H+}

Uses SysUtils;

type
  TEnumTestType = (
etOne,
etTwo,
etThree,
etFour,
etFive,
etSix,
etSeven,
etEight,
etNine,
etTen,
etEleven,
etTwelve,
etThirteen,
etForteen
  );

var
  ET: TEnumTestType;

begin
  writeln(IntToStr(SizeOf(ET)));
end.

Regards
Lukas


Michael Van Canneyt schrieb:


On Thu, 11 Sep 2008, Marco van de Voort wrote:


In our previous episode, Michael Van Canneyt said:
As far as I could find in the docs it depends on $MODE: for $MODE 
OBJPAS it's

4 but I could'nt find the default for $MODE DELPHI.

Where did you read that this depends on $MODE ?
It just says that the default (contrary to Delphi) is 4.
Then the doc is wrong, since sizeof (enum with one element) is 1 in 
Delphi

mode.


No problem, if someone would tell me the exact behaviour, I will 
change it.


Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal





--

--
software security networks
Lukas Gradl 
Eduard-Bodem-Gasse 9
A - 6020 Innsbruck
Tel: +43-512-214040-0
Fax: +43-512-214040-21
--
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] UIB on Linux X86_64

2008-09-12 Thread Lukas Gradl

Solved the problem:

Its in uiblib.pas and uibase.pas:

{$IFNDEF CPU64}
  {$ALIGN ON}
  {$MINENUMSIZE 4}
{$ENDIF}

The MINENUMSIZE should be set always and not only for non-64bit CPUs as 
the source is compiled using {$mode delphi} - MINENUMSIZE is 1 by 
default for delphi.


So it should read:
{$IFNDEF CPU64}
  {$ALIGN ON}
{$ENDIF}
{$MINENUMSIZE 4}

Regards
Lukas
(already posted to the UIB-Forum, just for information here...)

Lukas Gradl schrieb:

Another problem occured:

When using UIB with fpc on X86_64 field values are always empty (for 
strings) or 0 (for integers).


For demonstrating the problem I created the following program:
Failes with: FPC 2.3.1 svn, UIB latest svn, Firebird 2.0, OS Ubuntu 8.04 
X86_64

OK with: FPC 2.3.1 svn, UIB latest svn, Firebird 2.0, OS Ubuntu 8.04 i386



program Project1;

{$mode Delphi}{$H+}

uses
  Classes, SysUtils, UIB, UIBLib, UIBDataset;

var IDB: TUIBDataBase;
ITrans: TUIBTransaction;
IQuery: TUIBDataSet;

begin
  IDB:=TUIBDataBase.Create(nil);
  ITrans:=TUIBTransaction.Create(nil);
  IQuery:=TUIBDataSet.Create(nil);
  IDB.DatabaseName:='DB.fdb';
  IDB.CharacterSet:=csISO8859_1;
  IDB.LibraryName:='libfbclient.so';
  IDB.UserName:='User';
  IDB.PassWord:='Pass';
  ITrans.DataBase:=IDB;
  ITrans.AutoStart:=false;
  ITrans.AutoStop:=false;
  IDB.Connected:=True;
  ITrans.StartTransaction;
  IQuery.DataBase:=IDB;
  IQuery.Transaction:=ITrans;
  IQuery.SQL.Text:='SELECT "DocID","DocName" FROM "Docs";';
  try
IQuery.Open;
IQuery.First;
while not IQuery.EOF do begin
  Writeln('Line found:'+IQuery.Fields[0].AsString+' 
'+IQuery.Fields[1].AsString);

  IQuery.Next;
end;
  finally
if IQuery.Active then IQuery.Close;
if ITrans.InTransaction then ITrans.RollBack;
IDB.Connected:=False;
  end;
end.


The DB-definition in Firebird 2.0 is as follows:

CREATE DOMAIN "dm_Key" AS Integer
 DEFAULT 0
 NOT NULL
 CHECK (VALUE>=0)
;
CREATE DOMAIN "dm_TypID" AS Smallint
 DEFAULT 0
 NOT NULL
;
CREATE DOMAIN "dm_Text" AS
VARCHAR(80) CHARACTER SET ISO8859_1
DEFAULT ''
COLLATE DE_DE
;

CREATE TABLE "Docs"(
  "DocID" "dm_Key" DEFAULT 0,
  "DocType" "dm_TypID" DEFAULT 0,
  "DocName" "dm_Text",
  PRIMARY KEY ("DocID")
);

INSERT INTO "Docs" ("DocID","DocType","DocName") VALUES 
(1,2,'DocNameTest');



When executed the output should be:

Line found: 1 DocNameTest


but instead you will get:

Line found: 0


Anyone an idea how to proceed?

regards
Lukas



--


software security networks
Lukas Gradl 
Eduard-Bodem-Gasse 9
A - 6020 Innsbruck
Tel: +43-512-214040-0
Fax: +43-512-214040-21

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] OT: Buy a Mac to develop for MacOS? Which one?

2008-10-11 Thread Lukas Gradl

Hi!

Having a customer request to port an app to MacOS I have to think about 
some test platform.

As I was never interested in MacOS this is virgin territory to me.

So perhaps some of the Mac-users here can help me out a bit:
I still want to use my current machines as them main ones, I just need a 
platform to compile and test my application on.


1.) Do I really need to buy a Mac? Or is there a good solution to 
emulate one on an x86 Linux box? Just crosscompiling without the 
possibility to do serious tests in house is not an option, as my app has 
to integrate in some hardware-subsystems (printing, networking).


2.) If 1=yes, which one would you recommend? Which hardware platform? 
Intel? PowerPC? It has to be OSX, do I have to care which version I get 
or is just any OSX ok for testing?


Perhaps some Mac-Developer out there could post his/her opinion...

regards
Lukas


--

--
software security networks
Lukas Gradl 
Eduard-Bodem-Gasse 9
A - 6020 Innsbruck
Tel: +43-512-214040-0
Fax: +43-512-214040-21
--
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] PostMessage() from a thread (in a thread save manner)

2008-10-20 Thread Lukas Gradl

Graeme Geldenhuys schrieb:

Some developers prefer to pass in a GUI component to a thread
instance, so the thread knows what widget to update. Other users
prefer to post a "gui update" message to the application event queue.

I'm very new to threads and might know just enough to make in
dangerous. :-)  In fpGUI the application's "custom" event queue is a
linked-list structure.  If threads post messages to that queue, I
obviously need to make the queue manipulation code thread safe.

fpgApplication is a global singleton of the TfpgApplication class.
fpgPostMessage() is a stand-alone function (not a member of
TfpgApplication class).  To make fpgPostMessage() thread save, I
instantiated a TCriticalSection instance in the TfpgApplication class
- in the constructor. I added two member functions .Lock and .Unlock
which calls FCritSect.Enter and FCritSect.Leave respectively.  In
fpgPostMessage, I call fpgApplication.Lock, then manipulate the
message queue and then call fpgApplication.Unlock.

Is this the correct way to make my event queue thread save?


It is - theoretically. I use threads quite a lot and found it a constant 
source of problems, to create a deadlock here and there when using the 
messagequeue or to forget some lock/unlock somewhere. (you will need 
more than PostMessage for your queue! *bg*)


I prefer to implement the messaging in the object it belongs to - in 
this case on fpgApplication. The Queue will not be visible from outside, 
only funcions like PostMessage, GetMessage or DiscardMessage. This way 
you can make shure, the lock/unlock sequence will be used correctly...


Regards
Lukas
(Just seen that Vincent was a bit faster than me, but with quite the 
same thougts...)



--

--
software security networks
Lukas Gradl 
Eduard-Bodem-Gasse 9
A - 6020 Innsbruck
Tel: +43-512-214040-0
Fax: +43-512-214040-21
--
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] CGI upload app

2008-11-04 Thread Lukas Gradl

Graeme Geldenhuys schrieb:

Hi Darius,

Did you ever manage to get an example of uploading a file?  I've got a
CGI app based on Powtils or PSP or whatever it's called these days. My
CGI app needs to permit uploading of files, but I got no idea how to
do it.

Regards,
  - Graeme -


You just want to upload a file to a server using a CGI running on that 
server?

I did this with cgiapp contained in the fpc-web package.

It's quite simple - if needed I could extract the relevant lines out of 
my (quite complex) CGI tomorrow and create a compilable example.


The relevant parts are:

uses cgiapp,...;



Type
  TYourNewCGI = Class(TCGIApplication)
Procedure DoRun; override;
  end;

.

procedure TYourNewCGI.DoRun;
Var RcvStream:TMemoryStream;
SndStream:TMemoryStream;
L:TStringList;
begin
  RcvStream:=TMemoryStream.Create;
  SndStream:=TMemoryStream.Create;
  L:=TStringList.Create;
  try
If (RequestVariableCount>0) then begin
  GetRequestVarList(L,True);
  for i:=0 to L.Count-1 do begin
if VariableIsUploadedFile(L[i]) then begin
  RcvStream.LoadFromFile(UploadedFileName(L[i]));
end;
  end;
end;
AddResponseLn('Content-Disposition: inline; filename="data.txt" 
 Content-Type: application/txt;');

AddResponseLn('');
SndStream.LoadFromFile('FileToSendBack.txt');
SndStream.Seek(0,soBeginning);
Response.CopyFrom(SndStream,SndStream.Size);
  finally
RcvStream.Free;
SndStream.Free;
L.Free;
Terminate;
  end;
end;

begin
  With TYourNewCGI.Create(Nil) do begin
try
  Title:='YourNewCGI';
  Initialize;
  Run;
Finally
  Free;
end;
  end;
end.


Regards
Lukas

--

--
software security networks
Lukas Gradl 
Eduard-Bodem-Gasse 9
A - 6020 Innsbruck
Tel: +43-512-214040-0
Fax: +43-512-214040-21
--
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Sockets in FPC

2009-02-18 Thread Lukas Gradl

Nataraj S Narayan schrieb:

Hi

I need to write a daemon on Linux which will wait on a user defined
port (say 3) and parse the socket input to write into a Mysql
database. Can anybody suggest examples in FPC ?

Presently , I am using TCL for this. The problem is the behaviour of
Gets function in TCL.. It is buffered with EOF as newline.

But i need the socket to have a user defined char like ':' and it
should be  unbuffered too. I mean dont want an Enter keyed to be at
the end.

We use various GPRS modules on embedded devices, each with its own
nuances of terminating a string. So we can't afford to have a 'normal'
gets or readln behaviours.


Take a look at synapse and the examples provided with the source and on 
their page. I remember there was a well documented example for a 
ftp-server, which uses exactly the techniques you need for building a 
service.


To daemonize a program on linux there are quite some examples on the net.

regards
Lukas

--

--
software security networks
Lukas Gradl 
Eduard-Bodem-Gasse 9
A - 6020 Innsbruck
Tel: +43-512-214040-0
Fax: +43-512-214040-21
--
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Howto create a (simple) PDF?

2009-03-30 Thread Lukas Gradl

Hello,

for an application I need a possibility to create a rather simple PDF 
(Just a few lines of text, if possible in 2 columns).



To do this I don't want to call an external program like latex or convert...

Does anybody know some library helping on that task?

regards
Lukas
--

--
software security networks
Lukas Gradl 
Eduard-Bodem-Gasse 9
A - 6020 Innsbruck
Tel: +43-512-214040-0
Fax: +43-512-214040-21
--
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] dll for Win64 - problems porting from win32

2009-12-15 Thread Lukas Gradl

Hi,

Some time ago I wrote a PrintMonitor-DLL for 32bit Windows.
Now I tried to port it to win64 using the svn-Version of FPC (did a 
checkout two days ago)
When I check the resulting DLL using Mitec-EXE-Explorer everything looks 
fine. The Main-Section of the DLL gets called, as well as the function 
InitializePrintMonitor which is exported by the DLL.

This function returns a pointer to a Structure containing the addresses
of some other functions.

For Win32 I compile with -Pi386 -TWin32, for Win64 I use -Px86_64 -TWin64

The resulting DLL works like a charm on Win32 and will crash the spooler 
on Win64.


Unfortunatly I was not able to produce a version of the source I can 
release without running into copyright issues, as I use some code 
contributed by someone else.


Perhaps someone has an idea what I could have missed?
Are there any open issues compiling DLLs for Win64?

regards
Lukas

--

--
software security networks
Lukas Gradl 
Eduard-Bodem-Gasse 5
A - 6020 Innsbruck
Tel: +43-512-214040-0
Fax: +43-512-214040-21
--
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Problem compiling DLL for 64Bit Windows - complete example attached

2009-12-17 Thread Lukas Gradl
e:LPWSTR;H:PHANDLE):BOOL;stdcall;
begin
  DbgSend('OpenPort');
end;

function StartDocPort(hPort:HANDLE;pPrinterName:LPWSTR;
  JobID,Level:DWORD;pDocInfo:LPBYTE):BOOL;stdcall;
begin
  DbgSend('StartDocPort');
end;

function WritePort(hPort:HANDLE;pBuffer:LPBYTE;cbBuf:DWORD;
   pcbWritten:LPDWORD):BOOL;stdcall;
begin
  DbgSend('WritePort');
end;

function ReadPort(hPort:HANDLE;pBuffer:LPBYTE;cbBuf:DWORD;
  pcbRead:LPDWORD):BOOL;stdcall;
begin
  DbgSend('ReadPort');
end;

function EndDocPort(hPort:HANDLE):BOOL;stdcall;
begin
  DbgSend('EndDocPort');
end;

function ClosePort(hPort:HANDLE):BOOL;stdcall;
begin
  DbgSend('ClosePort');
end;

function AddPort(pName:LPWSTR;h:HWND;pMonitorName:LPWSTR):BOOL;stdcall;
begin
  DbgSend('AddPort');
end;

function AddPortEx(pName:LPWSTR;Level:DWORD;pBuffer:LPBYTE;
   pMonitorName:LPWSTR):BOOL;stdcall;
begin
  DbgSend('AddPortEx');
end;

function ConfigurePort(pName:LPWSTR;h:HWND;
   pMonitorName:LPWSTR):BOOL;stdcall;
begin
  DbgSend('ConfigurePort');
end;

function DeletePort(pName:LPWSTR;h:HWND;
pMonitorName:LPWSTR):BOOL;stdcall;
begin
  DbgSend('DeletePort');
end;

function InitializePrintMonitor(pRegRoot:LPWSTR):pMonitorEx;stdcall;export;
begin
  DbgSend('InitializePrintMonitor start');
  Result:=...@mon;
  DbgSend('InitializePrintMonitor end');
end;

exports InitializePrintMonitor;

begin
  DbgSend('MainSection start');

  Mon.dwMonitorSize:=SizeOf(rMonitor);
  Mon.Monitor.pfnEnumPorts:=EnumPorts;
  Mon.Monitor.pfnOpenPort:=OpenPort;
  Mon.Monitor.pfnOpenPortEx:=nil;
  Mon.Monitor.pfnStartDocPort:=StartDocPort;
  Mon.Monitor.pfnWritePort:=WritePort;
  Mon.Monitor.pfnReadPort:=ReadPort;
  Mon.Monitor.pfnEndDocPort:=EndDocPort;
  Mon.Monitor.pfnClosePort:=ClosePort;
  Mon.Monitor.pfnAddPort:=AddPort;
  Mon.Monitor.pfnAddPortEx:=AddPortEx;
  Mon.Monitor.pfnConfigurePort:=ConfigurePort;
  Mon.Monitor.pfnDeletePort:=DeletePort;
  Mon.Monitor.pfnGetPrinterDataFromPort:=nil;
  Mon.Monitor.pfnSetPortTimeOuts:=nil;
  Mon.Monitor.pfnXcvOpenPort:=nil;
  Mon.Monitor.pfnXcvDataPort:=nil;
  Mon.Monitor.pfnXcvClosePort:=nil;

  DbgSend('MainSection end');
end.

End

I compiled it by the command
32Bit:
fpc -WB0 -MDelphi -B -O- -Os -CX -g- -XDs -Pi386 -TWin32 -vewi PMon64.lpr

and 64Bit.
fpc -WB0 -MDelphi -B -O- -Os -CX -g- -XDs -Px86_64 -TWin64 -vewi PMon64.lpr


The debug.txt on 32 Bit reads:
20:11:37: MainSection start
20:11:37: MainSection end
20:11:37: InitializePrintMonitor start
20:11:37: InitializePrintMonitor end
20:11:37: EnumPorts

The debug.txt on 64 Bit reads:
20:11:37: MainSection start
20:11:37: MainSection end
20:11:37: InitializePrintMonitor start
20:11:37: InitializePrintMonitor end
--> The EnumPorts-Entry is missing here!

so the crash is before or on calling the EnumPorts-Function.

So, anyone an Idea what I might have missed? Or is ther a bug in FPC for 
 Win64?


Any help would be appreciated.

Regards
Lukas



--

--
software security networks
Lukas Gradl 
Eduard-Bodem-Gasse 5
A - 6020 Innsbruck
Tel: +43-512-214040-0
Fax: +43-512-214040-21
--
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Problem compiling DLL for 64Bit Windows - complete example attached

2009-12-18 Thread Lukas Gradl

 >   rMonitor=packed record
...

  end;

  rMonitorEx=packed record
dwMonitorSize:DWORD;
Monitor:rMonitor;
  end;


Are you sure the C record is packed too ? This would mean that all 
function pointers in rMonitor are not aligned.


I'm not shure about that as I'm not that good at C. The packed record 
works at 32bit -so I thought that should be correct.


Is there a difference between 64Bit and 32Bit?

Here is the orginal C definition, could someone take a look at this:

typedef struct _MONITOR {
  BOOL (WINAPI *pfnEnumPorts)
   (LPWSTR pName, DWORD Level, LPBYTE  pPorts, DWORD cbBuf,
LPDWORD pcbNeeded, LPDWORD pcReturned);
  BOOL (WINAPI *pfnOpenPort)
   (LPWSTR pName, PHANDLE pHandle);
  BOOL (WINAPI *pfnOpenPortEx)
   (LPWSTR  pPortName, LPWSTR pPrinterName, PHANDLE pHandle,
struct _MONITOR FAR *pMonitor);
  BOOL (WINAPI *pfnStartDocPort)
   (HANDLE hPort, LPWSTR pPrinterName, DWORD JobId,
DWORD Level, LPBYTE  pDocInfo);
  BOOL (WINAPI *pfnWritePort)
   (HANDLE hPort, LPBYTE pBuffer, DWORD cbBuf,
LPDWORD pcbWritten);
  BOOL (WINAPI *pfnReadPort)
   (HANDLE hPort, LPBYTE pBuffer, DWORD cbBuffer,
LPDWORD pcbRead);
  BOOL (WINAPI *pfnEndDocPort)
   (HANDLE hPort);
  BOOL (WINAPI *pfnClosePort)
   (HANDLE hPort);
  BOOL (WINAPI *pfnAddPort)
   (LPWSTR pName, HWND hWnd, LPWSTR pMonitorName);
  BOOL (WINAPI *pfnAddPortEx)
   (LPWSTR pName, DWORD Level, LPBYTE lpBuffer,
LPWSTR lpMonitorName);
  BOOL (WINAPI *pfnConfigurePort)
   (LPWSTR pName, HWND hWnd, LPWSTR pPortName);
  BOOL (WINAPI *pfnDeletePort)
   (LPWSTR pName, HWND hWnd, LPWSTR pPortName);
  BOOL (WINAPI *pfnGetPrinterDataFromPort)
   (HANDLE hPort, DWORD ControlID, LPWSTR pValueName,
LPWSTR lpInBuffer, DWORD cbInBuffer, LPWSTR lpOutBuffer,
DWORD cbOutBuffer, LPDWORD lpcbReturned);
  BOOL (WINAPI *pfnSetPortTimeOuts)
   (HANDLE hPort, LPCOMMTIMEOUTS lpCTO,
DWORD reserved// must be set to 0);
  BOOL (WINAPI *pfnXcvOpenPort)
   (LPCWSTR pszObject, ACCESS_MASK GrantedAccess, PHANDLE phXcv);
  DWORD (WINAPI *pfnXcvDataPort)
(HANDLE  hXcv, LPCWSTR pszDataName, PBYTE pInputData,
 DWORD cbInputData, PBYTE pOutputData, DWORD cbOutputData,
 PDWORD pcbOutputNeeded);
  BOOL (WINAPI *pfnXcvClosePort)
   (HANDLE  hXcv);
} MONITOR, FAR *LPMONITOR;

typedef struct _MONITOREX {
  DWORD  dwMonitorSize;
  MONITOR  Monitor;
} MONITOREX, FAR *LPMONITOREX;

regards
Lukas

--

--
software security networks
Lukas Gradl 
Eduard-Bodem-Gasse 5
A - 6020 Innsbruck
Tel: +43-512-214040-0
Fax: +43-512-214040-21
--
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Problem compiling DLL for 64Bit Windows - complete example attached

2009-12-18 Thread Lukas Gradl

Jonas Maebe schrieb:


You must never use a "packed" record for a C record, unless it is 
declared in C using __attribute__((__packed__)). The fact that it worked 
in 32 bit was pure coincidence. You also have to add {$packrecords c} to 
your source file to tell the compiler to lay out records the same way as 
C compilers to guarantee interoperability.


Jonas, Marc, if you ever come near my place feel free to come along for 
a beer or something...


Never heard of the $packrecords switch, but that was it - now it works 
for 32 and 64 bits...


regards
Lukas

--

--
software security networks
Lukas Gradl 
Eduard-Bodem-Gasse 5
A - 6020 Innsbruck
Tel: +43-512-214040-0
Fax: +43-512-214040-21
--
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] OT: mySQL Master-Master-Slave replication

2010-03-24 Thread Lukas Gradl
Perhaps it's just that I'm a little bit short of sleep - but I can't 
find good solution for a problem although I'm shure it should be easy to 
solve...


So apologies for posting off topic here - but as all my work on that 
project is done using FPC i'll give it a try...

Perhaps someone can point me to the right direction...

As a part of a project for a customer I would like to replicate 
mysql-dbs to a slave. I could implement some replication-daemon, but i 
would prefer to use the mysqld-possibilities.


I want:
Master1.DBA -> Slave.DBA
Master2.DBB -> Slave.DBB

I've mySQL 5.1 on all Servers. After some hours of googling I've only 
found how to replicate to the SAME DB on the slave (and not to the two 
different ones I want) or to run two instances of mysql on the slave.


Unfortunatly the two instances are not an option, as I want to conntect 
to the Databases with some third party tool that has no configurable 
DB-Port, but uses the mysql-Default.



Anyone already done something like that?

Any hint apreciated...

Regards
Lukas

--

------
software security networks
Lukas Gradl 
Eduard-Bodem-Gasse 5
A - 6020 Innsbruck
Tel: +43-512-214040-0
Fax: +43-512-214040-21
--
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC + 64bit Windows => anybody?

2010-05-04 Thread Lukas Gradl

Graeme Geldenhuys schrieb:

Hi,

I often hear of developers using FPC on 64-bit Linux. My development
machine is the same.  But I can't say I have ever heard of anybody using
64-bit Windows with FPC.

Does FPC support 64-bit Windows? If so, is it stable (like 64-bit Linux) or
still experimental?


I use FPC to compile Win64 DLLs. No Problems with the compiler so far, 
only had some problems with UIB and DCPCrypt, but nothing which couldn't 
easily resolved...


I normally use FPC on an 64-Bit Ubuntu and crosscompile to windows 32 
and 64 or Windows 32 to compile to Win64 - an Win64 Installation I never 
 used for compilation.


What I never tested was LCL on Win64, but I think this is not an 
important option for you, Graeme *g*...


regards
Lukas


--

--
software security networks
Lukas Gradl 
Eduard-Bodem-Gasse 9
A - 6020 Innsbruck
Tel: +43-512-214040-0
Fax: +43-512-214040-21
--
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC + 64bit Windows => anybody?

2010-05-04 Thread Lukas Gradl

Thanks. BTW: are you using the latest DCPCrypt? Recently I applied a lot of
64-bit fixes for DCPCrypt - extensively tested under 64-bit Linux. Once I
get a 64-bit Windows FPC going, I'll test on that platform too.
Latest DCPCrypt is in Lazarus-CCR git repository at SourceForge. Or
released version v2.0.4.1 in downloads section.


Could'nt find a version number in my copy - but there is some Mr. 
Geldenhuys in the Changelog, so I think I've one of your versions.


I normally use FPC on an 64-Bit Ubuntu and crosscompile to windows 32 
and 64


Ah, so there is hope.


I just use it for some DLLs - that works as expected. But they are so 
small, that I'm not able to tell for shure that FPC will work correctly 
unter Win64...


What I never tested was LCL on Win64, but I think this is not an 
important option for you, Graeme *g*...


What is LCL?  ;-)


You know, some fancy GUI-Toolkit, a little bit more VCL-compatible than 
some competitor from South-Africa... *runningawayasfastaspossible*


Lukas

--

--
software security networks
Lukas Gradl 
Eduard-Bodem-Gasse 5
A - 6020 Innsbruck
Tel: +43-512-214040-0
Fax: +43-512-214040-21
--
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] where to set the binutils-path

2014-06-25 Thread Lukas Gradl

I'm trying to compile fpc for arm-android using the following script:


FPCBIN=/usr/lib/fpc/2.6.2/ppcx64
SRCDIR=/space/projekte/Sourcen/fpc27
ANDROIDBINDIR="~/Software/Android_Development/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin"
export PATH=$ANDROIDBINDIR:$PATH

make crossall CPU_TARGET=arm OS_TARGET=android FPC=$FPCBIN  
CROSSOPT=-CfVFPV3 CROSSBINDIR=$ANDROIDBINDIR  
BINUTILSPREFIX=arm-linux-androideabi-


The script stops with:

/bin/mkdir -p /space/projekte/Sourcen/fpc27/rtl/units/arm-android
~/Software/Android_Development/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-as  -o /space/projekte/Sourcen/fpc27/rtl/units/arm-android/prt0.o  
arm/prt0.as
~/Software/Android_Development/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-as  -o /space/projekte/Sourcen/fpc27/rtl/units/arm-android/dllprt0.o  
arm/dllprt0.as
/space/projekte/Sourcen/fpc27/compiler/ppcrossarm -Ur -Tandroid -Parm  
-XParm-linux-androideabi- -Xr -Ur -Xs -O2 -n -Fi../inc -Fi../arm  
-Fi../unix -Fiarm -Fi../linux -Fi../linux/arm  
-FD~/Software/Android_Development/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin -FE. -FU/space/projekte/Sourcen/fpc27/rtl/units/arm-android -darm -dRELEASE -CfVFPV3 -Us -Sg  
../linux/system.pp
system.inc(1804,8) Warning: Implicit string type conversion from  
"RawByteString" to "UnicodeString"
system.pp(376) Error: Assembler arm-linux-androideabi-as not found,  
switching to external assembling

system.pp(376) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted


So, prt0.o is built, dllprt0.o as well, but for system.pp it fails.

So - where do I have to set the path to the arm-android binutils as well?

Any help appreciated...

regards
Lukas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] where to set the binutils-path

2014-06-25 Thread Lukas Gradl


The proper alternative is to use $HOME instead (as long as you don't  
use single quotes).



Hmpf - I could have seen that myself.

Thanks for your help - it works.

regards
Lukas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Target Win32 missing

2015-12-06 Thread Lukas Gradl

Hello!

Sorry to disturb anyone... Perhaps I just need a little bit more  
sleep, but I cant find a solution to my problem...


When calling fpc from linux command line -Twin32 is missing. -TWin64  
works as expected.


Where did -Twin32 go?

I'm using Debian jessie x86_64 as main OS.

I compile fpc from the latest trunk sources with a script I wrote once.
Basically it does (among a few other things and platforms):

make all FPC=/usr/lib/fpc/2.6.4/ppcx64
sudo make install PREFIX=/usr FPC=/usr/lib/fpc/2.6.4/ppcx64
make clean
make crossall CPU_TARGET=i386 OS_TARGET=win32
sudo make crossinstall CPU_TARGET=i386 OS_TARGET=win32 PREFIX=/usrmake clean
make clean
make crossall OS_TARGET=win64
sudo make crossinstall OS_TARGET=win64 PREFIX=/usr


When calling fpc it shows under section -T
  -T  Target operating system:
  -Tdarwin   Darwin/Mac OS X
  -Tfreebsd  FreeBSD
  -Tiphonesim  iPhoneSimulator
  -TlinuxLinux
  -Tnetbsd   NetBSD
  -Topenbsd  OpenBSD
  -Tsolaris  Solaris
  -Twin64Win64 (64 bit Windows systems)

but no win32. And trying to compile results in "Error: Illegal  
parameter: -Twin32".


Any hint what I'm doing wrong?

regards
Lukas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Target Win32 missing

2015-12-06 Thread Lukas Gradl


What does '`fpc -Pi386 -PB`' do (the outer quotes should be removed before
copying it to the command line, the inner quotes are there on purpose)?


it says:
/usr/bin/ppcross386

When I call that directly I get win32 under the -T section
But not when calling through fpc.


You need to tell fpc to call compiler for the respective CPU using the
-Pi386 (if it is installed correctly). Then you would see all the targets
supported for i386 listed under -T.


And how do I tell this to fpc? In the fpc.cfg?
I didn't touch win32 for some time - but it had been working. And I  
can't remember what I might have changed so it stopped working


Thanks for the help

Lukas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Target Win32 missing

2015-12-06 Thread Lukas Gradl


Quoting from my previous e-mail above: 'You need to tell fpc to call
compiler for the respective CPU using the -Pi386'. I.e. add '-Pi386' to
the command line options of 'fpc' (together with '-Twin32' and whatever
else you'd need there) and it should work.

Adding the -Pi386 parameter to fpc.cfg would not work (it's ignored
there); changing the default CPU to something different than the host CPU
doesn't make much sense (it would be more reasonable to install the 32-bit
compiler instead of the 64-bit compiler if you wanted to have i386 as the
default CPU target).


you mean calling through fpc -Twin32 -Pi386 ?

I tried that - got the "Error: Illegal parameter: -Twin32" again...

I'll do a make distclean;make all now for the whole thing...
perhaps that will help.

And while the machine is working I'll get some sleep...

Thanks for your patient help,

Lukas

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Target Win32 missing

2015-12-06 Thread Lukas Gradl


Zitat von "Karoly Balogh (Charlie/SGR)" :


Hi

On Sun, 6 Dec 2015, Lukas Gradl wrote:

When calling fpc from linux command line -Twin32 is missing.  
-TWin64 works as

expected. Where did -Twin32 go?


Nowhere. Seems you are using a 64bit targeted compiler, which can only
output x86_64 code, so Win64 only. You need an i386 compiler or
crosscompiler, to produce Win32 (therefore x86/i386) code.

There was no single compiler binary ever, which could do Win32 and Win64
in one.

Yes, indeed, have a sleep. :)


but there was fpc as a wrapper for a long time calling the right compiler.
I have ppcrossi386 and other crosscompilers in my path - as I had for  
a long time. (see my answer to Tomas answer btw...)


When calling ppcrossi386 directly the win32 Target ist there - but not  
when calling through the fpc wrapper


Thanks for the help
Lukas
--


software security networks
Lukas Gradl 
Eduard-Bodem-Gasse 6
A - 6020 Innsbruck
Tel: +43-512-214040-0
Fax: +43-512-214040-21

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal