Fix TLogger.AddStdLine to work with Wine 1.6
authorMegaBrutal <code+git@megabrutal.com>
Wed, 17 Oct 2018 15:30:30 +0000 (17:30 +0200)
committerMegaBrutal <code+git@megabrutal.com>
Wed, 17 Oct 2018 15:30:30 +0000 (17:30 +0200)
commit29de169741b074ce9158bce94f0b8db5088cdcf2
tree30200b9a3efd642ff8ad0a1c4be37dd6521ff06f
parentf4882400776ff6de4f796a3e8123909d5531da53
Fix TLogger.AddStdLine to work with Wine 1.6

Wine 1.6 gives a standard output handle to the service process,
albeit all writes to it fails. Because of this, TLogger.AddStdLine
did not even write to the log file due to short-circuit evaluation.
Now I made sure to attempt both stdout and logfile writes.

Native Windows doesn't provide an stdout handle for service processes
(GetStdHandle returns 0), in which case MgSMTP detects it has no
stdout and redirects its output to mgsmtp_stdout.log. Wine 3.0 behaves
the same, so I deemed the Wine 1.6 behaviour a bug. Therefore, I find
this quick fix sufficient - there is no need to bother with Wine 1.6
compatibility any further, e.g. by checking if Wine 1.6 gave a writable
stdout handle or not. Users of MgSMTP on Wine are rather suggested to
update to Wine 3.0.

modified:   Log.pas
modified:   MgSMTP.pas
Log.pas
MgSMTP.pas