Another attempt to refactor the bacapp_print_value function into a print() and

an extract() function. The original implementation used calloc() inside the
extract() routine which forced all clients, including embedded builds, to have a
heap. This was very heavy handed. The new solution is must more flexible. 
* If the client want to use the print() functionality, they will have to support
  calloc and string safe variable argument length function similar to snprintf.
  This seems reasonable because if you can print, then you can typically support
  these complex capabilities. 
* For clients that don't want to print, but still want to parse the bacpp value
  into a string, they can use the new extract() method, which only requires
  supports for snprintf. This would require a compile time definition of
  BACAPP_SNPRINTF_ENABLED.
* For clients which don't want the overhead of these heavy handed methods, it is
  possible to set compile time flags to not inherit either the print() or the
  extract() functions.
This commit is contained in:
gri6507
2011-12-12 16:22:04 +00:00
parent fcf2c4a8ba
commit 6e82afde79
2 changed files with 234 additions and 62 deletions
+8
View File
@@ -200,9 +200,17 @@ extern "C" {
#ifndef BACAPP_PRINT_ENABLED
#if PRINT_ENABLED || defined TEST
#define BACAPP_PRINT_ENABLED
#define BACAPP_SNPRINTF_ENABLED
#endif
#endif
#ifdef BACAPP_SNPRINTF_ENABLED
int bacapp_snprintf_value(
char *str,
size_t str_len,
BACNET_OBJECT_PROPERTY_VALUE * object_value);
#endif
#ifdef BACAPP_PRINT_ENABLED
bool bacapp_parse_application_data(
BACNET_APPLICATION_TAG tag_number,