Veranderingen om CCS blij te maken

This commit is contained in:
Dennis Boekholtz 2024-04-13 23:16:24 +02:00
parent 64a72b70ef
commit 2495ac6ee6
3 changed files with 11 additions and 7 deletions

View File

@ -9,6 +9,7 @@
CLI_charOutFn CLI_charOut; CLI_charOutFn CLI_charOut;
CMDList_t* CMDList; CMDList_t* CMDList;
FIFOBuffChar_t* FIFO; FIFOBuffChar_t* FIFO;
int i;
// initilize and register the lineout print function // initilize and register the lineout print function
bool CLI_init(CLI_charOutFn lineOut, CMDList_t* cmdList) bool CLI_init(CLI_charOutFn lineOut, CMDList_t* cmdList)
@ -41,7 +42,7 @@ char* fifoToString(FIFOBuffChar_t* fifo)
char* out = malloc(fifo->size + 1); char* out = malloc(fifo->size + 1);
char* write_p = out; char* write_p = out;
for (int i = fifo->size; i > 0; i--) for (i = fifo->size; i > 0; i--)
{ {
FIFOBuffChar_get(fifo, write_p); FIFOBuffChar_get(fifo, write_p);
write_p++; write_p++;
@ -74,7 +75,7 @@ int tryExecute(FIFOBuffChar_t* fifo)
{ {
char err[100]; char err[100];
sprintf(&err[0], "command not found: %s\n> ", line); sprintf(&err[0], "command not found: %s\n> ", line);
for (int i=0; err[i] != 0; i++) for (i=0; err[i] != 0; i++)
{ {
char c[2] = {err[i], 0}; char c[2] = {err[i], 0};
(*CLI_charOut)(&c[0]); (*CLI_charOut)(&c[0]);
@ -139,7 +140,7 @@ bool CLI_charIn(char c)
case 27: // escape (start for arrow keys) case 27: // escape (start for arrow keys)
sprintf(&str[0], "\ninvlid char: ESC - (%i)\n", c); sprintf(&str[0], "\ninvlid char: ESC - (%i)\n", c);
for (int i=0; str[i] != 0; i++) for (i=0; str[i] != 0; i++)
{ {
char ch[2] = {str[i], 0}; char ch[2] = {str[i], 0};
(*CLI_charOut)(&ch[0]); (*CLI_charOut)(&ch[0]);
@ -148,7 +149,7 @@ bool CLI_charIn(char c)
default: default:
sprintf(&str[0], "\ninvlid char: '%c' - (%i)\n", c, c); sprintf(&str[0], "\ninvlid char: '%c' - (%i)\n", c, c);
for (int i=0; str[i] != 0; i++) for (i=0; str[i] != 0; i++)
{ {
char ch[2] = {str[i], 0}; char ch[2] = {str[i], 0};
(*CLI_charOut)(&ch[0]); (*CLI_charOut)(&ch[0]);

View File

@ -5,6 +5,7 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
int i;
// initilises a CMDList_t with all NULL pointers // initilises a CMDList_t with all NULL pointers
CMDList_t* CMDList_init() CMDList_t* CMDList_init()
{ {
@ -21,7 +22,7 @@ int CMDList_deinit(CMDList_t *list)
// printf("deinit %p\n", (void*)list); // printf("deinit %p\n", (void*)list);
// printf("deinit e %p\n", list->e); // printf("deinit e %p\n", list->e);
for (int i = 0; i < 26; i++) for (i = 0; i < 26; i++)
{ {
if (*(list_p + i) != NULL) if (*(list_p + i) != NULL)
{ {
@ -31,7 +32,7 @@ int CMDList_deinit(CMDList_t *list)
} }
//TODO: fix "free(): invalid pointer" //TODO: fix "free(): invalid pointer"
// free(list); free(list);
return 0; return 0;
} }

View File

@ -1,4 +1,4 @@
#include "FIFOBuffChar.h" #include "C:\Users\denbo\git\ems31_2023-2024_groep_09_ccs\ ems31_2023-2024_groep_09_submodules_2\FIFOBuff\FIFOBuffChar.h"
#include <stdlib.h> #include <stdlib.h>
#include <stddef.h> #include <stddef.h>
@ -141,6 +141,7 @@ bool FIFOBuffChar_pop(FIFOBuffChar_t *fifo)
default: // buffer is at least 2 element big default: // buffer is at least 2 element big
// find the second last element // find the second last element
{
FIFOBuffChar_element_t* secondLastEl = fifo->FirstEl_p; FIFOBuffChar_element_t* secondLastEl = fifo->FirstEl_p;
while ( while (
secondLastEl->nextElement != fifo->LastEl_p secondLastEl->nextElement != fifo->LastEl_p
@ -158,6 +159,7 @@ bool FIFOBuffChar_pop(FIFOBuffChar_t *fifo)
fifo->size--; fifo->size--;
ok = true; ok = true;
break; break;
}
} }
return ok; return ok;