Skip to content

Commit

Permalink
Remove -x from mosquitto_sub - this is provided by -F now.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralight committed Aug 10, 2016
1 parent 8140ce1 commit 840453c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 32 deletions.
1 change: 0 additions & 1 deletion ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ Client library:

Client:
- Add -F to mosquitto_sub to allow the user to choose the output format.
- Add -x to mosquitto_sub for printing the payload in hexadecimal format.
- Add -U to mosquitto_sub for unsubscribing from topics.
- Add --retained-only to mosquitto_sub to exit after receiving all retained
messages.
Expand Down
5 changes: 0 additions & 5 deletions client/client_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -853,11 +853,6 @@ int client_config_line_proc(struct mosq_config *cfg, int pub_or_sub, int argc, c
goto unknown_option;
}
cfg->verbose = 1;
}else if(!strcmp(argv[i], "-x")){
if(pub_or_sub == CLIENT_PUB){
goto unknown_option;
}
cfg->hex_output = true;
}else{
goto unknown_option;
}
Expand Down
1 change: 0 additions & 1 deletion client/client_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ struct mosq_config {
int unsub_topic_count; /* sub */
bool verbose; /* sub */
bool eol; /* sub */
bool hex_output; /* sub */
int msg_count; /* sub */
char *format; /* sub */
#ifdef WITH_SOCKS
Expand Down
33 changes: 16 additions & 17 deletions client/sub_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,6 @@ and the Eclipse Distribution License is available at
bool process_messages = true;
int msg_count = 0;

static void write_payload(const unsigned char *payload, int payloadlen, bool hex)
{
int i;

if(!hex){
(void)fwrite(payload, 1, payloadlen, stdout);
}else{
for(i=0; i<payloadlen; i++){
fprintf(stdout, "%x", payload[i]);
}
}
}

static int get_time(struct tm **ti, long *ns)
{
#ifdef WIN32
Expand Down Expand Up @@ -79,6 +66,19 @@ static int get_time(struct tm **ti, long *ns)
return 0;
}

static void write_payload(const unsigned char *payload, int payloadlen, bool hex)
{
int i;

if(!hex){
(void)fwrite(payload, 1, payloadlen, stdout);
}else{
for(i=0; i<payloadlen; i++){
fprintf(stdout, "%x", payload[i]);
}
}
}

void write_json_payload(const char *payload, int payloadlen)
{
int i;
Expand Down Expand Up @@ -290,7 +290,7 @@ void print_message(struct mosq_config *cfg, const struct mosquitto_message *mess
}else if(cfg->verbose){
if(message->payloadlen){
printf("%s ", message->topic);
write_payload(message->payload, message->payloadlen, cfg->hex_output);
write_payload(message->payload, message->payloadlen, false);
if(cfg->eol){
printf("\n");
}
Expand All @@ -302,7 +302,7 @@ void print_message(struct mosq_config *cfg, const struct mosquitto_message *mess
fflush(stdout);
}else{
if(message->payloadlen){
write_payload(message->payload, message->payloadlen, cfg->hex_output);
write_payload(message->payload, message->payloadlen, false);
if(cfg->eol){
printf("\n");
}
Expand Down Expand Up @@ -407,7 +407,7 @@ void print_usage(void)
printf(" [-A bind_address]\n");
#endif
printf(" [-i id] [-I id_prefix]\n");
printf(" [-d] [-N] [--quiet] [-v] [-x]\n");
printf(" [-d] [-N] [--quiet] [-v]\n");
printf(" [--will-topic [--will-payload payload] [--will-qos qos] [--will-retain]]\n");
#ifdef WITH_TLS
printf(" [{--cafile file | --capath dir} [--cert file] [--key file]\n");
Expand Down Expand Up @@ -448,7 +448,6 @@ void print_usage(void)
printf(" -v : print published messages verbosely.\n");
printf(" -V : specify the version of the MQTT protocol to use when connecting.\n");
printf(" Can be mqttv31 or mqttv311. Defaults to mqttv31.\n");
printf(" -x : print published message payloads as hexadecimal data.\n");
printf(" --help : display this message.\n");
printf(" --quiet : don't print error messages.\n");
printf(" --retained-only : only handle messages with the retained flag set, and exit when the\n");
Expand Down
8 changes: 0 additions & 8 deletions man/mosquitto_sub.1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
<arg choice='opt' rep='repeat'><option>-U</option> <replaceable>unsub-topic</replaceable></arg>
<arg><option>-v</option></arg>
<arg><option>-V</option> <replaceable>protocol-version</replaceable></arg>
<arg><option>-x</option></arg>
<arg><option>--proxy</option> <replaceable>socks-url</replaceable></arg>
<arg><option>--quiet</option></arg>
<arg>
Expand Down Expand Up @@ -546,13 +545,6 @@
the client disconnects unexpectedly.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-x</option></term>
<listitem>
<para>Print published message payloads as hexadecimal
data.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>

Expand Down

0 comments on commit 840453c

Please sign in to comment.