Re: [fpc-pascal] IRC channel for FreePascal support ?

2023-04-13 Thread Marc Weustink via fpc-pascal




On 13/04/2023 13:55, Rik van Kekem via fpc-pascal wrote:

Op 13-04-2023 om 12:53 schreef Jacob Kroon via fpc-pascal:


Thanks for checking, but well, I just got contacted by "Joanna" 
privately on IRC, this is the chatlog:


The following topic might be of interest. You can view it without 
registering.

https://forum.lazarus.freepascal.org/index.php/topic,61328.0.html

There are more people who have the same problem with that IRC channel(s) 
and with 'Joanna'.

Especially the strict rules that are enforced.
(your chatlog doesn't stand alone, there are also multiple topics on the 
forum about this, besides the link given above.)


BTW. That IRC channel is not an official FPC/Lazarus channel.
(I think 'Joanna' is the founder of the channel and sole moderator there.)


#fpc and #lazarus were the official channels in the freenode times. 
After freenode got abandoned, some active users started those channels 
on libera. Soon after that I registered #lazarus as the official channel 
for the lazarus project. No registration is done for the fpc channel (yet)
As of today, Joanna is not a channel operator anymore on the lazarus 
channel. She has been warned that the same could happen for the fpc channel.


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


Re: [fpc-pascal] Open array in object constructor gives error

2023-01-03 Thread Marc Weustink via fpc-pascal



On 3-1-2023 14:07, Hairy Pixels via fpc-pascal wrote:




On Jan 3, 2023, at 3:12 PM, Sven Barth  wrote:

But then you don't use the type name either. You simply do "o.Create(...)".



O I get it now. I didn’t realize you couldn’t create on the type. That 
breaks my entire design then. It would be great to have a modern object that 
behaved more like classes but on the stack (like C++ does).


On what instance/variable/piece of memory would your code 
"TMyObject.Create(['1', '2', '3'])" then operate ?


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


Re: [fpc-pascal] Windows Volume Control

2022-01-18 Thread Marc Weustink via fpc-pascal


On 15-1-2022 19:02, James Richters via fpc-pascal wrote:
Are there functions to check the current volume level and to set the 
volume with just FPC (not Lazarus) on Windows 10?


All I need is the master system volume, not any of the mixer controls.


This is possible. Please be aware that you can have multiple mixers and 
that the presence of the master volume is defined by the audio driver of 
the specific device (for a headset you may need to control the wave out).


The following are more or less the routines I use. Other application 
logic is stripped, so it won't compile, but it should give you an idea.
This code is used in a context where we can control multiple mixers, 
having different left/right volumes (hence the search for a specific 
name and a volume array)


Marc

function Initialize: Boolean;
var
  n, maxlen, MixerId: Integer;
  woc: TWaveOutCaps;
  Search, Name: String;

  nDest: Integer;
  mmr: MMRESULT;
  mxcaps: TMixerCaps;
  mxl, mxlsrc: TMixerLine;
  mxlc: TMixerLineControls;
  mxc: TMixerControl;
begin
  Result := False;

  // == setup volumes ===

  MixerId := -1;

  // only compare the first wic.szPname -1 (==0) len characters, 
info.name can be longer

  maxlen := SizeOf(woc.szPname) - 1;
  Search := Trim(Copy(FName, 1, maxlen));

  for n := 0 to Integer(waveOutGetNumDevs) - 1 do
  begin
waveOutGetDevCaps(n, @woc, SizeOf(woc));
Name := Trim(woc.szPname);
if not SameText(Search, Name) then Continue;

mixerGetID(n, Cardinal(MixerId), MIXER_OBJECTF_WAVEOUT);
Break;
  end;

  if MixerID = -1 then Exit;

  // === controls ===

  mmr := mixerGetDevCaps(MixerID, @mxcaps, SizeOf(mxcaps));
  if mmr <> MMSYSERR_NOERROR
  then begin
Exit;
  end;

  if mxcaps.cDestinations = 0
  then begin
Exit;
  end;

  mxl.cbStruct := SizeOf(mxl);
  for nDest := 0 to mxcaps.cDestinations - 1 do
  begin
// loop through the mixer destinations to find a waveout type
mxl.dwDestination := nDest;
mxl.dwSource := 0;
mxl.dwLineID := 0;
mmr := mixerGetLineInfo(MixerID, @mxl, MIXER_OBJECTF_MIXER or 
MIXER_GETLINEINFOF_DESTINATION);

if mmr <> 0 then Continue;
if mxl.Target.dwType <> MIXERLINE_TARGETTYPE_WAVEOUT then Continue;

// -- master Volume --

if mxl.cControls > 0
then begin
  mxlc.cbStruct := SizeOf(mxlc);
  mxlc.dwLineID := mxl.dwLineID;
  mxlc.dwControlType := MIXERCONTROL_CONTROLTYPE_VOLUME;
  mxlc.cControls := 1;
  mxlc.pamxctrl := @mxc;
  mxlc.cbmxctrl := SizeOf(mxc);
  mmr := mixerGetLineControls(MixerID, @mxlc, MIXER_OBJECTF_MIXER 
or MIXER_GETLINECONTROLSF_ONEBYTYPE);

  if mmr = MMSYSERR_NOERROR
  then begin
// set master volume
SetMixerControlVolume(MixerID, mxc, mxl.cChannels, FMasterVolume);
  end;
end;

// -- wave Volume --

if mxl.cConnections > 0
then begin
  mxlsrc.cbStruct := SizeOf(mxlsrc);
  mxlsrc.dwComponentType := MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT;
  mxlsrc.dwLineID := 0;
  mmr := mixerGetLineInfo(MixerID, @mxlsrc, MIXER_OBJECTF_MIXER or 
MIXER_GETLINEINFOF_COMPONENTTYPE);


  if mmr = MMSYSERR_NOERROR
  then begin
// get wave volume

mxlc.cbStruct := SizeOf(mxlc);
mxlc.dwLineID := mxlsrc.dwLineID;
mxlc.dwControlType := MIXERCONTROL_CONTROLTYPE_VOLUME;
mxlc.cControls := 1;
mxlc.cbmxctrl := SizeOf(mxc);
mxlc.pamxctrl := @mxc;

mmr := mixerGetLineControls(MixerID, @mxlc, MIXER_OBJECTF_MIXER 
or MIXER_GETLINECONTROLSF_ONEBYTYPE);

if mmr = MMSYSERR_NOERROR
then begin
  // set wave volume
  SetMixerControlVolume(MixerID, mxc, mxlsrc.cChannels, FVolume);
end;
  end;
end;

Break;
  end;
end;

procedure SetMixerControlVolume(AMixerID: Integer; AControl: 
TMixerControl; AChannels: Cardinal; const AValues: array of Byte);

var
  mxcd: TMixerControlDetails;
  idx, c: integer;
  detailUnsigned: array of MIXERCONTROLDETAILS_UNSIGNED;
begin
  if AControl.cbStruct = 0 then Exit; // no volume

  if AControl.fdwControl and MIXERCONTROL_CONTROLF_UNIFORM <> 0
  then AChannels := 1;

  SetLength(detailUnsigned, AChannels);

  mxcd.cbStruct := SizeOf(mxcd);
  mxcd.dwControlID := AControl.dwControlID;
  mxcd.cChannels := AChannels;
  mxcd.cMultipleItems := 0;
  mxcd.cbDetails := SizeOf(detailUnsigned[0]);
  mxcd.paDetails := @detailUnsigned[0];
  mixerGetControlDetails(AMixerID, @mxcd, MIXER_GETCONTROLDETAILSF_VALUE);

  idx := 0;
  for c := 0 to AChannels - 1 do
  begin
if idx < Length(AValues)
then detailUnsigned[c].dwValue := MulDiv(AControl.Bounds.dwMaximum, 
 AValues[idx] , 100)

else detailUnsigned[c].dwValue := 0;

if Length(AValues) > 1
then Inc(idx);
  end;
  mixerSetControlDetails(AMixerID, @mxcd, MIXER_SETCONTROLDETAILSF_VALUE);
end;
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lis

Re: [fpc-pascal] Crash on Windows for Aarch64 target

2022-01-14 Thread Marc Weustink via fpc-pascal



On 12-1-2022 14:37, Volo Zyko via fpc-pascal wrote:

Hello,

Some time ago it was announced an experimental support for Windows on Aarch64 
(namely in this post 
https://lists.freepascal.org/pipermail/fpc-pascal/2020-April/057762.html). I 
tried to build a dll with a proprietary code for that target. Building 
succeeded but it crashes on loading. At the moment I don't understand how to 
investigate the issue to provide more information about it.


I've been experimenting with this too. It looked cool to me to see if I 
can show our flagship product running on a rpi4.


The major pain is to debug windbg what is going wrong on asm level.
One of the issues I ran into was something weird when a case jumptable 
was used. It jumped to invalid code. I never was able to reproduce this 
in a smaller example and in the full code it was one of the issues it 
could run into.
Now that VisualStudio starts to supports more and more dwarf debug info, 
I hope one day to use it as debugger.


Marc

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


Re: [fpc-pascal] freepascal.org SSL_ERROR_BAD_CERT_DOMAIN

2022-01-10 Thread Marc Weustink via fpc-pascal



On 10-1-2022 17:45, Marc Weustink via fpc-pascal wrote:



On 5-1-2022 10:15, Mattias Gaertner via fpc-pascal wrote:

On Wed, 5 Jan 2022 09:40:49 +0200
"Dimitrios Chr. Ioannidis via fpc-pascal"
 wrote:


Hi,

Στις 5/1/2022 2:00 π.μ., ο/η Rainer Stratmann via fpc-pascal έγραψε:

https://freepascal.org/


the certificate issued for www.freepascal.org and not for
freepascal.org .

It seems that the let's encrypt script was run with -d freepascal.org
instead of -d *.freepascal.org .


or

-d freepascal.org,www.freepascal.org


Better, since forum.lazarus.freepascal.org is not served by this server 
and has a different LE certificate.


if lets encrypt registers certificates right, there cannot exist a 
*.freepascal.org and a different forum.lazarus.freepascal.org cert.


OK, after some reading, this seems to be allowed.
However while reading I noticed that *.freepascal.org doesn't cover 
freepascal.org. You have to define it separate



Marc

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


Re: [fpc-pascal] freepascal.org SSL_ERROR_BAD_CERT_DOMAIN

2022-01-10 Thread Marc Weustink via fpc-pascal



On 5-1-2022 10:15, Mattias Gaertner via fpc-pascal wrote:

On Wed, 5 Jan 2022 09:40:49 +0200
"Dimitrios Chr. Ioannidis via fpc-pascal"
 wrote:


Hi,

Στις 5/1/2022 2:00 π.μ., ο/η Rainer Stratmann via fpc-pascal έγραψε:

https://freepascal.org/


the certificate issued for www.freepascal.org and not for
freepascal.org .

It seems that the let's encrypt script was run with -d freepascal.org
instead of -d *.freepascal.org .


or

-d freepascal.org,www.freepascal.org


Better, since forum.lazarus.freepascal.org is not served by this server 
and has a different LE certificate.


if lets encrypt registers certificates right, there cannot exist a 
*.freepascal.org and a different forum.lazarus.freepascal.org cert.


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


[fpc-pascal] Lazarus server back online

2021-12-28 Thread Marc Weustink via fpc-pascal

Hi all,

It took a bit longer than expected, but I'm happy to inform you that the 
Lazarus services are back online.
For those interested in why it took longer, I'll explain at the end of 
the message.


Marc

On 24-12-2021 08:30, Marc Weustink wrote:

Hi,

On Monday 27 December 9.00 CET (8.00 GMT) the Lazarus server will be 
down for maintenance. This affects the following services:


* Lazarus website
* Lazarus mailinglists
* Lazarus online package manager
* Lazarus and FreePascal forum

Thanks,
Marc


The story

The server was running Ubuntu 16 LTR, so it's support ended on April 
this year. An attempt at that time failed since Ubuntu decided to switch 
to systemd-resolve which resulted in a server not even able to resolve 
its own name, let alone other hosts. When Googling about it, you learn 
that it doesn't work, it's a half backed solution, not a full DNS etc. 
At that time it became clear that I wouldn't be able to solve that in an 
evening. Luckily I could try this on a cloned server (we had to rent for 
another issue) so I parked the upgrade till I could spend a full day.


Yesterday I found the "correct" solution to this which appeared to work. 
So I continued to upgrade to Ubuntu 18 and finally to Ubuntu 20 LTR. 
Everything seemed to work until I enabled the mailserver. It couldn't 
resolve any mailserver for a given domain.
What the f.. 'host -t mx freepascal.org' resolves, why can't postfix 
resolve it. Again after some Googling, postfix needs a /etc/resolf.conf. 
However one step of the DNS solution was to remove the /etc/resolf.conf 
symlink, so I tried to restore the original link to some systemd-resolve 
generated one. This one pointed to their internal resolver. Still no 
luck since I hadn't configured systemd-resolve which DNS itself should 
use. After doing so, the generated resolf.conf became empty ?
After more Googling I found that systemd-resolve generates another conf 
where you also can link to. No clue why there have to exist another 
version, but this one works.
So this part of the server upgrade got finished around 14:00. The 
Lazarus mailing list and main website were back online.


Another wish we had was to change the database backend of the forum. It 
appeared over time that when doing a search on the database, mysql 
blocks updates, so browsing the forum becomes unresponsive. The current 
version of SMF supports different databases so we decided to go for 
PostgreSQL (I'm using them at work for years now).
Migrating MySql data to PostgreSQL seemed easy with pgLoader. The 
documentation about is was initially a bit sparse, but I could start a 
conversion with some commandline options. Unfortunately it got killed 
after 15 mins of import. After two more attempts it became clear, out of 
memory :(
Reducing the memory requirements was a build time option so I didn't 
want to go that way. Another solution was to convert only a few tables 
at a time. That required however a configuration file which has more 
options than the command line. Most of the examples I found on the web 
failed, since they lack the semi colon at the end if the configuration. 
So the parser barfs with some abracadabra, initially not giving a clue.
Fast forward, on 18:00 all but the messages table were converted. On 
22:00 the messages table was converted using 9 parts. Then I realized 
that I didn't have a php-pgsql driver installed. After doing so, I 
discovered that the Lazarus main site also showed the forum maintenance 
message ???
Those sites are running on two different virtual servers. How can the 
contents of an index.php of one site have influence on the index.php of 
another site. What did go wrong when I installed the driver ???
After an hour investigating I decided to enable the forum first and 
investigate the issue later.
Poof the forum results in a bunch of errors. What we didn't think of 
when switching backend, is that we use SMF (which is PostgreSQL capable) 
and TinyPortal (TP) to have the menus at the sides. And TP is full of 
MySQL only statements. Luckily there is someone who created all those 
missing functions for SMF and I created them on the database. After 
adjusting some TP php files (PostgreSQL requires a true boolean and not 
some integer <> 0), the forum started without errors. But it didn't show 
any boards. So there is still something wrong under the hood.
Meanwhile it was 24:00 and I decided to continue using MySQL and called 
it a day.
This morning I reverted my TP changes and put the MySQL database back 
online.


To be continued...


Marc

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


[fpc-pascal] Lazarus server maintenance

2021-12-23 Thread Marc Weustink via fpc-pascal

Hi,

On Monday 27 December 9.00 CET (8.00 GMT) the Lazarus server will be 
down for maintenance. This affects the following services:


* Lazarus website
* Lazarus mailinglists
* Lazarus online package manager
* Lazarus and FreePascal forum

Thanks,
Marc

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


Re: [fpc-pascal] How to check if a network is available?

2021-07-02 Thread Marc Weustink via fpc-pascal

On 18-6-2021 13:49, Bo Berglund via fpc-pascal wrote:

I would like to know how I can check if a remote network is available, i.e. if
the VPN system has succeeded to connect the remote network.

I need this in a class that connects an OpenVPN tunnel on demand and takes it
down after use. Unfortunately openvpn-gui does not have an API call to do
this...
It provides an API for connect, disconnect, reconnect etc but not for returning
the state of a connection for example.
https://github.com/OpenVPN/openvpn-gui#send-commands-to-a-running-instance-of-openvpn-gui

Any suggestions for Windows?
I just want to know if a call to connect succeeded.


You can use the management interface
 https://openvpn.net/community-resources/management-interface/

But since we are developers you can lookup this info with the windows 
function GetIpAddrTable



https://docs.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getipaddrtable

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


Re: [fpc-pascal] Initialization of constant record member of pointer type

2020-12-14 Thread Marc Weustink via fpc-pascal



On 4-12-2020 13:01, LacaK via fpc-pascal wrote:


Dňa 2.12.2020 o 16:09 Tomas Hajny via fpc-pascal napísal(a):

On 2020-12-02 16:01, LacaK via fpc-pascal wrote:

Dňa 2.12.2020 o 13:55 Tomas Hajny via fpc-pascal napísal(a):

On 2020-12-01 11:39, Ladislav Karrach via fpc-pascal wrote:


Because MyConst1 is not an *untyped* constant. Only untyped 
constants can be used in constant expressions (a pointer to 
something can be considered an untyped constant).


The following might work though I did not test it:

=== code begin ===

const
   MyStr = 'abc'
   MyConst1: AnsiString = MyStr;
   MyConst2: TMyRec = (l: Length(MyStr); a: @MyConst1[1]);


=== code end ===


Yes it works, but I must define 2 constants (MyStr and MyConst1),
which is not so nice ;-)

It would be nice to have support for true constants:

const
   MyConst1 = 'abc' ;
   MyConst2: TMyRec = (l: Length(MyConst1); a: @MyConst1[1]);

But may be that there are technical reasons why it is problematic (may
be that true constants are stored in another memory locations, which
can not be easy addressed)


Yes, that's one of possible reasons.

Regarding Length in constant value assignment - remember that Length 
is a function. In case of real constants, the call may be replaced 
by the compiler with the constant value. However typed constants may 
not be constant, so generic replacement throughout the source code 
at compile time is not possible (if it appears in the main body or 
some function, the length may already be changed to something else) 
and selective replacement may result in a behaviour not expected by 
the user. The only questionable case is IMHO the case of 
{$WRITEABLECONST OFF} - the compiler _might_ be able to perform the 
compile-time substition in that case (and thus allow using Length of 
such a constant in constant value assignment), but it doesn't do 
that in that case either apparently.


Yes I have no problem with {$WRITEABLECONST OFF} if it will allow 
Length().


Somewhere I read (may be in Delphi documentation) that some intristic
functions like Low(), High(), Pred() and also Length() etc. can be
used in constant expressions because compiler can evaluate them if
theirs arguments are also constants.
Which is the case in my example.
For now {$WRITEABLECONST OFF} does not help ;-)


Yes, that's what I mentioned as well, but it might be changed for this 
particular case. You might create a ticket for that if Delphi allows 
to use Length that way; obviously, you might create such a ticket even 
if Delphi doesn't allow to do that. ;-)


I checked it with older Delphi XE and it seems, that Delphi XE does not 
support Length() for typed constant also when {$WRITEABLECONST OFF}


I do not believe that this will be accepted for FPC, so I don not open 
new feature request in bug tracker.


On other side FPC developers read this mailing list so if they consider 
this as a useful/doable feature may be that someone will take look at it 


I just happened to write a construct like this (in Delphi):

const
  X_0: array[0..4276] of SmallInt = (.

  MAP: array['0'..'9'] of TSomething = (
(Samples: @X_0; Count: Length(X_0)), ...


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


Re: [fpc-pascal] Return value of StrToHostAddr and StrToHostAddr6 in sockets unit

2020-05-12 Thread Marc Weustink via fpc-pascal



On 12-5-2020 14:56, Marco van de Voort wrote:


Op 2020-05-12 om 12:32 schreef Michael Van Canneyt:


The names I use here are the libc names, which many other languages 
also use.


Now, StrToHostAddr and StrToHostAddr6 can call the appropriate 
function, and programs that use those functions won't notice any 
change. But new code will be able to use the new functions and have 
an unambiguous answer as to whether the address is valid or not.


The change is quite straightforward to make, and it won't break 
existing code, so I think it's worthwhile to do.


Any thoughts or opinions on this?


I'm all for it, but please use the following names:

function TryStrToHostAddr(IP: String; var ip4: in_addr): Boolean;
function TryStrToHostAddr6(IP: String; var ip6: in6_addr): Boolean;

Rationale for this request: All conversion calls in sysutils and 
dateutils use this naming scheme, it's good for consistency.


(and I hate underscores, but that's beside the point ;))

Yes to the principle and yes to the TryStrTo naming. But I would make 
the IP param CONST ;-)


And maybe change the var into an out

Marc

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


[fpc-pascal] Freepascal/Lazarus forum and Lazarus website outage wrap-up

2020-02-12 Thread Marc Weustink via fpc-pascal

Now that everything seems to be normal, time for a wrap-up, what happened:

There were happening 2 things simultaneously
 - an increased interest(?) from china
 - one or two bots every second looking for SQL injections.

This caused a load on the original server configuration, apache using 
mod_php, so it became unresponsive. Since the amount of traffic was 
larger than normal, but still realistic, I decided to use fast-cgi to 
remove the php overhead from the apache main process. With fast-cgi in 
place I could now use the mpm_event module which can handle way more 
connections to the server.

After some days of config tweaking everything should be fine. not.

The server started to work OK until, according to netstat, about 800 
sockets were in use, after which the server failed to respond. This 
continued till the amount of sockets dropped to about 50 (due to 
timeouts etc). Then the server was responsive again and the whole cycle 
started over again.
After a lot of googling it appeared that this was caused by this issue 
in apache https://bz.apache.org/bugzilla/show_bug.cgi?id=53555

A manual upgrade of apache to the latest version solved the problem.

Marc


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