1: #include "global.h"
2: #include "rtlm.h"
3: #include "mqtt.h"
4:
5:
6: sl_config cfg;
7: sqlite3 *acc, *pub;
8: FILE *logg;
9: extern char compiled[], compiledby[], compilehost[];
10: static char szCfgName[MAXPATHLEN];
11: int Verbose, Kill;
12:
13: char szPublish[STRSIZ];
14:
15:
16: static void
17: Usage(void)
18: {
19: printf( " -= MQTT Client =- Publisher/Subscriber from ELWIX\n"
20: "=== %s@%s === Compiled: %s ===\n\n"
21: " Syntax: mqtt [options] <connect_to_broker[:port]> [value_for_publish]\n\n"
22: "\t-p <topic>\tPublish topic\n"
23: "\t-s <topic>\tSubscribe for this topic\n"
24: "\t-q <QoS>\tQoS level (0-at most 1, 1-at least 1, 2-explicit 1)\n"
25: "\t-d\t\tSend duplicate message\n"
26: "\t-r\t\tRetain message from broker\n"
27: "\t-c <config>\tService config\n"
28: "\t-f\t\t'value_for_publish' is file instead text\n"
29: "\t-D\t\tDaemon mode\n"
30: "\t-v\t\tVerbose (more -vvv, more verbose)\n"
31: "\t-h\t\tHelp! This screen\n\n",
32: compiledby, compilehost, compiled);
33: }
34:
35:
36: int
37: main(int argc, char **argv)
38: {
39: char ch, batch = 1, szStr[STRSIZ] = { 0 };
40:
41: strlcpy(szCfgName, DEFAULT_CONFIG, sizeof szCfgName);
42: while ((ch = getopt(argc, argv, "p:s:q:drc:fDvh")) != -1)
43: switch (ch) {
44: case 'p':
45: break;
46: case 's':
47: break;
48: case 'q':
49: break;
50: case 'd':
51: break;
52: case 'r':
53: break;
54: case 'f':
55: break;
56: case 'c':
57: strlcpy(szCfgName, optarg, sizeof szCfgName);
58: break;
59: case 'D':
60: batch = 0;
61: break;
62: case 'v':
63: Verbose++;
64: break;
65: case 'h':
66: default:
67: Usage();
68: return 1;
69: }
70: argc -= optind;
71: argv += optind;
72:
73: if (LoadConfig(szCfgName, &cfg)) {
74: printf("Error:: can't load #%d - %s\n", cfg_GetErrno(), cfg_GetError());
75: return 1;
76: }
77:
78: UnloadConfig(&cfg);
79: return 0;
80: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>