1 /*****************************************************************************/ 2 /* Klavaro - a flexible touch typing tutor */ 3 /* Copyright (C) 2005, 2006, 2007, 2008 Felipe Castro */ 4 /* Copyright (C) 2009, 2010, 2011, 2012, 2013 The Free Software Foundation */ 5 /* */ 6 /* This program is free software, licensed under the terms of the GNU */ 7 /* General Public License as published by the Free Software Foundation, */ 8 /* either version 3 of the License, or (at your option) any later version. */ 9 /* You should have received a copy of the GNU General Public License */ 10 /* along with this program. If not, see <http://www.gnu.org/licenses/>. */ 11 /*****************************************************************************/ 12 13 /************************************************** 14 * Contest for fluidness performance 15 */ 16 #define DOWNHOST "klavaro.sourceforge.io/top10" 17 #define CGI_SERVER "klavaro.sourceforge.io/cgi-bin/klavaro_rangilo" 18 #define MIN_CHARS_TO_LOG 500 19 20 #define TIMEOUT 10 21 #define LOW_SPEED_LIMIT 160 22 #define LOW_SPEED_TIME 5 23 24 /************************************************** 25 * Structures 26 */ 27 typedef struct USERS 28 { 29 gchar *id; 30 gchar *name; 31 } User; 32 33 #define MAX_NAME_LEN 255 34 typedef struct STATISTICS 35 { 36 gchar lang[2]; // Language code 37 gchar genv; // Graphical environment: 'x' = X; 'w' = Windows 38 time_t when; // Epoch of stats logging 39 gint32 nchars; // Number of chars typed in the test 40 gfloat accur; 41 gfloat velo; 42 gfloat fluid; 43 gfloat score; // s = f (accur, velo, fluid) 44 gint32 name_len; 45 gchar name[MAX_NAME_LEN + 1]; 46 } Statistics; 47 48 void top10_init (void); 49 50 void top10_message (gchar * msg); 51 52 void top10_init_stats (gboolean locally); 53 54 void top10_clean_stat (gint i, gboolean locally); 55 56 void top10_insert_stat (Statistics * stat, gint i, gboolean locally); 57 58 gboolean top10_compare_insert_stat (Statistics * stat, gboolean locally); 59 60 void top10_delete_stat (gint i, gboolean locally); 61 62 gfloat top10_calc_score (Statistics * stat); 63 64 gboolean top10_validate_stat (Statistics * stat); 65 66 gchar *top10_get_score_file (gboolean locally, gint lang); 67 68 gboolean top10_read_stats_from_file (gboolean locally, gchar * file); 69 70 void top10_read_stats (gboolean locally, gint lang); 71 72 void top10_write_stats (gboolean locally, gint lang); 73 74 void top10_show_stat (Statistics * stats); 75 76 void top10_show_stats (gboolean locally); 77 78 gboolean top10_global_update (gpointer data); 79 80 gboolean top10_global_publish (gpointer data); 81 82