diff --git a/compat.c b/compat.c index a3fb17f7e..765614944 100644 --- a/compat.c +++ b/compat.c @@ -26,6 +26,11 @@ struct iio_context * iio_create_xml_context(const char *xml_file) return create_context_with_arg("xml:", xml_file); } +struct iio_context * iio_create_network_context(const char *hostname) +{ + return create_context_with_arg("ip:", hostname); +} + struct iio_context * iio_create_local_context(void) { return iio_create_context_from_uri("local:"); diff --git a/context.c b/context.c index b176ed3e3..b8bc5f19f 100644 --- a/context.c +++ b/context.c @@ -464,21 +464,6 @@ struct iio_context * iio_create_default_context(void) return iio_create_context_from_uri("local:"); } -static struct iio_context * -iio_create_context_from_uri_arg(const char *backend, const char *arg) -{ - char uri[1024]; - - iio_snprintf(uri, sizeof(uri), "%s:%s", backend, arg); - - return iio_create_context_from_uri(uri); -} - -struct iio_context * iio_create_network_context(const char *hostname) -{ - return iio_create_context_from_uri_arg("ip", hostname); -} - struct iio_context * iio_create_xml_context_mem(const char *xml, size_t len) { if (WITH_XML_BACKEND) diff --git a/iio-compat.h b/iio-compat.h index 14f824225..b5bf05509 100644 --- a/iio-compat.h +++ b/iio-compat.h @@ -36,6 +36,13 @@ __api __check_ret struct iio_context * iio_create_local_context(void); +/** @brief Create a context from the network + * @param host Hostname, IPv4 or IPv6 address where the IIO Daemon is running + * @return On success, a pointer to an iio_context structure + * @return On failure, NULL is returned and errno is set appropriately */ +__api __check_ret struct iio_context * iio_create_network_context(const char *host); + + /** @brief Create a context from a XML file * @param xml_file Path to the XML file to open * @return On success, A pointer to an iio_context structure diff --git a/iio.h b/iio.h index 82b81b609..f2de195b5 100644 --- a/iio.h +++ b/iio.h @@ -429,13 +429,6 @@ __api __check_ret struct iio_context * iio_create_xml_context_mem( const char *xml, size_t len); -/** @brief Create a context from the network - * @param host Hostname, IPv4 or IPv6 address where the IIO Daemon is running - * @return On success, a pointer to an iio_context structure - * @return On failure, NULL is returned and errno is set appropriately */ -__api __check_ret struct iio_context * iio_create_network_context(const char *host); - - /** @brief Create a context from a URI description * @param uri A URI describing the context location * @return On success, a pointer to a iio_context structure