data.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*
  2. * Copyright (C) 2000,2001 Florian Sander
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18. #define SAVESTATSLENGTH 5000
  19. #define TYPES "words letters started minutes topics lines actions modes bans kicks nicks joins smileys questions"
  20. #define SPECIAL_TYPES "age wpl vocables idle"
  21. #define T_GSTARTED -1
  22. #define T_LSTARTED -2
  23. #define T_PEAK -3
  24. #define T_WPL -4
  25. #define T_WORD -5
  26. #define T_VOCABLES -6
  27. #define T_QUOTE -7
  28. #define T_IDLE -8
  29. #define T_ERROR -999
  30. #define T_WORDS 0
  31. #define T_LETTERS 1
  32. #define T_MINUTES 2
  33. #define T_TOPICS 3
  34. #define T_LINES 4
  35. #define T_ACTIONS 5
  36. #define T_MODES 6
  37. #define T_BANS 7
  38. #define T_KICKS 8
  39. #define T_NICKS 9
  40. #define T_JOINS 10
  41. #define T_SMILEYS 11
  42. #define T_QUESTIONS 12
  43. #define TOTAL_TYPES 13
  44. #define TOTAL_SPECIAL_TYPES 8
  45. #define S_TOTAL 0
  46. #define S_TODAY 1
  47. #define S_DAILY 1
  48. #define S_WEEKLY 2
  49. #define S_MONTHLY 3
  50. #define RANGESTR_LONG(x) x ? ((x == S_DAILY) ? SLLTODAY : ((x == S_WEEKLY) ? SLLWEEKLY : SLLMONTHLY)) : SLLTOTAL
  51. #define S_USERSUM 0
  52. #define S_USERCOUNTS 1
  53. #define SL_PRIVMSG 0
  54. #define SL_KICK 1
  55. #define SL_MODE 2
  56. #define SL_NICK 3
  57. #define SL_PART 4
  58. #define SL_QUIT 5
  59. #define SL_JOIN 6
  60. typedef struct stats_words {
  61. struct stats_words *next;
  62. struct stats_words *left;
  63. struct stats_words *right;
  64. char *word;
  65. int nr;
  66. } wordstats;
  67. typedef struct stats_quote {
  68. struct stats_quote *next;
  69. char *quote;
  70. } quotestr;
  71. typedef struct stats_topic {
  72. struct stats_topic *next;
  73. char *topic;
  74. char *by;
  75. time_t when;
  76. } topicstr;
  77. struct stats_url {
  78. struct stats_url *next;
  79. char *url;
  80. char *by;
  81. int shown;
  82. time_t when;
  83. };
  84. struct stats_kick {
  85. struct stats_kick *next;
  86. quotestr *log;
  87. int shown;
  88. };
  89. typedef struct stats_hosts {
  90. struct stats_hosts *next;
  91. char *host;
  92. int nr;
  93. } hoststr;
  94. typedef struct stats_local {
  95. struct stats_local *next;
  96. struct stats_local *snext[4][TOTAL_TYPES + TOTAL_SPECIAL_TYPES];
  97. char *user;
  98. struct stats_userlist *u;
  99. time_t started;
  100. time_t lastspoke;
  101. long int values[4][TOTAL_TYPES];
  102. wordstats *words;
  103. wordstats *tree;
  104. wordstats *word;
  105. int vocables;
  106. quotestr *quotes;
  107. int quotefr;
  108. int flag;
  109. } locstats;
  110. typedef struct stats_global {
  111. struct stats_global *next;
  112. char *chan;
  113. time_t started;
  114. int peak[4];
  115. int users[2][24];
  116. int activity[24];
  117. struct stats_local *local;
  118. struct stats_local *slocal[4][TOTAL_TYPES + TOTAL_SPECIAL_TYPES];
  119. wordstats *words;
  120. topicstr *topics;
  121. hoststr *hosts;
  122. struct stats_url *urls;
  123. quotestr *log;
  124. quotestr *lastlog;
  125. int log_length;
  126. struct stats_kick *kicks;
  127. } globstats;
  128. static void locstats_init(locstats *);
  129. static void globstats_init(globstats *);
  130. static char *itotype(int);
  131. static int typetoi(char *);
  132. static void incrwordstats(locstats *, char *, int, int);
  133. static void sortstats(struct stats_global *, int, int);
  134. static void sort_stats_alphabetically(globstats *);
  135. static void sortstats_wpl(struct stats_global *, int);
  136. static void sortstats_vocables(struct stats_global *, int);
  137. static void sortstats_word(struct stats_global *, int);
  138. static void sortstats_idle(struct stats_global *, int);
  139. static void sortwordstats(locstats *, globstats *);
  140. static void free_stats();
  141. static void free_localstats(struct stats_local *sl);
  142. static void free_wordstats(wordstats *l);
  143. static void free_quotes(quotestr *l);
  144. static void free_topics(topicstr *e);
  145. static void free_urls(struct stats_url *e);
  146. static void free_kicks(struct stats_kick *e);
  147. static void free_hosts(hoststr *e);