clibdocker
0.1.0-alpha.0
A Docker API for C
|
Docker API utils. More...
Go to the source code of this file.
Data Structures | |
struct | pair_t |
Typedefs | |
typedef struct pair_t | pair |
Functions | |
d_err_t | make_pair (pair **p, char *key, char *value) |
char * | get_value (pair *p) |
char * | get_key (pair *p) |
void | free_pair (pair *p) |
json_object * | make_filters () |
void | add_filter_str (json_object *filters, const char *name, const char *value) |
void | add_filter_int (json_object *filters, const char *name, int value) |
const char * | filters_to_str (json_object *filters) |
char * | str_clone (const char *from) |
char * | get_attr_str (json_object *obj, const char *name) |
d_err_t | set_attr_str (json_object *obj, const char *name, const char *val) |
int | get_attr_int (json_object *obj, const char *name) |
d_err_t | set_attr_int (json_object *obj, const char *name, int val) |
int | get_attr_boolean (json_object *obj, const char *name) |
d_err_t | set_attr_boolean (json_object *obj, const char *name, int val) |
long | get_attr_long (json_object *obj, const char *name) |
d_err_t | set_attr_long (json_object *obj, const char *name, long val) |
unsigned long | get_attr_unsigned_long (json_object *obj, const char *name) |
d_err_t | set_attr_unsigned_long (json_object *obj, const char *name, unsigned long val) |
long long | get_attr_long_long (json_object *obj, const char *name) |
d_err_t | set_attr_long_long (json_object *obj, const char *name, long long val) |
time_t | get_attr_time (json_object *obj, const char *name) |
d_err_t | set_attr_time (json_object *obj, const char *name, time_t val) |
json_object * | get_attr_json_object (json_object *obj, const char *name) |
d_err_t | set_attr_json_object (json_object *obj, const char *name, json_object *val) |
json_type | get_attr_type (json_object *obj, const char *name) |
const char * | get_json_string (json_object *obj) |
void | add_array_str (json_object *obj, const char *name, const char *value) |
void | add_array_int (json_object *obj, const char *name, int value) |
void | parse_iso_datetime (char *date_str, struct tm *tm) |
Parse the iso date time from given string. More... | |
void | parse_docker_stats_readtime (char *date_str, struct tm *tm) |
Parse the docker stats read time from the given string. More... | |
char * | calculate_size (uint64_t size) |
Docker API utils.
void add_array_int | ( | json_object * | obj, |
const char * | name, | ||
int | value | ||
) |
Add an int value to the array if it exits, or create a new one.
obj | the json object containing the array |
name | name of the array |
value | value of the array |
void add_array_str | ( | json_object * | obj, |
const char * | name, | ||
const char * | value | ||
) |
Add a string value to the array if it exits, or create a new one.
obj | the json object containing the array |
name | name of the array |
value | value of the array |
void add_filter_int | ( | json_object * | filters, |
const char * | name, | ||
int | value | ||
) |
Add an int value to the filter if it exits, or create a new one.
filters | the filters object created earlier using make_filters |
name | name of the filter |
value | value of the filter |
void add_filter_str | ( | json_object * | filters, |
const char * | name, | ||
const char * | value | ||
) |
Add a string value to the filter if it exits, or create a new one.
filters | the filters object created earlier using make_filters |
name | name of the filter |
value | value of the filter |
char* calculate_size | ( | uint64_t | size | ) |
Get the size in bytes, kb, mb, gb, tb etc. (higest possible unit)
size |
const char* filters_to_str | ( | json_object * | filters | ) |
Convert the filters object to a json string. Behaviour is undefined if filters is NULL.
filters |
void free_pair | ( | pair * | p | ) |
int get_attr_boolean | ( | json_object * | obj, |
const char * | name | ||
) |
Get a boolean object with the given key from a json_object
obj | the json object |
name | of the string attribute |
int get_attr_int | ( | json_object * | obj, |
const char * | name | ||
) |
Get a int object with the given key from a json_object
obj | the json object |
name | of the string attribute |
json_object* get_attr_json_object | ( | json_object * | obj, |
const char * | name | ||
) |
Get a long long object with the given key from a json_object
obj | the json object |
name | of the object attribute |
long get_attr_long | ( | json_object * | obj, |
const char * | name | ||
) |
Get a long object with the given key from a json_object
obj | the json object |
name | of the string attribute |
long long get_attr_long_long | ( | json_object * | obj, |
const char * | name | ||
) |
Get a long long object with the given key from a json_object
obj | the json object |
name | of the string attribute |
char* get_attr_str | ( | json_object * | obj, |
const char * | name | ||
) |
Get a string object with the given key from a json_object (will return NULL if the attribute is not found).
obj | the json object |
name | of the string attribute |
Referenced by get_attr_time().
time_t get_attr_time | ( | json_object * | obj, |
const char * | name | ||
) |
Get the time_t object with the given key from a json_object
obj | the json_object |
name | of the string attribute |
References get_attr_str(), and parse_iso_datetime().
json_type get_attr_type | ( | json_object * | obj, |
const char * | name | ||
) |
Get the json type of the attribute identified by "name" of the given json_object. See the json_type enum for possible values.
obj | the json object |
name | of the attribute |
unsigned long get_attr_unsigned_long | ( | json_object * | obj, |
const char * | name | ||
) |
Get a unsigned long object with the given key from a json_object
obj | the json object |
name | of the string attribute |
const char* get_json_string | ( | json_object * | obj | ) |
Get prettified json string. The returned string is owned by the json_object, and will be free when the json_object is freed. If caller needs to use the string beyond the lifetime of owning object, create a duplicate.
obj | the json object. |
char* get_key | ( | pair * | p | ) |
char* get_value | ( | pair * | p | ) |
json_object* make_filters | ( | ) |
Create new filter json_object for use in calls to the docker API, which uses filters in many endpoints.
Create a new pair with the given key and value. The key and value strings can be freed, as the constructor creates its own copy of the strings.
p | pair to create and return |
key | key of the pair |
value | value of the pair |
void parse_docker_stats_readtime | ( | char * | date_str, |
struct tm * | tm | ||
) |
Parse the docker stats read time from the given string.
date_str | input date string |
tm | output time object |
void parse_iso_datetime | ( | char * | date_str, |
struct tm * | tm | ||
) |
Parse the iso date time from given string.
date_str | input date string |
tm | output time object |
Referenced by get_attr_time().
d_err_t set_attr_boolean | ( | json_object * | obj, |
const char * | name, | ||
int | val | ||
) |
Set a boolean object with the given key in a json_object
obj | the json object |
name | of the string attribute |
val | string value of the attribute |
d_err_t set_attr_int | ( | json_object * | obj, |
const char * | name, | ||
int | val | ||
) |
Set an integer object with the given key in a json_object
obj | the json object |
name | of the string attribute |
val | string value of the attribute |
d_err_t set_attr_json_object | ( | json_object * | obj, |
const char * | name, | ||
json_object * | val | ||
) |
Set a json object with the given key in a json_object
obj | the json object |
name | of the string attribute |
val | string value of the attribute |
d_err_t set_attr_long | ( | json_object * | obj, |
const char * | name, | ||
long | val | ||
) |
Set a long integer object with the given key in a json_object
obj | the json object |
name | of the string attribute |
val | string value of the attribute |
d_err_t set_attr_long_long | ( | json_object * | obj, |
const char * | name, | ||
long long | val | ||
) |
Set a long long int object with the given key in a json_object
obj | the json object |
name | of the string attribute |
val | string value of the attribute |
d_err_t set_attr_str | ( | json_object * | obj, |
const char * | name, | ||
const char * | val | ||
) |
Set a string object with the given key in a json_object
obj | the json object |
name | of the string attribute |
val | string value of the attribute |
d_err_t set_attr_time | ( | json_object * | obj, |
const char * | name, | ||
time_t | val | ||
) |
Set a time object with the given key in a json_object
obj | the json object |
name | of the string attribute |
val | string value of the attribute |
d_err_t set_attr_unsigned_long | ( | json_object * | obj, |
const char * | name, | ||
unsigned long | val | ||
) |
Set an unsigned long integer object with the given key in a json_object
obj | the json object |
name | of the string attribute |
val | string value of the attribute |
char* str_clone | ( | const char * | from | ) |
Clone a string for usage in internal apis. User of api can then get rid of their copy. (obviously wasteful, use with caution)
from | string to clone from |
Referenced by docker_call_content_type_header_set(), docker_call_get_svc_url(), docker_call_get_url(), docker_call_params_add(), docker_call_request_data_set(), docker_call_request_method_set(), and list_dir_w_ignore().