Add "deaf/mute" to pubsub
Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
parent
0845337f47
commit
9e673769ce
1 changed files with 55 additions and 1 deletions
|
@ -411,7 +411,7 @@ static int read_value(char *command, int *key, struct tstamp_t *tstamp, char **a
|
|||
return 1;
|
||||
}
|
||||
break;
|
||||
case 'p': case 'S': case ':': case 'Q': {
|
||||
case 'p': case 'S': case 'C': case ':': case 'Q': {
|
||||
int i = 0;
|
||||
*command = (char) c;
|
||||
while ((c = getc(stdin)) != EOF && !isspace((unsigned char) c)) {
|
||||
|
@ -1164,6 +1164,53 @@ static void pub_do_auto(const struct writerspec *spec) {
|
|||
dds_free(handle);
|
||||
}
|
||||
|
||||
static void do_deafmute(const char *args)
|
||||
{
|
||||
const char *a = args;
|
||||
bool deaf = false;
|
||||
bool mute = false;
|
||||
dds_duration_t duration = 0;
|
||||
double durfloat;
|
||||
int pos;
|
||||
if (strncmp(a, "self", 4) == 0) {
|
||||
a += 4;
|
||||
} else {
|
||||
printf ("deafmute: invalid args: %s\n", args);
|
||||
return;
|
||||
}
|
||||
if (*a++ != ';') {
|
||||
printf ("deafmute: invalid args: %s\n", args);
|
||||
return;
|
||||
}
|
||||
while (*a && *a != ';') {
|
||||
switch (*a++) {
|
||||
case 'm': mute = true; break;
|
||||
case 'd': deaf = true; break;
|
||||
default: printf ("deafmute: invalid flags: %s\n", args); return;
|
||||
}
|
||||
}
|
||||
if (*a++ != ';') {
|
||||
printf ("deafmute: invalid args: %s\n", args);
|
||||
return;
|
||||
}
|
||||
if (strcmp(a, "inf") == 0) {
|
||||
duration = DDS_INFINITY;
|
||||
} else if (sscanf(a, "%lf%n", &durfloat, &pos) == 1 && a[pos] == 0) {
|
||||
if (durfloat <= 0.0) {
|
||||
printf ("deafmute: invalid duration (<= 0): %s\n", args);
|
||||
return;
|
||||
}
|
||||
if (durfloat > (double) (DDS_INFINITY / DDS_NSECS_IN_SEC))
|
||||
duration = DDS_INFINITY;
|
||||
else
|
||||
duration = (dds_duration_t) (durfloat * 1e9);
|
||||
} else {
|
||||
printf ("deafmute: invalid args: %s\n", args);
|
||||
return;
|
||||
}
|
||||
dds_domain_set_deafmute (dp, deaf, mute, duration);
|
||||
}
|
||||
|
||||
static char *pub_do_nonarb(const struct writerspec *spec, uint32_t *seq) {
|
||||
struct tstamp_t tstamp_spec = { .isabs = 0, .t = 0 };
|
||||
int result;
|
||||
|
@ -1278,6 +1325,9 @@ static char *pub_do_nonarb(const struct writerspec *spec, uint32_t *seq) {
|
|||
case 'Y': case 'B': case 'E': case 'W':
|
||||
non_data_operation(command, spec->wr);
|
||||
break;
|
||||
case 'C':
|
||||
do_deafmute(arg);
|
||||
break;
|
||||
case ':':
|
||||
break;
|
||||
default:
|
||||
|
@ -1362,6 +1412,10 @@ static char *pub_do_nonarb(const struct writerspec *spec, uint32_t *seq) {
|
|||
// case 'Y': case 'B': case 'E': case 'W':
|
||||
// non_data_operation(*line, spec->wr);
|
||||
// break;
|
||||
// case 'C':
|
||||
// do_deafmute(arg);
|
||||
// line = NULL;
|
||||
// break;
|
||||
// case 'S':
|
||||
// make_persistent_snapshot(line+1);
|
||||
// line = NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue