/*
This file is part of GNUnet.
(C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/**
* @file statistics/statistics_api.c
* @brief API of the statistics service
* @author Christian Grothoff
*/
#include "platform.h"
#include "gnunet_client_lib.h"
#include "gnunet_constants.h"
#include "gnunet_container_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_server_lib.h"
#include "gnunet_statistics_service.h"
#include "gnunet_strings_lib.h"
#include "statistics.h"
/**
* How long do we wait until a statistics request for setting
* a value times out? (The update will be lost if the
* service does not react within this timeframe).
*/
#define SET_TRANSMIT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2)
#define LOG(kind,...) GNUNET_log_from (kind, "statistics-api",__VA_ARGS__)
/**
* Types of actions.
*/
enum ActionType
{
/**
* Get a value.
*/
ACTION_GET,
/**
* Set a value.
*/
ACTION_SET,
/**
* Update a value.
*/
ACTION_UPDATE,
/**
* Watch a value.
*/
ACTION_WATCH
};
/**
* Entry kept for each value we are watching.
*/
struct GNUNET_STATISTICS_WatchEntry
{
/**
* What subsystem is this action about? (never NULL)
*/
char *subsystem;
/**
* What value is this action about? (never NULL)
*/
char *name;
/**
* Function to call
*/
GNUNET_STATISTICS_Iterator proc;
/**
* Closure for proc
*/
void *proc_cls;
};
/**
* Linked list of things we still need to do.
*/
struct GNUNET_STATISTICS_GetHandle
{
/**
* This is a doubly linked list.
*/
struct GNUNET_STATISTICS_GetHandle *next;
/**
* This is a doubly linked list.
*/
struct GNUNET_STATISTICS_GetHandle *prev;
/**
* Main statistics handle.
*/
struct GNUNET_STATISTICS_Handle *sh;
/**
* What subsystem is this action about? (can be NULL)
*/
char *subsystem;
/**
* What value is this action about? (can be NULL)
*/
char *name;
/**
* Continuation to call once action is complete.
*/
GNUNET_STATISTICS_Callback cont;
/**
* Function to call (for GET actions only).
*/
GNUNET_STATISTICS_Iterator proc;
/**
* Closure for proc and cont.
*/
void *cls;<