-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautoCompletion.c
77 lines (68 loc) · 1.33 KB
/
autoCompletion.c
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include "autoCompletion.h"
char **read_file(char *file)
{
int fileread;
int in;
char buffer[10000];
char **stock;
in = open(file, O_RDONLY);
if (in == - 1)
{
printf("Argument invalide\n");
exit(EXIT_FAILURE);
}
fileread = read(in, buffer, sizeof(buffer));
stock = save_dico(buffer);
return (stock);
}
char **separate(char *stock)
{
char **cut;
cut = cut_addr(stock);
return (cut);
}
llist add(llist liste, char **str)
{
element* new = malloc(sizeof(element));
char **typevoie;
char *ville;
char *num;
char *type;
char *nom;
typevoie = init_type();
ville = add_ville(str);
num = add_numvoie(str);
type = add_type(str);
nom = add_nom(str, typevoie);
new->ville = ville;
new->num = num;
new->type = type;
new->nomvoie = nom;
new->nxt = liste;
return (new);
}
int main(int ac, char **av)
{
llist liste = NULL;
llist_proba liste_proba = NULL;
char **stock;
char **cut;
int i = 0;
stock = read_file(av[1]);
while (stock[i] != NULL)
{
cut = separate(stock[i]);
liste = add(liste, cut);
i++;
}
liste_proba = run(liste, liste_proba);
start(liste, liste_proba);
//first_suggestion(liste_proba);
// view2(liste_proba);
//view(liste);
}