File:  [ELWIX - Embedded LightWeight unIX -] / mqtt / src / Attic / mqtt.c
Revision 1.1.1.1.2.10: download - view: text, annotated - select for diffs - revision graph
Thu Nov 24 00:08:56 2011 UTC (12 years, 7 months ago) by misho
Branches: mqtt1_0
Diff to: branchpoint 1.1.1.1: preferred, unified
again rework callbacks :) for easy init all with NULL
finish log_mqtt.so

    1: #include "global.h"
    2: #include "rtlm.h"
    3: 
    4: 
    5: sl_config cfg;
    6: 
    7: 
    8: int
    9: main(int argc, char **argv)
   10: {
   11: 	sqlite3 *acc = NULL, *pub = NULL;
   12: 	FILE *logg = NULL;
   13: 
   14: 	if (LoadConfig("/etc/mqtt.conf", &cfg)) {
   15: 		printf("Error:: Load config #%d - %s\n", cfg_GetErrno(), cfg_GetError());
   16: 		return 1;
   17: 	}
   18: 	if (!mqttLoadRTLM(&cfg, 0)) {
   19: 		printf("Error:: Can't load RTL ACC module\n");
   20: 		UnloadConfig(&cfg);
   21: 		return 2;
   22: 	}
   23: 	if (!mqttLoadRTLM(&cfg, 1)) {
   24: 		printf("Error:: Can't load RTL PUB module\n");
   25: 		mqttUnloadRTLM(0);
   26: 		UnloadConfig(&cfg);
   27: 		return 2;
   28: 	}
   29: 	if (!mqttLoadRTLM(&cfg, 2)) {
   30: 		printf("Error:: Can't load RTL LOG module\n");
   31: 		mqttUnloadRTLM(1);
   32: 		mqttUnloadRTLM(0);
   33: 		UnloadConfig(&cfg);
   34: 		return 2;
   35: 	}
   36: 
   37: 	acc = call.OpenACC(&cfg);
   38: 	if (!acc)
   39: 		goto end;
   40: 	pub = call.OpenPUB(&cfg);
   41: 	if (!pub)
   42: 		goto end;
   43: 	logg = call.OpenLOG(&cfg);
   44: 	if (!logg)
   45: 		goto end;
   46: 
   47: 	if (mqttMkDir(&cfg)) {
   48: 		printf("Error:: in statedir #%d - %s\n", errno, strerror(errno));
   49: 		goto end;
   50: 	}
   51: 
   52: 	call.LOG(logg, "success!\n");
   53: 
   54: end:
   55: 	call.CloseLOG(logg);
   56: 	call.ClosePUB(pub);
   57: 	call.CloseACC(acc);
   58: 	mqttUnloadRTLM(2);
   59: 	mqttUnloadRTLM(1);
   60: 	mqttUnloadRTLM(0);
   61: 	UnloadConfig(&cfg);
   62: 	return 0;
   63: }

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