Esempio n. 1
0
int main()
{
    list_t *list = list_new();
    dynamic_t * dll = dynamic_init(chooseLib ());
    if (NULL == dll) {
        printf("Can't load dynamic!\n");
        return 1;
    }
    if (NULL == dll->chk) {
        printf("Can't get check function!\n");
        return 1;
    }
    if (NULL == dll->react) {
        printf("Can't get reaction function!\n");
        return 1;
    }
    printf("Dynamic loaded!\n");
    srand(time(NULL));

    int i = 0;
    for (i = 0; i < 10; i++){
        list_add(list, rand() % 125);
    }
    list_print(list);
    dll->react(dll->chk(list));

    list_free(list);
    dynamic_clean(dll);
    return 0;
}
Esempio n. 2
0
int main(void) {
    progQueue_t queue = progQueue_new();

    const char * dllName = userChoice();
    dynamic_t * dll = dynamic_init(dllName);
    if (NULL == dll) {
        printf("Can't load dynamic!\n");
        return 1;
    }
    if (NULL == dll->check) {
        printf("Can't get compare function!\n");
        return 1;
    }
    if (NULL == dll->react) {
        printf("Can't get reaction function!\n");
        return 1;
    }
    printf("Dynamic loaded!");

    srand(time(NULL));

    for(int i = 0; i < 8; i++){
         progQueue_enqueue(queue, rand() % 25);
    }
    puts("");
    progQueue_print(queue);
    if(dll->check(queue) == 1)
        dll->react();
    else
        printf("OK\n");

    progQueue_remove(queue);
    dynamic_clean(dll);
    return 0;
}
Esempio n. 3
0
int main(void){
    char *dllName = choose_way();
    dynamic_t *dll = dynamic_init(dllName);
    if(!dll){
        printf("\nError: could not recieve dll name");
        return 0;
    }
    if(!dll->chk || !dll->react){
        printf("\nError: could not recieve dll funcltion name");
        return 0;
    }

    char sample[ARRAY_SIZE];
    srand(time(NULL));
    printf("\n");
    for(int i = 0; i < ARRAY_SIZE; i++){
        switch(rand() % SPACE_CHANCE + 1){
            case SPACE_CHANCE:
                add_elem(sample, i, ' ');
                break;
            default:
                add_elem(sample, i, rand() % 58 + 65);
                break;
        }
    }
    printf("\n%s", sample);
    if(dll->chk(sample, ARRAY_SIZE)){
        printf("\nReaction positive!");
        dll->react(sample, ARRAY_SIZE);
    }
    else
        printf("\nReaction negative!");
    dynamic_clean(dll);
    return 0;
}