Oyster Harvest Area Closure Analysis 0.1
Prediction and analysis of NSW oyster harvest area closures.
Loading...
Searching...
No Matches
harvest_area.c File Reference
Include dependency graph for harvest_area.c:

Functions

static void FA_FindHTMLValue (char *data, const char *search_term, char *value)
 Find value with HTML tags. More...
 
CURLcode FA_GetHarvestAreaStatus (const char *harvest_name, FA_HarvestArea_TypeDef *harvest_area)
 Harvest area of interest status information. More...
 
void FA_ParseResponse (char *data, FA_HarvestArea_TypeDef *harvest_area)
 Parse HTML data to populate status information data. More...
 

Function Documentation

◆ FA_FindHTMLValue()

static void FA_FindHTMLValue ( char *  data,
const char *  search_term,
char *  value 
)
static

Find value with HTML tags.

Extracts the value (item between HTML tags) from a HTML tag.

This function takes a search term that is unique to a particular HTML tag and searchers for the tags value. The value is then added to a provided char* (value) and returns.

Note
The search term can contain items from the previous HTML tag if the required tag doesn't have unique information.
Parameters
data
search_term
value

◆ FA_GetHarvestAreaStatus()

CURLcode FA_GetHarvestAreaStatus ( const char *  harvest_name,
FA_HarvestArea_TypeDef harvest_area 
)

Harvest area of interest status information.

Gets harvest area status information from NSW Food Authority.

NSW Food Authority provides a JSON response with XML data as values. The XML data basically contains generic cards that are used on the NSW FA website. This function parses out the relevent XML data and used helper functions to pull out a struct containing relevent data.

FA_HarvestAreaStatus_TypeDef harvest_area;
CURLcode FA_GetHarvestAreaStatus(const char *harvest_name, FA_HarvestArea_TypeDef *harvest_area)
Harvest area of interest status information.
Definition: harvest_area.c:32
#define FA_HA_CLYDE_MOONLIGHT
Moonlight harvest area.
Definition: harvest_area.h:16

The havest area names for Batemans Bay are as follow:

  • Waterfall
  • Moonlight
  • Rocky (representing Rocky Point)

Other harvest areas can be checked using this function (just need to know their name and use it as the harvest_name variable.

Parameters
harvest_nameName of harvest area.
harvest_areaHarvest area struct to populate with status information.
Returns
Code representing CURL response status.

◆ FA_ParseResponse()

void FA_ParseResponse ( char *  data,
FA_HarvestArea_TypeDef harvest_area 
)

Parse HTML data to populate status information data.

Takes a character array containing HTML data and formats a struct containing relevent harvest area status information.

Search terms are taken from the HTML input and the corresponding values (i.e. the text between relevent tags) are added to the corresponding struct.

Parameters
dataThe string to parse.
harvest_areaThe struct to populate with values.

Convert time to tm struct