diff --git a/Makefile b/Makefile
index 03f29b3..ebce6a1 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,8 @@
.PHONY: clean All
All:
- @echo "----------Building project:[ UOC20211 - Release ]----------"
+ @echo "----------Building project:[ UOC20211 - Debug ]----------"
@"$(MAKE)" -f "UOC20211.mk"
clean:
- @echo "----------Cleaning project:[ UOC20211 - Release ]----------"
+ @echo "----------Cleaning project:[ UOC20211 - Debug ]----------"
@"$(MAKE)" -f "UOC20211.mk" clean
diff --git a/UOC20211.mk b/UOC20211.mk
index 445b454..f2815d8 100644
--- a/UOC20211.mk
+++ b/UOC20211.mk
@@ -2,12 +2,12 @@
## Auto Generated makefile by CodeLite IDE
## any manual changes will be erased
##
-## Release
+## Debug
ProjectName :=UOC20211
-ConfigurationName :=Release
+ConfigurationName :=Debug
WorkspacePath :=/dades/git/UOC/PP/PR1/UOC20211
ProjectPath :=/dades/git/UOC/PP/PR1/UOC20211
-IntermediateDirectory :=./bin/Release
+IntermediateDirectory :=./bin/Debug
OutDir := $(IntermediateDirectory)
CurrentFileName :=
CurrentFilePath :=
@@ -27,8 +27,8 @@ OutputSwitch :=-o
LibraryPathSwitch :=-L
PreprocessorSwitch :=-D
SourceSwitch :=-c
-OutputFile :=./bin/$(ProjectName)
-Preprocessors :=$(PreprocessorSwitch)NDEBUG
+OutputFile :=./bin/$(ProjectName)d
+Preprocessors :=
ObjectSwitch :=-o
ArchiveOutputSwitch :=
PreprocessOnlySwitch :=-E
@@ -39,8 +39,8 @@ LinkOptions :=
IncludePath := $(IncludeSwitch). $(IncludeSwitch). $(IncludeSwitch)test/include $(IncludeSwitch)UOCContacts/include
IncludePCH :=
RcIncludePath :=
-Libs := $(LibrarySwitch)UOCContacts
-ArLibs := "libUOCContacts.a"
+Libs := $(LibrarySwitch)UOCContactsd
+ArLibs := "libUOCContactsd.a"
LibPath := $(LibraryPathSwitch). $(LibraryPathSwitch)./lib
##
@@ -50,8 +50,8 @@ LibPath := $(LibraryPathSwitch). $(LibraryPathSwitch)./lib
AR := /usr/bin/ar rcu
CXX := /usr/bin/g++
CC := /usr/bin/gcc
-CXXFLAGS := -O2 -Wall $(Preprocessors)
-CFLAGS := -O2 -Wall $(Preprocessors)
+CXXFLAGS := -g -O0 -Wall $(Preprocessors)
+CFLAGS := -g -O0 -Wall $(Preprocessors)
ASFLAGS :=
AS := /usr/bin/as
@@ -79,11 +79,11 @@ $(OutputFile): $(IntermediateDirectory)/.d $(Objects)
$(LinkerName) $(OutputSwitch)$(OutputFile) @$(ObjectsFileList) $(LibPath) $(Libs) $(LinkOptions)
MakeIntermediateDirs:
- @test -d ./bin/Release || $(MakeDirCommand) ./bin/Release
+ @test -d ./bin/Debug || $(MakeDirCommand) ./bin/Debug
$(IntermediateDirectory)/.d:
- @test -d ./bin/Release || $(MakeDirCommand) ./bin/Release
+ @test -d ./bin/Debug || $(MakeDirCommand) ./bin/Debug
PreBuild:
@@ -121,6 +121,6 @@ $(IntermediateDirectory)/src_main.c$(PreprocessSuffix): src/main.c
## Clean
##
clean:
- $(RM) -r ./bin/Release/
+ $(RM) -r ./bin/Debug/
diff --git a/UOC20211.txt b/UOC20211.txt
index 07780c6..7d5be10 100644
--- a/UOC20211.txt
+++ b/UOC20211.txt
@@ -1 +1 @@
-./bin/Debug/test_src_test.c.o ./bin/Debug/test_src_test_suite.c.o ./bin/Debug/test_src_test_pr1.c.o ./bin/Debug/src_main.c.o
+./bin/Release/test_src_test.c.o ./bin/Release/test_src_test_suite.c.o ./bin/Release/test_src_test_pr1.c.o ./bin/Release/src_main.c.o
diff --git a/UOC20211.workspace b/UOC20211.workspace
index 580deab..65122bf 100644
--- a/UOC20211.workspace
+++ b/UOC20211.workspace
@@ -3,12 +3,12 @@
-
+
-
+
diff --git a/UOCContacts/UOCContacts.mk b/UOCContacts/UOCContacts.mk
index 237f4d2..2b46f42 100644
--- a/UOCContacts/UOCContacts.mk
+++ b/UOCContacts/UOCContacts.mk
@@ -2,12 +2,12 @@
## Auto Generated makefile by CodeLite IDE
## any manual changes will be erased
##
-## Release
+## Debug
ProjectName :=UOCContacts
-ConfigurationName :=Release
+ConfigurationName :=Debug
WorkspacePath :=/dades/git/UOC/PP/PR1/UOC20211
ProjectPath :=/dades/git/UOC/PP/PR1/UOC20211/UOCContacts
-IntermediateDirectory :=../bin/Release
+IntermediateDirectory :=../bin/Debug
OutDir := $(IntermediateDirectory)
CurrentFileName :=
CurrentFilePath :=
@@ -27,7 +27,7 @@ OutputSwitch :=-o
LibraryPathSwitch :=-L
PreprocessorSwitch :=-D
SourceSwitch :=-c
-OutputFile :=../lib/lib$(ProjectName).a
+OutputFile :=../lib/lib$(ProjectName)d.a
Preprocessors :=
ObjectSwitch :=-o
ArchiveOutputSwitch :=
@@ -50,8 +50,8 @@ LibPath := $(LibraryPathSwitch).
AR := /usr/bin/ar rcu
CXX := /usr/bin/g++
CC := /usr/bin/gcc
-CXXFLAGS := $(Preprocessors)
-CFLAGS := $(Preprocessors)
+CXXFLAGS := -g $(Preprocessors)
+CFLAGS := -g $(Preprocessors)
ASFLAGS :=
AS := /usr/bin/as
@@ -77,15 +77,15 @@ $(OutputFile): $(Objects)
@echo "" > $(IntermediateDirectory)/.d
@echo $(Objects0) > $(ObjectsFileList)
$(AR) $(ArchiveOutputSwitch)$(OutputFile) @$(ObjectsFileList)
- @$(MakeDirCommand) "/dades/git/UOC/PP/PR1/UOC20211/.build-release"
- @echo rebuilt > "/dades/git/UOC/PP/PR1/UOC20211/.build-release/UOCContacts"
+ @$(MakeDirCommand) "/dades/git/UOC/PP/PR1/UOC20211/.build-debug"
+ @echo rebuilt > "/dades/git/UOC/PP/PR1/UOC20211/.build-debug/UOCContacts"
MakeIntermediateDirs:
- @test -d ../bin/Release || $(MakeDirCommand) ../bin/Release
+ @test -d ../bin/Debug || $(MakeDirCommand) ../bin/Debug
-../bin/Release:
- @test -d ../bin/Release || $(MakeDirCommand) ../bin/Release
+../bin/Debug:
+ @test -d ../bin/Debug || $(MakeDirCommand) ../bin/Debug
PreBuild:
@@ -129,6 +129,6 @@ $(IntermediateDirectory)/src_date.c$(PreprocessSuffix): src/date.c
## Clean
##
clean:
- $(RM) -r ../bin/Release/
+ $(RM) -r ../bin/Debug/
diff --git a/UOCContacts/UOCContacts.txt b/UOCContacts/UOCContacts.txt
index 787bf82..8e3d4ce 100644
--- a/UOCContacts/UOCContacts.txt
+++ b/UOCContacts/UOCContacts.txt
@@ -1 +1 @@
-../bin/Debug/src_contact.c.o ../bin/Debug/src_api.c.o ../bin/Debug/src_person.c.o ../bin/Debug/src_csv.c.o ../bin/Debug/src_date.c.o
+../bin/Release/src_contact.c.o ../bin/Release/src_api.c.o ../bin/Release/src_person.c.o ../bin/Release/src_csv.c.o ../bin/Release/src_date.c.o
diff --git a/UOCContacts/include/contact.h b/UOCContacts/include/contact.h
index 887211d..d145878 100755
--- a/UOCContacts/include/contact.h
+++ b/UOCContacts/include/contact.h
@@ -85,5 +85,4 @@ void timePos_cpy(tTimePosition* destination, tTimePosition source);
// Clear tGeopositionData structure
void geoData_free(tGeolocationData* geoData);
////////////////////////////////////////////
-
#endif
diff --git a/UOCContacts/src/api.c b/UOCContacts/src/api.c
index 8137e0f..85d3f80 100644
--- a/UOCContacts/src/api.c
+++ b/UOCContacts/src/api.c
@@ -165,7 +165,32 @@ tApiError api_findPerson(tApiData* data, const char* document, tCSVEntry* person
//////////////////////////////////
// Ex PR1 3
/////////////////////////////////
- return E_NOT_IMPLEMENTED;
+
+ // Init new person entry for CSV data storage
+ csv_initEntry(person);
+
+ int index = population_find(data->population, document);
+
+ if (index != -1) {
+
+ char strCSV[FILE_READ_BUFFER_SIZE];
+
+ tPerson found = data->population.elems[index];
+
+ // Fill strCSV variable with data from the person found
+ sprintf(strCSV, "%s;%s;%s;%s;%s;%s;%s;%d/%d/%d",
+ "PERSON", found.document, found.name, found.surname,
+ found.email, found.address, found.cp,
+ found.birthday.day, found.birthday.month, found.birthday.year);
+
+ csv_parseEntry(person, strCSV, NULL);
+
+ return E_SUCCESS;
+
+ } else {
+ return E_PERSON_NOT_FOUND;
+ }
+
}
// Get all geolocation data for a given person
@@ -173,13 +198,69 @@ tApiError api_getPersonGeolocation(tApiData* data, const char* document, tCSVDat
//////////////////////////////////
// Ex PR1 3
/////////////////////////////////
- return E_NOT_IMPLEMENTED;
+
+ assert(geodata != NULL);
+ tApiError ret;
+
+ csv_init(geodata);
+
+ int i;
+ for(i = 0; i < data->geolocationData.count; i++) {
+ if(strcmp(data->geolocationData.elems[i].person, document) == 0) {
+
+ tTimePosition found = data->geolocationData.elems[i];
+ tCSVEntry csvEntry;
+ char strCSV[FILE_READ_BUFFER_SIZE];
+
+ // Fill strCSV variable with data from the person found
+ sprintf(strCSV, "%s;%s;%d/%d/%d;%d:%d;%f;%f",
+ "GEOLOCATION", found.person,
+ found.timestamp.date.day, found.timestamp.date.month, found.timestamp.date.year,
+ found.timestamp.time.hour, found.timestamp.time.minutes,
+ found.coordinate.latitude, found.coordinate.longitude);
+
+ csv_addStrEntry(geodata, strCSV, NULL);
+ }
+ }
+
+ if (geodata->count != 0) {
+ return E_SUCCESS;
+ } else {
+ return E_PERSON_NOT_FOUND;
+ }
+
}
// Remove a person
tApiError api_removePerson(tApiData* data, const char* document) {
//////////////////////////////////
// Ex PR1 3
- /////////////////////////////////
- return E_NOT_IMPLEMENTED;
+ /////////////////////////////////
+
+ population_del(&data->population, document);
+
+ tCSVData toDelete;
+ tDateTime dateTime;
+
+ char date[11];
+ char time[6];
+
+ api_getPersonGeolocation(data, document, &toDelete);
+
+ for(int i = 0; i < toDelete.count; i++) {
+
+ csv_getAsString(toDelete.entries[i], 1, date, 11);
+ csv_getAsString(toDelete.entries[i], 2, time, 6);
+
+ dateTime_parse(&dateTime, date, time);
+
+ geoData_del(&data->geolocationData, document, dateTime);
+ }
+
+ if (toDelete.count != 0) {
+ return E_SUCCESS;
+ } else {
+ return E_PERSON_NOT_FOUND;
+ }
+
}
diff --git a/UOCContacts/src/contact.c b/UOCContacts/src/contact.c
index f9933a5..7740691 100755
--- a/UOCContacts/src/contact.c
+++ b/UOCContacts/src/contact.c
@@ -5,7 +5,7 @@
#include "contact.h"
// Parse a tDateTime from string information
-void dateTime_parse(tDateTime* dateTime, const char* date, const char* time) {
+/*void dateTime_parse(tDateTime* dateTime, const char* date, const char* time) {
// Check output data
assert(dateTime != NULL);
@@ -22,16 +22,16 @@ void dateTime_parse(tDateTime* dateTime, const char* date, const char* time) {
// Parse the input time
sscanf(time, "%d:%d", &(dateTime->time.hour), &(dateTime->time.minutes));
-}
+}*/
// Compare two tDateTime structures and return true if they contain the same value or false otherwise.
-bool dateTime_cmp(tDateTime dateTime1, tDateTime dateTime2) {
+/*bool dateTime_cmp(tDateTime dateTime1, tDateTime dateTime2) {
if (dateTime1.date.day != dateTime2.date.day || dateTime1.date.month != dateTime2.date.month || dateTime1.date.year != dateTime2.date.year) {
return false;
}
return dateTime1.time.hour == dateTime2.time.hour && dateTime1.time.minutes == dateTime2.time.minutes;
-}
+}*/
// EX2: Implement your methods here....
diff --git a/bin/UOC20211 b/bin/UOC20211
index d6b95fb..e81c131 100755
Binary files a/bin/UOC20211 and b/bin/UOC20211 differ
diff --git a/bin/UOC20211d b/bin/UOC20211d
index e467ec9..a2f7c05 100755
Binary files a/bin/UOC20211d and b/bin/UOC20211d differ
diff --git a/compile_flags.txt b/compile_flags.txt
index acbe73e..c20a212 100644
--- a/compile_flags.txt
+++ b/compile_flags.txt
@@ -7,4 +7,3 @@
-I/dades/git/UOC/PP/PR1/UOC20211
-I/dades/git/UOC/PP/PR1/UOC20211/test/include
-I/dades/git/UOC/PP/PR1/UOC20211/UOCContacts/include
--DNDEBUG
diff --git a/lib/libUOCContacts.a b/lib/libUOCContacts.a
index da841c2..76a36ef 100644
Binary files a/lib/libUOCContacts.a and b/lib/libUOCContacts.a differ
diff --git a/lib/libUOCContactsd.a b/lib/libUOCContactsd.a
index 69ca883..6ad2710 100644
Binary files a/lib/libUOCContactsd.a and b/lib/libUOCContactsd.a differ