Beispiel #1
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;
}
Beispiel #2
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];
    
    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;
}
Beispiel #3
0
int main (int argc, char **argv)
{
    FILE *out;
    char *eachData = NULL;
    size_t len = 0;
    float fAlarmRate = 12.0;
    unsigned char isFirst = 1, index = 0;

    updateTimeDoze();
    //if (2 != argc || USEFUL_ID != getuid() || USEFUL_ID != geteuid() || 0 != strcmp(FILE_OUTP, ttyname(0)))
    if (2 != argc || 0 != strcmp(FILE_OUTP, ttyname(0)))
    {
        printf ("---------------KEWELL--------------- : %s %s() +%d\n", __FILE__, __func__, __LINE__);
        goto CleanUp;
    }

    if (2 == argc)
    {
        if (1 == strlen(argv[1]))
        {
            //fAlarmRate = __strtof_internal(argv[1], NULL, 0);
            fAlarmRate = strtof(argv[1], NULL);
        }

        if (fAlarmRate > 0.9 && fAlarmRate < 9.1)
        {
            iRunCnt= LOOP_TIME;
        }
        else if (0 == strcmp(argv[1], RUN_ONCE))
        {
            g_ucRunOnce = 1;
        }
        else if (0 == strcmp(argv[1], RUN_NO_STOP))
        {
            g_ucRunNoStop = 1;
            iRunCnt= LOOP_TIME;
        }
        else
        {
            printf ("---------------KEWELL--------------- : %s %s() +%d\n", __FILE__, __func__, __LINE__);
            goto CleanUp;
        }
    }

    while (iRunCnt > 0)
    {
        iRunCnt--;

        system("wget -q -O /tmp/.data2.list -i /var/www/icons/.README.list");
        out = fopen(OUT_PUT, "r");

        if (NULL != out)
        {
            index = 0;
            while (getline(&eachData, &len, out) != -1)
            {
                if (g_ucIsSZA || strlen(eachData) > 180)
                {
                    if (NULL != eachData)
                    {
                        analysia_each_stk(eachData, fAlarmRate, isFirst, index);
                        g_ucIsSZA = 0;
                    }
                }
                index++;
            }    
        }

        if (out)
        {
            fclose(out);
            //system("rm -rf /tmp/.data2.list");
        }

        if (iRunCnt > 0)
        {
            if(0 == isFirst)
            {
                sleep(g_dozeSec);
            }
            g_ucIsSZA = 1;
        }

        if (0 == iRunCnt % 20)
        {
            isFirst = 1;
        }
        else
        {
            isFirst = 0;
        }

    }
    exit(EXIT_SUCCESS);

    printf ("---------------KEWELL--------------- : %s %s() +%d\n", __FILE__, __func__, __LINE__);
CleanUp:
    system("rm -rf /tmp/.data2.list");
    printf("hello world\n");
    return 0;
}