Skip to content

Commit

Permalink
Merge branch 'eclipse-zenoh:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaz98 authored Sep 18, 2023
2 parents 6b9e586 + ab578c2 commit 34249c4
Show file tree
Hide file tree
Showing 22 changed files with 230 additions and 108 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ cmake_minimum_required(VERSION 3.13)
project(zenohpico VERSION 0.10.0.0 LANGUAGES C)

include(CMakePackageConfigHelpers)
include(GNUInstallDirs)

option(BUILD_SHARED_LIBS "Build shared libraries if ON, otherwise build static libraries" ON)
option(ZENOH_DEBUG "Use this to set the ZENOH_DEBUG variable." 0)
Expand Down
19 changes: 13 additions & 6 deletions examples/unix/c11/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,30 @@ void reply_handler(z_owned_reply_t *reply, void *ctx) {
int main(int argc, char **argv) {
const char *keyexpr = "demo/example/**";
const char *mode = "client";
const char *locator = NULL;
const char *clocator = NULL;
const char *llocator = NULL;
const char *value = NULL;

int opt;
while ((opt = getopt(argc, argv, "k:e:m:v:")) != -1) {
while ((opt = getopt(argc, argv, "k:e:m:v:l:")) != -1) {
switch (opt) {
case 'k':
keyexpr = optarg;
break;
case 'e':
locator = optarg;
clocator = optarg;
break;
case 'm':
mode = optarg;
break;
case 'l':
llocator = optarg;
break;
case 'v':
value = optarg;
break;
case '?':
if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'v') {
if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'v' || optopt == 'l') {
fprintf(stderr, "Option -%c requires an argument.\n", optopt);
} else {
fprintf(stderr, "Unknown option `-%c'.\n", optopt);
Expand All @@ -70,8 +74,11 @@ int main(int argc, char **argv) {

z_owned_config_t config = z_config_default();
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode));
if (locator != NULL) {
zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(locator));
if (clocator != NULL) {
zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator));
}
if (llocator != NULL) {
zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator));
}

printf("Opening session...\n");
Expand Down
19 changes: 13 additions & 6 deletions examples/unix/c11/z_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,23 @@ void print_zid(const z_id_t *id, void *ctx) {

int main(int argc, char **argv) {
const char *mode = "client";
char *locator = NULL;
char *clocator = NULL;
char *llocator = NULL;

int opt;
while ((opt = getopt(argc, argv, "e:m:")) != -1) {
while ((opt = getopt(argc, argv, "e:m:l:")) != -1) {
switch (opt) {
case 'e':
locator = optarg;
clocator = optarg;
break;
case 'm':
mode = optarg;
break;
case 'l':
llocator = optarg;
break;
case '?':
if (optopt == 'e' || optopt == 'm') {
if (optopt == 'e' || optopt == 'm' || optopt == 'l') {
fprintf(stderr, "Option -%c requires an argument.\n", optopt);
} else {
fprintf(stderr, "Unknown option `-%c'.\n", optopt);
Expand All @@ -54,8 +58,11 @@ int main(int argc, char **argv) {

z_owned_config_t config = z_config_default();
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode));
if (locator != NULL) {
zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(locator));
if (clocator != NULL) {
zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator));
}
if (llocator != NULL) {
zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator));
}

printf("Opening session...\n");
Expand Down
22 changes: 10 additions & 12 deletions examples/unix/c11/z_pub.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ int main(int argc, char **argv) {
char *const default_value = "Pub from Pico!";
char *value = default_value;
const char *mode = "client";
char *locator = NULL;
char *clocator = NULL;
char *llocator = NULL;
int n = 10;

int opt;
Expand All @@ -40,25 +41,19 @@ int main(int argc, char **argv) {
value = optarg;
break;
case 'e':
locator = optarg;
clocator = optarg;
break;
case 'm':
mode = optarg;
break;
case 'l':
opt = atoi(optarg);
value = z_malloc(opt + 1);
memset(value, 'A', opt);
value[opt] = 0;
for (int i = opt - 1; opt > 0; i--, opt /= 10) {
value[i] = '0' + (opt % 10);
}
llocator = optarg;
break;
case 'n':
n = atoi(optarg);
break;
case '?':
if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm') {
if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm' || optopt == 'l') {
fprintf(stderr, "Option -%c requires an argument.\n", optopt);
} else {
fprintf(stderr, "Unknown option `-%c'.\n", optopt);
Expand All @@ -71,8 +66,11 @@ int main(int argc, char **argv) {

z_owned_config_t config = z_config_default();
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode));
if (locator != NULL) {
zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(locator));
if (clocator != NULL) {
zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator));
}
if (llocator != NULL) {
zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator));
}

printf("Opening session...\n");
Expand Down
19 changes: 13 additions & 6 deletions examples/unix/c11/z_pub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ int main(int argc, char **argv) {
const char *keyexpr = "demo/example/zenoh-pico-pub";
const char *value = "Pub from Pico!";
const char *mode = "client";
char *locator = NULL;
char *clocator = NULL;
char *llocator = NULL;

int opt;
while ((opt = getopt(argc, argv, "k:v:e:m:")) != -1) {
while ((opt = getopt(argc, argv, "k:v:e:m:l:")) != -1) {
switch (opt) {
case 'k':
keyexpr = optarg;
Expand All @@ -35,13 +36,16 @@ int main(int argc, char **argv) {
value = optarg;
break;
case 'e':
locator = optarg;
clocator = optarg;
break;
case 'm':
mode = optarg;
break;
case 'l':
llocator = optarg;
break;
case '?':
if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm') {
if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm' || optopt == 'l') {
fprintf(stderr, "Option -%c requires an argument.\n", optopt);
} else {
fprintf(stderr, "Unknown option `-%c'.\n", optopt);
Expand All @@ -54,8 +58,11 @@ int main(int argc, char **argv) {

z_owned_config_t config = z_config_default();
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode));
if (locator != NULL) {
zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(locator));
if (clocator != NULL) {
zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator));
}
if (llocator != NULL) {
zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator));
}

printf("Opening session...\n");
Expand Down
19 changes: 13 additions & 6 deletions examples/unix/c11/z_put.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ int main(int argc, char **argv) {
const char *keyexpr = "demo/example/zenoh-pico-put";
const char *value = "Pub from Pico!";
const char *mode = "client";
char *locator = NULL;
char *clocator = NULL;
char *llocator = NULL;

int opt;
while ((opt = getopt(argc, argv, "k:v:e:m:")) != -1) {
while ((opt = getopt(argc, argv, "k:v:e:m:l:")) != -1) {
switch (opt) {
case 'k':
keyexpr = optarg;
Expand All @@ -35,13 +36,16 @@ int main(int argc, char **argv) {
value = optarg;
break;
case 'e':
locator = optarg;
clocator = optarg;
break;
case 'm':
mode = optarg;
break;
case 'l':
llocator = optarg;
break;
case '?':
if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm') {
if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm' || optopt == 'l') {
fprintf(stderr, "Option -%c requires an argument.\n", optopt);
} else {
fprintf(stderr, "Unknown option `-%c'.\n", optopt);
Expand All @@ -54,8 +58,11 @@ int main(int argc, char **argv) {

z_owned_config_t config = z_config_default();
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode));
if (locator != NULL) {
zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(locator));
if (clocator != NULL) {
zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator));
}
if (llocator != NULL) {
zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator));
}

printf("Opening session...\n");
Expand Down
19 changes: 13 additions & 6 deletions examples/unix/c11/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,29 @@ void query_handler(const z_query_t *query, void *ctx) {

int main(int argc, char **argv) {
const char *mode = "client";
char *locator = NULL;
char *clocator = NULL;
char *llocator = NULL;

int opt;
while ((opt = getopt(argc, argv, "k:e:m:v:")) != -1) {
while ((opt = getopt(argc, argv, "k:e:m:v:l:")) != -1) {
switch (opt) {
case 'k':
keyexpr = optarg;
break;
case 'e':
locator = optarg;
clocator = optarg;
break;
case 'm':
mode = optarg;
break;
case 'l':
llocator = optarg;
break;
case 'v':
value = optarg;
break;
case '?':
if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'v') {
if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'v' || optopt == 'l') {
fprintf(stderr, "Option -%c requires an argument.\n", optopt);
} else {
fprintf(stderr, "Unknown option `-%c'.\n", optopt);
Expand All @@ -69,8 +73,11 @@ int main(int argc, char **argv) {

z_owned_config_t config = z_config_default();
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode));
if (locator != NULL) {
zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(locator));
if (clocator != NULL) {
zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator));
}
if (llocator != NULL) {
zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator));
}

printf("Opening session...\n");
Expand Down
19 changes: 13 additions & 6 deletions examples/unix/c11/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,26 @@ void data_handler(const z_sample_t *sample, void *ctx) {
int main(int argc, char **argv) {
const char *keyexpr = "demo/example/**";
const char *mode = "client";
char *locator = NULL;
char *clocator = NULL;
char *llocator = NULL;

int opt;
while ((opt = getopt(argc, argv, "k:e:m:")) != -1) {
while ((opt = getopt(argc, argv, "k:e:m:l:")) != -1) {
switch (opt) {
case 'k':
keyexpr = optarg;
break;
case 'e':
locator = optarg;
clocator = optarg;
break;
case 'm':
mode = optarg;
break;
case 'l':
llocator = optarg;
break;
case '?':
if (optopt == 'k' || optopt == 'e' || optopt == 'm') {
if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'l') {
fprintf(stderr, "Option -%c requires an argument.\n", optopt);
} else {
fprintf(stderr, "Unknown option `-%c'.\n", optopt);
Expand All @@ -58,8 +62,11 @@ int main(int argc, char **argv) {

z_owned_config_t config = z_config_default();
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode));
if (locator != NULL) {
zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(locator));
if (clocator != NULL) {
zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator));
}
if (llocator != NULL) {
zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator));
}

printf("Opening session...\n");
Expand Down
19 changes: 13 additions & 6 deletions examples/unix/c11/z_sub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,26 @@ void data_handler(const z_sample_t *sample, void *ctx) {
int main(int argc, char **argv) {
const char *keyexpr = "demo/example/**";
const char *mode = "client";
char *locator = NULL;
char *clocator = NULL;
char *llocator = NULL;

int opt;
while ((opt = getopt(argc, argv, "k:e:m:")) != -1) {
while ((opt = getopt(argc, argv, "k:e:m:l:")) != -1) {
switch (opt) {
case 'k':
keyexpr = optarg;
break;
case 'e':
locator = optarg;
clocator = optarg;
break;
case 'm':
mode = optarg;
break;
case 'l':
llocator = optarg;
break;
case '?':
if (optopt == 'k' || optopt == 'e' || optopt == 'm') {
if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'l') {
fprintf(stderr, "Option -%c requires an argument.\n", optopt);
} else {
fprintf(stderr, "Unknown option `-%c'.\n", optopt);
Expand All @@ -58,8 +62,11 @@ int main(int argc, char **argv) {

z_owned_config_t config = z_config_default();
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode));
if (locator != NULL) {
zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(locator));
if (clocator != NULL) {
zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator));
}
if (llocator != NULL) {
zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator));
}

printf("Opening session...\n");
Expand Down
Loading

0 comments on commit 34249c4

Please sign in to comment.