1
Fork 0

Complet exercici 3a

This commit is contained in:
Guillem 2022-04-02 12:55:39 +02:00
parent 36bac13b1b
commit 7b660cd0dc
Signed by: lordwektabyte
GPG key ID: 73C5458905782129

View file

@ -19,6 +19,7 @@
#define MAX_PERSON_NAME_LEN 15
#define MAX_PERSON_EMAIL_LEN 30
#define MAX_PERSON_ADDRESS_LEN 30
#define VACCINE_TYPE_NAME "VACCINE"
// Get the API version information
const char* api_version() {
@ -237,7 +238,29 @@ tApiError api_getVaccine(tApiData data, const char *name, tCSVEntry *entry) {
//////////////////////////////////
// Ex PR1 3a
/////////////////////////////////
return E_NOT_IMPLEMENTED;
tApiError ret = E_NOT_IMPLEMENTED;
tVaccine* found;
char buffer[FILE_READ_BUFFER_SIZE];
found = vaccineList_find(data.vaccines,name);
if (found) { // If pointer is not null, vaccine exists
// Fill buffer with data from the vaccine on that pointer
sprintf(buffer, "%s;%d;%d", found->name, found->required, found->days);
// Init CSV entry and set values accordingly
csv_initEntry(entry);
csv_parseEntry(entry,buffer,VACCINE_TYPE_NAME);
ret = E_SUCCESS;
} else { // If pointer is null, vaccine does not exist
ret = E_VACCINE_NOT_FOUND;
}
return ret;
}
// Get vaccine lot data