1
Fork 0

Complet exercici 3b

This commit is contained in:
Guillem 2022-04-02 13:18:51 +02:00
parent 1bd56d81e7
commit a15e818110
Signed by: lordwektabyte
GPG key ID: 73C5458905782129

View file

@ -268,7 +268,37 @@ tApiError api_getVaccineLot(tApiData data, const char* cp, const char* vaccine,
//////////////////////////////////
// Ex PR1 3b
/////////////////////////////////
return E_NOT_IMPLEMENTED;
tApiError ret = E_NOT_IMPLEMENTED;
tVaccineLot found;
int index;
char buffer[FILE_READ_BUFFER_SIZE];
index = vaccineLotData_find(data.vaccineLots,cp,vaccine,timestamp);
if (index != -1) { // If value is not -1, vaccineLot exists
vaccineLot_cpy(&found,data.vaccineLots.elems[index]);
// Fill buffer with data from the vaccine on that pointer
sprintf(buffer, "%02d/%02d/%04d;%02d:%02d;%s;%s;%d;%d;%d",
found.timestamp.date.day,found.timestamp.date.month,found.timestamp.date.year,
found.timestamp.time.hour,found.timestamp.time.minutes,
found.cp,
found.vaccine->name,found.vaccine->required,found.vaccine->days,
found.doses);
// Init CSV entry and set values accordingly
csv_initEntry(entry);
csv_parseEntry(entry,buffer,VACCINE_LOT_TYPE_NAME);
ret = E_SUCCESS;
} else { // If value is -1, vaccineLot does not exist
ret = E_LOT_NOT_FOUND;
}
return ret;
}
// Get registered vaccines