diff options
author | V.Krishn <vkrishn4@gmail.com> | 2014-03-20 15:24:00 +0530 |
---|---|---|
committer | V.Krishn <vkrishn4@gmail.com> | 2014-03-20 15:24:00 +0530 |
commit | 2767f15766dc94b1b18e0b8b94600c6d0981403f (patch) | |
tree | 6b8db31942b6d0268aa3841f960c59c59d263107 | |
parent | 97ac19706f249a8e080f52c8a1ac4f3450d62d79 (diff) | |
download | mqtt-dirpub-2767f15766dc94b1b18e0b8b94600c6d0981403f.tar.bz2 |
Update to v1.2.3, code cleanv0.3.0
-rw-r--r-- | docs/release-note/0.3.0.md | 4 | ||||
-rw-r--r-- | sub_client.c | 24 |
2 files changed, 17 insertions, 11 deletions
diff --git a/docs/release-note/0.3.0.md b/docs/release-note/0.3.0.md new file mode 100644 index 0000000..c0f5fc2 --- /dev/null +++ b/docs/release-note/0.3.0.md @@ -0,0 +1,4 @@ +## mqtt-dirpub +Release date: 2014-03-20 +* Updated difference from mosquitto.org(v1.2.3). +* Code clean. diff --git a/sub_client.c b/sub_client.c index b2a608e..98fbdf6 100644 --- a/sub_client.c +++ b/sub_client.c @@ -1,6 +1,6 @@ /* Copyright (c) 2009-2013 Roger Light <roger@atchoo.org> -Copyright (c) 2013 V.Krishn <vkrishn@insteps.net> +Copyright (c) 2013-2014 V.Krishn <vkrishn@insteps.net> All rights reserved. Redistribution and use in source and binary forms, with or without @@ -46,9 +46,6 @@ POSSIBILITY OF SUCH DAMAGE. #include <sys/types.h> #include <time.h> -// try using witout them -#include <stddef.h> -#include <stdlib.h> #include <mosquitto.h> @@ -388,13 +385,16 @@ void my_message_file_callback(struct mosquitto *mosq, void *obj, const struct mo } else{ if(ud->verbose){ if(message->payloadlen){ - fprintf(fptr, "%s %s\n", message->topic, (const char *)message->payload); + fprintf(fptr, "%s ", message->topic); + fwrite(message->payload, 1, message->payloadlen, fptr); + fprintf(fptr, "\n"); }else{ fprintf(fptr, "%s (null)\n", message->topic); } }else{ if(message->payloadlen){ - fprintf(fptr, "%s\n", (const char *)message->payload); + fwrite(message->payload, 1, message->payloadlen, fptr); + fprintf(fptr, "\n"); } } fclose(fptr); @@ -413,14 +413,17 @@ void my_message_callback(struct mosquitto *mosq, void *obj, const struct mosquit if(ud->verbose){ if(message->payloadlen){ - printf("%s %s\n", message->topic, (const char *)message->payload); + printf("%s ", message->topic); + fwrite(message->payload, 1, message->payloadlen, stdout); + printf("\n"); }else{ printf("%s (null)\n", message->topic); } fflush(stdout); }else{ if(message->payloadlen){ - printf("%s\n", (const char *)message->payload); + fwrite(message->payload, 1, message->payloadlen, stdout); + printf("\n"); fflush(stdout); } } @@ -561,7 +564,6 @@ int main(int argc, char *argv[]) char *will_topic = NULL; bool insecure = false; - //char *fmask = NULL; char *cafile = NULL; char *capath = NULL; char *certfile = NULL; @@ -601,7 +603,7 @@ int main(int argc, char *argv[]) clean_session = false; }else if(!strcmp(argv[i], "--fmask")){ if(i==argc-1){ - fprintf(stderr, "Error: --fmask argument given but no file specified.\n\n"); + fprintf(stderr, "Error: --fmask argument given but no outfile specified.\n\n"); print_usage(); return 1; }else{ @@ -958,8 +960,8 @@ int main(int argc, char *argv[]) fprintf(stderr, "Unable to connect (%d).\n", rc); } } - return rc; mosquitto_lib_cleanup(); + return rc; } rc = mosquitto_loop_forever(mosq, -1, 1); |