/* This file is part of GNUnet (C) 2004, 2005, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "platform.h" #include "gnunetgtk_common.h" #include #include #include #include #include "functions.h" #define FUNCTIONS_DEBUG NO static StatPair * lastStatValues; static unsigned int lsv_size; static struct ClientServerConnection * sock; static struct MUTEX * lock; static long connectionGoal; static long long banddown; static long long bandup; static struct GE_Context * ectx; static struct GC_Configuration * cfg; static struct CronManager * cron; static int getStatValue(long long * value, long long * lvalue, cron_t * dtime, const char * optName) { unsigned int i; *value = 0; if (lvalue != NULL) *lvalue = 0; for (i=0;i 0) { data[0][1] = lastavg = 1.0 * (success + lsuccess - local - llocal) / (total + ltotal); } else { data[0][1] = 0.0; return OK; } if (total == 0) return OK; success -= lsuccess; local -= llocal; if (success <= local) return OK; success -= local; lsuccess -= llocal; data[0][0] = lastdata = 1.0 * success / total; return OK; } static int statsProcessor(const char * optName, unsigned long long value, void * data) { /** * Keep track of last match (or, more precisely, position * of next expected match) since 99.99% of the time we * go over the same stats in the same order and thus * this will predict correctly). */ static unsigned int last; cron_t * delta = data; int j; int found; if (last >= lsv_size) last = 0; j = last; found = -1; if (0 == strcmp(optName, lastStatValues[j].statName)) found = j; if (found == -1) { for (j=0;j