hooks.c File Reference

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <strutil.h>
#include <configfile.h>
#include <funprotos.h>

Include dependency graph for hooks.c:

Go to the source code of this file.

Functions

int addLogHook (hookfn_t hf)
void processLogHooks (char *buf)
int addLoopHook (loopfn_t hf)
void processLoopHooks (char *buf)

Variables

static hookfn_tloghooks = NULL
static int hookcnt = 0
static loopfn_tloophooks = NULL
static int loopcnt = 0


Function Documentation

int addLogHook hookfn_t  hf  ) 
 

addLogHook adds a pointer to a hook function to the list of log hooks to be called during the process of scanning logs. This is to allow loadable modules to hook into the log scanning process.

Definition at line 28 of file hooks.c.

References hookcnt, and loghooks.

00028                             {
00029      int hp = hookcnt ++;
00030      if((loghooks = realloc(loghooks,(sizeof(hookfn_t)*hookcnt))) == NULL)
00031           return -1;
00032      loghooks[hp] = hf;
00033      return 0;
00034 }

int addLoopHook loopfn_t  hf  ) 
 

addLoopHook adds a pointer to a loop hook function to the list of loop hooks to be called during the process of scanning logs. This is to allow loadable modules to hook into the main execution loop

Definition at line 51 of file hooks.c.

References hookcnt, and loophooks.

00051                              {
00052      int hp = hookcnt ++;
00053      if((loophooks = realloc(loophooks,(sizeof(hookfn_t)*hookcnt))) == NULL)
00054           return -1;
00055      loophooks[hp] = hf;
00056      return 0;
00057 }

void processLogHooks char *  buf  ) 
 

walk along the loghooks and execute each loghook function in turn

Definition at line 38 of file hooks.c.

References hookcnt, and loghooks.

Referenced by secwatch().

00038                                 {
00039      int i;
00040      if(loghooks == NULL) 
00041           return;
00042      
00043      for(i = 0; i < hookcnt; i++) 
00044           loghooks[i](0,buf);
00045 }

void processLoopHooks char *  buf  ) 
 

walk along the loophooks and execute each loghook function in turn

Definition at line 61 of file hooks.c.

References hookcnt, and loophooks.

00061                                  {
00062      int i;
00063      if(loophooks == NULL) 
00064           return;
00065      
00066      for(i = 0; i < hookcnt; i++) 
00067           loophooks[i]();
00068 }


Variable Documentation

int hookcnt = 0 [static]
 

Definition at line 19 of file hooks.c.

Referenced by addLogHook(), addLoopHook(), processLogHooks(), and processLoopHooks().

hookfn_t* loghooks = NULL [static]
 

Definition at line 18 of file hooks.c.

Referenced by addLogHook(), and processLogHooks().

int loopcnt = 0 [static]
 

Definition at line 22 of file hooks.c.

loopfn_t* loophooks = NULL [static]
 

Definition at line 21 of file hooks.c.

Referenced by addLoopHook(), and processLoopHooks().


Generated on Tue Oct 31 10:17:29 2006 for secwatch by  doxygen 1.4.6