/**
* HTTP methods allows for this plugin
*/
-static char* allow_methods;
+static char *allow_methods;
/**
* @brief struct returned by the initialization function of the plugin
* Response code
*/
int response_code;
-
};
/**
struct EgoEntry *ego_entry;
struct EgoEntry *ego_tmp;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Cleaning up\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
if (NULL != handle->timeout_task)
{
GNUNET_SCHEDULER_cancel (handle->timeout_task);
handle->timeout_task = NULL;
}
if (NULL != handle->record_name)
- GNUNET_free(handle->record_name);
+ GNUNET_free (handle->record_name);
if (NULL != handle->url)
- GNUNET_free(handle->url);
+ GNUNET_free (handle->url);
if (NULL != handle->emsg)
- GNUNET_free(handle->emsg);
+ GNUNET_free (handle->emsg);
if (NULL != handle->rd)
{
if (NULL != handle->rd->data)
- GNUNET_free((void*)handle->rd->data);
- GNUNET_free(handle->rd);
+ GNUNET_free ((void *) handle->rd->data);
+ GNUNET_free (handle->rd);
}
if (NULL != handle->timeout_task)
- GNUNET_SCHEDULER_cancel(handle->timeout_task);
+ GNUNET_SCHEDULER_cancel (handle->timeout_task);
if (NULL != handle->list_it)
- GNUNET_NAMESTORE_zone_iteration_stop(handle->list_it);
+ GNUNET_NAMESTORE_zone_iteration_stop (handle->list_it);
if (NULL != handle->add_qe)
- GNUNET_NAMESTORE_cancel(handle->add_qe);
+ GNUNET_NAMESTORE_cancel (handle->add_qe);
if (NULL != handle->identity_handle)
- GNUNET_IDENTITY_disconnect(handle->identity_handle);
+ GNUNET_IDENTITY_disconnect (handle->identity_handle);
if (NULL != handle->ns_handle)
{
- GNUNET_NAMESTORE_disconnect(handle->ns_handle);
+ GNUNET_NAMESTORE_disconnect (handle->ns_handle);
}
- for (ego_entry = handle->ego_head;
- NULL != ego_entry;)
+ for (ego_entry = handle->ego_head; NULL != ego_entry;)
{
ego_tmp = ego_entry;
ego_entry = ego_entry->next;
- GNUNET_free(ego_tmp->identifier);
- GNUNET_free(ego_tmp->keystring);
- GNUNET_free(ego_tmp);
+ GNUNET_free (ego_tmp->identifier);
+ GNUNET_free (ego_tmp->keystring);
+ GNUNET_free (ego_tmp);
}
- if(NULL != handle->resp_object)
+ if (NULL != handle->resp_object)
{
- json_decref(handle->resp_object);
+ json_decref (handle->resp_object);
}
GNUNET_free (handle);
{
struct RequestHandle *handle = cls;
struct MHD_Response *resp;
- json_t *json_error = json_object();
+ json_t *json_error = json_object ();
char *response;
if (NULL == handle->emsg)
- handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_ERROR_UNKNOWN);
+ handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_ERROR_UNKNOWN);
- json_object_set_new(json_error,"error", json_string(handle->emsg));
+ json_object_set_new (json_error, "error", json_string (handle->emsg));
if (0 == handle->response_code)
handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
response = json_dumps (json_error, 0);
resp = GNUNET_REST_create_response (response);
handle->proc (handle->proc_cls, resp, handle->response_code);
- json_decref(json_error);
- GNUNET_free(response);
+ json_decref (json_error);
+ GNUNET_free (response);
GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
}
* @param name the name of an identity (only one can be NULL)
* @return EgoEntry or NULL if not found
*/
-struct EgoEntry*
-get_egoentry_namestore(struct RequestHandle *handle, char *name)
+struct EgoEntry *
+get_egoentry_namestore (struct RequestHandle *handle, char *name)
{
struct EgoEntry *ego_entry;
if (NULL != name)
{
- for (ego_entry = handle->ego_head;
- NULL != ego_entry;
- ego_entry = ego_entry->next)
+ for (ego_entry = handle->ego_head; NULL != ego_entry;
+ ego_entry = ego_entry->next)
{
if (0 != strcasecmp (name, ego_entry->identifier))
- continue;
+ continue;
return ego_entry;
}
}
namestore_iteration_error (void *cls)
{
struct RequestHandle *handle = cls;
- handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_FAILED);
+ handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_FAILED);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
{
if (NULL != emsg)
{
- handle->emsg = GNUNET_strdup(emsg);
+ handle->emsg = GNUNET_strdup (emsg);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
- handle->emsg = GNUNET_strdup("Error storing records");
+ handle->emsg = GNUNET_strdup ("Error storing records");
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
if (GNUNET_NO == success)
{
handle->response_code = MHD_HTTP_NOT_FOUND;
- handle->emsg = GNUNET_strdup("No record found");
+ handle->emsg = GNUNET_strdup ("No record found");
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
{
if (NULL != emsg)
{
- handle->emsg = GNUNET_strdup(emsg);
+ handle->emsg = GNUNET_strdup (emsg);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
- handle->emsg = GNUNET_strdup("Deleting record failed");
+ handle->emsg = GNUNET_strdup ("Deleting record failed");
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
handle->list_it = NULL;
if (NULL == handle->resp_object)
- handle->resp_object = json_array();
+ handle->resp_object = json_array ();
result_str = json_dumps (handle->resp_object, 0);
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
resp = GNUNET_REST_create_response (result_str);
handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
GNUNET_free_non_null (result_str);
*/
static void
namestore_list_iteration (void *cls,
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key,
- const char *rname,
- unsigned int rd_len,
- const struct GNUNET_GNSRECORD_Data *rd)
+ const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key,
+ const char *rname,
+ unsigned int rd_len,
+ const struct GNUNET_GNSRECORD_Data *rd)
{
struct RequestHandle *handle = cls;
json_t *record_obj;
if (NULL == handle->resp_object)
- handle->resp_object = json_array();
+ handle->resp_object = json_array ();
for (unsigned int i = 0; i < rd_len; i++)
{
- if ( (GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) &&
- (0 != strcmp (rname, GNUNET_GNS_EMPTY_LABEL_AT)) )
+ if ((GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) &&
+ (0 != strcmp (rname, GNUNET_GNS_EMPTY_LABEL_AT)))
continue;
record_obj = GNUNET_JSON_from_gns_record (rname, &rd[i]);
- if(NULL == record_obj)
+ if (NULL == record_obj)
continue;
json_array_append (handle->resp_object, record_obj);
*/
static void
default_ego_get (void *cls,
- struct GNUNET_IDENTITY_Ego *ego,
- void **ctx,
- const char *identifier)
+ struct GNUNET_IDENTITY_Ego *ego,
+ void **ctx,
+ const char *identifier)
{
struct RequestHandle *handle = cls;
handle->op = NULL;
if (ego == NULL)
{
- handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_NO_DEFAULT_ZONE);
+ handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_NO_DEFAULT_ZONE);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
handle->zone_pkey = GNUNET_IDENTITY_ego_get_private_key (ego);
- handle->list_it = GNUNET_NAMESTORE_zone_iteration_start (handle->ns_handle,
- handle->zone_pkey,
- &namestore_iteration_error,
- handle,
- &namestore_list_iteration,
- handle,
- &namestore_list_finished,
- handle);
+ handle->list_it =
+ GNUNET_NAMESTORE_zone_iteration_start (handle->ns_handle,
+ handle->zone_pkey,
+ &namestore_iteration_error,
+ handle,
+ &namestore_list_iteration,
+ handle,
+ &namestore_list_finished,
+ handle);
if (NULL == handle->list_it)
{
- handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_FAILED);
+ handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_FAILED);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
*/
void
namestore_get (struct GNUNET_REST_RequestHandle *con_handle,
- const char* url,
- void *cls)
+ const char *url,
+ void *cls)
{
struct RequestHandle *handle = cls;
struct EgoEntry *ego_entry;
egoname = NULL;
ego_entry = NULL;
- //set zone to name if given
+ // set zone to name if given
if (strlen (GNUNET_REST_API_NS_NAMESTORE) < strlen (handle->url))
{
- egoname = &handle->url[strlen (GNUNET_REST_API_NS_NAMESTORE)+1];
- ego_entry = get_egoentry_namestore(handle, egoname);
+ egoname = &handle->url[strlen (GNUNET_REST_API_NS_NAMESTORE) + 1];
+ ego_entry = get_egoentry_namestore (handle, egoname);
if (NULL == ego_entry)
{
handle->response_code = MHD_HTTP_NOT_FOUND;
- handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND);
+ handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
}
- if ( NULL != ego_entry )
+ if (NULL != ego_entry)
{
- handle->zone_pkey = GNUNET_IDENTITY_ego_get_private_key(ego_entry->ego);
+ handle->zone_pkey = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
}
if (NULL == handle->zone_pkey)
{
handle->op = GNUNET_IDENTITY_get (handle->identity_handle,
- "namestore",
- &default_ego_get,
- handle);
+ "namestore",
+ &default_ego_get,
+ handle);
return;
}
- handle->list_it = GNUNET_NAMESTORE_zone_iteration_start (handle->ns_handle,
- handle->zone_pkey,
- &namestore_iteration_error,
- handle,
- &namestore_list_iteration,
- handle,
- &namestore_list_finished,
- handle);
+ handle->list_it =
+ GNUNET_NAMESTORE_zone_iteration_start (handle->ns_handle,
+ handle->zone_pkey,
+ &namestore_iteration_error,
+ handle,
+ &namestore_list_iteration,
+ handle,
+ &namestore_list_finished,
+ handle);
if (NULL == handle->list_it)
{
- handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_FAILED);
+ handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_FAILED);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
*/
static void
default_ego_post (void *cls,
- struct GNUNET_IDENTITY_Ego *ego,
- void **ctx,
- const char *identifier)
+ struct GNUNET_IDENTITY_Ego *ego,
+ void **ctx,
+ const char *identifier)
{
struct RequestHandle *handle = cls;
handle->op = NULL;
if (ego == NULL)
{
- handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_NO_DEFAULT_ZONE);
+ handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_NO_DEFAULT_ZONE);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
handle->zone_pkey = GNUNET_IDENTITY_ego_get_private_key (ego);
handle->add_qe = GNUNET_NAMESTORE_records_store (handle->ns_handle,
- handle->zone_pkey,
- handle->record_name,
- 1,
- handle->rd,
- &create_finished,
- handle);
+ handle->zone_pkey,
+ handle->record_name,
+ 1,
+ handle->rd,
+ &create_finished,
+ handle);
+ if (NULL == handle->add_qe)
+ {
+ handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_FAILED);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
+ }
+}
+
+
+static void
+ns_lookup_error_cb (void *cls)
+{
+ struct RequestHandle *handle = cls;
+ handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_FAILED);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+}
+
+
+static void
+ns_lookup_cb (void *cls,
+ const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
+ const char *label,
+ unsigned int rd_count,
+ const struct GNUNET_GNSRECORD_Data *rd)
+{
+ struct RequestHandle *handle = cls;
+ struct GNUNET_GNSRECORD_Data rd_new[rd_count + 1];
+ for (int i = 0; i < rd_count; i++)
+ rd_new[i] = rd[i];
+ rd_new[rd_count] = *handle->rd;
+ handle->add_qe = GNUNET_NAMESTORE_records_store (handle->ns_handle,
+ handle->zone_pkey,
+ handle->record_name,
+ rd_count + 1,
+ rd_new,
+ &create_finished,
+ handle);
if (NULL == handle->add_qe)
{
- handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_FAILED);
+ handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_FAILED);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
*/
void
namestore_add (struct GNUNET_REST_RequestHandle *con_handle,
- const char* url,
- void *cls)
+ const char *url,
+ void *cls)
{
struct RequestHandle *handle = cls;
struct GNUNET_GNSRECORD_Data *gns_record;
json_error_t err;
char term_data[handle->rest_handle->data_size + 1];
- struct GNUNET_JSON_Specification gnsspec[] = {
- GNUNET_JSON_spec_gnsrecord_data(&gns_record),
- GNUNET_JSON_spec_end ()
- };
+ struct GNUNET_JSON_Specification gnsspec[] =
+ {GNUNET_JSON_spec_gnsrecord_data (&gns_record), GNUNET_JSON_spec_end ()};
if (0 >= handle->rest_handle->data_size)
{
- handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_NO_DATA);
+ handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_NO_DATA);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
term_data[handle->rest_handle->data_size] = '\0';
- GNUNET_memcpy(term_data, handle->rest_handle->data,
- handle->rest_handle->data_size);
+ GNUNET_memcpy (term_data,
+ handle->rest_handle->data,
+ handle->rest_handle->data_size);
data_js = json_loads (term_data, JSON_DECODE_ANY, &err);
if (GNUNET_OK != GNUNET_JSON_parse (data_js, gnsspec, NULL, NULL))
{
- handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_INVALID_DATA);
+ handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_INVALID_DATA);
GNUNET_SCHEDULER_add_now (&do_error, handle);
- GNUNET_JSON_parse_free(gnsspec);
+ GNUNET_JSON_parse_free (gnsspec);
json_decref (data_js);
return;
}
handle->rd = gns_record;
- name_json = json_object_get(data_js, "record_name");
- if (!json_is_string(name_json))
+ name_json = json_object_get (data_js, "record_name");
+ if (! json_is_string (name_json))
{
- handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_INVALID_DATA);
+ handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_INVALID_DATA);
GNUNET_SCHEDULER_add_now (&do_error, handle);
json_decref (data_js);
return;
}
- handle->record_name = GNUNET_strdup(json_string_value(name_json));
- if(NULL == handle->record_name)
+ handle->record_name = GNUNET_strdup (json_string_value (name_json));
+ if (NULL == handle->record_name)
{
- handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_INVALID_DATA);
+ handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_INVALID_DATA);
GNUNET_SCHEDULER_add_now (&do_error, handle);
json_decref (data_js);
return;
}
- if (0 >= strlen(handle->record_name))
+ if (0 >= strlen (handle->record_name))
{
- handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_INVALID_DATA);
+ handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_INVALID_DATA);
GNUNET_SCHEDULER_add_now (&do_error, handle);
json_decref (data_js);
return;
egoname = NULL;
ego_entry = NULL;
- //set zone to name if given
+ // set zone to name if given
if (strlen (GNUNET_REST_API_NS_NAMESTORE) < strlen (handle->url))
{
- egoname = &handle->url[strlen (GNUNET_REST_API_NS_NAMESTORE)+1];
- ego_entry = get_egoentry_namestore(handle, egoname);
+ egoname = &handle->url[strlen (GNUNET_REST_API_NS_NAMESTORE) + 1];
+ ego_entry = get_egoentry_namestore (handle, egoname);
if (NULL == ego_entry)
{
handle->response_code = MHD_HTTP_NOT_FOUND;
- handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND);
+ handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
}
if (NULL != ego_entry)
{
- handle->zone_pkey = GNUNET_IDENTITY_ego_get_private_key(ego_entry->ego);
+ handle->zone_pkey = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
}
if (NULL == handle->zone_pkey)
{
handle->op = GNUNET_IDENTITY_get (handle->identity_handle,
- "namestore",
- &default_ego_post,
- handle);
+ "namestore",
+ &default_ego_post,
+ handle);
return;
}
- handle->add_qe = GNUNET_NAMESTORE_records_store (handle->ns_handle,
- handle->zone_pkey,
- handle->record_name,
- 1,
- handle->rd,
- &create_finished,
- handle);
+ handle->add_qe = GNUNET_NAMESTORE_records_lookup (handle->ns_handle,
+ handle->zone_pkey,
+ handle->record_name,
+ &ns_lookup_error_cb,
+ handle,
+ &ns_lookup_cb,
+ handle);
if (NULL == handle->add_qe)
{
- handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_FAILED);
+ handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_FAILED);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
*/
static void
default_ego_delete (void *cls,
- struct GNUNET_IDENTITY_Ego *ego,
- void **ctx,
- const char *identifier)
+ struct GNUNET_IDENTITY_Ego *ego,
+ void **ctx,
+ const char *identifier)
{
struct RequestHandle *handle = cls;
handle->op = NULL;
if (ego == NULL)
{
- handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_NO_DEFAULT_ZONE);
+ handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_NO_DEFAULT_ZONE);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
handle->zone_pkey,
handle->record_name,
0,
- NULL,
+ NULL,
&del_finished,
handle);
if (NULL == handle->add_qe)
{
- handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_FAILED);
+ handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_FAILED);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
*/
void
namestore_delete (struct GNUNET_REST_RequestHandle *con_handle,
- const char* url,
- void *cls)
+ const char *url,
+ void *cls)
{
struct RequestHandle *handle = cls;
struct GNUNET_HashCode key;
egoname = NULL;
ego_entry = NULL;
- //set zone to name if given
+ // set zone to name if given
if (strlen (GNUNET_REST_API_NS_NAMESTORE) < strlen (handle->url))
{
- egoname = &handle->url[strlen (GNUNET_REST_API_NS_NAMESTORE)+1];
- ego_entry = get_egoentry_namestore(handle, egoname);
+ egoname = &handle->url[strlen (GNUNET_REST_API_NS_NAMESTORE) + 1];
+ ego_entry = get_egoentry_namestore (handle, egoname);
if (NULL == ego_entry)
{
handle->response_code = MHD_HTTP_NOT_FOUND;
- handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND);
+ handle->emsg = GNUNET_strdup (GNUNET_REST_IDENTITY_NOT_FOUND);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
}
- if ( NULL != ego_entry )
+ if (NULL != ego_entry)
{
- handle->zone_pkey = GNUNET_IDENTITY_ego_get_private_key(ego_entry->ego);
+ handle->zone_pkey = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
}
GNUNET_CRYPTO_hash ("record_name", strlen ("record_name"), &key);
- if ( GNUNET_NO
- == GNUNET_CONTAINER_multihashmap_contains (con_handle->url_param_map,
- &key))
+ if (GNUNET_NO ==
+ GNUNET_CONTAINER_multihashmap_contains (con_handle->url_param_map, &key))
{
- handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_INVALID_DATA);
+ handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_INVALID_DATA);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
- handle->record_name = GNUNET_strdup(
- GNUNET_CONTAINER_multihashmap_get (con_handle->url_param_map, &key));
+ handle->record_name = GNUNET_strdup (
+ GNUNET_CONTAINER_multihashmap_get (con_handle->url_param_map, &key));
if (NULL == handle->zone_pkey)
{
handle->op = GNUNET_IDENTITY_get (handle->identity_handle,
- "namestore",
- &default_ego_delete,
- handle);
+ "namestore",
+ &default_ego_delete,
+ handle);
return;
}
handle->zone_pkey,
handle->record_name,
0,
- NULL,
+ NULL,
&del_finished,
handle);
if (NULL == handle->add_qe)
{
- handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_FAILED);
+ handle->emsg = GNUNET_strdup (GNUNET_REST_NAMESTORE_FAILED);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
}
-
/**
* Respond to OPTIONS request
*
*/
static void
options_cont (struct GNUNET_REST_RequestHandle *con_handle,
- const char* url,
+ const char *url,
void *cls)
{
struct MHD_Response *resp;
struct RequestHandle *handle = cls;
- //independent of path return all options
+ // independent of path return all options
resp = GNUNET_REST_create_response (NULL);
- MHD_add_response_header (resp,
- "Access-Control-Allow-Methods",
- allow_methods);
+ MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods);
handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
return;
init_cont (struct RequestHandle *handle)
{
struct GNUNET_REST_RequestHandlerError err;
- static const struct GNUNET_REST_RequestHandler handlers[] = {
- {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_NAMESTORE, &namestore_get},
- {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_NAMESTORE, &namestore_add},
- {MHD_HTTP_METHOD_DELETE, GNUNET_REST_API_NS_NAMESTORE, &namestore_delete},
- {MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_NAMESTORE, &options_cont},
- GNUNET_REST_HANDLER_END
- };
-
- if (GNUNET_NO == GNUNET_REST_handle_request (handle->rest_handle,
- handlers,
- &err,
- handle))
+ static const struct GNUNET_REST_RequestHandler handlers[] =
+ {{MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_NAMESTORE, &namestore_get},
+ {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_NAMESTORE, &namestore_add},
+ {MHD_HTTP_METHOD_DELETE, GNUNET_REST_API_NS_NAMESTORE, &namestore_delete},
+ {MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_NAMESTORE, &options_cont},
+ GNUNET_REST_HANDLER_END};
+
+ if (GNUNET_NO ==
+ GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle))
{
handle->response_code = err.error_code;
GNUNET_SCHEDULER_add_now (&do_error, handle);
if ((NULL == ego) && (ID_REST_STATE_INIT == handle->state))
{
handle->state = ID_REST_STATE_POST_INIT;
- init_cont(handle);
+ init_cont (handle);
return;
}
if (ID_REST_STATE_INIT == handle->state)
{
- ego_entry = GNUNET_new(struct EgoEntry);
+ ego_entry = GNUNET_new (struct EgoEntry);
GNUNET_IDENTITY_ego_get_public_key (ego, &pk);
ego_entry->keystring = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk);
ego_entry->ego = ego;
GNUNET_asprintf (&ego_entry->identifier, "%s", name);
- GNUNET_CONTAINER_DLL_insert_tail(handle->ego_head, handle->ego_tail,
- ego_entry);
+ GNUNET_CONTAINER_DLL_insert_tail (handle->ego_head,
+ handle->ego_tail,
+ ego_entry);
}
-
}
* @return GNUNET_OK if request accepted
*/
static void
-rest_process_request(struct GNUNET_REST_RequestHandle *rest_handle,
- GNUNET_REST_ResultProcessor proc,
- void *proc_cls)
+rest_process_request (struct GNUNET_REST_RequestHandle *rest_handle,
+ GNUNET_REST_ResultProcessor proc,
+ void *proc_cls)
{
struct RequestHandle *handle = GNUNET_new (struct RequestHandle);
handle->zone_pkey = NULL;
handle->url = GNUNET_strdup (rest_handle->url);
- if (handle->url[strlen (handle->url)-1] == '/')
- handle->url[strlen (handle->url)-1] = '\0';
+ if (handle->url[strlen (handle->url) - 1] == '/')
+ handle->url[strlen (handle->url) - 1] = '\0';
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n");
handle->ns_handle = GNUNET_NAMESTORE_connect (cfg);
- handle->identity_handle = GNUNET_IDENTITY_connect (cfg, &id_connect_cb, handle);
+ handle->identity_handle =
+ GNUNET_IDENTITY_connect (cfg, &id_connect_cb, handle);
handle->timeout_task =
- GNUNET_SCHEDULER_add_delayed (handle->timeout,
- &do_error,
- handle);
+ GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_error, handle);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected\n");
}
cfg = cls;
if (NULL != plugin.cfg)
- return NULL; /* can only initialize once! */
+ return NULL; /* can only initialize once! */
memset (&plugin, 0, sizeof (struct Plugin));
plugin.cfg = cfg;
api = GNUNET_new (struct GNUNET_REST_Plugin);
MHD_HTTP_METHOD_DELETE,
MHD_HTTP_METHOD_OPTIONS);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- _("Namestore REST API initialized\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _ ("Namestore REST API initialized\n"));
return api;
}
GNUNET_free_non_null (allow_methods);
GNUNET_free (api);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Namestore REST plugin is finished\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Namestore REST plugin is finished\n");
return NULL;
}