Annotation of mqtt/src/mqttd.c, revision 1.1.1.1.2.3
1.1 misho 1: #include "global.h"
1.1.1.1.2.1 misho 2: #include "rtlm.h"
3:
4:
5: sl_config cfg;
1.1.1.1.2.2 misho 6: extern char compiled[], compiledby[], compilehost[];
7: int Verbose;
8:
9:
10: static void
11: Usage(void)
12: {
13: printf( " -= MQTT Broker =- MQTT Service from ELWIX\n"
14: "=== %s@%s === Compiled: %s ===\n\n"
15: "\t-c <config>\tService config\n"
16: "\t-v\t\tVerbose (more -vvv, more verbose)\n"
17: "\t-h\t\tHelp! This screen\n\n",
18: compiledby, compilehost, compiled);
19: }
1.1 misho 20:
21:
22: int
23: main(int argc, char **argv)
24: {
1.1.1.1.2.2 misho 25: char ch, szCfgName[MAXPATHLEN];
1.1.1.1.2.3! misho 26: register int i;
! 27: sqlite3 *acc = NULL, *pub = NULL;
! 28: FILE *logg = NULL;
1.1.1.1.2.2 misho 29:
30: strlcpy(szCfgName, DEFAULT_CONFIG, sizeof szCfgName);
31: while ((ch = getopt(argc, argv, "hvc:")) != -1)
32: switch (ch) {
33: case 'c':
34: strlcpy(szCfgName, optarg, sizeof szCfgName);
35: break;
36: case 'v':
37: Verbose++;
38: break;
39: case 'h':
40: default:
41: Usage();
42: return 1;
43: }
44: argc -= optind;
45: argv += optind;
46:
47: if (LoadConfig(szCfgName, &cfg)) {
48: printf("Error:: can't load #%d - %s\n", cfg_GetErrno(), cfg_GetError());
49: return 1;
50: }
1.1.1.1.2.3! misho 51: for (i = 0; i < 3; i++)
! 52: if (!mqttLoadRTLM(&cfg, i)) {
! 53: printf("Error:: Can't load RTL module\n");
! 54: while (i--)
! 55: mqttUnloadRTLM(i);
! 56: UnloadConfig(&cfg);
! 57: return 2;
! 58: }
! 59: acc = call.OpenACC(&cfg);
! 60: if (!acc)
! 61: goto end;
! 62: pub = call.OpenPUB(&cfg);
! 63: if (!pub)
! 64: goto end;
! 65: logg = call.OpenLOG(&cfg);
! 66: if (!logg)
! 67: goto end;
! 68:
! 69: if (mqttMkDir(&cfg)) {
! 70: printf("Error:: in statedir #%d - %s\n", errno, strerror(errno));
! 71: goto end;
! 72: }
! 73:
! 74: VERB(2) printf("Service is ready for start engine ...\n");
1.1.1.1.2.2 misho 75:
1.1.1.1.2.3! misho 76: end:
! 77: call.CloseLOG(logg);
! 78: call.ClosePUB(pub);
! 79: call.CloseACC(acc);
! 80: for (i = 0; i < 3; i++)
! 81: mqttUnloadRTLM(i);
1.1.1.1.2.2 misho 82: UnloadConfig(&cfg);
1.1 misho 83: return 0;
84: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>