Back to index

citadel  8.12
Classes | Defines | Typedefs | Functions | Variables
serv_extensions.h File Reference
#include "server.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ServiceFunctionHook
struct  CleanupFunctionHook

Defines

#define MDBGLOG(LEVEL)   if ((LEVEL != LOG_DEBUG) || (DebugModules != 0))
#define MOD_syslog(LEVEL, FORMAT,...)
#define MODM_syslog(LEVEL, FORMAT)

Typedefs

typedef void(* CtdlDbgFunction )(const int)
typedef struct ServiceFunctionHook
typedef struct CleanupFunctionHook

Functions

void initialize_server_extensions (void)
int DLoader_Exec_Cmd (char *cmdbuf)
char * Dynamic_Module_Init (void)
void CtdlDestroySessionHooks (void)
void PerformSessionHooks (int EventType)
void CtdlDestroyUserHooks (void)
void PerformUserHooks (struct ctdluser *usbuf, int EventType)
int PerformXmsgHooks (char *, char *, char *, char *)
void CtdlDestroyXmsgHooks (void)
void CtdlDestroyMessageHook (void)
int PerformMessageHooks (struct CtdlMessage *, int EventType)
void CtdlDestroyNetprocHooks (void)
int PerformNetprocHooks (struct CtdlMessage *, char *)
void CtdlDestroyRoomHooks (void)
int PerformRoomHooks (struct ctdlroom *)
void CtdlDestroyDeleteHooks (void)
void PerformDeleteHooks (char *, long)
void CtdlDestroyCleanupHooks (void)
void CtdlDestroyProtoHooks (void)
void CtdlDestroyServiceHook (void)
void CtdlDestroySearchHooks (void)
void CtdlDestroyFixedOutputHooks (void)
int PerformFixedOutputHooks (char *, char *, int)
void CtdlRegisterDebugFlagHook (const char *Name, long len, CtdlDbgFunction F, const int *)
void CtdlSetDebugLogFacilities (const char **Str, long n)
void CtdlDestroyDebugTable (void)

Variables

int DebugModules
ServiceFunctionHookServiceHookTable
CleanupFunctionHookCleanupHookTable

Define Documentation

#define MDBGLOG (   LEVEL)    if ((LEVEL != LOG_DEBUG) || (DebugModules != 0))

Definition at line 21 of file serv_extensions.h.

#define MOD_syslog (   LEVEL,
  FORMAT,
  ... 
)
Value:
MDBGLOG(LEVEL) syslog(LEVEL,                            \
                           "Modules: " FORMAT, __VA_ARGS__)

Definition at line 23 of file serv_extensions.h.

#define MODM_syslog (   LEVEL,
  FORMAT 
)
Value:
MDBGLOG(LEVEL) syslog(LEVEL,                     \
                           "Modules: " FORMAT);

Definition at line 27 of file serv_extensions.h.


Typedef Documentation

typedef struct CleanupFunctionHook

Definition at line 51 of file serv_extensions.h.

typedef void(* CtdlDbgFunction)(const int)

Definition at line 18 of file serv_extensions.h.

typedef struct ServiceFunctionHook

Definition at line 38 of file serv_extensions.h.


Function Documentation

void CtdlDestroyCleanupHooks ( void  )

Definition at line 524 of file serv_extensions.c.

{
       CleanupFunctionHook *cur, *p;

       cur = CleanupHookTable;
       while (cur != NULL)
       {
              MODM_syslog(LOG_DEBUG, "Destroyed cleanup function\n");
              p = cur->next;
              free(cur);
              cur = p;
       }
       CleanupHookTable = NULL;
}

Here is the caller graph for this function:

void CtdlDestroyDebugTable ( void  )

Definition at line 444 of file serv_extensions.c.

{

       DeleteHash(&LogDebugEntryTable);
}

Here is the caller graph for this function:

void CtdlDestroyDeleteHooks ( void  )

Definition at line 949 of file serv_extensions.c.

{
       DeleteFunctionHook *cur, *p;

       cur = DeleteHookTable;
       while (cur != NULL)
       {
              MODM_syslog(LOG_DEBUG, "Destroyed delete function\n");
              p = cur->next;
              free(cur);
              cur = p;             
       }
       DeleteHookTable = NULL;
}

Here is the caller graph for this function:

void CtdlDestroyFixedOutputHooks ( void  )

Definition at line 1013 of file serv_extensions.c.

{
       FixedOutputHook *cur, *p;

       cur = FixedOutputTable; 
       while (cur != NULL)
       {
              MOD_syslog(LOG_DEBUG, "Destroyed fixed output function for %s\n", cur->content_type);
              p = cur->next;
              free(cur);
              cur = p;
              
       }
       FixedOutputTable = NULL;
}

Here is the caller graph for this function:

void CtdlDestroyMessageHook ( void  )

Definition at line 778 of file serv_extensions.c.

{
       MessageFunctionHook *cur, *p;

       cur = MessageHookTable; 
       while (cur != NULL)
       {
              MOD_syslog(LOG_DEBUG, "Destroyed message function (type %d)\n", cur->eventtype);
              p = cur->next;
              free(cur);
              cur = p;
       }
       MessageHookTable = NULL;
}

Here is the caller graph for this function:

void CtdlDestroyNetprocHooks ( void  )

Definition at line 893 of file serv_extensions.c.

{
       NetprocFunctionHook *cur, *p;

       cur = NetprocHookTable;
       while (cur != NULL)
       {
              MODM_syslog(LOG_DEBUG, "Destroyed netproc function\n");
              p = cur->next;
              free(cur);
              cur = p;
       }
       NetprocHookTable = NULL;
}

Here is the caller graph for this function:

void CtdlDestroyProtoHooks ( void  )

Definition at line 473 of file serv_extensions.c.

{

       DeleteHash(&ProtoHookList);
}

Here is the caller graph for this function:

void CtdlDestroyRoomHooks ( void  )

Definition at line 836 of file serv_extensions.c.

{
       RoomFunctionHook *cur, *p;

       cur = RoomHookTable;
       while (cur != NULL)
       {
              MODM_syslog(LOG_DEBUG, "Destroyed room function\n");
              p = cur->next;
              free(cur);
              cur = p;
       }
       RoomHookTable = NULL;
}

Here is the caller graph for this function:

void CtdlDestroySearchHooks ( void  )

Definition at line 1305 of file serv_extensions.c.

{
        SearchFunctionHook *cur, *p;

       cur = SearchFunctionHookTable;
       SearchFunctionHookTable = NULL;
        while (cur != NULL) {
              p = cur->next;
              free(cur);
              cur = p;
       }
}

Here is the caller graph for this function:

void CtdlDestroyServiceHook ( void  )

Definition at line 1236 of file serv_extensions.c.

{
       ServiceFunctionHook *cur, *p;

       cur = ServiceHookTable;
       while (cur != NULL)
       {
              close(cur->msock);
              if (cur->sockpath) {
                     MOD_syslog(LOG_INFO, "Closed UNIX domain socket %s\n",
                               cur->sockpath);
                     unlink(cur->sockpath);
              } else if (cur->tcp_port) {
                     MOD_syslog(LOG_INFO, "Closed TCP port %d\n", cur->tcp_port);
              } else {
                     MOD_syslog(LOG_INFO, "Destroyed service \"%s\"\n", cur->ServiceName);
              }
              p = cur->next;
              free(cur);
              cur = p;
       }
       ServiceHookTable = NULL;
}

Here is the caller graph for this function:

void CtdlDestroySessionHooks ( void  )

Definition at line 653 of file serv_extensions.c.

{
       SessionFunctionHook *cur, *p;

       cur = SessionHookTable;
       while (cur != NULL)
       {
              MODM_syslog(LOG_DEBUG, "Destroyed session function\n");
              p = cur->next;
              free(cur);
              cur = p;
       }
       SessionHookTable = NULL;
}

Here is the caller graph for this function:

void CtdlDestroyUserHooks ( void  )

Definition at line 715 of file serv_extensions.c.

{
       UserFunctionHook *cur, *p;

       cur = UserHookTable;
       while (cur != NULL)
       {
              MODM_syslog(LOG_DEBUG, "Destroyed user function \n");
              p = cur->next;
              free(cur);
              cur = p;
       }
       UserHookTable = NULL;
}

Here is the caller graph for this function:

void CtdlDestroyXmsgHooks ( void  )

Definition at line 1090 of file serv_extensions.c.

{
       XmsgFunctionHook *cur, *p;

       cur = XmsgHookTable;
       while (cur != NULL)
       {
              MOD_syslog(LOG_DEBUG, "Destroyed x-msg function "
                     "(priority %d)\n", cur->order);
              p = cur->next;
                     
              free(cur);
              cur = p;
       }
       XmsgHookTable = NULL;
}

Here is the caller graph for this function:

void CtdlRegisterDebugFlagHook ( const char *  Name,
long  len,
CtdlDbgFunction  F,
const int *   
)

Definition at line 339 of file serv_extensions.c.

{
       LogDebugEntry *E;
       if (LogDebugEntryTable == NULL)
              LogDebugEntryTable = NewHash(1, NULL);
       E = (LogDebugEntry*) malloc(sizeof(LogDebugEntry));
       E->F = F;
       E->Name = Name;
       E->Len = Len;
       E->LogP = LogP;
       Put(LogDebugEntryTable, Name, Len, E, NULL);
       
}

Here is the caller graph for this function:

void CtdlSetDebugLogFacilities ( const char **  Str,
long  n 
)

Definition at line 352 of file serv_extensions.c.

{
       StrBuf *Token = NULL;
       StrBuf *Buf = NULL;
       const char *ch;
       int i;
       int DoAll = 0;
       void *vptr;

       for (i=0; i < n; i++){
              if ((Str[i] != NULL) && !IsEmptyStr(Str[i])) {
                     if (strcmp(Str[i], "all") == 0) {
                            DoAll = 1;
                            continue;
                     }
                     Buf = NewStrBufPlain(Str[i], -1);
                     ch = NULL;
                     if (Token == NULL)
                            Token = NewStrBufPlain(NULL, StrLength(Buf));
                     while ((ch != StrBufNOTNULL) &&
                            StrBufExtract_NextToken(Token, Buf, &ch, ',')) {
                            if (GetHash(LogDebugEntryTable, SKEY(Token), &vptr) && 
                                (vptr != NULL))
                            {
                                   LogDebugEntry *E = (LogDebugEntry*)vptr;
                                   E->F(1);
                            }
                     }
              }
              FreeStrBuf(&Buf);
       }
       FreeStrBuf(&Token);
       if (DoAll) {
              long HKLen;
              const char *ch;
              HashPos *Pos;

              Pos = GetNewHashPos(LogDebugEntryTable, 0);
              while (GetNextHashPos(LogDebugEntryTable, Pos, &HKLen, &ch, &vptr)) {
                     LogDebugEntry *E = (LogDebugEntry*)vptr;
                     E->F(1);
              }

              DeleteHashPos(&Pos);
       }
}

Here is the caller graph for this function:

int DLoader_Exec_Cmd ( char *  cmdbuf)

Definition at line 310 of file serv_extensions.c.

{
       void *vP;
       ProtoFunctionHook *p;

       if (GetHash(ProtoHookList, cmdbuf, 4, &vP) && (vP != NULL)) {
              p = (ProtoFunctionHook*) vP;
              p->handler(&cmdbuf[5]);
              return 1;
       }
       return 0;
}

Here is the caller graph for this function:

char* Dynamic_Module_Init ( void  )
void PerformDeleteHooks ( char *  ,
long   
)

Definition at line 1421 of file serv_extensions.c.

{
       DeleteFunctionHook *fcn;

       for (fcn = DeleteHookTable; fcn != NULL; fcn = fcn->next) {
              (*fcn->h_function_pointer) (room, msgnum);
       }
}

Here is the caller graph for this function:

int PerformFixedOutputHooks ( char *  ,
char *  ,
int   
)

Definition at line 1030 of file serv_extensions.c.

{
       FixedOutputHook *fcn;

       for (fcn = FixedOutputTable; fcn != NULL; fcn = fcn->next) {
              if (!strcasecmp(content_type, fcn->content_type)) {
                     (*fcn->h_function_pointer) (content, content_length);
                     return(1);
              }
       }
       return(0);
}

Here is the caller graph for this function:

int PerformMessageHooks ( struct CtdlMessage ,
int  EventType 
)

Definition at line 1357 of file serv_extensions.c.

{
       MessageFunctionHook *fcn = NULL;
       int total_retval = 0;

       /* Other code may elect to protect this message from server-side
        * handlers; if this is the case, don't do anything.
       MOD_syslog(LOG_DEBUG, "** Event type is %d, flags are %d\n", EventType, msg->cm_flags);
        */
       if (msg->cm_flags & CM_SKIP_HOOKS) {
              MODM_syslog(LOG_DEBUG, "Skipping hooks\n");
              return(0);
       }

       /* Otherwise, run all the hooks appropriate to this event type.
        */
       for (fcn = MessageHookTable; fcn != NULL; fcn = fcn->next) {
              if (fcn->eventtype == EventType) {
                     total_retval = total_retval + (*fcn->h_function_pointer) (msg);
              }
       }

       /* Return the sum of the return codes from the hook functions.  If
        * this is an EVT_BEFORESAVE event, a nonzero return code will cause
        * the save operation to abort.
        */
       return total_retval;
}

Here is the caller graph for this function:

int PerformNetprocHooks ( struct CtdlMessage ,
char *   
)

Definition at line 1404 of file serv_extensions.c.

{
       NetprocFunctionHook *fcn;
       int total_retval = 0;

       for (fcn = NetprocHookTable; fcn != NULL; fcn = fcn->next) {
              total_retval = total_retval +
                     (*fcn->h_function_pointer) (msg, target_room);
       }

       /* Return the sum of the return codes from the hook functions.
        * A nonzero return code will cause the message to *not* be imported.
        */
       return total_retval;
}

Here is the caller graph for this function:

int PerformRoomHooks ( struct ctdlroom )

Definition at line 1387 of file serv_extensions.c.

{
       RoomFunctionHook *fcn;
       int total_retval = 0;

       MOD_syslog(LOG_DEBUG, "Performing room hooks for <%s>\n", target_room->QRname);

       for (fcn = RoomHookTable; fcn != NULL; fcn = fcn->next) {
              total_retval = total_retval + (*fcn->fcn_ptr) (target_room);
       }

       /* Return the sum of the return codes from the hook functions.
        */
       return total_retval;
}

Here is the caller graph for this function:

void PerformSessionHooks ( int  EventType)

Definition at line 1332 of file serv_extensions.c.

{
       SessionFunctionHook *fcn = NULL;

       for (fcn = SessionHookTable; fcn != NULL; fcn = fcn->next) {
              if (fcn->eventtype == EventType) {
                     if (EventType == EVT_TIMER) {
                            pthread_setspecific(MyConKey, NULL);      /* for every hook */
                     }
                     (*fcn->h_function_pointer) ();
              }
       }
}

Here is the caller graph for this function:

void PerformUserHooks ( struct ctdluser usbuf,
int  EventType 
)

Definition at line 1346 of file serv_extensions.c.

{
       UserFunctionHook *fcn = NULL;

       for (fcn = UserHookTable; fcn != NULL; fcn = fcn->next) {
              if (fcn->eventtype == EventType) {
                     (*fcn->h_function_pointer) (usbuf);
              }
       }
}

Here is the caller graph for this function:

int PerformXmsgHooks ( char *  ,
char *  ,
char *  ,
char *   
)

Definition at line 1434 of file serv_extensions.c.

{
       XmsgFunctionHook *fcn;
       int total_sent = 0;
       int p;

       for (p=0; p<MAX_XMSG_PRI; ++p) {
              for (fcn = XmsgHookTable; fcn != NULL; fcn = fcn->next) {
                     if (fcn->order == p) {
                            total_sent +=
                                   (*fcn->h_function_pointer)
                                          (sender, sender_email, recp, msg);
                     }
              }
              /* Break out of the loop if a higher-priority function
               * successfully delivered the message.  This prevents duplicate
               * deliveries to local users simultaneously signed onto
               * remote services.
               */
              if (total_sent) break;
       }
       return total_sent;
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 186 of file serv_extensions.c.

Definition at line 49 of file serv_extensions.c.

Definition at line 194 of file serv_extensions.c.