diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..586299e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +Libs/ diff --git a/LibCell/Makefile b/LibCell/Makefile new file mode 100644 index 0000000..aa62e0a --- /dev/null +++ b/LibCell/Makefile @@ -0,0 +1,27 @@ +CC=gcc +CFLAGS=-Wall -Werror -pedantic -fpic -g + + +LIBSDIR=-L/usr/lib -L../Libs +INCLUDEDIR=-I/usr/include -I. + +#Library variables +LIBTARGET=libCellElement.so +LIBSOURCE=CellElement +LIBSOURCECFILE=$(LIBSOURCE:=.c) +LIBSOURCEOFILE=$(LIBSOURCE:=.o) + +#Generating the library binary +$(LIBTARGET): $(LIBSOURCEOFILE) + @echo "\n Generating the library binary" + $(CC) $(CFLAGS) -shared $(LIBSOURCEOFILE) -o ../Libs/$(LIBTARGET) + +#Generating object files +.c.o: + @echo "\n Generating " $@ " from " $< + $(CC) $(CFLAGS) $(INCLUDEDIR) -c -o $@ $< + +#Cleaning +clean: + @echo "\n Cleaning" + rm -rf *.o *.exe *.so diff --git a/LibCell/CellElement.c b/LibList/CellElement.c similarity index 59% rename from LibCell/CellElement.c rename to LibList/CellElement.c index 07484f9..7e90729 100644 --- a/LibCell/CellElement.c +++ b/LibList/CellElement.c @@ -2,15 +2,15 @@ * @Author: klmp200 * @Date: 2016-12-10 01:32:50 * @Last Modified by: klmp200 -* @Last Modified time: 2016-12-10 01:33:40 +* @Last Modified time: 2016-12-10 04:29:48 */ #include #include -#include +#include -void freeCellElement(cellElement* element) { +void FreeCellElement(cellElement* element) { if (element != NULL){ free(element); } -} \ No newline at end of file +} diff --git a/LibCell/CellElement.h b/LibList/CellElement.h similarity index 89% rename from LibCell/CellElement.h rename to LibList/CellElement.h index 58c2623..be01e3b 100644 --- a/LibCell/CellElement.h +++ b/LibList/CellElement.h @@ -7,9 +7,9 @@ *@false : 0 */ typedef enum Bool{ - - true = 1; - false = 0; + + true = 1, + false = 0 } bool; @@ -40,6 +40,6 @@ struct cellElement { typedef struct cellElement * cellElement; -void freeCellElement(cellElement* element); +void FreeCellElement(cellElement* element); -#endif \ No newline at end of file +#endif diff --git a/LibList/Makefile b/LibList/Makefile new file mode 100644 index 0000000..ac206d5 --- /dev/null +++ b/LibList/Makefile @@ -0,0 +1,30 @@ +CC=gcc +CFLAGS=-Wall -Werror -pedantic -fpic -g + + +LIBSDIR=-L/usr/lib -L../Libs +INCLUDEDIR=-I/usr/include -I. + +#Library variables +LIBTARGET=libList.so +LIBSOURCE=list CellElement +LIBSOURCECFILE=$(LIBSOURCE:=.c) +LIBSOURCEOFILE=$(LIBSOURCE:=.o) + +#Generating the library binary +$(LIBTARGET): $(LIBSOURCEOFILE) + @echo "\n Generating the library binary" + mkdir -p ../Libs + $(CC) $(CFLAGS) -shared $(LIBSOURCEOFILE) -o ../Libs/$(LIBTARGET) + +#Generating object files +.c.o: + @echo "\n Generating " $@ " from " $< + $(CC) $(CFLAGS) $(INCLUDEDIR) -c -o $@ $< + +#Cleaning +clean: + @echo "\n Cleaning" + rm -rf *.o *.exe *.so + + diff --git a/LibList/list.c b/LibList/list.c index e87000a..f422a88 100644 --- a/LibList/list.c +++ b/LibList/list.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #define SUCCESS 0 @@ -36,7 +36,7 @@ int unshift(List *list, cellElement *data){ ListElement *newElement = malloc(sizeof(*newElement)); if (list != NULL && newElement != NULL && newData != NULL){ - memcpy(newData, data, size); + memcpy(newData, data, sizeof(cellElement)); newElement->data = newData; /* Insert the element at the begining of the list */ @@ -71,7 +71,7 @@ int push(List *list, cellElement *data){ ListElement *newElement = malloc(sizeof(*newElement)); if(list != NULL && newElement != NULL && newData != NULL){ - memcpy(newData, data, size); + memcpy(newData, data, sizeof(cellElement)); newElement->data = newData; newElement->next = NULL; if (list->tail == NULL){ @@ -145,7 +145,7 @@ int PopPtnList(List *list, ListElement *element){ } if (element->data != NULL){ - freeCellElement(element->data); + FreeCellElement(element->data); } free(element); list->size = list->size - 1; @@ -187,10 +187,10 @@ int DeleteListContent(List *list){ current = current->next; if (toDelete->data != NULL){ - freeCellElement(toDelete->data); + FreeCellElement(toDelete->data); } - freeCellElement(toDelete); + free(toDelete); } list->head = NULL; list->tail = NULL; diff --git a/LibList/list.h b/LibList/list.h index 514e02a..455c941 100644 --- a/LibList/list.h +++ b/LibList/list.h @@ -1,7 +1,7 @@ #ifndef LIST_H #define LIST_H -#import +#include #define SUCCESS 0 #define FAILURE 1 @@ -41,7 +41,7 @@ int unshift(List* list, cellElement* data); * @param size size of the data * @return status of the operation */ -int push(List* list, cellElement* data, int size); +int push(List* list, cellElement* data); /* * Get an element in a given list diff --git a/Makefile b/Makefile index b69a9ff..d7e22c6 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:./Libs CC=gcc -CFLAGS=-Wall -Werror -ansi -pedantic -fpic -g +CFLAGS=-Wall -Werror -pedantic -fpic -g LIBSDIR=-L/usr/lib -L./Libs @@ -34,6 +34,7 @@ $(TARGET): $(SOURCEOFILE) $(DEPENDENCELIST) lib #Generating the library binary lib: @echo "\n Generating the automaton library binary" + mkdir -p Libs $(MAKE) -C LibCell $(DEPENDENCELIST): @@ -51,6 +52,6 @@ $(DEPENDENCELIST): clean: @echo "\n Cleaning" rm -rf *.o ./Libs/*.so *.exe - $(MAKE) -C LibPoly clean + $(MAKE) -C LibCell clean $(MAKE) -C LibList clean diff --git a/main b/main deleted file mode 100755 index c1dee62..0000000 Binary files a/main and /dev/null differ diff --git a/main.o b/main.o deleted file mode 100644 index 61c790f..0000000 Binary files a/main.o and /dev/null differ