Skip to content

Commit

Permalink
Update string usage examples (#587)
Browse files Browse the repository at this point in the history
Using z_string_data + z_string_len
  • Loading branch information
sashacmc authored Aug 12, 2024
1 parent 939c469 commit 0944a5d
Show file tree
Hide file tree
Showing 41 changed files with 98 additions and 63 deletions.
4 changes: 2 additions & 2 deletions examples/arduino/z_get.ino
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ void reply_handler(const z_loaned_reply_t *oreply, void *ctx) {
z_bytes_deserialize_into_string(z_sample_payload(sample), &replystr);

Serial.print(" >> [Get listener] Received (");
Serial.print(z_string_data(z_view_string_loan(&keystr)));
Serial.write(z_string_data(z_view_string_loan(&keystr)), z_string_len(z_view_string_loan(&keystr)));
Serial.print(", ");
Serial.print(z_string_data(z_string_loan(&replystr)));
Serial.write(z_string_data(z_string_loan(&replystr)), z_string_len(z_string_loan(&replystr)));
Serial.println(")");

z_string_drop(z_string_move(&replystr));
Expand Down
4 changes: 2 additions & 2 deletions examples/arduino/z_queryable.ino
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ void query_handler(const z_loaned_query_t *query, void *arg) {
z_view_string_t keystr;
z_keyexpr_as_view_string(z_query_keyexpr(query), &keystr);
Serial.print(" >> [Queryable handler] Received Query '");
Serial.print(z_string_data(z_view_string_loan(&keystr)));
Serial.write(z_string_data(z_view_string_loan(&keystr)), z_string_len(z_view_string_loan(&keystr)));
Serial.println("'");

// Process value
z_owned_string_t payload_string;
z_bytes_deserialize_into_string(z_query_payload(query), &payload_string);
if (z_string_len(z_string_loan(&payload_string)) > 1) {
Serial.print(" with value '");
Serial.print(z_string_data(z_string_loan(&payload_string)));
Serial.write(z_string_data(z_string_loan(&payload_string)), z_string_len(z_string_loan(&payload_string)));
Serial.println("'");
}
z_string_drop(z_string_move(&payload_string));
Expand Down
4 changes: 2 additions & 2 deletions examples/arduino/z_sub.ino
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ void data_handler(const z_loaned_sample_t *sample, void *arg) {
z_bytes_deserialize_into_string(z_sample_payload(sample), &value);

Serial.print(" >> [Subscription listener] Received (");
Serial.print(z_string_data(z_view_string_loan(&keystr)));
Serial.write(z_string_data(z_view_string_loan(&keystr)), z_string_len(z_view_string_loan(&keystr)));
Serial.print(", ");
Serial.print(z_string_data(z_string_loan(&value)));
Serial.write(z_string_data(z_string_loan(&value)), z_string_len(z_string_loan(&value)));
Serial.println(")");

z_string_drop(z_string_move(&value));
Expand Down
3 changes: 2 additions & 1 deletion examples/espidf/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ void reply_handler(const z_loaned_reply_t *oreply, void *ctx) {
z_owned_string_t replystr;
z_bytes_deserialize_into_string(z_sample_payload(sample), &replystr);

printf(" >> Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(replystr)));
printf(" >> Received ('%.*s': '%.*s')\n", (int)z_string_len(z_loan(keystr)), z_string_data(z_loan(keystr)),
(int)z_string_len(z_loan(replystr)), z_string_data(z_loan(replystr)));
z_drop(z_move(replystr));
} else {
printf(" >> Received an error\n");
Expand Down
4 changes: 2 additions & 2 deletions examples/espidf/z_pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ void app_main() {
z_keyexpr_as_view_string(z_sample_keyexpr(z_loan(sample)), &keystr);
z_owned_string_t value;
z_bytes_deserialize_into_string(z_sample_payload(z_loan(sample)), &value);
printf(">> [Subscriber] Pulled ('%s': '%s')\n", z_string_data(z_loan(keystr)),
z_string_data(z_loan(value)));
printf(">> [Subscriber] Pulled ('%.*s': '%.*s')\n", (int)z_string_len(z_loan(keystr)),
z_string_data(z_loan(keystr)), (int)z_string_len(z_loan(value)), z_string_data(z_loan(value)));
z_drop(z_move(value));
z_drop(z_move(sample));
}
Expand Down
3 changes: 2 additions & 1 deletion examples/espidf/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ void query_handler(const z_loaned_query_t *query, void *ctx) {
z_owned_string_t payload_string;
z_bytes_deserialize_into_string(z_query_payload(query), &payload_string);
if (z_string_len(z_loan(payload_string)) > 0) {
printf(" with value '%s'\n", z_string_data(z_loan(payload_string)));
printf(" with value '%.*s'\n", (int)z_string_len(z_loan(payload_string)),
z_string_data(z_loan(payload_string)));
}
z_drop(z_move(payload_string));

Expand Down
3 changes: 2 additions & 1 deletion examples/espidf/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ void data_handler(const z_loaned_sample_t* sample, void* arg) {
z_keyexpr_as_view_string(z_sample_keyexpr(sample), &keystr);
z_owned_string_t value;
z_bytes_deserialize_into_string(z_sample_payload(sample), &value);
printf(" >> [Subscriber handler] Received ('%s': '%s')\n", z_string_data(z_view_string_loan(&keystr)),
printf(" >> [Subscriber handler] Received ('%.*s': '%.*s')\n", (int)z_string_len(z_view_string_loan(&keystr)),
z_string_data(z_view_string_loan(&keystr)), (int)z_string_len(z_string_loan(&value)),
z_string_data(z_string_loan(&value)));
z_string_drop(z_string_move(&value));
}
Expand Down
3 changes: 2 additions & 1 deletion examples/freertos_plus_tcp/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ void reply_handler(const z_loaned_reply_t *reply, void *ctx) {
z_owned_string_t replystr;
z_bytes_deserialize_into_string(z_sample_payload(sample), &replystr);

printf(">> Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(replystr)));
printf(">> Received ('%.*s': '%.*s')\n", (int)z_string_len(z_loan(keystr)), z_string_data(z_loan(keystr)),
(int)z_string_len(z_loan(replystr)), z_string_data(z_loan(replystr)));
z_drop(z_move(replystr));
} else {
printf(">> Received an error\n");
Expand Down
4 changes: 2 additions & 2 deletions examples/freertos_plus_tcp/z_pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ void app_main(void) {
z_keyexpr_as_view_string(z_sample_keyexpr(z_loan(sample)), &keystr);
z_owned_string_t value;
z_bytes_deserialize_into_string(z_sample_payload(z_loan(sample)), &value);
printf(">> [Subscriber] Pulled ('%s': '%s')\n", z_string_data(z_loan(keystr)),
z_string_data(z_loan(value)));
printf(">> [Subscriber] Pulled ('%.*s': '%.*s')\n", (int)z_string_len(z_loan(keystr)),
z_string_data(z_loan(keystr)), (int)z_string_len(z_loan(value)), z_string_data(z_loan(value)));
z_drop(z_move(value));
z_drop(z_move(sample));
}
Expand Down
3 changes: 2 additions & 1 deletion examples/freertos_plus_tcp/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ void query_handler(const z_loaned_query_t *query, void *ctx) {
z_owned_string_t payload_string;
z_bytes_deserialize_into_string(z_query_payload(query), &payload_string);
if (z_string_len(z_loan(payload_string)) > 0) {
printf(" with value '%s'\n", z_string_data(z_loan(payload_string)));
printf(" with value '%.*s'\n", (int)z_string_len(z_loan(payload_string)),
z_string_data(z_loan(payload_string)));
}
z_drop(z_move(payload_string));

Expand Down
3 changes: 2 additions & 1 deletion examples/freertos_plus_tcp/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ void data_handler(const z_loaned_sample_t *sample, void *ctx) {
z_keyexpr_as_view_string(z_sample_keyexpr(sample), &keystr);
z_owned_string_t value;
z_bytes_deserialize_into_string(z_sample_payload(sample), &value);
printf(">> [Subscriber] Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(value)));
printf(">> [Subscriber] Received ('%.*s': '%.*s')\n", (int)z_string_len(z_loan(keystr)),
z_string_data(z_loan(keystr)), (int)z_string_len(z_loan(value)), z_string_data(z_loan(value)));
z_drop(z_move(value));
}

Expand Down
3 changes: 2 additions & 1 deletion examples/freertos_plus_tcp/z_sub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ void data_handler(const z_loaned_sample_t *sample, void *ctx) {
z_keyexpr_as_view_string(z_sample_keyexpr(sample), &keystr);
z_owned_string_t value;
z_bytes_deserialize_into_string(z_sample_payload(sample), &value);
printf(">> [Subscriber] Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(value)));
printf(">> [Subscriber] Received ('%.*s': '%.*s')\n", (int)z_string_len(z_loan(keystr)),
z_string_data(z_loan(keystr)), (int)z_string_len(z_loan(value)), z_string_data(z_loan(value)));
z_drop(z_move(value));
msg_nb++;
}
Expand Down
3 changes: 2 additions & 1 deletion examples/mbed/z_get.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ void reply_handler(const z_loaned_reply_t *oreply, void *ctx) {
z_owned_string_t replystr;
z_bytes_deserialize_into_string(z_sample_payload(sample), &replystr);

printf(" >> Received ('%s': '%s')\n", z_string_data(z_view_string_loan(&keystr)),
printf(" >> Received ('%.*s': '%.*s')\n", (int)z_string_len(z_view_string_loan(&keystr)),
z_string_data(z_view_string_loan(&keystr)), (int)z_string_len(z_string_loan(&replystr)),
z_string_data(z_string_loan(&replystr)));
z_string_drop(z_string_move(&replystr));
} else {
Expand Down
3 changes: 2 additions & 1 deletion examples/mbed/z_pull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ int main(int argc, char **argv) {
z_keyexpr_as_view_string(z_sample_keyexpr(z_sample_loan(&sample)), &keystr);
z_owned_string_t value;
z_bytes_deserialize_into_string(z_sample_payload(z_sample_loan(&sample)), &value);
printf(">> [Subscriber] Pulled ('%s': '%s')\n", z_string_data(z_view_string_loan(&keystr)),
printf(">> [Subscriber] Pulled ('%.*s': '%.*s')\n", (int)z_string_len(z_view_string_loan(&keystr)),
z_string_data(z_view_string_loan(&keystr)), (int)z_string_len(z_string_loan(&value)),
z_string_data(z_string_loan(&value)));
z_string_drop(z_string_move(&value));
z_sample_drop(z_sample_move(&sample));
Expand Down
3 changes: 2 additions & 1 deletion examples/mbed/z_queryable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ void query_handler(const z_loaned_query_t *query, void *ctx) {
z_owned_string_t payload_string;
z_bytes_deserialize_into_string(z_query_payload(query), &payload_string);
if (z_string_len(z_string_loan(&payload_string)) > 1) {
printf(" with value '%s'\n", z_string_data(z_string_loan(&payload_string)));
printf(" with value '%.*s'\n", (int)z_string_len(z_string_loan(&payload_string)),
z_string_data(z_string_loan(&payload_string)));
}
z_string_drop(z_string_move(&payload_string));

Expand Down
3 changes: 2 additions & 1 deletion examples/mbed/z_sub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ void data_handler(const z_loaned_sample_t *sample, void *arg) {
z_keyexpr_as_view_string(z_sample_keyexpr(sample), &keystr);
z_owned_string_t value;
z_bytes_deserialize_into_string(z_sample_payload(sample), &value);
printf(" >> [Subscriber handler] Received ('%s': '%s')\n", z_string_data(z_view_string_loan(&keystr)),
printf(" >> [Subscriber handler] Received ('%.*s': '%.*s')\n", (int)z_string_len(z_view_string_loan(&keystr)),
z_string_data(z_view_string_loan(&keystr)), (int)z_string_len(z_string_loan(&value)),
z_string_data(z_string_loan(&value)));
z_string_drop(z_string_move(&value));
}
Expand Down
5 changes: 3 additions & 2 deletions examples/unix/c11/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ void reply_handler(const z_loaned_reply_t *reply, void *ctx) {
z_owned_string_t replystr;
z_bytes_deserialize_into_string(z_sample_payload(sample), &replystr);

printf(">> Received %s ('%s': '%s')\n", kind_to_str(z_sample_kind(sample)), z_string_data(z_loan(keystr)),
printf(">> Received %s ('%.*s': '%.*s')\n", kind_to_str(z_sample_kind(sample)),
(int)z_string_len(z_loan(keystr)), z_string_data(z_loan(keystr)), (int)z_string_len(z_loan(replystr)),
z_string_data(z_loan(replystr)));
z_drop(z_move(replystr));
} else {
const z_loaned_reply_err_t *err = z_reply_err(reply);
z_owned_string_t errstr;
z_bytes_deserialize_into_string(z_reply_err_payload(err), &errstr);
printf(">> Received an error: %s\n", z_string_data(z_loan(errstr)));
printf(">> Received an error: %.*s\n", (int)z_string_len(z_loan(errstr)), z_string_data(z_loan(errstr)));
z_drop(z_move(errstr));
}
}
Expand Down
8 changes: 5 additions & 3 deletions examples/unix/c11/z_get_attachment.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ void parse_attachment(kv_pairs_rx_t *kvp, const z_loaned_bytes_t *attachment) {
void print_attachment(kv_pairs_rx_t *kvp) {
printf(" with attachment:\n");
for (uint32_t i = 0; i < kvp->current_idx; i++) {
printf(" %d: %s, %s\n", i, z_string_data(z_loan(kvp->data[i].key)),
printf(" %d: %.*s, %.*s\n", i, (int)z_string_len(z_loan(kvp->data[i].key)),
z_string_data(z_loan(kvp->data[i].key)), (int)z_string_len(z_loan(kvp->data[i].value)),
z_string_data(z_loan(kvp->data[i].value)));
}
}
Expand Down Expand Up @@ -109,8 +110,9 @@ void reply_handler(const z_loaned_reply_t *reply, void *ctx) {
z_owned_string_t encoding;
z_encoding_to_string(z_sample_encoding(sample), &encoding);

printf(">> Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(replystr)));
printf(" with encoding: %s\n", z_string_data(z_loan(encoding)));
printf(">> Received ('%.*s': '%.*s')\n", (int)z_string_len(z_loan(keystr)), z_string_data(z_loan(keystr)),
(int)z_string_len(z_loan(replystr)), z_string_data(z_loan(replystr)));
printf(" with encoding: %.*s\n", (int)z_string_len(z_loan(encoding)), z_string_data(z_loan(encoding)));

// Check attachment
kv_pairs_rx_t kvp = {
Expand Down
3 changes: 2 additions & 1 deletion examples/unix/c11/z_get_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ int main(int argc, char **argv) {
z_owned_string_t replystr;
z_bytes_deserialize_into_string(z_sample_payload(sample), &replystr);

printf(">> Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(replystr)));
printf(">> Received ('%.*s': '%.*s')\n", (int)z_string_len(z_loan(keystr)), z_string_data(z_loan(keystr)),
(int)z_string_len(z_loan(replystr)), z_string_data(z_loan(replystr)));
z_drop(z_move(replystr));
} else {
printf(">> Received an error\n");
Expand Down
4 changes: 2 additions & 2 deletions examples/unix/c11/z_pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ int main(int argc, char **argv) {
z_keyexpr_as_view_string(z_sample_keyexpr(z_loan(sample)), &keystr);
z_owned_string_t value;
z_bytes_deserialize_into_string(z_sample_payload(z_loan(sample)), &value);
printf(">> [Subscriber] Pulled ('%s': '%s')\n", z_string_data(z_loan(keystr)),
z_string_data(z_loan(value)));
printf(">> [Subscriber] Pulled ('%.*s': '%.*s')\n", (int)z_string_len(z_loan(keystr)),
z_string_data(z_loan(keystr)), (int)z_string_len(z_loan(value)), z_string_data(z_loan(value)));
z_drop(z_move(value));
z_drop(z_move(sample));
}
Expand Down
7 changes: 4 additions & 3 deletions examples/unix/c11/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ void query_handler(const z_loaned_query_t *query, void *ctx) {
z_keyexpr_as_view_string(z_query_keyexpr(query), &keystr);
z_view_string_t params;
z_query_parameters(query, &params);
printf(" >> [Queryable handler] Received Query '%s%.*s'\n", z_string_data(z_loan(keystr)),
(int)z_string_len(z_loan(params)), z_string_data(z_loan(params)));
printf(" >> [Queryable handler] Received Query '%.*s%.*s'\n", (int)z_string_len(z_loan(keystr)),
z_string_data(z_loan(keystr)), (int)z_string_len(z_loan(params)), z_string_data(z_loan(params)));
// Process value
z_owned_string_t payload_string;
z_bytes_deserialize_into_string(z_query_payload(query), &payload_string);
if (z_string_len(z_loan(payload_string)) > 0) {
printf(" with value '%s'\n", z_string_data(z_loan(payload_string)));
printf(" with value '%.*s'\n", (int)z_string_len(z_loan(payload_string)),
z_string_data(z_loan(payload_string)));
}
z_drop(z_move(payload_string));

Expand Down
12 changes: 7 additions & 5 deletions examples/unix/c11/z_queryable_attachment.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ void parse_attachment(kv_pairs_rx_t *kvp, const z_loaned_bytes_t *attachment) {
void print_attachment(kv_pairs_rx_t *kvp) {
printf(" with attachment:\n");
for (uint32_t i = 0; i < kvp->current_idx; i++) {
printf(" %d: %s, %s\n", i, z_string_data(z_loan(kvp->data[i].key)),
printf(" %d: %.*s, %.*s\n", i, (int)z_string_len(z_loan(kvp->data[i].key)),
z_string_data(z_loan(kvp->data[i].key)), (int)z_string_len(z_loan(kvp->data[i].value)),
z_string_data(z_loan(kvp->data[i].value)));
}
}
Expand All @@ -109,18 +110,19 @@ void query_handler(const z_loaned_query_t *query, void *ctx) {
z_keyexpr_as_view_string(z_query_keyexpr(query), &keystr);
z_view_string_t params;
z_query_parameters(query, &params);
printf(" >> [Queryable handler] Received Query '%s%.*s'\n", z_string_data(z_loan(keystr)),
(int)z_string_len(z_loan(params)), z_string_data(z_loan(params)));
printf(" >> [Queryable handler] Received Query '%.*s%.*s'\n", (int)z_string_len(z_loan(keystr)),
z_string_data(z_loan(keystr)), (int)z_string_len(z_loan(params)), z_string_data(z_loan(params)));
// Process encoding
z_owned_string_t encoding;
z_encoding_to_string(z_query_encoding(query), &encoding);
printf(" with encoding: %s\n", z_string_data(z_loan(encoding)));
printf(" with encoding: %.*s\n", (int)z_string_len(z_loan(encoding)), z_string_data(z_loan(encoding)));

// Process value
z_owned_string_t payload_string;
z_bytes_deserialize_into_string(z_query_payload(query), &payload_string);
if (z_string_len(z_loan(payload_string)) > 0) {
printf(" with value '%s'\n", z_string_data(z_loan(payload_string)));
printf(" with value '%.*s'\n", (int)z_string_len(z_loan(payload_string)),
z_string_data(z_loan(payload_string)));
}
// Check attachment
kv_pairs_rx_t kvp = {
Expand Down
7 changes: 4 additions & 3 deletions examples/unix/c11/z_queryable_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,14 @@ int main(int argc, char **argv) {
z_keyexpr_as_view_string(z_query_keyexpr(q), &keystr);
z_view_string_t params;
z_query_parameters(q, &params);
printf(" >> [Queryable handler] Received Query '%s%.*s'\n", z_string_data(z_loan(keystr)),
(int)z_string_len(z_loan(params)), z_string_data(z_loan(params)));
printf(" >> [Queryable handler] Received Query '%.*s%.*s'\n", (int)z_string_len(z_loan(keystr)),
z_string_data(z_loan(keystr)), (int)z_string_len(z_loan(params)), z_string_data(z_loan(params)));
// Process value
z_owned_string_t payload_string;
z_bytes_deserialize_into_string(z_query_payload(z_loan(query)), &payload_string);
if (z_string_len(z_loan(payload_string)) > 0) {
printf(" with value '%s'\n", z_string_data(z_loan(payload_string)));
printf(" with value '%.*s'\n", (int)z_string_len(z_loan(payload_string)),
z_string_data(z_loan(payload_string)));
}
z_drop(z_move(payload_string));

Expand Down
3 changes: 2 additions & 1 deletion examples/unix/c11/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ void data_handler(const z_loaned_sample_t *sample, void *ctx) {
z_keyexpr_as_view_string(z_sample_keyexpr(sample), &keystr);
z_owned_string_t value;
z_bytes_deserialize_into_string(z_sample_payload(sample), &value);
printf(">> [Subscriber] Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(value)));
printf(">> [Subscriber] Received ('%.*s': '%.*s')\n", (int)z_string_len(z_loan(keystr)),
z_string_data(z_loan(keystr)), (int)z_string_len(z_loan(value)), z_string_data(z_loan(value)));
z_drop(z_move(value));
msg_nb++;
}
Expand Down
8 changes: 5 additions & 3 deletions examples/unix/c11/z_sub_attachment.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ void parse_attachment(kv_pairs_t *kvp, const z_loaned_bytes_t *attachment) {
void print_attachment(kv_pairs_t *kvp) {
printf(" with attachment:\n");
for (uint32_t i = 0; i < kvp->current_idx; i++) {
printf(" %d: %s, %s\n", i, z_string_data(z_loan(kvp->data[i].key)),
printf(" %d: %.*s, %.*s\n", i, (int)z_string_len(z_loan(kvp->data[i].key)),
z_string_data(z_loan(kvp->data[i].key)), (int)z_string_len(z_loan(kvp->data[i].value)),
z_string_data(z_loan(kvp->data[i].value)));
}
}
Expand All @@ -78,8 +79,9 @@ void data_handler(const z_loaned_sample_t *sample, void *ctx) {
z_owned_string_t encoding;
z_encoding_to_string(z_sample_encoding(sample), &encoding);

printf(">> [Subscriber] Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(value)));
printf(" with encoding: %s\n", z_string_data(z_loan(encoding)));
printf(">> [Subscriber] Received ('%.*s': '%.*s')\n", (int)z_string_len(z_loan(keystr)),
z_string_data(z_loan(keystr)), (int)z_string_len(z_loan(value)), z_string_data(z_loan(value)));
printf(" with encoding: %.*s\n", (int)z_string_len(z_loan(encoding)), z_string_data(z_loan(encoding)));

// Check timestamp
const z_timestamp_t *ts = z_sample_timestamp(sample);
Expand Down
Loading

0 comments on commit 0944a5d

Please sign in to comment.