Remove -x from mosquitto_sub - this is provided by -F now.

This commit is contained in:
Roger A. Light 2016-08-10 12:20:04 +01:00
parent 8140ce1f24
commit 840453c14f
5 changed files with 16 additions and 32 deletions

View File

@ -48,7 +48,6 @@ Client library:
Client: Client:
- Add -F to mosquitto_sub to allow the user to choose the output format. - 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 -U to mosquitto_sub for unsubscribing from topics.
- Add --retained-only to mosquitto_sub to exit after receiving all retained - Add --retained-only to mosquitto_sub to exit after receiving all retained
messages. messages.

View File

@ -853,11 +853,6 @@ int client_config_line_proc(struct mosq_config *cfg, int pub_or_sub, int argc, c
goto unknown_option; goto unknown_option;
} }
cfg->verbose = 1; cfg->verbose = 1;
}else if(!strcmp(argv[i], "-x")){
if(pub_or_sub == CLIENT_PUB){
goto unknown_option;
}
cfg->hex_output = true;
}else{ }else{
goto unknown_option; goto unknown_option;
} }

View File

@ -82,7 +82,6 @@ struct mosq_config {
int unsub_topic_count; /* sub */ int unsub_topic_count; /* sub */
bool verbose; /* sub */ bool verbose; /* sub */
bool eol; /* sub */ bool eol; /* sub */
bool hex_output; /* sub */
int msg_count; /* sub */ int msg_count; /* sub */
char *format; /* sub */ char *format; /* sub */
#ifdef WITH_SOCKS #ifdef WITH_SOCKS

View File

@ -34,19 +34,6 @@ Contributors:
bool process_messages = true; bool process_messages = true;
int msg_count = 0; 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) static int get_time(struct tm **ti, long *ns)
{ {
#ifdef WIN32 #ifdef WIN32
@ -79,6 +66,19 @@ static int get_time(struct tm **ti, long *ns)
return 0; 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) void write_json_payload(const char *payload, int payloadlen)
{ {
int i; int i;
@ -290,7 +290,7 @@ void print_message(struct mosq_config *cfg, const struct mosquitto_message *mess
}else if(cfg->verbose){ }else if(cfg->verbose){
if(message->payloadlen){ if(message->payloadlen){
printf("%s ", message->topic); printf("%s ", message->topic);
write_payload(message->payload, message->payloadlen, cfg->hex_output); write_payload(message->payload, message->payloadlen, false);
if(cfg->eol){ if(cfg->eol){
printf("\n"); printf("\n");
} }
@ -302,7 +302,7 @@ void print_message(struct mosq_config *cfg, const struct mosquitto_message *mess
fflush(stdout); fflush(stdout);
}else{ }else{
if(message->payloadlen){ if(message->payloadlen){
write_payload(message->payload, message->payloadlen, cfg->hex_output); write_payload(message->payload, message->payloadlen, false);
if(cfg->eol){ if(cfg->eol){
printf("\n"); printf("\n");
} }
@ -407,7 +407,7 @@ void print_usage(void)
printf(" [-A bind_address]\n"); printf(" [-A bind_address]\n");
#endif #endif
printf(" [-i id] [-I id_prefix]\n"); 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"); printf(" [--will-topic [--will-payload payload] [--will-qos qos] [--will-retain]]\n");
#ifdef WITH_TLS #ifdef WITH_TLS
printf(" [{--cafile file | --capath dir} [--cert file] [--key file]\n"); printf(" [{--cafile file | --capath dir} [--cert file] [--key file]\n");
@ -448,7 +448,6 @@ void print_usage(void)
printf(" -v : print published messages verbosely.\n"); printf(" -v : print published messages verbosely.\n");
printf(" -V : specify the version of the MQTT protocol to use when connecting.\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(" 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(" --help : display this message.\n");
printf(" --quiet : don't print error messages.\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"); printf(" --retained-only : only handle messages with the retained flag set, and exit when the\n");

View File

@ -50,7 +50,6 @@
<arg choice='opt' rep='repeat'><option>-U</option> <replaceable>unsub-topic</replaceable></arg> <arg choice='opt' rep='repeat'><option>-U</option> <replaceable>unsub-topic</replaceable></arg>
<arg><option>-v</option></arg> <arg><option>-v</option></arg>
<arg><option>-V</option> <replaceable>protocol-version</replaceable></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>--proxy</option> <replaceable>socks-url</replaceable></arg>
<arg><option>--quiet</option></arg> <arg><option>--quiet</option></arg>
<arg> <arg>
@ -546,13 +545,6 @@
the client disconnects unexpectedly.</para> the client disconnects unexpectedly.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>-x</option></term>
<listitem>
<para>Print published message payloads as hexadecimal
data.</para>
</listitem>
</varlistentry>
</variablelist> </variablelist>
</refsect1> </refsect1>