mirror of
https://gitlab.com/klmp200/LO27.git
synced 2024-11-19 18:43:19 +00:00
Add true makefile + lists
This commit is contained in:
parent
30e9c36b2d
commit
77491c8e61
BIN
CellElemFunc.o
BIN
CellElemFunc.o
Binary file not shown.
27
LibCell/Makefile
Normal file
27
LibCell/Makefile
Normal file
@ -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
|
@ -1,4 +1,4 @@
|
|||||||
/***
|
/***
|
||||||
--- CellElemFunc ---
|
--- CellElemFunc ---
|
||||||
---Created by : Naej Doree ---
|
---Created by : Naej Doree ---
|
||||||
***/
|
***/
|
||||||
@ -7,29 +7,11 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <CellElement.h>
|
#include <CellElement.h>
|
||||||
|
|
||||||
int main(int argc, char **argv){
|
|
||||||
cellElement * tree = NULL;
|
|
||||||
tree = CreateCellElem();
|
|
||||||
tree->colIndex = 1;
|
|
||||||
AddNextRow(tree);
|
|
||||||
tree->nextRow->colIndex = 2;
|
|
||||||
AddNextCol(tree);
|
|
||||||
tree->nextCol->colIndex = 3;
|
|
||||||
recursivePrint(tree);
|
|
||||||
removeNextRow(tree);
|
|
||||||
removeNextCol(tree);
|
|
||||||
|
|
||||||
recursivePrint(tree);
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
cellElement * CreateCellElem(){
|
cellElement * CreateCellElem(){
|
||||||
cellElement * elem = NULL;
|
cellElement * elem = NULL;
|
||||||
elem = (cellElement*) malloc(sizeof(cellElement));
|
elem = (cellElement*) malloc(sizeof(cellElement));
|
||||||
|
|
||||||
if (elem == NULL){
|
if (elem == NULL){
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -40,8 +22,8 @@ cellElement * CreateCellElem(){
|
|||||||
elem->nextCol = NULL;
|
elem->nextCol = NULL;
|
||||||
elem->nextRow = NULL;
|
elem->nextRow = NULL;
|
||||||
|
|
||||||
|
|
||||||
return elem;
|
return elem;
|
||||||
}
|
}
|
||||||
|
|
||||||
void freeCellElem(cellElement * elem){
|
void freeCellElem(cellElement * elem){
|
||||||
@ -53,7 +35,7 @@ int AddNextCol(cellElement* tree){
|
|||||||
|
|
||||||
cellElement * elem = NULL;
|
cellElement * elem = NULL;
|
||||||
elem = (cellElement*) malloc(sizeof(cellElement));
|
elem = (cellElement*) malloc(sizeof(cellElement));
|
||||||
|
|
||||||
if (elem == NULL){
|
if (elem == NULL){
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -69,7 +51,7 @@ int AddNextCol(cellElement* tree){
|
|||||||
}else{
|
}else{
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +60,7 @@ int AddNextRow(cellElement* tree){
|
|||||||
|
|
||||||
cellElement * elem = NULL;
|
cellElement * elem = NULL;
|
||||||
elem = (cellElement*) malloc(sizeof(cellElement));
|
elem = (cellElement*) malloc(sizeof(cellElement));
|
||||||
|
|
||||||
if (elem == NULL){
|
if (elem == NULL){
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -104,7 +86,7 @@ void removeNextCol(cellElement* tree){
|
|||||||
free(elem);
|
free(elem);
|
||||||
elem = NULL;
|
elem = NULL;
|
||||||
tree->nextCol = NULL;
|
tree->nextCol = NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -117,7 +99,7 @@ void removeNextRow(cellElement* tree){
|
|||||||
free(elem);
|
free(elem);
|
||||||
elem =NULL;
|
elem =NULL;
|
||||||
tree->nextRow = NULL;
|
tree->nextRow = NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -135,4 +117,10 @@ void recursivePrint(cellElement * tree){
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FreeCellElement(cellElement* element) {
|
||||||
|
if (element != NULL){
|
||||||
|
free(element);
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,7 @@
|
|||||||
*@false : 0
|
*@false : 0
|
||||||
*/
|
*/
|
||||||
typedef enum Bool{
|
typedef enum Bool{
|
||||||
|
|
||||||
true = 1,
|
true = 1,
|
||||||
false = 0
|
false = 0
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ typedef enum Bool{
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
struct cellElement {
|
struct cellElement {
|
||||||
|
|
||||||
int colIndex;
|
int colIndex;
|
||||||
int rowIndex;
|
int rowIndex;
|
||||||
|
|
||||||
@ -47,7 +47,8 @@ int AddNextRow(cellElement* tree);
|
|||||||
|
|
||||||
void removeNextCol(cellElement* list);
|
void removeNextCol(cellElement* list);
|
||||||
void removeNextRow(cellElement* list);
|
void removeNextRow(cellElement* list);
|
||||||
|
|
||||||
void recursivePrint(cellElement * tree);
|
void recursivePrint(cellElement * tree);
|
||||||
|
|
||||||
#endif
|
void FreeCellElement(cellElement* element);
|
||||||
|
|
||||||
|
#endif
|
29
LibList/Makefile
Normal file
29
LibList/Makefile
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
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"
|
||||||
|
$(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
|
||||||
|
|
||||||
|
|
99
LibList/list.h
Normal file
99
LibList/list.h
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
#ifndef LIST_H
|
||||||
|
#define LIST_H
|
||||||
|
|
||||||
|
#include <CellElement.h>
|
||||||
|
|
||||||
|
#define SUCCESS 0
|
||||||
|
#define FAILURE 1
|
||||||
|
|
||||||
|
typedef struct ListElement ListElement;
|
||||||
|
struct ListElement {
|
||||||
|
void *data;
|
||||||
|
ListElement *next;
|
||||||
|
ListElement *previous;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct List {
|
||||||
|
ListElement *head;
|
||||||
|
ListElement *tail;
|
||||||
|
int size;
|
||||||
|
} List;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create a new list
|
||||||
|
* @return a pointer of list
|
||||||
|
*/
|
||||||
|
List * CreateList();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Insert an element at the begining of a list
|
||||||
|
* @param list pointer of a list
|
||||||
|
* @param data any type of data
|
||||||
|
* @param size size of the data
|
||||||
|
* @return status of the operation
|
||||||
|
*/
|
||||||
|
int unshift(List* list, cellElement* data);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Insert an element at the end of a list
|
||||||
|
* @param list pointer of a list
|
||||||
|
* @param data any type of data
|
||||||
|
* @param size size of the data
|
||||||
|
* @return status of the operation
|
||||||
|
*/
|
||||||
|
int push(List* list, cellElement* data);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get an element in a given list
|
||||||
|
* @param list as a pointer
|
||||||
|
* @param nb the number of the element (can be negative)
|
||||||
|
* @return an element
|
||||||
|
*/
|
||||||
|
ListElement * GetElement(List *list, int nb);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Delete an element with a pointer of element in the list
|
||||||
|
* @param list as a pointer
|
||||||
|
* @param element of the list as a pointer
|
||||||
|
* @return status of the operation
|
||||||
|
*/
|
||||||
|
int PopPtnList(List *list, ListElement *element);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Delete an element with a position in the list
|
||||||
|
* @param list as a pointer
|
||||||
|
* @param position of the element
|
||||||
|
* @return status of the operation
|
||||||
|
*/
|
||||||
|
int RemoveElement(List *list, int nb);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Delete the first element of the list
|
||||||
|
* @param list as a pointer
|
||||||
|
* @return status of the operation
|
||||||
|
*/
|
||||||
|
int shift(List *list);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Delete the last element of the list
|
||||||
|
* @param list as a pointer
|
||||||
|
* @return status of the operation
|
||||||
|
*/
|
||||||
|
int pop(List *list);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Delete every elements in a list
|
||||||
|
* @param list as a pointer
|
||||||
|
* @return status of the operation
|
||||||
|
*/
|
||||||
|
int DeleteListContent(List *list);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Free a list
|
||||||
|
* @param list as a pointer
|
||||||
|
* @return status of the operation
|
||||||
|
*/
|
||||||
|
int FreeList(List *list);
|
||||||
|
|
||||||
|
#endif /* LIST_H */
|
68
Makefile
68
Makefile
@ -1,21 +1,57 @@
|
|||||||
CXX = gcc
|
# Makefile compiling the whole project
|
||||||
TARGET = Exe
|
# Don't forget before the first compilation to run that command:
|
||||||
SOURCEFILE = CellElemFunc
|
# export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:./Libs
|
||||||
CFLAGS = -Wall -Werror -ansi -pedantic -fpic -I. -g
|
|
||||||
|
|
||||||
#Generating the executable
|
CC=gcc
|
||||||
$(TARGET): $(SOURCEFILE).o
|
CFLAGS=-Wall -Werror -pedantic -fpic -g
|
||||||
@echo "Generating the executable" $@
|
|
||||||
$(CXX) $(CFLAGS) $(SOURCEFILE).o -o $@
|
|
||||||
|
|
||||||
$(SOURCEFILE).o:
|
|
||||||
@echo "Generating objectfiles" $@
|
|
||||||
$(CXX) $(CFLAGS) -c $(SOURCEFILE).c -o $@
|
|
||||||
|
|
||||||
#Cleaning the executable
|
LIBSDIR=-L/usr/lib -L./Libs
|
||||||
|
INCLUDEDIR=-I/usr/include -I. -I./LibCell -I./LibList
|
||||||
|
|
||||||
|
#Exe test variables
|
||||||
|
TARGET=main.exe
|
||||||
|
SOURCE=main
|
||||||
|
|
||||||
|
SOURCECFILE=$(SOURCE:=.c)
|
||||||
|
SOURCEOFILE=$(SOURCE:=.o)
|
||||||
|
|
||||||
|
#Library variables
|
||||||
|
DEPENDENCE=libCellElement.so
|
||||||
|
DEPENDENCENAME=CellElement
|
||||||
|
|
||||||
|
DEPENDENCELIST=libList.so
|
||||||
|
DEPENDENCENAMELIST=List
|
||||||
|
|
||||||
|
|
||||||
|
all: $(TARGET)
|
||||||
|
|
||||||
|
#Generating the main.exe
|
||||||
|
$(TARGET): $(SOURCEOFILE) $(DEPENDENCELIST) lib
|
||||||
|
@echo "\n Generating the " $(TARGET) " binary"
|
||||||
|
$(CC) $(SOURCEOFILE) $(LIBSDIR) -l$(DEPENDENCENAME) -l$(DEPENDENCENAMELIST) -o $(TARGET)
|
||||||
|
|
||||||
|
#Generating the library binary
|
||||||
|
lib:
|
||||||
|
@echo "\n Generating the automaton library binary"
|
||||||
|
mkdir -p Libs
|
||||||
|
$(MAKE) -C LibCell
|
||||||
|
|
||||||
|
$(DEPENDENCELIST):
|
||||||
|
@echo "\n Generating the list library binary"
|
||||||
|
$(MAKE) -C LibList
|
||||||
|
|
||||||
|
|
||||||
|
#Generating object files
|
||||||
|
.c.o:
|
||||||
|
@echo "\n Generating " $@ " from " $<
|
||||||
|
$(CC) $(CFLAGS) $(INCLUDEDIR) -c -o $@ $<
|
||||||
|
|
||||||
|
|
||||||
|
#Cleaning
|
||||||
clean:
|
clean:
|
||||||
@echo "Cleaning temporary files"
|
@echo "\n Cleaning"
|
||||||
rm -rf *.o *- *.so $(TARGET)
|
rm -rf *.o ./Libs/*.so *.exe
|
||||||
|
$(MAKE) -C LibCell clean
|
||||||
|
$(MAKE) -C LibList clean
|
||||||
|
|
||||||
|
|
||||||
|
28
main.c
Normal file
28
main.c
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/*********************************************************************************
|
||||||
|
* File Name : main.c
|
||||||
|
* Created By : klmp200
|
||||||
|
* Creation Date : [2016-12-10 01:06]
|
||||||
|
* Last Modified : [2016-12-10 01:07]
|
||||||
|
* Description :
|
||||||
|
**********************************************************************************/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <CellElement.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv){
|
||||||
|
cellElement * tree = NULL;
|
||||||
|
tree = CreateCellElem();
|
||||||
|
tree->colIndex = 1;
|
||||||
|
AddNextRow(tree);
|
||||||
|
tree->nextRow->colIndex = 2;
|
||||||
|
AddNextCol(tree);
|
||||||
|
tree->nextCol->colIndex = 3;
|
||||||
|
recursivePrint(tree);
|
||||||
|
removeNextRow(tree);
|
||||||
|
removeNextCol(tree);
|
||||||
|
recursivePrint(tree);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user