Re: [fpc-pascal] SpVoice.GetVoices returned exception class EOleSysError

2017-04-11 Thread Andrew Haines via fpc-pascal

On 04/10/2017 02:58 AM, misabov wrote:

The project has generated an exception class EOleSysError with a message:
 ?? ?? ??.

uses
...,ComObj;

var
SpVoice: Variant;

SpVoice := CreateOleObject('SAPI.SpVoice');
SpVoice.Voice:= SpVoice.GetVoices('','').Item(0);

SpVoice GetVoices method (SAPI 5.3) cannot return  a selection of voices
available to the voice.


A long time ago I played with MS sapi. I will try to put the relevant 
code here for you. My goal was to put the output speech into memory to 
be processed further.  I think I used the fpc tool importtl to generate 
the  Speechlib_tlb unit. But its been a long time now. I can email you 
directly the file if you want.


Regards,

Andrew Haines

uses
   OleServer, ComObj, Speechlib_tlb, Windows, Variants,  ActiveX, ...

var
  SpeechVoice: ISpeechVoice;
  Voice: TSpVoice;
  Voices: ISpeechObjectTokens;
  ToSpeak: OleVariant;
  i: Integer;
  VoiceList: TStringList;
begin
  CoInitialize(nil);
  Voice := TSpVoice.Create(self);
  CoCreateInstance(CLASS_SpVoice, nil, CLSCTX_ALL, IID_ISpeechVoice, 
SpeechVoice);

  Voice.ConnectTo(SpeechVoice);
  Voices := Voice.GetVoices('','');
  VoiceList := TStringList.Create;
  for i := 0 to Voices.Get_Count -1 do
VoiceList.AddObject(Voices.Item(I).GetDescription(0), 
TObject(Voices.Item(I)));
  Voice.Voice := ISpeechObjectToken(Pointer(VoiceList.Objects[0])); // 
0 is the index of the desired voice.

  // VoiceList.Strings[x] is a text description of the voice

  ToSpeak := 'Hello MS SAPI';
  Voice.speak(ToSpeak, SVSFDefault);

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

Re: [fpc-pascal] Get value of PPChar ?

2017-04-16 Thread Andrew Haines via fpc-pascal

On 04/16/2017 10:58 AM, fredvs wrote:

K, the function seems to work because the result = 0 (no error).

But how to retrieve the data icy_meta (PPChar) ?

var
theicytag : PPChar;
resu : integer;
...

resu := mpg123_icy(ahandle, theicytag);
if resu = 0 then writeln(theicytag^); --> raise exception + crash

resu := mpg123_icy(ahandle, theicytag);
if resu = 0 then writeln(theicytag^^); --> also raise exception + crash


You haven't checked if theicytag is nil. The call to mpg123_icy may 
succeed but still the tag may be nil.


resu := mpg123_icy(ahandle, theicytag);
if (resu = 0) and Assigned(theicytag) and Assigned(theicytag^)
then writeln(theicytag^);

Regards,

Andrew

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

Re: [fpc-pascal] SVN RSS

2017-07-25 Thread Andrew Haines via fpc-pascal

On 07/25/2017 01:39 PM, José Mejuto wrote:

El 25/07/2017 a las 8:33, Michael Van Canneyt escribió:

Is it possible that the SVN RSS is stuck at day 21 ?
https://svn.freepascal.org/feeds/fpcsvn.rss


Yes. The post-commit script that creates the feed has been disabled 
due to time-out problems.




Hello,

Will it be re-enabled ?




If you only want to see commits in a feed you can use this link to the 
unofficial github mirror:


https://github.com/graemeg/freepascal/commits/master.atom

It's synced every 15 minutes.

Regards,

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

Re: [fpc-pascal] Type helper for JNI pointers

2018-08-22 Thread Andrew Haines via fpc-pascal



On 08/12/2018 07:42 AM, Benito van der Zander wrote:



But this does not work, because fpc thinks jclass and jobject are the 
same type, so there is only one type helper for both of the types allowed.


Because it is declared as

type
 jobject=pointer;
 jclass=jobject;


What can we do about this?


I haven't used type helpers but why not change to defines like

type
  jObjectRec = record end;
  jObject= ^jObjectRec;
  jClassRec = record end;
  jClass = ^jClassRec;

or possibly simpler you could try
  jclass = type(jobject); // I believe this forces a new type and is 
not just an alias


Regards,

Andrew

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

[fpc-pascal] Unrelated type helpers with the same members? Implement an interface with a type helper?

2022-12-22 Thread Andrew Haines via fpc-pascal
Hi what I want to do is similar to this question here: 
https://en.delphipraxis.net/topic/423-rtti-determine-record-helper-type-for-a-base-type/


I am going to create multiple type helpers for enums and I would like to 
look up the helper and use common methods AsString AsOrdinal to get/set 
the values. I am recieving them as json that I dont have control over. I 
am using typeinfo to fill in all the properties but I would like to 
convert the strings I am receiving to the enum values semi-automatically.


LString := 'STATUS';

LHelper := GetHelper(LPropInfo^.PropType); // enum proptype

LToStringInterface := LHelper as IToStringInterface;

SetOrdProp(LObject, 'propname', LToStringInterface.OrdValue(LString);


Something like that. I'm not sure if it's even possible to find the 
helper type with typeinfo.


Thanks for your suggestions :)

Regards,

Andrew

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


Re: [fpc-pascal] Unrelated type helpers with the same members? Implement an interface with a type helper?

2022-12-22 Thread Andrew Haines via fpc-pascal

So, I came up with a solution using Custom Attributes.

I can declare this:

[TEnumAttr('YES', 'NO', 'COULD_BE')]
  TMyEnum = (meYes, meNo, meCouldBe);

and at runtime look for the TEnumAttr attribute and use that.


TEnumAttr = class(TCustomAttribute)
  protected
    FValues: TStringArray;
    FTypeName: String;
  public
    class function FromType(ATypeInfo: PTypeInfo): TEnumAttr;
    constructor Create(Val1: String);
    constructor Create(Val1, Val2: String);

etc

Maybe this can help someone else with a similar use case.


Regards,

Andrew Haines

On 12/22/22 8:40 PM, Andrew Haines via fpc-pascal wrote:
Hi what I want to do is similar to this question here: 
https://en.delphipraxis.net/topic/423-rtti-determine-record-helper-type-for-a-base-type/


I am going to create multiple type helpers for enums and I would like 
to look up the helper and use common methods AsString AsOrdinal to 
get/set the values. I am recieving them as json that I dont have 
control over. I am using typeinfo to fill in all the properties but I 
would like to convert the strings I am receiving to the enum values 
semi-automatically.


LString := 'STATUS';

LHelper := GetHelper(LPropInfo^.PropType); // enum proptype

LToStringInterface := LHelper as IToStringInterface;

SetOrdProp(LObject, 'propname', LToStringInterface.OrdValue(LString);


Something like that. I'm not sure if it's even possible to find the 
helper type with typeinfo.


Thanks for your suggestions :)

Regards,

Andrew

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

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


Re: [fpc-pascal] Unrelated type helpers with the same members? Implement an interface with a type helper?

2022-12-23 Thread Andrew Haines via fpc-pascal


On 12/23/22 5:24 AM, Ondrej Pokorny via fpc-pascal wrote:

This may be simpler:

[TEnumAttr(['YES', 'NO', 'COULD_BE'])]
  TMyEnum = (meYes, meNo, meCouldBe);

TEnumAttr = class(TCustomAttribute)
  protected
    FValues: TStringArray;
    FTypeName: String;
  public
    class function FromType(ATypeInfo: PTypeInfo): TEnumAttr;
    constructor Create(Values: array of string);

---



I tried that first but the compiler gave an error on the "["

Error: Ordinal expression expected

[TEnumAttr(['YES', 'NO', 'COULD_BE'])]



Or, if the enum values are valid identifiers, you can simple use 
scoped enums:


{$SCOPEDENUMS ON}
  TMyEnum = (YES, NO, COULD_BE);

and the usual TypeInfo methods.

Ondrej



I didn't know about those, that could also be a good solution, thanks!

Andrew

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


[fpc-pascal] fcl-web websocket

2022-12-24 Thread Andrew Haines via fpc-pascal

Hi,

I am trying to test the websocket client in fcl-web by making a simple 
echo client. I have been unable to make it work using fpc trunk on 
linux64. I also crosscompiled to win64 and ran it on wine with identical 
results. The project is attached here if anyone can give some hints.


I am testing it with a server I found here 
https://github.com/vi/wsmirror (written in rust) but also I tried it 
with some public echo servers. There is a html/javascript websocket 
example also for testing it which is working.


I have no real guesses as to the problem. I modified the server that the 
client connects to enough to know when it receives messages and what 
kind. The server never identifies a proper message after the connection 
handshake is completed. It gets something but it doesn't identify it as 
a text message or ping or close etc. The server is dropping the 
connection after a few seconds with ss -t dport = 8080 giving this:


State Recv-Q Send-Q Local Address:Port

CLOSE-WAIT    5 0    127.0.0.1:47828

I believe those are several ping packets the server is sending that the 
client doesn't read.


One thing the websocket is doing is disabling MSG_SIGNAL so that when 
the pipe is broken it doesn't show an exception. However the component 
doesn't check for this and doesn't send the disconnect event.


I have made my own websocket component in the past which is working but 
I wanted to try the one included with fpc.


I'm really baffled, I spent a long time to try and find what is wrong, 
even putting debug code in the underlying socket components. And 
verifying that the websocket frames are correct.


An oddity I noted is that TInetSocket.CanRead seems to always return 
false if it's used as a client. I may not have understood that fully.


Regards,

Andrew Haines
<>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fcl-web websocket

2022-12-25 Thread Andrew Haines via fpc-pascal


On 12/25/22 6:06 PM, Michael Van Canneyt via fpc-pascal wrote:


Does the sample chat client/program work for you ?

See below


When I have a moment, I'll look at your test program.


Thank you



Michael.




I'm not sure, maybe. It seems like the clients are not receiving 
messages. Also, using strace I realized the server ignores the port and 
uses 6060. I tried with and without threading.


./server/wsserver -p 8080 -t pool
Received message: { "from" : "client1", "msg" : "Hello, this is a 
friendly greeting message from the client", "to" : "client1" }
Received message: { "from" : "client2", "msg" : "Hello, this is a 
friendly greeting message from the client", "to" : "client2" }
Received message: { "from" : "client2", "msg" : "Hello to 1", "to" : 
"client1" }


Received message: { "from" : "client1", "msg" : "I didn't hear anything. 
Are you there?", "to" : "client2" }


Connection 1 disappeared
Connection 1 disappeared
Connection 2 disappeared
Connection 2 disappeared


./client/wsclient -u ws://localhost:6060/  -a client2
Enter message or command (/stop /help), empty message will just check 
for incoming messages

client2> Hello to 1
Recipient> client1
client2>

client2> /quit


./client/wsclient -u ws://localhost:6060/ -p -a client1
Enter message or command (/stop /help), empty message will just check 
for incoming messages

client1>
client1> I didn't hear anything. Are you there?
Recipient> client2
client1>
client1> /quit

State   Recv-Q Send-Q Local 
Address:Port    Peer Address:Port Process
ESTAB   176 0 127.0.0.1:36486 127.0.0.1:6060 
users:(("wsclient",pid=1026336,fd=3))
ESTAB   204 0 127.0.0.1:36502 127.0.0.1:6060 
users:(("wsclient",pid=1026342,fd=3))


Andrew

PS Here is the strace from a client without sending messages, but 
pressing the 'enter' key once..


socket(AF_INET, SOCK_STREAM, IPPROTO_IP) = 3
getsockopt(3, SOL_SOCKET, SO_RCVTIMEO_OLD, 
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", [16]) = 0
connect(3, {sa_family=AF_INET, sin_port=htons(6060), 
sin_addr=inet_addr("127.0.0.1")}, 16) = 0

sendto(3, "GET / HTTP/1.1\r\n", 16, MSG_NOSIGNAL, NULL, 0) = 16
sendto(3, "Host: localhost:6060\r\n", 22, MSG_NOSIGNAL, NULL, 0) = 22
sendto(3, "Upgrade: websocket\r\n", 20, MSG_NOSIGNAL, NULL, 0) = 20
sendto(3, "Connection: Upgrade\r\n", 21, MSG_NOSIGNAL, NULL, 0) = 21
sendto(3, "Origin: localhost\r\n", 19, MSG_NOSIGNAL, NULL, 0) = 19
sendto(3, "Sec-WebSocket-Key: 3pqrw1xgwqSel"..., 45, MSG_NOSIGNAL, NULL, 
0) = 45

sendto(3, "Sec-WebSocket-Version: 13\r\n", 27, MSG_NOSIGNAL, NULL, 0) = 27
sendto(3, "\r\n", 2, MSG_NOSIGNAL, NULL, 0) = 2
recvfrom(3, "H", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "T", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "T", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "P", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "/", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "1", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, ".", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "1", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, " ", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "1", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "0", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "1", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, " ", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "S", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "w", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "i", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "t", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "c", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "h", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "i", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "n", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "g", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, " ", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "P", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "r", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "o", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "t", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "o", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "c", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "o", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "l", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "s", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "\r", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "\n", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "U", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "p", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "g", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "r", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "a", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "d", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "e", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, ":", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, " ", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "w", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "e", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "b", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "s", 1, M

Re: [fpc-pascal] fcl-web websocket

2022-12-26 Thread Andrew Haines via fpc-pascal



On 12/26/22 8:02 AM, Michael Van Canneyt via fpc-pascal wrote:


I fixed the -p/--port option.

I could reproduce the broken behaviour in the fcl-web example.

As I thought, a change in the fcl-net ssockets unit is the cause of the
behaviour. I fixed it.

Please check if your example now also works ?

Michael.



I tested the client/server example and they are working now. My echo 
test program still sends but does not receive.



Andrew

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


Re: [fpc-pascal] fcl-web websocket

2022-12-26 Thread Andrew Haines via fpc-pascal


On 12/26/22 8:48 AM, Michael Van Canneyt via fpc-pascal wrote:



Please make a version of your program that does not use the LCL.
Then I'll test that too.

2 reasons for this request: - I don't have a working version of 
Lazarus with FPC trunk.
- I want to exclude the problems of dealing with the main application 
message loop.



I attached a console version. It uses threads. If this is useful at all 
please feel free to add it to the examples and modify it however you want.


I found the problem. First was the problem of no data being read, which 
you fixed by changing the inheritance. But the second problem is that 
the OutgoingFrameMask value was not being used. In the rfc section 5.2 
it states in the Mask bit explanation that all frames sent from a client 
must be masked. Unfortunately the echo server was not giving a close 
frame with a protocol error which would have been useful.


In the attached patch there are 3 hunks that include the 
OutgoingFrameMask with the payload. The rest of the patch is about 
handling a connection that encounters an error sending data. I added an 
exception and also a flag that ignores the exception and tries to close 
gracefully.


You can compile the console client I sent without applying the patch to 
see how it was failing before. There are default servers to choose from.


Maybe in the client, the constructor should pick a mask at random by 
default since all frames from the client are supposed to be masked 
anyway. Section 5.3 has some strong language about the random mask 
having a strong entropy source. It actually says each frame should have 
a new unique mask so I'm not sure the OutgoingFrameMask property really 
makes sense since the mask is given to the connection only once when the 
connection is created. I doubt most server implementations care about this.


Regards,

Andrew


diff --git a/packages/fcl-web/src/websocket/fpwebsocket.pp b/packages/fcl-web/src/websocket/fpwebsocket.pp
index 8424f6c44f..3b6ecd24be 100644
--- a/packages/fcl-web/src/websocket/fpwebsocket.pp
+++ b/packages/fcl-web/src/websocket/fpwebsocket.pp
@@ -287,7 +287,8 @@   TWSMessage = record
woCloseExplicit, // SeDo Close explicitly, not implicitly.
woIndividualFrames,  // Send frames one by one, do not concatenate.
woSkipUpgradeCheck,  // Skip handshake "Upgrade:" HTTP header cheack.
-   woSkipVersionCheck   // Skip handshake "Sec-WebSocket-Version' HTTP header check.
+   woSkipVersionCheck,  // Skip handshake "Sec-WebSocket-Version' HTTP header check.
+   woSendErrClosesConn  // Don't raise an exception when writing to a broken connection
   );
   TWSOptions = set of TWSOption;
 
@@ -482,6 +483,7 @@   TWSServerTransport = class(TWSTransport)
   SErrServerActive = 'Operation cannot be performed while the websocket connection is active';
   SErrInvalidSizeFlag = 'Invalid size flag: %d';
   SErrInvalidFrameType = 'Invalid frame type flag: %d';
+  SErrWriteReturnedError = 'Write operation returned error: (%d) %s';
 
 function DecodeBytesBase64(const s: string; Strict: boolean = false) : TBytes;
 function EncodeBytesBase64(const aBytes : TBytes) : String;
@@ -1175,7 +1177,7 @@ procedure TWSConnection.Send(aFrameType : TFrameType; aData : TBytes = Nil);
 begin
   if not (aFrameType in [ftClose,ftPing,ftPong]) then
 Raise EWebSocket.CreateFmt(SErrNotSimpleOperation,[Ord(aFrameType)]);
-  aFrame:=FrameClass.Create(aFrameType,True,aData);
+  aFrame:=FrameClass.Create(aFrameType,True,aData, OutgoingFrameMask);
   try
 Send(aFrame);
   finally
@@ -1532,7 +1534,7 @@ procedure TWSConnection.Send(const AMessage: UTF8string);
   aFrame: TWSFrame;
 
 begin
-  aFrame:=FrameClass.Create(aMessage);
+  aFrame:=FrameClass.Create(aMessage, OutgoingFrameMask);
   try
 Send(aFrame);
   finally
@@ -1544,7 +1546,7 @@ procedure TWSConnection.Send(const ABytes: TBytes);
 var
   aFrame: TWSFrame;
 begin
-  aFrame:=FrameClass.Create(ftBinary,True,ABytes);
+  aFrame:=FrameClass.Create(ftBinary,True,ABytes, OutgoingFrameMask);
   try
 Send(aFrame);
   finally
@@ -1590,12 +1592,27 @@ procedure TWSConnection.Send(aFrame: TWSFrame);
 
 Var
   Data : TBytes;
+  Res: Integer;
+  ErrMsg: UTF8String;
 
 begin
   if FCloseState=csClosed then
 Raise EWebSocket.Create(SErrCloseAlreadySent);
   Data:=aFrame.AsBytes;
-  Transport.WriteBytes(Data,Length(Data));
+  Res := Transport.WriteBytes(Data,Length(Data));
+  if Res < 0 then
+  begin
+FCloseState:=csClosed;
+ErrMsg := Format(SErrWriteReturnedError, [GetLastOSError, SysErrorMessage(GetLastOSError)]);
+if woSendErrClosesConn in Options then
+begin
+  SetLength(Data, 0);
+  Data.Append(TEncoding.UTF8.GetBytes(UnicodeString(ErrMsg)));
+  DispatchEvent(ftClose, nil, Data);
+end
+else
+  Raise EWebSocket.Create(ErrMsg);
+  end;
   if (aFrame.FrameType=ftClose) then
 begin
 if FCloseState=csNone then
diff --git a

Re: [fpc-pascal] fcl-web websocket

2022-12-27 Thread Andrew Haines via fpc-pascal



On 12/27/22 3:39 AM, Michael Van Canneyt via fpc-pascal wrote:



Anyway: I have applied the patch, and added your example with some minor
modifications. Thank you for both !

Michael.
___



Awesome thanks very much!

Andrew

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


[fpc-pascal] Generic threadlist

2022-12-30 Thread Andrew Haines via fpc-pascal
Hi, I made a generic threadlist for the unit fgl. I'm wondering what is 
the opinion on stuff like that. Specifically it's T: TObject and not for 
"pointers." I had made both TFPGThreadList and TFPGObjectThreadList and 
I thought afterwards only TFPGThreadList is needed and it should hold 
TObjects.


If I implement both, should the TThreadList in classes be declared as 
Specialize TFPGThreadList? I noticed the fgl unit is not 
included in classes.


What kind of things should be added to fgl if any?

Thanks

Andrew


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


[fpc-pascal] unixsockets

2024-12-28 Thread Andrew Haines via fpc-pascal
Hi, is unixsockets.pp in rtl-extra supposed to be included when fpc is 
built for linux? I ran


'find /usr/lib/fpc/ | grep unixsockets' and it returns nothing, also not 
in /usr/local/lib/fpc.


I needed msghdr/cmsghdr which I found in 
packages/rtl-extra/src/linux/unixsocketsh.inc.


grep -r "unixsockets" ./fpc-gitlab

./utils/dotutils/known.txt:unixsockets=*UnixApi.Sockets
./packages/rtl-extra/src/unix/unixsockets.pp:unit unixsockets;
./packages/rtl-extra/src/unix/unixsockets.pp:{$unixsocketsh.inc}
./packages/rtl-extra/src/unix/unixsockets.pp:{$unixsockets.inc}
./packages/rtl-extra/namespaced/UnixApi.Sockets.pp:{$i unixsockets.pp}
./packages/rtl-extra/namespaces.lst:src/unix/unixsockets.pp=namespaced/UnixApi.Sockets.pp

so it's not in any Makefile or fpmake.pp file.

Also, at least on my system(linux/64) the msghdr and cmshdr records have 
used socklen_t in a couple places where it should be size_t. But perhaps 
it's matching other *nix's


https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/bits/socket.h;h=ca27a3c5979c7535f33390d3fac3384710e0db9b;hb=HEAD#l265


I found this which seems to match the changes I made

https://lists.freepascal.org/fpc-pascal/2014-June/042244.html

diff --git a/packages/rtl-extra/src/linux/unixsocketsh.inc 
b/packages/rtl-extra/src/linux/unixsocketsh.inc

index 4b492654b5..27fd66449f 100644
--- a/packages/rtl-extra/src/linux/unixsocketsh.inc
+++ b/packages/rtl-extra/src/linux/unixsocketsh.inc
@@ -9,13 +9,13 @@   msghdr = record
  msg_iov : piovec;
  msg_iovlen : size_t;
  msg_control : pointer;
- msg_controllen : socklen_t;
+ msg_controllen : size_t;
  msg_flags : cInt;
   end;

   Pcmsghdr = ^cmsghdr;
   cmsghdr = record
-    cmsg_len   : socklen_t;
+    cmsg_len   : size_t;
 cmsg_level : cInt;
 cmsg_type  : cInt;
   end;

Regards

Andrew Haines


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


Re: [fpc-pascal] How to read the 'a_quick_guide_to_fpgui.ipf'

2025-01-10 Thread Andrew Haines via fpc-pascal


On 1/8/25 12:02 PM, M B via fpc-pascal wrote:

I have googled for a reader for this format but can't find one.
I found a web page claiming to read this format but it didn't work.

Am I misunderstanding something? The file is under /docs/quick_guide  
in the repository. for fpGUI on github.


ipf files are the uncompiled project files for inf files. There's an exe 
here you can propably run with wine to compile it


https://github.com/graemeg/fpGUI/tree/develop/tools/wipfc

Then I think you can read it with Docview.

Regards,

Andrew Haines

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


Re: [fpc-pascal] unixsockets

2025-01-03 Thread Andrew Haines via fpc-pascal



On 1/3/25 6:12 AM, Michael Van Canneyt via fpc-pascal wrote:


Yes. It was not built, I added it to fpmake.

I also applied the fix you mentioned for the size_t problem.




Thanks very much!

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