2.5.4-Pre2 Fixes

This commit is contained in:
fishwaldo 2003-07-17 10:13:51 +00:00
parent 451ae72731
commit ac142e06c8
9 changed files with 183 additions and 107 deletions

View file

@ -1,4 +1,9 @@
NeoStats ChangeLog - Anything we add/remove/fix/change is in here (even our rants)
* NeoStats * Fish * Version 2.5.4 Pre2
- Fixed a problem with statserv and the HTML settings
- Fixed a problem with statserv and channel member counts (didn't decrease for kicks)
- Implemented our own Assertion function to show backtraces and log it. Changed all asserts to nassert
* NeoStats * Fish & Shmad * Version 2.5.4 (or 2.6.0)
- Initial import for Mystic 1.1.x IRCd support
- Updated all copyright notices.

View file

@ -1,28 +1,42 @@
# Makefile for GeoStats
# GeoStats CVS Identification
# $Id: Makefile.in,v 1.41 2003/05/28 14:33:14 fishwaldo Exp $
# $Id: Makefile.in,v 1.42 2003/07/17 10:13:51 fishwaldo Exp $
# makefile originally created by Andy Church.
include Makefile.inc
OBJS = dns.o chans.o dotconf.o services.o main.o sock.o conf.o ircd.o timer.o users.o \
ns_help.o dl.o list.o hash.o server.o keeper.o log.o @IRCD_FILES_OBJS@
SRCS = dns.c chans.c dotconf.c services.c main.c sock.c conf.c ircd.c timer.c users.c \
ns_help.c dl.c list.c hash.c server.c keeper.c log.c @IRCD_FILES_SRC@
OBJS = dns.o chans.o dotconf.o services.o main.o sock.o conf.o ircd.o timer.o \
users.o ns_help.o dl.o list.o hash.o server.o keeper.o log.o \
@IRCD_FILES_OBJS@
SRCS = dns.c chans.c dotconf.c services.c main.c sock.c conf.c ircd.c timer.c \
users.c ns_help.c dl.c list.c hash.c server.c keeper.c log.c \
@IRCD_FILES_SRC@
PROGS = neostats cronchk makeconf
CONF = neostats.motd
DOCS = doc/FAQ doc/USERMAN README BUGS AUTHORS COPYING CREDITS TODO tools/README* tools/cfgtool/README* ChangeLog
DOCS = doc/FAQ doc/USERMAN README BUGS AUTHORS COPYING CREDITS TODO \
tools/README* tools/cfgtool/README* ChangeLog
DOCS_PROGS = doc/read-faq doc/read-userman
DATA = data/tlds.nfo
INCLUDES = config.h dl.h dotconf.h hash.h list.h stats.h Ultimate.h Unreal.h adns/adns.h hybrid7.h neoircd.h conf.h log.h
BUILDFILES = configure *.in adns/Makefile adns/config.h.in dl/Makefile dl/modules.txt RELNOTES install-sh neoircd.c neoircd.h hybrid7.c hybrid7.h Ultimate.c Ultimate.h Unreal.c Unreal.h makeconf cronchk tools/Makefile.in tools/cfgtool/Makefile keeper/Makefile doc/old/*
TOOLFILES = tools/*.c tools/*.h tools/cfgtool/*.h tools/cfgtool/*.c tools/cfgtool/pixmaps/*.xpm
DISTFILES = $(INCLUDES) $(SRCS) $(DATA) $(DOCS) $(DOCS_PROGS) $(CONF) $(BUILDFILES) $(TOOLFILES) keeper/*.c keeper/*.h adns/*.c adns/adns.h adns/dlist.h adns/internal.h adns/tvarith.h
INCLUDES = config.h dl.h dotconf.h hash.h list.h stats.h Ultimate.h Unreal.h \
adns/adns.h hybrid7.h neoircd.h conf.h log.h Bahamut.h \
Ircu.h mystic.h QuantumIRCd.h sock.h ircd.h
BUILDFILES = configure *.in adns/Makefile adns/config.h.in dl/Makefile \
dl/modules.txt RELNOTES install-sh neoircd.c neoircd.h \
hybrid7.c hybrid7.h Ultimate.c Ultimate.h Unreal.c Unreal.h \
makeconf cronchk tools/Makefile.in tools/cfgtool/Makefile \
keeper/Makefile doc/old/* Bahamut.c Ircu.c mystic.c \
QuantumIRCd.c
TOOLFILES = tools/*.c tools/*.h tools/cfgtool/*.h tools/cfgtool/*.c \
tools/cfgtool/pixmaps/*.xpm
DISTFILES = $(INCLUDES) $(SRCS) $(DATA) $(DOCS) $(DOCS_PROGS) $(CONF) \
$(BUILDFILES) $(TOOLFILES) keeper/*.c keeper/*.h adns/*.c \
adns/adns.h adns/dlist.h adns/internal.h adns/tvarith.h
distdir = @PACKAGE@-@VERSION@
SUBDIRS = doc doc/old data adns logs keeper tools tools/cfgtool tools/cfgtool/pixmaps
SUBDIRS = doc doc/old data adns logs keeper tools tools/cfgtool \
tools/cfgtool/pixmaps
DISTMOD = cs extauth hostserv loveserv ms spam statserv version
.c.o:

View file

@ -5,7 +5,7 @@ PACKAGE=NeoStats
AC_DEFINE(MAJOR, 2)
AC_DEFINE(MINOR, 5)
AC_DEFINE(REV, 4)
VERSION=2.5.4
VERSION=2.5.4-Pre2
AC_PREFIX_DEFAULT(~/NeoStats)
CFLAGS="$CFLAGS -O2"

View file

@ -20,7 +20,7 @@
** USA
**
** NeoStats CVS Identification
** $Id: m_stats.h,v 1.11 2003/06/13 14:49:33 fishwaldo Exp $
** $Id: m_stats.h,v 1.12 2003/07/17 10:13:51 fishwaldo Exp $
*/
#ifndef M_STATS_H
@ -34,7 +34,7 @@
#define IncreaseUsers(x) x->users++; stats_network.users++; x->totusers++; stats_network.totusers++; daily.tot_users++;
#define IncreaseServers() stats_network.servers++;
#define IncreaseKicks(x) x->kicks++; x->maxkickstoday++;
#define IncreaseKicks(x) x->kicks++; x->maxkickstoday++; x->members--;
#define IncreaseTops(x) x->topics++; x->topicstoday++;
#define Increasemems(x) x->members++; x->totmem++; x->lastseen = time(NULL); x->joinstoday++;
#define Decreasemems(x) x->members--; x->lastseen = time(NULL);

View file

@ -20,7 +20,7 @@
** USA
**
** NeoStats CVS Identification
** $Id: statserv.c,v 1.68 2003/07/15 10:53:19 fishwaldo Exp $
** $Id: statserv.c,v 1.69 2003/07/17 10:13:51 fishwaldo Exp $
*/
#include <stdio.h>
@ -141,7 +141,9 @@ void ss_Config()
} else {
/* assume that html is enabled if we don't have a setting for it */
StatServ.html = 1;
GetConf((void *) StatServ.html, CFGINT, "HTML_Enabled");
if (GetConf((void *) &StatServ.html, CFGINT, "HTML_Enabled") < 0) {
StatServ.html = 1;
}
snprintf(StatServ.htmlpath, 255, "%s", tmp);
free(tmp);
}

68
hash.c
View file

@ -39,7 +39,7 @@
* into proprietary software; there is no requirement for such software to
* contain a copyright notice related to this source.
*
* $Id: hash.c,v 1.9 2003/06/13 13:11:48 fishwaldo Exp $
* $Id: hash.c,v 1.10 2003/07/17 10:13:51 fishwaldo Exp $
* $Name: $
*/
@ -50,12 +50,12 @@
#include <ctype.h>
#define HASH_IMPLEMENTATION
#include "hash.h"
#include "log.h"
#ifdef KAZLIB_RCSID
static const char rcsid[] =
"$Id: hash.c,v 1.9 2003/06/13 13:11:48 fishwaldo Exp $";
"$Id: hash.c,v 1.10 2003/07/17 10:13:51 fishwaldo Exp $";
#endif
#define INIT_BITS 6
@ -136,8 +136,8 @@ static int is_power_of_two(hash_val_t arg)
static hash_val_t compute_mask(hashcount_t size)
{
assert(is_power_of_two(size));
assert(size >= 2);
nassert(is_power_of_two(size));
nassert(size >= 2);
return size - 1;
}
@ -186,7 +186,7 @@ static void grow_table(hash_t * hash)
{
hnode_t **newtable;
assert(2 * hash->nchains > hash->nchains); /* 1 */
nassert(2 * hash->nchains > hash->nchains); /* 1 */
newtable = realloc(hash->table, sizeof *newtable * hash->nchains * 2); /* 4 */
@ -195,7 +195,7 @@ static void grow_table(hash_t * hash)
hash_val_t exposed_bit = mask ^ hash->mask; /* 6 */
hash_val_t chain;
assert(mask != hash->mask);
nassert(mask != hash->mask);
for (chain = 0; chain < hash->nchains; chain++) { /* 7 */
hnode_t *low_chain = 0, *high_chain =
@ -224,7 +224,7 @@ static void grow_table(hash_t * hash)
hash->lowmark *= 2;
hash->highmark *= 2;
}
assert(hash_verify(hash));
nassert(hash_verify(hash));
}
/*
@ -262,7 +262,7 @@ static void shrink_table(hash_t * hash)
hash_val_t chain, nchains;
hnode_t **newtable, *low_tail, *low_chain, *high_chain;
assert(hash->nchains >= 2); /* 1 */
nassert(hash->nchains >= 2); /* 1 */
nchains = hash->nchains / 2;
for (chain = 0; chain < nchains; chain++) {
@ -274,7 +274,7 @@ static void shrink_table(hash_t * hash)
else if (high_chain != 0) /* 5 */
hash->table[chain] = high_chain;
else
assert(hash->table[chain] == NULL); /* 6 */
nassert(hash->table[chain] == NULL); /* 6 */
}
newtable = realloc(hash->table, sizeof *newtable * nchains); /* 7 */
if (newtable) /* 8 */
@ -283,7 +283,7 @@ static void shrink_table(hash_t * hash)
hash->nchains = nchains;
hash->lowmark /= 2;
hash->highmark /= 2;
assert(hash_verify(hash));
nassert(hash_verify(hash));
}
@ -344,7 +344,7 @@ hash_t *hash_create(hashcount_t maxcount, hash_comp_t compfun,
hash->mask = INIT_MASK;
hash->dynamic = 1; /* 7 */
clear_table(hash); /* 8 */
assert(hash_verify(hash));
nassert(hash_verify(hash));
return hash;
}
free(hash);
@ -360,8 +360,8 @@ hash_t *hash_create(hashcount_t maxcount, hash_comp_t compfun,
void hash_set_allocator(hash_t * hash, hnode_alloc_t al,
hnode_free_t fr, void *context)
{
assert(hash_count(hash) == 0);
assert((al == 0 && fr == 0) || (al != 0 && fr != 0));
nassert(hash_count(hash) == 0);
nassert((al == 0 && fr == 0) || (al != 0 && fr != 0));
hash->allocnode = al ? al : hnode_alloc;
hash->freenode = fr ? fr : hnode_free;
@ -394,7 +394,7 @@ void hash_free_nodes(hash_t * hash)
void hash_free(hash_t * hash)
{
#ifdef KAZLIB_OBSOLESCENT_DEBUG
assert("call to obsolescent function hash_free()" && 0);
nassert("call to obsolescent function hash_free()" && 0);
#endif
hash_free_nodes(hash);
hash_destroy(hash);
@ -406,8 +406,8 @@ void hash_free(hash_t * hash)
void hash_destroy(hash_t * hash)
{
assert(hash_val_t_bit != 0);
assert(hash_isempty(hash));
nassert(hash_val_t_bit != 0);
nassert(hash_isempty(hash));
free(hash->table);
free(hash);
}
@ -432,7 +432,7 @@ hash_t *hash_init(hash_t * hash, hashcount_t maxcount,
if (hash_val_t_bit == 0) /* 1 */
compute_bits();
assert(is_power_of_two(nchains));
nassert(is_power_of_two(nchains));
hash->table = table; /* 2 */
hash->nchains = nchains;
@ -444,7 +444,7 @@ hash_t *hash_init(hash_t * hash, hashcount_t maxcount,
hash->mask = compute_mask(nchains); /* 4 */
clear_table(hash); /* 5 */
assert(hash_verify(hash));
nassert(hash_verify(hash));
return hash;
}
@ -486,7 +486,7 @@ void hash_scan_begin(hscan_t * scan, hash_t * hash)
* Notes:
* 1. Remember the next pointer in a temporary value so that it can be
* returned.
* 2. This assertion essentially checks whether the module has been properly
* 2. This nassertion essentially checks whether the module has been properly
* initialized. The first point of interaction with the module should be
* either hash_create() or hash_init(), both of which set hash_val_t_bit to
* a non zero value.
@ -513,7 +513,7 @@ hnode_t *hash_scan_next(hscan_t * scan)
hash_val_t chain = scan->chain + 1;
hash_val_t nchains = hash->nchains;
assert(hash_val_t_bit != 0); /* 2 */
nassert(hash_val_t_bit != 0); /* 2 */
if (next) { /* 3 */
if (next->next) { /* 4 */
@ -549,10 +549,10 @@ void hash_insert(hash_t * hash, hnode_t * node, const void *key)
{
hash_val_t hkey, chain;
assert(hash_val_t_bit != 0);
assert(node->next == NULL);
assert(hash->nodecount < hash->maxcount); /* 1 */
assert(hash_lookup(hash, key) == NULL); /* 2 */
nassert(hash_val_t_bit != 0);
nassert(node->next == NULL);
nassert(hash->nodecount < hash->maxcount); /* 1 */
nassert(hash_lookup(hash, key) == NULL); /* 2 */
if (hash->dynamic && hash->nodecount >= hash->highmark) /* 3 */
grow_table(hash);
@ -566,7 +566,7 @@ void hash_insert(hash_t * hash, hnode_t * node, const void *key)
hash->table[chain] = node;
hash->nodecount++;
assert(hash_verify(hash));
nassert(hash_verify(hash));
}
/*
@ -623,8 +623,8 @@ hnode_t *hash_delete(hash_t * hash, hnode_t * node)
hash_val_t chain;
hnode_t *hptr;
assert(hash_lookup(hash, node->key) == node); /* 1 */
assert(hash_val_t_bit != 0);
nassert(hash_lookup(hash, node->key) == node); /* 1 */
nassert(hash_val_t_bit != 0);
if (hash->dynamic && hash->nodecount <= hash->lowmark
&& hash->nodecount > INIT_SIZE)
@ -637,15 +637,15 @@ hnode_t *hash_delete(hash_t * hash, hnode_t * node)
hash->table[chain] = node->next;
} else {
while (hptr->next != node) { /* 5 */
assert(hptr != 0);
nassert(hptr != 0);
hptr = hptr->next;
}
assert(hptr->next == node);
nassert(hptr->next == node);
hptr->next = node->next;
}
hash->nodecount--;
assert(hash_verify(hash));
nassert(hash_verify(hash));
node->next = NULL; /* 6 */
return node;
@ -679,8 +679,8 @@ hnode_t *hash_scan_delete(hash_t * hash, hnode_t * node)
hash_val_t chain;
hnode_t *hptr;
assert(hash_lookup(hash, node->key) == node);
assert(hash_val_t_bit != 0);
nassert(hash_lookup(hash, node->key) == node);
nassert(hash_val_t_bit != 0);
chain = node->hkey & hash->mask;
hptr = hash->table[chain];
@ -694,7 +694,7 @@ hnode_t *hash_scan_delete(hash_t * hash, hnode_t * node)
}
hash->nodecount--;
assert(hash_verify(hash));
nassert(hash_verify(hash));
node->next = NULL;
return node;

103
list.c
View file

@ -37,17 +37,18 @@
* into proprietary software; there is no requirement for such software to
* contain a copyright notice related to this source.
*
* $Id: list.c,v 1.8 2003/06/13 13:11:49 fishwaldo Exp $
* $Id: list.c,v 1.9 2003/07/17 10:13:51 fishwaldo Exp $
* $Name: $
*/
#include <stdlib.h>
#include <stddef.h>
#include <assert.h>
#include <string.h>
#include <assert.h>
#define LIST_IMPLEMENTATION
#include "list.h"
#include "log.h"
#define next list_next
#define prev list_prev
@ -69,7 +70,7 @@
#ifdef KAZLIB_RCSID
static const char rcsid[] =
"$Id: list.c,v 1.8 2003/06/13 13:11:49 fishwaldo Exp $";
"$Id: list.c,v 1.9 2003/07/17 10:13:51 fishwaldo Exp $";
#endif
/*
@ -81,7 +82,7 @@ static const char rcsid[] =
list_t *list_init(list_t * list, listcount_t maxcount)
{
assert(maxcount != 0);
nassert(maxcount != 0);
list->nilnode.next = &list->nilnode;
list->nilnode.prev = &list->nilnode;
list->nodecount = 0;
@ -99,7 +100,7 @@ list_t *list_create(listcount_t maxcount)
{
list_t *new = malloc(sizeof *new);
if (new) {
assert(maxcount != 0);
nassert(maxcount != 0);
new->nilnode.next = &new->nilnode;
new->nilnode.prev = &new->nilnode;
new->nodecount = 0;
@ -115,7 +116,7 @@ list_t *list_create(listcount_t maxcount)
void list_destroy(list_t * list)
{
assert(list_isempty(list));
nassert(list_isempty(list));
free(list);
}
@ -170,11 +171,11 @@ void list_ins_after(list_t * list, lnode_t * new, lnode_t * this)
{
lnode_t *that = this->next;
assert(new != NULL);
assert(!list_contains(list, new));
assert(!lnode_is_in_a_list(new));
assert(this == list_nil(list) || list_contains(list, this));
assert(list->nodecount + 1 > list->nodecount);
nassert(new != NULL);
nassert(!list_contains(list, new));
nassert(!lnode_is_in_a_list(new));
nassert(this == list_nil(list) || list_contains(list, this));
nassert(list->nodecount + 1 > list->nodecount);
new->prev = this;
new->next = that;
@ -182,7 +183,7 @@ void list_ins_after(list_t * list, lnode_t * new, lnode_t * this)
this->next = new;
list->nodecount++;
assert(list->nodecount <= list->maxcount);
nassert(list->nodecount <= list->maxcount);
}
/*
@ -193,11 +194,11 @@ void list_ins_before(list_t * list, lnode_t * new, lnode_t * this)
{
lnode_t *that = this->prev;
assert(new != NULL);
assert(!list_contains(list, new));
assert(!lnode_is_in_a_list(new));
assert(this == list_nil(list) || list_contains(list, this));
assert(list->nodecount + 1 > list->nodecount);
nassert(new != NULL);
nassert(!list_contains(list, new));
nassert(!lnode_is_in_a_list(new));
nassert(this == list_nil(list) || list_contains(list, this));
nassert(list->nodecount + 1 > list->nodecount);
new->next = this;
new->prev = that;
@ -205,7 +206,7 @@ void list_ins_before(list_t * list, lnode_t * new, lnode_t * this)
this->prev = new;
list->nodecount++;
assert(list->nodecount <= list->maxcount);
nassert(list->nodecount <= list->maxcount);
}
/*
@ -217,7 +218,7 @@ lnode_t *list_delete(list_t * list, lnode_t * del)
lnode_t *next = del->next;
lnode_t *prev = del->prev;
assert(list_contains(list, del));
nassert(list_contains(list, del));
prev->next = next;
next->prev = prev;
@ -244,7 +245,7 @@ void list_process(list_t * list, void *context,
while (node != nil) {
/* check for callback function deleting */
/* the next node from under us */
assert(list_contains(list, node));
nassert(list_contains(list, node));
next = node->next;
function(list, node, context);
node = next;
@ -284,7 +285,7 @@ lnode_t *lnode_init(lnode_t * lnode, void *data)
void lnode_destroy(lnode_t * lnode)
{
assert(!lnode_is_in_a_list(lnode));
nassert(!lnode_is_in_a_list(lnode));
free(lnode);
}
@ -299,7 +300,7 @@ lnodepool_t *lnode_pool_init(lnodepool_t * pool, lnode_t * nodes,
{
listcount_t i;
assert(n != 0);
nassert(n != 0);
pool->pool = nodes;
pool->fre = nodes;
@ -321,7 +322,7 @@ lnodepool_t *lnode_pool_create(listcount_t n)
lnodepool_t *pool;
lnode_t *nodes;
assert(n != 0);
nassert(n != 0);
pool = malloc(sizeof *pool);
if (!pool)
@ -388,8 +389,8 @@ lnode_t *lnode_borrow(lnodepool_t * pool, void *data)
void lnode_return(lnodepool_t * pool, lnode_t * node)
{
assert(lnode_pool_isfrom(pool, node));
assert(!lnode_is_in_a_list(node));
nassert(lnode_pool_isfrom(pool, node));
nassert(!lnode_is_in_a_list(node));
node->next = pool->fre;
node->prev = node;
@ -424,8 +425,8 @@ void list_extract(list_t * dest, list_t * source, lnode_t * first,
{
listcount_t moved = 1;
assert(first == NULL || list_contains(source, first));
assert(last == NULL || list_contains(source, last));
nassert(first == NULL || list_contains(source, first));
nassert(last == NULL || list_contains(source, last));
if (first == NULL || last == NULL)
return;
@ -444,23 +445,23 @@ void list_extract(list_t * dest, list_t * source, lnode_t * first,
while (first != last) {
first = first->next;
assert(first != list_nil(source)); /* oops, last before first! */
nassert(first != list_nil(source)); /* oops, last before first! */
moved++;
}
/* assert no overflows */
assert(source->nodecount - moved <= source->nodecount);
assert(dest->nodecount + moved >= dest->nodecount);
/* nassert no overflows */
nassert(source->nodecount - moved <= source->nodecount);
nassert(dest->nodecount + moved >= dest->nodecount);
/* assert no weirdness */
assert(moved <= source->nodecount);
/* nassert no weirdness */
nassert(moved <= source->nodecount);
source->nodecount -= moved;
dest->nodecount += moved;
/* assert list sanity */
assert(list_verify(source));
assert(list_verify(dest));
/* nassert list sanity */
nassert(list_verify(source));
nassert(list_verify(dest));
}
@ -477,7 +478,7 @@ void list_transfer(list_t * dest, list_t * source, lnode_t * first)
listcount_t moved = 1;
lnode_t *last;
assert(first == NULL || list_contains(source, first));
nassert(first == NULL || list_contains(source, first));
if (first == NULL)
return;
@ -497,19 +498,19 @@ void list_transfer(list_t * dest, list_t * source, lnode_t * first)
moved++;
}
/* assert no overflows */
assert(source->nodecount - moved <= source->nodecount);
assert(dest->nodecount + moved >= dest->nodecount);
/* nassert no overflows */
nassert(source->nodecount - moved <= source->nodecount);
nassert(dest->nodecount + moved >= dest->nodecount);
/* assert no weirdness */
assert(moved <= source->nodecount);
/* nassert no weirdness */
nassert(moved <= source->nodecount);
source->nodecount -= moved;
dest->nodecount += moved;
/* assert list sanity */
assert(list_verify(source));
assert(list_verify(dest));
/* nassert list sanity */
nassert(list_verify(source));
nassert(list_verify(dest));
}
void list_merge(list_t * dest, list_t * sour,
@ -523,11 +524,11 @@ void list_merge(list_t * dest, list_t * sour,
return;
/* overflow check */
assert(list_count(sour) + list_count(dest) >= list_count(sour));
nassert(list_count(sour) + list_count(dest) >= list_count(sour));
/* lists must be sorted */
assert(list_is_sorted(sour, compare));
assert(list_is_sorted(dest, compare));
nassert(list_is_sorted(sour, compare));
nassert(list_is_sorted(dest, compare));
dn = list_first_priv(dest);
sn = list_first_priv(sour);
@ -570,7 +571,7 @@ void list_sort(list_t * list, int compare(const void *, const void *))
list_sort(&extra, compare);
list_merge(list, &extra, compare);
}
assert(list_is_sorted(list, compare));
nassert(list_is_sorted(list, compare));
}
lnode_t *list_find(list_t * list, const void *key,
@ -751,7 +752,7 @@ void *lnode_get(lnode_t * lnode)
lnode_t *list_next(list_t * list, lnode_t * lnode)
{
assert(list_contains(list, lnode));
nassert(list_contains(list, lnode));
if (lnode->next == list_nil(list))
return NULL;
@ -764,7 +765,7 @@ lnode_t *list_next(list_t * list, lnode_t * lnode)
lnode_t *list_prev(list_t * list, lnode_t * lnode)
{
assert(list_contains(list, lnode));
nassert(list_contains(list, lnode));
if (lnode->prev == list_nil(list))
return NULL;

38
log.c
View file

@ -20,13 +20,16 @@
** USA
**
** NeoStats CVS Identification
** $Id: log.c,v 1.10 2003/06/26 06:00:43 fishwaldo Exp $
** $Id: log.c,v 1.11 2003/07/17 10:13:51 fishwaldo Exp $
*/
#include "stats.h"
#include "conf.h"
#include "hash.h"
#include "log.h"
#ifdef HAVE_BACKTRACE
#include <execinfo.h>
#endif
const char *loglevels[10] = {
"CRITICAL",
@ -75,10 +78,8 @@ void *close_logs()
hash_scan_begin(&hs, logs);
while ((hn = hash_scan_next(&hs)) != NULL) {
logentry = hnode_get(hn);
if (logentry->flush > 0) {
fflush(logentry->logfile);
logentry->flush = 0;
}
fflush(logentry->logfile);
logentry->flush = 0;
#ifdef DEBUG
printf("Closing Logfile %s (%s)\n", logentry->name,
(char *) hnode_getkey(hn));
@ -205,3 +206,30 @@ void ResetLogs()
}
}
}
/* this is for printing out details during a assertion failure */
extern void nassert_fail(const char *expr, const char *file, const int line, const char *infunk) {
#ifdef HAVE_BACKTRACE
void *array[50];
size_t size;
char **strings;
size_t i;
/* thanks to gnulibc libary for letting me find this usefull function */
size = backtrace(array, 10);
strings = backtrace_symbols(array, size);
#endif
nlog(LOG_CRITICAL, LOG_CORE, "Assertion Failure!!!!!!!!!!!");
nlog(LOG_CRITICAL, LOG_CORE, "Function: %s (%s:%d)", infunk, file, line);
nlog(LOG_CRITICAL, LOG_CORE, "Expression: %s", expr);
#ifdef HAVE_BACKTRACE
for (i = 1; i < size; i++) {
nlog(LOG_CRITICAL, LOG_CORE, "BackTrace(%d): %s",
i - 1, strings[i]);
}
#endif
nlog(LOG_CRITICAL, LOG_CORE, "Shutting Down!");
exit(-1);
}

28
log.h
View file

@ -20,7 +20,7 @@
** USA
**
** NeoStats CVS Identification
** $Id: log.h,v 1.3 2003/05/26 09:18:28 fishwaldo Exp $
** $Id: log.h,v 1.4 2003/07/17 10:13:51 fishwaldo Exp $
*/
@ -62,6 +62,32 @@
#define LOG_MOD 1
/* this is for the neostats assert replacement. */
/* Version 2.4 and later of GCC define a magical variable _PRETTY_FUNCTION__'
which contains the name of the function currently being defined.
This is broken in G++ before version 2.6.
C9x has a similar variable called __func__, but prefer the GCC one since
it demangles C++ function names. */
# if defined __cplusplus ? __GNUC_PREREQ (2, 6) : __GNUC_PREREQ (2, 4)
# define __NASSERT_FUNCTION __PRETTY_FUNCTION__
# else
# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
# define __NASSERT_FUNCTION __func__
# else
# define __NASSERT_FUNCTION ((__const char *) 0)
# endif
# endif
extern void nassert_fail(const char *expr, const char *file, const int line, const char *infunk);
#define nassert(expr) \
(__ASSERT_VOID_CAST ((expr) ? 0 : \
(nassert_fail(__STRING(expr), __FILE__, __LINE__, __NASSERT_FUNCTION), 0)))
extern void nlog(int level, int scope, char *fmt, ...);
void *close_logs();
void init_logs();