Open Storm
Functions
strlib.c File Reference

Functions for parsing c strings. More...

#include "strlib.h"
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for strlib.c:

Functions

uint8_t parse_influxdb (char *value, char *packet, char *name)
 Searches InfluxDB json packet, "packet", for "name" and writes the associated value to "value" as a char array. This is ported from packet_get_value() from packet.c in kLabUM/IoT. More...
 
uint8_t strparse_influxdb (char *param, char *packet, char *name)
 Searches InfluxDB json-packet, "packet" for "name" and stores the associated value as a string in "param". Removes the quotations that wrap the strings returned in the query. More...
 
uint8_t intparse_influxdb (int *param, char *packet, char *name)
 Searches InfluxDB json-packet, "packet" for "name" and stores the associated value as an int in "param". Removes the quotations that wrap the strings returned in the query. More...
 
uint8_t clear_str (char *str)
 Resets a string to null bytes. More...
 
void zips (char *begin[], char *end[],...)
 Variadic function that zips c strings. More...
 
void zipf (float begin[], float end[],...)
 Variadic function that zips floats. More...
 
char * strextract (const char input_str[], char output_str[], const char search_start[], const char search_end[])
 Searches for the left-most c string in between search_start and search_end and stores it in output_str. More...
 
void for_each (void *begin, void *end, size_t sz, void(*fn)(void *a))
 Applies a function over a range of values;. More...
 
uint8_t gps_parse (const char *gps_string, float *lat, float *lon, float *hdop, float *altitude, uint8_t *gps_fix, float *cog, float *spkm, float *spkn, uint8_t *nsat)
 Parses the given gps string into the given buffers. More...
 
uint8_t parse_http_status (char *http_status, char *version, char *status_code, char *phrase)
 Searches a string "http_status" and attempts to parse the status line. Stores the results in "version", "status_code", and "phrase". More...
 

Detailed Description

Functions for parsing c strings.

Author
Brandon Wong, Ivan Mondragon
Version
TODO
Date
2017-06-19

Function Documentation

uint8_t clear_str ( char *  str)

Resets a string to null bytes.

Parameters
strString to reset
Returns
1u on success, 0u otherwise

Here is the caller graph for this function:

void for_each ( void *  begin,
void *  end,
size_t  sz,
void(*)(void *a)  fn 
)

Applies a function over a range of values;.

Parameters
begin[]Pointer to beginning of range.
end[]Pointer to one past the end of the range.
szSize of each element in bytes.
fnfunction which transforms each value.
uint8_t gps_parse ( const char *  gps_string,
float *  lat,
float *  lon,
float *  hdop,
float *  altitude,
uint8_t *  gps_fix,
float *  cog,
float *  spkm,
float *  spkn,
uint8_t *  nsat 
)

Parses the given gps string into the given buffers.

Parameters
gps_stringThe string to be parsed
latBuffer to store the Latitude.
lonBuffer to store the Longitude.
hdopBuffer to store the Horizontal Diluition of Precision.
altitudeBuffer to store the Altitude: mean-sea-level (geoid).
gps_fixBuffer to store the flag:
  • 0 = Invalid Fix
  • 2 = 2D fix
  • 3 = 3D fix
cogBuffer to store the Course over ground.
spkmBuffer to store the Speed over ground (km/hr).
spknBuffer to store the Speed over ground (knots).
nsatBuffer to store the number of satellites in use [0..12]
Returns
1u on successful parsing, 0u otherwise.

Here is the call graph for this function:

Here is the caller graph for this function:

uint8_t intparse_influxdb ( int *  param,
char *  packet,
char *  name 
)

Searches InfluxDB json-packet, "packet" for "name" and stores the associated value as an int in "param". Removes the quotations that wrap the strings returned in the query.

Parameters
paramParameter to be written to
packetPacket to search
nameSubstring to search for in packet
Returns
1u on success, 0u otherwise

Here is the call graph for this function:

Here is the caller graph for this function:

uint8_t parse_http_status ( char *  http_status,
char *  version,
char *  status_code,
char *  phrase 
)

Searches a string "http_status" and attempts to parse the status line. Stores the results in "version", "status_code", and "phrase".

Parameters
http_statusString to be parsed. Expects Status-Line protocol.
versionBuffer to store the version.
status_codeBuffer to store the status code.
phraseBuffer to store the phrase.
Returns
1u on success, 0u otherwise.

Here is the call graph for this function:

Here is the caller graph for this function:

uint8_t parse_influxdb ( char *  value,
char *  packet,
char *  name 
)

Searches InfluxDB json packet, "packet", for "name" and writes the associated value to "value" as a char array. This is ported from packet_get_value() from packet.c in kLabUM/IoT.

Parameters
valueValue to be written to
packetPacket to search
nameSubstring to search for in packet
Returns
1u on success, 0u otherwise

Here is the caller graph for this function:

char* strextract ( const char  input_str[],
char  output_str[],
const char  search_start[],
const char  search_end[] 
)

Searches for the left-most c string in between search_start and search_end and stores it in output_str.

Parameters
input_str[]C string to be searched
output_str[]Buffer to store the resulting c string
search_start[]Leading c string in the query
search_end[]Ending c string in the query
Returns
Pointer to first occurance of search_end after search_start or NULL if extraction fails.

Here is the caller graph for this function:

uint8_t strparse_influxdb ( char *  param,
char *  packet,
char *  name 
)

Searches InfluxDB json-packet, "packet" for "name" and stores the associated value as a string in "param". Removes the quotations that wrap the strings returned in the query.

Parameters
paramParameter to be written to
packetPacket to search
nameSubstring to search for in packet
Returns
1u on success, 0u otherwise

Here is the call graph for this function:

Here is the caller graph for this function:

void zipf ( float  begin[],
float  end[],
  ... 
)

Variadic function that zips floats.

Parameters
beginBuffer to store the floats.
endPointer to one past the end of the buffer.
...Variadic number of floats.

Here is the caller graph for this function:

void zips ( char *  begin[],
char *  end[],
  ... 
)

Variadic function that zips c strings.

Parameters
beginBuffer to store the c strings.
endPointer to one past the end of the buffer.
...Variadic number of c strings.

Here is the caller graph for this function: