#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>
#include "cJSON.h"
#include "JSON_checker.h"
#include "Integra/integra_model.h"
#include "debug.h"
Data Structures | |
struct | _t_memory_chunk |
Defines | |
#define | LOGIN_HANDLER "login_handler" |
Typedefs | |
typedef struct _t_memory_chunk | t_memory_chunk |
Functions | |
int | get_valuestr (char *valuestr) |
void | licenses_get_json (t_memory_chunk *chunk, struct curl_slist *headers, const char *document_url) |
void | default_values_get_json (t_memory_chunk *chunk, struct curl_slist *headers, const char *document_url) |
void | attributes_get_json (t_memory_chunk *chunk, struct curl_slist *headers, const char *document_url) |
void | module_attributes_get_json (t_memory_chunk *chunk, struct curl_slist *headers, const char *document_url) |
void | softwares_get_json (t_memory_chunk *chunk, struct curl_slist *headers, const char *document_url) |
void | definitions_get_json (t_memory_chunk *chunk, struct curl_slist *headers, const char *document_url) |
void | legal_values_get_json (t_memory_chunk *chunk, struct curl_slist *headers, const char *document_url) |
void | attribute_units_get_json (t_memory_chunk *chunk, struct curl_slist *headers, const char *document_url) |
void | control_attributes_get_json (t_memory_chunk *chunk, struct curl_slist *headers, const char *document_url) |
void | attribute_scales_get_json (t_memory_chunk *chunk, struct curl_slist *headers, const char *document_url) |
void | implementation_dependencys_get_json (t_memory_chunk *chunk, struct curl_slist *headers, const char *document_url) |
void | attribute_types_get_json (t_memory_chunk *chunk, struct curl_slist *headers, const char *document_url) |
void | tags_get_json (t_memory_chunk *chunk, struct curl_slist *headers, const char *document_url) |
void | value_labels_get_json (t_memory_chunk *chunk, struct curl_slist *headers, const char *document_url) |
void | attribute_scopes_get_json (t_memory_chunk *chunk, struct curl_slist *headers, const char *document_url) |
void | databases_get_json (t_memory_chunk *chunk, struct curl_slist *headers, const char *document_url) |
void | targets_get_json (t_memory_chunk *chunk, struct curl_slist *headers, const char *document_url) |
void | control_classs_get_json (t_memory_chunk *chunk, struct curl_slist *headers, const char *document_url) |
void | definition_tags_get_json (t_memory_chunk *chunk, struct curl_slist *headers, const char *document_url) |
void | uris_get_json (t_memory_chunk *chunk, struct curl_slist *headers, const char *document_url) |
void | implementations_get_json (t_memory_chunk *chunk, struct curl_slist *headers, const char *document_url) |
int | get_id_max (cJSON *items, int n_items) |
void | free_chunk_memory (t_memory_chunk *chunk) |
void | authenticate (char *login_url) |
void | validate_json (const char *test_string, size_t len) |
void | licenses_populate (cJSON *json, ntg_license ***licenses, int *n_items, int *n_allocated) |
void | default_values_populate (cJSON *json, ntg_default_value ***default_values, int *n_items, int *n_allocated) |
void | attributes_populate (cJSON *json, ntg_attribute ***attributes, int *n_items, int *n_allocated) |
void | module_attributes_populate (cJSON *json, ntg_module_attribute ***module_attributes, int *n_items, int *n_allocated) |
void | softwares_populate (cJSON *json, ntg_software ***softwares, int *n_items, int *n_allocated) |
void | definitions_populate (cJSON *json, ntg_definition ***definitions, int *n_items, int *n_allocated) |
void | legal_values_populate (cJSON *json, ntg_legal_value ***legal_values, int *n_items, int *n_allocated) |
void | attribute_units_populate (cJSON *json, ntg_attribute_unit ***attribute_units, int *n_items, int *n_allocated) |
void | control_attributes_populate (cJSON *json, ntg_control_attribute ***control_attributes, int *n_items, int *n_allocated) |
void | attribute_scales_populate (cJSON *json, ntg_attribute_scale ***attribute_scales, int *n_items, int *n_allocated) |
void | implementation_dependencys_populate (cJSON *json, ntg_implementation_dependency ***implementation_dependencys, int *n_items, int *n_allocated) |
void | attribute_types_populate (cJSON *json, ntg_attribute_type ***attribute_types, int *n_items, int *n_allocated) |
void | tags_populate (cJSON *json, ntg_tag ***tags, int *n_items, int *n_allocated) |
void | value_labels_populate (cJSON *json, ntg_value_label ***value_labels, int *n_items, int *n_allocated) |
void | attribute_scopes_populate (cJSON *json, ntg_attribute_scope ***attribute_scopes, int *n_items, int *n_allocated) |
void | databases_populate (cJSON *json, ntg_database ***databases, int *n_items, int *n_allocated) |
void | targets_populate (cJSON *json, ntg_target ***targets, int *n_items, int *n_allocated) |
void | control_classs_populate (cJSON *json, ntg_control_class ***control_classs, int *n_items, int *n_allocated) |
void | definition_tags_populate (cJSON *json, ntg_definition_tag ***definition_tags, int *n_items, int *n_allocated) |
void | uris_populate (cJSON *json, ntg_uri ***uris, int *n_items, int *n_allocated) |
void | implementations_populate (cJSON *json, ntg_implementation ***implementations, int *n_items, int *n_allocated) |
int | ntg_populate (char *base_url, ntg_model *model) |
#define LOGIN_HANDLER "login_handler" |
Referenced by ntg_populate().
typedef struct _t_memory_chunk t_memory_chunk |
void attribute_scales_get_json | ( | t_memory_chunk * | chunk, | |
struct curl_slist * | headers, | |||
const char * | document_url | |||
) |
References DB_MODEL, and DEBUG_POST().
Referenced by ntg_populate().
void attribute_scales_populate | ( | cJSON * | json, | |
ntg_attribute_scale *** | attribute_scales, | |||
int * | n_items, | |||
int * | n_allocated | |||
) |
void attribute_scopes_get_json | ( | t_memory_chunk * | chunk, | |
struct curl_slist * | headers, | |||
const char * | document_url | |||
) |
References DB_MODEL, and DEBUG_POST().
Referenced by ntg_populate().
void attribute_scopes_populate | ( | cJSON * | json, | |
ntg_attribute_scope *** | attribute_scopes, | |||
int * | n_items, | |||
int * | n_allocated | |||
) |
void attribute_types_get_json | ( | t_memory_chunk * | chunk, | |
struct curl_slist * | headers, | |||
const char * | document_url | |||
) |
References DB_MODEL, and DEBUG_POST().
Referenced by ntg_populate().
void attribute_types_populate | ( | cJSON * | json, | |
ntg_attribute_type *** | attribute_types, | |||
int * | n_items, | |||
int * | n_allocated | |||
) |
void attribute_units_get_json | ( | t_memory_chunk * | chunk, | |
struct curl_slist * | headers, | |||
const char * | document_url | |||
) |
References DB_MODEL, and DEBUG_POST().
Referenced by ntg_populate().
void attribute_units_populate | ( | cJSON * | json, | |
ntg_attribute_unit *** | attribute_units, | |||
int * | n_items, | |||
int * | n_allocated | |||
) |
void attributes_get_json | ( | t_memory_chunk * | chunk, | |
struct curl_slist * | headers, | |||
const char * | document_url | |||
) |
References DB_MODEL, and DEBUG_POST().
Referenced by ntg_populate().
void attributes_populate | ( | cJSON * | json, | |
ntg_attribute *** | attributes, | |||
int * | n_items, | |||
int * | n_allocated | |||
) |
References cJSON_GetArrayItem(), cJSON_GetArraySize(), cJSON_GetObjectItem(), DB_MODEL, DEBUG_POST(), _ntg_attribute::description, get_id_max(), get_valuestr(), _ntg_attribute::id, _ntg_attribute::id_definition, _ntg_attribute::id_module_attribute, _ntg_attribute::id_scope, _ntg_attribute::id_type, _ntg_attribute::name, cJSON::valueint, and cJSON::valuestring.
Referenced by ntg_populate().
void authenticate | ( | char * | login_url | ) |
Referenced by ntg_populate().
void control_attributes_get_json | ( | t_memory_chunk * | chunk, | |
struct curl_slist * | headers, | |||
const char * | document_url | |||
) |
References DB_MODEL, and DEBUG_POST().
Referenced by ntg_populate().
void control_attributes_populate | ( | cJSON * | json, | |
ntg_control_attribute *** | control_attributes, | |||
int * | n_items, | |||
int * | n_allocated | |||
) |
References cJSON_GetArrayItem(), cJSON_GetArraySize(), cJSON_GetObjectItem(), DB_MODEL, DEBUG_POST(), get_id_max(), get_valuestr(), _ntg_control_attribute::id, _ntg_control_attribute::id_control_class, _ntg_control_attribute::name, cJSON::valueint, and cJSON::valuestring.
Referenced by ntg_populate().
void control_classs_get_json | ( | t_memory_chunk * | chunk, | |
struct curl_slist * | headers, | |||
const char * | document_url | |||
) |
References DB_MODEL, and DEBUG_POST().
Referenced by ntg_populate().
void control_classs_populate | ( | cJSON * | json, | |
ntg_control_class *** | control_classs, | |||
int * | n_items, | |||
int * | n_allocated | |||
) |
void databases_get_json | ( | t_memory_chunk * | chunk, | |
struct curl_slist * | headers, | |||
const char * | document_url | |||
) |
References DB_MODEL, and DEBUG_POST().
Referenced by ntg_populate().
void databases_populate | ( | cJSON * | json, | |
ntg_database *** | databases, | |||
int * | n_items, | |||
int * | n_allocated | |||
) |
References cJSON_GetArrayItem(), cJSON_GetArraySize(), cJSON_GetObjectItem(), DB_MODEL, DEBUG_POST(), get_id_max(), get_valuestr(), _ntg_database::maintainer_email, _ntg_database::maintainer_name, _ntg_database::schema_version_major, _ntg_database::schema_version_minor, cJSON::valueint, and cJSON::valuestring.
Referenced by ntg_populate().
void default_values_get_json | ( | t_memory_chunk * | chunk, | |
struct curl_slist * | headers, | |||
const char * | document_url | |||
) |
References DB_MODEL, and DEBUG_POST().
Referenced by ntg_populate().
void default_values_populate | ( | cJSON * | json, | |
ntg_default_value *** | default_values, | |||
int * | n_items, | |||
int * | n_allocated | |||
) |
References _ntg_default_value::blob_, cJSON_GetArrayItem(), cJSON_GetArraySize(), cJSON_GetObjectItem(), DB_MODEL, DEBUG_POST(), _ntg_default_value::float_, get_id_max(), get_valuestr(), _ntg_default_value::id, _ntg_default_value::integer_, _ntg_default_value::string_, cJSON::valueint, and cJSON::valuestring.
Referenced by ntg_populate().
void definition_tags_get_json | ( | t_memory_chunk * | chunk, | |
struct curl_slist * | headers, | |||
const char * | document_url | |||
) |
References DB_MODEL, and DEBUG_POST().
Referenced by ntg_populate().
void definition_tags_populate | ( | cJSON * | json, | |
ntg_definition_tag *** | definition_tags, | |||
int * | n_items, | |||
int * | n_allocated | |||
) |
void definitions_get_json | ( | t_memory_chunk * | chunk, | |
struct curl_slist * | headers, | |||
const char * | document_url | |||
) |
References DB_MODEL, and DEBUG_POST().
Referenced by ntg_populate().
void definitions_populate | ( | cJSON * | json, | |
ntg_definition *** | definitions, | |||
int * | n_items, | |||
int * | n_allocated | |||
) |
References _ntg_definition::absolute_version, cJSON_GetArrayItem(), cJSON_GetArraySize(), cJSON_GetObjectItem(), _ntg_definition::core, DB_MODEL, DEBUG_POST(), _ntg_definition::description, get_id_max(), get_valuestr(), _ntg_definition::id, _ntg_definition::id_documentation, _ntg_definition::id_parent, _ntg_definition::id_updated_by, _ntg_definition::instantiable, _ntg_definition::label, _ntg_definition::name, _ntg_definition::schema_version_major, _ntg_definition::schema_version_minor, _ntg_definition::system, cJSON::valueint, and cJSON::valuestring.
Referenced by ntg_populate().
void free_chunk_memory | ( | t_memory_chunk * | chunk | ) |
References _t_memory_chunk::memory, and _t_memory_chunk::size.
Referenced by ntg_populate().
int get_id_max | ( | cJSON * | items, | |
int | n_items | |||
) |
References cJSON_GetArrayItem(), and cJSON_GetObjectItem().
Referenced by attribute_scales_populate(), attribute_scopes_populate(), attribute_types_populate(), attribute_units_populate(), attributes_populate(), control_attributes_populate(), control_classs_populate(), databases_populate(), default_values_populate(), definition_tags_populate(), definitions_populate(), implementation_dependencys_populate(), implementations_populate(), legal_values_populate(), licenses_populate(), module_attributes_populate(), softwares_populate(), tags_populate(), targets_populate(), uris_populate(), and value_labels_populate().
int get_valuestr | ( | char * | valuestr | ) |
Referenced by attribute_scales_populate(), attribute_scopes_populate(), attribute_types_populate(), attribute_units_populate(), attributes_populate(), control_attributes_populate(), control_classs_populate(), databases_populate(), default_values_populate(), definition_tags_populate(), definitions_populate(), implementation_dependencys_populate(), implementations_populate(), legal_values_populate(), licenses_populate(), module_attributes_populate(), softwares_populate(), tags_populate(), targets_populate(), uris_populate(), and value_labels_populate().
void implementation_dependencys_get_json | ( | t_memory_chunk * | chunk, | |
struct curl_slist * | headers, | |||
const char * | document_url | |||
) |
References DB_MODEL, and DEBUG_POST().
Referenced by ntg_populate().
void implementation_dependencys_populate | ( | cJSON * | json, | |
ntg_implementation_dependency *** | implementation_dependencys, | |||
int * | n_items, | |||
int * | n_allocated | |||
) |
References cJSON_GetArrayItem(), cJSON_GetArraySize(), cJSON_GetObjectItem(), DB_MODEL, DEBUG_POST(), _ntg_implementation_dependency::description, get_id_max(), get_valuestr(), _ntg_implementation_dependency::id, _ntg_implementation_dependency::id_dependency, _ntg_implementation_dependency::id_implementation, cJSON::valueint, and cJSON::valuestring.
Referenced by ntg_populate().
void implementations_get_json | ( | t_memory_chunk * | chunk, | |
struct curl_slist * | headers, | |||
const char * | document_url | |||
) |
References DB_MODEL, and DEBUG_POST().
Referenced by ntg_populate().
void implementations_populate | ( | cJSON * | json, | |
ntg_implementation *** | implementations, | |||
int * | n_items, | |||
int * | n_allocated | |||
) |
References _ntg_implementation::build_script, cJSON_GetArrayItem(), cJSON_GetArraySize(), cJSON_GetObjectItem(), DB_MODEL, DEBUG_POST(), _ntg_implementation::description, _ntg_implementation::generated_file_name, get_id_max(), get_valuestr(), _ntg_implementation::id, _ntg_implementation::id_definition, _ntg_implementation::id_license, _ntg_implementation::id_target, _ntg_implementation::source_code, cJSON::valueint, and cJSON::valuestring.
Referenced by ntg_populate().
void legal_values_get_json | ( | t_memory_chunk * | chunk, | |
struct curl_slist * | headers, | |||
const char * | document_url | |||
) |
References DB_MODEL, and DEBUG_POST().
Referenced by ntg_populate().
void legal_values_populate | ( | cJSON * | json, | |
ntg_legal_value *** | legal_values, | |||
int * | n_items, | |||
int * | n_allocated | |||
) |
References _ntg_legal_value::blob_, cJSON_GetArrayItem(), cJSON_GetArraySize(), cJSON_GetObjectItem(), DB_MODEL, DEBUG_POST(), _ntg_legal_value::float_, get_id_max(), get_valuestr(), _ntg_legal_value::id, _ntg_legal_value::id_module_attribute, _ntg_legal_value::integer_, _ntg_legal_value::string_, cJSON::valueint, and cJSON::valuestring.
Referenced by ntg_populate().
void licenses_get_json | ( | t_memory_chunk * | chunk, | |
struct curl_slist * | headers, | |||
const char * | document_url | |||
) |
References DB_MODEL, and DEBUG_POST().
Referenced by ntg_populate().
void licenses_populate | ( | cJSON * | json, | |
ntg_license *** | licenses, | |||
int * | n_items, | |||
int * | n_allocated | |||
) |
References cJSON_GetArrayItem(), cJSON_GetArraySize(), cJSON_GetObjectItem(), DB_MODEL, DEBUG_POST(), get_id_max(), get_valuestr(), _ntg_license::id, _ntg_license::name, _ntg_license::text, cJSON::valueint, and cJSON::valuestring.
Referenced by ntg_populate().
void module_attributes_get_json | ( | t_memory_chunk * | chunk, | |
struct curl_slist * | headers, | |||
const char * | document_url | |||
) |
References DB_MODEL, and DEBUG_POST().
Referenced by ntg_populate().
void module_attributes_populate | ( | cJSON * | json, | |
ntg_module_attribute *** | module_attributes, | |||
int * | n_items, | |||
int * | n_allocated | |||
) |
References cJSON_GetArrayItem(), cJSON_GetArraySize(), cJSON_GetObjectItem(), _ntg_module_attribute::control_group, DB_MODEL, DEBUG_POST(), get_id_max(), get_valuestr(), _ntg_module_attribute::id, _ntg_module_attribute::id_control_attribute, _ntg_module_attribute::id_default_value, _ntg_module_attribute::id_scale, _ntg_module_attribute::id_unit, _ntg_module_attribute::maximum, _ntg_module_attribute::minimum, _ntg_module_attribute::undoable, cJSON::valueint, and cJSON::valuestring.
Referenced by ntg_populate().
int ntg_populate | ( | char * | base_url, | |
ntg_model * | model | |||
) |
References _ntg_model::allocated_attribute_scales, _ntg_model::allocated_attribute_scopes, _ntg_model::allocated_attribute_types, _ntg_model::allocated_attribute_units, _ntg_model::allocated_attributes, _ntg_model::allocated_control_attributes, _ntg_model::allocated_control_classs, _ntg_model::allocated_databases, _ntg_model::allocated_default_values, _ntg_model::allocated_definition_tags, _ntg_model::allocated_definitions, _ntg_model::allocated_implementation_dependencys, _ntg_model::allocated_implementations, _ntg_model::allocated_legal_values, _ntg_model::allocated_licenses, _ntg_model::allocated_module_attributes, _ntg_model::allocated_softwares, _ntg_model::allocated_tags, _ntg_model::allocated_targets, _ntg_model::allocated_uris, _ntg_model::allocated_value_labels, _ntg_model::attribute_scales, attribute_scales_get_json(), attribute_scales_populate(), _ntg_model::attribute_scopes, attribute_scopes_get_json(), attribute_scopes_populate(), _ntg_model::attribute_types, attribute_types_get_json(), attribute_types_populate(), _ntg_model::attribute_units, attribute_units_get_json(), attribute_units_populate(), _ntg_model::attributes, attributes_get_json(), attributes_populate(), authenticate(), cJSON_Delete(), cJSON_Parse(), _ntg_model::control_attributes, control_attributes_get_json(), control_attributes_populate(), _ntg_model::control_classs, control_classs_get_json(), control_classs_populate(), _ntg_model::databases, databases_get_json(), databases_populate(), _ntg_model::default_values, default_values_get_json(), default_values_populate(), _ntg_model::definition_tags, definition_tags_get_json(), definition_tags_populate(), _ntg_model::definitions, definitions_get_json(), definitions_populate(), free_chunk_memory(), _ntg_model::implementation_dependencys, implementation_dependencys_get_json(), implementation_dependencys_populate(), _ntg_model::implementations, implementations_get_json(), implementations_populate(), _ntg_model::legal_values, legal_values_get_json(), legal_values_populate(), _ntg_model::licenses, licenses_get_json(), licenses_populate(), LOGIN_HANDLER, _t_memory_chunk::memory, _ntg_model::module_attributes, module_attributes_get_json(), module_attributes_populate(), _ntg_model::n_attribute_scales, _ntg_model::n_attribute_scopes, _ntg_model::n_attribute_types, _ntg_model::n_attribute_units, _ntg_model::n_attributes, _ntg_model::n_control_attributes, _ntg_model::n_control_classs, _ntg_model::n_databases, _ntg_model::n_default_values, _ntg_model::n_definition_tags, _ntg_model::n_definitions, _ntg_model::n_implementation_dependencys, _ntg_model::n_implementations, _ntg_model::n_legal_values, _ntg_model::n_licenses, _ntg_model::n_module_attributes, _ntg_model::n_softwares, _ntg_model::n_tags, _ntg_model::n_targets, _ntg_model::n_uris, _ntg_model::n_value_labels, _t_memory_chunk::size, _ntg_model::softwares, softwares_get_json(), softwares_populate(), _ntg_model::tags, tags_get_json(), tags_populate(), _ntg_model::targets, targets_get_json(), targets_populate(), _ntg_model::uris, uris_get_json(), uris_populate(), validate_json(), _ntg_model::value_labels, value_labels_get_json(), and value_labels_populate().
Referenced by ntg_server_new().
void softwares_get_json | ( | t_memory_chunk * | chunk, | |
struct curl_slist * | headers, | |||
const char * | document_url | |||
) |
References DB_MODEL, and DEBUG_POST().
Referenced by ntg_populate().
void softwares_populate | ( | cJSON * | json, | |
ntg_software *** | softwares, | |||
int * | n_items, | |||
int * | n_allocated | |||
) |
References cJSON_GetArrayItem(), cJSON_GetArraySize(), cJSON_GetObjectItem(), DB_MODEL, DEBUG_POST(), _ntg_software::description, get_id_max(), get_valuestr(), _ntg_software::id, _ntg_software::name, cJSON::valueint, and cJSON::valuestring.
Referenced by ntg_populate().
void tags_get_json | ( | t_memory_chunk * | chunk, | |
struct curl_slist * | headers, | |||
const char * | document_url | |||
) |
References DB_MODEL, and DEBUG_POST().
Referenced by ntg_populate().
References cJSON_GetArrayItem(), cJSON_GetArraySize(), cJSON_GetObjectItem(), DB_MODEL, DEBUG_POST(), get_id_max(), get_valuestr(), _ntg_tag::id, _ntg_tag::name, cJSON::valueint, and cJSON::valuestring.
Referenced by ntg_populate().
void targets_get_json | ( | t_memory_chunk * | chunk, | |
struct curl_slist * | headers, | |||
const char * | document_url | |||
) |
References DB_MODEL, and DEBUG_POST().
Referenced by ntg_populate().
void targets_populate | ( | cJSON * | json, | |
ntg_target *** | targets, | |||
int * | n_items, | |||
int * | n_allocated | |||
) |
References cJSON_GetArrayItem(), cJSON_GetArraySize(), cJSON_GetObjectItem(), DB_MODEL, DEBUG_POST(), get_id_max(), get_valuestr(), _ntg_target::id, _ntg_target::id_software, cJSON::valueint, cJSON::valuestring, and _ntg_target::version.
Referenced by ntg_populate().
void uris_get_json | ( | t_memory_chunk * | chunk, | |
struct curl_slist * | headers, | |||
const char * | document_url | |||
) |
References DB_MODEL, and DEBUG_POST().
Referenced by ntg_populate().
void validate_json | ( | const char * | test_string, | |
size_t | len | |||
) |
References DB_MODEL, DEBUG_POST(), JSON_checker_char(), JSON_checker_done(), and new_JSON_checker().
Referenced by ntg_populate().
void value_labels_get_json | ( | t_memory_chunk * | chunk, | |
struct curl_slist * | headers, | |||
const char * | document_url | |||
) |
References DB_MODEL, and DEBUG_POST().
Referenced by ntg_populate().
void value_labels_populate | ( | cJSON * | json, | |
ntg_value_label *** | value_labels, | |||
int * | n_items, | |||
int * | n_allocated | |||
) |