Linux Perf
json.c File Reference
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include "jsmn.h"
#include "json.h"
#include <linux/kernel.h>
Include dependency graph for json.c:

Go to the source code of this file.

Macros

#define LOOKUP(a, i)   ((i) < (sizeof(a)/sizeof(*(a))) ? ((a)[i]) : "?")
 

Functions

static char * mapfile (const char *fn, size_t *size)
 
static void unmapfile (char *map, size_t size)
 
jsmntok_tparse_json (const char *fn, char **map, size_t *size, int *len)
 
void free_json (char *map, size_t size, jsmntok_t *tokens)
 
static int countchar (char *map, char c, int end)
 
int json_line (char *map, jsmntok_t *t)
 
const char * json_name (jsmntok_t *t)
 
int json_len (jsmntok_t *t)
 
int json_streq (char *map, jsmntok_t *t, const char *s)
 

Variables

static const char *const jsmn_types []
 

Macro Definition Documentation

◆ LOOKUP

#define LOOKUP (   a,
 
)    ((i) < (sizeof(a)/sizeof(*(a))) ? ((a)[i]) : "?")

Definition at line 144 of file json.c.

Function Documentation

◆ countchar()

static int countchar ( char *  map,
char  c,
int  end 
)
static

Definition at line 121 of file json.c.

◆ free_json()

void free_json ( char *  map,
size_t  size,
jsmntok_t tokens 
)

Definition at line 115 of file json.c.

Here is the call graph for this function:

◆ json_len()

int json_len ( jsmntok_t t)

Definition at line 152 of file json.c.

◆ json_line()

int json_line ( char *  map,
jsmntok_t t 
)

Definition at line 132 of file json.c.

Here is the call graph for this function:

◆ json_name()

const char* json_name ( jsmntok_t t)

Definition at line 147 of file json.c.

◆ json_streq()

int json_streq ( char *  map,
jsmntok_t t,
const char *  s 
)

Definition at line 158 of file json.c.

Here is the call graph for this function:

◆ mapfile()

static char* mapfile ( const char *  fn,
size_t *  size 
)
static

Definition at line 44 of file json.c.

Here is the call graph for this function:

◆ parse_json()

jsmntok_t* parse_json ( const char *  fn,
char **  map,
size_t *  size,
int *  len 
)

Definition at line 83 of file json.c.

Here is the call graph for this function:

◆ unmapfile()

static void unmapfile ( char *  map,
size_t  size 
)
static

Definition at line 73 of file json.c.

Variable Documentation

◆ jsmn_types

const char* const jsmn_types[]
static
Initial value:
= {
[JSMN_PRIMITIVE] = "primitive",
[JSMN_ARRAY] = "array",
[JSMN_OBJECT] = "object",
[JSMN_STRING] = "string"
}

Definition at line 137 of file json.c.