stephane/libmodbus — pull request #102 by oldfaber (2013-03-07 13:58:58+00:00)
Title: Introduce a new debugging function.

PLEASE do not pull yet: this is a request for comments.

Problem:
If the modbus DLL is linked with a GUI application there is no stderr to write to.
It may be solved in the application, but it's not often done.

Solution:
Use the dbgprintf, that behaves differently under windows or other OSes.

Notes
* I removed the ctx->debug tests, I thing the speed gain they need is minimal,
and the new interface allows to dynamically select the verbosity level.
* I also had to replace perrors(), because the Windows socket functions DO NOT set
errno.
* I only touched modbus-tcp.c, as a proof of concept.
* The #define of the log level should probably go to a public header.
* I only tested this code under Windows, it may not compile under Linux or other OSes.

Is this acceptable ?

Thank you.