| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- /*
- * Copyright (C) 2000,2001 Florian Sander
- *
- * This program 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
- * of the License, or (at your option) any later version.
- *
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
- struct slang_facts {
- struct slang_facts *next;
- int sorting;
- struct slang_facts_place *places;
- };
- static struct slang_facts *slang_facts_add(struct slang_facts *, int, int, char *);
- //static int slang_facts_expmem(struct slang_facts *);
- static void slang_facts_free(struct slang_facts *);
- static int slang_facts_selectfirst(struct slang_facts *);
- static int slang_facts_selectnext();
- //static char *slang_facts_getfirst();
- //static char *slang_facts_getnext();
- static char *slang_facts_get(int);
- static struct slang_facts *slang_facts_add(struct slang_facts *where, int sorting, int place, char *text)
- {
- struct slang_facts *newitem, *target;
- newitem = NULL;
- if (where) {
- for (newitem = where; newitem; newitem = newitem->next)
- if (newitem->sorting == sorting)
- break;
- }
- if (!newitem) {
- newitem = nmalloc(sizeof(struct slang_facts));
- newitem->next = NULL;
- newitem->sorting = sorting;
- newitem->places = NULL;
- for (target = where; target && target->next; target = target->next);
- if (target)
- target->next = newitem;
- else
- where = newitem;
- }
- newitem->places = slang_facts_place_add(newitem->places, place, text);
- return where;
- }
- /*static int slang_facts_expmem(struct slang_facts *what)
- {
- int size = 0;
- for (; what; what = what->next) {
- size += sizeof(struct slang_facts);
- size += slang_facts_place_expmem(what->places);
- }
- return size;
- }*/
- static void slang_facts_free(struct slang_facts *what)
- {
- struct slang_facts *next;
- while (what) {
- next = what->next;
- slang_facts_place_free(what->places);
- nfree(what);
- what = next;
- }
- }
- static struct slang_facts *glob_fact;
- static int slang_facts_selectfirst(struct slang_facts *what)
- {
- int itype, pitype;
- locstats *ls;
- if (!glob_globstats)
- return 0;
- if (!glob_globstats->local)
- return 0;
- for (glob_fact = what; glob_fact; glob_fact = glob_fact->next) {
- sortstats(glob_globstats, glob_fact->sorting, S_DAILY);
- itype = glob_fact->sorting;
- glob_sorting = itype;
- if (itype >= 0) {
- if (!glob_globstats->slocal[S_TODAY][itype]->values[S_TODAY][itype])
- continue;
- } else {
- pitype = (itype * -1) + (TOTAL_TYPES - 1);
- ls = glob_globstats->slocal[S_TODAY][pitype];
- if ((itype == T_WPL) && (!ls->values[S_DAILY][T_WORDS]
- || !ls->values[S_DAILY][T_LINES]))
- continue;
- else if ((itype == T_IDLE) && (!ls->values[S_DAILY][T_MINUTES]
- || !ls->values[S_DAILY][T_LINES]))
- continue;
- else if ((itype == T_VOCABLES) && !ls->vocables)
- continue;
- }
- return 1;
- }
- return 0;
- }
- static int slang_facts_selectnext()
- {
- int itype, pitype;
- locstats *ls;
- if (!glob_fact)
- return 0;
- for (glob_fact = glob_fact->next; glob_fact; glob_fact = glob_fact->next) {
- sortstats(glob_globstats, glob_fact->sorting, S_DAILY);
- itype = glob_fact->sorting;
- glob_sorting = itype;
- if (itype >= 0) {
- if (!glob_globstats->slocal[S_TODAY][itype]->values[S_TODAY][itype])
- continue;
- } else {
- pitype = (itype * -1) + (TOTAL_TYPES - 1);
- ls = glob_globstats->slocal[S_TODAY][pitype];
- if ((itype == T_WPL) && (!ls->values[S_DAILY][T_WORDS]
- || !ls->values[S_DAILY][T_LINES]))
- continue;
- else if ((itype == T_IDLE) && (!ls->values[S_DAILY][T_MINUTES]
- || !ls->values[S_DAILY][T_LINES]))
- continue;
- else if ((itype == T_VOCABLES) && !ls->vocables)
- continue;
- }
- return 1;
- }
- return 0;
- }
- /*
- static char *slang_facts_getfirst()
- {
- Assert(glob_fact);
- return slang_facts_place_getfirst(glob_fact->places);
- }
- static char *slang_facts_getnext()
- {
- return slang_facts_place_getnext();
- }
- */
- static char *slang_facts_get(int place)
- {
- return slang_facts_place_get(glob_fact->places, glob_fact->sorting, place);
- }
|