Esempio n. 1
0
loodsensysteem *maak_loodsensysteem(void){
    loodsensysteem *loodsensysteem = malloc(sizeof(loodsensysteem));
    (*loodsensysteem).l1 = maak_loods();
    (*loodsensysteem).l2 = maak_loods();
    return loodsensysteem;
}
Esempio n. 2
0
int main(void)
{
    system("clear");
    printf("Welcome to C-Industries Tea Company\n\nShell: (type 'help' for help)\n");
    
    int exit = 0,
        i,j;
    loods1_t * loods1;
    loods1_t * loods2;
    
    loods1 = maak_loods();
    loods2 = maak_loods();
    
    do{
        char buffer[BUFFERSIZE];
        char input[BUFFERSIZE];
        printf("> ");
        if(fgets(buffer, sizeof(buffer), stdin) != NULL)
        {
            if (strncmp (buffer,"exit",3) == 0)
            {
                printf("Now exiting\n");
                sloop_loods(loods1, loods2);
                exit = 1;
            }
            else if (strncmp (buffer,"leveren",6) == 0)
            {
                char * data = leveren(loods1);
                if(data == NULL)
                {
                    printf("The Queue is empty\n");
                }
                else
                {
                    printf("%s", data);
                }
            }
            else if (strncmp (buffer,"opslaan",7) == 0)
            {
                /* Clear char input */
                for(i = 0; i < BUFFERSIZE; i++)
                {
                    input[i] = ' ';
                }
                /* Copy buffer to input */
                for(j = 0; buffer[j] != '\0'; j++)
                {
                    input[j] = buffer[j+8];
                }
                /* Save to Loods */
                if(verplaatsen12(loods1, loods2) != NULL)
                {
                    verplaatsen12(loods1, loods2);
                }
                
                opslaan(loods1, input);
                
                if(verplaatsen21(loods2, loods1) != NULL)
                {
                    verplaatsen21(loods2, loods1);
                }
            }
            else if (strncmp (buffer,"help",3) == 0)
            {
                printf("Commandos:\n\tlist\t\t\tgeeft de status van de stack weer\n\topslaan <string>\tSaves the entered string\n\tleveren\t\t\tPrint the top item of the Stack\n\texit\t\t\tExit the Program\n");
            }
            else if (strncmp (buffer,"list",3) == 0)
            {
                printf("> Listing the Queue: (loods1)\n");
                printf("\tloods1 -> size: %d\n\tloods1 -> front: %d\n", loods1 -> size, loods1 -> front);
                printf("> Listing the Queue: (loods2)\n");
                printf("\tloods2 -> size: %d\n\tloods2 -> front: %d\n", loods2 -> size, loods2 -> front);
            }
            else
            {
                printf("Command not recognized\n");
            }
        }
    } while(exit != 1);
    return 0;
}