Mercurial > noffle
comparison src/filter.c @ 281:5eece4dfd945 noffle
[svn] * src/log.c,src/log.h: Add Log_fatal() for reporting fatal errors
and exiting, Log_gdbm_fatal() for the the same but specifically as
a GDBM error reporting function, and a new log debug level AUTH for
a forthcoming authentication mechanism.
* src/database.c,src/group.c: Provide new gdbm error function to all
gdbm opens.
* src/noffle.c: Add atexit() to always close databases on a program-
inspired exit.
* src/content.c,src/dynamicstring.c,src/fetchlist.c,src/filter.c,
src/itemlist.c,src/log.c,src/log.h,src/over.c,src/protocol.h,
src/request.c,src/util.c: Use Log_fatal where appropriate.
| author | bears |
|---|---|
| date | Fri, 27 Dec 2002 21:48:25 +0000 |
| parents | 0340b9c17edc |
| children | 21300895412f |
comparison
equal
deleted
inserted
replaced
| 280:9c54bf672ca1 | 281:5eece4dfd945 |
|---|---|
| 1 /* | 1 /* |
| 2 filter.c | 2 filter.c |
| 3 | 3 |
| 4 Article filtering. | 4 Article filtering. |
| 5 | 5 |
| 6 $Id: filter.c 381 2002-05-14 14:25:45Z mirkol $ | 6 $Id: filter.c 413 2002-12-27 21:48:25Z bears $ |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #if HAVE_CONFIG_H | 9 #if HAVE_CONFIG_H |
| 10 #include <config.h> | 10 #include <config.h> |
| 11 #endif | 11 #endif |
| 218 filter.filters = | 218 filter.filters = |
| 219 ( const Filter ** ) realloc( filter.filters, | 219 ( const Filter ** ) realloc( filter.filters, |
| 220 ( filter.maxFilters + 5 ) | 220 ( filter.maxFilters + 5 ) |
| 221 * sizeof( Filter * ) ); | 221 * sizeof( Filter * ) ); |
| 222 if ( filter.filters == NULL ) | 222 if ( filter.filters == NULL ) |
| 223 { | 223 Log_fatal( "Could not realloc filter list" ); |
| 224 Log_err( "Could not realloc filter list" ); | |
| 225 exit( EXIT_FAILURE ); | |
| 226 } | |
| 227 filter.maxFilters += 5; | 224 filter.maxFilters += 5; |
| 228 } | 225 } |
| 229 filter.filters[ filter.nFilters++ ] = f; | 226 filter.filters[ filter.nFilters++ ] = f; |
| 230 } | 227 } |
| 231 | 228 |
| 346 new_Filter( void ) | 343 new_Filter( void ) |
| 347 { | 344 { |
| 348 Filter *f; | 345 Filter *f; |
| 349 | 346 |
| 350 if ( ! ( f = ( Filter * ) malloc( sizeof( Filter ) ) ) ) | 347 if ( ! ( f = ( Filter * ) malloc( sizeof( Filter ) ) ) ) |
| 351 { | 348 Log_fatal( "Cannot allocate Filter" ); |
| 352 Log_err( "Cannot allocate Filter" ); | |
| 353 exit( EXIT_FAILURE ); | |
| 354 } | |
| 355 f->nRules = 0; | 349 f->nRules = 0; |
| 356 f->maxRules = 0; | 350 f->maxRules = 0; |
| 357 f->rules = NULL; | 351 f->rules = NULL; |
| 358 f->action = FILTER_DEFAULT; | 352 f->action = FILTER_DEFAULT; |
| 359 return f; | 353 return f; |
| 419 ( FilterRule * ) realloc( f->rules, | 413 ( FilterRule * ) realloc( f->rules, |
| 420 ( f->maxRules + 5 ) | 414 ( f->maxRules + 5 ) |
| 421 * sizeof( FilterRule ) ); | 415 * sizeof( FilterRule ) ); |
| 422 | 416 |
| 423 if ( f->rules == NULL ) | 417 if ( f->rules == NULL ) |
| 424 { | 418 Log_fatal( "Could not realloc rule list" ); |
| 425 Log_err( "Could not realloc rule list" ); | |
| 426 exit( EXIT_FAILURE ); | |
| 427 } | |
| 428 f->maxRules += 5; | 419 f->maxRules += 5; |
| 429 } | 420 } |
| 430 f->rules[ f->nRules++ ] = rule; | 421 f->rules[ f->nRules++ ] = rule; |
| 431 } | 422 } |
| 432 | 423 |
