# ntrip.c

Functions:- | Gather and dispatch DGNSS data from Ntrip broadcasters.
Notes based on codec as of Tue Apr 6 10:17:55 2010 -0400.
`static char *ntrip_field_iterate(char *start, char *prev, const char *eol)` | Extract individual fields from the STR data block using ';' as the separator but handling string-embedded ';' characters correctly.
`static void ntrip_str_parse(char *str, size_t len, struct ntrip_stream_t *hold)` | Break an STR data block down using `ntrip_field_iterate()` and store the relevant details in an accumulation buffer.
`static int ntrip_sourcetable_parse(int fd, char *buf, ssize_t blen, const char *stream, struct ntrip_stream_t *keep)` | Parse a block of ntrip data by passing the STR data to `ntrip_str_parse()`. Return a 0 on success or -1 on any of the many possible failures.
`static int ntrip_stream_probe(const char *caster, const char *port, const char *stream, struct ntrip_stream_t *keep)` | Send a request to the broadcaster for a block of correction data. If successful, return the result of parsing the table. On error return -1.
`static int ntrip_auth_encode(const struct ntrip_stream_t *stream, const char *auth, char buf[], size_t size)` | Check the authorisation of the stream and return 0 if there is none or it is basic. Return -1 in all other cases.
`static int ntrip_stream_open(const char *caster, const char *port, const char *auth, struct gps_context_t *context, struct ntrip_stream_t *stream)` | Check the authorisation of the stream and if successful, try to connect. On connection, try to read data and test for various errors. On success, return the socket number, on error return -1.
`int ntrip_open(struct gps_context_t *context, char *caster)` | Try to establish a connection to the ntrip server. On success, return the socket number. Signal error with a return of -1.
`void ntrip_report(struct gps_device_t *session)` | If we have not contacted the server already and we have at least 10 fixes, send a report to the server and set the flag, so we don't do it again.