--- mqtt/src/Attic/mqtt.c 2011/12/12 09:24:25 1.1.1.1.2.20 +++ mqtt/src/Attic/mqtt.c 2011/12/12 09:45:16 1.1.1.1.2.21 @@ -10,7 +10,7 @@ extern char compiled[], compiledby[], compilehost[]; static char szCfgName[MAXPATHLEN]; int Verbose, Kill; -char szPublish[STRSIZ]; +struct tagArgs *args; static void @@ -20,7 +20,7 @@ Usage(void) "=== %s@%s === Compiled: %s ===\n\n" " Syntax: mqtt [options] [value_for_publish]\n\n" "\t-p \tPublish topic\n" - "\t-s \tSubscribe for this topic\n" + "\t-s \tSubscribe for this topic, if wish add different |QoS to topic\n" "\t-q \tQoS level (0-at most 1, 1-at least 1, 2-explicit 1)\n" "\t-d\t\tSend duplicate message\n" "\t-r\t\tRetain message from broker\n" @@ -38,6 +38,11 @@ main(int argc, char **argv) { char ch, batch = 1, szStr[STRSIZ] = { 0 }; + if (!(args = malloc(sizeof(struct tagArgs)))) { + printf("Error:: in arguments #%d - %s\n", errno, strerror(errno)); + return 1; + } + strlcpy(szCfgName, DEFAULT_CONFIG, sizeof szCfgName); while ((ch = getopt(argc, argv, "p:s:q:drc:fDvh")) != -1) switch (ch) { @@ -64,6 +69,7 @@ main(int argc, char **argv) break; case 'h': default: + free(args); Usage(); return 1; } @@ -72,9 +78,11 @@ main(int argc, char **argv) if (LoadConfig(szCfgName, &cfg)) { printf("Error:: can't load #%d - %s\n", cfg_GetErrno(), cfg_GetError()); + free(args); return 1; } UnloadConfig(&cfg); + free(args); return 0; }