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);
|
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) {
|
void saveConf(ptConf confChain) {
|
||||||
FILE *file = fopen("./data/confs", "w");
|
FILE *file = fopen("./data/confs", "w");
|
||||||
ptConf px = confChain;
|
ptConf px = confChain;
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
|
|
||||||
void readConfs(ptConf confChain);
|
void readConfs(ptConf confChain);
|
||||||
|
void readListeners(ptListener listenerChain);
|
||||||
void saveConf(ptConf confChain);
|
void saveConf(ptConf confChain);
|
||||||
void saveListeners(ptListener listenerChain);
|
void saveListeners(ptListener listenerChain);
|
||||||
|
|
||||||
|
|
3
main.c
3
main.c
|
@ -10,7 +10,10 @@ int main()
|
||||||
ptListener listenerChain = newListenerChain();
|
ptListener listenerChain = newListenerChain();
|
||||||
|
|
||||||
readConfs(confChain);
|
readConfs(confChain);
|
||||||
|
readListeners(listenerChain);
|
||||||
|
|
||||||
menu(confChain, listenerChain);
|
menu(confChain, listenerChain);
|
||||||
|
|
||||||
saveConf(confChain);
|
saveConf(confChain);
|
||||||
saveListeners(listenerChain);
|
saveListeners(listenerChain);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue