![]() |
GNUnet
0.11.x
|
#include "platform.h"
#include "gnunet_rest_plugin.h"
#include <gnunet_rest_lib.h>
#include <gnunet_util_lib.h>
#include <jansson.h>
Go to the source code of this file.
Data Structures | |
struct | Plugin |
Handle for a plugin. More... | |
struct | RequestHandle |
The request handle. More... | |
Macros | |
#define | GNUNET_REST_API_NS_CONFIG "/config" |
Functions | |
static void | cleanup_handle (struct RequestHandle *handle) |
Cleanup request handle. More... | |
static void | do_error (void *cls) |
Task run on shutdown. More... | |
static void | add_sections (void *cls, const char *section, const char *option, const char *value) |
static void | add_section_contents (void *cls, const char *section, const char *option, const char *value) |
static void | get_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls) |
Handle rest request. More... | |
struct GNUNET_CONFIGURATION_Handle * | set_value (struct GNUNET_CONFIGURATION_Handle *config, const char *section, const char *option, json_t *value) |
static void | set_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls) |
Handle REST POST request. More... | |
static void | options_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls) |
Handle rest request. More... | |
static enum GNUNET_GenericReturnValue | rest_config_process_request (struct GNUNET_REST_RequestHandle *conndata_handle, GNUNET_REST_ResultProcessor proc, void *proc_cls) |
Function processing the REST call. More... | |
void * | libgnunet_plugin_rest_config_init (void *cls) |
Entry point for the plugin. More... | |
void * | libgnunet_plugin_rest_config_done (void *cls) |
Exit point from the plugin. More... | |
Variables | |
const struct GNUNET_CONFIGURATION_Handle * | cfg |
Handle to our configuration. More... | |
static struct RequestHandle * | requests_head |
DLL. More... | |
static struct RequestHandle * | requests_tail |
DLL. More... | |
#define GNUNET_REST_API_NS_CONFIG "/config" |
Definition at line 33 of file plugin_rest_config.c.
Referenced by get_cont(), libgnunet_plugin_rest_config_init(), rest_config_process_request(), and set_cont().
|
static |
Cleanup request handle.
handle | Handle to clean up |
Definition at line 101 of file plugin_rest_config.c.
References GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, and RequestHandle::url.
Referenced by do_error(), get_cont(), libgnunet_plugin_rest_config_done(), options_cont(), rest_config_process_request(), and set_cont().
|
static |
Task run on shutdown.
Cleans up everything.
cls | unused |
tc | scheduler context |
Definition at line 120 of file plugin_rest_config.c.
References cleanup_handle(), GNUNET_REST_create_response(), handle, RequestHandle::proc, RequestHandle::proc_cls, and RequestHandle::response_code.
Referenced by get_cont(), and set_cont().
|
static |
Definition at line 132 of file plugin_rest_config.c.
Referenced by get_cont().
|
static |
Definition at line 153 of file plugin_rest_config.c.
Referenced by get_cont().
|
static |
Handle rest request.
handle | the lookup handle |
Definition at line 170 of file plugin_rest_config.c.
References add_section_contents(), add_sections(), cleanup_handle(), do_error(), GNUNET_CONFIGURATION_iterate(), GNUNET_CONFIGURATION_iterate_section_values(), GNUNET_free, GNUNET_REST_API_NS_CONFIG, GNUNET_REST_create_response(), GNUNET_SCHEDULER_add_now(), handle, RequestHandle::proc, RequestHandle::proc_cls, response, RequestHandle::response_code, result, section, and RequestHandle::url.
Referenced by rest_config_process_request().
struct GNUNET_CONFIGURATION_Handle* set_value | ( | struct GNUNET_CONFIGURATION_Handle * | config, |
const char * | section, | ||
const char * | option, | ||
json_t * | value | ||
) |
Definition at line 211 of file plugin_rest_config.c.
References config, GNUNET_CONFIGURATION_set_value_number(), and GNUNET_CONFIGURATION_set_value_string().
Referenced by set_cont().
|
static |
Handle REST POST request.
handle | the lookup handle |
Definition at line 240 of file plugin_rest_config.c.
References cleanup_handle(), config_file, GNUNET_REST_RequestHandle::data, GNUNET_REST_RequestHandle::data_size, DIR_SEPARATOR_STR, do_error(), getenv(), GNUNET_asprintf(), GNUNET_CONFIGURATION_dup(), GNUNET_CONFIGURATION_write(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_memcpy, GNUNET_OS_project_data_get(), GNUNET_REST_API_NS_CONFIG, GNUNET_REST_create_response(), GNUNET_SCHEDULER_add_now(), GNUNET_strdup, handle, option, RequestHandle::proc, RequestHandle::proc_cls, RequestHandle::response_code, RequestHandle::rest_handle, section, set_value(), RequestHandle::url, and value.
Referenced by rest_config_process_request().
|
static |
Handle rest request.
handle | the lookup handle |
Definition at line 347 of file plugin_rest_config.c.
References cleanup_handle(), GNUNET_REST_create_response(), handle, RequestHandle::proc, and RequestHandle::proc_cls.
Referenced by rest_config_process_request().
|
static |
Function processing the REST call.
method | HTTP method |
url | URL of the HTTP request |
data | body of the HTTP request (optional) |
data_size | length of the body |
proc | callback function for the result |
proc_cls | closure for proc |
Definition at line 375 of file plugin_rest_config.c.
References cleanup_handle(), get_cont(), GNUNET_CONTAINER_DLL_insert, GNUNET_new, GNUNET_NO, GNUNET_REST_API_NS_CONFIG, GNUNET_REST_handle_request(), GNUNET_REST_HANDLER_END, GNUNET_strdup, GNUNET_YES, handle, options_cont(), RequestHandle::proc, RequestHandle::proc_cls, RequestHandle::rest_handle, set_cont(), GNUNET_REST_RequestHandle::url, and RequestHandle::url.
Referenced by libgnunet_plugin_rest_config_init().
void* libgnunet_plugin_rest_config_init | ( | void * | cls | ) |
Entry point for the plugin.
cls | the "struct GNUNET_NAMESTORE_PluginEnvironment*" |
Definition at line 414 of file plugin_rest_config.c.
References _, Plugin::api, Plugin::cfg, GNUNET_REST_Plugin::cls, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_new, GNUNET_REST_API_NS_CONFIG, GNUNET_REST_Plugin::name, plugin, GNUNET_REST_Plugin::process_request, and rest_config_process_request().
void* libgnunet_plugin_rest_config_done | ( | void * | cls | ) |
Exit point from the plugin.
cls | the plugin context (as returned by "init") |
Definition at line 439 of file plugin_rest_config.c.
References Plugin::api, Plugin::cfg, cleanup_handle(), GNUNET_REST_Plugin::cls, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, and plugin.
const struct GNUNET_CONFIGURATION_Handle* cfg |
Handle to our configuration.
Handle to our configuration.
Definition at line 43 of file plugin_rest_config.c.
|
static |
DLL.
Definition at line 86 of file plugin_rest_config.c.
|
static |
DLL.
Definition at line 91 of file plugin_rest_config.c.