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