Ejemplo 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;
}
Ejemplo 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;
}
Ejemplo n.º 3
0
int main(){

const char * dllName = userChoice();
    dynamic_t * dll = dynamic_init(dllName);
    if (NULL == dll) {
        printf("Can't load dynamic!\n");
        return 1;
    }
    if (NULL == dll->cmp) {
        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!\n");
     fflush(stdin);

    char str[100];
    gets(str);
    word_t * words = senToWords(str);
    puts("Done");
   //printf("Dynamic loaded!\n");
    /*for (int i = 0; words[i] != NULL; i++)
        puts(words[i]);*/
    if (words != NULL)
    if (dll->cmp(words))
        dll->react(words);

    return 0;
}
Ejemplo n.º 4
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;
}
Ejemplo n.º 5
0
int main(void) {
    const int MAX_QUEUE_SIZE = 7;
    Queue_t queue = Queue_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;
    }
    puts("Dynamic loaded!");
    srand(time(NULL));
    for (int i = 0; i < MAX_QUEUE_SIZE; i++) {
        int prec =  !(rand() % 3) ? 1 + rand() % 15 : 0;
        printf("%dth day's precipitation: %d\n", i, prec);
        Queue_enqueue(queue, prec);
    }
    if(dll->check(queue))
        dll->react();
    Queue_delete(queue);
    return 0;
}
Ejemplo n.º 6
0
int main(){
    queue_t * q1 = queue_createQueue();
    const char * dllName = userChoice();
    dynamic_t * dll = dynamic_init(dllName);
    int sum = 0;
    if (NULL == dll) {
        printf("Can't load dynamic!\n");
        return 1;
    }
    if (NULL == dll->cmp) {
        printf("Can't get compare function!\n");
        return 1;
    }
    if (NULL == dll->react) {
        printf("Can't get reaction function!\n");
        return 1;
    }
    srand(time(NULL));
    printf("Dynamic loaded!\n");
    while (queue_getCount(q1) < MAX_QUEUE_SIZE){
        queue_enqueue(q1, rand() % 100);
        printQueue(q1, sum);
        if(dll->cmp(q1)) {
            sum = dll->react(q1);
        }
    }
    queue_free(q1);

    return 0;
}
Ejemplo n.º 7
0
Archivo: main.c Proyecto: lorvis/study
int main()
{
    srand(time(NULL));

    queue_t * q = queue_new(QUEUE_SIZE);
    for(int i = 0; i < QUEUE_SIZE; i++)
        queue_add(q,rand()%(NUMBER_RANGE*2)-NUMBER_RANGE);
    int choice = 0;
    while (choice!=1&&choice!=2){
    system("cls");
    puts("Choose your library, type 1 or 2");
    scanf("%i",&choice);
    }

    dynamic_t * dyn;

    if(choice==1){
    dyn = dynamic_init("Lab2DLL1.dll");
    if(dyn==NULL){
    puts("FAILED TO LOAD DLL1");
    exit(1);
    }
    }

    else{
    dyn = dynamic_init("Lab2DLL2.dll");
    if(dyn==NULL){
    puts("FAILED TO LOAD DLL2");
    exit(1);
    }
    }

    puts("ORIGINAL QUEUE:");
    queue_show(q);
    puts(" ");

    if(dyn->check(q))
        dyn->action(q);

    queue_show(q);

    queue_free(q);

    return 0;
}
Ejemplo n.º 8
0
void lpc32xx_emc_init(const lpc32xx_emc_dynamic_config *dyn_cfg)
{
  /* Enable buffers in AHB ports */
  emc_ahb [0].control = EMC_AHB_PORT_BUFF_EN;
  emc_ahb [3].control = EMC_AHB_PORT_BUFF_EN;
  emc_ahb [4].control = EMC_AHB_PORT_BUFF_EN;

  /* Set AHB port timeouts */
  emc_ahb [0].timeout = EMC_AHB_TIMEOUT(32);
  emc_ahb [3].timeout = EMC_AHB_TIMEOUT(32);
  emc_ahb [4].timeout = EMC_AHB_TIMEOUT(32);

  /* Enable EMC */
  emc->control = EMC_CTRL_E,
  emc->config = 0;

  dynamic_init(dyn_cfg);
}
Ejemplo n.º 9
0
int main(){
    queue_osnova * q = new_queue_osnova();
    char * file = malloc(sizeof(char)*10);
    UserChoose(file);
    dynamic_t * dll = dynamic_init(file);
    if (NULL == dll) {
        printf("Can't load dynamic!\n");
        return 1;
    }
    if (NULL == dll->inspection_f) {
        printf("Can't get compare function!\n");
        return 1;
    }
    if (NULL == dll->react_f) {
        printf("Can't get reaction function!\n");
        return 1;
    }
    printf("Dynamic loaded!");

    Sleep(2000);

    queue_t * arr;

    while(1){
        system("cls");
        arr = queue_new(q, rand()%20-5);
        queue_print(q);
        if(dll->inspection_f(q))
            dll->react_f();
        Sleep(2000);
        //system("cls");

    }
    //dynamic_clean(dll);

    return 0;
}
Ejemplo n.º 10
0
int main(void) {
    const int MAX_STACK_SIZE = 10;
    stack_t * stack1 = stack_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!");
    Sleep(500);
    srand(time(NULL));
    while (stack_getCount(stack1) < MAX_STACK_SIZE) {
        stack_push(stack1, rand() % 100 - 50);
        printStacks(stack1);
        }
        if(dll->check(stack1)==1){
            dll->react(stack1);
        }
        else{
            return 0;
        }

        printStacks(stack1);
        Sleep(500);
        stack_free(stack1);
        return 0;
}