Annotation of mqtt/src/mqtt.c, revision 1.1.1.1.2.21

1.1       misho       1: #include "global.h"
1.1.1.1.2.5  misho       2: #include "rtlm.h"
1.1.1.1.2.20  misho       3: #include "mqtt.h"
1.1.1.1.2.5  misho       4: 
                      5: 
                      6: sl_config cfg;
1.1.1.1.2.20  misho       7: sqlite3 *acc, *pub;
                      8: FILE *logg;
                      9: extern char compiled[], compiledby[], compilehost[];
                     10: static char szCfgName[MAXPATHLEN];
                     11: int Verbose, Kill;
                     12: 
1.1.1.1.2.21! misho      13: struct tagArgs *args;
1.1.1.1.2.20  misho      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"
1.1.1.1.2.21! misho      23:                "\t-s <topic[|QoS]>\tSubscribe for this topic, if wish add different |QoS to topic\n"
1.1.1.1.2.20  misho      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: }
1.1       misho      34: 
                     35: 
                     36: int
                     37: main(int argc, char **argv)
                     38: {
1.1.1.1.2.20  misho      39:        char ch, batch = 1, szStr[STRSIZ] = { 0 };
1.1.1.1.2.5  misho      40: 
1.1.1.1.2.21! misho      41:        if (!(args = malloc(sizeof(struct tagArgs)))) {
        !            42:                printf("Error:: in arguments #%d - %s\n", errno, strerror(errno));
        !            43:                return 1;
        !            44:        }
        !            45: 
1.1.1.1.2.20  misho      46:        strlcpy(szCfgName, DEFAULT_CONFIG, sizeof szCfgName);
                     47:        while ((ch = getopt(argc, argv, "p:s:q:drc:fDvh")) != -1)
                     48:                switch (ch) {
                     49:                        case 'p':
                     50:                                break;
                     51:                        case 's':
                     52:                                break;
                     53:                        case 'q':
                     54:                                break;
                     55:                        case 'd':
                     56:                                break;
                     57:                        case 'r':
                     58:                                break;
                     59:                        case 'f':
                     60:                                break;
                     61:                        case 'c':
                     62:                                strlcpy(szCfgName, optarg, sizeof szCfgName);
                     63:                                break;
                     64:                        case 'D':
                     65:                                batch = 0;
                     66:                                break;
                     67:                        case 'v':
                     68:                                Verbose++;
                     69:                                break;
                     70:                        case 'h':
                     71:                        default:
1.1.1.1.2.21! misho      72:                                free(args);
1.1.1.1.2.20  misho      73:                                Usage();
                     74:                                return 1;
                     75:                }
                     76:        argc -= optind;
                     77:        argv += optind;
1.1.1.1.2.5  misho      78: 
1.1.1.1.2.20  misho      79:        if (LoadConfig(szCfgName, &cfg)) {
                     80:                printf("Error:: can't load #%d - %s\n", cfg_GetErrno(), cfg_GetError());
1.1.1.1.2.21! misho      81:                free(args);
1.1.1.1.2.20  misho      82:                return 1;
1.1.1.1.2.7  misho      83:        }
                     84: 
1.1.1.1.2.5  misho      85:        UnloadConfig(&cfg);
1.1.1.1.2.21! misho      86:        free(args);
1.1       misho      87:        return 0;
                     88: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>