LIBSSDP
 All Classes Files Functions Variables Typedefs Macros
Macros | Functions
ssdp_cache_output_format.c File Reference
#include <stdlib.h>
#include <string.h>
#include "common_definitions.h"
#include "log.h"
#include "ssdp_cache_output_format.h"
#include "ssdp_message.h"
Include dependency graph for ssdp_cache_output_format.c:

Go to the source code of this file.

Macros

#define SSDP_CUSTOM_FIELD_SERIALNUMBER   "serialNumber"
 
#define SSDP_CUSTOM_FIELD_FRIENDLYNAME   "friendlyName"
 
#define ONELINE_ANSI_COLOR_GREEN   "\x1b[1;32m"
 
#define ONELINE_ANSI_COLOR_GREEN_SIZE   10
 
#define ONELINE_ANSI_COLOR_RESET   "\x1b[0m"
 
#define ONELINE_ANSI_COLOR_RESET_SIZE   7
 

Functions

unsigned int cache_to_json (ssdp_cache_s *ssdp_cache, char *json_buffer, unsigned int json_buffer_size)
 
unsigned int cache_to_xml (ssdp_cache_s *ssdp_cache, char *xml_buffer, unsigned int xml_buffer_size)
 
unsigned int to_json (const ssdp_message_s *ssdp_message, BOOL full_json, char *json_buffer, int json_buffer_size)
 
unsigned int to_xml (const ssdp_message_s *ssdp_message, BOOL full_xml, char *xml_buffer, int xml_buffer_size)
 
char * to_oneline (const ssdp_message_s *message, BOOL monochrome)
 

Detailed Description

Functions for converting the SSDP cache to different output formats.

Definition in file ssdp_cache_output_format.c.

Function Documentation

unsigned int cache_to_json ( ssdp_cache_s ssdp_cache,
char *  json_buffer,
unsigned int  json_buffer_size 
)

Convert a ssdp cache list (multiple ssdp_messages) to a single JSON blob

Parameters
ssdp_cacheThe SSDP messages to convert
json_messageThe buffer to write to
json_buffer_sizeThe buffer size
Returns
The number of byter written

Definition at line 22 of file ssdp_cache_output_format.c.

unsigned int cache_to_xml ( ssdp_cache_s ssdp_cache,
char *  xml_buffer,
unsigned int  xml_buffer_size 
)

Convert a ssdp cache list (multiple ssdp_messages) to a single XML blob

Parameters
ssdp_cacheThe SSDP messages to convert
xml_messageThe buffer to write to
xml_buffer_sizeThe buffer size
Returns
The number of byter written

Definition at line 43 of file ssdp_cache_output_format.c.

unsigned int to_json ( const ssdp_message_s ,
BOOL  full_json,
char *  json_buffer,
int  json_buffer_size 
)

Converts a UPnP message to a JSON string

Parameters
ssdp_messageThe message to be converted
full_jsonWhether to contain the JSON opening hash
json_bufferThe JSON buffer to write the JSON document to
json_sizeThe size of the passed buffer (json_buffer)

Definition at line 74 of file ssdp_cache_output_format.c.

char* to_oneline ( const ssdp_message_s message,
BOOL  monochrome 
)

Return an oneline string with the message ID, IP and (if present) the model.

Parameters
messageThe ssdp message to convert.
monochromeUse monochrome (no color) when generating onelines.
Returns
An oneline string with the message ID, IP and (if present) the model.

Definition at line 251 of file ssdp_cache_output_format.c.

unsigned int to_xml ( const ssdp_message_s ssdp_message,
BOOL  full_xml,
char *  xml_buffer,
int  xml_buffer_size 
)

Converts a UPnP message to a XML string

Parameters
ssdp_messageThe message to be converted
full_xmlWhether to contain the XML declaration and the root tag
xml_bufferThe XML buffer to write the XML document to
xml_buffer_sizeThe size of the passed buffer (xml_buffer)

Definition at line 83 of file ssdp_cache_output_format.c.