mosquitto_sub and mosquitto_rr now open stdout in binary mode on Windows
This is so binary payloads are not modified when printing. Thanks to Steve Mullock.
This commit is contained in:
parent
5217863b8b
commit
6028d0e33e
@ -1,3 +1,10 @@
|
||||
2.0.12 - 2021-07-xx
|
||||
===================
|
||||
|
||||
Clients:
|
||||
- mosquitto_sub and mosquitto_rr now open stdout in binary mode on Windows
|
||||
so binary payloads are not modified when printing.
|
||||
|
||||
2.0.11 - 2021-06-08
|
||||
===================
|
||||
|
||||
|
@ -309,6 +309,7 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
mosquitto_lib_init();
|
||||
output_init();
|
||||
|
||||
rc = client_config_load(&cfg, CLIENT_RR, argc, argv);
|
||||
if(rc){
|
||||
|
@ -324,7 +324,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
mosquitto_lib_init();
|
||||
|
||||
rand_init();
|
||||
output_init();
|
||||
|
||||
rc = client_config_load(&cfg, CLIENT_SUB, argc, argv);
|
||||
if(rc){
|
||||
|
@ -21,6 +21,8 @@ Contributors:
|
||||
#ifdef WIN32
|
||||
/* For rand_s on Windows */
|
||||
# define _CRT_RAND_S
|
||||
# include <fcntl.h>
|
||||
# include <io.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
@ -764,7 +766,7 @@ static void formatted_print(const struct mosq_config *lcfg, const struct mosquit
|
||||
}
|
||||
|
||||
|
||||
void rand_init(void)
|
||||
void output_init(void)
|
||||
{
|
||||
#ifndef WIN32
|
||||
struct tm *ti = NULL;
|
||||
@ -773,6 +775,9 @@ void rand_init(void)
|
||||
if(!get_time(&ti, &ns)){
|
||||
srandom((unsigned int)ns);
|
||||
}
|
||||
#else
|
||||
/* Disable text translation so binary payloads aren't modified */
|
||||
_setmode(_fileno(stdout), _O_BINARY);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ Contributors:
|
||||
#include "mosquitto.h"
|
||||
#include "client_shared.h"
|
||||
|
||||
void rand_init(void);
|
||||
void output_init(void);
|
||||
void print_message(struct mosq_config *cfg, const struct mosquitto_message *message, const mosquitto_property *properties);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user