commit
This commit is contained in:
parent
7ae2a6982e
commit
8cb20fda51
3 changed files with 33 additions and 1 deletions
|
@ -31,6 +31,34 @@ void readConfs(ptConf confChain) {
|
|||
fclose(file);
|
||||
}
|
||||
|
||||
void readListeners(ptListener listenerChain) {
|
||||
FILE *file = fopen("./data/listeners", "r");
|
||||
char line[100];
|
||||
char *tokens[4];
|
||||
char *token;
|
||||
|
||||
if (file == NULL) {
|
||||
printf("ça marche pas.");
|
||||
return;
|
||||
}
|
||||
|
||||
while (fgets(line, sizeof(line), file)) {
|
||||
token = strtok(line, ",");
|
||||
|
||||
int i = 0;
|
||||
|
||||
while (token != NULL && i < 4) {
|
||||
tokens[i] = token;
|
||||
i ++;
|
||||
token = strtok(NULL, ",");
|
||||
}
|
||||
|
||||
addListener(listenerChain, atoi(tokens[0]), tokens[1], atoi(tokens[2]), atoi(tokens[3]));
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
void saveConf(ptConf confChain) {
|
||||
FILE *file = fopen("./data/confs", "w");
|
||||
ptConf px = confChain;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "conf.h"
|
||||
|
||||
void readConfs(ptConf confChain);
|
||||
void readListeners(ptListener listenerChain);
|
||||
void saveConf(ptConf confChain);
|
||||
void saveListeners(ptListener listenerChain);
|
||||
|
||||
|
|
5
main.c
5
main.c
|
@ -10,9 +10,12 @@ int main()
|
|||
ptListener listenerChain = newListenerChain();
|
||||
|
||||
readConfs(confChain);
|
||||
readListeners(listenerChain);
|
||||
|
||||
menu(confChain, listenerChain);
|
||||
|
||||
saveConf(confChain);
|
||||
saveListeners(listenerChain);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue