Skip to content

Commit

Permalink
iiod: Support new protocol without ZSTD
Browse files Browse the repository at this point in the history
If ZSTD was not enabled during compilation, the PRINT command will
simply send the uncompressed XML string. The client can then detect and
use the uncompressed string directly.

Signed-off-by: Paul Cercueil <[email protected]>
  • Loading branch information
pcercuei committed Jan 30, 2024
1 parent 73e2dc2 commit 91d2fec
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions iiod/iiod.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,11 @@ static void sig_handler_usr1(int sig)

static void *get_xml_zstd_data(const struct iio_context *ctx, size_t *out_len)
{
#if WITH_ZSTD
const char *xml = iio_context_get_xml(ctx);
size_t len, xml_len = strlen(xml);
size_t xml_len = strlen(xml);
void *buf;
#if WITH_ZSTD
size_t len;
size_t ret;

len = ZSTD_compressBound(xml_len);
Expand All @@ -118,11 +119,15 @@ static void *get_xml_zstd_data(const struct iio_context *ctx, size_t *out_len)
}

*out_len = ret;

return buf;
#else
return NULL;
buf = iio_strdup(xml);
if (!buf)
return NULL;

*out_len = xml_len;
#endif

return buf;
}

static void free_device_pdata(struct iio_context *ctx)
Expand Down

0 comments on commit 91d2fec

Please sign in to comment.