rtl433  UNKNOWN
RTL-433 utility
data.h File Reference

A general structure for extracting hierarchical data from the devices; typically key-value pairs, but allows for more rich data as well. More...

Go to the source code of this file.

Data Structures

struct  data_array
 
struct  data
 
struct  data_output
 

Typedefs

typedef struct data_array data_array_t
 
typedef struct data data_t
 
typedef struct data_output data_output_t
 

Enumerations

enum  data_type_t {
  DATA_DATA, DATA_INT, DATA_DOUBLE, DATA_STRING,
  DATA_ARRAY, DATA_COUNT, DATA_FORMAT
}
 

Functions

data_tdata_make (const char *key, const char *pretty_key,...)
 Constructs a structured data object. More...
 
data_tdata_append (data_t *first, const char *key, const char *pretty_key,...)
 Adds to a structured data object, by appending data. More...
 
data_tdata_prepend (data_t *first, const char *key, const char *pretty_key,...)
 Adds to a structured data object, by prepending data. More...
 
data_array_tdata_array (int num_values, data_type_t type, void *ptr)
 Constructs an array from given data of the given uniform type. More...
 
void data_array_free (data_array_t *array)
 Releases a data array. More...
 
data_tdata_retain (data_t *data)
 Retain a structure object, returns the structure object passed in. More...
 
void data_free (data_t *data)
 Releases a structure object if retain is zero, decrement retain otherwise. More...
 
struct data_outputdata_output_csv_create (FILE *file)
 Construct data output for CSV printer. More...
 
struct data_outputdata_output_json_create (FILE *file)
 
struct data_outputdata_output_kv_create (FILE *file)
 
struct data_outputdata_output_syslog_create (const char *host, const char *port)
 
void data_output_start (struct data_output *output, const char **fields, int num_fields)
 Setup known field keys and start output, used by CSV only. More...
 
void data_output_print (struct data_output *output, data_t *data)
 Prints a structured data object. More...
 
void data_output_poll (struct data_output *output)
 Allows to polls an event loop, if necessary. More...
 
void data_output_free (struct data_output *output)
 
void print_value (data_output_t *output, data_type_t type, void *value, char *format)
 
void print_array_value (data_output_t *output, data_array_t *array, char *format, int idx)
 
size_t data_print_jsons (data_t *data, char *dst, size_t len)
 

Detailed Description

A general structure for extracting hierarchical data from the devices; typically key-value pairs, but allows for more rich data as well.

Copyright (C) 2015 by Erkki Seppälä flux@.nosp@m.mode.nosp@m.emi.f.nosp@m.i

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Typedef Documentation

◆ data_array_t

typedef struct data_array data_array_t

◆ data_output_t

typedef struct data_output data_output_t

◆ data_t

typedef struct data data_t

Enumeration Type Documentation

◆ data_type_t

Enumerator
DATA_DATA 

pointer to data is stored

DATA_INT 

pointer to integer is stored

DATA_DOUBLE 

pointer to a double is stored

DATA_STRING 

pointer to a string is stored

DATA_ARRAY 

pointer to an array of values is stored

DATA_COUNT 

invalid

DATA_FORMAT 

indicates the following value is formatted

Function Documentation

◆ data_append()

data_t* data_append ( data_t first,
const char *  key,
const char *  pretty_key,
  ... 
)

◆ data_array()

data_array_t* data_array ( int  num_values,
data_type_t  type,
void *  ptr 
)

Constructs an array from given data of the given uniform type.

Parameters
ptrThe contents pointed by the argument are copied in.
Returns
The constructed data array object, typically placed inside a data_t or NULL if there was a memory allocation error.

References data_meta_type_t::array_element_size, import_values(), data_array::num_values, data_array::type, and data_array::values.

Referenced by decoder_output_bitbuffer(), and radiohead_ask_callback().

◆ data_array_free()

◆ data_free()

void data_free ( data_t data)

Releases a structure object if retain is zero, decrement retain otherwise.

References data::format, data::key, data::next, data::pretty_key, data::retain, data::type, data::value, and data_meta_type_t::value_release.

Referenced by data_acquired_handler(), event_occurred_handler(), and vdata_make().

◆ data_make()

data_t* data_make ( const char *  key,
const char *  pretty_key,
  ... 
)

Constructs a structured data object.

Example: data_make( "key", "Pretty key", DATA_INT, 42, "others", "More data", DATA_DATA, data_make("foo", DATA_DOUBLE, 42.0, NULL), "zoom", NULL, data_array(2, DATA_STRING, (char*[]){"hello", "World"}), "double", "Double", DATA_DOUBLE, 10.0/3, NULL);

Most of the time the function copies perhaps what you expect it to. Things it copies:

  • string contents for keys and values
  • numerical arrays
  • string arrays (copied deeply)

Things it moves:

  • recursive data_t* and data_array_t* values

The rule is: if an object is boxed (look at the dmt structure in the data.c) and it has a array_elementwise_import in the same structure, then it is copied deeply. Otherwise, it is copied shallowly.

Parameters
keyName of the first value to put in.
pretty_keyPretty name for the key. Use "" if to omit pretty label for this field completely, or NULL if to use key name for it.
typeType of the first value to put in.
...The value of the first value to put in, followed by the rest of the key-type-values. The list is terminated with a NULL.
Returns
A constructed data_t* object or NULL if there was a memory allocation error.

References vdata_make().

Referenced by acurite_00275rm_decode(), acurite_6045_decode(), acurite_606_decode(), acurite_986_decode(), acurite_rain_896_decode(), acurite_th_decode(), acurite_txr_decode(), akhan_rke_callback(), alecto_ws1200v1_callback(), alecto_ws1200v2_callback(), alecto_ws1200v2_dcf_callback(), alectov1_callback(), ambient_weather_decode(), ambientweather_tx8300_callback(), ambientweather_wh31e_callback(), blyss_callback(), brennenstuhl_rcs_2044_process_row(), bresser_3ch_callback(), bresser_5in1_callback(), bt_rain_callback(), calibeur_rf104_callback(), cardin_callback(), chuango_callback(), companion_wtr001_decode(), create_report_data(), current_cost_decode(), danfoss_cfr_callback(), decode_xc0324_message(), decoder_output_bitbuffer(), decoder_output_bitbuffer_array(), decoder_output_bitrow(), decoder_output_message(), directv_decode(), dish_remote_6_3_callback(), dsc_callback(), ecowitt_decode(), efergy_e2_classic_callback(), efergy_optical_callback(), elro_db286a_callback(), em1000_callback(), emontx_callback(), esa_cost_callback(), esic_emt7110_decode(), esperanza_ews_callback(), eurochron_callback(), fineoffset_WH0290_callback(), fineoffset_WH0530_callback(), fineoffset_wh1050_callback(), fineoffset_wh1080_callback(), fineoffset_WH24_callback(), fineoffset_WH25_callback(), fineoffset_WH2_callback(), flex_callback(), fordremote_callback(), fs20_decode(), ft004b_callback(), ge_coloreffects_decode(), generic_motion_callback(), generic_remote_callback(), generic_temperature_sensor_callback(), gt_wt_02_process_row(), hcs200_callback(), hideki_ts04_callback(), holman_ws5029_decode(), hondaremote_callback(), honeywell_callback(), honeywell_wdb_callback(), ht680_callback(), ibis_beacon_callback(), ikea_sparsnas_callback(), infactory_callback(), interlogix_callback(), intertechno_callback(), kedsum_callback(), kerui_callback(), kw9015b_callback(), lacrosse_it(), lacrosse_tx141x_decode(), lacrosse_ws7000_decode(), lacrossetx_callback(), lacrossews_callback(), lightwave_rf_callback(), m_bus_output_data(), maverick_et73_sensor_callback(), maverick_et73x_callback(), mebus433_callback(), new_template_decode(), newkaku_callback(), nexa_callback(), nexus_callback(), oil_standard_decode(), oil_watchman_callback(), opus_xt300_callback(), oregon_scientific_sl109h_callback(), oregon_scientific_v1_callback(), oregon_scientific_v2_1_decode(), oregon_scientific_v3_decode(), philips_aj3650_decode(), philips_aj7010_decode(), prologue_callback(), proove_callback(), quhwa_callback(), radiohead_ask_callback(), rftech_callback(), rubicson_48659_decode(), rubicson_callback(), s3318p_callback(), schrader_EG53MA4_callback(), schraeder_callback(), sensible_living_callback(), silvercrest_callback(), smoke_gs558_callback(), solight_te44_callback(), springfield_callback(), ss_keypad_commands(), ss_pinentry_parser(), ss_sensor_parser(), steelmate_callback(), tfa_303196_callback(), tfa_pool_thermometer_callback(), tfa_twin_plus_303049_callback(), thermopro_tp11_sensor_callback(), thermopro_tp12_sensor_callback(), tpms_citroen_decode(), tpms_ford_decode(), tpms_jansite_decode(), tpms_pmv107j_decode(), tpms_renault_decode(), tpms_toyota_decode(), ts_ft002_decoder(), ttx201_decode(), vaillant_vrt340_callback(), waveman_callback(), wg_pb12v1_decode(), ws2000_callback(), wssensor_callback(), wt1024_callback(), wt450_callback(), x10_rf_callback(), and x10_sec_callback().

◆ data_output_csv_create()

struct data_output* data_output_csv_create ( FILE *  file)

Construct data output for CSV printer.

Parameters
filethe output stream
Returns
The auxiliary data to pass along with data_csv_printer to data_print. You must release this object with data_output_free once you're done with it.

References data_output_csv_free(), data_output_csv_start(), data_output::file, data_output_csv_t::output, data_output::output_free, data_output::output_start, data_output::print_array, print_csv_array(), print_csv_data(), print_csv_double(), print_csv_int(), print_csv_string(), data_output::print_data, data_output::print_double, data_output::print_int, and data_output::print_string.

Referenced by add_csv_output().

◆ data_output_free()

void data_output_free ( struct data_output output)

References data_output::output_free.

Referenced by r_free_cfg().

◆ data_output_json_create()

◆ data_output_kv_create()

◆ data_output_poll()

void data_output_poll ( struct data_output output)

Allows to polls an event loop, if necessary.

References data_output::output_poll.

Referenced by sdr_callback().

◆ data_output_print()

void data_output_print ( struct data_output output,
data_t data 
)

Prints a structured data object.

References data_output::file, and data_output::print_data.

Referenced by data_acquired_handler(), and event_occurred_handler().

◆ data_output_start()

void data_output_start ( struct data_output output,
const char **  fields,
int  num_fields 
)

Setup known field keys and start output, used by CSV only.

Parameters
outputthe data_output handle from data_output_x_create
fieldsthe list of fields to accept and expect. Array is copied, but the actual strings not. The list may contain duplicates and they are eliminated.
num_fieldsnumber of fields

References data_output::output_start.

Referenced by start_outputs().

◆ data_output_syslog_create()

◆ data_prepend()

data_t* data_prepend ( data_t first,
const char *  key,
const char *  pretty_key,
  ... 
)

Adds to a structured data object, by prepending data.

See also
data_make()

References data::next, and vdata_make().

Referenced by data_acquired_handler(), and event_occurred_handler().

◆ data_print_jsons()

◆ data_retain()

data_t* data_retain ( data_t data)

Retain a structure object, returns the structure object passed in.

References data::retain.

◆ print_array_value()

◆ print_value()