示例#1
0
void Carrier::validate () const
{
    UniqueLock lock(m_mutex);

    POMAGMA_INFO("Validating Carrier");

    m_support.validate();

    size_t actual_item_count = 0;
    size_t actual_rep_count = 0;
    for (Ob i = 1; i <= item_dim(); ++i) {
        Ob rep = m_reps[i].load();
        if (contains(i)) {
            POMAGMA_ASSERT(rep, "supported object has no rep: " << i);
            POMAGMA_ASSERT(rep <= i, "rep out of order: " << rep << "," << i);
            ++actual_item_count;
            if (rep == i) {
                ++actual_rep_count;
            }
        } else {
            POMAGMA_ASSERT(rep == 0, "unsupported object has rep: " << i);
        }
    }
    POMAGMA_ASSERT_EQ(item_count(), actual_item_count);
    POMAGMA_ASSERT_EQ(rep_count(), actual_rep_count);
}
示例#2
0
//aux to call stats functions
void statistics(char stat)
{
    if(stopApp==1)main();
    char tmp[1024]= {0x0};
    int fldcnt=0;
    char arr[MAXFLDS][MAXFLDSIZE]= {0x0};
    int recordcnt=0;

    if(stat=='a') strcpy(filename,"");

    if (!strcmp(filename,""))
    {
        printf("Enter key [d] to assume defaults [logcsv.csv],\n");
        printf("or insert the name of the CSV file [file.csv]: ");
        scanf("%s", filename);
    }
    if (!strcmp(filename,"d"))
        strcpy(filename,"logcsv.csv");

    in = fopen(filename,"r");/* open file on command line */

    if(checkFileIn()==-1)
    {
        optionSaveStats='3';
        printf("Error loading file...[%s]\n\n", filename);
        statistics('a');
    }
    if(checkFileIn()==0)
    {
        if(stat=='a')printf("Loading file...[%s]\n\n", filename);
        fgets(tmp,sizeof(tmp),in); /*jump over header*/
        while(fgets(tmp,sizeof(tmp),in)!=0) /* read a record */
        {
            i=0;
            j=0;
            recordcnt++;
            parse(tmp,",",arr,&fldcnt);    /* whack record into fields */
            for(i; i<fldcnt; i++)
            {
                //copy all records to strs
                strcpy(strs[recordcnt-1][i],arr[i]);
            }

        }
        if(stat=='a')printf("Done!!!\n", filename);
        if(stat=='a')PressEnterToReturn();
    }

    if (stat=='b') {
        system("clear");
        print_all_macip(recordcnt, 2,"Source devices:\n"); //list of all source devices - print mac and ip
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='c') {
        system("clear");
        print_all(recordcnt, 8, "Source ports:\n"); //list of all source ports
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='d') {
        system("clear");
        print_all_macip(recordcnt, 3,"\nDestination devices:\n"); //list of all destination devices - print mac and ip
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='e') {
        system("clear");
        print_all(recordcnt, 9, "Destination ports:\n"); //list of all destination ports
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='f') {
        system("clear");
        rep_count(recordcnt, 12, "0", "\nNº of Queries: "); //count number of queries, verifying the flag response=o
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='g') {
        system("clear");
        rep_count(recordcnt, 12, "1", "\nNº of Responses: "); //count number of responses, verifying the flag response=1
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='h') {
        system("clear");
        rep_count(recordcnt, 13, "3", "\nNº of Rcodes: "); //count number of Rcodes errors
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='i') {
        system("clear");
        check_times(recordcnt, 10); //verify delay between question and answer
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='j') {
        system("clear");
        print_all_stats(recordcnt, 2, "\nMAC source:"); //stats MAC Source
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='k') {
        system("clear");
        print_all_stats(recordcnt, 3, "\nMAC destination:");//stats MAC destination
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='l') {
        system("clear");
        print_all_stats(recordcnt, 18, "\nNames:");//stats Name
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='m') {
        system("clear");
        string keyword;
        printf("Insert the keyword to search in all queries: ");
        scanf("%s", keyword);
        count_occurrences(recordcnt, 18, "\nThe selected keyword:", keyword);
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='n') {
        system("clear");
        check_blacklisted(recordcnt, 21, "\nCheck queries responses:\n");//Check queries responses
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }

    statsMenu();
}