int main (int argc, char **argv) { FILE *out; char *eachData = NULL; size_t len = 0; unsigned char index = 0; char outPutMsg[BUF_SIZE_256B], outPutMsgTmp[BUF_SIZE_256B]; if (0 == argsCheck(argc, argv)) { if (0 != initStaticNames()) { printUsage(argv[0]); return 0; } } else { printUsage(argv[0]); return 0; } debug_printf("code[0]=[%s], code[1]=[%s]\n", g_acNaList[0], g_acNaList[1]); if (0 != initOutPutFileName())return 0; #ifdef __TEST__ printf("SleepSec is %d Sec g_fArgTinyDeal=%.0f Code=[%s]\n", g_iArgSlp, g_fArgTinyDeal, g_acNaList[SPE_DEX]); #endif do { g_ucHiddenMsg = 0; g_dateError = 0; memset(outPutMsg, 0, BUF_SIZE_256B); out = fopen(OUT_PUT, "r"); if (NULL != out) { index = 0; while (getline(&eachData, &len, out) != -1) { if (strlen(eachData) > EACH_REALTIME_DATA_MINIMAL_LEN) { if (NULL != eachData) { memset(outPutMsgTmp, 0, BUF_SIZE_256B); analysia_each_stk(eachData, index, outPutMsgTmp); if (0 == g_ucHiddenMsg && NULL != outPutMsgTmp && 2 < strlen(outPutMsgTmp)) { strcat(outPutMsg, outPutMsgTmp); } } } index++; } fclose(out); } if (0 == g_ucHiddenMsg && NULL != outPutMsg && 20 < strlen(outPutMsg)) // TODO //11:20:42+4.0 { #ifdef __TEST__ //int ptsFd = open(FILE_OUTP, O_RDWR); //if (0<ptsFd){write(ptsFd, outPutMsg, strlen(outPutMsg));close(ptsFd);} printf("%s", outPutMsg); #else int bakFd = open(g_acBakFileNa, O_RDWR|O_APPEND);//O_APPEND); if (0 < bakFd)write(bakFd, outPutMsg, strlen(outPutMsg));close(bakFd); #endif } sleep(g_iArgSlp); }while (0 == g_outOfTimeFlag && 1); printf("OUT OF TIME\n"); exit(EXIT_SUCCESS);return 0; }
int main (int argc, char **argv) { FILE *out; char *eachData = NULL; size_t len = 0; unsigned char index = 0; char outPutMsg[BUF_SIZE_256B], outPutMsgTmp[BUF_SIZE_256B]; int analysiaCnt = 0; if (0 == argsCheck(argc, argv)) { if (0 != initStaticNames()) { printUsage(argv[0]); return 0; } } else { printUsage(argv[0]); return 0; } debug_printf("code[0]=[%s], code[1]=[%s]\n", g_acNaList[0], g_acNaList[1]); #ifdef __TEST__ printf("SleepSec is %d Sec g_fArgTinyDeal=%.0f Code=[%s] g_iArgGapCnt=%d\n", g_iArgSlp, g_fArgTinyDeal, g_acNaList[SPE_DEX], g_iArgGapCnt); #endif if (0 != initOutPutFileName())return 0; do { g_ucHiddenMsg = 0; g_dateError = 0; memset(outPutMsg, 0, BUF_SIZE_256B); out = fopen(OUT_PUT, "r"); if (NULL != out) { index = 0; while (getline(&eachData, &len, out) != -1) { if (strlen(eachData) > EACH_REALTIME_DATA_MINIMAL_LEN) { if (NULL != eachData) { memset(outPutMsgTmp, 0, BUF_SIZE_256B); analysia_each_stk(eachData, index, outPutMsgTmp); if (0 == g_ucHiddenMsg && NULL != outPutMsgTmp && 2 < strlen(outPutMsgTmp)) { strcat(outPutMsg, outPutMsgTmp); } } } index++; } fclose(out); } if (0 == g_ucHiddenMsg && NULL != outPutMsg && 20 < strlen(outPutMsg)) // TODO //11:20:42+4.0 { #ifdef __TEST__ if (0 == analysiaCnt % g_iArgGapCnt) { printf("\n%02d-%02d-%02d%s", g_pstTime->tm_year-100, g_pstTime->tm_mon+1, g_pstTime->tm_mday, g_ucBakFileMsg[g_ucZhiShuType]); } printf("%s", outPutMsg); #else int bakFd = open(g_acBakFileNa, O_RDWR|O_APPEND);//O_APPEND); if (0 < bakFd) { write(bakFd, outPutMsg, strlen(outPutMsg)); close(bakFd); } #endif analysiaCnt++; } fflush(stdout); /* Add by KEWELL 2015-12-03 17:12:59 */ sleep(g_iArgSlp); }while (0 == g_outOfTimeFlag && 1); printf("OUT OF TIME\n"); exit(EXIT_SUCCESS);return 0; }