-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.c
More file actions
53 lines (51 loc) · 1.67 KB
/
Copy pathparser.c
File metadata and controls
53 lines (51 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <stdio.h>
#include <stdlib.h>
#include "LinkedList.h"
#include "vuelos-piloto.h"
#include "parser.h"
int parcerVueloFromText(FILE* pFile, LinkedList* pArrayListVuelo)
{
int auxRet =-1;
char idVuelo[500], idAvion[500], idPiloto[500], fecha[500], destino[500], cantPasajeros[500], horaDespegue[500], horaLlegada[500];
eVuelos* auxVuelo;
if(pFile != NULL && pArrayListVuelo)
{
auxRet=0;
fscanf(pFile, "%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^\n]\n",
idVuelo, idAvion, idPiloto, fecha, destino, cantPasajeros, horaDespegue, horaLlegada);
while(!feof(pFile))
{
if(feof(pFile))
{
break;
}
fscanf(pFile, "%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^,],%[^\n]\n",
idVuelo, idAvion, idPiloto, fecha, destino, cantPasajeros, horaDespegue, horaLlegada);
auxVuelo = newVueloParametros(idVuelo, idAvion, idPiloto, fecha, destino, cantPasajeros, horaDespegue, horaLlegada);
ll_add(pArrayListVuelo, (void*)auxVuelo);
}
}
return auxRet;
}
int parcerPilotoFromText(FILE* pFile, LinkedList* pArrayListPiloto)
{
int auxRet =-1;
char id[500], nombre[500];
ePiloto* pilotoAux;
if(pFile != NULL && pArrayListPiloto)
{
auxRet=0;
fscanf(pFile, "%[^,],%[^\n]\n",id,nombre);
while(!feof(pFile))
{
if(feof(pFile))
{
break;
}
fscanf(pFile, "%[^,],%[^\n]\n",id, nombre);
pilotoAux = newPilotoParametros(id, nombre);
ll_add(pArrayListPiloto, (void*)pilotoAux);
}
}
return auxRet;
}