#include <stdio.h>
#include "omcLib.h"

int main()
{
	static MYSQL *dbConn;
	static FILE *logFp_1;
	static FILE *logFp_2;

	dbConn = mysql_conn("localhost", "OMC_PUB");
	if (dbConn == NULL) {
		return (0);
	}
	//test omc_RbcdToAscii
	if (1) {
		char tmpAsc[10];
		unsigned char tmpBcd[5] = { 0x96, 0x51, 0x99, 0x99, 0x99 };
		omc_RbcdToAscii(tmpAsc, tmpBcd, 10);
		printf("\n tmpAsc = %s", tmpAsc);
		printf("\n Just say:Good Luck! \n\n");
	}
	//test omcLog 
	if (1) {
		char hewd[6] = "hewd";
		omcLogInit("./log", "hahaLog", &logFp_1);
		omcLog(logFp_1, "I love you, %s", hewd);
		omcLogInit("./log", "heheLog", &logFp_2);
		omcLog(logFp_2, "%s,I love you", hewd);
		omcLog(logFp_2, "%s,I love you", hewd);
		omcLog(logFp_2, "%s,I love you", hewd);
		omcLog(logFp_2, "%s,I love you", hewd);
	}
	//test mysql_tblcopy
	if (0) {
		int haha;
		haha =
			mysql_tblCpy(dbConn, "CDR_DB.cdrFromHLR_30",
						 "CDR_DB.cdrFromHLR_00");
		printf("haha = %d", haha);
	}
	//test delete table's record and sync with other omc
	if (0) {
		char sqlstr[256] = "\0";
		sprintf(sqlstr,
				"DELETE FROM CDR_DB.cdrFromMSC_23 WHERE TO_DAYS(releaseTime)<TO_DAYS(NOW())");
		if (mysql_query(dbConn, sqlstr) != 0) {
			printf("query failed !");
		} else {
			printf("query ok !");
		}
	}
	if (1) {
		char sqlstr[256] = "\0";
		sprintf(sqlstr,
				"CREATE TABLE CDR_DB.test (test TINYINT not null ) ");
		if (mysql_query(dbConn, sqlstr) != 0) {
			printf("query failed !");
		} else {
			printf("query ok !");
		}
	}
	mysql_close(dbConn);
	if (!0) {
		printf("\n!0 is ture");
	}
	if (-1) {
		int i = !-1;
		printf("\n!-1 is false [%d]", i);
	}
	return (0);
}
