libvigicrues  2.0.1
vigilance.c

A detailed example on how to retreive and handle the current vigilance state of a station (Morlaix [Lannidy] in this example).

#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <vigicrues.h>
#define VIGICRUES_LOIRE_BRETAGNE 8
static vigicrues_status_t func(const vigicrues_t *p_data, void *param)
{
char *s = NULL;
switch (p_data->vigilance) {
s = "Green";
break;
s = "Yellow";
break;
s = "Orange";
break;
s = "Red";
break;
}
struct tm *p_date = localtime(&(p_data->timestamp));
printf("Current vigilance state for station \"Morlaix [Lannidy]\":\n"
"%s published on %s", s, asctime(p_date));
}
int main(void)
{
vigicrues_status_t status = vigicrues_get(VIGICRUES_LOIRE_BRETAGNE,
"J260301501", VIGICRUES_VIGILANCE,
VIGICRUES_IGNORE_PARAM, &func, NULL,
return (status == VIGICRUES_SUCCESS) ? EXIT_SUCCESS : EXIT_FAILURE;
}