From a8c236dc073675dbf740ce73fd281b1aaafdf385 Mon Sep 17 00:00:00 2001 From: Alexander Bushnev Date: Thu, 30 May 2024 19:58:36 +0200 Subject: [PATCH] Rename z_str_data to z_string_data --- examples/arduino/z_get.ino | 4 ++-- examples/arduino/z_pull.ino | 2 +- examples/arduino/z_queryable.ino | 4 ++-- examples/arduino/z_sub.ino | 2 +- examples/espidf/z_get.c | 2 +- examples/espidf/z_pull.c | 2 +- examples/espidf/z_queryable.c | 4 ++-- examples/espidf/z_sub.c | 4 ++-- examples/freertos_plus_tcp/z_get.c | 2 +- examples/freertos_plus_tcp/z_pull.c | 2 +- examples/freertos_plus_tcp/z_queryable.c | 4 ++-- examples/freertos_plus_tcp/z_sub.c | 3 ++- examples/freertos_plus_tcp/z_sub_st.c | 3 ++- examples/mbed/z_get.cpp | 3 ++- examples/mbed/z_pull.cpp | 2 +- examples/mbed/z_queryable.cpp | 4 ++-- examples/mbed/z_sub.cpp | 4 ++-- examples/unix/c11/z_get.c | 2 +- examples/unix/c11/z_get_channel.c | 2 +- examples/unix/c11/z_pull.c | 2 +- examples/unix/c11/z_queryable.c | 4 ++-- examples/unix/c11/z_queryable_channel.c | 4 ++-- examples/unix/c11/z_sub.c | 3 ++- examples/unix/c11/z_sub_channel.c | 2 +- examples/unix/c11/z_sub_st.c | 3 ++- examples/unix/c99/z_get.c | 3 ++- examples/unix/c99/z_pull.c | 3 ++- examples/unix/c99/z_queryable.c | 4 ++-- examples/unix/c99/z_sub.c | 2 +- examples/unix/c99/z_sub_st.c | 2 +- examples/windows/z_get.c | 2 +- examples/windows/z_pull.c | 2 +- examples/windows/z_queryable.c | 4 ++-- examples/windows/z_sub.c | 3 ++- examples/windows/z_sub_st.c | 3 ++- examples/zephyr/z_get.c | 2 +- examples/zephyr/z_pull.c | 2 +- examples/zephyr/z_queryable.c | 4 ++-- examples/zephyr/z_sub.c | 2 +- include/zenoh-pico/api/primitives.h | 2 +- src/api/api.c | 2 +- tests/z_test_fragment_rx.c | 2 +- 42 files changed, 63 insertions(+), 54 deletions(-) diff --git a/examples/arduino/z_get.ino b/examples/arduino/z_get.ino index 3fc12d587..2e172996f 100644 --- a/examples/arduino/z_get.ino +++ b/examples/arduino/z_get.ino @@ -52,9 +52,9 @@ void reply_handler(const z_loaned_reply_t *oreply, void *ctx) { z_bytes_decode_into_string(z_sample_payload(sample), &replystr); Serial.print(" >> [Get listener] Received ("); - Serial.print(z_str_data(z_string_loan(&keystr))); + Serial.print(z_string_data(z_string_loan(&keystr))); Serial.print(", "); - Serial.print(z_str_data(z_string_loan(&replystr))); + Serial.print(z_string_data(z_string_loan(&replystr))); Serial.println(")"); z_string_drop(z_string_move(&keystr)); diff --git a/examples/arduino/z_pull.ino b/examples/arduino/z_pull.ino index dd8a271db..d785a1faf 100644 --- a/examples/arduino/z_pull.ino +++ b/examples/arduino/z_pull.ino @@ -44,7 +44,7 @@ // std::string val((const char *)sample->payload.start, sample->payload.len); // Serial.print(" >> [Subscription listener] Received ("); -// Serial.print(z_str_data(z_string_loan(&keystr))); +// Serial.print(z_string_data(z_string_loan(&keystr))); // Serial.print(", "); // Serial.print(val.c_str()); // Serial.println(")"); diff --git a/examples/arduino/z_queryable.ino b/examples/arduino/z_queryable.ino index b7f652b7f..d4751dab5 100644 --- a/examples/arduino/z_queryable.ino +++ b/examples/arduino/z_queryable.ino @@ -39,7 +39,7 @@ void query_handler(const z_loaned_query_t *query, void *arg) { z_owned_string_t keystr; z_keyexpr_to_string(z_query_keyexpr(query), &keystr); Serial.print(" >> [Queryable handler] Received Query '"); - Serial.print(z_str_data(z_string_loan(&keystr))); + Serial.print(z_string_data(z_string_loan(&keystr))); Serial.println("'"); // Process value @@ -48,7 +48,7 @@ void query_handler(const z_loaned_query_t *query, void *arg) { z_owned_string_t payload_string; z_bytes_decode_into_string(payload, &payload_string); Serial.print(" with value '"); - Serial.print(z_str_data(z_string_loan(&payload_string))); + Serial.print(z_string_data(z_string_loan(&payload_string))); Serial.println("'"); z_string_drop(z_string_move(&payload_string)); } diff --git a/examples/arduino/z_sub.ino b/examples/arduino/z_sub.ino index 5336932e1..990ab7580 100644 --- a/examples/arduino/z_sub.ino +++ b/examples/arduino/z_sub.ino @@ -40,7 +40,7 @@ void data_handler(const z_loaned_sample_t *sample, void *arg) { std::string val((const char *)z_sample_payload(sample)->start, z_sample_payload(sample)->len); Serial.print(" >> [Subscription listener] Received ("); - Serial.print(z_str_data(z_string_loan(&keystr))); + Serial.print(z_string_data(z_string_loan(&keystr))); Serial.print(", "); Serial.print(val.c_str()); Serial.println(")"); diff --git a/examples/espidf/z_get.c b/examples/espidf/z_get.c index 889e4e1a5..eb06f20f1 100644 --- a/examples/espidf/z_get.c +++ b/examples/espidf/z_get.c @@ -111,7 +111,7 @@ void reply_handler(const z_loaned_reply_t *oreply, void *ctx) { z_owned_string_t replystr; z_bytes_decode_into_string(z_sample_payload(sample), &replystr); - printf(" >> Received ('%s': '%s')\n", z_str_data(z_loan(keystr)), z_str_data(z_loan(replystr))); + printf(" >> Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(replystr))); z_drop(z_move(keystr)); z_drop(z_move(replystr)); } else { diff --git a/examples/espidf/z_pull.c b/examples/espidf/z_pull.c index 8efd04a29..9647f4ef2 100644 --- a/examples/espidf/z_pull.c +++ b/examples/espidf/z_pull.c @@ -104,7 +104,7 @@ void wifi_init_sta(void) { // void data_handler(const z_loaned_sample_t* sample, void* arg) { // z_owned_string_t keystr; // z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); -// printf(" >> [Subscriber handler] Received ('%s': '%.*s')\n", z_str_data(z_loan(keystr)), +// printf(" >> [Subscriber handler] Received ('%s': '%.*s')\n", z_string_data(z_loan(keystr)), // (int)sample->payload.len, // sample->payload.start); // z_drop(z_move(keystr)); diff --git a/examples/espidf/z_queryable.c b/examples/espidf/z_queryable.c index dbf232594..48b09ff8b 100644 --- a/examples/espidf/z_queryable.c +++ b/examples/espidf/z_queryable.c @@ -107,14 +107,14 @@ void query_handler(const z_loaned_query_t *query, void *ctx) { z_keyexpr_to_string(z_query_keyexpr(query), &keystr); z_view_string_t params; z_query_parameters(query, ¶ms); - printf(" >> [Queryable handler] Received Query '%s%.*s'\n", z_str_data(z_loan(keystr)), (int)z_loan(params)->len, + printf(" >> [Queryable handler] Received Query '%s%.*s'\n", z_string_data(z_loan(keystr)), (int)z_loan(params)->len, z_loan(params)->val); // Process value const z_loaned_bytes_t *payload = z_value_payload(z_query_value(query)); if (z_bytes_len(payload) > 0) { z_owned_string_t payload_string; z_bytes_decode_into_string(payload, &payload_string); - printf(" with value '%s'\n", z_str_data(z_loan(payload_string))); + printf(" with value '%s'\n", z_string_data(z_loan(payload_string))); z_drop(z_move(payload_string)); } z_view_keyexpr_t ke; diff --git a/examples/espidf/z_sub.c b/examples/espidf/z_sub.c index 45e1b8ed9..d496734e6 100644 --- a/examples/espidf/z_sub.c +++ b/examples/espidf/z_sub.c @@ -104,8 +104,8 @@ void data_handler(const z_loaned_sample_t* sample, void* arg) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); const z_loaned_bytes_t* payload = z_sample_payload(sample); - printf(" >> [Subscriber handler] Received ('%s': '%.*s')\n", z_str_data(z_string_loan(&keystr)), (int)payload->len, - payload->start); + printf(" >> [Subscriber handler] Received ('%s': '%.*s')\n", z_string_data(z_string_loan(&keystr)), + (int)payload->len, payload->start); z_string_drop(z_string_move(&keystr)); } diff --git a/examples/freertos_plus_tcp/z_get.c b/examples/freertos_plus_tcp/z_get.c index 3c7ddbb3b..1d53dab41 100644 --- a/examples/freertos_plus_tcp/z_get.c +++ b/examples/freertos_plus_tcp/z_get.c @@ -45,7 +45,7 @@ void reply_handler(const z_loaned_reply_t *reply, void *ctx) { z_owned_string_t replystr; z_bytes_decode_into_string(z_sample_payload(sample), &replystr); - printf(">> Received ('%s': '%s')\n", z_str_data(z_loan(keystr)), z_str_data(z_loan(replystr))); + printf(">> Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(replystr))); z_drop(z_move(keystr)); z_drop(z_move(replystr)); } else { diff --git a/examples/freertos_plus_tcp/z_pull.c b/examples/freertos_plus_tcp/z_pull.c index 6f1273b70..8d2ef7f8f 100644 --- a/examples/freertos_plus_tcp/z_pull.c +++ b/examples/freertos_plus_tcp/z_pull.c @@ -33,7 +33,7 @@ // (void)(ctx); // z_owned_string_t keystr; // z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); -// printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_str_data(z_loan(keystr)), (int)sample->payload.len, +// printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_string_data(z_loan(keystr)), (int)sample->payload.len, // sample->payload.start); // z_drop(z_move(keystr)); // } diff --git a/examples/freertos_plus_tcp/z_queryable.c b/examples/freertos_plus_tcp/z_queryable.c index be8e1672f..20d72f7eb 100644 --- a/examples/freertos_plus_tcp/z_queryable.c +++ b/examples/freertos_plus_tcp/z_queryable.c @@ -35,14 +35,14 @@ void query_handler(const z_loaned_query_t *query, void *ctx) { z_keyexpr_to_string(z_query_keyexpr(query), &keystr); z_view_string_t params; z_query_parameters(query, ¶ms); - printf(" >> [Queryable handler] Received Query '%s%.*s'\n", z_str_data(z_loan(keystr)), (int)z_loan(params)->len, + printf(" >> [Queryable handler] Received Query '%s%.*s'\n", z_string_data(z_loan(keystr)), (int)z_loan(params)->len, z_loan(params)->val); // Process value const z_loaned_bytes_t *payload = z_value_payload(z_query_value(query)); if (z_bytes_len(payload) > 0) { z_owned_string_t payload_string; z_bytes_decode_into_string(payload, &payload_string); - printf(" with value '%s'\n", z_str_data(z_loan(payload_string))); + printf(" with value '%s'\n", z_string_data(z_loan(payload_string))); z_drop(z_move(payload_string)); } z_query_reply_options_t options; diff --git a/examples/freertos_plus_tcp/z_sub.c b/examples/freertos_plus_tcp/z_sub.c index dbf7e79f9..d0afc19ad 100644 --- a/examples/freertos_plus_tcp/z_sub.c +++ b/examples/freertos_plus_tcp/z_sub.c @@ -33,7 +33,8 @@ void data_handler(const z_loaned_sample_t *sample, void *ctx) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); const z_loaned_bytes_t *payload = z_sample_payload(sample); - printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_str_data(z_loan(keystr)), (int)payload->len, payload->start); + printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_string_data(z_loan(keystr)), (int)payload->len, + payload->start); z_drop(z_move(keystr)); } diff --git a/examples/freertos_plus_tcp/z_sub_st.c b/examples/freertos_plus_tcp/z_sub_st.c index 151e078a6..aa24456ee 100644 --- a/examples/freertos_plus_tcp/z_sub_st.c +++ b/examples/freertos_plus_tcp/z_sub_st.c @@ -36,7 +36,8 @@ void data_handler(const z_loaned_sample_t *sample, void *ctx) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); const z_loaned_bytes_t *payload = z_sample_payload(sample); - printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_str_data(z_loan(keystr)), (int)payload->len, payload->start); + printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_string_data(z_loan(keystr)), (int)payload->len, + payload->start); z_drop(z_move(keystr)); z_drop(z_move(keystr)); msg_nb++; diff --git a/examples/mbed/z_get.cpp b/examples/mbed/z_get.cpp index d5f89b09d..699186612 100644 --- a/examples/mbed/z_get.cpp +++ b/examples/mbed/z_get.cpp @@ -41,7 +41,8 @@ void reply_handler(const z_loaned_reply_t *oreply, void *ctx) { z_owned_string_t replystr; z_bytes_decode_into_string(z_sample_payload(sample), &replystr); - printf(" >> Received ('%s': '%s')\n", z_str_data(z_string_loan(&keystr)), z_str_data(z_string_loan(&replystr))); + printf(" >> Received ('%s': '%s')\n", z_string_data(z_string_loan(&keystr)), + z_string_data(z_string_loan(&replystr))); z_string_drop(z_string_move(&keystr)); z_string_drop(z_string_move(&replystr)); } else { diff --git a/examples/mbed/z_pull.cpp b/examples/mbed/z_pull.cpp index d01f2978c..52a4f9be0 100644 --- a/examples/mbed/z_pull.cpp +++ b/examples/mbed/z_pull.cpp @@ -34,7 +34,7 @@ // void data_handler(const z_loaned_sample_t *sample, void *arg) { // z_owned_string_t keystr; // z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); -// printf(" >> [Subscriber handler] Received ('%s': '%.*s')\n", z_str_data(z_string_loan(&keystr)), +// printf(" >> [Subscriber handler] Received ('%s': '%.*s')\n", z_string_data(z_string_loan(&keystr)), // (int)sample->payload.len, // sample->payload.start); // z_string_drop(z_string_move(&keystr)); diff --git a/examples/mbed/z_queryable.cpp b/examples/mbed/z_queryable.cpp index 64f68e9fa..5c09bf79f 100644 --- a/examples/mbed/z_queryable.cpp +++ b/examples/mbed/z_queryable.cpp @@ -37,14 +37,14 @@ void query_handler(const z_loaned_query_t *query, void *ctx) { z_keyexpr_to_string(z_query_keyexpr(query), &keystr); z_view_string_t pred; z_query_parameters(query, &pred); - printf(" >> [Queryable handler] Received Query '%s%.*s'\n", z_str_data(z_string_loan(&keystr)), + printf(" >> [Queryable handler] Received Query '%s%.*s'\n", z_string_data(z_string_loan(&keystr)), (int)z_view_string_loan(&pred)->len, z_view_string_loan(&pred)->val); // Process value const z_loaned_bytes_t *payload = z_value_payload(z_query_value(query)); if (z_bytes_len(payload) > 0) { z_owned_string_t payload_string; z_bytes_decode_into_string(payload, &payload_string); - printf(" with value '%s'\n", z_str_data(z_string_loan(&payload_string))); + printf(" with value '%s'\n", z_string_data(z_string_loan(&payload_string))); z_string_drop(z_string_move(&payload_string)); } // Reply value encoding diff --git a/examples/mbed/z_sub.cpp b/examples/mbed/z_sub.cpp index 537630d6a..20ea106d4 100644 --- a/examples/mbed/z_sub.cpp +++ b/examples/mbed/z_sub.cpp @@ -34,8 +34,8 @@ void data_handler(const z_loaned_sample_t *sample, void *arg) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); const z_loaned_bytes_t *payload = z_sample_payload(sample); - printf(" >> [Subscriber handler] Received ('%s': '%.*s')\n", z_str_data(z_string_loan(&keystr)), (int)payload->len, - payload->start); + printf(" >> [Subscriber handler] Received ('%s': '%.*s')\n", z_string_data(z_string_loan(&keystr)), + (int)payload->len, payload->start); z_string_drop(z_string_move(&keystr)); } diff --git a/examples/unix/c11/z_get.c b/examples/unix/c11/z_get.c index b650556ed..f7677e3b3 100644 --- a/examples/unix/c11/z_get.c +++ b/examples/unix/c11/z_get.c @@ -46,7 +46,7 @@ void reply_handler(const z_loaned_reply_t *reply, void *ctx) { z_owned_string_t replystr; z_bytes_decode_into_string(z_sample_payload(sample), &replystr); - printf(">> Received ('%s': '%s')\n", z_str_data(z_loan(keystr)), z_str_data(z_loan(replystr))); + printf(">> Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(replystr))); #if Z_FEATURE_ATTACHMENT == 1 if (z_attachment_check(&sample.attachment)) { printf("Attachement found\n"); diff --git a/examples/unix/c11/z_get_channel.c b/examples/unix/c11/z_get_channel.c index daefcd25c..4f74b1848 100644 --- a/examples/unix/c11/z_get_channel.c +++ b/examples/unix/c11/z_get_channel.c @@ -115,7 +115,7 @@ int main(int argc, char **argv) { z_owned_string_t replystr; z_bytes_decode_into_string(z_sample_payload(sample), &replystr); - printf(">> Received ('%s': '%s')\n", z_str_data(z_loan(keystr)), z_str_data(z_loan(replystr))); + printf(">> Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(replystr))); z_drop(z_move(keystr)); z_drop(z_move(replystr)); } else { diff --git a/examples/unix/c11/z_pull.c b/examples/unix/c11/z_pull.c index 5b396c265..6e7506663 100644 --- a/examples/unix/c11/z_pull.c +++ b/examples/unix/c11/z_pull.c @@ -90,7 +90,7 @@ int main(int argc, char **argv) { for (z_call(channel.try_recv, &sample); z_check(sample); z_call(channel.try_recv, &sample)) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(z_loan(sample)), &keystr); - printf(">> [Subscriber] Pulled ('%s': '%.*s')\n", z_str_data(z_loan(keystr)), + printf(">> [Subscriber] Pulled ('%s': '%.*s')\n", z_string_data(z_loan(keystr)), (int)z_sample_payload(z_loan(sample))->len, z_sample_payload(z_loan(sample))->start); z_drop(z_move(keystr)); z_drop(z_move(sample)); diff --git a/examples/unix/c11/z_queryable.c b/examples/unix/c11/z_queryable.c index b480c3636..3fd4b415a 100644 --- a/examples/unix/c11/z_queryable.c +++ b/examples/unix/c11/z_queryable.c @@ -37,14 +37,14 @@ void query_handler(const z_loaned_query_t *query, void *ctx) { z_keyexpr_to_string(z_query_keyexpr(query), &keystr); z_view_string_t params; z_query_parameters(query, ¶ms); - printf(" >> [Queryable handler] Received Query '%s%.*s'\n", z_str_data(z_loan(keystr)), (int)z_loan(params)->len, + printf(" >> [Queryable handler] Received Query '%s%.*s'\n", z_string_data(z_loan(keystr)), (int)z_loan(params)->len, z_loan(params)->val); // Process value const z_loaned_bytes_t *payload = z_value_payload(z_query_value(query)); if (z_bytes_len(payload) > 0) { z_owned_string_t payload_string; z_bytes_decode_into_string(payload, &payload_string); - printf(" with value '%s'\n", z_str_data(z_loan(payload_string))); + printf(" with value '%s'\n", z_string_data(z_loan(payload_string))); z_drop(z_move(payload_string)); } #if Z_FEATURE_ATTACHMENT == 1 diff --git a/examples/unix/c11/z_queryable_channel.c b/examples/unix/c11/z_queryable_channel.c index 562e6cd66..9038790b2 100644 --- a/examples/unix/c11/z_queryable_channel.c +++ b/examples/unix/c11/z_queryable_channel.c @@ -104,13 +104,13 @@ int main(int argc, char **argv) { z_keyexpr_to_string(z_query_keyexpr(q), &keystr); z_view_string_t params; z_query_parameters(q, ¶ms); - printf(" >> [Queryable handler] Received Query '%s%.*s'\n", z_str_data(z_loan(keystr)), + printf(" >> [Queryable handler] Received Query '%s%.*s'\n", z_string_data(z_loan(keystr)), (int)z_loan(params)->len, z_loan(params)->val); const z_loaned_bytes_t *payload = z_value_payload(z_query_value(z_loan(query))); if (z_bytes_len(payload) > 0) { z_owned_string_t payload_string; z_bytes_decode_into_string(payload, &payload_string); - printf(" with value '%s'\n", z_str_data(z_loan(payload_string))); + printf(" with value '%s'\n", z_string_data(z_loan(payload_string))); z_drop(z_move(payload_string)); } z_query_reply_options_t options; diff --git a/examples/unix/c11/z_sub.c b/examples/unix/c11/z_sub.c index df6bf9e07..a91133fa6 100644 --- a/examples/unix/c11/z_sub.c +++ b/examples/unix/c11/z_sub.c @@ -37,7 +37,8 @@ void data_handler(const z_loaned_sample_t *sample, void *ctx) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); const z_loaned_bytes_t *payload = z_sample_payload(sample); - printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_str_data(z_loan(keystr)), (int)payload->len, payload->start); + printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_string_data(z_loan(keystr)), (int)payload->len, + payload->start); #if Z_FEATURE_ATTACHMENT == 1 z_attachment_t attachment = z_sample_attachment(sample); if (z_attachment_check(&attachment)) { diff --git a/examples/unix/c11/z_sub_channel.c b/examples/unix/c11/z_sub_channel.c index 1067a475f..02a793961 100644 --- a/examples/unix/c11/z_sub_channel.c +++ b/examples/unix/c11/z_sub_channel.c @@ -80,7 +80,7 @@ int main(int argc, char **argv) { for (z_call(channel.recv, &sample); z_check(sample); z_call(channel.recv, &sample)) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(z_loan(sample)), &keystr); - printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_str_data(z_loan(keystr)), + printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_string_data(z_loan(keystr)), (int)z_sample_payload(z_loan(sample))->len, z_sample_payload(z_loan(sample))->start); z_drop(z_move(keystr)); z_drop(z_move(sample)); diff --git a/examples/unix/c11/z_sub_st.c b/examples/unix/c11/z_sub_st.c index 852011459..97bcacfc0 100644 --- a/examples/unix/c11/z_sub_st.c +++ b/examples/unix/c11/z_sub_st.c @@ -28,7 +28,8 @@ void data_handler(const z_loaned_sample_t *sample, void *ctx) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); const z_loaned_bytes_t *payload = z_sample_payload(sample); - printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_str_data(z_loan(keystr)), (int)payload->len, payload->start); + printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_string_data(z_loan(keystr)), (int)payload->len, + payload->start); z_drop(z_move(keystr)); msg_nb++; } diff --git a/examples/unix/c99/z_get.c b/examples/unix/c99/z_get.c index 78a9a6ad4..12c5bc3f6 100644 --- a/examples/unix/c99/z_get.c +++ b/examples/unix/c99/z_get.c @@ -38,7 +38,8 @@ void reply_handler(const z_loaned_reply_t *reply, void *ctx) { z_owned_string_t replystr; z_bytes_decode_into_string(z_sample_payload(sample), &replystr); - printf(">> Received ('%s': '%s')\n", z_str_data(z_string_loan(&keystr)), z_str_data(z_string_loan(&replystr))); + printf(">> Received ('%s': '%s')\n", z_string_data(z_string_loan(&keystr)), + z_string_data(z_string_loan(&replystr))); z_string_drop(z_string_move(&keystr)); z_string_drop(z_string_move(&replystr)); } else { diff --git a/examples/unix/c99/z_pull.c b/examples/unix/c99/z_pull.c index 0760264de..460389878 100644 --- a/examples/unix/c99/z_pull.c +++ b/examples/unix/c99/z_pull.c @@ -24,7 +24,8 @@ // (void)(ctx); // z_owned_string_t keystr; // z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); -// printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_str_data(z_string_loan(&keystr)), (int)sample->payload.len, +// printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_string_data(z_string_loan(&keystr)), +// (int)sample->payload.len, // sample->payload.start); // z_string_drop(z_string_move(&keystr)); // } diff --git a/examples/unix/c99/z_queryable.c b/examples/unix/c99/z_queryable.c index de03d1c49..f4b7b4156 100644 --- a/examples/unix/c99/z_queryable.c +++ b/examples/unix/c99/z_queryable.c @@ -28,14 +28,14 @@ void query_handler(const z_loaned_query_t *query, void *ctx) { z_keyexpr_to_string(z_query_keyexpr(query), &keystr); z_view_string_t params; z_query_parameters(query, ¶ms); - printf(" >> [Queryable handler] Received Query '%s%.*s'\n", z_str_data(z_string_loan(&keystr)), + printf(" >> [Queryable handler] Received Query '%s%.*s'\n", z_string_data(z_string_loan(&keystr)), (int)z_view_string_loan(¶ms)->len, z_view_string_loan(¶ms)->val); // Process value const z_loaned_bytes_t *payload = z_value_payload(z_query_value(query)); if (z_bytes_len(payload) > 0) { z_owned_string_t payload_string; z_bytes_decode_into_string(payload, &payload_string); - printf(" with value '%s'\n", z_str_data(z_string_loan(&payload_string))); + printf(" with value '%s'\n", z_string_data(z_string_loan(&payload_string))); z_string_drop(z_string_move(&payload_string)); } z_query_reply_options_t options; diff --git a/examples/unix/c99/z_sub.c b/examples/unix/c99/z_sub.c index fa05fc001..3495d167a 100644 --- a/examples/unix/c99/z_sub.c +++ b/examples/unix/c99/z_sub.c @@ -25,7 +25,7 @@ void data_handler(const z_loaned_sample_t *sample, void *arg) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); const z_loaned_bytes_t *payload = z_sample_payload(sample); - printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_str_data(z_string_loan(&keystr)), (int)payload->len, + printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_string_data(z_string_loan(&keystr)), (int)payload->len, payload->start); z_string_drop(z_string_move(&keystr)); } diff --git a/examples/unix/c99/z_sub_st.c b/examples/unix/c99/z_sub_st.c index f97540233..c83d059ba 100644 --- a/examples/unix/c99/z_sub_st.c +++ b/examples/unix/c99/z_sub_st.c @@ -28,7 +28,7 @@ void data_handler(const z_loaned_sample_t *sample, void *arg) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); const z_loaned_bytes_t *payload = z_sample_payload(sample); - printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_str_data(z_string_loan(&keystr)), (int)payload->len, + printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_string_data(z_string_loan(&keystr)), (int)payload->len, payload->start); z_string_drop(z_string_move(&keystr)); msg_nb++; diff --git a/examples/windows/z_get.c b/examples/windows/z_get.c index 8e0192618..9292ebdb1 100644 --- a/examples/windows/z_get.c +++ b/examples/windows/z_get.c @@ -37,7 +37,7 @@ void reply_handler(const z_loaned_reply_t *reply, void *ctx) { z_owned_string_t replystr; z_bytes_decode_into_string(z_sample_payload(sample), &replystr); - printf(">> Received ('%s': '%s')\n", z_str_data(z_loan(keystr)), z_str_data(z_loan(replystr))); + printf(">> Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(replystr))); z_drop(z_move(keystr)); z_drop(z_move(replystr)); } else { diff --git a/examples/windows/z_pull.c b/examples/windows/z_pull.c index 5dd66e558..9256cf4d9 100644 --- a/examples/windows/z_pull.c +++ b/examples/windows/z_pull.c @@ -23,7 +23,7 @@ // (void)(ctx); // z_owned_string_t keystr; // z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); -// printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_str_data(z_loan(keystr)), (int)sample->payload.len, +// printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_string_data(z_loan(keystr)), (int)sample->payload.len, // sample->payload.start); // z_drop(z_move(keystr)); // } diff --git a/examples/windows/z_queryable.c b/examples/windows/z_queryable.c index d5c06db56..6ccae4b3a 100644 --- a/examples/windows/z_queryable.c +++ b/examples/windows/z_queryable.c @@ -28,14 +28,14 @@ void query_handler(const z_loaned_query_t *query, void *ctx) { z_view_string_t params; z_query_parameters(query, ¶ms); - printf(" >> [Queryable handler] Received Query '%s%.*s'\n", z_str_data(z_loan(keystr)), (int)z_loan(params)->len, + printf(" >> [Queryable handler] Received Query '%s%.*s'\n", z_string_data(z_loan(keystr)), (int)z_loan(params)->len, z_loan(params)->val); // Process value const z_loaned_bytes_t *payload = z_value_payload(z_query_value(query)); if (z_bytes_len(payload) > 0) { z_owned_string_t payload_string; z_bytes_decode_into_string(payload, &payload_string); - printf(" with value '%s'\n", z_str_data(z_loan(payload_string))); + printf(" with value '%s'\n", z_string_data(z_loan(payload_string))); z_drop(z_move(payload_string)); } z_query_reply_options_t options; diff --git a/examples/windows/z_sub.c b/examples/windows/z_sub.c index e908f2534..5ca826633 100644 --- a/examples/windows/z_sub.c +++ b/examples/windows/z_sub.c @@ -24,7 +24,8 @@ void data_handler(const z_loaned_sample_t *sample, void *ctx) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); const z_loaned_bytes_t *payload = z_sample_payload(sample); - printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_str_data(z_loan(keystr)), (int)payload->len, payload->start); + printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_string_data(z_loan(keystr)), (int)payload->len, + payload->start); z_drop(z_move(keystr)); } diff --git a/examples/windows/z_sub_st.c b/examples/windows/z_sub_st.c index fed96e89c..5aed70bdc 100644 --- a/examples/windows/z_sub_st.c +++ b/examples/windows/z_sub_st.c @@ -27,7 +27,8 @@ void data_handler(const z_loaned_sample_t *sample, void *ctx) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); const z_loaned_bytes_t *payload = z_sample_payload(sample); - printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_str_data(z_loan(keystr)), (int)payload->len, payload->start); + printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_string_data(z_loan(keystr)), (int)payload->len, + payload->start); z_drop(z_move(keystr)); msg_nb++; diff --git a/examples/zephyr/z_get.c b/examples/zephyr/z_get.c index f4213b96c..2635eb1ef 100644 --- a/examples/zephyr/z_get.c +++ b/examples/zephyr/z_get.c @@ -42,7 +42,7 @@ void reply_handler(const z_loaned_reply_t *oreply, void *ctx) { z_owned_string_t replystr; z_bytes_decode_into_string(z_sample_payload(sample), &replystr); - printf(" >> Received ('%s': '%s')\n", z_str_data(z_loan(keystr)), z_str_data(z_loan(replystr))); + printf(" >> Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(replystr))); z_drop(z_move(keystr)); z_drop(z_move(replystr)); } else { diff --git a/examples/zephyr/z_pull.c b/examples/zephyr/z_pull.c index 374c6e8d3..007b20ba5 100644 --- a/examples/zephyr/z_pull.c +++ b/examples/zephyr/z_pull.c @@ -33,7 +33,7 @@ // void data_handler(const z_loaned_sample_t *sample, void *arg) { // z_owned_string_t keystr; // z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); -// printf(" >> [Subscriber handler] Received ('%s': '%.*s')\n", z_str_data(z_loan(keystr)), +// printf(" >> [Subscriber handler] Received ('%s': '%.*s')\n", z_string_data(z_loan(keystr)), // (int)sample->payload.len, // sample->payload.start); // z_drop(z_move(keystr)); diff --git a/examples/zephyr/z_queryable.c b/examples/zephyr/z_queryable.c index 3cbb4c3bb..61e8710f8 100644 --- a/examples/zephyr/z_queryable.c +++ b/examples/zephyr/z_queryable.c @@ -37,14 +37,14 @@ void query_handler(const z_loaned_query_t *query, void *ctx) { z_keyexpr_to_string(z_query_keyexpr(query), &keystr); z_view_string_t params; z_query_parameters(query, ¶ms); - printf(" >> [Queryable handler] Received Query '%s%.*s'\n", z_str_data(z_loan(keystr)), z_loan(params)->len, + printf(" >> [Queryable handler] Received Query '%s%.*s'\n", z_string_data(z_loan(keystr)), z_loan(params)->len, z_loan(params)->val); // Process value const z_loaned_bytes_t *payload = z_value_payload(z_query_value(query)); if (z_bytes_len(payload) > 0) { z_owned_string_t payload_string; z_bytes_decode_into_string(payload, &payload_string); - printf(" with value '%s'\n", z_str_data(z_loan(payload_string))); + printf(" with value '%s'\n", z_string_data(z_loan(payload_string))); z_drop(z_move(payload_string)); } // Reply value encoding diff --git a/examples/zephyr/z_sub.c b/examples/zephyr/z_sub.c index 81b97ad01..bda16ff13 100644 --- a/examples/zephyr/z_sub.c +++ b/examples/zephyr/z_sub.c @@ -33,7 +33,7 @@ void data_handler(const z_loaned_sample_t *sample, void *arg) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); const z_loaned_bytes_t *payload = z_sample_payload(sample); - printf(" >> [Subscriber handler] Received ('%s': '%.*s')\n", z_str_data(z_loan(keystr)), (int)payload->len, + printf(" >> [Subscriber handler] Received ('%s': '%.*s')\n", z_string_data(z_loan(keystr)), (int)payload->len, payload->start); z_drop(z_move(keystr)); } diff --git a/include/zenoh-pico/api/primitives.h b/include/zenoh-pico/api/primitives.h index 6a782b3a4..0999b306b 100644 --- a/include/zenoh-pico/api/primitives.h +++ b/include/zenoh-pico/api/primitives.h @@ -824,7 +824,7 @@ _VIEW_FUNCTIONS(z_loaned_string_t, z_view_string_t, string) // TODO(sashacmc): comments, docs, etc. const z_loaned_sample_t *z_sample_loan(const z_owned_sample_t *sample); -const char *z_str_data(const z_loaned_string_t *str); +const char *z_string_data(const z_loaned_string_t *str); /************* Primitives **************/ /** diff --git a/src/api/api.c b/src/api/api.c index fe358e755..1d7aa356c 100644 --- a/src/api/api.c +++ b/src/api/api.c @@ -593,7 +593,7 @@ z_qos_t z_sample_qos(const z_loaned_sample_t *sample) { return _Z_RC_IN_VAL(samp z_attachment_t z_sample_attachment(const z_loaned_sample_t *sample) { return _Z_RC_IN_VAL(sample).attachment; } #endif -const char *z_str_data(const z_loaned_string_t *str) { return str->val; } +const char *z_string_data(const z_loaned_string_t *str) { return str->val; } #if Z_FEATURE_PUBLICATION == 1 int8_t _z_publisher_drop(_z_publisher_t **pub) { diff --git a/tests/z_test_fragment_rx.c b/tests/z_test_fragment_rx.c index 55bd8bce2..8f1c8b95f 100644 --- a/tests/z_test_fragment_rx.c +++ b/tests/z_test_fragment_rx.c @@ -31,7 +31,7 @@ void data_handler(const z_loaned_sample_t *sample, void *ctx) { break; } } - printf("[rx]: Received packet on %s, len: %d, validity: %d\n", z_str_data(z_loan(keystr)), + printf("[rx]: Received packet on %s, len: %d, validity: %d\n", z_string_data(z_loan(keystr)), (int)z_sample_payload(sample)->len, is_valid); z_drop(z_move(keystr)); }