* Removed "Log Hooks." This enabled the removal of a buf[SIZ] in lprintf,
authorArt Cancro <ajc@citadel.org>
Thu, 17 Feb 2005 16:13:59 +0000 (16:13 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 17 Feb 2005 16:13:59 +0000 (16:13 +0000)
  where it can potentially blow lots of stacks.

citadel/ChangeLog
citadel/serv_extensions.c
citadel/serv_extensions.h
citadel/serv_test.c
citadel/sysdep.c

index 7f91a024b9224d6ee6b1145a45225bc1c3b9ac36..7f16656f25053a81385dfb8ef5350042ffc48bd7 100644 (file)
@@ -1,4 +1,8 @@
  $Log$
+ Revision 640.12  2005/02/17 16:13:59  ajc
+ * Removed "Log Hooks."  This enabled the removal of a buf[SIZ] in lprintf,
+   where it can potentially blow lots of stacks.
+
  Revision 640.11  2005/02/17 03:52:16  ajc
  * setup.c: clarify some of the messages
 
@@ -6414,3 +6418,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
+
index 21d36c66804fff9367ef32c07cc464d294eb2a50..f066846d7e58fbc44e49be8594a0194aedd0344d 100644 (file)
@@ -28,7 +28,6 @@
 #include "snprintf.h"
 #endif
 
-struct LogFunctionHook *LogHookTable = NULL;
 struct CleanupFunctionHook *CleanupHookTable = NULL;
 struct SessionFunctionHook *SessionHookTable = NULL;
 struct UserFunctionHook *UserHookTable = NULL;
@@ -128,43 +127,6 @@ void initialize_server_extensions(void)
 
 
 
-void CtdlRegisterLogHook(void (*fcn_ptr) (char *), int loglevel)
-{
-
-       struct LogFunctionHook *newfcn;
-
-       newfcn = (struct LogFunctionHook *)
-           malloc(sizeof(struct LogFunctionHook));
-       newfcn->next = LogHookTable;
-       newfcn->h_function_pointer = fcn_ptr;
-       newfcn->loglevel = loglevel;
-       LogHookTable = newfcn;
-
-       lprintf(CTDL_INFO, "Registered a new logging function\n");
-}
-
-
-void CtdlUnregisterLogHook(void (*fcn_ptr) (char *), int loglevel)
-{
-       struct LogFunctionHook *cur, *p;
-
-       for (cur = LogHookTable; cur != NULL; cur = cur->next) {
-               /* This will also remove duplicates if any */
-               while (cur != NULL &&
-                               fcn_ptr == cur->h_function_pointer &&
-                               loglevel == cur->loglevel) {
-                       lprintf(CTDL_INFO, "Unregistered logging function\n");
-                       p = cur->next;
-                       if (cur == LogHookTable) {
-                               LogHookTable = p;
-                       }
-                       free(cur);
-                       cur = p;
-               }
-       }
-}
-
-
 void CtdlRegisterCleanupHook(void (*fcn_ptr) (void))
 {
 
@@ -520,17 +482,6 @@ void PerformSessionHooks(int EventType)
        }
 }
 
-void PerformLogHooks(int loglevel, char *logmsg)
-{
-       struct LogFunctionHook *fcn;
-
-       for (fcn = LogHookTable; fcn != NULL; fcn = fcn->next) {
-               if (fcn->loglevel >= loglevel) {
-                       (*fcn->h_function_pointer) (logmsg);
-               }
-       }
-}
-
 void PerformUserHooks(struct ctdluser *usbuf, int EventType)
 {
        struct UserFunctionHook *fcn;
index a165bd8c5f31cbd1047937cb09a7f0cc359ae00f..1a2ed6028606616d3618b8854b6713d53a52c1bc 100644 (file)
@@ -39,10 +39,6 @@ void initialize_server_extensions(void);
 int DLoader_Exec_Cmd(char *cmdbuf);
 char *Dynamic_Module_Init(void);
 
-void CtdlRegisterLogHook(void (*fcn_ptr)(char *), int loglevel);
-void CtdlUnregisterLogHook(void (*fcn_ptr)(char *), int loglevel);
-void PerformLogHooks(int loglevel, char *logmsg);
-
 void CtdlRegisterSessionHook(void (*fcn_ptr)(void), int EventType);
 void CtdlUnregisterSessionHook(void (*fcn_ptr)(void), int EventType);
 void PerformSessionHooks(int EventType);
index afee1effa00bd1f08e60da3c362cf2a674545539..f3bf3c59cdb12f2c8d0133ad260fb2d4d1934f0a 100644 (file)
@@ -65,12 +65,6 @@ void LoginTest(void) {
        lprintf(CTDL_DEBUG, "--- Hello, %s ---\n", CC->curr_user);
        }
 
-void LogTest(char *buf) {
-       fprintf(stderr,"%c[1m%s%c[0m", 27, buf, 27);
-       fflush(stderr);
-       }
-
-
 char *serv_test_init(void)
 {
    CtdlRegisterCleanupHook(CleanupTest);
@@ -78,6 +72,5 @@ char *serv_test_init(void)
    CtdlRegisterSessionHook(SessionStartTest, EVT_START);
    CtdlRegisterSessionHook(SessionStopTest, EVT_STOP);
    CtdlRegisterSessionHook(LoginTest, EVT_LOGIN);
-   CtdlRegisterLogHook(LogTest, 1);
    return "$Id$";
 }
index 888020f95ffe5ba8f24d1328a3a26d87aa6f351a..e8894a2fc86b6a52bf59153c5048f3d567e16219 100644 (file)
@@ -103,9 +103,6 @@ int syslog_facility = (-1);
 
 /*
  * lprintf()  ...   Write logging information
- * 
- * Note: the variable "buf" below needs to be large enough to handle any
- * log data sent through this function.  BE CAREFUL!
  */
 extern int running_as_daemon;
 static int enable_syslog = 1;
@@ -118,15 +115,7 @@ void lprintf(enum LogLevel loglevel, const char *format, ...) {
                va_end(arg_ptr);
        }
 
-       if (enable_syslog && LogHookTable == 0) return;
-
-       /* legacy output code; hooks get processed first */
-       char buf[SIZ];
-       va_start(arg_ptr, format);   
-               vsnprintf(buf, sizeof(buf), format, arg_ptr);   
-       va_end(arg_ptr);   
-       PerformLogHooks(loglevel, buf);
-
+       /* stderr output code */
        if (enable_syslog || running_as_daemon) return;
 
        /* if we run in forground and syslog is disabled, log to terminal */
@@ -141,18 +130,21 @@ void lprintf(enum LogLevel loglevel, const char *format, ...) {
                localtime_r(&unixtime, &tim);
                if (CC->cs_pid != 0) {
                        fprintf(stderr,
-                               "%04d/%02d/%02d %2d:%02d:%02d.%06ld [%3d] %s",
+                               "%04d/%02d/%02d %2d:%02d:%02d.%06ld [%3d] ",
                                tim.tm_year + 1900, tim.tm_mon + 1,
                                tim.tm_mday, tim.tm_hour, tim.tm_min,
                                tim.tm_sec, (long)tv.tv_usec,
-                               CC->cs_pid, buf);
+                               CC->cs_pid);
                } else {
                        fprintf(stderr,
-                               "%04d/%02d/%02d %2d:%02d:%02d.%06ld %s",
+                               "%04d/%02d/%02d %2d:%02d:%02d.%06ld ",
                                tim.tm_year + 1900, tim.tm_mon + 1,
                                tim.tm_mday, tim.tm_hour, tim.tm_min,
-                               tim.tm_sec, (long)tv.tv_usec, buf);
+                               tim.tm_sec, (long)tv.tv_usec);
                }
+               va_start(arg_ptr, format);   
+                       vfprintf(stderr, format, arg_ptr);   
+               va_end(arg_ptr);   
                fflush(stderr);
        }
 }