Skip to content

Commit

Permalink
use proper listen config for -l
Browse files Browse the repository at this point in the history
  • Loading branch information
p-avital committed Sep 15, 2023
1 parent 210b00f commit da7eab7
Show file tree
Hide file tree
Showing 18 changed files with 161 additions and 99 deletions.
15 changes: 9 additions & 6 deletions examples/unix/c11/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ 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;
Expand All @@ -48,14 +49,13 @@ int main(int argc, char **argv) {
keyexpr = optarg;
break;
case 'e':
locator = optarg;
clocator = optarg;
break;
case 'm':
mode = optarg;
break;
case 'l':
locator = optarg;
mode = "peer";
llocator = optarg;
break;
case 'v':
value = optarg;
Expand All @@ -74,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
15 changes: 9 additions & 6 deletions examples/unix/c11/z_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ 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:l:")) != -1) {
switch (opt) {
case 'e':
locator = optarg;
clocator = optarg;
break;
case 'm':
mode = optarg;
break;
case 'l':
locator = optarg;
mode = "peer";
llocator = optarg;
break;
case '?':
if (optopt == 'e' || optopt == 'm' || optopt == 'l') {
Expand All @@ -58,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
15 changes: 9 additions & 6 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,14 +41,13 @@ int main(int argc, char **argv) {
value = optarg;
break;
case 'e':
locator = optarg;
clocator = optarg;
break;
case 'm':
mode = optarg;
break;
case 'l':
locator = optarg;
mode = "peer";
llocator = optarg;
break;
case 'n':
n = atoi(optarg);
Expand All @@ -66,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
15 changes: 9 additions & 6 deletions examples/unix/c11/z_pub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ 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:l:")) != -1) {
Expand All @@ -35,14 +36,13 @@ int main(int argc, char **argv) {
value = optarg;
break;
case 'e':
locator = optarg;
clocator = optarg;
break;
case 'm':
mode = optarg;
break;
case 'l':
locator = optarg;
mode = "peer";
llocator = optarg;
break;
case '?':
if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm' || optopt == 'l') {
Expand All @@ -58,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
15 changes: 9 additions & 6 deletions examples/unix/c11/z_put.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ 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:l:")) != -1) {
Expand All @@ -35,14 +36,13 @@ int main(int argc, char **argv) {
value = optarg;
break;
case 'e':
locator = optarg;
clocator = optarg;
break;
case 'm':
mode = optarg;
break;
case 'l':
locator = optarg;
mode = "peer";
llocator = optarg;
break;
case '?':
if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm' || optopt == 'l') {
Expand All @@ -58,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
15 changes: 9 additions & 6 deletions examples/unix/c11/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ 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:l:")) != -1) {
Expand All @@ -47,14 +48,13 @@ int main(int argc, char **argv) {
keyexpr = optarg;
break;
case 'e':
locator = optarg;
clocator = optarg;
break;
case 'm':
mode = optarg;
break;
case 'l':
locator = optarg;
mode = "peer";
llocator = optarg;
break;
case 'v':
value = optarg;
Expand All @@ -73,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
15 changes: 9 additions & 6 deletions 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_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:l:")) != -1) {
Expand All @@ -39,14 +40,13 @@ int main(int argc, char **argv) {
keyexpr = optarg;
break;
case 'e':
locator = optarg;
clocator = optarg;
break;
case 'm':
mode = optarg;
break;
case 'l':
locator = optarg;
mode = "peer";
llocator = optarg;
break;
case '?':
if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'l') {
Expand All @@ -62,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
15 changes: 9 additions & 6 deletions examples/unix/c11/z_sub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ 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:l:")) != -1) {
Expand All @@ -39,14 +40,13 @@ int main(int argc, char **argv) {
keyexpr = optarg;
break;
case 'e':
locator = optarg;
clocator = optarg;
break;
case 'm':
mode = optarg;
break;
case 'l':
locator = optarg;
mode = "peer";
llocator = optarg;
break;
case '?':
if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'l') {
Expand All @@ -62,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
15 changes: 9 additions & 6 deletions examples/unix/c99/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ 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;
Expand All @@ -48,14 +49,13 @@ int main(int argc, char **argv) {
keyexpr = optarg;
break;
case 'e':
locator = optarg;
clocator = optarg;
break;
case 'm':
mode = optarg;
break;
case 'l':
locator = optarg;
mode = "peer";
llocator = optarg;
break;
case 'v':
value = optarg;
Expand All @@ -74,8 +74,11 @@ int main(int argc, char **argv) {

z_owned_config_t config = z_config_default();
zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(mode));
if (locator != NULL) {
zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(locator));
if (clocator != NULL) {
zp_config_insert(z_config_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 da7eab7

Please sign in to comment.