|
/* Fichier trames.c - Gestion et decodage des trames */
|
|
/* Ce fichier sera fourni */
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include "trame.h"
|
|
|
|
#define FICHIER_TRAMES "gps.log" /* Par exemple */
|
|
|
|
#define MAX_FRAME_LENGTH 80
|
|
|
|
static char trame_buf[MAX_FRAME_LENGTH];
|
|
static FILE *trame_fic;
|
|
|
|
int trame_init(void)
|
|
{
|
|
trame_fic = fopen(FICHIER_TRAMES, "r");
|
|
if (trame_fic)
|
|
return 1;
|
|
|
|
fprintf(stderr, "Impossible d'ouvrir le fichier %s\n", FICHIER_TRAMES);
|
|
return 0;
|
|
}
|
|
|
|
char *trame_suivante(void)
|
|
{
|
|
return fgets(trame_buf, MAX_FRAME_LENGTH-1, trame_fic);
|
|
}
|