My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
Classes | Macros | Functions | Variables
dfg_writer.c File Reference
#include <string.h>
#include <stdlib.h>
#include "runtime_communication.h"
#include "controller_stats.h"
#include "timeseries.h"
#include "dfg.h"
#include "controller_dfg.h"
#include "jsmn.h"
#include "logging.h"
#include <unistd.h>

Go to the source code of this file.

Classes

struct  json_output
 

Macros

#define JSON_LEN_INCREMENT   1024
 
#define CHECK_JSON_LEN(json, len)
 
#define START_JSON(json)   (json).length = 0
 
#define START_LIST(json)
 
#define END_LIST(json)
 
#define START_OBJ(json)
 
#define END_OBJ(json)
 
#define KEY_VAL(json, key, fmt, value, value_len)
 
#define KEY_INTVAL(json, key, value)   KEY_VAL(json, key, "%d", value, 128)
 
#define KEY_STRVAL(json, key, value)   KEY_VAL(json, key, "\"%s\"", value, strlen(value))
 
#define FMT_KEY_VAL(json, key_fmt, key, key_len, val_fmt, value, value_len)
 
#define KEY(json, key)
 
#define VALUE(json, fmt, value, value_len)
 
#define END_JSON(json)   (json).string[(json).length-1] = '\0'
 

Functions

static char * stat_to_json (struct timed_rrdb *timeseries, int n_stats)
 
static char * meta_routing_to_json (struct dfg_meta_routing *meta_routing)
 
static char * dependency_to_json (struct dfg_dependency *dep)
 
static char * msu_type_to_json (struct dfg_msu_type *type)
 
static char * scheduling_to_json (struct dfg_scheduling *sched)
 
static char * msu_stats_to_json (int msu_id, int n_stats)
 
static char * msu_to_json (struct dfg_msu *msu, int n_stats)
 
static char * endpoint_to_json (struct dfg_route_endpoint *ep)
 
static char * route_to_json (struct dfg_route *route)
 
static char * runtime_to_json (struct dfg_runtime *rt)
 
char * dfg_to_json (struct dedos_dfg *dfg, int n_stats)
 
void dfg_to_file (char *filename)
 
int dfg_to_fd (int fd)
 

Variables

static pthread_mutex_t json_lock
 
static int initialized = 0
 

Macro Definition Documentation

#define CHECK_JSON_LEN (   json,
  len 
)
Value:
while ( (int)((json).allocated_size - (json).length) < (len)) { \
log(LOG_DFG_WRITER, "Reallocating to %d", (int)(json.allocated_size + JSON_LEN_INCREMENT)); \
(json).string = realloc((json).string, (json).allocated_size + JSON_LEN_INCREMENT); \
(json).allocated_size += JSON_LEN_INCREMENT; \
}
#define log(level, fmt,...)
Log at a custom level.
Definition: logging.h:147
#define JSON_LEN_INCREMENT
Definition: dfg_writer.c:32

Definition at line 34 of file dfg_writer.c.

#define END_JSON (   json)    (json).string[(json).length-1] = '\0'

Definition at line 101 of file dfg_writer.c.

#define END_LIST (   json)
Value:
do { \
CHECK_JSON_LEN(json, 2); \
(json).length += sprintf((json).string + (json).length - 1, "],") - 1; \
} while (0)
#define CHECK_JSON_LEN(json, len)
Definition: dfg_writer.c:34

Definition at line 53 of file dfg_writer.c.

#define END_OBJ (   json)
Value:
do { \
CHECK_JSON_LEN(json, 2); \
(json).length += sprintf((json).string + (json).length - 1 , "},") - 1; \
} while (0)
#define CHECK_JSON_LEN(json, len)
Definition: dfg_writer.c:34

Definition at line 65 of file dfg_writer.c.

#define FMT_KEY_VAL (   json,
  key_fmt,
  key,
  key_len,
  val_fmt,
  value,
  value_len 
)
Value:
do { \
CHECK_JSON_LEN(json, key_len + value_len + 8); \
(json).length += sprintf((json).string + (json).length, "\"" key_fmt "\":\"" val_fmt "\",", key, value); \
} while (0)
#define CHECK_JSON_LEN(json, len)
Definition: dfg_writer.c:34

Definition at line 83 of file dfg_writer.c.

#define JSON_LEN_INCREMENT   1024

Definition at line 32 of file dfg_writer.c.

#define KEY (   json,
  key 
)
Value:
do { \
CHECK_JSON_LEN(json, strlen(key) + 4); \
(json).length += sprintf((json).string + (json).length, "\"" key "\":"); \
} while (0)
#define CHECK_JSON_LEN(json, len)
Definition: dfg_writer.c:34

Definition at line 89 of file dfg_writer.c.

#define KEY_INTVAL (   json,
  key,
  value 
)    KEY_VAL(json, key, "%d", value, 128)

Definition at line 77 of file dfg_writer.c.

#define KEY_STRVAL (   json,
  key,
  value 
)    KEY_VAL(json, key, "\"%s\"", value, strlen(value))

Definition at line 80 of file dfg_writer.c.

#define KEY_VAL (   json,
  key,
  fmt,
  value,
  value_len 
)
Value:
do { \
CHECK_JSON_LEN(json, value_len + strlen(key) + 8); \
(json).length += sprintf((json).string + (json).length, "\"" key "\":" fmt ",", value); \
} while (0)
#define CHECK_JSON_LEN(json, len)
Definition: dfg_writer.c:34

Definition at line 71 of file dfg_writer.c.

#define START_JSON (   json)    (json).length = 0

Definition at line 41 of file dfg_writer.c.

#define START_LIST (   json)
Value:
do { \
CHECK_JSON_LEN(json, 2); \
(json).length += sprintf((json).string + (json).length, "[ "); \
} while (0)
#define CHECK_JSON_LEN(json, len)
Definition: dfg_writer.c:34

Definition at line 44 of file dfg_writer.c.

#define START_OBJ (   json)
Value:
do { \
CHECK_JSON_LEN(json, 2); \
(json).length += sprintf((json).string + (json).length, "{ " ); \
} while (0)
#define CHECK_JSON_LEN(json, len)
Definition: dfg_writer.c:34

Definition at line 59 of file dfg_writer.c.

#define VALUE (   json,
  fmt,
  value,
  value_len 
)
Value:
do { \
CHECK_JSON_LEN(json, value_len + 4); \
(json).length += sprintf((json).string + (json).length, fmt ",", value); \
} while (0)
#define CHECK_JSON_LEN(json, len)
Definition: dfg_writer.c:34

Definition at line 95 of file dfg_writer.c.

Function Documentation

static char* dependency_to_json ( struct dfg_dependency dep)
static

Definition at line 163 of file dfg_writer.c.

int dfg_to_fd ( int  fd)

Definition at line 429 of file dfg_writer.c.

void dfg_to_file ( char *  filename)

Definition at line 413 of file dfg_writer.c.

char* dfg_to_json ( struct dedos_dfg dfg,
int  n_stats 
)

Definition at line 362 of file dfg_writer.c.

static char* endpoint_to_json ( struct dfg_route_endpoint ep)
static

Definition at line 290 of file dfg_writer.c.

static char* meta_routing_to_json ( struct dfg_meta_routing meta_routing)
static

Definition at line 138 of file dfg_writer.c.

static char* msu_stats_to_json ( int  msu_id,
int  n_stats 
)
static

Definition at line 227 of file dfg_writer.c.

static char* msu_to_json ( struct dfg_msu msu,
int  n_stats 
)
static

Definition at line 254 of file dfg_writer.c.

static char* msu_type_to_json ( struct dfg_msu_type type)
static

Definition at line 176 of file dfg_writer.c.

static char* route_to_json ( struct dfg_route route)
static

Definition at line 303 of file dfg_writer.c.

static char* runtime_to_json ( struct dfg_runtime rt)
static

Definition at line 326 of file dfg_writer.c.

static char* scheduling_to_json ( struct dfg_scheduling sched)
static

Definition at line 205 of file dfg_writer.c.

static char* stat_to_json ( struct timed_rrdb timeseries,
int  n_stats 
)
static

Definition at line 112 of file dfg_writer.c.

Variable Documentation

int initialized = 0
static

Definition at line 360 of file dfg_writer.c.

pthread_mutex_t json_lock
static

Definition at line 359 of file dfg_writer.c.