Set errno when iio_device_create_buffer fails

Signed-off-by: Paul Cercueil <paul.cercueil@analog.com>
IIOD: Wait until the device is opened to return from OPEN

Previously, the OPEN command would return 0 as soon as the client
thread was appended. But that did not guarantee that the opening
succeeded, as the r/w thread could still fail to open the IIO device.

Signed-off-by: Paul Cercueil <paul.cercueil@analog.com>
IIOD: Properly handle errors in read_all

Also, return -EPIPE instead of -EIO of the remote client closed the
connexion.

Signed-off-by: Paul Cercueil <paul.cercueil@analog.com>
Network backend: Added backend function network_write

Signed-off-by: Paul Cercueil <paul.cercueil@analog.com>
Added API function iio_context_get_version

Also added constants in the public header iio.h to inform about the
version of the API programs are compiled with.

Then, it is easy to verify that the version of libiio which was used at
compilation time is the same than the one used at runtime.

Note that iio_context_get_version does not exactly return the version of
the library, but the version of the backend. For most backends, this
corresponds to the version of the library, but the network backend for
instance will instead return the version of the library used by the IIO
daemon.

Signed-off-by: Paul Cercueil <paul.cercueil@analog.com>
IIOD: Avoid receiving SIGPIPE when the client closes the socket

Otherwise the daemon exits, and we don't want that.

Signed-off-by: Paul Cercueil <paul.cercueil@analog.com>
IIOD: Simplify lexer file by removing tokens

Signed-off-by: Paul Cercueil <paul.cercueil@analog.com>
IIOD: Added VERSION command

This command can be used to retrieve the version of the libiio library
used by the server.

Signed-off-by: Paul Cercueil <paul.cercueil@analog.com>
Network backend: Added backend function network_get_version

Signed-off-by: Paul Cercueil <paul.cercueil@analog.com>