Removed the logging facility from citserver, use syslog instead
authorArt Cancro <ajc@citadel.org>
Mon, 17 Jan 2011 17:39:59 +0000 (12:39 -0500)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 4 Sep 2011 12:43:08 +0000 (12:43 +0000)
added libevent modified files.

77 files changed:
citadel/citadel.h
citadel/citserver.c
citadel/clientsocket.c
citadel/context.c
citadel/context.h
citadel/control.c
citadel/database.c
citadel/docs/citadel.html
citadel/domain.c
citadel/ecrash.c
citadel/euidindex.c
citadel/event_client.c
citadel/event_client.h
citadel/file_ops.c
citadel/housekeeping.c
citadel/ical_dezonify.c
citadel/include/ctdl_module.h
citadel/internet_addressing.c
citadel/ldap.c
citadel/locate_host.c
citadel/modules/c-ares-dns/serv_c-ares-dns.c
citadel/modules/calendar/serv_calendar.c
citadel/modules/checkpoint/serv_checkpoint.c
citadel/modules/clamav/serv_virus.c
citadel/modules/crypto/serv_crypto.c
citadel/modules/dspam/serv_dspam.c
citadel/modules/eventclient/serv_eventclient.c
citadel/modules/expire/serv_expire.c
citadel/modules/extnotify/extnotify_main.c
citadel/modules/extnotify/funambol65.c
citadel/modules/fulltext/ft_wordbreaker.c
citadel/modules/fulltext/serv_fulltext.c
citadel/modules/imap/imap_fetch.c
citadel/modules/imap/imap_list.c
citadel/modules/imap/imap_misc.c
citadel/modules/imap/imap_tools.c
citadel/modules/imap/serv_imap.c
citadel/modules/listsub/serv_listsub.c
citadel/modules/managesieve/serv_managesieve.c
citadel/modules/migrate/serv_migrate.c
citadel/modules/network/serv_network.c
citadel/modules/notes/serv_notes.c
citadel/modules/openid/serv_openid_rp.c
citadel/modules/pop3/serv_pop3.c
citadel/modules/pop3client/serv_pop3client.c
citadel/modules/rssclient/rss_atom_parser.c
citadel/modules/rssclient/serv_rssclient.c
citadel/modules/sieve/serv_sieve.c
citadel/modules/smtp/serv_smtp.c
citadel/modules/smtp/serv_smtpclient.c
citadel/modules/smtp/serv_smtpeventclient.c
citadel/modules/smtp/serv_smtpqueue.c
citadel/modules/smtp/smtp_clienthandlers.c
citadel/modules/smtp/smtp_util.c
citadel/modules/spam/serv_spam.c
citadel/modules/test/serv_test.c
citadel/modules/upgrade/serv_upgrade.c
citadel/modules/urldeshortener/serv_expand_shorter_urls.c
citadel/modules/vcard/serv_vcard.c
citadel/modules/wiki/serv_wiki.c
citadel/modules/xmpp/serv_xmpp.c
citadel/modules/xmpp/xmpp_presence.c
citadel/modules/xmpp/xmpp_query_namespace.c
citadel/modules/xmpp/xmpp_queue.c
citadel/msgbase.c
citadel/parsedate.c
citadel/room_ops.c
citadel/scripts/mk_module_init.sh
citadel/serv_extensions.c
citadel/server_main.c
citadel/sysdep.c
citadel/sysdep_decls.h
citadel/textclient/citadel.c
citadel/threads.c
citadel/user_ops.c
citadel/user_ops.h
webcit/webserver.c

index 5b4831b91a5138e36a9173419d9b440d34443e90..5e9d6fc8f1942ca35984517ab0224244b5526f94 100644 (file)
@@ -279,7 +279,7 @@ enum {
 #define SIEVECONFIG    "application/x-citadel-sieve-config"
 #define XMPPMORTUARY   "application/x-citadel-xmpp-mortuary"
 
-#define TRACE  CtdlLogPrintf(CTDL_DEBUG, "Checkpoint: %s, %d\n", __FILE__, __LINE__)
+#define TRACE  syslog(LOG_DEBUG, "Checkpoint: %s, %d\n", __FILE__, __LINE__)
 
 #ifndef LONG_MAX
 #define LONG_MAX 2147483647L
index 71ec7e05e935dfcf5a1b945fdc9729ba367c61d8..e1843eb209c2396a3684203f93eabc6ffb994d21 100644 (file)
@@ -1,9 +1,9 @@
 /* 
  * Main source module for the Citadel server
  *
- * Copyright (c) 1987-2010 by the citadel.org team
+ * Copyright (c) 1987-2011 by the citadel.org team
  *
- * This program is free software; you can redistribute it and/or modify
+ * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
@@ -15,7 +15,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
 #include "sysdep.h"
@@ -98,9 +98,9 @@ void cit_backtrace(void)
        strings = backtrace_symbols(stack_frames, size);
        for (i = 0; i < size; i++) {
                if (strings != NULL)
-                       CtdlLogPrintf(CTDL_ALERT, "%s\n", strings[i]);
+                       syslog(LOG_ALERT, "%s\n", strings[i]);
                else
-                       CtdlLogPrintf(CTDL_ALERT, "%p\n", stack_frames[i]);
+                       syslog(LOG_ALERT, "%p\n", stack_frames[i]);
        }
        free(strings);
 #endif
@@ -126,7 +126,7 @@ void cit_oneline_backtrace(void)
                                StrBufAppendPrintf(Buf, "%p : ", stack_frames[i]);
                }
                free(strings);
-               CtdlLogPrintf(CTDL_ALERT, "%s\n", ChrPtr(Buf));
+               syslog(LOG_ALERT, "%s\n", ChrPtr(Buf));
                FreeStrBuf(&Buf);
        }
 #endif
@@ -147,9 +147,9 @@ void cit_panic_backtrace(int SigNum)
        strings = backtrace_symbols(stack_frames, size);
        for (i = 0; i < size; i++) {
                if (strings != NULL)
-                       CtdlLogPrintf(CTDL_ALERT, "%s\n", strings[i]);
+                       syslog(LOG_ALERT, "%s\n", strings[i]);
                else
-                       CtdlLogPrintf(CTDL_ALERT, "%p\n", stack_frames[i]);
+                       syslog(LOG_ALERT, "%p\n", stack_frames[i]);
        }
        free(strings);
 #endif
@@ -166,10 +166,10 @@ void master_startup(void) {
        struct ctdlroom qrbuf;
        int rv;
        
-       CtdlLogPrintf(CTDL_DEBUG, "master_startup() started\n");
+       syslog(LOG_DEBUG, "master_startup() started\n");
        time(&server_startup_time);
 
-       CtdlLogPrintf(CTDL_INFO, "Opening databases\n");
+       syslog(LOG_INFO, "Opening databases\n");
        open_databases();
 
        ctdl_thread_internal_init_tsd();
@@ -178,7 +178,7 @@ void master_startup(void) {
        
        check_ref_counts();
 
-       CtdlLogPrintf(CTDL_INFO, "Creating base rooms (if necessary)\n");
+       syslog(LOG_INFO, "Creating base rooms (if necessary)\n");
        CtdlCreateRoom(config.c_baseroom,       0, "", 0, 1, 0, VIEW_BBS);
        CtdlCreateRoom(AIDEROOM,                3, "", 0, 1, 0, VIEW_BBS);
        CtdlCreateRoom(SYSCONFIGROOM,           3, "", 0, 1, 0, VIEW_BBS);
@@ -196,7 +196,7 @@ void master_startup(void) {
                 CtdlPutRoomLock(&qrbuf);
         }
 
-       CtdlLogPrintf(CTDL_INFO, "Seeding the pseudo-random number generator...\n");
+       syslog(LOG_INFO, "Seeding the pseudo-random number generator...\n");
        urandom = fopen("/dev/urandom", "r");
        if (urandom != NULL) {
                rv = fread(&seed, sizeof seed, 1, urandom);
@@ -209,12 +209,12 @@ void master_startup(void) {
        srand(seed);
        srandom(seed);
 
-       CtdlLogPrintf(CTDL_INFO, "Initializing ipgm secret\n");
+       syslog(LOG_INFO, "Initializing ipgm secret\n");
        get_config();
        config.c_ipgm_secret = rand();
        put_config();
 
-       CtdlLogPrintf(CTDL_DEBUG, "master_startup() finished\n");
+       syslog(LOG_DEBUG, "master_startup() finished\n");
 }
 
 
@@ -240,7 +240,7 @@ void master_cleanup(int exitcode) {
        sysdep_master_cleanup();
        
        /* Close databases */
-       CtdlLogPrintf(CTDL_INFO, "Closing databases\n");
+       syslog(LOG_INFO, "Closing databases\n");
        close_databases();
 
 #ifdef DEBUG_MEMORY_LEAKS
@@ -249,7 +249,7 @@ void master_cleanup(int exitcode) {
 
        /* If the operator requested a halt but not an exit, halt here. */
        if (shutdown_and_halt) {
-               CtdlLogPrintf(CTDL_NOTICE, "citserver: Halting server without exiting.\n");
+               syslog(LOG_NOTICE, "citserver: Halting server without exiting.\n");
                fflush(stdout); fflush(stderr);
                while(1) {
                        sleep(32767);
@@ -259,7 +259,7 @@ void master_cleanup(int exitcode) {
        release_control();
 
        /* Now go away. */
-       CtdlLogPrintf(CTDL_NOTICE, "citserver: Exiting with status %d\n", exitcode);
+       syslog(LOG_NOTICE, "citserver: Exiting with status %d\n", exitcode);
        fflush(stdout); fflush(stderr);
        
        if (restart_server != 0)
@@ -390,14 +390,14 @@ int is_public_client(void)
         */
        if (stat(public_clients_file, &statbuf) != 0) {
                /* No public_clients file exists, so bail out */
-               CtdlLogPrintf(CTDL_WARNING, "Warning: '%s' does not exist\n", 
+               syslog(LOG_WARNING, "Warning: '%s' does not exist\n", 
                                public_clients_file);
                return(0);
        }
 
        if (statbuf.st_mtime > pc_timestamp) {
                begin_critical_section(S_PUBLIC_CLIENTS);
-               CtdlLogPrintf(CTDL_INFO, "Loading %s\n", public_clients_file);
+               syslog(LOG_INFO, "Loading %s\n", public_clients_file);
 
                public_clientspos = &public_clients[0];
                public_clientsend = public_clientspos + SIZ;
@@ -443,18 +443,18 @@ int is_public_client(void)
                end_critical_section(S_PUBLIC_CLIENTS);
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Checking whether %s is a local or public client\n",
+       syslog(LOG_DEBUG, "Checking whether %s is a local or public client\n",
                CC->cs_addr);
        for (i=0; i<num_parms(public_clients); ++i) {
                extract_token(addrbuf, public_clients, i, '|', sizeof addrbuf);
                if (!strcasecmp(CC->cs_addr, addrbuf)) {
-                       CtdlLogPrintf(CTDL_DEBUG, "... yes it is.\n");
+                       syslog(LOG_DEBUG, "... yes it is.\n");
                        return(1);
                }
        }
 
        /* No hits.  This is not a public client. */
-       CtdlLogPrintf(CTDL_DEBUG, "... no it isn't.\n");
+       syslog(LOG_DEBUG, "... no it isn't.\n");
        return(0);
 }
 
@@ -497,7 +497,7 @@ void cmd_iden(char *argbuf)
                CC->cs_addr[0] = 0;
        }
 
-       CtdlLogPrintf(CTDL_NOTICE, "Client %d/%d/%01d.%02d (%s) from %s\n",
+       syslog(LOG_NOTICE, "Client %d/%d/%01d.%02d (%s) from %s\n",
                dev_code,
                cli_code,
                (rev_level / 100),
@@ -789,7 +789,7 @@ void cmd_ipgm(char *argbuf)
        else {
                sleep(5);
                cprintf("%d Authentication failed.\n", ERROR + PASSWORD_REQUIRED);
-               CtdlLogPrintf(CTDL_ERR, "Warning: ipgm authentication failed.\n");
+               syslog(LOG_ERR, "Warning: ipgm authentication failed.\n");
                CC->kill_me = 1;
        }
 }
@@ -814,7 +814,7 @@ void cmd_down(char *argbuf) {
                }
                if ((restart_server > 0) && !running_as_daemon)
                {
-                       CtdlLogPrintf(CTDL_ERR, "The user requested restart, but not running as daemon! Geronimooooooo!\n");
+                       syslog(LOG_ERR, "The user requested restart, but not running as daemon! Geronimooooooo!\n");
                        Reply = "%d Warning: citserver is not running in daemon mode and is therefore unlikely to restart automatically.\n";
                        state = ERROR;
                }
@@ -859,7 +859,7 @@ void cmd_scdn(char *argbuf)
                restart_server = 1;
                if (!running_as_daemon)
                {
-                       CtdlLogPrintf(CTDL_ERR, "The user requested restart, but not running as deamon! Geronimooooooo!\n");
+                       syslog(LOG_ERR, "The user requested restart, but not running as deamon! Geronimooooooo!\n");
                        Reply = "%d %d Warning, not running in deamon mode. maybe we will come up again, but don't lean on it.\n";
                        state = ERROR;
                }
@@ -955,7 +955,7 @@ void begin_session(CitContext *con)
                        
                        /*fill in the user data structure */
                        if(getsockopt(con->client_socket, SOL_SOCKET, SO_PEERCRED, &credentials, &ucred_length)) {
-                               CtdlLogPrintf(CTDL_NOTICE, "could obtain credentials from unix domain socket");
+                               syslog(LOG_NOTICE, "could obtain credentials from unix domain socket");
                                
                        }
                        else {          
@@ -991,10 +991,10 @@ void begin_session(CitContext *con)
        }
 
        if (!CC->is_local_socket) {
-               CtdlLogPrintf(CTDL_NOTICE, "Session (%s) started from %s (%s).\n", con->ServiceName, con->cs_host, con->cs_addr);
+               syslog(LOG_NOTICE, "Session (%s) started from %s (%s).\n", con->ServiceName, con->cs_host, con->cs_addr);
        }
        else {
-               CtdlLogPrintf(CTDL_NOTICE, "Session (%s) started via local socket UID:%d.\n", con->ServiceName, con->cs_UDSclientUID);
+               syslog(LOG_NOTICE, "Session (%s) started via local socket UID:%d.\n", con->ServiceName, con->cs_UDSclientUID);
        }
 
        /* Run any session startup routines registered by loadable modules */
@@ -1056,7 +1056,7 @@ void do_command_loop(void) {
        time(&CC->lastcmd);
        memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
        if (client_getln(cmdbuf, sizeof cmdbuf) < 1) {
-               CtdlLogPrintf(CTDL_ERR, "Client disconnected: ending session.\n");
+               syslog(LOG_ERR, "Client disconnected: ending session.\n");
                CC->kill_me = 1;
                CtdlThreadName(old_name);
                return;
@@ -1064,10 +1064,10 @@ void do_command_loop(void) {
 
        /* Log the server command, but don't show passwords... */
        if ( (strncasecmp(cmdbuf, "PASS", 4)) && (strncasecmp(cmdbuf, "SETP", 4)) ) {
-               CtdlLogPrintf(CTDL_INFO, "CtdlCommand [%s] [%s] %s\n", CTDLUSERIP, CC->curr_user, cmdbuf);
+               syslog(LOG_INFO, "CtdlCommand [%s] [%s] %s\n", CTDLUSERIP, CC->curr_user, cmdbuf);
        }
        else {
-               CtdlLogPrintf(CTDL_INFO, "CtdlCommand [%s] [%s] <password command hidden from log>\n", CTDLUSERIP, CC->curr_user);
+               syslog(LOG_INFO, "CtdlCommand [%s] [%s] <password command hidden from log>\n", CTDLUSERIP, CC->curr_user);
        }
 
        buffer_output();
index 49cfd54ef7c68fa03b590aad4347549e13213ea5..e4044d630c9d892b63a44104e7b43c07f0908391 100644 (file)
@@ -4,7 +4,7 @@
  * sockets for the Citadel client; for that you must look in ipc_c_tcp.c
  * (which, uncoincidentally, bears a striking similarity to this file).
  *
- * Copyright (c) 1987-2010 by the citadel.org team
+ * Copyright (c) 1987-2011 by the citadel.org team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -36,6 +36,7 @@
 #include <pwd.h>
 #include <errno.h>
 #include <stdarg.h>
+#include <syslog.h>
 #include <libcitadel.h>
 #include "citadel.h"
 #include "server.h"
@@ -85,7 +86,7 @@ int sock_connect(char *host, char *service)
 
        rc = getaddrinfo(host, service, &hints, &res);
        if (rc != 0) {
-               CtdlLogPrintf(CTDL_ERR, "%s: %s\n", host, gai_strerror(rc));
+               syslog(LOG_ERR, "%s: %s\n", host, gai_strerror(rc));
                return(-1);
        }
 
@@ -95,7 +96,7 @@ int sock_connect(char *host, char *service)
        for (ai = res; ai != NULL; ai = ai->ai_next) {
                sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
                if (sock < 0) {
-                       CtdlLogPrintf(CTDL_ERR, "socket() failed: %s\n", strerror(errno));
+                       syslog(LOG_ERR, "socket() failed: %s\n", strerror(errno));
                        freeaddrinfo(res);
                        return(-1);
                }
@@ -105,7 +106,7 @@ int sock_connect(char *host, char *service)
                        return(sock);
                }
                else {
-                       CtdlLogPrintf(CTDL_ERR, "connect() failed: %s\n", strerror(errno));
+                       syslog(LOG_ERR, "connect() failed: %s\n", strerror(errno));
                        close(sock);
                }
        }
@@ -140,7 +141,7 @@ int socket_read_blob(int *Socket, StrBuf * Target, int bytes, int timeout)
                                        &CCC->SBuf.ReadWritePointer,
                                        Socket, 1, bytes, O_TERM, &Error);
        if (retval < 0) {
-               CtdlLogPrintf(CTDL_CRIT,
+               syslog(LOG_CRIT,
                              "%s failed: %s\n", __FUNCTION__, Error);
        }
        return retval;
@@ -159,7 +160,7 @@ int CtdlSockGetLine(int *sock, StrBuf * Target, int nSec)
                                               &CCC->SBuf.ReadWritePointer,
                                               sock, nSec, 1, &Error);
        if ((rc < 0) && (Error != NULL))
-               CtdlLogPrintf(CTDL_CRIT,
+               syslog(LOG_CRIT,
                              "%s failed: %s\n", __FUNCTION__, Error);
        return rc;
 }
index f54e3e57d2bab649d8ac905dc6fc46ea01a68e3f..bf34f255e0ce0dbfc9eddc450c425f9db9416426 100644 (file)
@@ -159,7 +159,7 @@ int CtdlTerminateOtherSession (int session_num)
                return TERM_NOTALLOWED;
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Locating session to kill\n");
+       syslog(LOG_DEBUG, "Locating session to kill\n");
        begin_critical_section(S_SESSION_TABLE);
        for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) {
                if (session_num == ccptr->cs_pid) {
@@ -301,9 +301,9 @@ void terminate_idle_sessions(void)
        }
        end_critical_section(S_SESSION_TABLE);
        if (killed > 0)
-               CtdlLogPrintf(CTDL_INFO, "Scheduled %d idle sessions for termination\n", killed);
+               syslog(LOG_INFO, "Scheduled %d idle sessions for termination\n", killed);
        if (longrunners > 0)
-               CtdlLogPrintf(CTDL_INFO, "Didn't terminate %d protected idle sessions;\n", killed);
+               syslog(LOG_INFO, "Didn't terminate %d protected idle sessions;\n", killed);
 }
 
 void terminate_stuck_sessions(void)
@@ -322,7 +322,7 @@ void terminate_stuck_sessions(void)
        }
        end_critical_section(S_SESSION_TABLE);
        if (killed > 0)
-               CtdlLogPrintf(CTDL_INFO, "Flushed %d stuck sessions\n", killed);
+               syslog(LOG_INFO, "Flushed %d stuck sessions\n", killed);
 }
 
 
@@ -333,11 +333,11 @@ void terminate_stuck_sessions(void)
 void RemoveContext (CitContext *con)
 {
        if (con==NULL) {
-               CtdlLogPrintf(CTDL_ERR,
+               syslog(LOG_ERR,
                        "WARNING: RemoveContext() called with NULL!\n");
                return;
        }
-       CtdlLogPrintf(CTDL_DEBUG, "RemoveContext() session %d\n", con->cs_pid);
+       syslog(LOG_DEBUG, "RemoveContext() session %d\n", con->cs_pid);
 
        /* Run any cleanup routines registered by loadable modules.
         * Note: We have to "become_session()" because the cleanup functions
@@ -348,7 +348,7 @@ void RemoveContext (CitContext *con)
        PerformSessionHooks(EVT_STOP);
        become_session(NULL);
 
-       CtdlLogPrintf(CTDL_NOTICE, "[%3d] Session ended.\n", con->cs_pid);
+       syslog(LOG_NOTICE, "[%3d] Session ended.\n", con->cs_pid);
 
        /* 
         * If the client is still connected, blow 'em away. 
@@ -356,7 +356,7 @@ void RemoveContext (CitContext *con)
         */
        if (con->client_socket != 0)
        {
-               CtdlLogPrintf(CTDL_DEBUG, "Closing socket %d\n", con->client_socket);
+               syslog(LOG_DEBUG, "Closing socket %d\n", con->client_socket);
                close(con->client_socket);
        }
 
@@ -368,7 +368,7 @@ void RemoveContext (CitContext *con)
 
        FreeStrBuf(&con->MigrateBuf);
        FreeStrBuf(&con->RecvBuf.Buf);
-       CtdlLogPrintf(CTDL_DEBUG, "Done with RemoveContext()\n");
+       syslog(LOG_DEBUG, "Done with RemoveContext()\n");
 }
 
 
@@ -386,7 +386,7 @@ CitContext *CreateNewContext(void) {
 
        me = (CitContext *) malloc(sizeof(CitContext));
        if (me == NULL) {
-               CtdlLogPrintf(CTDL_ALERT, "citserver: can't allocate memory!!\n");
+               syslog(LOG_ALERT, "citserver: can't allocate memory!!\n");
                return NULL;
        }
        memset(me, 0, sizeof(CitContext));
@@ -431,7 +431,7 @@ CitContext *CloneContext(CitContext *CloneMe) {
 
        me = (CitContext *) malloc(sizeof(CitContext));
        if (me == NULL) {
-               CtdlLogPrintf(CTDL_ALERT, "citserver: can't allocate memory!!\n");
+               syslog(LOG_ALERT, "citserver: can't allocate memory!!\n");
                return NULL;
        }
        memcpy(me, CloneMe, sizeof(CitContext));
@@ -535,7 +535,7 @@ void CtdlFillSystemContext(CitContext *context, char *name)
        if (context->user.usernum == 0)
        {       /* old system user with number 0, upgrade it */
                context->user.usernum = get_new_user_number();
-               CtdlLogPrintf(CTDL_DEBUG, "Upgrading system user \"%s\" from user number 0 to user number %ld\n", context->user.fullname, context->user.usernum);
+               syslog(LOG_DEBUG, "Upgrading system user \"%s\" from user number 0 to user number %ld\n", context->user.fullname, context->user.usernum);
                /* add user to the database */
                CtdlPutUser(&(context->user));
                cdb_store(CDB_USERSBYNUMBER, &(context->user.usernum), sizeof(long), context->user.fullname, strlen(context->user.fullname)+1);
@@ -578,8 +578,8 @@ void context_cleanup(void)
                /* Remove the session from the active list */
                rem = ptr->next;
                --num_sessions;
-               
-               CtdlLogPrintf(CTDL_DEBUG, "Purging session #%d %s\n", ptr->cs_pid, ptr->ServiceName);
+
+               syslog(LOG_DEBUG, "Purging session #%d %s\n", ptr->cs_pid, ptr->ServiceName);
                RemoveContext(ptr);
                free (ptr);
                ptr = rem;
@@ -656,7 +656,7 @@ void dead_session_purge(int force) {
         * is allocated privately on this thread's stack.
         */
        while (rem != NULL) {
-               CtdlLogPrintf(CTDL_DEBUG, "Purging session %d\n", rem->cs_pid);
+               syslog(LOG_DEBUG, "Purging session %d\n", rem->cs_pid);
                RemoveContext(rem);
                ptr = rem;
                rem = rem->next;
@@ -687,7 +687,7 @@ void InitializeMasterCC(void) {
  */
 void set_async_waiting(struct CitContext *ccptr)
 {
-       CtdlLogPrintf(CTDL_DEBUG, "Setting async_waiting flag for session %d\n", ccptr->cs_pid);
+       syslog(LOG_DEBUG, "Setting async_waiting flag for session %d\n", ccptr->cs_pid);
        if (ccptr->is_async) {
                ccptr->async_waiting++;
                if (ccptr->state == CON_IDLE) {
index cb7d92f0293f3b451ad85b0930429a6b1dbf92de..679f90e99b88cb9d5244f0796a1f0b3496999190 100644 (file)
@@ -186,7 +186,7 @@ static INLINE void become_session(CitContext *which_con) {
 */
        citthread_setspecific(MyConKey, (void *)which_con );
 /*
-       CtdlLogPrintf(CTDL_DEBUG, "[%d]: Now doing %s\n", 
+       syslog(LOG_DEBUG, "[%d]: Now doing %s\n", 
                      (int) tid, 
                      ((which_con != NULL) && (which_con->ServiceName != NULL)) ? 
                      which_con->ServiceName:"");
index 1779633faff7bd13976d23803509977498ecdc58..242cac8163cf97c247c5ebeff6e3b2d14bbd4967 100644 (file)
@@ -77,8 +77,8 @@ void lock_control(void)
 {
 #if defined(LOCK_EX) && defined(LOCK_NB)
        if (flock(fileno(control_fp), (LOCK_EX | LOCK_NB))) {
-               CtdlLogPrintf(CTDL_EMERG, "citserver: unable to lock %s.\n", file_citadel_control);
-               CtdlLogPrintf(CTDL_EMERG, "Is another citserver already running?\n");
+               syslog(LOG_EMERG, "citserver: unable to lock %s.\n", file_citadel_control);
+               syslog(LOG_EMERG, "Is another citserver already running?\n");
                exit(CTDLEXIT_CONTROL);
        }
 #endif
@@ -127,9 +127,9 @@ void control_find_highest(struct ctdlroom *qrbuf, void *data)
        }
        cdb_free(cdbfr);
        if (room_fixed)
-               CtdlLogPrintf(CTDL_INFO, "Control record checking....Fixed room counter\n");
+               syslog(LOG_INFO, "Control record checking....Fixed room counter\n");
        if (message_fixed)
-               CtdlLogPrintf(CTDL_INFO, "Control record checking....Fixed message count\n");
+               syslog(LOG_INFO, "Control record checking....Fixed message count\n");
        return;
 }
 
@@ -148,7 +148,7 @@ void control_find_user (struct ctdluser *EachUser, void *out_data)
                user_fixed = 1;
        }
        if(user_fixed)
-               CtdlLogPrintf(CTDL_INFO, "Control record checking....Fixed user count\n");
+               syslog(LOG_INFO, "Control record checking....Fixed user count\n");
 }
 
 
@@ -191,7 +191,7 @@ void get_control(void)
                }
        }
        if (control_fp == NULL) {
-               CtdlLogPrintf(CTDL_ALERT, "ERROR opening %s: %s\n", file_citadel_control, strerror(errno));
+               syslog(LOG_ALERT, "ERROR opening %s: %s\n", file_citadel_control, strerror(errno));
                return;
        }
 
@@ -222,7 +222,7 @@ void put_control(void)
  */
 void check_control(void)
 {
-       CtdlLogPrintf(CTDL_INFO, "Checking/re-building control record\n");
+       syslog(LOG_INFO, "Checking/re-building control record\n");
        get_control();
        // Find highest room number and message number.
        CtdlForEachRoom(control_find_highest, NULL);
index 155910a2da5062fbed1cdf5f1f618aad63ad1e97..d0aab07300d56305ba0c4203c74445b03c1317ad 100644 (file)
@@ -1,21 +1,21 @@
 /*
  * This is a data store backend for the Citadel server which uses Berkeley DB.
  *
- * Copyright (c) 1987-2009 by the citadel.org team
+ * Copyright (c) 1987-2011 by the citadel.org team
  *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
+ * This program is open source software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
  *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  *
  */
 
@@ -42,6 +42,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <dirent.h>
+#include <syslog.h>
 
 #ifdef HAVE_DB_H
 #include <db.h>
@@ -84,7 +85,7 @@ static DB_ENV *dbenv;         /* The DB environment (global) */
 void cdb_verbose_log(const DB_ENV *dbenv, const char *msg)
 {
        if (!IsEmptyStr(msg)) {
-               CtdlLogPrintf(CTDL_DEBUG, "DB: %s\n", msg);
+               syslog(LOG_DEBUG, "DB: %s\n", msg);
        }
 }
 
@@ -92,7 +93,7 @@ void cdb_verbose_log(const DB_ENV *dbenv, const char *msg)
 /* Verbose logging callback */
 void cdb_verbose_err(const DB_ENV *dbenv, const char *errpfx, const char *msg)
 {
-       CtdlLogPrintf(CTDL_ALERT, "DB: %s\n", msg);
+       syslog(LOG_ALERT, "DB: %s\n", msg);
 }
 
 
@@ -104,7 +105,7 @@ static void txabort(DB_TXN * tid)
        ret = tid->abort(tid);
 
        if (ret) {
-               CtdlLogPrintf(CTDL_EMERG, "bdb(): txn_abort: %s\n", db_strerror(ret));
+               syslog(LOG_EMERG, "bdb(): txn_abort: %s\n", db_strerror(ret));
                abort();
        }
 }
@@ -117,7 +118,7 @@ static void txcommit(DB_TXN * tid)
        ret = tid->commit(tid, 0);
 
        if (ret) {
-               CtdlLogPrintf(CTDL_EMERG, "bdb(): txn_commit: %s\n", db_strerror(ret));
+               syslog(LOG_EMERG, "bdb(): txn_commit: %s\n", db_strerror(ret));
                abort();
        }
 }
@@ -130,14 +131,14 @@ static void txbegin(DB_TXN ** tid)
        ret = dbenv->txn_begin(dbenv, NULL, tid, 0);
 
        if (ret) {
-               CtdlLogPrintf(CTDL_EMERG, "bdb(): txn_begin: %s\n", db_strerror(ret));
+               syslog(LOG_EMERG, "bdb(): txn_begin: %s\n", db_strerror(ret));
                abort();
        }
 }
 
 static void dbpanic(DB_ENV * env, int errval)
 {
-       CtdlLogPrintf(CTDL_EMERG, "bdb(): PANIC: %s\n", db_strerror(errval));
+       syslog(LOG_EMERG, "bdb(): PANIC: %s\n", db_strerror(errval));
 }
 
 static void cclose(DBC * cursor)
@@ -145,7 +146,7 @@ static void cclose(DBC * cursor)
        int ret;
 
        if ((ret = cursor->c_close(cursor))) {
-               CtdlLogPrintf(CTDL_EMERG, "bdb(): c_close: %s\n", db_strerror(ret));
+               syslog(LOG_EMERG, "bdb(): c_close: %s\n", db_strerror(ret));
                abort();
        }
 }
@@ -156,7 +157,7 @@ static void bailIfCursor(DBC ** cursors, const char *msg)
 
        for (i = 0; i < MAXCDB; i++)
                if (cursors[i] != NULL) {
-                       CtdlLogPrintf(CTDL_EMERG,
+                       syslog(LOG_EMERG,
                                "bdb(): cursor still in progress on cdb %02x: %s\n", i, msg);
                        abort();
                }
@@ -170,7 +171,7 @@ void check_handles(void *arg)
                bailIfCursor(tsd->cursors, "in check_handles");
 
                if (tsd->tid != NULL) {
-                       CtdlLogPrintf(CTDL_EMERG, "bdb(): transaction still in progress!");
+                       syslog(LOG_EMERG, "bdb(): transaction still in progress!");
                        abort();
                }
        }
@@ -196,14 +197,14 @@ static void cdb_cull_logs(void)
 
        /* Get the list of names. */
        if ((ret = dbenv->log_archive(dbenv, &list, flags)) != 0) {
-               CtdlLogPrintf(CTDL_ERR, "cdb_cull_logs: %s\n", db_strerror(ret));
+               syslog(LOG_ERR, "cdb_cull_logs: %s\n", db_strerror(ret));
                return;
        }
 
        /* Print the list of names. */
        if (list != NULL) {
                for (file = list; *file != NULL; ++file) {
-                       CtdlLogPrintf(CTDL_DEBUG, "Deleting log: %s\n", *file);
+                       syslog(LOG_DEBUG, "Deleting log: %s\n", *file);
                        ret = unlink(*file);
                        if (ret != 0) {
                                snprintf(errmsg, sizeof(errmsg),
@@ -238,11 +239,11 @@ void cdb_checkpoint(void)
 {
        int ret;
 
-       CtdlLogPrintf(CTDL_DEBUG, "-- db checkpoint --\n");
+       syslog(LOG_DEBUG, "-- db checkpoint --\n");
        ret = dbenv->txn_checkpoint(dbenv, MAX_CHECKPOINT_KBYTES, MAX_CHECKPOINT_MINUTES, 0);
 
        if (ret != 0) {
-               CtdlLogPrintf(CTDL_EMERG, "cdb_checkpoint: txn_checkpoint: %s\n", db_strerror(ret));
+               syslog(LOG_EMERG, "cdb_checkpoint: txn_checkpoint: %s\n", db_strerror(ret));
                abort();
        }
 
@@ -269,19 +270,19 @@ void open_databases(void)
        int dbversion_major, dbversion_minor, dbversion_patch;
        int current_dbversion = 0;
 
-       CtdlLogPrintf(CTDL_DEBUG, "bdb(): open_databases() starting\n");
-       CtdlLogPrintf(CTDL_DEBUG, "Compiled db: %s\n", DB_VERSION_STRING);
-       CtdlLogPrintf(CTDL_INFO, "  Linked db: %s\n",
+       syslog(LOG_DEBUG, "bdb(): open_databases() starting\n");
+       syslog(LOG_DEBUG, "Compiled db: %s\n", DB_VERSION_STRING);
+       syslog(LOG_INFO, "  Linked db: %s\n",
                db_version(&dbversion_major, &dbversion_minor, &dbversion_patch));
 
        current_dbversion = (dbversion_major * 1000000) + (dbversion_minor * 1000) + dbversion_patch;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Calculated dbversion: %d\n", current_dbversion);
-       CtdlLogPrintf(CTDL_DEBUG, "  Previous dbversion: %d\n", CitControl.MMdbversion);
+       syslog(LOG_DEBUG, "Calculated dbversion: %d\n", current_dbversion);
+       syslog(LOG_DEBUG, "  Previous dbversion: %d\n", CitControl.MMdbversion);
 
        if ( (getenv("SUPPRESS_DBVERSION_CHECK") == NULL)
           && (CitControl.MMdbversion > current_dbversion) ) {
-               CtdlLogPrintf(CTDL_EMERG, "You are attempting to run the Citadel server using a version\n"
+               syslog(LOG_EMERG, "You are attempting to run the Citadel server using a version\n"
                                        "of Berkeley DB that is older than that which last created or\n"
                                        "updated the database.  Because this would probably cause data\n"
                                        "corruption or loss, the server is aborting execution now.\n");
@@ -292,7 +293,7 @@ void open_databases(void)
        put_control();
 
 #ifdef HAVE_ZLIB
-       CtdlLogPrintf(CTDL_INFO, "Linked zlib: %s\n", zlibVersion());
+       syslog(LOG_INFO, "Linked zlib: %s\n", zlibVersion());
 #endif
 
        /*
@@ -300,26 +301,26 @@ void open_databases(void)
         * already there, no problem.
         */
        if ((mkdir(ctdl_data_dir, 0700) != 0) && (errno != EEXIST)){
-               CtdlLogPrintf(CTDL_EMERG, 
+               syslog(LOG_EMERG, 
                              "unable to create database directory [%s]: %s", 
                              ctdl_data_dir, strerror(errno));
        }
        if (chmod(ctdl_data_dir, 0700) != 0){
-               CtdlLogPrintf(CTDL_EMERG, 
+               syslog(LOG_EMERG, 
                              "unable to set database directory accessrights [%s]: %s", 
                              ctdl_data_dir, strerror(errno));
        }
        if (chown(ctdl_data_dir, CTDLUID, (-1)) != 0){
-               CtdlLogPrintf(CTDL_EMERG, 
+               syslog(LOG_EMERG, 
                              "unable to set the owner for [%s]: %s", 
                              ctdl_data_dir, strerror(errno));
        }
-       CtdlLogPrintf(CTDL_DEBUG, "bdb(): Setting up DB environment\n");
+       syslog(LOG_DEBUG, "bdb(): Setting up DB environment\n");
        db_env_set_func_yield((int (*)(u_long,  u_long))sched_yield);
        ret = db_env_create(&dbenv, 0);
        if (ret) {
-               CtdlLogPrintf(CTDL_EMERG, "bdb(): db_env_create: %s\n", db_strerror(ret));
-               CtdlLogPrintf(CTDL_EMERG, "exit code %d\n", ret);
+               syslog(LOG_EMERG, "bdb(): db_env_create: %s\n", db_strerror(ret));
+               syslog(LOG_EMERG, "exit code %d\n", ret);
                exit(CTDLEXIT_DB);
        }
        dbenv->set_errpfx(dbenv, "citserver");
@@ -338,51 +339,51 @@ void open_databases(void)
         */
        ret = dbenv->set_cachesize(dbenv, 0, 64 * 1024, 0);
        if (ret) {
-               CtdlLogPrintf(CTDL_EMERG, "bdb(): set_cachesize: %s\n", db_strerror(ret));
+               syslog(LOG_EMERG, "bdb(): set_cachesize: %s\n", db_strerror(ret));
                dbenv->close(dbenv, 0);
-               CtdlLogPrintf(CTDL_EMERG, "exit code %d\n", ret);
+               syslog(LOG_EMERG, "exit code %d\n", ret);
                exit(CTDLEXIT_DB);
        }
 
        if ((ret = dbenv->set_lk_detect(dbenv, DB_LOCK_DEFAULT))) {
-               CtdlLogPrintf(CTDL_EMERG, "bdb(): set_lk_detect: %s\n", db_strerror(ret));
+               syslog(LOG_EMERG, "bdb(): set_lk_detect: %s\n", db_strerror(ret));
                dbenv->close(dbenv, 0);
-               CtdlLogPrintf(CTDL_EMERG, "exit code %d\n", ret);
+               syslog(LOG_EMERG, "exit code %d\n", ret);
                exit(CTDLEXIT_DB);
        }
 
        flags = DB_CREATE | DB_INIT_MPOOL | DB_PRIVATE | DB_INIT_TXN | DB_INIT_LOCK | DB_THREAD | DB_RECOVER;
-       CtdlLogPrintf(CTDL_DEBUG, "dbenv->open(dbenv, %s, %d, 0)\n", ctdl_data_dir, flags);
+       syslog(LOG_DEBUG, "dbenv->open(dbenv, %s, %d, 0)\n", ctdl_data_dir, flags);
        ret = dbenv->open(dbenv, ctdl_data_dir, flags, 0);
        if (ret == DB_RUNRECOVERY) {
-               CtdlLogPrintf(CTDL_ALERT, "dbenv->open: %s\n", db_strerror(ret));
-               CtdlLogPrintf(CTDL_ALERT, "Attempting recovery...\n");
+               syslog(LOG_ALERT, "dbenv->open: %s\n", db_strerror(ret));
+               syslog(LOG_ALERT, "Attempting recovery...\n");
                flags |= DB_RECOVER;
                ret = dbenv->open(dbenv, ctdl_data_dir, flags, 0);
        }
        if (ret == DB_RUNRECOVERY) {
-               CtdlLogPrintf(CTDL_ALERT, "dbenv->open: %s\n", db_strerror(ret));
-               CtdlLogPrintf(CTDL_ALERT, "Attempting catastrophic recovery...\n");
+               syslog(LOG_ALERT, "dbenv->open: %s\n", db_strerror(ret));
+               syslog(LOG_ALERT, "Attempting catastrophic recovery...\n");
                flags &= ~DB_RECOVER;
                flags |= DB_RECOVER_FATAL;
                ret = dbenv->open(dbenv, ctdl_data_dir, flags, 0);
        }
        if (ret) {
-               CtdlLogPrintf(CTDL_EMERG, "dbenv->open: %s\n", db_strerror(ret));
+               syslog(LOG_EMERG, "dbenv->open: %s\n", db_strerror(ret));
                dbenv->close(dbenv, 0);
-               CtdlLogPrintf(CTDL_EMERG, "exit code %d\n", ret);
+               syslog(LOG_EMERG, "exit code %d\n", ret);
                exit(CTDLEXIT_DB);
        }
 
-       CtdlLogPrintf(CTDL_INFO, "Starting up DB\n");
+       syslog(LOG_INFO, "Starting up DB\n");
 
        for (i = 0; i < MAXCDB; ++i) {
 
                /* Create a database handle */
                ret = db_create(&dbp[i], dbenv, 0);
                if (ret) {
-                       CtdlLogPrintf(CTDL_EMERG, "db_create: %s\n", db_strerror(ret));
-                       CtdlLogPrintf(CTDL_EMERG, "exit code %d\n", ret);
+                       syslog(LOG_EMERG, "db_create: %s\n", db_strerror(ret));
+                       syslog(LOG_EMERG, "exit code %d\n", ret);
                        exit(CTDLEXIT_DB);
                }
 
@@ -401,11 +402,11 @@ void open_databases(void)
                                   0600
                );
                if (ret) {
-                       CtdlLogPrintf(CTDL_EMERG, "db_open[%02x]: %s\n", i, db_strerror(ret));
+                       syslog(LOG_EMERG, "db_open[%02x]: %s\n", i, db_strerror(ret));
                        if (ret == ENOMEM) {
-                               CtdlLogPrintf(CTDL_EMERG, "You may need to tune your database; please read http://www.citadel.org/doku.php/faq:troubleshooting:out_of_lock_entries for more information.\n");
+                               syslog(LOG_EMERG, "You may need to tune your database; please read http://www.citadel.org/doku.php/faq:troubleshooting:out_of_lock_entries for more information.\n");
                        }
-                       CtdlLogPrintf(CTDL_EMERG, "exit code %d\n", ret);
+                       syslog(LOG_EMERG, "exit code %d\n", ret);
                        exit(CTDLEXIT_DB);
                }
        }
@@ -427,10 +428,10 @@ void cdb_chmod_data(void) {
                        if (d->d_name[0] != '.') {
                                snprintf(filename, sizeof filename,
                                         "%s/%s", ctdl_data_dir, d->d_name);
-                               CtdlLogPrintf(CTDL_DEBUG, "chmod(%s, 0600) returned %d\n",
+                               syslog(LOG_DEBUG, "chmod(%s, 0600) returned %d\n",
                                        filename, chmod(filename, 0600)
                                );
-                               CtdlLogPrintf(CTDL_DEBUG, "chown(%s, CTDLUID, -1) returned %d\n",
+                               syslog(LOG_DEBUG, "chown(%s, CTDLUID, -1) returned %d\n",
                                        filename, chown(filename, CTDLUID, (-1))
                                );
                        }
@@ -438,7 +439,7 @@ void cdb_chmod_data(void) {
                closedir(dp);
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "open_databases() finished\n");
+       syslog(LOG_DEBUG, "open_databases() finished\n");
        CtdlRegisterProtoHook(cmd_cull, "CULL", "Cull database logs");
 }
 
@@ -455,7 +456,7 @@ void close_databases(void)
        ctdl_thread_internal_free_tsd();
        
        if ((ret = dbenv->txn_checkpoint(dbenv, 0, 0, 0))) {
-               CtdlLogPrintf(CTDL_EMERG,
+               syslog(LOG_EMERG,
                        "txn_checkpoint: %s\n", db_strerror(ret));
        }
 
@@ -466,10 +467,10 @@ void close_databases(void)
 
        /* close the tables */
        for (a = 0; a < MAXCDB; ++a) {
-               CtdlLogPrintf(CTDL_INFO, "Closing database %02x\n", a);
+               syslog(LOG_INFO, "Closing database %02x\n", a);
                ret = dbp[a]->close(dbp[a], 0);
                if (ret) {
-                       CtdlLogPrintf(CTDL_EMERG, "db_close: %s\n", db_strerror(ret));
+                       syslog(LOG_EMERG, "db_close: %s\n", db_strerror(ret));
                }
 
        }
@@ -477,7 +478,7 @@ void close_databases(void)
        /* Close the handle. */
        ret = dbenv->close(dbenv, 0);
        if (ret) {
-               CtdlLogPrintf(CTDL_EMERG, "DBENV->close: %s\n", db_strerror(ret));
+               syslog(LOG_EMERG, "DBENV->close: %s\n", db_strerror(ret));
        }
 }
 
@@ -521,7 +522,7 @@ void cdb_decompress_if_necessary(struct cdbdata *cdb)
                       (uLongf *) & destLen,
                       (const Bytef *) compressed_data,
                       (uLong) sourceLen) != Z_OK) {
-               CtdlLogPrintf(CTDL_EMERG, "uncompress() error\n");
+               syslog(LOG_EMERG, "uncompress() error\n");
                abort();
        }
 
@@ -529,7 +530,7 @@ void cdb_decompress_if_necessary(struct cdbdata *cdb)
        cdb->len = (size_t) destLen;
        cdb->ptr = uncompressed_data;
 #else                          /* HAVE_ZLIB */
-       CtdlLogPrintf(CTDL_EMERG, "Database contains compressed data, but this citserver was built without compression support.\n");
+       syslog(LOG_EMERG, "Database contains compressed data, but this citserver was built without compression support.\n");
        abort();
 #endif                         /* HAVE_ZLIB */
 }
@@ -575,7 +576,7 @@ int cdb_store(int cdb, const void *ckey, int ckeylen, void *cdata, int cdatalen)
                if (compress2((Bytef *) (compressed_data + sizeof(struct CtdlCompressHeader)),
                        &destLen, (Bytef *) cdata, (uLongf) cdatalen, 1) != Z_OK)
                {
-                       CtdlLogPrintf(CTDL_EMERG, "compress2() error\n");
+                       syslog(LOG_EMERG, "compress2() error\n");
                        abort();
                }
                zheader.compressed_len = (size_t) destLen;
@@ -592,7 +593,7 @@ int cdb_store(int cdb, const void *ckey, int ckeylen, void *cdata, int cdatalen)
                                    &ddata,     /* data */
                                    0); /* flags */
                if (ret) {
-                       CtdlLogPrintf(CTDL_EMERG, "cdb_store(%d): %s\n", cdb, db_strerror(ret));
+                       syslog(LOG_EMERG, "cdb_store(%d): %s\n", cdb, db_strerror(ret));
                        abort();
                }
 #ifdef HAVE_ZLIB
@@ -616,7 +617,7 @@ int cdb_store(int cdb, const void *ckey, int ckeylen, void *cdata, int cdatalen)
                                txabort(tid);
                                goto retry;
                        } else {
-                               CtdlLogPrintf(CTDL_EMERG, "cdb_store(%d): %s\n",
+                               syslog(LOG_EMERG, "cdb_store(%d): %s\n",
                                        cdb, db_strerror(ret));
                                abort();
                        }
@@ -650,7 +651,7 @@ int cdb_delete(int cdb, void *key, int keylen)
        if (MYTID != NULL) {
                ret = dbp[cdb]->del(dbp[cdb], MYTID, &dkey, 0);
                if (ret) {
-                       CtdlLogPrintf(CTDL_EMERG, "cdb_delete(%d): %s\n", cdb, db_strerror(ret));
+                       syslog(LOG_EMERG, "cdb_delete(%d): %s\n", cdb, db_strerror(ret));
                        if (ret != DB_NOTFOUND) {
                                abort();
                        }
@@ -667,7 +668,7 @@ int cdb_delete(int cdb, void *key, int keylen)
                                txabort(tid);
                                goto retry;
                        } else {
-                               CtdlLogPrintf(CTDL_EMERG, "cdb_delete(%d): %s\n",
+                               syslog(LOG_EMERG, "cdb_delete(%d): %s\n",
                                        cdb, db_strerror(ret));
                                abort();
                        }
@@ -691,7 +692,7 @@ static DBC *localcursor(int cdb)
                                          DB_POSITION);
 
        if (ret) {
-               CtdlLogPrintf(CTDL_EMERG, "localcursor: %s\n", db_strerror(ret));
+               syslog(LOG_EMERG, "localcursor: %s\n", db_strerror(ret));
                abort();
        }
 
@@ -736,7 +737,7 @@ struct cdbdata *cdb_fetch(int cdb, const void *key, int keylen)
        }
 
        if ((ret != 0) && (ret != DB_NOTFOUND)) {
-               CtdlLogPrintf(CTDL_EMERG, "cdb_fetch(%d): %s\n", cdb, db_strerror(ret));
+               syslog(LOG_EMERG, "cdb_fetch(%d): %s\n", cdb, db_strerror(ret));
                abort();
        }
 
@@ -745,7 +746,7 @@ struct cdbdata *cdb_fetch(int cdb, const void *key, int keylen)
        tempcdb = (struct cdbdata *) malloc(sizeof(struct cdbdata));
 
        if (tempcdb == NULL) {
-               CtdlLogPrintf(CTDL_EMERG, "cdb_fetch: Cannot allocate memory for tempcdb\n");
+               syslog(LOG_EMERG, "cdb_fetch: Cannot allocate memory for tempcdb\n");
                abort();
        }
 
@@ -791,7 +792,7 @@ void cdb_rewind(int cdb)
        int ret = 0;
 
        if (MYCURSORS[cdb] != NULL) {
-               CtdlLogPrintf(CTDL_EMERG,
+               syslog(LOG_EMERG,
                        "cdb_rewind: must close cursor on database %d before reopening.\n", cdb);
                abort();
                /* cclose(MYCURSORS[cdb]); */
@@ -802,7 +803,7 @@ void cdb_rewind(int cdb)
         */
        ret = dbp[cdb]->cursor(dbp[cdb], MYTID, &MYCURSORS[cdb], 0);
        if (ret) {
-               CtdlLogPrintf(CTDL_EMERG, "cdb_rewind: db_cursor: %s\n", db_strerror(ret));
+               syslog(LOG_EMERG, "cdb_rewind: db_cursor: %s\n", db_strerror(ret));
                abort();
        }
 }
@@ -827,7 +828,7 @@ struct cdbdata *cdb_next_item(int cdb)
 
        if (ret) {
                if (ret != DB_NOTFOUND) {
-                       CtdlLogPrintf(CTDL_EMERG, "cdb_next_item(%d): %s\n", cdb, db_strerror(ret));
+                       syslog(LOG_EMERG, "cdb_next_item(%d): %s\n", cdb, db_strerror(ret));
                        abort();
                }
                cclose(MYCURSORS[cdb]);
@@ -855,7 +856,7 @@ void cdb_begin_transaction(void)
        bailIfCursor(MYCURSORS, "can't begin transaction during r/o cursor");
 
        if (MYTID != NULL) {
-               CtdlLogPrintf(CTDL_EMERG, "cdb_begin_transaction: ERROR: nested transaction\n");
+               syslog(LOG_EMERG, "cdb_begin_transaction: ERROR: nested transaction\n");
                abort();
        }
 
@@ -868,7 +869,7 @@ void cdb_end_transaction(void)
 
        for (i = 0; i < MAXCDB; i++)
                if (MYCURSORS[i] != NULL) {
-                       CtdlLogPrintf(CTDL_WARNING,
+                       syslog(LOG_WARNING,
                                "cdb_end_transaction: WARNING: cursor %d still open at transaction end\n",
                                i);
                        cclose(MYCURSORS[i]);
@@ -876,7 +877,7 @@ void cdb_end_transaction(void)
                }
 
        if (MYTID == NULL) {
-               CtdlLogPrintf(CTDL_EMERG,
+               syslog(LOG_EMERG,
                        "cdb_end_transaction: ERROR: txcommit(NULL) !!\n");
                abort();
        } else {
@@ -896,7 +897,7 @@ void cdb_trunc(int cdb)
        u_int32_t count;
 
        if (MYTID != NULL) {
-               CtdlLogPrintf(CTDL_EMERG,
+               syslog(LOG_EMERG,
                        "cdb_trunc must not be called in a transaction.\n");
                abort();
        } else {
@@ -913,9 +914,9 @@ void cdb_trunc(int cdb)
                                /* txabort(tid); */
                                goto retry;
                        } else {
-                               CtdlLogPrintf(CTDL_EMERG, "cdb_truncate(%d): %s\n", cdb, db_strerror(ret));
+                               syslog(LOG_EMERG, "cdb_truncate(%d): %s\n", cdb, db_strerror(ret));
                                if (ret == ENOMEM) {
-                                       CtdlLogPrintf(CTDL_EMERG, "You may need to tune your database; please read http://www.citadel.org/doku.php/faq:troubleshooting:out_of_lock_entries for more information.\n");
+                                       syslog(LOG_EMERG, "You may need to tune your database; please read http://www.citadel.org/doku.php/faq:troubleshooting:out_of_lock_entries for more information.\n");
                                }
                                abort();
                        }
index 4430d299eb880288a4dcd6ffb247a66894766ec4..ce8c209425c816fbc2aac48c5d1281065df343db 100644 (file)
@@ -1127,7 +1127,7 @@ program against to set up some data files. If a directory is not
 specified, the directory
 name which was specified in the <tt>Makefile</tt> will be used.</p>
 <p><tt>-xDebugLevel</tt> - Set the verbosity of trace messages printed.
-When -x is used, it will suppress messages sent to syslog (see below).
+When -x is used, it will suppress messages sent to syslog(see below).
 In
 other words, syslog will never see certain messages if -x is used.
 Normally
index 0522c17fdf4e5a8c091aac3f16af5a7cad99e4b6..a1049537c3a446e08dab5383db92cbf39bde743f 100644 (file)
@@ -1,9 +1,9 @@
 /*
  * DNS lookup for SMTP sender
  *
- * Copyright (c) 1987-2009 by the citadel.org team
+ * Copyright (c) 1987-2011 by the citadel.org team
  *
- * This program is free software; you can redistribute it and/or modify
+ * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
@@ -24,6 +24,7 @@
 #include <string.h>
 #include <netinet/in.h>
 #include <stdio.h>
+#include <syslog.h>
 
 #ifdef HAVE_RESOLV_H
 #include <arpa/nameser.h>
@@ -160,7 +161,7 @@ int getmx(char *mxbuf, char *dest) {
        
                for (qdcount = ntohs(answer.header.qdcount); qdcount--; ptr += ret + QFIXEDSZ) {
                        if ((ret = dn_skipname(ptr, endptr)) < 0) {
-                               CtdlLogPrintf(CTDL_DEBUG, "dn_skipname error\n");
+                               syslog(LOG_DEBUG, "dn_skipname error\n");
                                return(0);
                        }
                }
index ea75ea1cd65aa1da4c7b2126b3216b06bd28c00b..72430670f05a7e4e0f3014a5ea8af5ed6ce20daf 100644 (file)
@@ -185,14 +185,7 @@ static void outputPrintf(char *format, ...)
 
        va_start(ap, format);
 
-       if (enable_syslog)
-       {
-               snprintf (StaticBuf, SIZ, format, ap);
-               syslog( LOG_CRIT|LOG_NDELAY|LOG_MAIL, StaticBuf);
-       }
-       else
-               CtdlLogPrintf(CTDL_EMERG, format, ap);
-
+       vsyslog(LOG_CRIT|LOG_NDELAY|LOG_MAIL, format, ap);
 } // outputPrintf
 
 
@@ -208,25 +201,14 @@ static void createGlobalBacktrace( void )
 {
 
        size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void*));
-       if (enable_syslog)
-               for (NThread = 0; NThread < size; NThread++) 
-               {
-                       snprintf (StaticBuf, SIZ, "RAW: %p  ", stack_frames[NThread]);
-                       syslog( LOG_CRIT|LOG_NDELAY|LOG_MAIL, StaticBuf);
-               }
-       else 
-               for (NThread = 0; NThread < size; NThread++) 
-                       CtdlLogPrintf(CTDL_ALERT, "RAW: %p\n", stack_frames[NThread]);
+       for (NThread = 0; NThread < size; NThread++) 
+       {
+               syslog(LOG_CRIT|LOG_NDELAY|LOG_MAIL, "RAW: %p  ", stack_frames[NThread]);
+       }
        strings = backtrace_symbols(stack_frames, size);
        for (NThread = 0; NThread < size; NThread++) {
                if (strings != NULL) {
-                       if (enable_syslog)
-                       {// vsyslogs printf compliance sucks.
-                               snprintf (StaticBuf, SIZ, "RAW: %p  ", strings[NThread]);
-                               syslog( LOG_CRIT|LOG_NDELAY|LOG_MAIL, StaticBuf);
-                       }
-                       else
-                               CtdlLogPrintf(CTDL_ALERT, "%s\n", strings[NThread]);
+                       syslog(LOG_CRIT|LOG_NDELAY|LOG_MAIL, "RAW: %p  ", strings[NThread]);
                }
        }
 } /* createGlobalBacktrace */
@@ -234,15 +216,10 @@ static void outputRawtrace( void )
 {
 
        size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void*));
-       if (enable_syslog)
-               for (NThread = 0; NThread < size; NThread++) 
-               {
-                       snprintf (StaticBuf, SIZ, "RAW: %p  ", stack_frames[NThread]);
-                       syslog( LOG_CRIT|LOG_NDELAY|LOG_MAIL, StaticBuf);
-               }
-       else 
-               for (NThread = 0; NThread < size; NThread++) 
-                       CtdlLogPrintf(CTDL_ALERT, "RAW: %p\n", stack_frames[NThread]);
+       for (NThread = 0; NThread < size; NThread++) 
+       {
+               syslog(LOG_CRIT|LOG_NDELAY|LOG_MAIL, "RAW: %p  ", stack_frames[NThread]);
+       }
 } /* createGlobalBacktrace */
 
 /*!
index 9071056fa149310d836ecd73a430914f78b3a0fd..8bad12925557f072c6b713397337121624e0e7f5 100644 (file)
@@ -98,7 +98,7 @@ long CtdlLocateMessageByEuid(char *euid, struct ctdlroom *qrbuf) {
        struct cdbdata *cdb_euid;
        long msgnum = (-1L);
 
-       CtdlLogPrintf(CTDL_DEBUG, "Searching for EUID <%s> in <%s>\n", euid, qrbuf->QRname);
+       syslog(LOG_DEBUG, "Searching for EUID <%s> in <%s>\n", euid, qrbuf->QRname);
 
        key_len = strlen(euid) + sizeof(long) + 1;
        key = malloc(key_len);
@@ -118,7 +118,7 @@ long CtdlLocateMessageByEuid(char *euid, struct ctdlroom *qrbuf) {
                memcpy(&msgnum, cdb_euid->ptr, sizeof(long));
                cdb_free(cdb_euid);
        }
-       CtdlLogPrintf(CTDL_DEBUG, "returning msgnum = %ld\n", msgnum);
+       syslog(LOG_DEBUG, "returning msgnum = %ld\n", msgnum);
        return(msgnum);
 }
 
@@ -133,7 +133,7 @@ void index_message_by_euid(char *euid, struct ctdlroom *qrbuf, long msgnum) {
        char *data;
        int data_len;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Indexing message #%ld <%s> in <%s>\n", msgnum, euid, qrbuf->QRname);
+       syslog(LOG_DEBUG, "Indexing message #%ld <%s> in <%s>\n", msgnum, euid, qrbuf->QRname);
 
        key_len = strlen(euid) + sizeof(long) + 1;
        key = malloc(key_len);
@@ -191,7 +191,7 @@ void rebuild_euid_index_for_room(struct ctdlroom *qrbuf, void *data) {
        while (rplist != NULL) {
                if (CtdlGetRoom(&qr, rplist->name) == 0) {
                        if (DoesThisRoomNeedEuidIndexing(&qr)) {
-                               CtdlLogPrintf(CTDL_DEBUG,
+                               syslog(LOG_DEBUG,
                                        "Rebuilding EUID index for <%s>\n",
                                        rplist->name);
                                CtdlUserGoto(rplist->name, 0, 0, NULL, NULL);
index 669a0e0aec6c76cfbde6d729aa9aa40f7067a890..956c9e92a182658bcc59fa427de8f917e8c613ad 100644 (file)
@@ -69,7 +69,7 @@
 
 static void IO_abort_shutdown_callback(struct ev_loop *loop, ev_cleanup *watcher, int revents)
 {
-       CtdlLogPrintf(CTDL_DEBUG, "EVENT Q: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "EVENT Q: %s\n", __FUNCTION__);
 
        AsyncIO *IO = watcher->data;
        assert(IO->ShutdownAbort);
@@ -101,13 +101,13 @@ eNextState QueueDBOperation(AsyncIO *IO, IO_CallBack CB)
        ev_cleanup_start(event_db, &IO->db_abort_by_shutdown);
 
        citthread_mutex_lock(&DBEventQueueMutex);
-       CtdlLogPrintf(CTDL_DEBUG, "DBEVENT Q\n");
+       syslog(LOG_DEBUG, "DBEVENT Q\n");
        i = ++evdb_count ;
        Put(DBInboundEventQueue, IKEY(i), h, NULL);
        citthread_mutex_unlock(&DBEventQueueMutex);
 
        ev_async_send (event_db, &DBAddJob);
-       CtdlLogPrintf(CTDL_DEBUG, "DBEVENT Q Done.\n");
+       syslog(LOG_DEBUG, "DBEVENT Q Done.\n");
        return eDBQuery;
 }
 
@@ -116,7 +116,7 @@ void ShutDownDBCLient(AsyncIO *IO)
        CitContext *Ctx =IO->CitContext;
        become_session(Ctx);
 
-       CtdlLogPrintf(CTDL_DEBUG, "DBEVENT\n");
+       syslog(LOG_DEBUG, "DBEVENT\n");
        ev_cleanup_stop(event_db, &IO->db_abort_by_shutdown);
 
        assert(IO->Terminate);
@@ -130,7 +130,7 @@ void
 DB_PerformNext(struct ev_loop *loop, ev_idle *watcher, int revents)
 {
        AsyncIO *IO = watcher->data;
-       CtdlLogPrintf(CTDL_DEBUG, "event: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "event: %s\n", __FUNCTION__);
        become_session(IO->CitContext);
        
        ev_idle_stop(event_db, &IO->db_unwind_stack);
@@ -191,13 +191,13 @@ eNextState QueueEventContext(AsyncIO *IO, IO_CallBack CB)
        ev_cleanup_start(event_base, &IO->abort_by_shutdown);
 
        citthread_mutex_lock(&EventQueueMutex);
-       CtdlLogPrintf(CTDL_DEBUG, "EVENT Q\n");
+       syslog(LOG_DEBUG, "EVENT Q\n");
        i = ++evbase_count;
        Put(InboundEventQueue, IKEY(i), h, NULL);
        citthread_mutex_unlock(&EventQueueMutex);
 
        ev_async_send (event_base, &AddJob);
-       CtdlLogPrintf(CTDL_DEBUG, "EVENT Q Done.\n");
+       syslog(LOG_DEBUG, "EVENT Q Done.\n");
        return eSendReply;
 }
 
@@ -240,7 +240,7 @@ void ShutDownCLient(AsyncIO *IO)
        CitContext *Ctx =IO->CitContext;
        become_session(Ctx);
 
-       CtdlLogPrintf(CTDL_DEBUG, "EVENT x %d\n", IO->SendBuf.fd);
+       syslog(LOG_DEBUG, "EVENT x %d\n", IO->SendBuf.fd);
 
        ev_cleanup_stop(event_base, &IO->abort_by_shutdown);
        StopClientWatchers(IO);
@@ -578,9 +578,9 @@ IO_recv_callback(struct ev_loop *loop, ev_io *watcher, int revents)
                return;
        } else if (nbytes == -1) {
 /// TODO: FD is gone. kick it.        sock_buff_invoke_free(sb, errno);
-               CtdlLogPrintf(CTDL_DEBUG,
-                             "EVENT: Socket Invalid! %s \n",
-                             strerror(errno));
+               syslog(LOG_DEBUG, 
+                      "EVENT: Socket Invalid! %s \n",
+                      strerror(errno));
                return;
        }
 }
@@ -589,7 +589,7 @@ void
 IO_postdns_callback(struct ev_loop *loop, ev_idle *watcher, int revents)
 {
        AsyncIO *IO = watcher->data;
-       CtdlLogPrintf(CTDL_DEBUG, "event: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "event: %s\n", __FUNCTION__);
        become_session(IO->CitContext);
 
        switch (IO->DNSQuery->PostDNS(IO))
@@ -613,23 +613,23 @@ eNextState event_connect_socket(AsyncIO *IO, double conn_timeout, double first_r
                        IPPROTO_TCP);
 
        if (IO->SendBuf.fd < 0) {
-               CtdlLogPrintf(CTDL_ERR, "EVENT: socket() failed: %s\n", strerror(errno));
+               syslog(LOG_ERR, "EVENT: socket() failed: %s\n", strerror(errno));
                StrBufPrintf(IO->ErrMsg, "Failed to create socket: %s", strerror(errno));
                return eAbort;
        }
        fdflags = fcntl(IO->SendBuf.fd, F_GETFL);
        if (fdflags < 0) {
-               CtdlLogPrintf(CTDL_DEBUG,
-                             "EVENT: unable to get socket flags! %s \n",
-                             strerror(errno));
+               syslog(LOG_DEBUG, 
+                      "EVENT: unable to get socket flags! %s \n",
+                      strerror(errno));
                StrBufPrintf(IO->ErrMsg, "Failed to get socket flags: %s", strerror(errno));
                return eAbort;
        }
        fdflags = fdflags | O_NONBLOCK;
        if (fcntl(IO->SendBuf.fd, F_SETFL, fdflags) < 0) {
-               CtdlLogPrintf(CTDL_DEBUG,
-                             "EVENT: unable to set socket nonblocking flags! %s \n",
-                             strerror(errno));
+               syslog(LOG_DEBUG, 
+                      "EVENT: unable to set socket nonblocking flags! %s \n",
+                      strerror(errno));
                StrBufPrintf(IO->ErrMsg, "Failed to set socket flags: %s", strerror(errno));
                close(IO->SendBuf.fd);
                IO->SendBuf.fd = IO->RecvBuf.fd = -1;
@@ -657,13 +657,13 @@ eNextState event_connect_socket(AsyncIO *IO, double conn_timeout, double first_r
                rc = connect(IO->SendBuf.fd, (struct sockaddr_in *)&IO->ConnectMe->Addr, sizeof(struct sockaddr_in));
 
        if (rc >= 0){
-               CtdlLogPrintf(CTDL_DEBUG, "connect() immediate success.\n");
+               syslog(LOG_DEBUG, "connect() immediate success.\n");
                set_start_callback(event_base, IO, 0);
                ev_timer_start(event_base, &IO->rw_timeout);
                return IO->NextState;
        }
        else if (errno == EINPROGRESS) {
-               CtdlLogPrintf(CTDL_DEBUG, "connect() have to wait now.\n");
+               syslog(LOG_DEBUG, "connect() have to wait now.\n");
 
                ev_io_init(&IO->conn_event, IO_connestd_callback, IO->SendBuf.fd, EV_READ|EV_WRITE);
                IO->conn_event.data = IO;
@@ -678,7 +678,7 @@ eNextState event_connect_socket(AsyncIO *IO, double conn_timeout, double first_r
                IO->conn_fail_immediate.data = IO;
                ev_idle_start(event_base, &IO->conn_fail_immediate);
                
-               CtdlLogPrintf(CTDL_ERR, "connect() failed: %s\n", strerror(errno));
+               syslog(LOG_ERR, "connect() failed: %s\n", strerror(errno));
                StrBufPrintf(IO->ErrMsg, "Failed to connect: %s", strerror(errno));
                return IO->NextState;
        }
index cb833e0683c6cdc7e45d7ebb13be51445e1e9630..de36f29ed126b31c3c82d4ec0ffb6bf2984961ad 100644 (file)
@@ -163,7 +163,7 @@ void InitC_ares_dns(AsyncIO *IO);
        do { \
                sta = curl_easy_setopt(chnd, (CURLOPT_##s), (v)); \
                if (sta)  {                                             \
-                       CtdlLogPrintf(CTDL_ERR, "error setting option " #s " on curl handle: %s", curl_easy_strerror(sta)); \
+                       syslog(LOG_ERR, "error setting option " #s " on curl handle: %s", curl_easy_strerror(sta)); \
        } } while (0)
 
 
index 20bc03b68af2f900e6693061238a18f4901c596e..bb5e985a6c0e5c866f2207bb01db71dbd4475b9f 100644 (file)
@@ -97,7 +97,7 @@ int network_talking_to(char *nodename, int operation) {
                        break;
        }
 
-       if (nttlist != NULL) CtdlLogPrintf(CTDL_DEBUG, "nttlist=<%s>\n", nttlist);
+       if (nttlist != NULL) syslog(LOG_DEBUG, "nttlist=<%s>\n", nttlist);
        end_critical_section(S_NTTLIST);
        return(retval);
 }
@@ -601,7 +601,7 @@ void cmd_ucls(char *cmd)
                                unlink(CC->upl_path);
                        }
                        else {
-                               CtdlLogPrintf(CTDL_ALERT, "Cannot link %s to %s: %s\n",
+                               syslog(LOG_ALERT, "Cannot link %s to %s: %s\n",
                                        CC->upl_path, final_filename, strerror(errno)
                                );
                        }
index 0b2f2464d4ce8eb829ad14cfa8f60ce2f219cefc..9cce884473a0426b51cfd3ebc9c054b4c2cfc128 100644 (file)
@@ -1,5 +1,21 @@
 /*
  * This file contains miscellaneous housekeeping tasks.
+ *
+ * Copyright (c) 1987-2011 by the citadel.org team
+ *
+ * This program is open source software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
 #include "sysdep.h"
@@ -27,6 +43,7 @@
 #ifdef HAVE_SYS_SELECT_H
 #include <sys/select.h>
 #endif
+#include <syslog.h>
 #include <libcitadel.h>
 #include "citadel.h"
 #include "server.h"
@@ -45,7 +62,7 @@
 
 void check_sched_shutdown(void) {
        if ((ScheduledShutdown == 1) && (ContextList == NULL)) {
-               CtdlLogPrintf(CTDL_NOTICE, "Scheduled shutdown initiating.\n");
+               syslog(LOG_NOTICE, "Scheduled shutdown initiating.\n");
                CtdlThreadStopAll();
        }
 }
@@ -71,7 +88,7 @@ void check_ref_counts(void) {
 
        int new_refcounts[MAXFLOORS];
 
-       CtdlLogPrintf(CTDL_DEBUG, "Checking floor reference counts\n");
+       syslog(LOG_DEBUG, "Checking floor reference counts\n");
        for (a=0; a<MAXFLOORS; ++a) {
                new_refcounts[a] = 0;
        }
@@ -90,7 +107,7 @@ void check_ref_counts(void) {
                        flbuf.f_flags = flbuf.f_flags & ~QR_INUSE;
                }
                lputfloor(&flbuf, a);
-               CtdlLogPrintf(CTDL_DEBUG, "Floor %d: %d rooms\n", a, new_refcounts[a]);
+               syslog(LOG_DEBUG, "Floor %d: %d rooms\n", a, new_refcounts[a]);
        }
 }      
 
index 40e2516617c5122cb58a36fcaab345428eac70e7..41c67a7e7556261649db1aac46e37e2b7f7e6d6e 100644 (file)
@@ -13,6 +13,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <strings.h>
+#include <syslog.h>
 #include <libical/ical.h>
 #include <libcitadel.h>
 #include "citadel.h"
@@ -40,13 +41,13 @@ icaltimezone *get_default_icaltimezone(void) {
                 zone = icaltimezone_get_builtin_timezone(default_zone_name);
         }
         if (!zone) {
-               CtdlLogPrintf(CTDL_ALERT,
+               syslog(LOG_ALERT,
                        "Unable to load '%s' time zone.  Defaulting to UTC.\n",
                        default_zone_name);
                 zone = icaltimezone_get_utc_timezone();
        }
        if (!zone) {
-               CtdlLogPrintf(CTDL_ALERT, "Unable to load UTC time zone!\n");
+               syslog(LOG_ALERT, "Unable to load UTC time zone!\n");
        }
         return zone;
 }
@@ -81,16 +82,16 @@ void ical_dezonify_backend(icalcomponent *cal,
 
                /* Convert it to an icaltimezone type. */
                if (tzid != NULL) {
-                       /* CtdlLogPrintf(CTDL_DEBUG, "                * Stringy supplied timezone is: '%s'\n", tzid); */
+                       /* syslog(LOG_DEBUG, "                * Stringy supplied timezone is: '%s'\n", tzid); */
                        if ( (!strcasecmp(tzid, "UTC")) || (!strcasecmp(tzid, "GMT")) ) {
                                utc_declared_as_tzid = 1;
-                               /* CtdlLogPrintf(CTDL_DEBUG, "                * ...and we handle that internally.\n"); */
+                               /* syslog(LOG_DEBUG, "                * ...and we handle that internally.\n"); */
                        }
                        else {
                                /* try attached first */
                                t = icalcomponent_get_timezone(cal, tzid);
 /*
-                               lprintf(CTDL_DEBUG, "                * ...and I %s have tzdata for that zone.\n",
+                               syslog(LOG_DEBUG, "                * ...and I %s have tzdata for that zone.\n",
                                        (t ? "DO" : "DO NOT")
                                );
 */
@@ -99,7 +100,7 @@ void ical_dezonify_backend(icalcomponent *cal,
                                        t = icaltimezone_get_builtin_timezone(tzid);
 /*
                                        if (t) {
-                                               lprintf(CTDL_DEBUG, "                * Using system tzdata!\n");
+                                               syslog(LOG_DEBUG, "                * Using system tzdata!\n");
                                        }
 */
                                }
@@ -126,24 +127,24 @@ void ical_dezonify_backend(icalcomponent *cal,
                return;
        }
 
-       /* CtdlLogPrintf(CTDL_DEBUG, "                * Was: %s\n", icaltime_as_ical_string(TheTime)); */
+       /* syslog(LOG_DEBUG, "                * Was: %s\n", icaltime_as_ical_string(TheTime)); */
 
        if (TheTime.is_utc) {
-               /* CtdlLogPrintf(CTDL_DEBUG, "                * This property is ALREADY UTC.\n"); */
+               /* syslog(LOG_DEBUG, "                * This property is ALREADY UTC.\n"); */
        }
 
        else if (utc_declared_as_tzid) {
-               /* CtdlLogPrintf(CTDL_DEBUG, "                * Replacing '%s' TZID with 'Z' suffix.\n", tzid); */
+               /* syslog(LOG_DEBUG, "                * Replacing '%s' TZID with 'Z' suffix.\n", tzid); */
                TheTime.is_utc = 1;
        }
 
        else {
                /* Do the conversion. */
                if (t != NULL) {
-                       /* CtdlLogPrintf(CTDL_DEBUG, "                * Timezone prop found.  Converting to UTC.\n"); */
+                       /* syslog(LOG_DEBUG, "                * Timezone prop found.  Converting to UTC.\n"); */
                }
                else {
-                       /* CtdlLogPrintf(CTDL_DEBUG, "                * Converting default timezone to UTC.\n"); */
+                       /* syslog(LOG_DEBUG, "                * Converting default timezone to UTC.\n"); */
                }
 
                if (t == NULL) {
@@ -158,7 +159,7 @@ void ical_dezonify_backend(icalcomponent *cal,
        }
 
        icalproperty_remove_parameter_by_kind(prop, ICAL_TZID_PARAMETER);
-       /* CtdlLogPrintf(CTDL_DEBUG, "                * Now: %s\n", icaltime_as_ical_string(TheTime)); */
+       /* syslog(LOG_DEBUG, "                * Now: %s\n", icaltime_as_ical_string(TheTime)); */
 
        /* Now add the converted property back in. */
        if (icalproperty_isa(prop) == ICAL_DTSTART_PROPERTY) {
@@ -224,7 +225,7 @@ void ical_dezonify_recurse(icalcomponent *cal, icalcomponent *rcal) {
 void ical_dezonify(icalcomponent *cal) {
        icalcomponent *vt = NULL;
 
-       /* CtdlLogPrintf(CTDL_DEBUG, "ical_dezonify() started\n"); */
+       /* syslog(LOG_DEBUG, "ical_dezonify() started\n"); */
 
        /* Convert all times to UTC */
        ical_dezonify_recurse(cal, cal);
@@ -236,5 +237,5 @@ void ical_dezonify(icalcomponent *cal) {
                icalcomponent_free(vt);
        }
 
-       /* CtdlLogPrintf(CTDL_DEBUG, "ical_dezonify() completed\n"); */
+       /* syslog(LOG_DEBUG, "ical_dezonify() completed\n"); */
 }
index 067071862122cef7d231c80f46749585caa7693f..543f1ed4bb5eeab0d86c4fe65b9065988b6b5ca9 100644 (file)
@@ -24,6 +24,7 @@
 #include <signal.h>
 #include <pwd.h>
 #include <errno.h>
+#include <syslog.h>
 #include <sys/types.h>
 
 #if TIME_WITH_SYS_TIME
 
 #define CTDL_UPGRADE_CALL(module_name) ctdl_module_##module_name##_upgrade ()
 
-
-/*
- * Prototype for making log entries in Citadel.
- */
-
-void CtdlLogPrintf(enum LogLevel loglevel, const char *format, ...);
-
 #define CtdlAideMessage(TEXT, SUBJECT) quickie_message("Citadel",NULL,NULL,AIDEROOM,TEXT,FMT_CITADEL,SUBJECT) 
-
 /*
  * Hook functions available to modules.
  */
index 4bb4bbf9971045fe89dc434527bc31269eae578c..05f07860d4a6c339177a763adf0d6942062cd370 100644 (file)
@@ -604,7 +604,7 @@ int convert_field(struct CtdlMessage *msg, const char *beg, const char *end) {
 
        else if (!strcasecmp(key, "From")) {
                process_rfc822_addr(value, user, node, name);
-               CtdlLogPrintf(CTDL_DEBUG, "Converted to <%s@%s> (%s)\n", user, node, name);
+               syslog(LOG_DEBUG, "Converted to <%s@%s> (%s)\n", user, node, name);
                snprintf(addr, sizeof addr, "%s@%s", user, node);
                if (msg->cm_fields['A'] == NULL)
                        msg->cm_fields['A'] = strdup(name);
@@ -640,7 +640,7 @@ int convert_field(struct CtdlMessage *msg, const char *beg, const char *end) {
 
        else if (!strcasecmp(key, "Message-ID")) {
                if (msg->cm_fields['I'] != NULL) {
-                       CtdlLogPrintf(CTDL_WARNING, "duplicate message id\n");
+                       syslog(LOG_WARNING, "duplicate message id\n");
                }
 
                if (msg->cm_fields['I'] == NULL) {
@@ -911,7 +911,7 @@ void directory_key(char *key, char *addr) {
        }
        key[keylen++] = 0;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Directory key is <%s>\n", key);
+       syslog(LOG_DEBUG, "Directory key is <%s>\n", key);
 }
 
 
@@ -955,7 +955,7 @@ void CtdlDirectoryAddUser(char *internet_addr, char *citadel_addr) {
        char key[SIZ];
 
        if (IsDirectory(internet_addr, 0) == 0) return;
-       CtdlLogPrintf(CTDL_DEBUG, "Create directory entry: %s --> %s\n", internet_addr, citadel_addr);
+       syslog(LOG_DEBUG, "Create directory entry: %s --> %s\n", internet_addr, citadel_addr);
        directory_key(key, internet_addr);
        cdb_store(CDB_DIRECTORY, key, strlen(key), citadel_addr, strlen(citadel_addr)+1 );
 }
@@ -970,7 +970,7 @@ void CtdlDirectoryAddUser(char *internet_addr, char *citadel_addr) {
 void CtdlDirectoryDelUser(char *internet_addr, char *citadel_addr) {
        char key[SIZ];
 
-       CtdlLogPrintf(CTDL_DEBUG, "Delete directory entry: %s --> %s\n", internet_addr, citadel_addr);
+       syslog(LOG_DEBUG, "Delete directory entry: %s --> %s\n", internet_addr, citadel_addr);
        directory_key(key, internet_addr);
        cdb_delete(CDB_DIRECTORY, key, strlen(key) );
 }
index 75bbb976a5fe17d85021700c76ddb190afff23ea..8efc6e59075bc7d6f8ab9b7e167e11c05b4ad434 100644 (file)
@@ -91,7 +91,7 @@ int CtdlTryUserLDAP(char *username,
 
        ldserver = ldap_init(config.c_ldap_host, config.c_ldap_port);
        if (ldserver == NULL) {
-               CtdlLogPrintf(CTDL_ALERT, "LDAP: Could not connect to %s:%d : %s\n",
+               syslog(LOG_ALERT, "LDAP: Could not connect to %s:%d : %s\n",
                        config.c_ldap_host, config.c_ldap_port,
                        strerror(errno)
                );
@@ -102,13 +102,13 @@ int CtdlTryUserLDAP(char *username,
 
        striplt(config.c_ldap_bind_dn);
        striplt(config.c_ldap_bind_pw);
-       CtdlLogPrintf(CTDL_DEBUG, "LDAP bind DN: %s\n", config.c_ldap_bind_dn);
+       syslog(LOG_DEBUG, "LDAP bind DN: %s\n", config.c_ldap_bind_dn);
        i = ldap_simple_bind_s(ldserver,
                (!IsEmptyStr(config.c_ldap_bind_dn) ? config.c_ldap_bind_dn : NULL),
                (!IsEmptyStr(config.c_ldap_bind_pw) ? config.c_ldap_bind_pw : NULL)
        );
        if (i != LDAP_SUCCESS) {
-               CtdlLogPrintf(CTDL_ALERT, "LDAP: Cannot bind: %s (%d)\n", ldap_err2string(i), i);
+               syslog(LOG_ALERT, "LDAP: Cannot bind: %s (%d)\n", ldap_err2string(i), i);
                return(i);
        }
 
@@ -122,7 +122,7 @@ int CtdlTryUserLDAP(char *username,
                sprintf(searchstring, "(&(objectclass=posixAccount)(uid=%s))", username);
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "LDAP search: %s\n", searchstring);
+       syslog(LOG_DEBUG, "LDAP search: %s\n", searchstring);
        i = ldap_search_ext_s(ldserver,                         /* ld                           */
                config.c_ldap_base_dn,                          /* base                         */
                LDAP_SCOPE_SUBTREE,                             /* scope                        */
@@ -140,7 +140,7 @@ int CtdlTryUserLDAP(char *username,
         * the search succeeds.  Instead, we check to see whether search_result is still NULL.
         */
        if (search_result == NULL) {
-               CtdlLogPrintf(CTDL_DEBUG, "LDAP search: zero results were returned\n");
+               syslog(LOG_DEBUG, "LDAP search: zero results were returned\n");
                ldap_unbind(ldserver);
                return(2);
        }
@@ -153,7 +153,7 @@ int CtdlTryUserLDAP(char *username,
 
                user_dn = ldap_get_dn(ldserver, entry);
                if (user_dn) {
-                       CtdlLogPrintf(CTDL_DEBUG, "dn = %s\n", user_dn);
+                       syslog(LOG_DEBUG, "dn = %s\n", user_dn);
                }
 
                if (config.c_auth_mode == AUTHMODE_LDAP_AD) {
@@ -161,7 +161,7 @@ int CtdlTryUserLDAP(char *username,
                        if (values) {
                                if (values[0]) {
                                        if (fullname) safestrncpy(fullname, values[0], fullname_size);
-                                       CtdlLogPrintf(CTDL_DEBUG, "displayName = %s\n", values[0]);
+                                       syslog(LOG_DEBUG, "displayName = %s\n", values[0]);
                                }
                                ldap_value_free(values);
                        }
@@ -171,7 +171,7 @@ int CtdlTryUserLDAP(char *username,
                        if (values) {
                                if (values[0]) {
                                        if (fullname) safestrncpy(fullname, values[0], fullname_size);
-                                       CtdlLogPrintf(CTDL_DEBUG, "cn = %s\n", values[0]);
+                                       syslog(LOG_DEBUG, "cn = %s\n", values[0]);
                                }
                                ldap_value_free(values);
                        }
@@ -183,7 +183,7 @@ int CtdlTryUserLDAP(char *username,
                                if (values[0]) {
                                        if (uid != NULL) {
                                                *uid = abs(HashLittle(values[0], strlen(values[0])));
-                                               CtdlLogPrintf(CTDL_DEBUG, "uid hashed from objectGUID = %d\n", *uid);
+                                               syslog(LOG_DEBUG, "uid hashed from objectGUID = %d\n", *uid);
                                        }
                                }
                                ldap_value_free(values);
@@ -193,7 +193,7 @@ int CtdlTryUserLDAP(char *username,
                        values = ldap_get_values(ldserver, search_result, "uidNumber");
                        if (values) {
                                if (values[0]) {
-                                       CtdlLogPrintf(CTDL_DEBUG, "uidNumber = %s\n", values[0]);
+                                       syslog(LOG_DEBUG, "uidNumber = %s\n", values[0]);
                                        if (uid != NULL) {
                                                *uid = atoi(values[0]);
                                        }
@@ -211,7 +211,7 @@ int CtdlTryUserLDAP(char *username,
        ldap_unbind(ldserver);
 
        if (!user_dn) {
-               CtdlLogPrintf(CTDL_DEBUG, "No such user was found.\n");
+               syslog(LOG_DEBUG, "No such user was found.\n");
                return(4);
        }
 
@@ -227,20 +227,20 @@ int CtdlTryPasswordLDAP(char *user_dn, const char *password)
        int i = (-1);
 
        if (IsEmptyStr(password)) {
-               CtdlLogPrintf(CTDL_DEBUG, "LDAP: empty passwords are not permitted\n");
+               syslog(LOG_DEBUG, "LDAP: empty passwords are not permitted\n");
                return(1);
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "LDAP: trying to bind as %s\n", user_dn);
+       syslog(LOG_DEBUG, "LDAP: trying to bind as %s\n", user_dn);
        ldserver = ldap_init(config.c_ldap_host, config.c_ldap_port);
        if (ldserver) {
                ldap_set_option(ldserver, LDAP_OPT_PROTOCOL_VERSION, &ctdl_require_ldap_version);
                i = ldap_simple_bind_s(ldserver, user_dn, password);
                if (i == LDAP_SUCCESS) {
-                       CtdlLogPrintf(CTDL_DEBUG, "LDAP: bind succeeded\n");
+                       syslog(LOG_DEBUG, "LDAP: bind succeeded\n");
                }
                else {
-                       CtdlLogPrintf(CTDL_DEBUG, "LDAP: Cannot bind: %s (%d)\n", ldap_err2string(i), i);
+                       syslog(LOG_DEBUG, "LDAP: Cannot bind: %s (%d)\n", ldap_err2string(i), i);
                }
                ldap_unbind(ldserver);
        }
index e1693d25cd92571c7beccc7a26c7d3dd00e8b643..20704c927c3958f8a419f109fa70bf84018cef20 100644 (file)
@@ -1,5 +1,21 @@
 /*
  * Functions which handle hostname/address lookups and resolution
+ *
+ * Copyright (c) 1987-2011 by the citadel.org team
+ *
+ * This program is open source software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
 #include "sysdep.h"
@@ -16,6 +32,7 @@
 #include <netdb.h>
 #include <string.h>
 #include <errno.h>
+#include <syslog.h>
 #include <libcitadel.h>
 #include "citadel.h"
 #include "server.h"
@@ -296,7 +313,7 @@ int rbl_check(char *message_to_spammer)
 
                if (rblcheck_backend(tbuf, txt_answer, sizeof txt_answer)) {
                        strcpy(message_to_spammer, txt_answer);
-                       CtdlLogPrintf(CTDL_INFO, "RBL: %s\n", txt_answer);
+                       syslog(LOG_INFO, "RBL: %s\n", txt_answer);
                        return(1);
                }
        }
index cba9d8303e52c4236ea69b1074fe9540db5892a0..4b00d727712bd6c1ff5c4d2b0832959ca94e99f2 100644 (file)
@@ -226,7 +226,7 @@ void QueryCb(void *arg,
                     IO_postdns_callback);
        IO->unwind_stack.data = IO;
        ev_idle_start(event_base, &IO->unwind_stack);
-       CtdlLogPrintf(CTDL_DEBUG, "C-ARES: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "C-ARES: %s\n", __FUNCTION__);
 }
 
 void QueryCbDone(AsyncIO *IO)
@@ -261,7 +261,7 @@ void QueueGetHostByNameDone(void *Ctx,
                     IO_postdns_callback);
        IO->unwind_stack.data = IO;
        ev_idle_start(event_base, &IO->unwind_stack);
-       CtdlLogPrintf(CTDL_DEBUG, "C-ARES: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "C-ARES: %s\n", __FUNCTION__);
 }
 
 void QueueGetHostByName(AsyncIO *IO, const char *Hostname, DNSQueryParts *QueryParts, IO_CallBack PostDNS)
index d2bf8d03fc248f0c9f8bf997dd19c0e0e1b594d7..314a5ccea42aacc5d16f98a8d10d10ff091bac7e 100644 (file)
@@ -4,9 +4,9 @@
  * iTIP protocol.  See RFCs 2445 and 2446.
  *
  *
- * Copyright (c) 1987-2009 by the citadel.org team
+ * Copyright (c) 1987-2011 by the citadel.org team
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  This program is open source software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 3 of the License, or
  *  (at your option) any later version.
@@ -50,7 +50,7 @@ icalcomponent *icalcomponent_new_citadel_vcalendar(void) {
 
        encaps = icalcomponent_new_vcalendar();
        if (encaps == NULL) {
-               CtdlLogPrintf(CTDL_CRIT, "ERROR: could not allocate component!\n");
+               syslog(LOG_CRIT, "ERROR: could not allocate component!\n");
                return NULL;
        }
 
@@ -186,13 +186,13 @@ void ical_send_a_reply(icalcomponent *request, char *action) {
        strcpy(summary_string, "Calendar item");
 
        if (request == NULL) {
-               CtdlLogPrintf(CTDL_ERR, "ERROR: trying to reply to NULL event?\n");
+               syslog(LOG_ERR, "ERROR: trying to reply to NULL event?\n");
                return;
        }
 
        the_reply = icalcomponent_new_clone(request);
        if (the_reply == NULL) {
-               CtdlLogPrintf(CTDL_ERR, "ERROR: cannot clone request\n");
+               syslog(LOG_ERR, "ERROR: cannot clone request\n");
                return;
        }
 
@@ -594,13 +594,13 @@ int ical_update_my_calendar_with_reply(icalcomponent *cal) {
        /* Figure out just what event it is we're dealing with */
        strcpy(uid, "--==<< InVaLiD uId >>==--");
        ical_learn_uid_of_reply(uid, cal);
-       CtdlLogPrintf(CTDL_DEBUG, "UID of event being replied to is <%s>\n", uid);
+       syslog(LOG_DEBUG, "UID of event being replied to is <%s>\n", uid);
 
        strcpy(hold_rm, CC->room.QRname);       /* save current room */
 
        if (CtdlGetRoom(&CC->room, USERCALENDARROOM) != 0) {
                CtdlGetRoom(&CC->room, hold_rm);
-               CtdlLogPrintf(CTDL_CRIT, "cannot get user calendar room\n");
+               syslog(LOG_CRIT, "cannot get user calendar room\n");
                return(2);
        }
 
@@ -614,7 +614,7 @@ int ical_update_my_calendar_with_reply(icalcomponent *cal) {
 
        CtdlGetRoom(&CC->room, hold_rm);        /* return to saved room */
 
-       CtdlLogPrintf(CTDL_DEBUG, "msgnum_being_replaced == %ld\n", msgnum_being_replaced);
+       syslog(LOG_DEBUG, "msgnum_being_replaced == %ld\n", msgnum_being_replaced);
        if (msgnum_being_replaced == 0) {
                return(1);                      /* no calendar event found */
        }
@@ -641,7 +641,7 @@ int ical_update_my_calendar_with_reply(icalcomponent *cal) {
 
        original_event = oec.c;
        if (original_event == NULL) {
-               CtdlLogPrintf(CTDL_ERR, "ERROR: Original_component is NULL.\n");
+               syslog(LOG_ERR, "ERROR: Original_component is NULL.\n");
                return(2);
        }
 
@@ -845,7 +845,7 @@ int ical_ctdl_is_overlap(
                return(1);
        }
 
-       /* lprintf (9, "Comparing t1start %d:%d t1end %d:%d t2start %d:%d t2end %d:%d \n",
+       /* syslog(LOG_DEBUG, "Comparing t1start %d:%d t1end %d:%d t2start %d:%d t2end %d:%d \n",
                t1start.hour, t1start.minute, t1end.hour, t1end.minute,
                t2start.hour, t2start.minute, t2end.hour, t2end.minute);
        */
@@ -854,11 +854,11 @@ int ical_ctdl_is_overlap(
 
        /* If event 1 ends before event 2 starts, we're in the clear. */
        if (icaltime_compare(t1end, t2start) <= 0) return(0);
-       /* lprintf(9, "first passed\n"); */
+       /* syslog(LOG_DEBUG, "first passed\n"); */
 
        /* If event 2 ends before event 1 starts, we're also ok. */
        if (icaltime_compare(t2end, t1start) <= 0) return(0);
-       /* lprintf(9, "second passed\n"); */
+       /* syslog(LOG_DEBUG, "second passed\n"); */
 
        /* Otherwise, they overlap. */
        return(1);
@@ -887,13 +887,13 @@ int ical_conflicts_phase6(struct icaltimetype t1start,
        /* debugging cruft *
        time_t tt;
        tt = icaltime_as_timet_with_zone(t1start, t1start.zone);
-       CtdlLogPrintf(CTDL_DEBUG, "PROPOSED START: %s", ctime(&tt));
+       syslog(LOG_DEBUG, "PROPOSED START: %s", ctime(&tt));
        tt = icaltime_as_timet_with_zone(t1end, t1end.zone);
-       CtdlLogPrintf(CTDL_DEBUG, "  PROPOSED END: %s", ctime(&tt));
+       syslog(LOG_DEBUG, "  PROPOSED END: %s", ctime(&tt));
        tt = icaltime_as_timet_with_zone(t2start, t2start.zone);
-       CtdlLogPrintf(CTDL_DEBUG, "EXISTING START: %s", ctime(&tt));
+       syslog(LOG_DEBUG, "EXISTING START: %s", ctime(&tt));
        tt = icaltime_as_timet_with_zone(t2end, t2end.zone);
-       CtdlLogPrintf(CTDL_DEBUG, "  EXISTING END: %s", ctime(&tt));
+       syslog(LOG_DEBUG, "  EXISTING END: %s", ctime(&tt));
        * debugging cruft */
 
        /* compare and output */
@@ -1430,7 +1430,7 @@ void ical_freebusy(char *who) {
        if (found_user != 0) {
                strcpy(buf, who);
                recp = validate_recipients(buf, NULL, 0);
-               CtdlLogPrintf(CTDL_DEBUG, "Trying <%s>\n", buf);
+               syslog(LOG_DEBUG, "Trying <%s>\n", buf);
                if (recp != NULL) {
                        if (recp->num_local == 1) {
                                found_user = CtdlGetUser(&usbuf, recp->recp_local);
@@ -1444,7 +1444,7 @@ void ical_freebusy(char *who) {
         */
        if (found_user != 0) {
                snprintf(buf, sizeof buf, "%s@%s", who, config.c_fqdn);
-               CtdlLogPrintf(CTDL_DEBUG, "Trying <%s>\n", buf);
+               syslog(LOG_DEBUG, "Trying <%s>\n", buf);
                recp = validate_recipients(buf, NULL, 0);
                if (recp != NULL) {
                        if (recp->num_local == 1) {
@@ -1467,7 +1467,7 @@ void ical_freebusy(char *who) {
                        if ( (!strcasecmp(type, "localhost"))
                           || (!strcasecmp(type, "directory")) ) {
                                snprintf(buf, sizeof buf, "%s@%s", who, host);
-                               CtdlLogPrintf(CTDL_DEBUG, "Trying <%s>\n", buf);
+                               syslog(LOG_DEBUG, "Trying <%s>\n", buf);
                                recp = validate_recipients(buf, NULL, 0);
                                if (recp != NULL) {
                                        if (recp->num_local == 1) {
@@ -1496,7 +1496,7 @@ void ical_freebusy(char *who) {
        }
 
        /* Create a VFREEBUSY subcomponent */
-       CtdlLogPrintf(CTDL_DEBUG, "Creating VFREEBUSY component\n");
+       syslog(LOG_DEBUG, "Creating VFREEBUSY component\n");
        fb = icalcomponent_new_vfreebusy();
        if (fb == NULL) {
                cprintf("%d Internal error: cannot allocate memory.\n",
@@ -1523,7 +1523,7 @@ void ical_freebusy(char *who) {
        icalcomponent_add_property(fb, icalproperty_new_organizer(buf));
 
        /* Add busy time from events */
-       CtdlLogPrintf(CTDL_DEBUG, "Adding busy time from events\n");
+       syslog(LOG_DEBUG, "Adding busy time from events\n");
        CtdlForEachMessage(MSGS_ALL, 0, NULL, NULL, NULL, ical_freebusy_backend, (void *)fb );
 
        /* If values for DTSTART and DTEND are still not present, set them
@@ -1537,7 +1537,7 @@ void ical_freebusy(char *who) {
        }
 
        /* Put the freebusy component into the calendar component */
-       CtdlLogPrintf(CTDL_DEBUG, "Encapsulating\n");
+       syslog(LOG_DEBUG, "Encapsulating\n");
        encaps = ical_encapsulate_subcomponent(fb);
        if (encaps == NULL) {
                icalcomponent_free(fb);
@@ -1548,11 +1548,11 @@ void ical_freebusy(char *who) {
        }
 
        /* Set the method to PUBLISH */
-       CtdlLogPrintf(CTDL_DEBUG, "Setting method\n");
+       syslog(LOG_DEBUG, "Setting method\n");
        icalcomponent_set_method(encaps, ICAL_METHOD_PUBLISH);
 
        /* Serialize it */
-       CtdlLogPrintf(CTDL_DEBUG, "Serializing\n");
+       syslog(LOG_DEBUG, "Serializing\n");
        serialized_request = icalcomponent_as_ical_string_r(encaps);
        icalcomponent_free(encaps);     /* Don't need this anymore. */
 
@@ -1661,7 +1661,7 @@ void ical_getics(void)
 
        encaps = icalcomponent_new_vcalendar();
        if (encaps == NULL) {
-               CtdlLogPrintf(CTDL_ALERT, "ERROR: could not allocate component!\n");
+               syslog(LOG_ALERT, "ERROR: could not allocate component!\n");
                cprintf("%d Could not allocate memory\n", ERROR+INTERNAL_ERROR);
                return;
        }
@@ -1787,7 +1787,7 @@ void ical_putics(void)
                                HashPos = GetNewHashPos(tzidlist, 0);
 
                                while (GetNextHashPos(tzidlist, HashPos, &len, &Key, &Value)) {
-                                       CtdlLogPrintf(CTDL_DEBUG, "Attaching timezone '%s'\n", (char*) Value);
+                                       syslog(LOG_DEBUG, "Attaching timezone '%s'\n", (char*) Value);
                                        icaltimezone *t = NULL;
 
                                        /* First look for a timezone attached to the original calendar */
@@ -1912,7 +1912,7 @@ void ical_CtdlCreateRoom(void)
 
        /* Set expiration policy to manual; otherwise objects will be lost! */
        if (CtdlGetRoomLock(&qr, USERCALENDARROOM)) {
-               CtdlLogPrintf(CTDL_CRIT, "Couldn't get the user calendar room!\n");
+               syslog(LOG_CRIT, "Couldn't get the user calendar room!\n");
                return;
        }
        qr.QRep.expire_mode = EXPIRE_MANUAL;
@@ -1929,7 +1929,7 @@ void ical_CtdlCreateRoom(void)
 
        /* Set expiration policy to manual; otherwise objects will be lost! */
        if (CtdlGetRoomLock(&qr, USERTASKSROOM)) {
-               CtdlLogPrintf(CTDL_CRIT, "Couldn't get the user calendar room!\n");
+               syslog(LOG_CRIT, "Couldn't get the user calendar room!\n");
                return;
        }
        qr.QRep.expire_mode = EXPIRE_MANUAL;
@@ -1946,7 +1946,7 @@ void ical_CtdlCreateRoom(void)
 
        /* Set expiration policy to manual; otherwise objects will be lost! */
        if (CtdlGetRoomLock(&qr, USERNOTESROOM)) {
-               CtdlLogPrintf(CTDL_CRIT, "Couldn't get the user calendar room!\n");
+               syslog(LOG_CRIT, "Couldn't get the user calendar room!\n");
                return;
        }
        qr.QRep.expire_mode = EXPIRE_MANUAL;
@@ -1995,7 +1995,7 @@ void ical_send_out_invitations(icalcomponent *top_level_cal, icalcomponent *cal)
        const char *tzidc = NULL;
 
        if (cal == NULL) {
-               CtdlLogPrintf(CTDL_ERR, "ERROR: trying to reply to NULL event?\n");
+               syslog(LOG_ERR, "ERROR: trying to reply to NULL event?\n");
                return;
        }
 
@@ -2013,7 +2013,7 @@ void ical_send_out_invitations(icalcomponent *top_level_cal, icalcomponent *cal)
        /* Clone the event */
        the_request = icalcomponent_new_clone(cal);
        if (the_request == NULL) {
-               CtdlLogPrintf(CTDL_ERR, "ERROR: cannot clone calendar object\n");
+               syslog(LOG_ERR, "ERROR: cannot clone calendar object\n");
                return;
        }
 
@@ -2049,7 +2049,7 @@ void ical_send_out_invitations(icalcomponent *top_level_cal, icalcomponent *cal)
                }
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "<%d> attendees: <%s>\n", num_attendees, attendees_string);
+       syslog(LOG_DEBUG, "<%d> attendees: <%s>\n", num_attendees, attendees_string);
 
        /* If there are no attendees, there are no invitations to send, so...
         * don't bother putting one together!  Punch out, Maverick!
@@ -2062,7 +2062,7 @@ void ical_send_out_invitations(icalcomponent *top_level_cal, icalcomponent *cal)
        /* Encapsulate the VEVENT component into a complete VCALENDAR */
        encaps = icalcomponent_new_vcalendar();
        if (encaps == NULL) {
-               CtdlLogPrintf(CTDL_ALERT, "ERROR: could not allocate component!\n");
+               syslog(LOG_ALERT, "ERROR: could not allocate component!\n");
                icalcomponent_free(the_request);
                return;
        }
@@ -2214,7 +2214,7 @@ void ical_saving_vevent(icalcomponent *top_level_cal, icalcomponent *cal) {
        icalproperty *organizer = NULL;
        char organizer_string[SIZ];
 
-       CtdlLogPrintf(CTDL_DEBUG, "ical_saving_vevent() has been called!\n");
+       syslog(LOG_DEBUG, "ical_saving_vevent() has been called!\n");
 
        /* Don't send out invitations unless the client wants us to. */
        if (CIT_ICAL->server_generated_invitations == 0) {
@@ -2329,7 +2329,7 @@ void ical_obj_beforesave_backend(char *name, char *filename, char *partnum,
                                                free(msg->cm_fields['E']);
                                        }
                                        msg->cm_fields['E'] = strdup(buf);
-                                       CtdlLogPrintf(CTDL_DEBUG, "Saving calendar UID <%s>\n", buf);
+                                       syslog(LOG_DEBUG, "Saving calendar UID <%s>\n", buf);
                                }
                        }
 
@@ -2390,7 +2390,7 @@ int ical_obj_beforesave(struct CtdlMessage *msg)
 
        /* It must be an RFC822 message! */
        if (msg->cm_format_type != 4) {
-               CtdlLogPrintf(CTDL_DEBUG, "Rejecting non-RFC822 message\n");
+               syslog(LOG_DEBUG, "Rejecting non-RFC822 message\n");
                return(1);              /* You tried to save a non-RFC822 message! */
        }
 
index 0b36b086cd6c9025e0715a4f5ed40b4e25c55f8a..061f980a7289c7f8c3b758ae2524d75132a8c4af 100644 (file)
@@ -66,13 +66,13 @@ void *checkpoint_thread(void *arg) {
        CtdlFillSystemContext(&checkpointCC, "checkpoint");
        citthread_setspecific(MyConKey, (void *)&checkpointCC );
 
-       CtdlLogPrintf(CTDL_DEBUG, "checkpoint_thread() initializing\n");
+       syslog(LOG_DEBUG, "checkpoint_thread() initializing\n");
        while (!CtdlThreadCheckStop()) {
                cdb_checkpoint();
                CtdlThreadSleep(60);
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "checkpoint_thread() exiting\n");
+       syslog(LOG_DEBUG, "checkpoint_thread() exiting\n");
        CtdlClearSystemContext();
        return NULL;
 }
index e57435cb793beea6951b847d303f49f2948518cc..f1d6b105ae24d50e96ff9c79d3304a00bbc69ef4 100644 (file)
@@ -94,7 +94,7 @@ int clamd(struct CtdlMessage *msg) {
        /* Try them one by one until we get a working one */
         for (clamhost=0; clamhost<num_clamhosts; ++clamhost) {
                 extract_token(buf, clamhosts, clamhost, '|', sizeof buf);
-                CtdlLogPrintf(CTDL_INFO, "Connecting to clamd at <%s>\n", buf);
+                syslog(LOG_INFO, "Connecting to clamd at <%s>\n", buf);
 
                 /* Assuming a host:port entry */ 
                 extract_token(hostbuf, buf, 0, ':', sizeof hostbuf);
@@ -105,7 +105,7 @@ int clamd(struct CtdlMessage *msg) {
                   /* Port specified lets try connecting to it! */
                   sock = sock_connect(hostbuf, portbuf);
 
-                if (sock >= 0) CtdlLogPrintf(CTDL_DEBUG, "Connected!\n");
+                if (sock >= 0) syslog(LOG_DEBUG, "Connected!\n");
         }
 
        if (sock < 0) {
@@ -120,16 +120,16 @@ int clamd(struct CtdlMessage *msg) {
        CCC->SBuf.ReadWritePointer = NULL;
 
        /* Command */
-       CtdlLogPrintf(CTDL_DEBUG, "Transmitting STREAM command\n");
+       syslog(LOG_DEBUG, "Transmitting STREAM command\n");
        sprintf(buf, "STREAM\r\n");
        sock_write(&sock, buf, strlen(buf));
 
-       CtdlLogPrintf(CTDL_DEBUG, "Waiting for PORT number\n");
+       syslog(LOG_DEBUG, "Waiting for PORT number\n");
         if (sock_getln(&sock, buf, sizeof buf) < 0) {
                 goto bail;
         }
 
-        CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+        syslog(LOG_DEBUG, "<%s\n", buf);
        if (strncasecmp(buf, "PORT", 4)!=0) {
                goto bail;
        }
@@ -149,7 +149,7 @@ int clamd(struct CtdlMessage *msg) {
                return(0);
         }
        else {
-               CtdlLogPrintf(CTDL_DEBUG, "STREAM socket connected!\n");
+               syslog(LOG_DEBUG, "STREAM socket connected!\n");
        }
 
 
@@ -170,11 +170,11 @@ int clamd(struct CtdlMessage *msg) {
                close(streamsock);
        
        /* Response */
-       CtdlLogPrintf(CTDL_DEBUG, "Awaiting response\n");
+       syslog(LOG_DEBUG, "Awaiting response\n");
         if (sock_getln(&sock, buf, sizeof buf) < 0) {
                 goto bail;
         }
-        CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+        syslog(LOG_DEBUG, "<%s\n", buf);
        if (strncasecmp(buf, "stream: OK", 10)!=0) {
                is_virus = 1;
        }
index 66693a7927c8669737bf3b83597c7499b72ee4d2..6afeee84bc7c0b7a643ea51fce35093bff23932a 100644 (file)
@@ -93,14 +93,14 @@ void init_ssl(void)
                RAND_egd(EGD_POOL);
 
        if (!RAND_status()) {
-               CtdlLogPrintf(CTDL_CRIT,
+               syslog(LOG_CRIT,
                        "PRNG not adequately seeded, won't do SSL/TLS\n");
                return;
        }
        SSLCritters =
            malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t *));
        if (!SSLCritters) {
-               CtdlLogPrintf(CTDL_EMERG, "citserver: can't allocate memory!!\n");
+               syslog(LOG_EMERG, "citserver: can't allocate memory!!\n");
                /* Nothing's been initialized, just die */
                exit(1);
        } else {
@@ -109,7 +109,7 @@ void init_ssl(void)
                for (a = 0; a < CRYPTO_num_locks(); a++) {
                        SSLCritters[a] = malloc(sizeof(pthread_mutex_t));
                        if (!SSLCritters[a]) {
-                               CtdlLogPrintf(CTDL_EMERG,
+                               syslog(LOG_EMERG,
                                        "citserver: can't allocate memory!!\n");
                                /* Nothing's been initialized, just die */
                                exit(1);
@@ -125,12 +125,12 @@ void init_ssl(void)
        SSL_load_error_strings();
        ssl_method = SSLv23_server_method();
        if (!(ssl_ctx = SSL_CTX_new(ssl_method))) {
-               CtdlLogPrintf(CTDL_CRIT, "SSL_CTX_new failed: %s\n",
+               syslog(LOG_CRIT, "SSL_CTX_new failed: %s\n",
                        ERR_reason_error_string(ERR_get_error()));
                return;
        }
        if (!(SSL_CTX_set_cipher_list(ssl_ctx, CIT_CIPHERS))) {
-               CtdlLogPrintf(CTDL_CRIT, "SSL: No ciphers available\n");
+               syslog(LOG_CRIT, "SSL: No ciphers available\n");
                SSL_CTX_free(ssl_ctx);
                ssl_ctx = NULL;
                return;
@@ -148,21 +148,21 @@ void init_ssl(void)
        /* Load DH parameters into the context */
        dh = DH_new();
        if (!dh) {
-               CtdlLogPrintf(CTDL_CRIT, "init_ssl() can't allocate a DH object: %s\n",
+               syslog(LOG_CRIT, "init_ssl() can't allocate a DH object: %s\n",
                        ERR_reason_error_string(ERR_get_error()));
                SSL_CTX_free(ssl_ctx);
                ssl_ctx = NULL;
                return;
        }
        if (!(BN_hex2bn(&(dh->p), DH_P))) {
-               CtdlLogPrintf(CTDL_CRIT, "init_ssl() can't assign DH_P: %s\n",
+               syslog(LOG_CRIT, "init_ssl() can't assign DH_P: %s\n",
                        ERR_reason_error_string(ERR_get_error()));
                SSL_CTX_free(ssl_ctx);
                ssl_ctx = NULL;
                return;
        }
        if (!(BN_hex2bn(&(dh->g), DH_G))) {
-               CtdlLogPrintf(CTDL_CRIT, "init_ssl() can't assign DH_G: %s\n",
+               syslog(LOG_CRIT, "init_ssl() can't assign DH_G: %s\n",
                        ERR_reason_error_string(ERR_get_error()));
                SSL_CTX_free(ssl_ctx);
                ssl_ctx = NULL;
@@ -181,13 +181,13 @@ void init_ssl(void)
         * Generate a key pair if we don't have one.
         */
        if (access(file_crpt_file_key, R_OK) != 0) {
-               CtdlLogPrintf(CTDL_INFO, "Generating RSA key pair.\n");
+               syslog(LOG_INFO, "Generating RSA key pair.\n");
                rsa = RSA_generate_key(1024,    /* modulus size */
                                        65537,  /* exponent */
                                        NULL,   /* no callback */
                                        NULL);  /* no callback */
                if (rsa == NULL) {
-                       CtdlLogPrintf(CTDL_CRIT, "Key generation failed: %s\n",
+                       syslog(LOG_CRIT, "Key generation failed: %s\n",
                                ERR_reason_error_string(ERR_get_error()));
                }
                if (rsa != NULL) {
@@ -202,7 +202,7 @@ void init_ssl(void)
                                                        NULL,   /* no callbk */
                                                        NULL    /* no callbk */
                                ) != 1) {
-                                       CtdlLogPrintf(CTDL_CRIT, "Cannot write key: %s\n",
+                                       syslog(LOG_CRIT, "Cannot write key: %s\n",
                                                ERR_reason_error_string(ERR_get_error()));
                                        unlink(file_crpt_file_key);
                                }
@@ -218,7 +218,7 @@ void init_ssl(void)
         * the CSR in this step so that the next step may commence.
         */
        if ( (access(file_crpt_file_cer, R_OK) != 0) && (access(file_crpt_file_csr, R_OK) != 0) ) {
-               CtdlLogPrintf(CTDL_INFO, "Generating a certificate signing request.\n");
+               syslog(LOG_INFO, "Generating a certificate signing request.\n");
 
                /*
                 * Read our key from the file.  No, we don't just keep this
@@ -281,7 +281,7 @@ void init_ssl(void)
 
                                        /* Sign the CSR */
                                        if (!X509_REQ_sign(req, pk, EVP_md5())) {
-                                               CtdlLogPrintf(CTDL_CRIT, "X509_REQ_sign(): error\n");
+                                               syslog(LOG_CRIT, "X509_REQ_sign(): error\n");
                                        }
                                        else {
                                                /* Write it to disk. */ 
@@ -301,7 +301,7 @@ void init_ssl(void)
                }
 
                else {
-                       CtdlLogPrintf(CTDL_CRIT, "Unable to read private key.\n");
+                       syslog(LOG_CRIT, "Unable to read private key.\n");
                }
        }
 
@@ -311,7 +311,7 @@ void init_ssl(void)
         * Generate a self-signed certificate if we don't have one.
         */
        if (access(file_crpt_file_cer, R_OK) != 0) {
-               CtdlLogPrintf(CTDL_INFO, "Generating a self-signed certificate.\n");
+               syslog(LOG_INFO, "Generating a self-signed certificate.\n");
 
                /* Same deal as before: always read the key from disk because
                 * it may or may not have just been generated.
@@ -351,7 +351,7 @@ void init_ssl(void)
                                        
                                        /* Sign the cert */
                                        if (!X509_sign(cer, pk, EVP_md5())) {
-                                               CtdlLogPrintf(CTDL_CRIT, "X509_sign(): error\n");
+                                               syslog(LOG_CRIT, "X509_sign(): error\n");
                                        }
                                        else {
                                                /* Write it to disk. */ 
@@ -377,7 +377,7 @@ void init_ssl(void)
         SSL_CTX_use_certificate_chain_file(ssl_ctx, file_crpt_file_cer);
         SSL_CTX_use_PrivateKey_file(ssl_ctx, file_crpt_file_key, SSL_FILETYPE_PEM);
         if ( !SSL_CTX_check_private_key(ssl_ctx) ) {
-               CtdlLogPrintf(CTDL_CRIT, "Cannot install certificate: %s\n",
+               syslog(LOG_CRIT, "Cannot install certificate: %s\n",
                                ERR_reason_error_string(ERR_get_error()));
         }
 
@@ -403,7 +403,7 @@ void client_write_ssl(const char *buf, int nbytes)
        while (nremain > 0) {
                if (SSL_want_write(CC->ssl)) {
                        if ((SSL_read(CC->ssl, junk, 0)) < 1) {
-                               CtdlLogPrintf(CTDL_DEBUG, "SSL_read in client_write: %s\n", ERR_reason_error_string(ERR_get_error()));
+                               syslog(LOG_DEBUG, "SSL_read in client_write: %s\n", ERR_reason_error_string(ERR_get_error()));
                        }
                }
                retval =
@@ -417,9 +417,9 @@ void client_write_ssl(const char *buf, int nbytes)
                                sleep(1);
                                continue;
                        }
-                       CtdlLogPrintf(CTDL_DEBUG, "SSL_write got error %ld, ret %d\n", errval, retval);
+                       syslog(LOG_DEBUG, "SSL_write got error %ld, ret %d\n", errval, retval);
                        if (retval == -1)
-                               CtdlLogPrintf(CTDL_DEBUG, "errno is %d\n", errno);
+                               syslog(LOG_DEBUG, "errno is %d\n", errno);
                        endtls();
                        client_write(&buf[nbytes - nremain], nremain);
                        return;
@@ -444,7 +444,7 @@ int client_read_sslbuffer(StrBuf *buf, int timeout)
        while (1) {
                if (SSL_want_read(pssl)) {
                        if ((SSL_write(pssl, junk, 0)) < 1) {
-                               CtdlLogPrintf(CTDL_DEBUG, "SSL_write in client_read\n");
+                               syslog(LOG_DEBUG, "SSL_write in client_read\n");
                        }
                }
                rlen = SSL_read(pssl, sbuf, sizeof(sbuf));
@@ -456,7 +456,7 @@ int client_read_sslbuffer(StrBuf *buf, int timeout)
                                sleep(1);
                                continue;
                        }
-                       CtdlLogPrintf(CTDL_DEBUG, "SSL_read got error %ld\n", errval);
+                       syslog(LOG_DEBUG, "SSL_read got error %ld\n", errval);
                        endtls();
                        return (-1);
                }
@@ -637,18 +637,18 @@ void CtdlStartTLS(char *ok_response, char *nosup_response,
        int retval, bits, alg_bits;
 
        if (!ssl_ctx) {
-               CtdlLogPrintf(CTDL_CRIT, "SSL failed: no ssl_ctx exists?\n");
+               syslog(LOG_CRIT, "SSL failed: no ssl_ctx exists?\n");
                if (nosup_response != NULL) cprintf("%s", nosup_response);
                return;
        }
        if (!(CC->ssl = SSL_new(ssl_ctx))) {
-               CtdlLogPrintf(CTDL_CRIT, "SSL_new failed: %s\n",
+               syslog(LOG_CRIT, "SSL_new failed: %s\n",
                                ERR_reason_error_string(ERR_get_error()));
                if (error_response != NULL) cprintf("%s", error_response);
                return;
        }
        if (!(SSL_set_fd(CC->ssl, CC->client_socket))) {
-               CtdlLogPrintf(CTDL_CRIT, "SSL_set_fd failed: %s\n",
+               syslog(LOG_CRIT, "SSL_set_fd failed: %s\n",
                        ERR_reason_error_string(ERR_get_error()));
                SSL_free(CC->ssl);
                CC->ssl = NULL;
@@ -667,7 +667,7 @@ void CtdlStartTLS(char *ok_response, char *nosup_response,
                char error_string[128];
 
                errval = SSL_get_error(CC->ssl, retval);
-               CtdlLogPrintf(CTDL_CRIT, "SSL_accept failed: retval=%d, errval=%ld, err=%s\n",
+               syslog(LOG_CRIT, "SSL_accept failed: retval=%d, errval=%ld, err=%s\n",
                        retval,
                        errval,
                        ERR_error_string(errval, error_string)
@@ -678,7 +678,7 @@ void CtdlStartTLS(char *ok_response, char *nosup_response,
        }
        BIO_set_close(CC->ssl->rbio, BIO_NOCLOSE);
        bits = SSL_CIPHER_get_bits(SSL_get_current_cipher(CC->ssl), &alg_bits);
-       CtdlLogPrintf(CTDL_INFO, "SSL/TLS using %s on %s (%d of %d bits)\n",
+       syslog(LOG_INFO, "SSL/TLS using %s on %s (%d of %d bits)\n",
                SSL_CIPHER_get_name(SSL_get_current_cipher(CC->ssl)),
                SSL_CIPHER_get_version(SSL_get_current_cipher(CC->ssl)),
                bits, alg_bits);
@@ -745,7 +745,7 @@ void endtls(void)
                return;
        }
 
-       CtdlLogPrintf(CTDL_INFO, "Ending SSL/TLS\n");
+       syslog(LOG_INFO, "Ending SSL/TLS\n");
        SSL_shutdown(CC->ssl);
        SSL_free(CC->ssl);
        CC->ssl = NULL;
index 1f1349a17127115836e995e1d3f843d9b2c54c96..b29ba20a1c73437b861493647e0e2a669e2ffa83 100644 (file)
@@ -157,12 +157,12 @@ void dspam_do_msg(long msgnum, void *userdata)
        if (dspam_process (CTX, msgtext) != 0)
        {
                free(msgtext);
-               CtdlLogPrintf(CTDL_CRIT, "ERROR: dspam_process failed");
+               syslog(LOG_CRIT, "ERROR: dspam_process failed");
                return;
        }
        if (CTX->signature == NULL)
        {
-               CtdlLogPrintf(CTDL_CRIT,"No signature provided\n");
+               syslog(LOG_CRIT,"No signature provided\n");
        }
        else
        {
@@ -175,7 +175,7 @@ void dspam_do_msg(long msgnum, void *userdata)
 
        SIG.length = CTX->signature->length;
        /* Print processing results */
-       CtdlLogPrintf (CTDL_DEBUG, "Probability: %2.4f Confidence: %2.4f, Result: %s\n",
+       syslog(LOG_DEBUG, "Probability: %2.4f Confidence: %2.4f, Result: %s\n",
                CTX->probability,
                CTX->confidence,
                (CTX->result == DSR_ISSPAM) ? "Spam" : "Innocent");
@@ -214,7 +214,7 @@ int serv_dspam_room(struct ctdlroom *room)
        /// else -> todo: global user for public rooms etc.
        if (CTX == NULL)
        {
-               CtdlLogPrintf(CTDL_CRIT, "ERROR: dspam_init failed!\n");
+               syslog(LOG_CRIT, "ERROR: dspam_init failed!\n");
                return ERROR + INTERNAL_ERROR;
        }
        /* Use graham and robinson algorithms, graham's p-values */
@@ -253,7 +253,7 @@ CTDL_MODULE_INIT(dspam)
 
 #else  /* HAVE_LIBDSPAM */
 
-               CtdlLogPrintf(CTDL_INFO, "This server is missing libdspam Spam filtering will be disabled.\n");
+               syslog(LOG_INFO, "This server is missing libdspam Spam filtering will be disabled.\n");
 
 #endif /* HAVE_LIBDSPAM */
        }
index 05f8e6f1c298d679af96fe4e81b1a40353485cdf..40b5cee81522b0834fabbcbd4e9a6903f283f259 100644 (file)
@@ -69,7 +69,7 @@ ev_loop *event_base;
        do {                                                            \
                sta = curl_multi_setopt(mhnd, (CURLMOPT_##s), (v));     \
                if (sta) {                                              \
-                       CtdlLogPrintf(CTDL_ERR, "EVCURL: error setting option " #s " on curl multi handle: %s\n", curl_easy_strerror(sta)); \
+                       syslog(LOG_ERR, "EVCURL: error setting option " #s " on curl multi handle: %s\n", curl_easy_strerror(sta)); \
                        exit (1);                                       \
                }                                                       \
        } while (0)
@@ -106,9 +106,9 @@ gotstatus(evcurl_global_data *global, int nnrun)
        global->nrun = nnrun;
        mhnd = global->mhnd;
 
-       CtdlLogPrintf(CTDL_DEBUG, "CURLEV: gotstatus(): about to call curl_multi_info_read\n");
+       syslog(LOG_DEBUG, "CURLEV: gotstatus(): about to call curl_multi_info_read\n");
        while ((msg = curl_multi_info_read(mhnd, &nmsg))) {
-               CtdlLogPrintf(CTDL_ERR, "EVCURL: got curl multi_info message msg=%d\n", msg->msg);
+               syslog(LOG_ERR, "EVCURL: got curl multi_info message msg=%d\n", msg->msg);
                if (CURLMSG_DONE == msg->msg) {
                        CURL *chnd;
                        char *chandle;
@@ -119,23 +119,23 @@ gotstatus(evcurl_global_data *global, int nnrun)
                        chandle = NULL;;
                        chnd = msg->easy_handle;
                        sta = curl_easy_getinfo(chnd, CURLINFO_PRIVATE, &chandle);
-                       CtdlLogPrintf(CTDL_ERR, "EVCURL: request complete\n");
+                       syslog(LOG_ERR, "EVCURL: request complete\n");
                        if (sta)
-                               CtdlLogPrintf(CTDL_ERR, "EVCURL: error asking curl for private cookie of curl handle: %s\n", curl_easy_strerror(sta));
+                               syslog(LOG_ERR, "EVCURL: error asking curl for private cookie of curl handle: %s\n", curl_easy_strerror(sta));
                        IO = (AsyncIO *)chandle;
                        
                        sta = msg->data.result;
                        if (sta) {
-                               CtdlLogPrintf(CTDL_ERR, "EVCURL: error description: %s\n", IO->HttpReq.errdesc);
-                               CtdlLogPrintf(CTDL_ERR, "EVCURL: error performing request: %s\n", curl_easy_strerror(sta));
+                               syslog(LOG_ERR, "EVCURL: error description: %s\n", IO->HttpReq.errdesc);
+                               syslog(LOG_ERR, "EVCURL: error performing request: %s\n", curl_easy_strerror(sta));
                        }
                        sta = curl_easy_getinfo(chnd, CURLINFO_RESPONSE_CODE, &IO->HttpReq.httpcode);
                        if (sta)
-                               CtdlLogPrintf(CTDL_ERR, "EVCURL: error asking curl for response code from request: %s\n", curl_easy_strerror(sta));
-                       CtdlLogPrintf(CTDL_ERR, "EVCURL: http response code was %ld\n", (long)IO->HttpReq.httpcode);
+                               syslog(LOG_ERR, "EVCURL: error asking curl for response code from request: %s\n", curl_easy_strerror(sta));
+                       syslog(LOG_ERR, "EVCURL: http response code was %ld\n", (long)IO->HttpReq.httpcode);
                        msta = curl_multi_remove_handle(mhnd, chnd);
                        if (msta)
-                               CtdlLogPrintf(CTDL_ERR, "EVCURL: warning problem detaching completed handle from curl multi: %s\n", curl_multi_strerror(msta));
+                               syslog(LOG_ERR, "EVCURL: warning problem detaching completed handle from curl multi: %s\n", curl_multi_strerror(msta));
 
                        IO->HttpReq.attached = 0;
                        IO->SendDone(IO);
@@ -155,27 +155,27 @@ stepmulti(evcurl_global_data *global, curl_socket_t fd) {
        CURLMcode msta;
        
        if (global == NULL) {
-           CtdlLogPrintf(CTDL_DEBUG, "EVCURL: stepmulti(NULL): wtf?\n");
+           syslog(LOG_DEBUG, "EVCURL: stepmulti(NULL): wtf?\n");
            return;
        }
        msta = curl_multi_socket_action(global->mhnd, fd, 0, &nnrun);
-       CtdlLogPrintf(CTDL_DEBUG, "EVCURL: stepmulti(): calling gotstatus()\n");
+       syslog(LOG_DEBUG, "EVCURL: stepmulti(): calling gotstatus()\n");
        if (msta)
-               CtdlLogPrintf(CTDL_ERR, "EVCURL: error in curl processing events on multi handle, fd %d: %s\n", (int)fd, curl_multi_strerror(msta));
+               syslog(LOG_ERR, "EVCURL: error in curl processing events on multi handle, fd %d: %s\n", (int)fd, curl_multi_strerror(msta));
        if (global->nrun != nnrun)
                gotstatus(global, nnrun);
 }
 
 static void
 gottime(struct ev_loop *loop, ev_timer *timeev, int events) {
-       CtdlLogPrintf(CTDL_DEBUG, "EVCURL: waking up curl for timeout\n");
+       syslog(LOG_DEBUG, "EVCURL: waking up curl for timeout\n");
        evcurl_global_data *global = (void *)timeev->data;
        stepmulti(global, CURL_SOCKET_TIMEOUT);
 }
 
 static void
 gotio(struct ev_loop *loop, ev_io *ioev, int events) {
-       CtdlLogPrintf(CTDL_DEBUG, "EVCURL: waking up curl for io on fd %d\n", (int)ioev->fd);
+       syslog(LOG_DEBUG, "EVCURL: waking up curl for io on fd %d\n", (int)ioev->fd);
        sockwatcher_data *sockwatcher = (void *)ioev->data;
        stepmulti(sockwatcher->global, ioev->fd);
 }
@@ -184,7 +184,7 @@ static size_t
 gotdata(void *data, size_t size, size_t nmemb, void *cglobal) {
        AsyncIO *IO = (AsyncIO*) cglobal;
        //evcurl_request_data *D = (evcurl_request_data*) data;
-       CtdlLogPrintf(CTDL_DEBUG, "EVCURL: gotdata(): calling CurlFillStrBuf_callback()\n");
+       syslog(LOG_DEBUG, "EVCURL: gotdata(): calling CurlFillStrBuf_callback()\n");
 
        if (IO->HttpReq.ReplyData == NULL)
        {
@@ -195,7 +195,7 @@ gotdata(void *data, size_t size, size_t nmemb, void *cglobal) {
 
 static int
 gotwatchtime(CURLM *multi, long tblock_ms, void *cglobal) {
-       CtdlLogPrintf(CTDL_DEBUG, "EVCURL: gotwatchtime called %ld ms\n", tblock_ms);
+       syslog(LOG_DEBUG, "EVCURL: gotwatchtime called %ld ms\n", tblock_ms);
        evcurl_global_data *global = cglobal;
        ev_timer_stop(EV_DEFAULT, &global->timeev);
        if (tblock_ms < 0 || 14000 < tblock_ms)
@@ -212,10 +212,10 @@ gotwatchsock(CURL *easy, curl_socket_t fd, int action, void *cglobal, void *csoc
        CURLM *mhnd = global->mhnd;
        sockwatcher_data *sockwatcher = csockwatcher;
 
-       CtdlLogPrintf(CTDL_DEBUG,"EVCURL: gotwatchsock called fd=%d action=%d\n", (int)fd, action);
+       syslog(LOG_DEBUG, "EVCURL: gotwatchsock called fd=%d action=%d\n", (int)fd, action);
 
        if (!sockwatcher) {
-               CtdlLogPrintf(CTDL_ERR,"EVCURL: called first time to register this sockwatcker\n");
+               syslog(LOG_ERR,"EVCURL: called first time to register this sockwatcker\n");
                sockwatcher = malloc(sizeof(sockwatcher_data));
                sockwatcher->global = global;
                ev_init(&sockwatcher->ioev, &gotio);
@@ -223,7 +223,7 @@ gotwatchsock(CURL *easy, curl_socket_t fd, int action, void *cglobal, void *csoc
                curl_multi_assign(mhnd, fd, sockwatcher);
        }
        if (CURL_POLL_REMOVE == action) {
-               CtdlLogPrintf(CTDL_ERR,"EVCURL: called last time to unregister this sockwatcher\n");
+               syslog(LOG_ERR,"EVCURL: called last time to unregister this sockwatcher\n");
                ev_io_stop(event_base, &sockwatcher->ioev);
                free(sockwatcher);
        } else {
@@ -248,13 +248,13 @@ void curl_init_connectionpool(void)
 
        if (sta) 
        {
-               CtdlLogPrintf(CTDL_ERR,"EVCURL: error initializing curl library: %s\n", curl_easy_strerror(sta));
+               syslog(LOG_ERR,"EVCURL: error initializing curl library: %s\n", curl_easy_strerror(sta));
                exit(1);
        }
        mhnd = global.mhnd = curl_multi_init();
        if (!mhnd)
        {
-               CtdlLogPrintf(CTDL_ERR,"EVCURL: error initializing curl multi handle\n");
+               syslog(LOG_ERR,"EVCURL: error initializing curl multi handle\n");
                exit(3);
        }
 
@@ -278,14 +278,14 @@ int evcurl_init(AsyncIO *IO,
        CURLcode sta;
        CURL *chnd;
 
-       CtdlLogPrintf(CTDL_DEBUG,"EVCURL: evcurl_init called ms\n");
+       syslog(LOG_DEBUG, "EVCURL: evcurl_init called ms\n");
        IO->HttpReq.attached = 0;
        IO->SendDone = CallBack;
        IO->Terminate = Terminate;
        chnd = IO->HttpReq.chnd = curl_easy_init();
        if (!chnd)
        {
-               CtdlLogPrintf(CTDL_ERR, "EVCURL: error initializing curl handle\n");
+               syslog(LOG_ERR, "EVCURL: error initializing curl handle\n");
                return 1;
        }
 
@@ -321,7 +321,7 @@ int evcurl_init(AsyncIO *IO,
                OPT(INTERFACE, config.c_ip_addr);
        }
                /* point to a structure that points back to the perl structure and stuff */
-       CtdlLogPrintf(CTDL_DEBUG, "EVCURL: Loading URL: %s\n", IO->ConnectMe->PlainUrl);
+       syslog(LOG_DEBUG, "EVCURL: Loading URL: %s\n", IO->ConnectMe->PlainUrl);
        OPT(URL, IO->ConnectMe->PlainUrl);
        if (StrLength(IO->ConnectMe->CurlCreds))
        {
@@ -355,17 +355,17 @@ evcurl_handle_start(AsyncIO *IO)
 {
        CURLMcode msta;
        
-       CtdlLogPrintf(CTDL_DEBUG, "EVCURL: attaching to curl multi handle\n");
+       syslog(LOG_DEBUG, "EVCURL: attaching to curl multi handle\n");
        msta = curl_multi_add_handle(global.mhnd, IO->HttpReq.chnd);
        if (msta)
-               CtdlLogPrintf(CTDL_ERR, "EVCURL: error attaching to curl multi handle: %s\n", curl_multi_strerror(msta));
+               syslog(LOG_ERR, "EVCURL: error attaching to curl multi handle: %s\n", curl_multi_strerror(msta));
        IO->HttpReq.attached = 1;
        ev_async_send (event_base, &WakeupCurl);
 }
 
 static void WakeupCurlCallback(EV_P_ ev_async *w, int revents)
 {
-       CtdlLogPrintf(CTDL_DEBUG, "EVCURL: waking up curl multi handle\n");
+       syslog(LOG_DEBUG, "EVCURL: waking up curl multi handle\n");
 
        curl_multi_perform(&global, CURL_POLL_NONE);
 }
@@ -420,7 +420,7 @@ static void QueueEventAddCallback(EV_P_ ev_async *w, int revents)
        }
        DeleteHashPos(&It);
        DeleteHashContent(&q);
-       CtdlLogPrintf(CTDL_DEBUG, "EVENT Q Read done.\n");
+       syslog(LOG_DEBUG, "EVENT Q Read done.\n");
 }
 
 
@@ -428,7 +428,7 @@ static void EventExitCallback(EV_P_ ev_async *w, int revents)
 {
        ev_break(event_base, EVBREAK_ALL);
 
-       CtdlLogPrintf(CTDL_DEBUG, "EVENT Q exiting.\n");
+       syslog(LOG_DEBUG, "EVENT Q exiting.\n");
 }
 
 
@@ -440,7 +440,7 @@ void InitEventQueue(void)
        citthread_mutex_init(&EventQueueMutex, NULL);
 
        if (pipe(event_add_pipe) != 0) {
-               CtdlLogPrintf(CTDL_EMERG, "Unable to create pipe for libev queueing: %s\n", strerror(errno));
+               syslog(LOG_EMERG, "Unable to create pipe for libev queueing: %s\n", strerror(errno));
                abort();
        }
        LimitSet.rlim_cur = 1;
@@ -463,7 +463,7 @@ void *client_event_thread(void *arg)
 
        CtdlFillSystemContext(&libev_client_CC, "LibEv Thread");
 //     citthread_setspecific(MyConKey, (void *)&smtp_queue_CC);
-       CtdlLogPrintf(CTDL_DEBUG, "client_ev_thread() initializing\n");
+       syslog(LOG_DEBUG, "client_ev_thread() initializing\n");
 
        event_base = ev_default_loop (EVFLAG_AUTO);
 
@@ -546,13 +546,13 @@ static void DBQueueEventAddCallback(EV_P_ ev_async *w, int revents)
        }
        DeleteHashPos(&It);
        DeleteHashContent(&q);
-       CtdlLogPrintf(CTDL_DEBUG, "DBEVENT Q Read done.\n");
+       syslog(LOG_DEBUG, "DBEVENT Q Read done.\n");
 }
 
 
 static void DBEventExitCallback(EV_P_ ev_async *w, int revents)
 {
-       CtdlLogPrintf(CTDL_DEBUG, "EVENT Q exiting.\n");
+       syslog(LOG_DEBUG, "EVENT Q exiting.\n");
        ev_break(event_db, EVBREAK_ALL);
 }
 
@@ -565,7 +565,7 @@ void DBInitEventQueue(void)
        citthread_mutex_init(&DBEventQueueMutex, NULL);
 
        if (pipe(evdb_add_pipe) != 0) {
-               CtdlLogPrintf(CTDL_EMERG, "Unable to create pipe for libev queueing: %s\n", strerror(errno));
+               syslog(LOG_EMERG, "Unable to create pipe for libev queueing: %s\n", strerror(errno));
                abort();
        }
        LimitSet.rlim_cur = 1;
@@ -589,7 +589,7 @@ void *db_event_thread(void *arg)
 
        CtdlFillSystemContext(&libev_msg_CC, "LibEv DB IO Thread");
 //     citthread_setspecific(MyConKey, (void *)&smtp_queue_CC);
-       CtdlLogPrintf(CTDL_DEBUG, "client_msgev_thread() initializing\n");
+       syslog(LOG_DEBUG, "client_msgev_thread() initializing\n");
 
        event_db = ev_loop_new (EVFLAG_AUTO);
 
index 22442ad1526cc255ff5dfbad339fd39d096fdd6d..bf10973814a6f73efb3da339d0eff7b7fd4e077e 100644 (file)
@@ -247,12 +247,12 @@ void DoPurgeMessages(FILE *purgelist) {
 void PurgeMessages(void) {
        FILE *purgelist;
 
-       CtdlLogPrintf(CTDL_DEBUG, "PurgeMessages() called\n");
+       syslog(LOG_DEBUG, "PurgeMessages() called\n");
        messages_purged = 0;
 
        purgelist = tmpfile();
        if (purgelist == NULL) {
-               CtdlLogPrintf(CTDL_CRIT, "Can't create purgelist temp file: %s\n",
+               syslog(LOG_CRIT, "Can't create purgelist temp file: %s\n",
                        strerror(errno));
                return;
        }
@@ -320,7 +320,7 @@ void DoPurgeRooms(struct ctdlroom *qrbuf, void *data) {
                age = time(NULL) - (qrbuf->QRmtime);
                purge_secs = (time_t)config.c_roompurge * (time_t)86400;
                if (purge_secs <= (time_t)0) return;
-               CtdlLogPrintf(CTDL_DEBUG, "<%s> is <%ld> seconds old\n", qrbuf->QRname, (long)age);
+               syslog(LOG_DEBUG, "<%s> is <%ld> seconds old\n", qrbuf->QRname, (long)age);
                if (age > purge_secs) do_purge = 1;
        } /* !QR_MAILBOX */
 
@@ -342,7 +342,7 @@ int PurgeRooms(void) {
        struct ValidUser *vuptr;
        char *transcript = NULL;
 
-       CtdlLogPrintf(CTDL_DEBUG, "PurgeRooms() called\n");
+       syslog(LOG_DEBUG, "PurgeRooms() called\n");
 
 
        /* Load up a table full of valid user numbers so we can delete
@@ -379,7 +379,7 @@ int PurgeRooms(void) {
        if (num_rooms_purged > 0) CtdlAideMessage(transcript, "Room Autopurger Message");
        free(transcript);
 
-       CtdlLogPrintf(CTDL_DEBUG, "Purged %d rooms.\n", num_rooms_purged);
+       syslog(LOG_DEBUG, "Purged %d rooms.\n", num_rooms_purged);
        return(num_rooms_purged);
 }
 
@@ -480,7 +480,7 @@ void do_user_purge(struct ctdluser *us, void *data) {
                 * we will need to try and purge them from users data bases.Some will not have names but
                 * those with names should be purged.
                 */
-               CtdlLogPrintf(CTDL_DEBUG, "Auto purger found a user 0 with name \"%s\"\n", us->fullname);
+               syslog(LOG_DEBUG, "Auto purger found a user 0 with name \"%s\"\n", us->fullname);
                // purge = 0;
        }
        
@@ -531,7 +531,7 @@ int PurgeUsers(void) {
        int num_users_purged = 0;
        char *transcript = NULL;
 
-       CtdlLogPrintf(CTDL_DEBUG, "PurgeUsers() called\n");
+       syslog(LOG_DEBUG, "PurgeUsers() called\n");
        users_not_purged = 0;
 
        switch(config.c_auth_mode) {
@@ -542,7 +542,7 @@ int PurgeUsers(void) {
                        ForEachUser(do_uid_user_purge, NULL);
                        break;
                default:
-                       CtdlLogPrintf(CTDL_DEBUG, "User purge for auth mode %d is not implemented.\n",
+                       syslog(LOG_DEBUG, "User purge for auth mode %d is not implemented.\n",
                                config.c_auth_mode);
                        break;
        }
@@ -593,7 +593,7 @@ int PurgeUsers(void) {
                users_zero_msg = NULL;
        }
                
-       CtdlLogPrintf(CTDL_DEBUG, "Purged %d users.\n", num_users_purged);
+       syslog(LOG_DEBUG, "Purged %d users.\n", num_users_purged);
        return(num_users_purged);
 }
 
@@ -708,7 +708,7 @@ int PurgeUseTable(void) {
        struct UPurgeList *uptr; 
 
        /* Phase 1: traverse through the table, discovering old records... */
-       CtdlLogPrintf(CTDL_DEBUG, "Purge use table: phase 1\n");
+       syslog(LOG_DEBUG, "Purge use table: phase 1\n");
        cdb_rewind(CDB_USETABLE);
        while(cdbut = cdb_next_item(CDB_USETABLE), cdbut != NULL) {
 
@@ -735,7 +735,7 @@ int PurgeUseTable(void) {
        }
 
        /* Phase 2: delete the records */
-       CtdlLogPrintf(CTDL_DEBUG, "Purge use table: phase 2\n");
+       syslog(LOG_DEBUG, "Purge use table: phase 2\n");
        while (ul != NULL) {
                cdb_delete(CDB_USETABLE, ul->up_key, strlen(ul->up_key));
                uptr = ul->next;
@@ -743,7 +743,7 @@ int PurgeUseTable(void) {
                ul = uptr;
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Purge use table: finished (purged %d records)\n", purged);
+       syslog(LOG_DEBUG, "Purge use table: finished (purged %d records)\n", purged);
        return(purged);
 }
 
@@ -762,7 +762,7 @@ int PurgeEuidIndexTable(void) {
        struct CtdlMessage *msg = NULL;
 
        /* Phase 1: traverse through the table, discovering old records... */
-       CtdlLogPrintf(CTDL_DEBUG, "Purge EUID index: phase 1\n");
+       syslog(LOG_DEBUG, "Purge EUID index: phase 1\n");
        cdb_rewind(CDB_EUIDINDEX);
        while(cdbei = cdb_next_item(CDB_EUIDINDEX), cdbei != NULL) {
 
@@ -789,7 +789,7 @@ int PurgeEuidIndexTable(void) {
        }
 
        /* Phase 2: delete the records */
-       CtdlLogPrintf(CTDL_DEBUG, "Purge euid index: phase 2\n");
+       syslog(LOG_DEBUG, "Purge euid index: phase 2\n");
        while (el != NULL) {
                cdb_delete(CDB_EUIDINDEX, el->ep_key, el->ep_keylen);
                free(el->ep_key);
@@ -798,7 +798,7 @@ int PurgeEuidIndexTable(void) {
                el = eptr;
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Purge euid index: finished (purged %d records)\n", purged);
+       syslog(LOG_DEBUG, "Purge euid index: finished (purged %d records)\n", purged);
        return(purged);
 }
 
@@ -840,7 +840,7 @@ int PurgeStaleOpenIDassociations(void) {
        HashPos = GetNewHashPos(keys, 0);
        while (GetNextHashPos(keys, HashPos, &len, &Key, &Value)!=0)
        {
-               CtdlLogPrintf(CTDL_DEBUG, "Deleting associated OpenID <%s>\n",  (char*)Value);
+               syslog(LOG_DEBUG, "Deleting associated OpenID <%s>\n",  (char*)Value);
                cdb_delete(CDB_OPENID, Value, strlen(Value));
                /* note: don't free(Value) -- deleting the hash list will handle this for us */
                ++num_deleted;
@@ -864,7 +864,7 @@ void *purge_databases(void *args)
 
        CtdlFillSystemContext(&purgerCC, "purger");
        citthread_setspecific(MyConKey, (void *)&purgerCC );
-       CtdlLogPrintf(CTDL_DEBUG, "Auto-purger_thread() initializing\n");
+       syslog(LOG_DEBUG, "Auto-purger_thread() initializing\n");
 
         while (!CtdlThreadCheckStop()) {
                 /* Do the auto-purge if the current hour equals the purge hour,
@@ -882,64 +882,64 @@ void *purge_databases(void *args)
                 }
 
 
-                CtdlLogPrintf(CTDL_INFO, "Auto-purger: starting.\n");
+                syslog(LOG_INFO, "Auto-purger: starting.\n");
 
                if (!CtdlThreadCheckStop())
                {
                        retval = PurgeUsers();
-                       CtdlLogPrintf(CTDL_NOTICE, "Purged %d users.\n", retval);
+                       syslog(LOG_NOTICE, "Purged %d users.\n", retval);
                }
                
                if (!CtdlThreadCheckStop())
                {
                        PurgeMessages();
-                       CtdlLogPrintf(CTDL_NOTICE, "Expired %d messages.\n", messages_purged);
+                       syslog(LOG_NOTICE, "Expired %d messages.\n", messages_purged);
                }
 
                if (!CtdlThreadCheckStop())
                {
                        retval = PurgeRooms();
-                       CtdlLogPrintf(CTDL_NOTICE, "Expired %d rooms.\n", retval);
+                       syslog(LOG_NOTICE, "Expired %d rooms.\n", retval);
                }
 
                if (!CtdlThreadCheckStop())
                {
                        retval = PurgeVisits();
-                       CtdlLogPrintf(CTDL_NOTICE, "Purged %d visits.\n", retval);
+                       syslog(LOG_NOTICE, "Purged %d visits.\n", retval);
                }
 
                if (!CtdlThreadCheckStop())
                {
                        retval = PurgeUseTable();
-                       CtdlLogPrintf(CTDL_NOTICE, "Purged %d entries from the use table.\n", retval);
+                       syslog(LOG_NOTICE, "Purged %d entries from the use table.\n", retval);
                }
 
                if (!CtdlThreadCheckStop())
                {
                        retval = PurgeEuidIndexTable();
-                       CtdlLogPrintf(CTDL_NOTICE, "Purged %d entries from the EUID index.\n", retval);
+                       syslog(LOG_NOTICE, "Purged %d entries from the EUID index.\n", retval);
                }
 
                if (!CtdlThreadCheckStop())
                {
                        retval = PurgeStaleOpenIDassociations();
-                       CtdlLogPrintf(CTDL_NOTICE, "Purged %d stale OpenID associations.\n", retval);
+                       syslog(LOG_NOTICE, "Purged %d stale OpenID associations.\n", retval);
                }
 
                if (!CtdlThreadCheckStop())
                {
                        retval = TDAP_ProcessAdjRefCountQueue();
-                       CtdlLogPrintf(CTDL_NOTICE, "Processed %d message reference count adjustments.\n", retval);
+                       syslog(LOG_NOTICE, "Processed %d message reference count adjustments.\n", retval);
                }
 
                if (!CtdlThreadCheckStop())
                {
-                       CtdlLogPrintf(CTDL_INFO, "Auto-purger: finished.\n");
+                       syslog(LOG_INFO, "Auto-purger: finished.\n");
                        last_purge = now;       /* So we don't do it again soon */
                        force_purge_now = 0;
                }
                else
-                       CtdlLogPrintf(CTDL_INFO, "Auto-purger: STOPPED.\n");
+                       syslog(LOG_INFO, "Auto-purger: STOPPED.\n");
 
         }
        CtdlClearSystemContext();
index c303e04b4fb1d0d21c0c63312c87ee1bb64b8e77..1fda772b15344dc247eb5f36c81d218a6b9b58b8 100644 (file)
@@ -119,7 +119,7 @@ int GetNotifyHosts(NotifyContext *Ctx)
                pchs = ChrPtr(Host);
                pche = strchr(pchs, ':');
                if (pche == NULL) {
-                       CtdlLogPrintf(CTDL_ERR, 
+                       syslog(LOG_ERR, 
                                      "extnotify: filename of notification template not found in %s.\n", 
                                      pchs);
                        continue;
@@ -166,7 +166,7 @@ eNotifyType extNotify_getConfigMessage(char *username, char **PagerNumber, char
                num_msgs = cdbfr->len / sizeof(long);
                cdb_free(cdbfr);
        } else {
-               CtdlLogPrintf(CTDL_DEBUG, "extNotify_getConfigMessage: No config messages found\n");
+               syslog(LOG_DEBUG, "extNotify_getConfigMessage: No config messages found\n");
                return eNone;   /* No messages at all?  No further action. */
        }
        for (a = 0; a < num_msgs; ++a) {
@@ -378,7 +378,7 @@ void do_extnotify_queue(void)
        if (IsEmptyStr(config.c_pager_program) && 
            IsEmptyStr(config.c_funambol_host))
        {
-               CtdlLogPrintf(CTDL_DEBUG, "No external notifiers configured on system/user\n");
+               syslog(LOG_ERR, "No external notifiers configured on system/user\n");
                return;
        }
 
@@ -390,13 +390,13 @@ void do_extnotify_queue(void)
        /*
         * Go ahead and run the queue
         */
-       CtdlLogPrintf(CTDL_DEBUG, "serv_extnotify: processing notify queue\n");
+       syslog(LOG_DEBUG, "serv_extnotify: processing notify queue\n");
 
        memset(&Ctx, 0, sizeof(NotifyContext));
        if ((GetNotifyHosts(&Ctx) > 0) && 
            (CtdlGetRoom(&CC->room, FNBL_QUEUE_ROOM) != 0))
        {
-               CtdlLogPrintf(CTDL_ERR, "Cannot find room <%s>\n", FNBL_QUEUE_ROOM);
+               syslog(LOG_ERR, "Cannot find room <%s>\n", FNBL_QUEUE_ROOM);
                CtdlClearSystemContext();
                if (Ctx.nNotifyHosts > 0)
                {
@@ -408,7 +408,7 @@ void do_extnotify_queue(void)
        }
        CtdlForEachMessage(MSGS_ALL, 0L, NULL,
                           SPOOLMIME, NULL, process_notify, &Ctx);
-       CtdlLogPrintf(CTDL_DEBUG, "serv_extnotify: queue run completed\n");
+       syslog(LOG_DEBUG, "serv_extnotify: queue run completed\n");
        doing_queue = 0;
        if (Ctx.nNotifyHosts > 0)
        {
index f81b41dbfadcdc5adba62d58ab25f4437b464c39..5cd7c4d9eda718e990749ee7fc05bce28d89451f 100644 (file)
@@ -90,7 +90,7 @@ int notify_http_server(char *remoteurl,
                        snprintf(buf, SIZ, 
                                 "Cannot load template file %s [%s]won't send notification\r\n", 
                                 file_funambol_msg, strerror(errno));
-                       CtdlLogPrintf(CTDL_ERR, buf);
+                       syslog(LOG_ERR, buf);
 
                        CtdlAideMessage(buf, "External notifier unable to find message template!");
                        goto abort;
@@ -113,7 +113,7 @@ int notify_http_server(char *remoteurl,
                        snprintf(buf, SIZ, 
                                 "Cannot load template file %s; won't send notification\r\n", 
                                 file_funambol_msg);
-                       CtdlLogPrintf(CTDL_ERR, buf);
+                       syslog(LOG_ERR, buf);
 
                        CtdlAideMessage(buf, "External notifier unable to load message template!");
                        goto abort;
@@ -158,7 +158,7 @@ int notify_http_server(char *remoteurl,
                          EvaluateResult, 
                          ExtNotifyTerminate))
        {
-               CtdlLogPrintf(CTDL_ALERT, "Unable to initialize libcurl.\n");
+               syslog(LOG_ALERT, "Unable to initialize libcurl.\n");
                goto abort;
        }
        chnd = IO->HttpReq.chnd;
@@ -198,9 +198,10 @@ eNextState EvaluateResult(AsyncIO *IO)
        if (IO->HttpReq.httpcode != 200) {
                StrBuf *ErrMsg;
 
-               CtdlLogPrintf(CTDL_ALERT, "libcurl error %ld: %s\n", 
+               syslog(LOG_ALERT, "libcurl error %ld: %s\n", 
                              IO->HttpReq.httpcode, 
                              IO->HttpReq.errdesc);
+
                ErrMsg = NewStrBufPlain(HKEY("Error sending your Notification\n"));
                StrBufAppendPrintf(ErrMsg, "\nlibcurl error %ld: \n\t\t%s\n", 
                                   IO->HttpReq.httpcode, 
@@ -224,7 +225,7 @@ eNextState EvaluateResult(AsyncIO *IO)
                CtdlAideMessage(ChrPtr(ErrMsg), "External notifier unable to load message template!");
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Funambol notified\n");
+       syslog(LOG_DEBUG, "Funambol notified\n");
 /*
        while ((Ctx.NotifyHostList != NULL) && (Ctx.NotifyHostList[i] != NULL))
                FreeStrBuf(&Ctx.NotifyHostList[i]);
index 44f40a45c58915a2b1748f696c0585b57b949f17..1979d48d3c53f957ebabfd38c16bfdb6b9a7c8df 100644 (file)
@@ -159,7 +159,7 @@ void noise_word_cleanup(void)
        int i;
        noise_word *cur, *next;
        
-       CtdlLogPrintf(CTDL_INFO, "Cleaning up fulltext noise words.\n");
+       syslog(LOG_INFO, "Cleaning up fulltext noise words.\n");
        
        for (i = 0 ; i < 26 ; i++)
        {
@@ -236,7 +236,7 @@ void wordbreaker(const char *text, int *num_tokens, int **tokens) {
                        /* extract the word */
                        word_len = word_end - word_start;
                        if (word_len >= sizeof word) {
-                               CtdlLogPrintf(CTDL_DEBUG, "Invalid word length: %d\n", word_len);
+                               syslog(LOG_DEBUG, "Invalid word length: %d\n", word_len);
                                safestrncpy(word, word_start, sizeof word);
                                word[(sizeof word) - 1] = 0;
                        }
index 88064ad503dd29bc5e1aa9bfc3f35312f61c21de..f7861ad03ab16caa14651adf28b72de8000c543d 100644 (file)
@@ -93,7 +93,7 @@ void ft_flush_cache(void) {
 
        for (i=0; i<65536; ++i) {
                if ((time(NULL) - last_update) >= 10) {
-                       CtdlLogPrintf(CTDL_INFO,
+                       syslog(LOG_INFO,
                                "Flushing index cache to disk (%d%% complete)\n",
                                (i * 100 / 65536)
                        );
@@ -107,7 +107,7 @@ void ft_flush_cache(void) {
                        ftc_msgs[i] = NULL;
                }
        }
-       CtdlLogPrintf(CTDL_INFO, "Flushed index cache to disk (100%% complete)\n");
+       syslog(LOG_INFO, "Flushed index cache to disk (100%% complete)\n");
 }
 
 
@@ -126,17 +126,17 @@ void ft_index_message(long msgnum, int op) {
 
        msg = CtdlFetchMessage(msgnum, 1);
        if (msg == NULL) {
-               CtdlLogPrintf(CTDL_ERR, "ft_index_message() could not load msg %ld\n", msgnum);
+               syslog(LOG_ERR, "ft_index_message() could not load msg %ld\n", msgnum);
                return;
        }
 
        if (msg->cm_fields['1'] != NULL) {
-               CtdlLogPrintf(CTDL_DEBUG, "ft_index_message() excluded msg %ld\n", msgnum);
+               syslog(LOG_DEBUG, "ft_index_message() excluded msg %ld\n", msgnum);
                CtdlFreeMessage(msg);
                return;
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "ft_index_message() %s msg %ld\n",
+       syslog(LOG_DEBUG, "ft_index_message() %s msg %ld\n",
                (op ? "adding" : "removing") , msgnum
        );
 
@@ -148,12 +148,12 @@ void ft_index_message(long msgnum, int op) {
        CtdlFreeMessage(msg);
        msgtext = CC->redirect_buffer;
        CC->redirect_buffer = NULL;
-       CtdlLogPrintf(CTDL_DEBUG, "Wordbreaking message %ld...\n", msgnum);
+       syslog(LOG_DEBUG, "Wordbreaking message %ld...\n", msgnum);
        txt = SmashStrBuf(&msgtext);
        wordbreaker(txt, &num_tokens, &tokens);
        free(txt);
 
-       CtdlLogPrintf(CTDL_DEBUG, "Indexing message %ld [%d tokens]\n", msgnum, num_tokens);
+       syslog(LOG_DEBUG, "Indexing message %ld [%d tokens]\n", msgnum, num_tokens);
        if (num_tokens > 0) {
                for (i=0; i<num_tokens; ++i) {
 
@@ -199,7 +199,7 @@ void ft_index_message(long msgnum, int op) {
                                }
                        }
                        else {
-                               CtdlLogPrintf(CTDL_ALERT, "Invalid token %d !!\n", tok);
+                               syslog(LOG_ALERT, "Invalid token %d !!\n", tok);
                        }
                }
 
@@ -277,7 +277,7 @@ void do_fulltext_indexing(void) {
        }
        
        run_time = time(NULL);
-       CtdlLogPrintf(CTDL_DEBUG, "do_fulltext_indexing() started (%ld)\n", run_time);
+       syslog(LOG_DEBUG, "do_fulltext_indexing() started (%ld)\n", run_time);
        
        /*
         * If we've switched wordbreaker modules, burn the index and start
@@ -285,9 +285,9 @@ void do_fulltext_indexing(void) {
         */
        begin_critical_section(S_CONTROL);
        if (CitControl.fulltext_wordbreaker != FT_WORDBREAKER_ID) {
-               CtdlLogPrintf(CTDL_DEBUG, "wb ver on disk = %d, code ver = %d\n",
+               syslog(LOG_DEBUG, "wb ver on disk = %d, code ver = %d\n",
                        CitControl.fulltext_wordbreaker, FT_WORDBREAKER_ID);
-               CtdlLogPrintf(CTDL_INFO, "(re)initializing full text index\n");
+               syslog(LOG_INFO, "(re)initializing full text index\n");
                cdb_trunc(CDB_FULLTEXT);
                CitControl.MMfulltext = 0L;
                put_control();
@@ -314,7 +314,7 @@ void do_fulltext_indexing(void) {
                /* Here it is ... do each message! */
                for (i=0; i<ft_num_msgs; ++i) {
                        if (time(NULL) != last_progress) {
-                               CtdlLogPrintf(CTDL_DEBUG,
+                               syslog(LOG_DEBUG,
                                        "Indexed %d of %d messages (%d%%)\n",
                                                i, ft_num_msgs,
                                                ((i*100) / ft_num_msgs)
@@ -325,14 +325,14 @@ void do_fulltext_indexing(void) {
 
                        /* Check to see if we need to quit early */
                        if (CtdlThreadCheckStop()) {
-                               CtdlLogPrintf(CTDL_DEBUG, "Indexer quitting early\n");
+                               syslog(LOG_DEBUG, "Indexer quitting early\n");
                                ft_newhighest = ft_newmsgs[i];
                                break;
                        }
 
                        /* Check to see if we have to maybe flush to disk */
                        if (i >= FT_MAX_CACHE) {
-                               CtdlLogPrintf(CTDL_DEBUG, "Time to flush.\n");
+                               syslog(LOG_DEBUG, "Time to flush.\n");
                                ft_newhighest = ft_newmsgs[i];
                                break;
                        }
@@ -349,7 +349,7 @@ void do_fulltext_indexing(void) {
        if (CtdlThreadCheckStop())
                return;
        
-       CtdlLogPrintf(CTDL_DEBUG, "do_fulltext_indexing() duration (%ld)\n", end_time - run_time);
+       syslog(LOG_DEBUG, "do_fulltext_indexing() duration (%ld)\n", end_time - run_time);
                
        /* Save our place so we don't have to do this again */
        ft_flush_cache();
@@ -360,7 +360,7 @@ void do_fulltext_indexing(void) {
        end_critical_section(S_CONTROL);
        last_index = time(NULL);
 
-       CtdlLogPrintf(CTDL_DEBUG, "do_fulltext_indexing() finished\n");
+       syslog(LOG_DEBUG, "do_fulltext_indexing() finished\n");
        return;
 }
 
@@ -373,14 +373,14 @@ void *indexer_thread(void *arg) {
 
        CtdlFillSystemContext(&indexerCC, "indexer");
        citthread_setspecific(MyConKey, (void *)&indexerCC );
-       CtdlLogPrintf(CTDL_DEBUG, "indexer_thread() initializing\n");
+       syslog(LOG_DEBUG, "indexer_thread() initializing\n");
 
        while (!CtdlThreadCheckStop()) {
                do_fulltext_indexing();
                CtdlThreadSleep(300);
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "indexer_thread() exiting\n");
+       syslog(LOG_DEBUG, "indexer_thread() exiting\n");
        CtdlClearSystemContext();
        return NULL;
 }
index 86102bf8ed9a2f4ce506ffd7e702cf48b84acac5..fa6cc0c8492ed57c20fca25af0385110b9ecce06 100644 (file)
@@ -240,7 +240,7 @@ void imap_fetch_rfc822(long msgnum, const char *whichfmt) {
                text_size = 0;
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, 
+       syslog(LOG_DEBUG, 
                "RFC822: headers=" SIZE_T_FMT 
                ", text=" SIZE_T_FMT
                ", total=" SIZE_T_FMT "\n",
@@ -288,7 +288,7 @@ void imap_load_part(char *name, char *filename, char *partnum, char *disp,
        char *desired_section;
 
        desired_section = (char *)cbuserdata;
-       CtdlLogPrintf(CTDL_DEBUG, "imap_load_part() looking for %s, found %s\n",
+       syslog(LOG_DEBUG, "imap_load_part() looking for %s, found %s\n",
                desired_section,
                partnum
        );
@@ -671,7 +671,7 @@ void imap_fetch_body(long msgnum, ConstStr item, int is_peek) {
        if (strchr(ChrPtr(section), '[') != NULL) {
                StrBufStripAllBut(section, '[', ']');
        }
-       CtdlLogPrintf(CTDL_DEBUG, "Section is: [%s]\n", 
+       syslog(LOG_DEBUG, "Section is: [%s]\n", 
              (StrLength(section) == 0) ? "(empty)" : ChrPtr(section)
        );
 
@@ -705,7 +705,7 @@ void imap_fetch_body(long msgnum, ConstStr item, int is_peek) {
                is_partial = 1;
        }
        if ( (is_partial == 1) && (StrLength(partial) > 0) ) {
-               CtdlLogPrintf(CTDL_DEBUG, "Partial is <%s>\n", ChrPtr(partial));
+               syslog(LOG_DEBUG, "Partial is <%s>\n", ChrPtr(partial));
        }
 
        if (Imap->cached_body == NULL) {
@@ -1133,17 +1133,17 @@ void imap_do_fetch(citimap_command *Cmd) {
 /* debug output the parsed vector */
        {
                int i;
-               CtdlLogPrintf(CTDL_DEBUG, "----- %ld params \n",
+               syslog(LOG_DEBUG, "----- %ld params \n",
                              Cmd->num_parms);
 
        for (i=0; i < Cmd->num_parms; i++) {
                if (Cmd->Params[i].len != strlen(Cmd->Params[i].Key))
-                       CtdlLogPrintf(CTDL_DEBUG, "*********** %ld != %ld : %s\n",
+                       syslog(LOG_DEBUG, "*********** %ld != %ld : %s\n",
                                      Cmd->Params[i].len, 
                                      strlen(Cmd->Params[i].Key),
                                      Cmd->Params[i].Key);
                else
-                       CtdlLogPrintf(CTDL_DEBUG, "%ld : %s\n",
+                       syslog(LOG_DEBUG, "%ld : %s\n",
                                      Cmd->Params[i].len, 
                                      Cmd->Params[i].Key);
        }}
@@ -1468,7 +1468,7 @@ void imap_uidfetch(int num_parms, ConstStr *Params) {
 
        MakeStringOf(Cmd.CmdBuf, 4);
 #if 0
-       CtdlLogPrintf(CTDL_DEBUG, "-------%s--------\n", ChrPtr(Cmd.CmdBuf));
+       syslog(LOG_DEBUG, "-------%s--------\n", ChrPtr(Cmd.CmdBuf));
 #endif
        num_items = imap_extract_data_items(&Cmd);
        if (num_items < 1) {
index 015ee1cd3d9e21e4b19e0b2be8970b96c5898d5a..465c6ea4002a75f3121ce5c0c9c90d78ed1285f7 100644 (file)
@@ -377,7 +377,7 @@ void imap_list(int num_parms, ConstStr *Params)
                                          &Params[i], 
                                          1);
 
-                       CtdlLogPrintf(9, "evaluating <%s>\n", Params[i].Key);
+                       syslog(LOG_DEBUG, "evaluating <%s>\n", Params[i].Key);
 
                        if (!strcasecmp(Params[i].Key, "SUBSCRIBED")) {
                                ImapFilter.return_subscribed = 1;
index d62f487fa635ecb993f31f7ff553d355b20ab419..14cc8afa95e3ecbadd6c3c4aa162c59ab1c13343 100644 (file)
@@ -355,10 +355,10 @@ void imap_append(int num_parms, ConstStr *Params) {
        client_getln(dummy, sizeof dummy);
 
        /* Convert RFC822 newlines (CRLF) to Unix newlines (LF) */
-       CtdlLogPrintf(CTDL_DEBUG, "Converting CRLF to LF\n");
+       syslog(LOG_DEBUG, "Converting CRLF to LF\n");
        StrBufToUnixLF(Imap->TransmittedMessage);
 
-       CtdlLogPrintf(CTDL_DEBUG, "Converting message format\n");
+       syslog(LOG_DEBUG, "Converting message format\n");
        msg = convert_internet_message_buf(&Imap->TransmittedMessage);
 
        ret = imap_grabroom(roomname, Params[2].Key, 1);
index 0af9406d4860b2366cbd2ca557712434479b6614..28fb95948eca6528f339ecb46da41449b876f36c 100644 (file)
@@ -225,7 +225,7 @@ static char* toimap(char* destp, char* destend, char* src)
 
        *destp = 0;
        string_init(&dest, destp, destend-destp);
-       /* CtdlLogPrintf(CTDL_DEBUG, "toimap %s\r\n", src); */
+       /* syslog(LOG_DEBUG, "toimap %s\r\n", src); */
 
        for (;;)
        {
@@ -291,7 +291,7 @@ static char* toimap(char* destp, char* destend, char* src)
 
        if (state == 1)
                utf7_closeb64(&dest, v, i);
-       /* CtdlLogPrintf(CTDL_DEBUG, "    -> %s\r\n", destp); */
+       /* syslog(LOG_DEBUG, "    -> %s\r\n", destp); */
        return string_end(&dest);
 }
 
@@ -309,7 +309,7 @@ static char* fromimap(char* destp, char* destend, const char* src)
 
        *destp = 0;
        string_init(&dest, destp, destend-destp);
-       /* CtdlLogPrintf(CTDL_DEBUG, "fromimap %s\r\n", src); */
+       /* syslog(LOG_DEBUG, "fromimap %s\r\n", src); */
 
        do {
                c = *p++;
@@ -367,7 +367,7 @@ static char* fromimap(char* destp, char* destend, const char* src)
                        }
        } while (c != '\0');
 
-       /* CtdlLogPrintf(CTDL_DEBUG, "      -> %s\r\n", destp); */
+       /* syslog(LOG_DEBUG, "      -> %s\r\n", destp); */
        return string_end(&dest);
 }
 
@@ -680,7 +680,7 @@ int imap_roomname(char *rbuf, int bufsize, const char *foldername)
        ret = (0 | IR_MAILBOX);
 
 exit:
-       CtdlLogPrintf(CTDL_DEBUG, "(That translates to \"%s\")\n", rbuf);
+       syslog(LOG_DEBUG, "(That translates to \"%s\")\n", rbuf);
        return(ret);
 }
 
index 798c25e5fc1fd3047fa8a70c3acf9d39ec12bf32..21f71a2b0c5395f69947b68836908d5734ceea00 100644 (file)
@@ -111,33 +111,33 @@ const imap_handler_hook *imap_lookup(int num_parms, ConstStr *Params)
        StrBufPlain(Imap->Reply, CKEY(Params[1]));
        StrBufUpCase(Imap->Reply);
 
-       CtdlLogPrintf(CTDL_DEBUG, "---- Looking up [%s] -----", 
+       syslog(LOG_DEBUG, "---- Looking up [%s] -----", 
                      ChrPtr(Imap->Reply));
        if (GetHash(ImapCmds, SKEY(Imap->Reply), &v))
        {
-               CtdlLogPrintf(CTDL_DEBUG, "Found. \n"); 
+               syslog(LOG_DEBUG, "Found. \n"); 
                FlushStrBuf(Imap->Reply);
                return (imap_handler_hook *) v;
        }
 
        if (num_parms == 1)
        {
-               CtdlLogPrintf(CTDL_DEBUG, "NOT Found. \n"); 
+               syslog(LOG_DEBUG, "NOT Found. \n"); 
                FlushStrBuf(Imap->Reply);
                return NULL;
        }
        
-       CtdlLogPrintf(CTDL_DEBUG, "---- Looking up [%s] -----", 
+       syslog(LOG_DEBUG, "---- Looking up [%s] -----", 
                      ChrPtr(Imap->Reply));
        StrBufAppendBufPlain(Imap->Reply, CKEY(Params[2]), 0);
        StrBufUpCase(Imap->Reply);
        if (GetHash(ImapCmds, SKEY(Imap->Reply), &v))
        {
-               CtdlLogPrintf(CTDL_DEBUG, "Found. \n"); 
+               syslog(LOG_DEBUG, "Found. \n"); 
                FlushStrBuf(Imap->Reply);
                return (imap_handler_hook *) v;
        }
-       CtdlLogPrintf(CTDL_DEBUG, "NOT Found. \n"); 
+       syslog(LOG_DEBUG, "NOT Found. \n"); 
        FlushStrBuf(Imap->Reply);
                return NULL;
 }
@@ -306,7 +306,7 @@ void imap_load_msgids(void)
        citimap *Imap = IMAP;
 
        if (Imap->selected == 0) {
-               CtdlLogPrintf(CTDL_ERR,
+               syslog(LOG_ERR,
                        "imap_load_msgids() can't run; no room selected\n");
                return;
        }
@@ -348,7 +348,7 @@ void imap_rescan_msgids(void)
        int num_recent = 0;
 
        if (Imap->selected == 0) {
-               CtdlLogPrintf(CTDL_ERR, "imap_load_msgids() can't run; no room selected\n");
+               syslog(LOG_ERR, "imap_load_msgids() can't run; no room selected\n");
                return;
        }
 
@@ -368,7 +368,7 @@ void imap_rescan_msgids(void)
        if (cdbfr != NULL) {
                msglist = malloc(cdbfr->len);
                if (msglist == NULL) {
-                       CtdlLogPrintf(CTDL_CRIT, "malloc() failed\n");
+                       syslog(LOG_CRIT, "malloc() failed\n");
                        abort();
                }
                memcpy(msglist, cdbfr->ptr, (size_t)cdbfr->len);
@@ -483,7 +483,7 @@ void imap_cleanup_function(void)
                imap_do_expunge();
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Performing IMAP cleanup hook\n");
+       syslog(LOG_DEBUG, "Performing IMAP cleanup hook\n");
        imap_free_msgids();
        imap_free_transmitted_message();
 
@@ -503,7 +503,7 @@ void imap_cleanup_function(void)
        FreeStrBuf(&Imap->Reply);
        if (Imap->Cmd.Params != NULL) free(Imap->Cmd.Params);
        free(Imap);
-       CtdlLogPrintf(CTDL_DEBUG, "Finished IMAP cleanup hook\n");
+       syslog(LOG_DEBUG, "Finished IMAP cleanup hook\n");
 }
 
 
@@ -918,7 +918,7 @@ int imap_do_expunge(void)
        long *delmsgs = NULL;
        int num_delmsgs = 0;
 
-       CtdlLogPrintf(CTDL_DEBUG, "imap_do_expunge() called\n");
+       syslog(LOG_DEBUG, "imap_do_expunge() called\n");
        if (Imap->selected == 0) {
                return (0);
        }
@@ -941,7 +941,7 @@ int imap_do_expunge(void)
                imap_rescan_msgids();
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Expunged %d messages from <%s>\n", num_expunged, CC->room.QRname);
+       syslog(LOG_DEBUG, "Expunged %d messages from <%s>\n", num_expunged, CC->room.QRname);
        return (num_expunged);
 }
 
@@ -1036,14 +1036,14 @@ void imap_create(int num_parms, ConstStr *Params)
 
        if (strchr(Params[2].Key, '\\') != NULL) {
                IReply("NO Invalid character in folder name");
-               CtdlLogPrintf(CTDL_DEBUG, "invalid character in folder name\n");
+               syslog(LOG_DEBUG, "invalid character in folder name\n");
                return;
        }
 
        ret = imap_roomname(roomname, sizeof roomname, Params[2].Key);
        if (ret < 0) {
                IReply("NO Invalid mailbox name or location");
-               CtdlLogPrintf(CTDL_DEBUG, "invalid mailbox name or location\n");
+               syslog(LOG_DEBUG, "invalid mailbox name or location\n");
                return;
        }
        floornum = (ret & 0x00ff);      /* lower 8 bits = floor number */
@@ -1052,7 +1052,7 @@ void imap_create(int num_parms, ConstStr *Params)
        if (flags & IR_MAILBOX) {
                if (strncasecmp(Params[2].Key, "INBOX/", 6)) {
                        IReply("NO Personal folders must be created under INBOX");
-                       CtdlLogPrintf(CTDL_DEBUG, "not subordinate to inbox\n");
+                       syslog(LOG_DEBUG, "not subordinate to inbox\n");
                        return;
                }
        }
@@ -1065,7 +1065,7 @@ void imap_create(int num_parms, ConstStr *Params)
                newroomview = VIEW_BBS;
        }
 
-       CtdlLogPrintf(CTDL_INFO, "Create new room <%s> on floor <%d> with type <%d>\n",
+       syslog(LOG_INFO, "Create new room <%s> on floor <%d> with type <%d>\n",
                roomname, floornum, newroomtype);
 
        ret = CtdlCreateRoom(roomname, newroomtype, "", floornum, 1, 0, newroomview);
@@ -1087,7 +1087,7 @@ void imap_create(int num_parms, ConstStr *Params)
                CtdlAideMessage(notification_message, "Room Creation Message");
                free(notification_message);
        }
-       CtdlLogPrintf(CTDL_DEBUG, "imap_create() completed\n");
+       syslog(LOG_DEBUG, "imap_create() completed\n");
 }
 
 
@@ -1450,7 +1450,7 @@ void imap_rename(int num_parms, ConstStr *Params)
                                           irl->irl_newfloor);
                        if (r != crr_ok) {
                                /* FIXME handle error returns better */
-                               CtdlLogPrintf(CTDL_ERR, "CtdlRenameRoom() error %d\n", r);
+                               syslog(LOG_ERR, "CtdlRenameRoom() error %d\n", r);
                        }
                        irlp = irl;
                        irl = irl->next;
@@ -1492,23 +1492,23 @@ void imap_command_loop(void)
                FlushStrBuf(Imap->Cmd.CmdBuf);
 
        if (CtdlClientGetLine(Imap->Cmd.CmdBuf) < 1) {
-               CtdlLogPrintf(CTDL_ERR, "Client disconnected: ending session.\r\n");
+               syslog(LOG_ERR, "Client disconnected: ending session.\r\n");
                CC->kill_me = 1;
                return;
        }
 
        if (Imap->authstate == imap_as_expecting_password) {
-               CtdlLogPrintf(CTDL_INFO, "IMAP: <password>\n");
+               syslog(LOG_INFO, "IMAP: <password>\n");
        }
        else if (Imap->authstate == imap_as_expecting_plainauth) {
-               CtdlLogPrintf(CTDL_INFO, "IMAP: <plain_auth>\n");
+               syslog(LOG_INFO, "IMAP: <plain_auth>\n");
        }
        else if ((Imap->authstate == imap_as_expecting_multilineusername) || 
                 cbmstrcasestr(ChrPtr(Imap->Cmd.CmdBuf), " LOGIN ")) {
-               CtdlLogPrintf(CTDL_INFO, "IMAP: LOGIN...\n");
+               syslog(LOG_INFO, "IMAP: LOGIN...\n");
        }
        else {
-               CtdlLogPrintf(CTDL_INFO, "IMAP: %s\n", ChrPtr(Imap->Cmd.CmdBuf));
+               syslog(LOG_INFO, "IMAP: %s\n", ChrPtr(Imap->Cmd.CmdBuf));
        }
 
        pchs = ChrPtr(Imap->Cmd.CmdBuf);
@@ -1564,17 +1564,17 @@ void imap_command_loop(void)
 /* debug output the parsed vector */
        {
                int i;
-               CtdlLogPrintf(CTDL_DEBUG, "----- %ld params \n",
+               syslog(LOG_DEBUG, "----- %ld params \n",
                              Imap->Cmd.num_parms);
 
        for (i=0; i < Imap->Cmd.num_parms; i++) {
                if (Imap->Cmd.Params[i].len != strlen(Imap->Cmd.Params[i].Key))
-                       CtdlLogPrintf(CTDL_DEBUG, "*********** %ld != %ld : %s\n",
+                       syslog(LOG_DEBUG, "*********** %ld != %ld : %s\n",
                                      Imap->Cmd.Params[i].len, 
                                      strlen(Imap->Cmd.Params[i].Key),
                                      Imap->Cmd.Params[i].Key);
                else
-                       CtdlLogPrintf(CTDL_DEBUG, "%ld : %s\n",
+                       syslog(LOG_DEBUG, "%ld : %s\n",
                                      Imap->Cmd.Params[i].len, 
                                      Imap->Cmd.Params[i].Key);
        }}
@@ -1627,7 +1627,7 @@ BAIL:
 
        gettimeofday(&tv2, NULL);
        total_time = (tv2.tv_usec + (tv2.tv_sec * 1000000)) - (tv1.tv_usec + (tv1.tv_sec * 1000000));
-       CtdlLogPrintf(CTDL_DEBUG, "IMAP command completed in %ld.%ld seconds\n",
+       syslog(LOG_DEBUG, "IMAP command completed in %ld.%ld seconds\n",
                (total_time / 1000000),
                (total_time % 1000000)
        );
index 15cd194ebfef14002dbfb9aa817789690815bb02..3ad989ab579a4da38e1a20db5059614ca18525a2 100644 (file)
@@ -515,7 +515,7 @@ void do_confirm(char *room, char *token) {
         */
        if (success) {
                cprintf("%d %d operation(s) confirmed.\n", CIT_OK, success);
-               CtdlLogPrintf(CTDL_NOTICE, 
+               syslog(LOG_NOTICE, 
                        "Mailing list: %s %ssubscribed to %s with token %s\n", 
                        email, 
                        (!IsEmptyStr(address_to_unsubscribe)) ? "un" : "", 
index f1523d73bf793ab1ebdd9a73c49056ee78e41ea2..0bdc0f1001fe03873b7dbbd0e6b7593d3c742720 100644 (file)
@@ -336,7 +336,7 @@ void cmd_mgsve_starttls(void)
 void cmd_mgsve_logout(struct sdm_userdata *u)
 {
        cprintf("OK\r\n");
-       CtdlLogPrintf(CTDL_NOTICE, "MgSve bye.");
+       syslog(LOG_NOTICE, "MgSve bye.");
        CC->kill_me = 1;
 }
 
@@ -585,11 +585,11 @@ void managesieve_command_loop(void) {
                length = strlen(parms[0]);
        }
        if (length < 1) {
-               CtdlLogPrintf(CTDL_CRIT, "Client disconnected: ending session.\n");
+               syslog(LOG_CRIT, "Client disconnected: ending session.\n");
                CC->kill_me = 1;
                return;
        }
-       CtdlLogPrintf(CTDL_INFO, "MANAGESIEVE: %s\n", cmdbuf);
+       syslog(LOG_INFO, "MANAGESIEVE: %s\n", cmdbuf);
        if ((length>= 12) && (!strncasecmp(parms[0], "AUTHENTICATE", 12))){
                cmd_mgsve_auth(num_parms, parms, &u);
        }
@@ -634,7 +634,7 @@ void managesieve_command_loop(void) {
        }
        else {
                cprintf("No Invalid access or command.\r\n");
-               CtdlLogPrintf(CTDL_INFO, "illegal Managesieve command: %s", parms[0]);
+               syslog(LOG_INFO, "illegal Managesieve command: %s", parms[0]);
                CC->kill_me = 1;
        }
 
@@ -650,7 +650,7 @@ void managesieve_cleanup_function(void) {
        /* Don't do this stuff if this is not a managesieve session! */
        if (CC->h_command_function != managesieve_command_loop) return;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Performing managesieve cleanup hook\n");
+       syslog(LOG_DEBUG, "Performing managesieve cleanup hook\n");
        free(MGSVE);
 }
 
index e71801c3bd003706d051549ed56e3aef6e5b5358..31d2eceea2e41140c3aa325c73e17e927a1de958 100644 (file)
@@ -181,9 +181,9 @@ void migr_export_rooms(void) {
         * exporting the message multiple times.)
         */
        snprintf(cmd, sizeof cmd, "sort <%s >%s", migr_tempfilename1, migr_tempfilename2);
-       if (system(cmd) != 0) CtdlLogPrintf(CTDL_ALERT, "Error %d\n", errno);
+       if (system(cmd) != 0) syslog(LOG_ALERT, "Error %d\n", errno);
        snprintf(cmd, sizeof cmd, "uniq <%s >%s", migr_tempfilename2, migr_tempfilename1);
-       if (system(cmd) != 0) CtdlLogPrintf(CTDL_ALERT, "Error %d\n", errno);
+       if (system(cmd) != 0) syslog(LOG_ALERT, "Error %d\n", errno);
 }
 
 
@@ -340,7 +340,7 @@ void migr_export_messages(void) {
        Ctx = CC;
        migr_global_message_list = fopen(migr_tempfilename1, "r");
        if (migr_global_message_list != NULL) {
-               CtdlLogPrintf(CTDL_INFO, "Opened %s\n", migr_tempfilename1);
+               syslog(LOG_INFO, "Opened %s\n", migr_tempfilename1);
                while ((Ctx->kill_me != 1) && 
                       (fgets(buf, sizeof(buf), migr_global_message_list) != NULL)) {
                        msgnum = atol(buf);
@@ -352,9 +352,9 @@ void migr_export_messages(void) {
                fclose(migr_global_message_list);
        }
        if (Ctx->kill_me != 1)
-               CtdlLogPrintf(CTDL_INFO, "Exported %d messages.\n", count);
+               syslog(LOG_INFO, "Exported %d messages.\n", count);
        else
-               CtdlLogPrintf(CTDL_ERR, "Export aborted due to client disconnect! \n");
+               syslog(LOG_ERR, "Export aborted due to client disconnect! \n");
 
        migr_export_message(-1L);       /* This frees the encoding buffer */
 }
@@ -547,7 +547,7 @@ void migr_xml_start(void *data, const char *el, const char **attr) {
        }
 
        if (citadel_migrate_data != 1) {
-               CtdlLogPrintf(CTDL_ALERT, "Out-of-sequence tag <%s> detected.  Warning: ODD-DATA!\n", el);
+               syslog(LOG_ALERT, "Out-of-sequence tag <%s> detected.  Warning: ODD-DATA!\n", el);
                return;
        }
 
@@ -592,7 +592,7 @@ void migr_xml_end(void *data, const char *el) {
        }
 
        if (citadel_migrate_data != 1) {
-               CtdlLogPrintf(CTDL_ALERT, "Out-of-sequence tag <%s> detected.  Warning: ODD-DATA!\n", el);
+               syslog(LOG_ALERT, "Out-of-sequence tag <%s> detected.  Warning: ODD-DATA!\n", el);
                return;
        }
 
@@ -601,14 +601,14 @@ void migr_xml_end(void *data, const char *el) {
                migr_chardata_len = 0;
        }
 
-       // CtdlLogPrintf(CTDL_DEBUG, "END TAG: <%s> DATA: <%s>\n", el, (migr_chardata_len ? migr_chardata : ""));
+       // syslog(LOG_DEBUG, "END TAG: <%s> DATA: <%s>\n", el, (migr_chardata_len ? migr_chardata : ""));
 
        /*** CONFIG ***/
 
        if (!strcasecmp(el, "config")) {
                config.c_enable_fulltext = 0;   /* always disable */
                put_config();
-               CtdlLogPrintf(CTDL_INFO, "Completed import of server configuration\n");
+               syslog(LOG_INFO, "Completed import of server configuration\n");
        }
 
        else if (!strcasecmp(el, "c_nodename"))                 safestrncpy(config.c_nodename, migr_chardata, sizeof config.c_nodename);
@@ -697,7 +697,7 @@ void migr_xml_end(void *data, const char *el) {
        else if (!strcasecmp(el, "control")) {
                CitControl.MMfulltext = (-1L);  /* always flush */
                put_control();
-               CtdlLogPrintf(CTDL_INFO, "Completed import of control record\n");
+               syslog(LOG_INFO, "Completed import of control record\n");
        }
 
        /*** USER ***/
@@ -716,7 +716,7 @@ void migr_xml_end(void *data, const char *el) {
 
        else if (!strcasecmp(el, "user")) {
                CtdlPutUser(&usbuf);
-               CtdlLogPrintf(CTDL_INFO, "Imported user: %s\n", usbuf.fullname);
+               syslog(LOG_INFO, "Imported user: %s\n", usbuf.fullname);
        }
 
        /*** OPENID ***/
@@ -733,7 +733,7 @@ void migr_xml_end(void *data, const char *el) {
                memcpy(&oid_data[sizeof(long)], openid_url, strlen(openid_url) + 1);
                cdb_store(CDB_OPENID, openid_url, strlen(openid_url), oid_data, oid_data_len);
                free(oid_data);
-               CtdlLogPrintf(CTDL_INFO, "Imported OpenID: %s (%ld)\n", openid_url, openid_usernum);
+               syslog(LOG_INFO, "Imported OpenID: %s (%ld)\n", openid_url, openid_usernum);
        }
 
        /*** ROOM ***/
@@ -757,7 +757,7 @@ void migr_xml_end(void *data, const char *el) {
 
        else if (!strcasecmp(el, "room")) {
                CtdlPutRoom(&qrbuf);
-               CtdlLogPrintf(CTDL_INFO, "Imported room: %s\n", qrbuf.QRname);
+               syslog(LOG_INFO, "Imported room: %s\n", qrbuf.QRname);
        }
 
        /*** ROOM MESSAGE POINTERS ***/
@@ -770,7 +770,7 @@ void migr_xml_end(void *data, const char *el) {
                        msglist_alloc = 1000;
                        msglist = malloc(sizeof(long) * msglist_alloc);
 
-                       CtdlLogPrintf(CTDL_DEBUG, "Message list for: %s\n", FRname);
+                       syslog(LOG_DEBUG, "Message list for: %s\n", FRname);
 
                        ptr = migr_chardata;
                        while (*ptr != 0) {
@@ -798,7 +798,7 @@ void migr_xml_end(void *data, const char *el) {
                        free(msglist);
                        msglist = NULL;
                        msglist_alloc = 0;
-                       CtdlLogPrintf(CTDL_DEBUG, "Imported %d messages.\n", msgcount);
+                       syslog(LOG_DEBUG, "Imported %d messages.\n", msgcount);
                        if (CtdlThreadCheckStop()) {
                                return;
                }
@@ -815,7 +815,7 @@ void migr_xml_end(void *data, const char *el) {
 
        else if (!strcasecmp(el, "floor")) {
                CtdlPutFloor(&flbuf, floornum);
-               CtdlLogPrintf(CTDL_INFO, "Imported floor #%d (%s)\n", floornum, flbuf.f_name);
+               syslog(LOG_INFO, "Imported floor #%d (%s)\n", floornum, flbuf.f_name);
        }
 
        /*** VISITS ***/
@@ -837,7 +837,7 @@ void migr_xml_end(void *data, const char *el) {
 
        else if (!strcasecmp(el, "visit")) {
                put_visit(&vbuf);
-               CtdlLogPrintf(CTDL_INFO, "Imported visit: %ld/%ld/%ld\n", vbuf.v_roomnum, vbuf.v_roomgen, vbuf.v_usernum);
+               syslog(LOG_INFO, "Imported visit: %ld/%ld/%ld\n", vbuf.v_roomnum, vbuf.v_roomgen, vbuf.v_usernum);
        }
 
        /*** MESSAGES ***/
@@ -857,7 +857,7 @@ void migr_xml_end(void *data, const char *el) {
                free(decoded_msg);
                decoded_msg = NULL;
                PutMetaData(&smi);
-               CtdlLogPrintf(CTDL_INFO, "Imported message #%ld, size=%ld, refcount=%d, content-type: %s\n",
+               syslog(LOG_INFO, "Imported message #%ld, size=%ld, refcount=%d, content-type: %s\n",
                        import_msgnum, msglen, smi.meta_refcount, smi.meta_content_type);
        }
 
index 5dd3a9523a0706a22df38d1c09e168e690aa6bdc..eae59f394c1d1a99566e90d31c2b55e7e16fa33b 100644 (file)
@@ -221,7 +221,7 @@ int network_usetable(struct CtdlMessage *msg) {
        cdbut = cdb_fetch(CDB_USETABLE, msgid, strlen(msgid));
        if (cdbut != NULL) {
                cdb_free(cdbut);
-               CtdlLogPrintf(CTDL_DEBUG, "network_usetable() : we already have %s\n", msgid);
+               syslog(LOG_DEBUG, "network_usetable() : we already have %s\n", msgid);
                return(1);
        }
 
@@ -323,7 +323,7 @@ int is_valid_node(char *nexthop, char *secret, char *node) {
         * First try the neighbor nodes
         */
        if (working_ignetcfg == NULL) {
-               CtdlLogPrintf(CTDL_ERR, "working_ignetcfg is NULL!\n");
+               syslog(LOG_ERR, "working_ignetcfg is NULL!\n");
                if (nexthop != NULL) {
                        strcpy(nexthop, "");
                }
@@ -371,7 +371,7 @@ int is_valid_node(char *nexthop, char *secret, char *node) {
        /*
         * If we get to this point, the supplied node name is bogus.
         */
-       CtdlLogPrintf(CTDL_ERR, "Invalid node name <%s>\n", node);
+       syslog(LOG_ERR, "Invalid node name <%s>\n", node);
        return(-1);
 }
 
@@ -562,7 +562,7 @@ void network_deliver_digest(SpoolControl *sc) {
        recps = malloc(recps_len);
 
        if (recps == NULL) {
-               CtdlLogPrintf(CTDL_EMERG, "Cannot allocate %ld bytes for recps...\n", (long)recps_len);
+               syslog(LOG_EMERG, "Cannot allocate %ld bytes for recps...\n", (long)recps_len);
                abort();
        }
 
@@ -617,7 +617,7 @@ void network_deliver_list(struct CtdlMessage *msg, SpoolControl *sc) {
        recps = malloc(recps_len);
 
        if (recps == NULL) {
-               CtdlLogPrintf(CTDL_EMERG, "Cannot allocate %ld bytes for recps...\n", (long)recps_len);
+               syslog(LOG_EMERG, "Cannot allocate %ld bytes for recps...\n", (long)recps_len);
                abort();
        }
 
@@ -895,24 +895,24 @@ void network_spool_msg(long msgnum, void *userdata) {
 
                        /* Check for valid node name */
                        if (is_valid_node(NULL, NULL, mptr->remote_nodename) != 0) {
-                               CtdlLogPrintf(CTDL_ERR, "Invalid node <%s>\n", mptr->remote_nodename);
+                               syslog(LOG_ERR, "Invalid node <%s>\n", mptr->remote_nodename);
                                send = 0;
                        }
 
                        /* Check for split horizon */
-                       CtdlLogPrintf(CTDL_DEBUG, "Path is %s\n", msg->cm_fields['P']);
+                       syslog(LOG_DEBUG, "Path is %s\n", msg->cm_fields['P']);
                        bang = num_tokens(msg->cm_fields['P'], '!');
                        if (bang > 1) for (i=0; i<(bang-1); ++i) {
                                extract_token(buf, msg->cm_fields['P'], i, '!', sizeof buf);
-                               CtdlLogPrintf(CTDL_DEBUG, "Compare <%s> to <%s>\n",
+                               syslog(LOG_DEBUG, "Compare <%s> to <%s>\n",
                                        buf, mptr->remote_nodename) ;
                                if (!strcasecmp(buf, mptr->remote_nodename)) {
                                        send = 0;
-                                       CtdlLogPrintf(CTDL_DEBUG, "Not sending to %s\n",
+                                       syslog(LOG_DEBUG, "Not sending to %s\n",
                                                mptr->remote_nodename);
                                }
                                else {
-                                       CtdlLogPrintf(CTDL_DEBUG, "Sending to %s\n", mptr->remote_nodename);
+                                       syslog(LOG_DEBUG, "Sending to %s\n", mptr->remote_nodename);
                                }
                        }
 
@@ -944,7 +944,7 @@ void network_spool_msg(long msgnum, void *userdata) {
                                                time(NULL),
                                                rand()
                                        );
-                                       CtdlLogPrintf(CTDL_DEBUG, "Appending to %s\n", filename);
+                                       syslog(LOG_DEBUG, "Appending to %s\n", filename);
                                        fp = fopen(filename, "ab");
                                        if (fp != NULL) {
                                                fwrite(sermsg.ser,
@@ -952,7 +952,7 @@ void network_spool_msg(long msgnum, void *userdata) {
                                                fclose(fp);
                                        }
                                        else {
-                                               CtdlLogPrintf(CTDL_ERR, "%s: %s\n", filename, strerror(errno));
+                                               syslog(LOG_ERR, "%s: %s\n", filename, strerror(errno));
                                        }
        
                                        /* free the serialized version */
@@ -1131,7 +1131,7 @@ int writenfree_spoolcontrol_file(SpoolControl **scc, char *filename)
        TmpFD = open(tempfilename, O_CREAT|O_EXCL|O_RDWR, S_IRUSR|S_IWUSR);
        Cfg = NewStrBuf();
        if ((TmpFD < 0) || (errno != 0)) {
-               CtdlLogPrintf(CTDL_CRIT, "ERROR: cannot open %s: %s\n",
+               syslog(LOG_CRIT, "ERROR: cannot open %s: %s\n",
                        filename, strerror(errno));
                free_spoolcontrol_struct(scc);
                unlink(tempfilename);
@@ -1185,7 +1185,7 @@ int writenfree_spoolcontrol_file(SpoolControl **scc, char *filename)
                        rename(tempfilename, filename);
                }
                else {
-                       CtdlLogPrintf(CTDL_EMERG, 
+                       syslog(LOG_EMERG, 
                                      "unable to write %s; [%s]; not enough space on the disk?\n", 
                                      tempfilename, 
                                      strerror(errno));
@@ -1243,7 +1243,7 @@ void network_spoolout_room(char *room_to_spool) {
         * queued for networking and then deleted before it can happen.
         */
        if (CtdlGetRoom(&CC->room, room_to_spool) != 0) {
-               CtdlLogPrintf(CTDL_CRIT, "ERROR: cannot load <%s>\n", room_to_spool);
+               syslog(LOG_CRIT, "ERROR: cannot load <%s>\n", room_to_spool);
                return;
        }
 
@@ -1256,7 +1256,7 @@ void network_spoolout_room(char *room_to_spool) {
                end_critical_section(S_NETCONFIGS);
                return;
        }
-       CtdlLogPrintf(CTDL_INFO, "Networking started for <%s>\n", CC->room.QRname);
+       syslog(LOG_INFO, "Networking started for <%s>\n", CC->room.QRname);
 
        /* If there are digest recipients, we have to build a digest */
        if (sc->digestrecps != NULL) {
@@ -1352,7 +1352,7 @@ int network_sync_to(char *target_node) {
        /* Concise cleanup because we know there's only one node in the sc */
        free(sc.ignet_push_shares);
 
-       CtdlLogPrintf(CTDL_NOTICE, "Synchronized %d messages to <%s>\n",
+       syslog(LOG_NOTICE, "Synchronized %d messages to <%s>\n",
                num_spooled, target_node);
        return(num_spooled);
 }
@@ -1471,7 +1471,7 @@ void network_bounce(struct CtdlMessage *msg, char *reason) {
        static int serialnum = 0;
        size_t size;
 
-       CtdlLogPrintf(CTDL_DEBUG, "entering network_bounce()\n");
+       syslog(LOG_DEBUG, "entering network_bounce()\n");
 
        if (msg == NULL) return;
 
@@ -1560,7 +1560,7 @@ void network_bounce(struct CtdlMessage *msg, char *reason) {
        /* Clean up */
        if (valid != NULL) free_recipients(valid);
        CtdlFreeMessage(msg);
-       CtdlLogPrintf(CTDL_DEBUG, "leaving network_bounce()\n");
+       syslog(LOG_DEBUG, "leaving network_bounce()\n");
 }
 
 
@@ -1584,13 +1584,13 @@ void network_process_buffer(char *buffer, long size) {
        unsigned char firstbyte;
        unsigned char lastbyte;
 
-       CtdlLogPrintf(CTDL_DEBUG, "network_process_buffer() processing %ld bytes\n", size);
+       syslog(LOG_DEBUG, "network_process_buffer() processing %ld bytes\n", size);
 
        /* Validate just a little bit.  First byte should be FF and * last byte should be 00. */
        firstbyte = buffer[0];
        lastbyte = buffer[size-1];
        if ( (firstbyte != 255) || (lastbyte != 0) ) {
-               CtdlLogPrintf(CTDL_ERR, "Corrupt message ignored.  Length=%ld, firstbyte = %d, lastbyte = %d\n",
+               syslog(LOG_ERR, "Corrupt message ignored.  Length=%ld, firstbyte = %d, lastbyte = %d\n",
                        size, firstbyte, lastbyte);
                return;
        }
@@ -1647,14 +1647,14 @@ void network_process_buffer(char *buffer, long size) {
                                        time(NULL),
                                        rand()
                                );
-                               CtdlLogPrintf(CTDL_DEBUG, "Appending to %s\n", filename);
+                               syslog(LOG_DEBUG, "Appending to %s\n", filename);
                                fp = fopen(filename, "ab");
                                if (fp != NULL) {
                                        fwrite(sermsg.ser, sermsg.len, 1, fp);
                                        fclose(fp);
                                }
                                else {
-                                       CtdlLogPrintf(CTDL_ERR, "%s: %s\n", filename, strerror(errno));
+                                       syslog(LOG_ERR, "%s: %s\n", filename, strerror(errno));
                                }
                                free(sermsg.ser);
                                CtdlFreeMessage(msg);
@@ -1705,7 +1705,7 @@ void network_process_buffer(char *buffer, long size) {
                                "Please check the address and try sending the message again.\n");
                        msg = NULL;
                        free_recipients(recp);
-                       CtdlLogPrintf(CTDL_DEBUG, "Bouncing message due to invalid recipient address.\n");
+                       syslog(LOG_DEBUG, "Bouncing message due to invalid recipient address.\n");
                        return;
                }
                strcpy(target_room, "");        /* no target room if mail */
@@ -1774,12 +1774,12 @@ void network_process_file(char *filename) {
 
        fp = fopen(filename, "rb");
        if (fp == NULL) {
-               CtdlLogPrintf(CTDL_CRIT, "Error opening %s: %s\n", filename, strerror(errno));
+               syslog(LOG_CRIT, "Error opening %s: %s\n", filename, strerror(errno));
                return;
        }
 
        fseek(fp, 0L, SEEK_END);
-       CtdlLogPrintf(CTDL_INFO, "network: processing %ld bytes from %s\n", ftell(fp), filename);
+       syslog(LOG_INFO, "network: processing %ld bytes from %s\n", ftell(fp), filename);
        rewind(fp);
 
        /* Look for messages in the data stream and break them out */
@@ -1822,11 +1822,11 @@ void network_do_spoolin(void) {
         */
        if (stat(ctdl_netin_dir, &statbuf)) return;
        if (statbuf.st_mtime == last_spoolin_mtime) {
-               CtdlLogPrintf(CTDL_DEBUG, "network: nothing in inbound queue\n");
+               syslog(LOG_DEBUG, "network: nothing in inbound queue\n");
                return;
        }
        last_spoolin_mtime = statbuf.st_mtime;
-       CtdlLogPrintf(CTDL_DEBUG, "network: processing inbound queue\n");
+       syslog(LOG_DEBUG, "network: processing inbound queue\n");
 
        /*
         * Ok, there's something interesting in there, so scan it.
@@ -1882,9 +1882,9 @@ void network_consolidate_spoolout(void) {
                                d->d_name
                        );
        
-                       CtdlLogPrintf(CTDL_DEBUG, "Consolidate %s to %s\n", filename, nexthop);
+                       syslog(LOG_DEBUG, "Consolidate %s to %s\n", filename, nexthop);
                        if (network_talking_to(nexthop, NTT_CHECK)) {
-                               CtdlLogPrintf(CTDL_DEBUG,
+                               syslog(LOG_DEBUG,
                                        "Currently online with %s - skipping for now\n",
                                        nexthop
                                );
@@ -1966,7 +1966,7 @@ void receive_spool(int *sock, char *remote_nodename) {
 
        if (sock_puts(sock, "NDOP") < 0) return;
        if (sock_getln(sock, buf, sizeof buf) < 0) return;
-       CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+       syslog(LOG_DEBUG, "<%s\n", buf);
        if (buf[0] != '2') {
                return;
        }
@@ -1979,11 +1979,11 @@ void receive_spool(int *sock, char *remote_nodename) {
        bytes_received = 0L;
        fp = fopen(tempfilename, "w");
        if (fp == NULL) {
-               CtdlLogPrintf(CTDL_CRIT, "Cannot create %s: %s\n", tempfilename, strerror(errno));
+               syslog(LOG_CRIT, "Cannot create %s: %s\n", tempfilename, strerror(errno));
                return;
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Expecting to transfer %d bytes\n", download_len);
+       syslog(LOG_DEBUG, "Expecting to transfer %d bytes\n", download_len);
        while (bytes_received < download_len) {
                /*
                 * If shutting down we can exit here and unlink the temp file.
@@ -2016,7 +2016,7 @@ void receive_spool(int *sock, char *remote_nodename) {
                        plen = extract_int(&buf[4], 0);
                        StrBuf *pbuf = NewStrBuf();
                        if (socket_read_blob(sock, pbuf, plen, CLIENT_TIMEOUT) != plen) {
-                               CtdlLogPrintf(CTDL_INFO, "Short read from peer; aborting.\n");
+                               syslog(LOG_INFO, "Short read from peer; aborting.\n");
                                fclose(fp);
                                unlink(tempfilename);
                                FreeStrBuf(&pbuf);
@@ -2050,13 +2050,13 @@ void receive_spool(int *sock, char *remote_nodename) {
                return;
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "%s\n", buf);
+       syslog(LOG_DEBUG, "%s\n", buf);
 
        /*
         * Now move the temp file to its permanent location.
         */
        if (link(tempfilename, permfilename) != 0) {
-               CtdlLogPrintf(CTDL_ALERT, "Could not link %s to %s: %s\n",
+               syslog(LOG_ALERT, "Could not link %s to %s: %s\n",
                        tempfilename, permfilename, strerror(errno)
                );
        }
@@ -2080,7 +2080,7 @@ void transmit_spool(int *sock, char *remote_nodename)
 
        if (sock_puts(sock, "NUOP") < 0) return;
        if (sock_getln(sock, buf, sizeof buf) < 0) return;
-       CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+       syslog(LOG_DEBUG, "<%s\n", buf);
        if (buf[0] != '2') {
                return;
        }
@@ -2093,7 +2093,7 @@ void transmit_spool(int *sock, char *remote_nodename)
        fd = open(sfname, O_RDONLY);
        if (fd < 0) {
                if (errno != ENOENT) {
-                       CtdlLogPrintf(CTDL_CRIT, "cannot open %s: %s\n", sfname, strerror(errno));
+                       syslog(LOG_CRIT, "cannot open %s: %s\n", sfname, strerror(errno));
                }
                return;
        }
@@ -2144,10 +2144,10 @@ ABORTUPL:
         * From here on we must complete or messages will get lost
         */
        if (sock_getln(sock, buf, sizeof buf) < 0) return;
-       CtdlLogPrintf(CTDL_NOTICE, "Sent %ld octets to <%s>\n", bytes_written, remote_nodename);
-       CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+       syslog(LOG_NOTICE, "Sent %ld octets to <%s>\n", bytes_written, remote_nodename);
+       syslog(LOG_DEBUG, "<%s\n", buf);
        if (buf[0] == '2') {
-               CtdlLogPrintf(CTDL_DEBUG, "Removing <%s>\n", sfname);
+               syslog(LOG_DEBUG, "Removing <%s>\n", sfname);
                unlink(sfname);
        }
 }
@@ -2166,24 +2166,24 @@ void network_poll_node(char *node, char *secret, char *host, char *port) {
 
        if (network_talking_to(node, NTT_CHECK)) return;
        network_talking_to(node, NTT_ADD);
-       CtdlLogPrintf(CTDL_DEBUG, "network: polling <%s>\n", node);
-       CtdlLogPrintf(CTDL_NOTICE, "Connecting to <%s> at %s:%s\n", node, host, port);
+       syslog(LOG_DEBUG, "network: polling <%s>\n", node);
+       syslog(LOG_NOTICE, "Connecting to <%s> at %s:%s\n", node, host, port);
 
        sock = sock_connect(host, port);
        if (sock < 0) {
-               CtdlLogPrintf(CTDL_ERR, "Could not connect: %s\n", strerror(errno));
+               syslog(LOG_ERR, "Could not connect: %s\n", strerror(errno));
                network_talking_to(node, NTT_REMOVE);
                return;
        }
        
-       CtdlLogPrintf(CTDL_DEBUG, "Connected!\n");
+       syslog(LOG_DEBUG, "Connected!\n");
        CCC->SBuf.Buf = NewStrBuf();
        CCC->sMigrateBuf = NewStrBuf();
        CCC->SBuf.ReadWritePointer = NULL;
 
        /* Read the server greeting */
        if (sock_getln(&sock, buf, sizeof buf) < 0) goto bail;
-       CtdlLogPrintf(CTDL_DEBUG, ">%s\n", buf);
+       syslog(LOG_DEBUG, ">%s\n", buf);
 
        /* Check that the remote is who we think it is and warn the Aide if not */
        extract_token (connected_to, buf, 1, ' ', sizeof connected_to);
@@ -2193,16 +2193,16 @@ void network_poll_node(char *node, char *secret, char *host, char *port) {
                        "Connected to node \"%s\" but I was expecting to connect to node \"%s\".",
                        connected_to, node
                );
-               CtdlLogPrintf(CTDL_ERR, "%s\n", err_buf);
+               syslog(LOG_ERR, "%s\n", err_buf);
                CtdlAideMessage(err_buf, "Network error");
        }
        else {
                /* We're talking to the correct node.  Now identify ourselves. */
                snprintf(buf, sizeof buf, "NETP %s|%s", config.c_nodename, secret);
-               CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+               syslog(LOG_DEBUG, "<%s\n", buf);
                if (sock_puts(&sock, buf) <0) goto bail;
                if (sock_getln(&sock, buf, sizeof buf) < 0) goto bail;
-               CtdlLogPrintf(CTDL_DEBUG, ">%s\n", buf);
+               syslog(LOG_DEBUG, ">%s\n", buf);
                if (buf[0] != '2') {
                        goto bail;
                }
@@ -2241,7 +2241,7 @@ void network_poll_other_citadel_nodes(int full_poll) {
        char spoolfile[256];
 
        if (working_ignetcfg == NULL) {
-               CtdlLogPrintf(CTDL_DEBUG, "network: no neighbor nodes are configured - not polling.\n");
+               syslog(LOG_DEBUG, "network: no neighbor nodes are configured - not polling.\n");
                return;
        }
 
@@ -2284,21 +2284,21 @@ void network_poll_other_citadel_nodes(int full_poll) {
  */
 void create_spool_dirs(void) {
        if ((mkdir(ctdl_spool_dir, 0700) != 0) && (errno != EEXIST))
-               CtdlLogPrintf(CTDL_EMERG, "unable to create directory [%s]: %s", ctdl_spool_dir, strerror(errno));
+               syslog(LOG_EMERG, "unable to create directory [%s]: %s", ctdl_spool_dir, strerror(errno));
        if (chown(ctdl_spool_dir, CTDLUID, (-1)) != 0)
-               CtdlLogPrintf(CTDL_EMERG, "unable to set the access rights for [%s]: %s", ctdl_spool_dir, strerror(errno));
+               syslog(LOG_EMERG, "unable to set the access rights for [%s]: %s", ctdl_spool_dir, strerror(errno));
        if ((mkdir(ctdl_netin_dir, 0700) != 0) && (errno != EEXIST))
-               CtdlLogPrintf(CTDL_EMERG, "unable to create directory [%s]: %s", ctdl_netin_dir, strerror(errno));
+               syslog(LOG_EMERG, "unable to create directory [%s]: %s", ctdl_netin_dir, strerror(errno));
        if (chown(ctdl_netin_dir, CTDLUID, (-1)) != 0)
-               CtdlLogPrintf(CTDL_EMERG, "unable to set the access rights for [%s]: %s", ctdl_netin_dir, strerror(errno));
+               syslog(LOG_EMERG, "unable to set the access rights for [%s]: %s", ctdl_netin_dir, strerror(errno));
        if ((mkdir(ctdl_nettmp_dir, 0700) != 0) && (errno != EEXIST))
-               CtdlLogPrintf(CTDL_EMERG, "unable to create directory [%s]: %s", ctdl_nettmp_dir, strerror(errno));
+               syslog(LOG_EMERG, "unable to create directory [%s]: %s", ctdl_nettmp_dir, strerror(errno));
        if (chown(ctdl_nettmp_dir, CTDLUID, (-1)) != 0)
-               CtdlLogPrintf(CTDL_EMERG, "unable to set the access rights for [%s]: %s", ctdl_nettmp_dir, strerror(errno));
+               syslog(LOG_EMERG, "unable to set the access rights for [%s]: %s", ctdl_nettmp_dir, strerror(errno));
        if ((mkdir(ctdl_netout_dir, 0700) != 0) && (errno != EEXIST))
-               CtdlLogPrintf(CTDL_EMERG, "unable to create directory [%s]: %s", ctdl_netout_dir, strerror(errno));
+               syslog(LOG_EMERG, "unable to create directory [%s]: %s", ctdl_netout_dir, strerror(errno));
        if (chown(ctdl_netout_dir, CTDLUID, (-1)) != 0)
-               CtdlLogPrintf(CTDL_EMERG, "unable to set the access rights for [%s]: %s", ctdl_netout_dir, strerror(errno));
+               syslog(LOG_EMERG, "unable to set the access rights for [%s]: %s", ctdl_netout_dir, strerror(errno));
 }
 
 
@@ -2321,7 +2321,7 @@ void network_do_queue(void) {
         */
        if ( (time(NULL) - last_run) < config.c_net_freq ) {
                full_processing = 0;
-               CtdlLogPrintf(CTDL_DEBUG, "Network full processing in %ld seconds.\n",
+               syslog(LOG_DEBUG, "Network full processing in %ld seconds.\n",
                        config.c_net_freq - (time(NULL)- last_run)
                );
        }
@@ -2357,12 +2357,12 @@ void network_do_queue(void) {
         * Go ahead and run the queue
         */
        if (full_processing && !CtdlThreadCheckStop()) {
-               CtdlLogPrintf(CTDL_DEBUG, "network: loading outbound queue\n");
+               syslog(LOG_DEBUG, "network: loading outbound queue\n");
                CtdlForEachRoom(network_queue_room, NULL);
        }
 
        if (rplist != NULL) {
-               CtdlLogPrintf(CTDL_DEBUG, "network: running outbound queue\n");
+               syslog(LOG_DEBUG, "network: running outbound queue\n");
                while (rplist != NULL && !CtdlThreadCheckStop()) {
                        char spoolroomname[ROOMNAMELEN];
                        safestrncpy(spoolroomname, rplist->name, sizeof spoolroomname);
@@ -2401,7 +2401,7 @@ void network_do_queue(void) {
 
        network_consolidate_spoolout();
 
-       CtdlLogPrintf(CTDL_DEBUG, "network: queue run completed\n");
+       syslog(LOG_DEBUG, "network: queue run completed\n");
 
        if (full_processing) {
                last_run = time(NULL);
@@ -2438,7 +2438,7 @@ void cmd_netp(char *cmdbuf)
                        "An unknown Citadel server called \"%s\" attempted to connect from %s [%s].\n",
                        node, CC->cs_host, CC->cs_addr
                );
-               CtdlLogPrintf(CTDL_WARNING, err_buf);
+               syslog(LOG_WARNING, err_buf);
                cprintf("%d authentication failed\n", ERROR + PASSWORD_REQUIRED);
                CtdlAideMessage(err_buf, "IGNet Networking.");
                return;
@@ -2449,21 +2449,21 @@ void cmd_netp(char *cmdbuf)
                        "A Citadel server at %s [%s] failed to authenticate as network node \"%s\".\n",
                        CC->cs_host, CC->cs_addr, node
                );
-               CtdlLogPrintf(CTDL_WARNING, err_buf);
+               syslog(LOG_WARNING, err_buf);
                cprintf("%d authentication failed\n", ERROR + PASSWORD_REQUIRED);
                CtdlAideMessage(err_buf, "IGNet Networking.");
                return;
        }
 
        if (network_talking_to(node, NTT_CHECK)) {
-               CtdlLogPrintf(CTDL_WARNING, "Duplicate session for network node <%s>", node);
+               syslog(LOG_WARNING, "Duplicate session for network node <%s>", node);
                cprintf("%d Already talking to %s right now\n", ERROR + RESOURCE_BUSY, node);
                return;
        }
 
        safestrncpy(CC->net_node, node, sizeof CC->net_node);
        network_talking_to(node, NTT_ADD);
-       CtdlLogPrintf(CTDL_NOTICE, "Network node <%s> logged in from %s [%s]\n",
+       syslog(LOG_NOTICE, "Network node <%s> logged in from %s [%s]\n",
                CC->net_node, CC->cs_host, CC->cs_addr
        );
        cprintf("%d authenticated as network node '%s'\n", CIT_OK, CC->net_node);
@@ -2479,7 +2479,7 @@ int network_room_handler (struct ctdlroom *room)
 void *ignet_thread(void *arg) {
        struct CitContext ignet_thread_CC;
 
-       CtdlLogPrintf(CTDL_DEBUG, "ignet_thread() initializing\n");
+       syslog(LOG_DEBUG, "ignet_thread() initializing\n");
        CtdlFillSystemContext(&ignet_thread_CC, "IGnet Queue");
        citthread_setspecific(MyConKey, (void *)&ignet_thread_CC);
 
index e1e6b81cc39e60e764fe45f0f693587b1c32d478..db8474b1ace28dd9604369e92143ec002bace775 100644 (file)
@@ -66,7 +66,7 @@ void notes_extract_vnote(char *name, char *filename, char *partnum, char *disp,
 
        if (!strcasecmp(cbtype, "text/vnote")) {
 
-               CtdlLogPrintf(CTDL_DEBUG, "Part %s contains a vNote!  Loading...\n", partnum);
+               syslog(LOG_DEBUG, "Part %s contains a vNote!  Loading...\n", partnum);
                if (*v != NULL) {
                        vnote_free(*v);
                }
@@ -118,7 +118,7 @@ int serv_notes_beforesave(struct CtdlMessage *msg)
                                }
                        }
 
-                       CtdlLogPrintf(9, "UUID of note is: %s\n", uuid);
+                       syslog(LOG_DEBUG, "UUID of note is: %s\n", uuid);
                        if (!IsEmptyStr(uuid)) {
 
                                if (msg->cm_fields['E'] != NULL) {
@@ -150,7 +150,7 @@ int serv_notes_beforesave(struct CtdlMessage *msg)
        /* Set the message EUID to the vNote UID */
 
        if (v->uid) if (!IsEmptyStr(v->uid)) {
-               CtdlLogPrintf(9, "UID of vNote is: %s\n", v->uid);
+               syslog(LOG_DEBUG, "UID of vNote is: %s\n", v->uid);
                if (msg->cm_fields['E'] != NULL) {
                        free(msg->cm_fields['E']);
                }
index aee397cad8565d4411fe76d63e5a9bdecac0ec17..d8fa443fdea8f164b8eaa282afb4ee824cdd4304 100644 (file)
@@ -74,7 +74,7 @@ void openid_cleanup_function(void) {
        struct CitContext *CCC = CC;    /* CachedCitContext - performance boost */
 
        if (CCC->openid_data != NULL) {
-               CtdlLogPrintf(CTDL_DEBUG, "Clearing OpenID session state\n");
+               syslog(LOG_DEBUG, "Clearing OpenID session state\n");
                Free_ctdl_openid((ctdl_openid **) &CCC->openid_data);
        }
 }
@@ -125,11 +125,11 @@ int attach_openid(struct ctdluser *who, StrBuf *claimed_id)
                cdb_free(cdboi);
 
                if (fetched_usernum == who->usernum) {
-                       CtdlLogPrintf(CTDL_INFO, "%s already associated; no action is taken\n", ChrPtr(claimed_id));
+                       syslog(LOG_INFO, "%s already associated; no action is taken\n", ChrPtr(claimed_id));
                        return(0);
                }
                else {
-                       CtdlLogPrintf(CTDL_INFO, "%s already belongs to another user\n", ChrPtr(claimed_id));
+                       syslog(LOG_INFO, "%s already belongs to another user\n", ChrPtr(claimed_id));
                        return(3);
                }
        }
@@ -148,7 +148,7 @@ int attach_openid(struct ctdluser *who, StrBuf *claimed_id)
        snprintf(buf, sizeof buf, "User <%s> (#%ld) has claimed the OpenID URL %s\n",
                 who->fullname, who->usernum, ChrPtr(claimed_id));
        CtdlAideMessage(buf, "OpenID claim");
-       CtdlLogPrintf(CTDL_INFO, "%s", buf);
+       syslog(LOG_INFO, "%s", buf);
        return(0);
 }
 
@@ -188,7 +188,7 @@ void openid_purge(struct ctdluser *usbuf) {
        HashPos = GetNewHashPos(keys, 0);
        while (GetNextHashPos(keys, HashPos, &len, &Key, &Value)!=0)
        {
-               CtdlLogPrintf(CTDL_DEBUG, "Deleting associated OpenID <%s>\n", (char*)Value);
+               syslog(LOG_DEBUG, "Deleting associated OpenID <%s>\n", (char*)Value);
                cdb_delete(CDB_OPENID, Value, strlen(Value));
                /* note: don't free(Value) -- deleting the hash list will handle this for us */
        }
@@ -421,11 +421,11 @@ int openid_create_user_via_sreg(StrBuf *claimed_id, HashList *sreg_keys)
        if (CC->logged_in) return(3);
        if (!GetHash(sreg_keys, "sreg.nickname", 13, (void *) &desired_name)) return(4);
 
-       CtdlLogPrintf(CTDL_DEBUG, "The desired account name is <%s>\n", desired_name);
+       syslog(LOG_DEBUG, "The desired account name is <%s>\n", desired_name);
 
        len = cutuserkey(desired_name);
        if (!CtdlGetUser(&CC->user, desired_name)) {
-               CtdlLogPrintf(CTDL_DEBUG, "<%s> is already taken by another user.\n", desired_name);
+               syslog(LOG_DEBUG, "<%s> is already taken by another user.\n", desired_name);
                memset(&CC->user, 0, sizeof(struct ctdluser));
                return(5);
        }
@@ -569,7 +569,7 @@ int fetch_http(StrBuf *url, StrBuf **target_buf)
 
        curl = curl_easy_init();
        if (!curl) {
-               CtdlLogPrintf(CTDL_ALERT, "Unable to initialize libcurl.\n");
+               syslog(LOG_ALERT, "Unable to initialize libcurl.\n");
                return(-1);
        }
 
@@ -598,7 +598,7 @@ int fetch_http(StrBuf *url, StrBuf **target_buf)
        }
        res = curl_easy_perform(curl);
        if (res) {
-               CtdlLogPrintf(CTDL_DEBUG, "fetch_http() libcurl error %d: %s\n", res, errmsg);
+               syslog(LOG_DEBUG, "fetch_http() libcurl error %d: %s\n", res, errmsg);
        }
        curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &effective_url);
        StrBufPlain(url, effective_url, -1);
@@ -646,7 +646,7 @@ void cmd_oids(char *argbuf) {
        oiddata->verified = 0;
 
        i = fetch_http(oiddata->claimed_id, &ReplyBuf);
-       CtdlLogPrintf(CTDL_DEBUG, "Normalized URL and Claimed ID is: %s\n", 
+       syslog(LOG_DEBUG, "Normalized URL and Claimed ID is: %s\n", 
                      ChrPtr(oiddata->claimed_id));
        if ((StrLength(ReplyBuf) > 0) && (i > 0)) {
 
@@ -744,13 +744,13 @@ void cmd_oidf(char *argbuf) {
                if (len < 0)
                        len = sizeof(thiskey) - 1;
                extract_token(thisdata, buf, 1, '|', sizeof thisdata);
-               CtdlLogPrintf(CTDL_DEBUG, "%s: [%d] %s\n", thiskey, strlen(thisdata), thisdata);
+               syslog(LOG_DEBUG, "%s: [%d] %s\n", thiskey, strlen(thisdata), thisdata);
                Put(keys, thiskey, len, strdup(thisdata), NULL);
        }
 
 
        /* Now that we have all of the parameters, we have to validate the signature against the server */
-       CtdlLogPrintf(CTDL_DEBUG, "About to validate the signature...\n");
+       syslog(LOG_DEBUG, "About to validate the signature...\n");
 
        CURL *curl;
        CURLcode res;
@@ -771,14 +771,14 @@ void cmd_oidf(char *argbuf) {
                CURLFORM_COPYNAME,      "openid.mode",
                CURLFORM_COPYCONTENTS,  "check_authentication",
                CURLFORM_END);
-       CtdlLogPrintf(CTDL_DEBUG, "%25s : %s\n", "openid.mode", "check_authentication");
+       syslog(LOG_DEBUG, "%25s : %s\n", "openid.mode", "check_authentication");
 
        if (GetHash(keys, "assoc_handle", 12, (void *) &o_assoc_handle)) {
                curl_formadd(&formpost, &lastptr,
                        CURLFORM_COPYNAME,      "openid.assoc_handle",
                        CURLFORM_COPYCONTENTS,  o_assoc_handle,
                        CURLFORM_END);
-               CtdlLogPrintf(CTDL_DEBUG, "%25s : %s\n", "openid.assoc_handle", o_assoc_handle);
+               syslog(LOG_DEBUG, "%25s : %s\n", "openid.assoc_handle", o_assoc_handle);
        }
 
        if (GetHash(keys, "sig", 3, (void *) &o_sig)) {
@@ -786,7 +786,7 @@ void cmd_oidf(char *argbuf) {
                        CURLFORM_COPYNAME,      "openid.sig",
                        CURLFORM_COPYCONTENTS,  o_sig,
                        CURLFORM_END);
-                       CtdlLogPrintf(CTDL_DEBUG, "%25s : %s\n", "openid.sig", o_sig);
+                       syslog(LOG_DEBUG, "%25s : %s\n", "openid.sig", o_sig);
        }
 
        if (GetHash(keys, "signed", 6, (void *) &o_signed)) {
@@ -794,7 +794,7 @@ void cmd_oidf(char *argbuf) {
                        CURLFORM_COPYNAME,      "openid.signed",
                        CURLFORM_COPYCONTENTS,  o_signed,
                        CURLFORM_END);
-               CtdlLogPrintf(CTDL_DEBUG, "%25s : %s\n", "openid.signed", o_signed);
+               syslog(LOG_DEBUG, "%25s : %s\n", "openid.signed", o_signed);
 
                num_signed_values = num_tokens(o_signed, ',');
                for (i=0; i<num_signed_values; ++i) {
@@ -806,10 +806,10 @@ void cmd_oidf(char *argbuf) {
                                                CURLFORM_COPYNAME,      k_o_keyname,
                                                CURLFORM_COPYCONTENTS,  k_value,
                                                CURLFORM_END);
-                                       CtdlLogPrintf(CTDL_DEBUG, "%25s : %s\n", k_o_keyname, k_value);
+                                       syslog(LOG_DEBUG, "%25s : %s\n", k_o_keyname, k_value);
                                }
                                else {
-                                       CtdlLogPrintf(CTDL_INFO, "OpenID: signed field '%s' is missing\n",
+                                       syslog(LOG_INFO, "OpenID: signed field '%s' is missing\n",
                                                k_keyname);
                                }
                        }
@@ -845,7 +845,7 @@ void cmd_oidf(char *argbuf) {
 
        res = curl_easy_perform(curl);
        if (res) {
-               CtdlLogPrintf(CTDL_DEBUG, "cmd_oidf() libcurl error %d: %s\n", res, errmsg);
+               syslog(LOG_DEBUG, "cmd_oidf() libcurl error %d: %s\n", res, errmsg);
        }
        curl_easy_cleanup(curl);
        curl_formfree(formpost);
@@ -855,7 +855,7 @@ void cmd_oidf(char *argbuf) {
        }
        FreeStrBuf(&ReplyBuf);
 
-       CtdlLogPrintf(CTDL_DEBUG, "Authentication %s.\n", (oiddata->verified ? "succeeded" : "failed") );
+       syslog(LOG_DEBUG, "Authentication %s.\n", (oiddata->verified ? "succeeded" : "failed") );
 
        /* Respond to the client */
 
@@ -865,11 +865,11 @@ void cmd_oidf(char *argbuf) {
                if (CC->logged_in) {
                        if (attach_openid(&CC->user, oiddata->claimed_id) == 0) {
                                cprintf("attach\n");
-                               CtdlLogPrintf(CTDL_DEBUG, "OpenID attach succeeded\n");
+                               syslog(LOG_DEBUG, "OpenID attach succeeded\n");
                        }
                        else {
                                cprintf("fail\n");
-                               CtdlLogPrintf(CTDL_DEBUG, "OpenID attach failed\n");
+                               syslog(LOG_DEBUG, "OpenID attach failed\n");
                        }
                }
 
@@ -886,7 +886,7 @@ void cmd_oidf(char *argbuf) {
                        if (login_via_openid(oiddata->claimed_id) == 0) {
                                cprintf("authenticate\n%s\n%s\n", CC->user.fullname, CC->user.password);
                                logged_in_response();
-                               CtdlLogPrintf(CTDL_DEBUG, "Logged in using previously claimed OpenID\n");
+                               syslog(LOG_DEBUG, "Logged in using previously claimed OpenID\n");
                        }
 
                        /*
@@ -895,7 +895,7 @@ void cmd_oidf(char *argbuf) {
                         */
                        else if (config.c_disable_newu) {
                                cprintf("fail\n");
-                               CtdlLogPrintf(CTDL_DEBUG, "Creating user failed due to local policy\n");
+                               syslog(LOG_DEBUG, "Creating user failed due to local policy\n");
                        }
 
                        /*
@@ -904,7 +904,7 @@ void cmd_oidf(char *argbuf) {
                        else if (openid_create_user_via_sreg(oiddata->claimed_id, keys) == 0) {
                                cprintf("authenticate\n%s\n%s\n", CC->user.fullname, CC->user.password);
                                logged_in_response();
-                               CtdlLogPrintf(CTDL_DEBUG, "Successfully auto-created new user\n");
+                               syslog(LOG_DEBUG, "Successfully auto-created new user\n");
                        }
 
                        /*
@@ -921,7 +921,7 @@ void cmd_oidf(char *argbuf) {
                                else {
                                        cprintf("\n");
                                }
-                               CtdlLogPrintf(CTDL_DEBUG, "The desired Simple Registration name is already taken.\n");
+                               syslog(LOG_DEBUG, "The desired Simple Registration name is already taken.\n");
                        }
                }
        }
index 1ad355a3e9cc955955d735e0b46820388cecf910..fe67455e1a4dc667e0a2e2ec3c2c63d4720962d2 100644 (file)
@@ -81,7 +81,7 @@ void pop3_cleanup_function(void) {
        /* Don't do this stuff if this is not a POP3 session! */
        if (CC->h_command_function != pop3_command_loop) return;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Performing POP3 cleanup hook\n");
+       syslog(LOG_DEBUG, "Performing POP3 cleanup hook\n");
        if (POP3->msgs != NULL) free(POP3->msgs);
 
        free(POP3);
@@ -135,7 +135,7 @@ void pop3_user(char *argbuf) {
        strcpy(username, argbuf);
        striplt(username);
 
-       /* CtdlLogPrintf(CTDL_DEBUG, "Trying <%s>\n", username); */
+       /* syslog(LOG_DEBUG, "Trying <%s>\n", username); */
        if (CtdlLoginExistingUser(NULL, username) == login_ok) {
                cprintf("+OK Password required for %s\r\n", username);
        }
@@ -213,7 +213,7 @@ void pop3_login(void)
        if (msgs >= 0) {
                cprintf("+OK %s is logged in (%d messages)\r\n",
                        CC->user.fullname, msgs);
-               CtdlLogPrintf(CTDL_NOTICE, "POP3 authenticated %s\n", CC->user.fullname);
+               syslog(LOG_NOTICE, "POP3 authenticated %s\n", CC->user.fullname);
        }
        else {
                cprintf("-ERR Can't open your mailbox\r\n");
@@ -285,7 +285,7 @@ void pop3_pass(char *argbuf) {
        safestrncpy(password, argbuf, sizeof password);
        striplt(password);
 
-       /* CtdlLogPrintf(CTDL_DEBUG, "Trying <%s>\n", password); */
+       /* syslog(LOG_DEBUG, "Trying <%s>\n", password); */
        if (CtdlTryPassword(password, strlen(password)) == pass_ok) {
                pop3_login();
        }
@@ -624,15 +624,15 @@ void pop3_command_loop(void) {
        time(&CC->lastcmd);
        memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
        if (client_getln(cmdbuf, sizeof cmdbuf) < 1) {
-               CtdlLogPrintf(CTDL_ERR, "Client disconnected: ending session.\r\n");
+               syslog(LOG_ERR, "Client disconnected: ending session.\r\n");
                CC->kill_me = 1;
                return;
        }
        if (!strncasecmp(cmdbuf, "PASS", 4)) {
-               CtdlLogPrintf(CTDL_INFO, "POP3: PASS...\r\n");
+               syslog(LOG_INFO, "POP3: PASS...\r\n");
        }
        else {
-               CtdlLogPrintf(CTDL_INFO, "POP3: %s\r\n", cmdbuf);
+               syslog(LOG_INFO, "POP3: %s\r\n", cmdbuf);
        }
        while (strlen(cmdbuf) < 5) strcat(cmdbuf, " ");
 
index 117b505240e13c2268908b78a7e36d2d9b75021f..8bbb74bfc007551fa1ca8573c66dfcac226ed759 100644 (file)
@@ -156,7 +156,7 @@ eNextState FinalizePOP3AggrRun(AsyncIO *IO)
        HashPos  *It;
        pop3aggr *cptr = (pop3aggr *)IO->Data;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Terminating Aggregator; bye.\n");
+       syslog(LOG_DEBUG, "Terminating Aggregator; bye.\n");
 
        It = GetNewHashPos(POP3FetchUrls, 0);
        citthread_mutex_lock(&POP3QueueMutex);
@@ -174,8 +174,8 @@ eNextState FailAggregationRun(AsyncIO *IO)
        return eAbort;
 }
 
-#define POP3C_DBG_SEND() CtdlLogPrintf(CTDL_DEBUG, "POP3 client[%ld]: > %s\n", RecvMsg->n, ChrPtr(RecvMsg->IO.SendBuf.Buf))
-#define POP3C_DBG_READ() CtdlLogPrintf(CTDL_DEBUG, "POP3 client[%ld]: < %s\n", RecvMsg->n, ChrPtr(RecvMsg->IO.IOBuf))
+#define POP3C_DBG_SEND() syslog(LOG_DEBUG, "POP3 client[%ld]: > %s\n", RecvMsg->n, ChrPtr(RecvMsg->IO.SendBuf.Buf))
+#define POP3C_DBG_READ() syslog(LOG_DEBUG, "POP3 client[%ld]: < %s\n", RecvMsg->n, ChrPtr(RecvMsg->IO.IOBuf))
 #define POP3C_OK (strncasecmp(ChrPtr(RecvMsg->IO.IOBuf), "+OK", 3) == 0)
 
 eNextState POP3C_ReadGreeting(pop3aggr *RecvMsg)
@@ -212,7 +212,7 @@ eNextState POP3C_SendPassword(pop3aggr *RecvMsg)
        /* Password */
        StrBufPrintf(RecvMsg->IO.SendBuf.Buf,
                     "PASS %s\r\n", ChrPtr(RecvMsg->pop3pass));
-       CtdlLogPrintf(CTDL_DEBUG, "<PASS <password>\n");
+       syslog(LOG_DEBUG, "<PASS <password>\n");
 //     POP3C_DBG_SEND();
        return eReadMessage;
 }
@@ -277,14 +277,14 @@ eNextState POP3C_GetListOneLine(pop3aggr *RecvMsg)
 #if 0
        rc = TestValidateHash(RecvMsg->MsgNumbers);
        if (rc != 0) 
-               CtdlLogPrintf(CTDL_DEBUG, "Hash Invalid: %d\n", rc);
+               syslog(LOG_DEBUG, "Hash Invalid: %d\n", rc);
 #endif
                
        Put(RecvMsg->MsgNumbers, LKEY(OneMsg->MSGID), OneMsg, HfreeFetchItem);
 #if 0
        rc = TestValidateHash(RecvMsg->MsgNumbers);
        if (rc != 0) 
-               CtdlLogPrintf(CTDL_DEBUG, "Hash Invalid: %d\n", rc);
+               syslog(LOG_DEBUG, "Hash Invalid: %d\n", rc);
 #endif
        //RecvMsg->State --; /* read next Line */
        return eReadMore;
@@ -303,7 +303,7 @@ eNextState POP3_FetchNetworkUsetableEntry(AsyncIO *IO)
                struct UseTable ut;
 
                RecvMsg->CurrMsg = (FetchItem*) vData;
-               CtdlLogPrintf(CTDL_DEBUG, "CHECKING: whether %s has already been seen: ", ChrPtr(RecvMsg->CurrMsg->MsgUID));
+               syslog(LOG_DEBUG, "CHECKING: whether %s has already been seen: ", ChrPtr(RecvMsg->CurrMsg->MsgUID));
                /* Find out if we've already seen this item */
                safestrncpy(ut.ut_msgid, 
                            ChrPtr(RecvMsg->CurrMsg->MsgUID),
@@ -313,7 +313,7 @@ eNextState POP3_FetchNetworkUsetableEntry(AsyncIO *IO)
                cdbut = cdb_fetch(CDB_USETABLE, SKEY(RecvMsg->CurrMsg->MsgUID));
                if (cdbut != NULL) {
                        /* Item has already been seen */
-                       CtdlLogPrintf(CTDL_DEBUG, "YES\n");
+                       syslog(LOG_DEBUG, "YES\n");
                        cdb_free(cdbut);
                
                        /* rewrite the record anyway, to update the timestamp */
@@ -324,7 +324,7 @@ eNextState POP3_FetchNetworkUsetableEntry(AsyncIO *IO)
                }
                else
                {
-                       CtdlLogPrintf(CTDL_DEBUG, "NO\n");
+                       syslog(LOG_DEBUG, "NO\n");
                        RecvMsg->CurrMsg->NeedFetch = 1;
                }
                return NextDBOperation(&RecvMsg->IO, POP3_FetchNetworkUsetableEntry);
@@ -348,7 +348,7 @@ eNextState POP3C_GetOneMessagID(pop3aggr *RecvMsg)
        int rc;
        rc = TestValidateHash(RecvMsg->MsgNumbers);
        if (rc != 0) 
-               CtdlLogPrintf(CTDL_DEBUG, "Hash Invalid: %d\n", rc);
+               syslog(LOG_DEBUG, "Hash Invalid: %d\n", rc);
 #endif
        if(GetNextHashPos(RecvMsg->MsgNumbers, RecvMsg->Pos, &HKLen, &HKey, &vData))
        {
@@ -375,7 +375,7 @@ eNextState POP3C_GetOneMessageIDState(pop3aggr *RecvMsg)
        int rc;
        rc = TestValidateHash(RecvMsg->MsgNumbers);
        if (rc != 0) 
-               CtdlLogPrintf(CTDL_DEBUG, "Hash Invalid: %d\n", rc);
+               syslog(LOG_DEBUG, "Hash Invalid: %d\n", rc);
 #endif
 
        POP3C_DBG_READ();
@@ -440,7 +440,7 @@ eNextState POP3C_StoreMsgRead(AsyncIO *IO)
        pop3aggr *RecvMsg = (pop3aggr *) IO->Data;
        struct UseTable ut;
 
-       CtdlLogPrintf(CTDL_DEBUG, "MARKING: %s as seen: ", ChrPtr(RecvMsg->CurrMsg->MsgUID));
+       syslog(LOG_DEBUG, "MARKING: %s as seen: ", ChrPtr(RecvMsg->CurrMsg->MsgUID));
 
        safestrncpy(ut.ut_msgid, 
                    ChrPtr(RecvMsg->CurrMsg->MsgUID),
@@ -475,7 +475,7 @@ eNextState POP3C_SaveMsg(AsyncIO *IO)
 
 eNextState POP3C_ReadMessageBody(pop3aggr *RecvMsg)
 {
-       CtdlLogPrintf(CTDL_DEBUG, "Converting message...\n");
+       syslog(LOG_DEBUG, "Converting message...\n");
        RecvMsg->CurrMsg->Msg = convert_internet_message_buf(&RecvMsg->IO.ReadMsg->MsgBuf);
 
        return QueueDBOperation(&RecvMsg->IO, POP3C_SaveMsg);
@@ -587,7 +587,7 @@ void POP3SetTimeout(eNextState NextTCPState, pop3aggr *pMsg)
 {
        double Timeout = 0.0;
 
-       CtdlLogPrintf(CTDL_DEBUG, "POP3: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "POP3: %s\n", __FUNCTION__);
 
        switch (NextTCPState) {
        case eSendReply:
@@ -629,7 +629,7 @@ void POP3SetTimeout(eNextState NextTCPState, pop3aggr *pMsg)
 }
 eNextState POP3_C_DispatchReadDone(AsyncIO *IO)
 {
-       CtdlLogPrintf(CTDL_DEBUG, "POP3: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "POP3: %s\n", __FUNCTION__);
        pop3aggr *pMsg = IO->Data;
        eNextState rc;
 
@@ -641,7 +641,7 @@ eNextState POP3_C_DispatchReadDone(AsyncIO *IO)
 }
 eNextState POP3_C_DispatchWriteDone(AsyncIO *IO)
 {
-       CtdlLogPrintf(CTDL_DEBUG, "POP3: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "POP3: %s\n", __FUNCTION__);
        pop3aggr *pMsg = IO->Data;
        eNextState rc;
 
@@ -658,7 +658,7 @@ eNextState POP3_C_Terminate(AsyncIO *IO)
 {
 ///    pop3aggr *pMsg = (pop3aggr *)IO->Data;
 
-       CtdlLogPrintf(CTDL_DEBUG, "POP3: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "POP3: %s\n", __FUNCTION__);
        FinalizePOP3AggrRun(IO);
        return eAbort;
 }
@@ -666,7 +666,7 @@ eNextState POP3_C_Timeout(AsyncIO *IO)
 {
        pop3aggr *pMsg = IO->Data;
 
-       CtdlLogPrintf(CTDL_DEBUG, "POP3: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "POP3: %s\n", __FUNCTION__);
        StrBufPlain(IO->ErrMsg, CKEY(POP3C_ReadErrors[pMsg->State]));
        return FailAggregationRun(IO);
 }
@@ -674,13 +674,13 @@ eNextState POP3_C_ConnFail(AsyncIO *IO)
 {
        pop3aggr *pMsg = (pop3aggr *)IO->Data;
 
-       CtdlLogPrintf(CTDL_DEBUG, "POP3: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "POP3: %s\n", __FUNCTION__);
        StrBufPlain(IO->ErrMsg, CKEY(POP3C_ReadErrors[pMsg->State]));
        return FailAggregationRun(IO);
 }
 eNextState POP3_C_Shutdown(AsyncIO *IO)
 {
-       CtdlLogPrintf(CTDL_DEBUG, "POP3: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "POP3: %s\n", __FUNCTION__);
 ////   pop3aggr *pMsg = IO->Data;
 
        ////pMsg->MyQEntry->Status = 3;
@@ -726,7 +726,7 @@ eNextState POP3_C_ReAttachToFetchMessages(AsyncIO *IO)
 {
        pop3aggr *cpptr = IO->Data;
 
-       CtdlLogPrintf(CTDL_DEBUG, "POP3: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "POP3: %s\n", __FUNCTION__);
 ////???        cpptr->State ++;
        if (cpptr->Pos == NULL)
                cpptr->Pos = GetNewHashPos(cpptr->MsgNumbers, 0);
@@ -741,7 +741,7 @@ eNextState connect_ip(AsyncIO *IO)
 {
        pop3aggr *cpptr = IO->Data;
 
-       CtdlLogPrintf(CTDL_DEBUG, "POP3: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "POP3: %s\n", __FUNCTION__);
        
 ////   IO->ConnectMe = &cpptr->Pop3Host;
        /*  Bypass the ns lookup result like this: IO->Addr.sin_addr.s_addr = inet_addr("127.0.0.1"); */
@@ -803,9 +803,9 @@ eNextState get_one_host_ip(AsyncIO *IO)
 
        InitC_ares_dns(IO);
 
-       CtdlLogPrintf(CTDL_DEBUG, "POP3: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "POP3: %s\n", __FUNCTION__);
 
-       CtdlLogPrintf(CTDL_DEBUG, 
+       syslog(LOG_DEBUG, 
                      "POP3 client[%ld]: looking up %s-Record %s : %d ...\n", 
                      cpptr->n, 
                      (cpptr->IO.ConnectMe->IPv6)? "aaaa": "a",
@@ -843,8 +843,8 @@ int pop3_do_fetching(pop3aggr *cpptr)
        
        cpptr->IO.NextState     = eReadMessage;
 /* TODO
-   CtdlLogPrintf(CTDL_DEBUG, "POP3: %s %s %s <password>\n", roomname, pop3host, pop3user);
-   CtdlLogPrintf(CTDL_NOTICE, "Connecting to <%s>\n", pop3host);
+   syslog(LOG_DEBUG, "POP3: %s %s %s <password>\n", roomname, pop3host, pop3user);
+   syslog(LOG_DEBUG, "Connecting to <%s>\n", pop3host);
 */
        
        SubC = CloneContext (&pop3_client_CC);
@@ -885,7 +885,7 @@ void pop3client_scan_room(struct ctdlroom *qrbuf, void *data)
        citthread_mutex_lock(&POP3QueueMutex);
        if (GetHash(POP3QueueRooms, LKEY(qrbuf->QRnumber), &vptr))
        {
-               CtdlLogPrintf(CTDL_DEBUG, 
+               syslog(LOG_DEBUG, 
                              "pop3client: [%ld] %s already in progress.\n", 
                              qrbuf->QRnumber, 
                              qrbuf->QRname);
@@ -902,13 +902,13 @@ void pop3client_scan_room(struct ctdlroom *qrbuf, void *data)
        /* Only do net processing for rooms that have netconfigs */
        fd = open(filename, 0);
        if (fd <= 0) {
-               //CtdlLogPrintf(CTDL_DEBUG, "rssclient: %s no config.\n", qrbuf->QRname);
+               //syslog(LOG_DEBUG, "rssclient: %s no config.\n", qrbuf->QRname);
                return;
        }
        if (CtdlThreadCheckStop())
                return;
        if (fstat(fd, &statbuf) == -1) {
-               CtdlLogPrintf(CTDL_DEBUG,  "ERROR: could not stat configfile '%s' - %s\n",
+               syslog(LOG_DEBUG, "ERROR: could not stat configfile '%s' - %s\n",
                              filename, strerror(errno));
                return;
        }
@@ -918,7 +918,7 @@ void pop3client_scan_room(struct ctdlroom *qrbuf, void *data)
        if (StrBufReadBLOB(CfgData, &fd, 1, statbuf.st_size, &Err) < 0) {
                close(fd);
                FreeStrBuf(&CfgData);
-               CtdlLogPrintf(CTDL_DEBUG,  "ERROR: reading config '%s' - %s<br>\n",
+               syslog(LOG_DEBUG, "ERROR: reading config '%s' - %s<br>\n",
                              filename, strerror(errno));
                return;
        }
@@ -1059,7 +1059,7 @@ void pop3client_scan(void) {
        if (doing_pop3client) return;
        doing_pop3client = 1;
 
-       CtdlLogPrintf(CTDL_DEBUG, "pop3client started\n");
+       syslog(LOG_DEBUG, "pop3client started\n");
        CtdlForEachRoom(pop3client_scan_room, NULL);
 
 
@@ -1075,7 +1075,7 @@ void pop3client_scan(void) {
        DeleteHashPos(&it);
        citthread_mutex_unlock(&POP3QueueMutex);
 
-       CtdlLogPrintf(CTDL_DEBUG, "pop3client ended\n");
+       syslog(LOG_DEBUG, "pop3client ended\n");
        last_run = time(NULL);
        doing_pop3client = 0;
 }
index bed68587c54d8f905628fabc473be65cf700dd5c..a1f9b512d2a58f998987fefe3307ff7dcb37e049 100644 (file)
@@ -270,19 +270,19 @@ void rss_xml_end(void *data, const char *supplied_el)
 
 void RSS_item_rss_start (StrBuf *CData, rss_item *ri, rss_aggregator *Cfg, const char** Attr)
 {
-       CtdlLogPrintf(CTDL_DEBUG, "RSS: This is an RSS feed.\n");
+       syslog(LOG_DEBUG, "RSS: This is an RSS feed.\n");
        Cfg->ItemType = RSS_RSS;
 }
 
 void RSS_item_rdf_start(StrBuf *CData, rss_item *ri, rss_aggregator *Cfg, const char** Attr)
 {
-       CtdlLogPrintf(CTDL_DEBUG, "RSS: This is an RDF feed.\n");
+       syslog(LOG_DEBUG, "RSS: This is an RDF feed.\n");
        Cfg->ItemType = RSS_RSS;
 }
 
 void ATOM_item_feed_start(StrBuf *CData, rss_item *ri, rss_aggregator *Cfg, const char** Attr)
 {
-       CtdlLogPrintf(CTDL_DEBUG, "RSS: This is an ATOM feed.\n");
+       syslog(LOG_DEBUG, "RSS: This is an ATOM feed.\n");
        Cfg->ItemType = RSS_ATOM;
 }
 
@@ -557,13 +557,13 @@ void ATOM_item_entry_end(StrBuf *CData, rss_item *ri, rss_aggregator *Cfg, const
 
 void RSS_item_rss_end(StrBuf *CData, rss_item *ri, rss_aggregator *Cfg, const char** Attr)
 {
-//             CtdlLogPrintf(CTDL_DEBUG, "End of feed detected.  Closing parser.\n");
+//             syslog(LOG_DEBUG, "End of feed detected.  Closing parser.\n");
        ri->done_parsing = 1;
        
 }
 void RSS_item_rdf_end(StrBuf *CData, rss_item *ri, rss_aggregator *Cfg, const char** Attr)
 {
-//             CtdlLogPrintf(CTDL_DEBUG, "End of feed detected.  Closing parser.\n");
+//             syslog(LOG_DEBUG, "End of feed detected.  Closing parser.\n");
        ri->done_parsing = 1;
 }
 
@@ -637,11 +637,11 @@ eNextState ParseRSSReply(AsyncIO *IO)
        else
                ptr = "UTF-8";
 
-       CtdlLogPrintf(CTDL_ALERT, "RSS: Now parsing [%s] \n", ChrPtr(rssc->Url));
+       syslog(LOG_DEBUG, "RSS: Now parsing [%s] \n", ChrPtr(rssc->Url));
 
        rssc->xp = XML_ParserCreateNS(ptr, ':');
        if (!rssc->xp) {
-               CtdlLogPrintf(CTDL_ALERT, "Cannot create XML parser!\n");
+               syslog(LOG_DEBUG, "Cannot create XML parser!\n");
                goto shutdown;
        }
        FlushStrBuf(rssc->Key);
@@ -662,7 +662,7 @@ eNextState ParseRSSReply(AsyncIO *IO)
                XML_Parse(rssc->xp, "", 0, 1);
 
 
-       CtdlLogPrintf(CTDL_ALERT, "RSS: XML Status [%s] \n", 
+       syslog(LOG_DEBUG, "RSS: XML Status [%s] \n", 
                      XML_ErrorString(
                              XML_GetErrorCode(rssc->xp)));
 
index db13c62cc30bd23eb4d5863d5bbae4aa62c755db..4466d7f621431e869eb11261fd91cb6a7fb0e36b 100644 (file)
@@ -213,7 +213,7 @@ eNextState RSS_FetchNetworkUsetableEntry(AsyncIO *IO)
 #ifndef DEBUG_RSS
        if (cdbut != NULL) {
                /* Item has already been seen */
-               CtdlLogPrintf(CTDL_DEBUG, "%s has already been seen\n", ChrPtr(Ctx->MsgGUID));
+               syslog(LOG_DEBUG, "%s has already been seen\n", ChrPtr(Ctx->MsgGUID));
                cdb_free(cdbut);
 
                /* rewrite the record anyway, to update the timestamp */
@@ -297,7 +297,7 @@ void rss_save_item(rss_item *ri, rss_aggregator *Cfg)
        }
 
        /* translate Item into message. */
-       CtdlLogPrintf(CTDL_DEBUG, "RSS: translating item...\n");
+       syslog(LOG_DEBUG, "RSS: translating item...\n");
        if (ri->description == NULL) ri->description = NewStrBufPlain(HKEY(""));
        StrBufSpaceToBlank(ri->description);
        msg = malloc(sizeof(struct CtdlMessage));
@@ -430,7 +430,7 @@ int rss_do_fetching(rss_aggregator *Cfg)
        IO->Data = Cfg;
 
 
-       CtdlLogPrintf(CTDL_DEBUG, "Fetching RSS feed <%s>\n", ChrPtr(Cfg->Url));
+       syslog(LOG_DEBUG, "Fetching RSS feed <%s>\n", ChrPtr(Cfg->Url));
        ParseURL(&IO->ConnectMe, Cfg->Url, 80);
        CurlPrepareURL(IO->ConnectMe);
 
@@ -441,7 +441,7 @@ int rss_do_fetching(rss_aggregator *Cfg)
                          ParseRSSReply, 
                          RSSAggregatorTerminate))
        {
-               CtdlLogPrintf(CTDL_ALERT, "Unable to initialize libcurl.\n");
+               syslog(LOG_DEBUG, "Unable to initialize libcurl.\n");
                return 0;
        }
 
@@ -533,7 +533,7 @@ void rssclient_scan_room(struct ctdlroom *qrbuf, void *data)
        citthread_mutex_lock(&RSSQueueMutex);
        if (GetHash(RSSQueueRooms, LKEY(qrbuf->QRnumber), &vptr))
        {
-               CtdlLogPrintf(CTDL_DEBUG, 
+               syslog(LOG_DEBUG, 
                              "rssclient: [%ld] %s already in progress.\n", 
                              qrbuf->QRnumber, 
                              qrbuf->QRname);
@@ -550,13 +550,13 @@ void rssclient_scan_room(struct ctdlroom *qrbuf, void *data)
        /* Only do net processing for rooms that have netconfigs */
        fd = open(filename, 0);
        if (fd <= 0) {
-               //CtdlLogPrintf(CTDL_DEBUG, "rssclient: %s no config.\n", qrbuf->QRname);
+               //syslog(LOG_DEBUG, "rssclient: %s no config.\n", qrbuf->QRname);
                return;
        }
        if (CtdlThreadCheckStop())
                return;
        if (fstat(fd, &statbuf) == -1) {
-               CtdlLogPrintf(CTDL_DEBUG,  "ERROR: could not stat configfile '%s' - %s\n",
+               syslog(LOG_DEBUG, "ERROR: could not stat configfile '%s' - %s\n",
                        filename, strerror(errno));
                return;
        }
@@ -566,7 +566,7 @@ void rssclient_scan_room(struct ctdlroom *qrbuf, void *data)
        if (StrBufReadBLOB(CfgData, &fd, 1, statbuf.st_size, &Err) < 0) {
                close(fd);
                FreeStrBuf(&CfgData);
-               CtdlLogPrintf(CTDL_DEBUG,  "ERROR: reading config '%s' - %s<br>\n",
+               syslog(LOG_DEBUG, "ERROR: reading config '%s' - %s<br>\n",
                        filename, strerror(errno));
                return;
        }
@@ -644,7 +644,7 @@ void rssclient_scan_room(struct ctdlroom *qrbuf, void *data)
        {
                Count->QRnumber = qrbuf->QRnumber;
                citthread_mutex_lock(&RSSQueueMutex);
-               CtdlLogPrintf(CTDL_DEBUG, "rssclient: [%ld] %s now starting.\n", 
+               syslog(LOG_DEBUG, "rssclient: [%ld] %s now starting.\n", 
                              qrbuf->QRnumber, qrbuf->QRname);
                Put(RSSQueueRooms, LKEY(qrbuf->QRnumber), Count, NULL);
                citthread_mutex_unlock(&RSSQueueMutex);
@@ -674,7 +674,7 @@ void rssclient_scan(void) {
        if (doing_rssclient) return;
        doing_rssclient = 1;
 
-       CtdlLogPrintf(CTDL_DEBUG, "rssclient started\n");
+       syslog(LOG_DEBUG, "rssclient started\n");
        CtdlForEachRoom(rssclient_scan_room, NULL);
 
        citthread_mutex_lock(&RSSQueueMutex);
@@ -690,7 +690,7 @@ void rssclient_scan(void) {
        DeleteHashPos(&it);
        citthread_mutex_unlock(&RSSQueueMutex);
 
-       CtdlLogPrintf(CTDL_DEBUG, "rssclientscheduler ended\n");
+       syslog(LOG_DEBUG, "rssclient ended\n");
        doing_rssclient = 0;
        return;
 }
@@ -710,7 +710,7 @@ CTDL_MODULE_INIT(rssclient)
                citthread_mutex_init(&RSSQueueMutex, NULL);
                RSSQueueRooms = NewHash(1, lFlathash);
                RSSFetchUrls = NewHash(1, NULL);
-               CtdlLogPrintf(CTDL_INFO, "%s\n", curl_version());
+               syslog(LOG_INFO, "%s\n", curl_version());
                CtdlRegisterSessionHook(rssclient_scan, EVT_TIMER);
                 CtdlRegisterCleanupHook(rss_cleanup);
        }
index a8fe4ea38a030f18eab573a8e985e2992b18d045..6a3ad95090a81ea8a24cf9100ba32905d8e3f70c 100644 (file)
@@ -64,7 +64,7 @@ char *msiv_extensions = NULL;
  */
 int ctdl_debug(sieve2_context_t *s, void *my)
 {
-       CtdlLogPrintf(CTDL_DEBUG, "Sieve: %s\n", sieve2_getvalue_string(s, "message"));
+       syslog(LOG_DEBUG, "Sieve: %s\n", sieve2_getvalue_string(s, "message"));
        return SIEVE2_OK;
 }
 
@@ -74,7 +74,7 @@ int ctdl_debug(sieve2_context_t *s, void *my)
  */
 int ctdl_errparse(sieve2_context_t *s, void *my)
 {
-       CtdlLogPrintf(CTDL_WARNING, "Error in script, line %d: %s\n",
+       syslog(LOG_WARNING, "Error in script, line %d: %s\n",
                sieve2_getvalue_int(s, "lineno"),
                sieve2_getvalue_string(s, "message")
        );
@@ -87,7 +87,7 @@ int ctdl_errparse(sieve2_context_t *s, void *my)
  */
 int ctdl_errexec(sieve2_context_t *s, void *my)
 {
-       CtdlLogPrintf(CTDL_WARNING, "Error executing script: %s\n",
+       syslog(LOG_WARNING, "Error executing script: %s\n",
                sieve2_getvalue_string(s, "message")
        );
        return SIEVE2_OK;
@@ -106,22 +106,22 @@ int ctdl_redirect(sieve2_context_t *s, void *my)
 
        safestrncpy(recp, sieve2_getvalue_string(s, "address"), sizeof recp);
 
-       CtdlLogPrintf(CTDL_DEBUG, "Action is REDIRECT, recipient <%s>\n", recp);
+       syslog(LOG_DEBUG, "Action is REDIRECT, recipient <%s>\n", recp);
 
        valid = validate_recipients(recp, NULL, 0);
        if (valid == NULL) {
-               CtdlLogPrintf(CTDL_WARNING, "REDIRECT failed: bad recipient <%s>\n", recp);
+               syslog(LOG_WARNING, "REDIRECT failed: bad recipient <%s>\n", recp);
                return SIEVE2_ERROR_BADARGS;
        }
        if (valid->num_error > 0) {
-               CtdlLogPrintf(CTDL_WARNING, "REDIRECT failed: bad recipient <%s>\n", recp);
+               syslog(LOG_WARNING, "REDIRECT failed: bad recipient <%s>\n", recp);
                free_recipients(valid);
                return SIEVE2_ERROR_BADARGS;
        }
 
        msg = CtdlFetchMessage(cs->msgnum, 1);
        if (msg == NULL) {
-               CtdlLogPrintf(CTDL_WARNING, "REDIRECT failed: unable to fetch msg %ld\n", cs->msgnum);
+               syslog(LOG_WARNING, "REDIRECT failed: unable to fetch msg %ld\n", cs->msgnum);
                free_recipients(valid);
                return SIEVE2_ERROR_BADARGS;
        }
@@ -141,7 +141,7 @@ int ctdl_keep(sieve2_context_t *s, void *my)
 {
        struct ctdl_sieve *cs = (struct ctdl_sieve *)my;
        
-       CtdlLogPrintf(CTDL_DEBUG, "Action is KEEP\n");
+       syslog(LOG_DEBUG, "Action is KEEP\n");
 
        cs->keep = 1;
        cs->cancel_implicit_keep = 1;
@@ -160,7 +160,7 @@ int ctdl_fileinto(sieve2_context_t *s, void *my)
        char foldername[256];
        char original_room_name[ROOMNAMELEN];
 
-       CtdlLogPrintf(CTDL_DEBUG, "Action is FILEINTO, destination is <%s>\n", dest_folder);
+       syslog(LOG_DEBUG, "Action is FILEINTO, destination is <%s>\n", dest_folder);
 
        /* FILEINTO 'INBOX' is the same thing as KEEP */
        if ( (!strcasecmp(dest_folder, "INBOX")) || (!strcasecmp(dest_folder, MAILROOM)) ) {
@@ -183,7 +183,7 @@ int ctdl_fileinto(sieve2_context_t *s, void *my)
        }
 
        if (c != 0) {
-               CtdlLogPrintf(CTDL_WARNING, "FILEINTO failed: target <%s> does not exist\n", dest_folder);
+               syslog(LOG_WARNING, "FILEINTO failed: target <%s> does not exist\n", dest_folder);
                return SIEVE2_ERROR_BADARGS;
        }
 
@@ -214,7 +214,7 @@ int ctdl_discard(sieve2_context_t *s, void *my)
 {
        struct ctdl_sieve *cs = (struct ctdl_sieve *)my;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Action is DISCARD\n");
+       syslog(LOG_DEBUG, "Action is DISCARD\n");
 
        /* Cancel the implicit keep.  That's all there is to it. */
        cs->cancel_implicit_keep = 1;
@@ -231,11 +231,11 @@ int ctdl_reject(sieve2_context_t *s, void *my)
        struct ctdl_sieve *cs = (struct ctdl_sieve *)my;
        char *reject_text = NULL;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Action is REJECT\n");
+       syslog(LOG_DEBUG, "Action is REJECT\n");
 
        /* If we don't know who sent the message, do a DISCARD instead. */
        if (IsEmptyStr(cs->sender)) {
-               CtdlLogPrintf(CTDL_INFO, "Unknown sender.  Doing DISCARD instead of REJECT.\n");
+               syslog(LOG_INFO, "Unknown sender.  Doing DISCARD instead of REJECT.\n");
                return ctdl_discard(s, my);
        }
 
@@ -286,7 +286,7 @@ int ctdl_vacation(sieve2_context_t *s, void *my)
        char *vacamsg_text = NULL;
        char vacamsg_subject[1024];
 
-       CtdlLogPrintf(CTDL_DEBUG, "Action is VACATION\n");
+       syslog(LOG_DEBUG, "Action is VACATION\n");
 
        message = sieve2_getvalue_string(s, "message");
        if (message == NULL) return SIEVE2_ERROR_BADARGS;
@@ -306,7 +306,7 @@ int ctdl_vacation(sieve2_context_t *s, void *my)
        for (vptr = cs->u->first_vacation; vptr != NULL; vptr = vptr->next) {
                if (!strcasecmp(vptr->fromaddr, cs->sender)) {
                        if ( (time(NULL) - vptr->timestamp) < (days * 86400) ) {
-                               CtdlLogPrintf(CTDL_DEBUG, "Already alerted <%s> recently.\n", cs->sender);
+                               syslog(LOG_DEBUG, "Already alerted <%s> recently.\n", cs->sender);
                                return SIEVE2_OK;
                        }
                }
@@ -391,7 +391,7 @@ int ctdl_getenvelope(sieve2_context_t *s, void *my)
 {
        struct ctdl_sieve *cs = (struct ctdl_sieve *)my;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Action is GETENVELOPE\nEnvFrom: %s\n  EnvTo: %s\n",
+       syslog(LOG_DEBUG, "Action is GETENVELOPE\nEnvFrom: %s\n  EnvTo: %s\n",
                cs->envelope_from, cs->envelope_to);
 
        if (cs->envelope_from != NULL) {
@@ -463,13 +463,13 @@ int ctdl_getscript(sieve2_context_t *s, void *my) {
 
        for (sptr=cs->u->first_script; sptr!=NULL; sptr=sptr->next) {
                if (sptr->script_active > 0) {
-                       CtdlLogPrintf(CTDL_DEBUG, "ctdl_getscript() is using script '%s'\n", sptr->script_name);
+                       syslog(LOG_DEBUG, "ctdl_getscript() is using script '%s'\n", sptr->script_name);
                        sieve2_setvalue_string(s, "script", sptr->script_content);
                        return SIEVE2_OK;
                }
        }
                
-       CtdlLogPrintf(CTDL_DEBUG, "ctdl_getscript() found no active script\n");
+       syslog(LOG_DEBUG, "ctdl_getscript() found no active script\n");
        return SIEVE2_ERROR_GETSCRIPT;
 }
 
@@ -480,7 +480,7 @@ int ctdl_getheaders(sieve2_context_t *s, void *my) {
 
        struct ctdl_sieve *cs = (struct ctdl_sieve *)my;
 
-       CtdlLogPrintf(CTDL_DEBUG, "ctdl_getheaders() was called\n");
+       syslog(LOG_DEBUG, "ctdl_getheaders() was called\n");
        sieve2_setvalue_string(s, "allheaders", cs->rfc822headers);
        return SIEVE2_OK;
 }
@@ -501,7 +501,7 @@ void sieve_queue_room(struct ctdlroom *which_room) {
        ptr->next = sieve_list;
        sieve_list = ptr;
        end_critical_section(S_SIEVELIST);
-       CtdlLogPrintf(CTDL_DEBUG, "<%s> queued for Sieve processing\n", which_room->QRname);
+       syslog(LOG_DEBUG, "<%s> queued for Sieve processing\n", which_room->QRname);
 }
 
 
@@ -521,13 +521,13 @@ void sieve_do_msg(long msgnum, void *userdata) {
 
        if (u == NULL)
        {
-               CtdlLogPrintf(CTDL_EMERG, "Can't process message <%ld> without userdata!\n", msgnum);
+               syslog(LOG_EMERG, "Can't process message <%ld> without userdata!\n", msgnum);
                return;
        }
 
        sieve2_context = u->sieve2_context;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Performing sieve processing on msg <%ld>\n", msgnum);
+       syslog(LOG_DEBUG, "Performing sieve processing on msg <%ld>\n", msgnum);
 
        /*
         * Make sure you include message body so you can get those second-level headers ;)
@@ -638,10 +638,10 @@ void sieve_do_msg(long msgnum, void *userdata) {
 
        sieve2_setvalue_string(sieve2_context, "allheaders", my.rfc822headers);
        
-       CtdlLogPrintf(CTDL_DEBUG, "Calling sieve2_execute()\n");
+       syslog(LOG_DEBUG, "Calling sieve2_execute()\n");
        res = sieve2_execute(sieve2_context, &my);
        if (res != SIEVE2_OK) {
-               CtdlLogPrintf(CTDL_CRIT, "sieve2_execute() returned %d: %s\n", res, sieve2_errstr(res));
+               syslog(LOG_CRIT, "sieve2_execute() returned %d: %s\n", res, sieve2_errstr(res));
        }
 
        free(my.rfc822headers);
@@ -652,11 +652,11 @@ void sieve_do_msg(long msgnum, void *userdata) {
         * if no other action was successfully taken.
         */
        if ( (!my.keep) && (my.cancel_implicit_keep) ) {
-               CtdlLogPrintf(CTDL_DEBUG, "keep is 0 -- deleting message from inbox\n");
+               syslog(LOG_DEBUG, "keep is 0 -- deleting message from inbox\n");
                CtdlDeleteMessages(CC->room.QRname, &msgnum, 1, "");
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Completed sieve processing on msg <%ld>\n", msgnum);
+       syslog(LOG_DEBUG, "Completed sieve processing on msg <%ld>\n", msgnum);
        u->lastproc = msgnum;
 
        return;
@@ -865,7 +865,7 @@ void sieve_do_room(char *roomname) {
         */
        snprintf(u.config_roomname, sizeof u.config_roomname, "%010ld.%s", atol(roomname), USERCONFIGROOM);
        if (CtdlGetRoom(&CC->room, u.config_roomname) != 0) {
-               CtdlLogPrintf(CTDL_DEBUG, "<%s> does not exist.  No processing is required.\n", u.config_roomname);
+               syslog(LOG_DEBUG, "<%s> does not exist.  No processing is required.\n", u.config_roomname);
                return;
        }
 
@@ -877,14 +877,14 @@ void sieve_do_room(char *roomname) {
                get_sieve_config_backend, (void *)&u );
 
        if (u.config_msgnum < 0) {
-               CtdlLogPrintf(CTDL_DEBUG, "No Sieve rules exist.  No processing is required.\n");
+               syslog(LOG_DEBUG, "No Sieve rules exist.  No processing is required.\n");
                return;
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Rules found.  Performing Sieve processing for <%s>\n", roomname);
+       syslog(LOG_DEBUG, "Rules found.  Performing Sieve processing for <%s>\n", roomname);
 
        if (CtdlGetRoom(&CC->room, roomname) != 0) {
-               CtdlLogPrintf(CTDL_CRIT, "ERROR: cannot load <%s>\n", roomname);
+               syslog(LOG_CRIT, "ERROR: cannot load <%s>\n", roomname);
                return;
        }
 
@@ -892,13 +892,13 @@ void sieve_do_room(char *roomname) {
        
        res = sieve2_alloc(&sieve2_context);
        if (res != SIEVE2_OK) {
-               CtdlLogPrintf(CTDL_CRIT, "sieve2_alloc() returned %d: %s\n", res, sieve2_errstr(res));
+               syslog(LOG_CRIT, "sieve2_alloc() returned %d: %s\n", res, sieve2_errstr(res));
                return;
        }
 
        res = sieve2_callbacks(sieve2_context, ctdl_sieve_callbacks);
        if (res != SIEVE2_OK) {
-               CtdlLogPrintf(CTDL_CRIT, "sieve2_callbacks() returned %d: %s\n", res, sieve2_errstr(res));
+               syslog(LOG_CRIT, "sieve2_callbacks() returned %d: %s\n", res, sieve2_errstr(res));
                goto BAIL;
        }
 
@@ -909,7 +909,7 @@ void sieve_do_room(char *roomname) {
        my.u = &u;
        res = sieve2_validate(sieve2_context, &my);
        if (res != SIEVE2_OK) {
-               CtdlLogPrintf(CTDL_CRIT, "sieve2_validate() returned %d: %s\n", res, sieve2_errstr(res));
+               syslog(LOG_CRIT, "sieve2_validate() returned %d: %s\n", res, sieve2_errstr(res));
                goto BAIL;
        }
 
@@ -924,7 +924,7 @@ void sieve_do_room(char *roomname) {
 BAIL:
        res = sieve2_free(&sieve2_context);
        if (res != SIEVE2_OK) {
-               CtdlLogPrintf(CTDL_CRIT, "sieve2_free() returned %d: %s\n", res, sieve2_errstr(res));
+               syslog(LOG_CRIT, "sieve2_free() returned %d: %s\n", res, sieve2_errstr(res));
        }
 
        /* Rewrite the config if we have to */
@@ -939,7 +939,7 @@ void perform_sieve_processing(void) {
        struct RoomProcList *ptr = NULL;
 
        if (sieve_list != NULL) {
-               CtdlLogPrintf(CTDL_DEBUG, "Begin Sieve processing\n");
+               syslog(LOG_DEBUG, "Begin Sieve processing\n");
                while (sieve_list != NULL) {
                        char spoolroomname[ROOMNAMELEN];
                        safestrncpy(spoolroomname, sieve_list->name, sizeof spoolroomname);
@@ -1256,7 +1256,7 @@ void ctdl_sieve_init(void) {
                strcpy(&cred[55], "...");
        }
 
-       CtdlLogPrintf(CTDL_INFO, "%s\n",cred);
+       syslog(LOG_INFO, "%s\n",cred);
        free(cred);
 
        /* Briefly initialize a Sieve parser instance just so we can list the
@@ -1264,22 +1264,22 @@ void ctdl_sieve_init(void) {
         */
        res = sieve2_alloc(&sieve2_context);
        if (res != SIEVE2_OK) {
-               CtdlLogPrintf(CTDL_CRIT, "sieve2_alloc() returned %d: %s\n", res, sieve2_errstr(res));
+               syslog(LOG_CRIT, "sieve2_alloc() returned %d: %s\n", res, sieve2_errstr(res));
                return;
        }
 
        res = sieve2_callbacks(sieve2_context, ctdl_sieve_callbacks);
        if (res != SIEVE2_OK) {
-               CtdlLogPrintf(CTDL_CRIT, "sieve2_callbacks() returned %d: %s\n", res, sieve2_errstr(res));
+               syslog(LOG_CRIT, "sieve2_callbacks() returned %d: %s\n", res, sieve2_errstr(res));
                goto BAIL;
        }
 
        msiv_extensions = strdup(sieve2_listextensions(sieve2_context));
-       CtdlLogPrintf(CTDL_INFO, "Extensions: %s\n", msiv_extensions);
+       syslog(LOG_INFO, "Extensions: %s\n", msiv_extensions);
 
 BAIL:  res = sieve2_free(&sieve2_context);
        if (res != SIEVE2_OK) {
-               CtdlLogPrintf(CTDL_CRIT, "sieve2_free() returned %d: %s\n", res, sieve2_errstr(res));
+               syslog(LOG_CRIT, "sieve2_free() returned %d: %s\n", res, sieve2_errstr(res));
        }
 
 }
index cccb61bf68ae6df8d893cbac4b8fc4fd72b41ee0..d2fbe63840b603778225dcc9640bc590bf52c3d0 100644 (file)
@@ -217,7 +217,7 @@ void lmtp_unfiltered_greeting(void) {
  */
 void smtp_auth_greeting(void) {
                cprintf("235 Hello, %s\r\n", CC->user.fullname);
-               CtdlLogPrintf(CTDL_NOTICE, "SMTP authenticated %s\n", CC->user.fullname);
+               syslog(LOG_NOTICE, "SMTP authenticated %s\n", CC->user.fullname);
                CC->internal_pgm = 0;
                CC->cs_flags &= ~CS_STEALTH;
 }
@@ -302,7 +302,7 @@ void smtp_get_user(char *argbuf) {
        citsmtp *sSMTP = SMTP;
 
        CtdlDecodeBase64(username, argbuf, SIZ);
-       /* CtdlLogPrintf(CTDL_DEBUG, "Trying <%s>\n", username); */
+       /* syslog(LOG_DEBUG, "Trying <%s>\n", username); */
        if (CtdlLoginExistingUser(NULL, username) == login_ok) {
                CtdlEncodeBase64(buf, "Password:", 9, 0);
                cprintf("334 %s\r\n", buf);
@@ -324,7 +324,7 @@ void smtp_get_pass(char *argbuf) {
 
        memset(password, 0, sizeof(password));  
        len = CtdlDecodeBase64(password, argbuf, SIZ);
-       /* CtdlLogPrintf(CTDL_DEBUG, "Trying <%s>\n", password); */
+       /* syslog(LOG_DEBUG, "Trying <%s>\n", password); */
        if (CtdlTryPassword(password, len) == pass_ok) {
                smtp_auth_greeting();
        }
@@ -695,7 +695,7 @@ void smtp_data(void) {
                return;
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Converting message...\n");
+       syslog(LOG_DEBUG, "Converting message...\n");
        msg = convert_internet_message_buf(&body);
 
        /* If the user is locally authenticated, FORCE the From: header to
@@ -785,20 +785,18 @@ void smtp_data(void) {
                cprintf("%s", result);
        }
 
-       /* Write something to the syslog (which may or may not be where the
+       /* Write something to the syslog(which may or may not be where the
         * rest of the Citadel logs are going; some sysadmins want LOG_MAIL).
         */
-       if (enable_syslog) {
-               syslog((LOG_MAIL | LOG_INFO),
-                       "%ld: from=<%s>, nrcpts=%d, relay=%s [%s], stat=%s",
-                       msgnum,
-                       sSMTP->from,
-                       sSMTP->number_of_recipients,
-                       CC->cs_host,
-                       CC->cs_addr,
-                       result
-               );
-       }
+       syslog((LOG_MAIL | LOG_INFO),
+               "%ld: from=<%s>, nrcpts=%d, relay=%s [%s], stat=%s",
+               msgnum,
+               sSMTP->from,
+               sSMTP->number_of_recipients,
+               CC->cs_host,
+               CC->cs_addr,
+               result
+       );
 
        /* Clean up */
        CtdlFreeMessage(msg);
@@ -836,17 +834,17 @@ void smtp_command_loop(void) {
        citsmtp *sSMTP = SMTP;
 
        if (sSMTP == NULL) {
-               CtdlLogPrintf(CTDL_EMERG, "Session SMTP data is null.  WTF?  We will crash now.\n");
+               syslog(LOG_EMERG, "Session SMTP data is null.  WTF?  We will crash now.\n");
        }
 
        time(&CC->lastcmd);
        memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
        if (client_getln(cmdbuf, sizeof cmdbuf) < 1) {
-               CtdlLogPrintf(CTDL_CRIT, "Client disconnected: ending session.\n");
+               syslog(LOG_CRIT, "Client disconnected: ending session.\n");
                CC->kill_me = 1;
                return;
        }
-       CtdlLogPrintf(CTDL_INFO, "SMTP server: %s\n", cmdbuf);
+       syslog(LOG_INFO, "SMTP server: %s\n", cmdbuf);
        while (strlen(cmdbuf) < 5) strcat(cmdbuf, " ");
 
        if (sSMTP->command_state == smtp_user) {
@@ -937,7 +935,7 @@ void smtp_cleanup_function(void) {
        /* Don't do this stuff if this is not an SMTP session! */
        if (CC->h_command_function != smtp_command_loop) return;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Performing SMTP cleanup hook\n");
+       syslog(LOG_DEBUG, "Performing SMTP cleanup hook\n");
        free(SMTP);
 }
 
index 7be77a4142f723315d1ed019f3782baa4ec02fcf..9782d3e42ebad236495acc3243a2cedaf7257abd 100644 (file)
@@ -129,7 +129,7 @@ void smtp_try(const char *key, const char *addr, int *status,
        /* Parse out the host portion of the recipient address */
        process_rfc822_addr(addr, user, node, name);
 
-       CtdlLogPrintf(CTDL_DEBUG, "SMTP client: Attempting delivery to <%s> @ <%s> (%s)\n",
+       syslog(LOG_DEBUG, "SMTP client: Attempting delivery to <%s> @ <%s> (%s)\n",
                user, node, name);
 
        /* Load the message out of the database */
@@ -190,7 +190,7 @@ void smtp_try(const char *key, const char *addr, int *status,
 
        /* Figure out what mail exchanger host we have to connect to */
        num_mxhosts = getmx(mxhosts, node);
-       CtdlLogPrintf(CTDL_DEBUG, "Number of MX hosts for <%s> is %d [%s]\n", node, num_mxhosts, mxhosts);
+       syslog(LOG_DEBUG, "Number of MX hosts for <%s> is %d [%s]\n", node, num_mxhosts, mxhosts);
        if (num_mxhosts < 1) {
                *status = 5;
                snprintf(dsn, SIZ, "No MX hosts found for <%s>", node);
@@ -224,21 +224,21 @@ void smtp_try(const char *key, const char *addr, int *status,
                else {
                        strcpy(mx_port, "25");
                }
-               CtdlLogPrintf(CTDL_DEBUG, "SMTP client: connecting to %s : %s ...\n", mx_host, mx_port);
+               syslog(LOG_DEBUG, "SMTP client: connecting to %s : %s ...\n", mx_host, mx_port);
                sock = sock_connect(mx_host, mx_port);
                snprintf(dsn, SIZ, "Could not connect: %s", strerror(errno));
                if (sock >= 0) 
                {
-                       CtdlLogPrintf(CTDL_DEBUG, "SMTP client: connected!\n");
+                       syslog(LOG_DEBUG, "SMTP client: connected!\n");
                                int fdflags; 
                                fdflags = fcntl(sock, F_GETFL);
                                if (fdflags < 0)
-                                       CtdlLogPrintf(CTDL_DEBUG,
+                                       syslog(LOG_DEBUG,
                                                      "unable to get SMTP-Client socket flags! %s \n",
                                                      strerror(errno));
                                fdflags = fdflags | O_NONBLOCK;
                                if (fcntl(sock, F_SETFL, fdflags) < 0)
-                                       CtdlLogPrintf(CTDL_DEBUG,
+                                       syslog(LOG_DEBUG,
                                                      "unable to set SMTP-Client socket nonblocking flags! %s \n",
                                                      strerror(errno));
                }
@@ -267,7 +267,7 @@ void smtp_try(const char *key, const char *addr, int *status,
                strcpy(dsn, "Connection broken during SMTP conversation");
                goto bail;
        }
-       CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+       syslog(LOG_DEBUG, "<%s\n", buf);
        if (buf[0] != '2') {
                if (buf[0] == '4') {
                        *status = 4;
@@ -285,17 +285,17 @@ void smtp_try(const char *key, const char *addr, int *status,
 
        /* Do a EHLO command.  If it fails, try the HELO command. */
        snprintf(buf, sizeof buf, "EHLO %s\r\n", config.c_fqdn);
-       CtdlLogPrintf(CTDL_DEBUG, ">%s", buf);
+       syslog(LOG_DEBUG, ">%s", buf);
        sock_write(&sock, buf, strlen(buf));
        if (ml_sock_gets(&sock, buf, 30) < 0) {
                *status = 4;
                strcpy(dsn, "Connection broken during SMTP HELO");
                goto bail;
        }
-       CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+       syslog(LOG_DEBUG, "<%s\n", buf);
        if (buf[0] != '2') {
                snprintf(buf, sizeof buf, "HELO %s\r\n", config.c_fqdn);
-               CtdlLogPrintf(CTDL_DEBUG, ">%s", buf);
+               syslog(LOG_DEBUG, ">%s", buf);
                sock_write(&sock, buf, strlen(buf));
                if (ml_sock_gets(&sock, buf, 30) < 0) {
                        *status = 4;
@@ -322,14 +322,14 @@ void smtp_try(const char *key, const char *addr, int *status,
                sprintf(buf, "%s%c%s%c%s", mx_user, '\0', mx_user, '\0', mx_pass);
                CtdlEncodeBase64(encoded, buf, strlen(mx_user) + strlen(mx_user) + strlen(mx_pass) + 2, 0);
                snprintf(buf, sizeof buf, "AUTH PLAIN %s\r\n", encoded);
-               CtdlLogPrintf(CTDL_DEBUG, ">%s", buf);
+               syslog(LOG_DEBUG, ">%s", buf);
                sock_write(&sock, buf, strlen(buf));
                if (ml_sock_gets(&sock, buf, 30) < 0) {
                        *status = 4;
                        strcpy(dsn, "Connection broken during SMTP AUTH");
                        goto bail;
                }
-               CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+               syslog(LOG_DEBUG, "<%s\n", buf);
                if (buf[0] != '2') {
                        if (buf[0] == '4') {
                                *status = 4;
@@ -346,14 +346,14 @@ void smtp_try(const char *key, const char *addr, int *status,
 
        /* previous command succeeded, now try the MAIL FROM: command */
        snprintf(buf, sizeof buf, "MAIL FROM:<%s>\r\n", envelope_from);
-       CtdlLogPrintf(CTDL_DEBUG, ">%s", buf);
+       syslog(LOG_DEBUG, ">%s", buf);
        sock_write(&sock, buf, strlen(buf));
        if (ml_sock_gets(&sock, buf, 30) < 0) {
                *status = 4;
                strcpy(dsn, "Connection broken during SMTP MAIL");
                goto bail;
        }
-       CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+       syslog(LOG_DEBUG, "<%s\n", buf);
        if (buf[0] != '2') {
                if (buf[0] == '4') {
                        *status = 4;
@@ -369,14 +369,14 @@ void smtp_try(const char *key, const char *addr, int *status,
 
        /* MAIL succeeded, now try the RCPT To: command */
        snprintf(buf, sizeof buf, "RCPT TO:<%s@%s>\r\n", user, node);
-       CtdlLogPrintf(CTDL_DEBUG, ">%s", buf);
+       syslog(LOG_DEBUG, ">%s", buf);
        sock_write(&sock, buf, strlen(buf));
        if (ml_sock_gets(&sock, buf, 30) < 0) {
                *status = 4;
                strcpy(dsn, "Connection broken during SMTP RCPT");
                goto bail;
        }
-       CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+       syslog(LOG_DEBUG, "<%s\n", buf);
        if (buf[0] != '2') {
                if (buf[0] == '4') {
                        *status = 4;
@@ -391,14 +391,14 @@ void smtp_try(const char *key, const char *addr, int *status,
        }
 
        /* RCPT succeeded, now try the DATA command */
-       CtdlLogPrintf(CTDL_DEBUG, ">DATA\n");
+       syslog(LOG_DEBUG, ">DATA\n");
        sock_write(&sock, "DATA\r\n", 6);
        if (ml_sock_gets(&sock, buf, 30) < 0) {
                *status = 4;
                strcpy(dsn, "Connection broken during SMTP DATA");
                goto bail;
        }
-       CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+       syslog(LOG_DEBUG, "<%s\n", buf);
        if (buf[0] != '3') {
                if (buf[0] == '4') {
                        *status = 3;
@@ -418,7 +418,7 @@ void smtp_try(const char *key, const char *addr, int *status,
                           msg_size, 
                           (msg_size / 128) + 50);
        if (msgtext[msg_size-1] != 10) {
-               CtdlLogPrintf(CTDL_WARNING, "Possible problem: message did not "
+               syslog(LOG_WARNING, "Possible problem: message did not "
                        "correctly terminate. (expecting 0x10, got 0x%02x)\n",
                                buf[msg_size-1]);
                sock_write(&sock, "\r\n", 2);
@@ -431,7 +431,7 @@ void smtp_try(const char *key, const char *addr, int *status,
                strcpy(dsn, "Connection broken during SMTP message transmit");
                goto bail;
        }
-       CtdlLogPrintf(CTDL_DEBUG, "%s\n", buf);
+       syslog(LOG_DEBUG, "%s\n", buf);
        if (buf[0] != '2') {
                if (buf[0] == '4') {
                        *status = 4;
@@ -449,11 +449,11 @@ void smtp_try(const char *key, const char *addr, int *status,
        safestrncpy(dsn, &buf[4], 1023);
        *status = 2;
 
-       CtdlLogPrintf(CTDL_DEBUG, ">QUIT\n");
+       syslog(LOG_DEBUG, ">QUIT\n");
        sock_write(&sock, "QUIT\r\n", 6);
        ml_sock_gets(&sock, buf, 30);
-       CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
-       CtdlLogPrintf(CTDL_INFO, "SMTP client: delivery to <%s> @ <%s> (%s) succeeded\n",
+       syslog(LOG_DEBUG, "<%s\n", buf);
+       syslog(LOG_INFO, "SMTP client: delivery to <%s> @ <%s> (%s) succeeded\n",
                user, node, name);
 
 bail:  free(msgtext);
@@ -462,18 +462,16 @@ bail:     free(msgtext);
        if (sock != -1)
                sock_close(sock);
 
-       /* Write something to the syslog (which may or may not be where the
+       /* Write something to the syslog(which may or may not be where the
         * rest of the Citadel logs are going; some sysadmins want LOG_MAIL).
         */
-       if (enable_syslog) {
-               syslog((LOG_MAIL | LOG_INFO),
-                       "%ld: to=<%s>, relay=%s, stat=%s",
-                       msgnum,
-                       addr,
-                       mx_host,
-                       dsn
-               );
-       }
+       syslog((LOG_MAIL | LOG_INFO),
+               "%ld: to=<%s>, relay=%s, stat=%s",
+               msgnum,
+               addr,
+               mx_host,
+               dsn
+       );
 
        return;
 }
@@ -507,7 +505,7 @@ void smtp_do_bounce(char *instr) {
        StrBuf *BounceMB;
        long omsgid = (-1);
 
-       CtdlLogPrintf(CTDL_DEBUG, "smtp_do_bounce() called\n");
+       syslog(LOG_DEBUG, "smtp_do_bounce() called\n");
        strcpy(bounceto, "");
        boundary = NewStrBufPlain(HKEY("=_Citadel_Multipart_"));
        StrBufAppendPrintf(boundary, "%s_%04x%04x", config.c_fqdn, getpid(), ++seq);
@@ -576,7 +574,7 @@ void smtp_do_bounce(char *instr) {
                dsnlen = extract_token(dsn, buf, 3, '|', sizeof dsn);
                bounce_this = 0;
 
-               CtdlLogPrintf(CTDL_DEBUG, "key=<%s> addr=<%s> status=%d dsn=<%s>\n",
+               syslog(LOG_DEBUG, "key=<%s> addr=<%s> status=%d dsn=<%s>\n",
                        key, addr, status, dsn);
 
                if (!strcasecmp(key, "bounceto")) {
@@ -630,13 +628,13 @@ void smtp_do_bounce(char *instr) {
                free(bmsg->cm_fields['A']);
        bmsg->cm_fields['A'] = SmashStrBuf(&BounceMB);
        /* Deliver the bounce if there's anything worth mentioning */
-       CtdlLogPrintf(CTDL_DEBUG, "num_bounces = %d\n", num_bounces);
+       syslog(LOG_DEBUG, "num_bounces = %d\n", num_bounces);
        if (num_bounces > 0) {
 
                /* First try the user who sent the message */
-               CtdlLogPrintf(CTDL_DEBUG, "bounce to user? <%s>\n", bounceto);
+               syslog(LOG_DEBUG, "bounce to user? <%s>\n", bounceto);
                if (IsEmptyStr(bounceto)) {
-                       CtdlLogPrintf(CTDL_ERR, "No bounce address specified\n");
+                       syslog(LOG_ERR, "No bounce address specified\n");
                        bounce_msgid = (-1L);
                }
 
@@ -661,7 +659,7 @@ void smtp_do_bounce(char *instr) {
        }
        FreeStrBuf(&boundary);
        CtdlFreeMessage(bmsg);
-       CtdlLogPrintf(CTDL_DEBUG, "Done processing bounces\n");
+       syslog(LOG_DEBUG, "Done processing bounces\n");
 }
 
 
@@ -731,12 +729,12 @@ void smtp_do_procmsg(long msgnum, void *userdata) {
        time_t last_attempted = 0L;
        time_t retry = SMTP_RETRY_INTERVAL;
 
-       CtdlLogPrintf(CTDL_DEBUG, "SMTP client: smtp_do_procmsg(%ld)\n", msgnum);
+       syslog(LOG_DEBUG, "SMTP client: smtp_do_procmsg(%ld)\n", msgnum);
        strcpy(envelope_from, "");
 
        msg = CtdlFetchMessage(msgnum, 1);
        if (msg == NULL) {
-               CtdlLogPrintf(CTDL_ERR, "SMTP client: tried %ld but no such message!\n", msgnum);
+               syslog(LOG_ERR, "SMTP client: tried %ld but no such message!\n", msgnum);
                return;
        }
 
@@ -784,7 +782,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) {
         * Postpone delivery if we've already tried recently.
         */
        if (((time(NULL) - last_attempted) < retry) && (run_queue_now == 0)) {
-               CtdlLogPrintf(CTDL_DEBUG, "SMTP client: Retry time not yet reached.\n");
+               syslog(LOG_DEBUG, "SMTP client: Retry time not yet reached.\n");
                free(instr);
                return;
        }
@@ -794,7 +792,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) {
         * Bail out if there's no actual message associated with this
         */
        if (text_msgid < 0L) {
-               CtdlLogPrintf(CTDL_ERR, "SMTP client: no 'msgid' directive found!\n");
+               syslog(LOG_ERR, "SMTP client: no 'msgid' directive found!\n");
                free(instr);
                return;
        }
@@ -824,7 +822,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) {
 
                        --i;
                        --lines;
-                       CtdlLogPrintf(CTDL_DEBUG, "SMTP client: Trying <%s>\n", addr);
+                       syslog(LOG_DEBUG, "SMTP client: Trying <%s>\n", addr);
                        smtp_try(key, addr, &status, dsn, sizeof dsn, text_msgid, envelope_from);
                        if (status != 2) {
                                if (results == NULL) {
@@ -945,19 +943,19 @@ void *smtp_queue_thread(void *arg) {
 
        CtdlFillSystemContext(&smtp_queue_CC, "SMTP Send");
        citthread_setspecific(MyConKey, (void *)&smtp_queue_CC);
-       CtdlLogPrintf(CTDL_DEBUG, "smtp_queue_thread() initializing\n");
+       syslog(LOG_DEBUG, "smtp_queue_thread() initializing\n");
 
        while (!CtdlThreadCheckStop()) {
                
-               CtdlLogPrintf(CTDL_INFO, "SMTP client: processing outbound queue\n");
+               syslog(LOG_INFO, "SMTP client: processing outbound queue\n");
 
                if (CtdlGetRoom(&CC->room, SMTP_SPOOLOUT_ROOM) != 0) {
-                       CtdlLogPrintf(CTDL_ERR, "Cannot find room <%s>\n", SMTP_SPOOLOUT_ROOM);
+                       syslog(LOG_ERR, "Cannot find room <%s>\n", SMTP_SPOOLOUT_ROOM);
                }
                else {
                        num_processed = CtdlForEachMessage(MSGS_ALL, 0L, NULL, SPOOLMIME, NULL, smtp_do_procmsg, NULL);
                }
-               CtdlLogPrintf(CTDL_INFO, "SMTP client: queue run completed; %d messages processed\n", num_processed);
+               syslog(LOG_INFO, "SMTP client: queue run completed; %d messages processed\n", num_processed);
                CtdlThreadSleep(60);
        }
 
index c8b5ba166a5227d243650503e706b0244a88d81b..831857b07a28c703effbf0e2f7e39dd06f4e6e72 100644 (file)
@@ -125,7 +125,7 @@ eNextState get_one_mx_host_ip(AsyncIO *IO);
  ******************************************************************************/
 void FinalizeMessageSend(SmtpOutMsg *Msg)
 {
-       CtdlLogPrintf(CTDL_DEBUG, "SMTP: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__);
        
        if (DecreaseQReference(Msg->MyQItem)) 
        {
@@ -213,12 +213,12 @@ void SetConnectStatus(AsyncIO *IO)
        if (SendMsg->mx_host == NULL)
                SendMsg->mx_host = "<no MX-Record>";
 
-       CtdlLogPrintf(CTDL_DEBUG, 
-                     "SMTP client[%ld]: connecting to %s [%s]:%d ...\n", 
-                     SendMsg->n, 
-                     SendMsg->mx_host, 
-                     buf,
-                     SendMsg->IO.ConnectMe->Port);
+       syslog(LOG_DEBUG,
+              "SMTP client[%ld]: connecting to %s [%s]:%d ...\n", 
+              SendMsg->n, 
+              SendMsg->mx_host, 
+              buf,
+              SendMsg->IO.ConnectMe->Port);
 
        SendMsg->MyQEntry->Status = 5; 
        StrBufPrintf(SendMsg->MyQEntry->StatusMessage, 
@@ -236,7 +236,7 @@ eNextState mx_connect_ip(AsyncIO *IO)
 {
        SmtpOutMsg *SendMsg = IO->Data;
 
-       CtdlLogPrintf(CTDL_DEBUG, "SMTP: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__);
        
        IO->ConnectMe = SendMsg->pCurrRelay;
        /*  Bypass the ns lookup result like this: IO->Addr.sin_addr.s_addr = inet_addr("127.0.0.1"); */
@@ -299,14 +299,14 @@ eNextState get_one_mx_host_ip(AsyncIO *IO)
 
        InitC_ares_dns(IO);
 
-       CtdlLogPrintf(CTDL_DEBUG, "SMTP: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__);
 
-       CtdlLogPrintf(CTDL_DEBUG, 
-                     "SMTP client[%ld]: looking up %s-Record %s : %d ...\n", 
-                     SendMsg->n, 
-                     (SendMsg->pCurrRelay->IPv6)? "aaaa": "a",
-                     SendMsg->pCurrRelay->Host, 
-                     SendMsg->pCurrRelay->Port);
+       syslog(LOG_DEBUG, 
+              "SMTP client[%ld]: looking up %s-Record %s : %d ...\n", 
+              SendMsg->n, 
+              (SendMsg->pCurrRelay->IPv6)? "aaaa": "a",
+              SendMsg->pCurrRelay->Host, 
+              SendMsg->pCurrRelay->Port);
 
        if (!QueueQuery((SendMsg->pCurrRelay->IPv6)? ns_t_aaaa : ns_t_a, 
                        SendMsg->pCurrRelay->Host, 
@@ -335,7 +335,7 @@ eNextState smtp_resolve_mx_record_done(AsyncIO *IO)
 
        QueryCbDone(IO);
 
-       CtdlLogPrintf(CTDL_DEBUG, "SMTP: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__);
        pp = &SendMsg->Relay;
        while ((pp != NULL) && (*pp != NULL) && ((*pp)->Next != NULL))
                pp = &(*pp)->Next;
@@ -392,7 +392,7 @@ eNextState resolve_mx_records(AsyncIO *IO)
 {
        SmtpOutMsg * SendMsg = IO->Data;
 
-       CtdlLogPrintf(CTDL_DEBUG, "SMTP: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__);
        /* start resolving MX records here. */
        if (!QueueQuery(ns_t_mx, 
                        SendMsg->node, 
@@ -456,7 +456,7 @@ void smtp_try_one_queue_entry(OneQueItem *MyQItem,
 {
        SmtpOutMsg *SendMsg;
 
-       CtdlLogPrintf(CTDL_DEBUG, "SMTP: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__);
 
        SendMsg = new_smtp_outmsg(MyQItem, MyQEntry, MsgCount);
        if (KeepMsgText) SendMsg->msgtext = MsgText;
@@ -507,7 +507,7 @@ void SMTPSetTimeout(eNextState NextTCPState, SmtpOutMsg *pMsg)
 {
        double Timeout = 0.0;
 
-       CtdlLogPrintf(CTDL_DEBUG, "SMTP: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__);
 
        switch (NextTCPState) {
        case eSendReply:
@@ -539,7 +539,7 @@ void SMTPSetTimeout(eNextState NextTCPState, SmtpOutMsg *pMsg)
 }
 eNextState SMTP_C_DispatchReadDone(AsyncIO *IO)
 {
-       CtdlLogPrintf(CTDL_DEBUG, "SMTP: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__);
        SmtpOutMsg *pMsg = IO->Data;
        eNextState rc;
 
@@ -550,7 +550,7 @@ eNextState SMTP_C_DispatchReadDone(AsyncIO *IO)
 }
 eNextState SMTP_C_DispatchWriteDone(AsyncIO *IO)
 {
-       CtdlLogPrintf(CTDL_DEBUG, "SMTP: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__);
        SmtpOutMsg *pMsg = IO->Data;
        eNextState rc;
 
@@ -567,7 +567,7 @@ eNextState SMTP_C_Terminate(AsyncIO *IO)
 {
        SmtpOutMsg *pMsg = IO->Data;
 
-       CtdlLogPrintf(CTDL_DEBUG, "SMTP: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__);
        FinalizeMessageSend(pMsg);
        return eAbort;
 }
@@ -575,7 +575,7 @@ eNextState SMTP_C_Timeout(AsyncIO *IO)
 {
        SmtpOutMsg *pMsg = IO->Data;
 
-       CtdlLogPrintf(CTDL_DEBUG, "SMTP: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__);
        StrBufPlain(IO->ErrMsg, CKEY(ReadErrors[pMsg->State]));
        return FailOneAttempt(IO);
 }
@@ -583,13 +583,13 @@ eNextState SMTP_C_ConnFail(AsyncIO *IO)
 {
        SmtpOutMsg *pMsg = IO->Data;
 
-       CtdlLogPrintf(CTDL_DEBUG, "SMTP: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__);
        StrBufPlain(IO->ErrMsg, CKEY(ReadErrors[pMsg->State]));
        return FailOneAttempt(IO);
 }
 eNextState SMTP_C_Shutdown(AsyncIO *IO)
 {
-       CtdlLogPrintf(CTDL_DEBUG, "SMTP: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__);
        SmtpOutMsg *pMsg = IO->Data;
 
        pMsg->MyQEntry->Status = 3;
index 369bc7276fea4adb26873d9fa8d7153f91119055..538fe1bca971bf353472886a7b66f45457c03681 100644 (file)
@@ -409,11 +409,11 @@ StrBuf *smtp_load_msg(OneQueItem *MyQItem, int n)
        CCC->redirect_buffer = NULL;
        if ((StrLength(SendMsg) > 0) && 
            ChrPtr(SendMsg)[StrLength(SendMsg) - 1] != '\n') {
-               CtdlLogPrintf(CTDL_WARNING, 
-                             "SMTP client[%d]: Possible problem: message did not "
-                             "correctly terminate. (expecting 0x10, got 0x%02x)\n",
-                             MsgCount, //yes uncool, but best choice here... 
-                             ChrPtr(SendMsg)[StrLength(SendMsg) - 1] );
+               syslog(LOG_WARNING, 
+                      "SMTP client[%d]: Possible problem: message did not "
+                      "correctly terminate. (expecting 0x10, got 0x%02x)\n",
+                      MsgCount, //yes uncool, but best choice here... 
+                      ChrPtr(SendMsg)[StrLength(SendMsg) - 1] );
                StrBufAppendBufPlain(SendMsg, HKEY("\r\n"), 0);
        }
        return SendMsg;
@@ -445,7 +445,7 @@ void smtpq_do_bounce(OneQueItem *MyQItem, StrBuf *OMsgTxt)
        int num_bounces = 0;
        int give_up = 0;
 
-       CtdlLogPrintf(CTDL_DEBUG, "smtp_do_bounce() called\n");
+       syslog(LOG_DEBUG, "smtp_do_bounce() called\n");
 
        if ( (ev_time() - MyQItem->Submitted) > SMTP_GIVE_UP ) {
                give_up = 1;/// TODO: replace time by libevq timer get
@@ -474,7 +474,7 @@ void smtpq_do_bounce(OneQueItem *MyQItem, StrBuf *OMsgTxt)
        DeleteHashPos(&It);
 
        /* Deliver the bounce if there's anything worth mentioning */
-       CtdlLogPrintf(CTDL_DEBUG, "num_bounces = %d\n", num_bounces);
+       syslog(LOG_DEBUG, "num_bounces = %d\n", num_bounces);
 
        if (num_bounces == 0) {
                FreeStrBuf(&Msg);
@@ -491,7 +491,7 @@ void smtpq_do_bounce(OneQueItem *MyQItem, StrBuf *OMsgTxt)
                                  StrLength(OMsgTxt)); /* the original message */
        if (BounceMB == NULL) {
                FreeStrBuf(&boundary);
-               CtdlLogPrintf(CTDL_ERR, "Failed to alloc() bounce message.\n");
+               syslog(LOG_ERR, "Failed to alloc() bounce message.\n");
 
                return;
        }
@@ -500,7 +500,7 @@ void smtpq_do_bounce(OneQueItem *MyQItem, StrBuf *OMsgTxt)
        if (bmsg == NULL) {
                FreeStrBuf(&boundary);
                FreeStrBuf(&BounceMB);
-               CtdlLogPrintf(CTDL_ERR, "Failed to alloc() bounce message.\n");
+               syslog(LOG_ERR, "Failed to alloc() bounce message.\n");
 
                return;
        }
@@ -566,9 +566,9 @@ void smtpq_do_bounce(OneQueItem *MyQItem, StrBuf *OMsgTxt)
 
        /* First try the user who sent the message */
        if (StrLength(MyQItem->BounceTo) == 0) 
-               CtdlLogPrintf(CTDL_ERR, "No bounce address specified\n");
+               syslog(LOG_ERR, "No bounce address specified\n");
        else
-               CtdlLogPrintf(CTDL_DEBUG, "bounce to user? <%s>\n", ChrPtr(MyQItem->BounceTo));
+               syslog(LOG_DEBUG, "bounce to user? <%s>\n", ChrPtr(MyQItem->BounceTo));
 
        /* Can we deliver the bounce to the original sender? */
        valid = validate_recipients(ChrPtr(MyQItem->BounceTo), NULL, 0);
@@ -586,7 +586,7 @@ void smtpq_do_bounce(OneQueItem *MyQItem, StrBuf *OMsgTxt)
        free_recipients(valid);
        FreeStrBuf(&boundary);
        CtdlFreeMessage(bmsg);
-       CtdlLogPrintf(CTDL_DEBUG, "Done processing bounces\n");
+       syslog(LOG_DEBUG, "Done processing bounces\n");
 }
 
 
@@ -618,12 +618,12 @@ void smtp_do_procmsg(long msgnum, void *userdata) {
        int HaveBuffers = 0;
        StrBuf *Msg =NULL;
        
-       CtdlLogPrintf(CTDL_DEBUG, "SMTP Queue: smtp_do_procmsg(%ld)\n", msgnum);
+       syslog(LOG_DEBUG, "SMTP Queue: smtp_do_procmsg(%ld)\n", msgnum);
        ///strcpy(envelope_from, "");
 
        msg = CtdlFetchMessage(msgnum, 1);
        if (msg == NULL) {
-               CtdlLogPrintf(CTDL_ERR, "SMTP Queue: tried %ld but no such message!\n", msgnum);
+               syslog(LOG_ERR, "SMTP Queue: tried %ld but no such message!\n", msgnum);
                return;
        }
 
@@ -643,7 +643,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) {
        FreeStrBuf(&PlainQItem);
 
        if (MyQItem == NULL) {
-               CtdlLogPrintf(CTDL_ERR, "SMTP Queue: Msg No %ld: already in progress!\n", msgnum);              
+               syslog(LOG_ERR, "SMTP Queue: Msg No %ld: already in progress!\n", msgnum);              
                return; /* s.b. else is already processing... */
        }
 
@@ -651,7 +651,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) {
         * Postpone delivery if we've already tried recently.
         * /
        if (((time(NULL) - MyQItem->LastAttempt.when) < MyQItem->LastAttempt.retry) && (run_queue_now == 0)) {
-               CtdlLogPrintf(CTDL_DEBUG, "SMTP client: Retry time not yet reached.\n");
+               syslog(LOG_DEBUG, "SMTP client: Retry time not yet reached.\n");
 
                It = GetNewHashPos(MyQItem->MailQEntries, 0);
                citthread_mutex_lock(&ActiveQItemsLock);
@@ -669,7 +669,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) {
         * Bail out if there's no actual message associated with this
         */
        if (MyQItem->MessageID < 0L) {
-               CtdlLogPrintf(CTDL_ERR, "SMTP Queue: no 'msgid' directive found!\n");
+               syslog(LOG_ERR, "SMTP Queue: no 'msgid' directive found!\n");
                It = GetNewHashPos(MyQItem->MailQEntries, 0);
                citthread_mutex_lock(&ActiveQItemsLock);
                {
@@ -696,7 +696,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) {
                        while ((Pos != StrBufNOTNULL) && ((Pos == NULL) || !IsEmptyStr(Pos))) {
                                StrBufExtract_NextToken(One, All, &Pos, '|');
                                if (!ParseURL(Url, One, 25))
-                                       CtdlLogPrintf(CTDL_DEBUG, "Failed to parse: %s\n", ChrPtr(One));
+                                       syslog(LOG_DEBUG, "Failed to parse: %s\n", ChrPtr(One));
                                else {
                                        ///if (!Url->IsIP)) /// todo dupe me fork ipv6
                                        Url = &(*Url)->Next;
@@ -719,7 +719,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) {
                        while ((Pos != StrBufNOTNULL) && ((Pos == NULL) || !IsEmptyStr(Pos))) {
                                StrBufExtract_NextToken(One, All, &Pos, '|');
                                if (!ParseURL(Url, One, 25))
-                                       CtdlLogPrintf(CTDL_DEBUG, "Failed to parse: %s\n", ChrPtr(One));
+                                       syslog(LOG_DEBUG, "Failed to parse: %s\n", ChrPtr(One));
                                else 
                                        Url = &(*Url)->Next;
                        }
@@ -732,7 +732,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) {
        while (GetNextHashPos(MyQItem->MailQEntries, It, &len, &Key, &vQE))
        {
                MailQEntry *ThisItem = vQE;
-               CtdlLogPrintf(CTDL_DEBUG, "SMTP Queue: Task: <%s> %d\n", ChrPtr(ThisItem->Recipient), ThisItem->Active);
+               syslog(LOG_DEBUG, "SMTP Queue: Task: <%s> %d\n", ChrPtr(ThisItem->Recipient), ThisItem->Active);
        }
        DeleteHashPos(&It);
 
@@ -751,11 +751,11 @@ void smtp_do_procmsg(long msgnum, void *userdata) {
                        if (ThisItem->Active == 1) {
                                int KeepBuffers = (i == m);
                                if (i > 1) n = MsgCount++;
-                               CtdlLogPrintf(CTDL_DEBUG, 
-                                             "SMTP Queue: Trying <%s> %d / %d \n", 
-                                             ChrPtr(ThisItem->Recipient), 
-                                             i, 
-                                             m);
+                               syslog(LOG_DEBUG, 
+                                      "SMTP Queue: Trying <%s> %d / %d \n", 
+                                      ChrPtr(ThisItem->Recipient), 
+                                      i, 
+                                      m);
                                smtp_try_one_queue_entry(MyQItem, 
                                                         ThisItem, 
                                                         Msg, 
@@ -804,19 +804,19 @@ void *smtp_queue_thread(void *arg) {
 
        CtdlFillSystemContext(&smtp_queue_CC, "SMTP_Send");
        citthread_setspecific(MyConKey, (void *)&smtp_queue_CC);
-       CtdlLogPrintf(CTDL_DEBUG, "smtp_queue_thread() initializing\n");
+       syslog(LOG_DEBUG, "smtp_queue_thread() initializing\n");
 
        while (!CtdlThreadCheckStop()) {
                
-               CtdlLogPrintf(CTDL_INFO, "SMTP client: processing outbound queue\n");
+               syslog(LOG_INFO, "SMTP client: processing outbound queue\n");
 
                if (CtdlGetRoom(&CC->room, SMTP_SPOOLOUT_ROOM) != 0) {
-                       CtdlLogPrintf(CTDL_ERR, "Cannot find room <%s>\n", SMTP_SPOOLOUT_ROOM);
+                       syslog(LOG_ERR, "Cannot find room <%s>\n", SMTP_SPOOLOUT_ROOM);
                }
                else {
                        num_processed = CtdlForEachMessage(MSGS_ALL, 0L, NULL, SPOOLMIME, NULL, smtp_do_procmsg, NULL);
                }
-               CtdlLogPrintf(CTDL_INFO, "SMTP client: queue run completed; %d messages processed\n", num_processed);
+               syslog(LOG_INFO, "SMTP client: queue run completed; %d messages processed\n", num_processed);
                CtdlThreadSleep(60);
        }
 
index 828ecd3ea89e69dac31dbaf90b2b3e6c78fee9a3..5c27435299f718f87bddac28e97a20de47a33e96 100644 (file)
 
 #define SMTP_IS_STATE(WHICH_STATE) (ChrPtr(SendMsg->IO.IOBuf)[0] == WHICH_STATE)
 
-#define SMTP_DBG_SEND() CtdlLogPrintf(CTDL_DEBUG, "SMTP client[%ld]: > %s\n", SendMsg->n, ChrPtr(SendMsg->IO.SendBuf.Buf))
-#define SMTP_DBG_READ() CtdlLogPrintf(CTDL_DEBUG, "SMTP client[%ld]: < %s\n", SendMsg->n, ChrPtr(SendMsg->IO.IOBuf))
+#define SMTP_DBG_SEND() syslog(LOG_DEBUG, "SMTP client[%ld]: > %s\n", SendMsg->n, ChrPtr(SendMsg->IO.SendBuf.Buf))
+#define SMTP_DBG_READ() syslog(LOG_DEBUG, "SMTP client[%ld]: < %s\n", SendMsg->n, ChrPtr(SendMsg->IO.IOBuf))
 
 
 /*****************************************************************************/
@@ -352,7 +352,7 @@ eNextState SMTPC_read_QUIT_reply(SmtpOutMsg *SendMsg)
 {
        SMTP_DBG_READ();
 
-       CtdlLogPrintf(CTDL_INFO, "SMTP client[%ld]: delivery to <%s> @ <%s> (%s) succeeded\n",
+       syslog(LOG_INFO, "SMTP client[%ld]: delivery to <%s> @ <%s> (%s) succeeded\n",
                      SendMsg->n, SendMsg->user, SendMsg->node, SendMsg->name);
        return eTerminateConnection;
 }
@@ -446,7 +446,7 @@ int smtp_resolve_recipients(SmtpOutMsg *SendMsg)
        int lp, rp;
        int i;
 
-       CtdlLogPrintf(CTDL_DEBUG, "SMTP: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "SMTP: %s\n", __FUNCTION__);
 
        if ((SendMsg==NULL) || 
            (SendMsg->MyQEntry == NULL) || 
@@ -460,8 +460,8 @@ int smtp_resolve_recipients(SmtpOutMsg *SendMsg)
                            SendMsg->node, 
                            SendMsg->name);
 
-       CtdlLogPrintf(CTDL_DEBUG, "SMTP client[%ld]: Attempting delivery to <%s> @ <%s> (%s)\n",
-                     SendMsg->n, SendMsg->user, SendMsg->node, SendMsg->name);
+       syslog(LOG_DEBUG, "SMTP client[%ld]: Attempting delivery to <%s> @ <%s> (%s)\n",
+              SendMsg->n, SendMsg->user, SendMsg->node, SendMsg->name);
        /* If no envelope_from is supplied, extract one from the message */
        SendMsg->envelope_from = ChrPtr(SendMsg->MyQItem->EnvelopeFrom);
        if ( (SendMsg->envelope_from == NULL) || 
index 304269afe2beda157ea8c4033770448ffc7d1e3d..9e215c07455176cc298a52d337239f9c5d6c4262 100644 (file)
@@ -126,7 +126,7 @@ void smtp_do_bounce(char *instr, StrBuf *OMsgTxt)
        StrBuf *BounceMB;
        long omsgid = (-1);
 
-       CtdlLogPrintf(CTDL_DEBUG, "smtp_do_bounce() called\n");
+       syslog(LOG_DEBUG, "smtp_do_bounce() called\n");
        strcpy(bounceto, "");
        boundary = NewStrBufPlain(HKEY("=_Citadel_Multipart_"));
        StrBufAppendPrintf(boundary, "%s_%04x%04x", config.c_fqdn, getpid(), ++seq);
@@ -195,8 +195,8 @@ void smtp_do_bounce(char *instr, StrBuf *OMsgTxt)
                dsnlen = extract_token(dsn, buf, 3, '|', sizeof dsn);
                bounce_this = 0;
 
-               CtdlLogPrintf(CTDL_DEBUG, "key=<%s> addr=<%s> status=%d dsn=<%s>\n",
-                       key, addr, status, dsn);
+               syslog(LOG_DEBUG, "key=<%s> addr=<%s> status=%d dsn=<%s>\n",
+                      key, addr, status, dsn);
 
                if (!strcasecmp(key, "bounceto")) {
                        strcpy(bounceto, addr);
@@ -254,13 +254,13 @@ void smtp_do_bounce(char *instr, StrBuf *OMsgTxt)
                free(bmsg->cm_fields['A']);
        bmsg->cm_fields['A'] = SmashStrBuf(&BounceMB);
        /* Deliver the bounce if there's anything worth mentioning */
-       CtdlLogPrintf(CTDL_DEBUG, "num_bounces = %d\n", num_bounces);
+       syslog(LOG_DEBUG, "num_bounces = %d\n", num_bounces);
        if (num_bounces > 0) {
 
                /* First try the user who sent the message */
-               CtdlLogPrintf(CTDL_DEBUG, "bounce to user? <%s>\n", bounceto);
+               syslog(LOG_DEBUG, "bounce to user? <%s>\n", bounceto);
                if (IsEmptyStr(bounceto)) {
-                       CtdlLogPrintf(CTDL_ERR, "No bounce address specified\n");
+                       syslog(LOG_ERR, "No bounce address specified\n");
                        bounce_msgid = (-1L);
                }
 
@@ -285,5 +285,5 @@ void smtp_do_bounce(char *instr, StrBuf *OMsgTxt)
        }
        FreeStrBuf(&boundary);
        CtdlFreeMessage(bmsg);
-       CtdlLogPrintf(CTDL_DEBUG, "Done processing bounces\n");
+       syslog(LOG_DEBUG, "Done processing bounces\n");
 }
index ad81f1217b3b650625ce8199d069a07c116c0591..df65ba6ef2a3e89449b5f24880c3d92a64a60030 100644 (file)
@@ -92,9 +92,9 @@ int spam_assassin(struct CtdlMessage *msg) {
        /* Try them one by one until we get a working one */
         for (sa=0; sa<num_sahosts; ++sa) {
                 extract_token(buf, sahosts, sa, '|', sizeof buf);
-                CtdlLogPrintf(CTDL_INFO, "Connecting to SpamAssassin at <%s>\n", buf);
+                syslog(LOG_INFO, "Connecting to SpamAssassin at <%s>\n", buf);
                 sock = sock_connect(buf, SPAMASSASSIN_PORT);
-                if (sock >= 0) CtdlLogPrintf(CTDL_DEBUG, "Connected!\n");
+                if (sock >= 0) syslog(LOG_DEBUG, "Connected!\n");
         }
 
        if (sock < 0) {
@@ -109,7 +109,7 @@ int spam_assassin(struct CtdlMessage *msg) {
        CCC->SBuf.ReadWritePointer = NULL;
 
        /* Command */
-       CtdlLogPrintf(CTDL_DEBUG, "Transmitting command\n");
+       syslog(LOG_DEBUG, "Transmitting command\n");
        sprintf(buf, "CHECK SPAMC/1.2\r\n\r\n");
        sock_write(&sock, buf, strlen(buf));
 
@@ -129,21 +129,21 @@ int spam_assassin(struct CtdlMessage *msg) {
                sock_shutdown(sock, SHUT_WR);
        
        /* Response */
-       CtdlLogPrintf(CTDL_DEBUG, "Awaiting response\n");
+       syslog(LOG_DEBUG, "Awaiting response\n");
         if (sock_getln(&sock, buf, sizeof buf) < 0) {
                 goto bail;
         }
-        CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
+        syslog(LOG_DEBUG, "<%s\n", buf);
        if (strncasecmp(buf, "SPAMD", 5)) {
                goto bail;
        }
         if (sock_getln(&sock, buf, sizeof buf) < 0) {
                 goto bail;
         }
-        CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
-        CtdlLogPrintf(CTDL_DEBUG, "c_spam_flag_only setting %d\n", config.c_spam_flag_only);
+        syslog(LOG_DEBUG, "<%s\n", buf);
+        syslog(LOG_DEBUG, "c_spam_flag_only setting %d\n", config.c_spam_flag_only);
         if (config.c_spam_flag_only) {
-                CtdlLogPrintf(CTDL_DEBUG, "flag spam code used");
+                syslog(LOG_DEBUG, "flag spam code used");
                int headerlen;
                int newmsgsize;
                int oldmsgsize;
@@ -174,7 +174,7 @@ int spam_assassin(struct CtdlMessage *msg) {
                memcpy(msg->cm_fields['M'],buf,headerlen);
 
        } else {
-                CtdlLogPrintf(CTDL_DEBUG, "reject spam code used");
+                syslog(LOG_DEBUG, "reject spam code used");
                if (!strncasecmp(buf, "Spam: True", 10)) {
                        is_spam = 1;
                }
index 7538b401a321fc116401440b57c2ca9663c91062..797958f199b256b4321a957c704c6dda37629fad 100644 (file)
 
 
 void CleanupTest(void) {
-       CtdlLogPrintf(CTDL_DEBUG, "--- test of adding an unload hook --- \n");
+       syslog(LOG_DEBUG, "--- test of adding an unload hook --- \n");
        }
 
 void NewRoomTest(void) {
-       CtdlLogPrintf(CTDL_DEBUG, "--- test module was told we're now in a new room ---\n");
+       syslog(LOG_DEBUG, "--- test module was told we're now in a new room ---\n");
        }
 
 void SessionStartTest(void) {
-       CtdlLogPrintf(CTDL_DEBUG, "--- starting up session %d ---\n",
+       syslog(LOG_DEBUG, "--- starting up session %d ---\n",
                CC->cs_pid);
        }
 
 void SessionStopTest(void) {
-       CtdlLogPrintf(CTDL_DEBUG, "--- ending session %d ---\n", 
+       syslog(LOG_DEBUG, "--- ending session %d ---\n", 
                CC->cs_pid);
        }
 
 void LoginTest(void) {
-       CtdlLogPrintf(CTDL_DEBUG, "--- Hello, %s ---\n", CC->curr_user);
+       syslog(LOG_DEBUG, "--- Hello, %s ---\n", CC->curr_user);
        }
 
 /* To insert this module into the server activate the next block by changing the #if 0 to #if 1 */
index 317023ae7a5558ce412d1a52a196f30e516f1505..8b6b315a5d63199bf4f74eb602d21c6dc4fbdef4 100644 (file)
@@ -131,14 +131,14 @@ void cmd_bmbx_backend(struct ctdlroom *qrbuf, void *data) {
        while (rplist != NULL) {
 
                if (CtdlGetRoomLock(&qr, rplist->name) == 0) {
-                       CtdlLogPrintf(CTDL_DEBUG, "Processing <%s>...\n", rplist->name);
+                       syslog(LOG_DEBUG, "Processing <%s>...\n", rplist->name);
                        if ( (qr.QRflags & QR_MAILBOX) == 0) {
-                               CtdlLogPrintf(CTDL_DEBUG, "  -- not a mailbox\n");
+                               syslog(LOG_DEBUG, "  -- not a mailbox\n");
                        }
                        else {
 
                                qr.QRgen = time(NULL);
-                               CtdlLogPrintf(CTDL_DEBUG, "  -- fixed!\n");
+                               syslog(LOG_DEBUG, "  -- fixed!\n");
                        }
                        CtdlPutRoomLock(&qr);
                }
@@ -153,7 +153,7 @@ void cmd_bmbx_backend(struct ctdlroom *qrbuf, void *data) {
  * quick fix to bump mailbox generation numbers
  */
 void bump_mailbox_generation_numbers(void) {
-       CtdlLogPrintf(CTDL_WARNING, "Applying security fix to mailbox rooms\n");
+       syslog(LOG_WARNING, "Applying security fix to mailbox rooms\n");
        CtdlForEachRoom(cmd_bmbx_backend, NULL);
        cmd_bmbx_backend(NULL, NULL);
        return;
@@ -186,7 +186,7 @@ void cbtm_backend(struct ctdluser *usbuf, void *data) {
        while (uplist != NULL) {
 
                if (CtdlGetUserLock(&us, uplist->user) == 0) {
-                       CtdlLogPrintf(CTDL_DEBUG, "Processing <%s>...\n", uplist->user);
+                       syslog(LOG_DEBUG, "Processing <%s>...\n", uplist->user);
                        if (us.uid == CTDLUID) {
                                us.uid = (-1);
                        }
@@ -203,7 +203,7 @@ void cbtm_backend(struct ctdluser *usbuf, void *data) {
  * quick fix to change all CTDLUID users to (-1)
  */
 void convert_ctdluid_to_minusone(void) {
-       CtdlLogPrintf(CTDL_WARNING, "Applying uid changes\n");
+       syslog(LOG_WARNING, "Applying uid changes\n");
        ForEachUser(cbtm_backend, NULL);
        cbtm_backend(NULL, NULL);
        return;
@@ -223,7 +223,7 @@ void guess_time_zone(void) {
                if (fgets(buf, sizeof buf, fp) && (strlen(buf) > 2)) {
                        buf[strlen(buf)-1] = 0;
                        safestrncpy(config.c_default_cal_zone, buf, sizeof config.c_default_cal_zone);
-                       CtdlLogPrintf(CTDL_INFO, "Configuring timezone: %s\n", config.c_default_cal_zone);
+                       syslog(LOG_INFO, "Configuring timezone: %s\n", config.c_default_cal_zone);
                }
                fclose(fp);
        }
@@ -278,12 +278,12 @@ void update_config(void) {
 void check_server_upgrades(void) {
 
        get_control();
-       CtdlLogPrintf(CTDL_INFO, "Server-hosted upgrade level is %d.%02d\n",
+       syslog(LOG_INFO, "Server-hosted upgrade level is %d.%02d\n",
                (CitControl.version / 100),
                (CitControl.version % 100) );
 
        if (CitControl.version < REV_LEVEL) {
-               CtdlLogPrintf(CTDL_WARNING,
+               syslog(LOG_WARNING,
                        "Server hosted updates need to be processed at "
                        "this time.  Please wait...\n");
        }
@@ -294,7 +294,7 @@ void check_server_upgrades(void) {
        update_config();
 
        if ((CitControl.version > 000) && (CitControl.version < 555)) {
-               CtdlLogPrintf(CTDL_EMERG,
+               syslog(LOG_EMERG,
                        "Your data files are from a version of Citadel\n"
                        "that is too old to be upgraded.  Sorry.\n");
                exit(EXIT_FAILURE);
index 7dc2096682f590b4577ead56bcbf1891e5f00b2f..0bc442f57e1fe77bddc54d6dd8f849e904e85948 100644 (file)
@@ -123,7 +123,7 @@ int LookupUrl(StrBuf *ShorterUrlStr)
                          LookupUrlResult, 
                          TerminateLookupUrl))
        {
-               CtdlLogPrintf(CTDL_ALERT, "Unable to initialize libcurl.\n");
+               syslog(LOG_ALERT, "Unable to initialize libcurl.\n");
                goto shutdown;
        }
        chnd = IO->HttpReq.chnd;
@@ -325,7 +325,7 @@ CTDL_MODULE_INIT(urldeshortener)
 {
        if (threading)
        {
-               CtdlLogPrintf(CTDL_INFO, "%s\n", curl_version());
+               syslog(LOG_INFO, "%s\n", curl_version());
        }
        else 
        {
index 2a2ffb4b3b3b329b3ea18bf21df9113998242ae8..0aba02889749b845e7f3ac68d36368774ee194e9 100644 (file)
@@ -146,18 +146,18 @@ void vcard_directory_add_user(char *internet_addr, char *citadel_addr) {
         * probably just the networker or something.
         */
        if (CC->logged_in) {
-               CtdlLogPrintf(CTDL_DEBUG, "Checking for <%s>...\n", internet_addr);
+               syslog(LOG_DEBUG, "Checking for <%s>...\n", internet_addr);
                if (CtdlDirectoryLookup(buf, internet_addr, sizeof buf) == 0) {
                        if (strcasecmp(buf, citadel_addr)) {
                                /* This address belongs to someone else.
                                 * Bail out silently without saving.
                                 */
-                               CtdlLogPrintf(CTDL_DEBUG, "DOOP!\n");
+                               syslog(LOG_DEBUG, "DOOP!\n");
                                return;
                        }
                }
        }
-       CtdlLogPrintf(CTDL_INFO, "Adding %s (%s) to directory\n", citadel_addr, internet_addr);
+       syslog(LOG_INFO, "Adding %s (%s) to directory\n", citadel_addr, internet_addr);
        CtdlDirectoryAddUser(internet_addr, citadel_addr);
 }
 
@@ -284,7 +284,7 @@ void vcard_extract_vcard(char *name, char *filename, char *partnum, char *disp,
        if (  (!strcasecmp(cbtype, "text/x-vcard"))
           || (!strcasecmp(cbtype, "text/vcard")) ) {
 
-               CtdlLogPrintf(CTDL_DEBUG, "Part %s contains a vCard!  Loading...\n", partnum);
+               syslog(LOG_DEBUG, "Part %s contains a vCard!  Loading...\n", partnum);
                if (*v != NULL) {
                        vcard_free(*v);
                }
@@ -362,7 +362,7 @@ int vcard_upload_beforesave(struct CtdlMessage *msg) {
        }
 
        s = vcard_get_prop(v, "fn", 1, 0, 0);
-       if (s) CtdlLogPrintf(CTDL_DEBUG, "vCard beforesave hook running for <%s>\n", s);
+       if (s) syslog(LOG_DEBUG, "vCard beforesave hook running for <%s>\n", s);
 
        if (yes_my_citadel_config) {
                /* Bingo!  The user is uploading a new vCard, so
@@ -810,7 +810,7 @@ void vcard_newuser(struct ctdluser *usbuf) {
        struct vCard *v;
 
        vcard_fn_to_n(vname, usbuf->fullname, sizeof vname);
-       CtdlLogPrintf(CTDL_DEBUG, "Converted <%s> to <%s>\n", usbuf->fullname, vname);
+       syslog(LOG_DEBUG, "Converted <%s> to <%s>\n", usbuf->fullname, vname);
 
        /* Create and save the vCard */
        v = vcard_new();
@@ -829,7 +829,7 @@ void vcard_newuser(struct ctdluser *usbuf) {
                if (getpwuid_r(usbuf->uid, &pwd, pwd_buffer, sizeof pwd_buffer) != NULL) {
 #else // SOLARIS_GETPWUID
                struct passwd *result = NULL;
-               CtdlLogPrintf(CTDL_DEBUG, "Searching for uid %d\n", usbuf->uid);
+               syslog(LOG_DEBUG, "Searching for uid %d\n", usbuf->uid);
                if (getpwuid_r(usbuf->uid, &pwd, pwd_buffer, sizeof pwd_buffer, &result) == 0) {
 #endif // HAVE_GETPWUID_R
                        snprintf(buf, sizeof buf, "%s@%s", pwd.pw_name, config.c_fqdn);
@@ -1116,13 +1116,13 @@ void check_get(void) {
        time(&CC->lastcmd);
        memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
        if (client_getln(cmdbuf, sizeof cmdbuf) < 1) {
-               CtdlLogPrintf(CTDL_CRIT, "Client disconnected: ending session.\n");
+               syslog(LOG_CRIT, "Client disconnected: ending session.\n");
                CC->kill_me = 1;
                return;
        }
-       CtdlLogPrintf(CTDL_INFO, ": %s\n", cmdbuf);
+       syslog(LOG_INFO, ": %s\n", cmdbuf);
        while (strlen(cmdbuf) < 3) strcat(cmdbuf, " ");
-       CtdlLogPrintf(CTDL_INFO, "[ %s]\n", cmdbuf);
+       syslog(LOG_INFO, "[ %s]\n", cmdbuf);
        
        if (strncasecmp(cmdbuf, "GET ", 4)==0)
        {
@@ -1139,13 +1139,13 @@ void check_get(void) {
                {
 
                        cprintf("200 OK %s\n", internet_addr);
-                       CtdlLogPrintf(CTDL_INFO, "sending 200 OK for the room %s\n", rcpt->display_recp);
+                       syslog(LOG_INFO, "sending 200 OK for the room %s\n", rcpt->display_recp);
                }
                else 
                {
                        cprintf("500 REJECT noone here by that name.\n");
                        
-                       CtdlLogPrintf(CTDL_INFO, "sending 500 REJECT noone here by that name: %s\n", internet_addr);
+                       syslog(LOG_INFO, "sending 500 REJECT noone here by that name: %s\n", internet_addr);
                }
                if (rcpt != NULL) 
                        free_recipients(rcpt);
@@ -1154,7 +1154,7 @@ void check_get(void) {
        {
                cprintf("500 REJECT invalid Query.\n");
                
-               CtdlLogPrintf(CTDL_INFO, "sending 500 REJECT invalid Query: %s\n", internet_addr);
+               syslog(LOG_INFO, "sending 500 REJECT invalid Query: %s\n", internet_addr);
        }
 }
 
@@ -1176,7 +1176,7 @@ void vcard_CtdlCreateRoom(void)
 
        /* Set expiration policy to manual; otherwise objects will be lost! */
        if (CtdlGetRoomLock(&qr, USERCONTACTSROOM)) {
-               CtdlLogPrintf(CTDL_ERR, "Couldn't get the user CONTACTS room!\n");
+               syslog(LOG_ERR, "Couldn't get the user CONTACTS room!\n");
                return;
        }
        qr.QRep.expire_mode = EXPIRE_MANUAL;
@@ -1351,7 +1351,7 @@ void store_this_ha(struct addresses_to_be_filed *aptr) {
                        }
                        vcard_free(v);
 
-                       CtdlLogPrintf(CTDL_DEBUG, "Adding contact: %s\n", recipient);
+                       syslog(LOG_DEBUG, "Adding contact: %s\n", recipient);
                        vmsgnum = CtdlSubmitMsg(vmsg, NULL, aptr->roomname, QP_EADDR);
                        CtdlFreeMessage(vmsg);
                }
index 81825c689c0d84d0207163d88d9229f6b4e5a7b1..0399124b396e44949fccfdc29af3070d37fbbf89 100644 (file)
@@ -116,7 +116,7 @@ int wiki_upload_beforesave(struct CtdlMessage *msg) {
        if (    (strlen(msg->cm_fields['E']) >= 9)
                && (!strcasecmp(&msg->cm_fields['E'][strlen(msg->cm_fields['E'])-9], "_HISTORY_"))
        ) {
-               CtdlLogPrintf(CTDL_DEBUG, "History page not being historied\n");
+               syslog(LOG_DEBUG, "History page not being historied\n");
                return(0);
        }
 
@@ -182,10 +182,10 @@ int wiki_upload_beforesave(struct CtdlMessage *msg) {
                } while (nbytes == 1024);
                diffbuf[diffbuf_len] = 0;
                if (pclose(fp) != 0) {
-                       CtdlLogPrintf(CTDL_ERR, "pclose() returned an error - diff failed\n");
+                       syslog(LOG_ERR, "pclose() returned an error - diff failed\n");
                }
        }
-       CtdlLogPrintf(CTDL_DEBUG, "diff length is %d bytes\n", diffbuf_len);
+       syslog(LOG_DEBUG, "diff length is %d bytes\n", diffbuf_len);
 
        unlink(diff_old_filename);
        unlink(diff_new_filename);
@@ -315,7 +315,7 @@ int wiki_upload_beforesave(struct CtdlMessage *msg) {
                CtdlSubmitMsg(history_msg, NULL, "", 0);
        }
        else {
-               CtdlLogPrintf(CTDL_ALERT, "Empty boundary string in history message.  No history!\n");
+               syslog(LOG_ALERT, "Empty boundary string in history message.  No history!\n");
        }
 
        free(diffbuf);
@@ -419,7 +419,7 @@ void wiki_rev_callback(char *name, char *filename, char *partnum, char *disp,
 
        CtdlDecodeBase64(memo, filename, strlen(filename));
        extract_token(this_rev, memo, 0, '|', sizeof this_rev);
-       CtdlLogPrintf(CTDL_DEBUG, "callback found rev: %s\n", this_rev);
+       syslog(LOG_DEBUG, "callback found rev: %s\n", this_rev);
 
        /* Perform the patch */
        fp = popen("patch -f -s -p0 -r /dev/null >/dev/null 2>/dev/null", "w");
@@ -443,13 +443,13 @@ void wiki_rev_callback(char *name, char *filename, char *partnum, char *disp,
                        }
                } while ((*ptr != 0) && (ptr < ((char*)content + length)));
                if (pclose(fp) != 0) {
-                       CtdlLogPrintf(CTDL_ERR, "pclose() returned an error - patch failed\n");
+                       syslog(LOG_ERR, "pclose() returned an error - patch failed\n");
                }
        }
 
        if (!strcasecmp(this_rev, hecbd->stop_when)) {
                /* Found our target rev.  Tell any subsequent callbacks to suppress processing. */
-               CtdlLogPrintf(CTDL_DEBUG, "Target revision has been reached -- stop patching.\n");
+               syslog(LOG_DEBUG, "Target revision has been reached -- stop patching.\n");
                hecbd->done = 1;
        }
 }
@@ -522,7 +522,7 @@ void wiki_rev(char *pagename, char *rev, char *operation)
                fclose(fp);
        }
        else {
-               CtdlLogPrintf(CTDL_ALERT, "Cannot open %s: %s\n", temp, strerror(errno));
+               syslog(LOG_ALERT, "Cannot open %s: %s\n", temp, strerror(errno));
        }
        CtdlFreeMessage(msg);
 
@@ -580,7 +580,7 @@ void wiki_rev(char *pagename, char *rev, char *operation)
                        fseek(fp, 0L, SEEK_SET);
                        msg->cm_fields['M'] = malloc(len + 1);
                        rv = fread(msg->cm_fields['M'], len, 1, fp);
-                       CtdlLogPrintf(CTDL_DEBUG, "did %d blocks of %ld bytes\n", rv, len);
+                       syslog(LOG_DEBUG, "did %d blocks of %ld bytes\n", rv, len);
                        msg->cm_fields['M'][len] = 0;
                        fclose(fp);
                }
index 922288f695bed26f71e7f404d2c15d9da2042098..a3084c6b1e1debeeaf87b55b327f6a03944e5e9d 100644 (file)
@@ -179,9 +179,9 @@ void xmpp_xml_start(void *data, const char *supplied_el, const char **attr) {
        }
 
        /*
-       CtdlLogPrintf(CTDL_DEBUG, "XMPP ELEMENT START: <%s>\n", el);
+       syslog(LOG_DEBUG, "XMPP ELEMENT START: <%s>\n", el);
        for (i=0; attr[i] != NULL; i+=2) {
-               CtdlLogPrintf(CTDL_DEBUG, "                    Attribute '%s' = '%s'\n", attr[i], attr[i+1]);
+               syslog(LOG_DEBUG, "                    Attribute '%s' = '%s'\n", attr[i], attr[i+1]);
        }
        uncomment for more verbosity */
 
@@ -251,9 +251,9 @@ void xmpp_xml_end(void *data, const char *supplied_el) {
        }
 
        /*
-       CtdlLogPrintf(CTDL_DEBUG, "XMPP ELEMENT END  : <%s>\n", el);
+       syslog(LOG_DEBUG, "XMPP ELEMENT END  : <%s>\n", el);
        if (XMPP->chardata_len > 0) {
-               CtdlLogPrintf(CTDL_DEBUG, "          chardata: %s\n", XMPP->chardata);
+               syslog(LOG_DEBUG, "          chardata: %s\n", XMPP->chardata);
        }
        uncomment for more verbosity */
 
@@ -314,7 +314,7 @@ void xmpp_xml_end(void *data, const char *supplied_el) {
                         * Unknown query ... return the XML equivalent of a blank stare
                         */
                        else {
-                               CtdlLogPrintf(CTDL_DEBUG,
+                               syslog(LOG_DEBUG,
                                        "Unknown query <%s> - returning <service-unavailable/>\n",
                                        el
                                );
@@ -449,14 +449,14 @@ void xmpp_xml_end(void *data, const char *supplied_el) {
        }
 
        else if (!strcasecmp(el, "stream")) {
-               CtdlLogPrintf(CTDL_DEBUG, "XMPP client shut down their stream\n");
+               syslog(LOG_DEBUG, "XMPP client shut down their stream\n");
                xmpp_massacre_roster();
                cprintf("</stream>\n");
                CC->kill_me = 1;
        }
 
        else {
-               CtdlLogPrintf(CTDL_DEBUG, "Ignoring unknown tag <%s>\n", el);
+               syslog(LOG_DEBUG, "Ignoring unknown tag <%s>\n", el);
        }
 
        XMPP->chardata_len = 0;
@@ -521,7 +521,7 @@ void xmpp_greeting(void) {
 
        XMPP->xp = XML_ParserCreateNS("UTF-8", ':');
        if (XMPP->xp == NULL) {
-               CtdlLogPrintf(CTDL_ALERT, "Cannot create XML parser!\n");
+               syslog(LOG_ALERT, "Cannot create XML parser!\n");
                CC->kill_me = 1;
                return;
        }
@@ -547,7 +547,7 @@ void xmpp_command_loop(void) {
                XML_Parse(XMPP->xp, ChrPtr(stream_input), rc, 0);
        }
        else {
-               CtdlLogPrintf(CTDL_ERR, "Client disconnected: ending session.\n");
+               syslog(LOG_ERR, "Client disconnected: ending session.\n");
                CC->kill_me = 1;
        }
        FreeStrBuf(&stream_input);
index cef4661f5083302309402c63ba03974bf7a3f402..2ef90858c0e25fd0c9c5a169959bfdef0624515e 100644 (file)
@@ -184,12 +184,12 @@ void xmpp_presence_notify(char *presence_jid, int event_type) {
                }
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "%d sessions for <%s> are now visible to session %d\n",
+       syslog(LOG_DEBUG, "%d sessions for <%s> are now visible to session %d\n",
                visible_sessions, presence_jid, CC->cs_pid);
 
        if ( (event_type == XMPP_EVT_LOGIN) && (visible_sessions == 1) ) {
 
-               CtdlLogPrintf(CTDL_DEBUG, "Telling session %d that <%s> logged in\n",
+               syslog(LOG_DEBUG, "Telling session %d that <%s> logged in\n",
                        CC->cs_pid, presence_jid);
 
                /* Do an unsolicited roster update that adds a new contact. */
@@ -204,7 +204,7 @@ void xmpp_presence_notify(char *presence_jid, int event_type) {
        }
 
        if (visible_sessions == 0) {
-               CtdlLogPrintf(CTDL_DEBUG, "Telling session %d that <%s> logged out\n",
+               syslog(LOG_DEBUG, "Telling session %d that <%s> logged out\n",
                        CC->cs_pid, presence_jid);
                xmpp_destroy_buddy(presence_jid);
        }
@@ -261,7 +261,7 @@ void xmpp_fetch_mortuary_backend(long msgnum, void *userdata) {
 HashList *xmpp_fetch_mortuary(void) {
        HashList *mortuary = NewHash(1, NULL);
        if (!mortuary) {
-               CtdlLogPrintf(CTDL_ALERT, "NewHash() failed!\n");
+               syslog(LOG_ALERT, "NewHash() failed!\n");
                return(NULL);
        }
 
index ee83d98eca0a8ddcf2b8b627a285f89088bd6c71..993801bf880128e332872d10f2baa1cd78309595 100644 (file)
@@ -88,7 +88,7 @@ void xmpp_iq_roster_query(void)
        if (cptr) {
                for (i=0; i<nContexts; i++) {
                        if (xmpp_is_visible(&cptr[i], CC)) {
-                               CtdlLogPrintf(CTDL_DEBUG, "Rosterizing %s\n", cptr[i].user.fullname);
+                               syslog(LOG_DEBUG, "Rosterizing %s\n", cptr[i].user.fullname);
                                xmpp_roster_item(&cptr[i]);
                        }
                }
@@ -124,7 +124,7 @@ void xmpp_query_namespace(char *iq_id, char *iq_from, char *iq_to, char *query_x
                supported_namespace = 1;
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "xmpp_query_namespace(%s, %s, %s, %s)\n", iq_id, iq_from, iq_to, query_xmlns);
+       syslog(LOG_DEBUG, "xmpp_query_namespace(%s, %s, %s, %s)\n", iq_id, iq_from, iq_to, query_xmlns);
 
        /*
         * Beginning of query result.
@@ -162,7 +162,7 @@ void xmpp_query_namespace(char *iq_id, char *iq_from, char *iq_to, char *query_x
         */
 
        else {
-               CtdlLogPrintf(CTDL_DEBUG,
+               syslog(LOG_DEBUG,
                        "Unknown query namespace '%s' - returning <service-unavailable/>\n",
                        query_xmlns
                );
index 77ce80343ece12c67e3520ed2e6d40eac0e7787c..f9fdd5823b1eb9b8a3f16d31cbbf6432e3fda730 100644 (file)
@@ -66,7 +66,7 @@ void xmpp_queue_event(int event_type, char *email_addr) {
        int purged_something = 0;
        struct CitContext *cptr;
 
-       CtdlLogPrintf(CTDL_DEBUG, "xmpp_queue_event(%d, %s)\n", event_type, email_addr);
+       syslog(LOG_DEBUG, "xmpp_queue_event(%d, %s)\n", event_type, email_addr);
 
        /* Purge events more than a minute old */
        begin_critical_section(S_XMPP_QUEUE);
index fc7b625e585c806b1cd76d2b7c402a3a5713aa2b..5ec0801d20038b45cd3f2b3ebc768081bb99452b 100644 (file)
@@ -198,7 +198,7 @@ int alias(char *name)
        }
 
        if (strcasecmp(original_name, name)) {
-               CtdlLogPrintf(CTDL_INFO, "%s is being forwarded to %s\n", original_name, name);
+               syslog(LOG_INFO, "%s is being forwarded to %s\n", original_name, name);
        }
 
        /* Change "user @ xxx" to "user" if xxx is an alias for this host */
@@ -206,7 +206,7 @@ int alias(char *name)
                if (name[a] == '@') {
                        if (CtdlHostAlias(&name[a+1]) == hostalias_localhost) {
                                name[a] = 0;
-                               CtdlLogPrintf(CTDL_INFO, "Changed to <%s>\n", name);
+                               syslog(LOG_INFO, "Changed to <%s>\n", name);
                        }
                }
        }
@@ -404,7 +404,7 @@ void CtdlSetSeen(long *target_msgnums, int num_target_msgnums,
                which_user = &CC->user;
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "CtdlSetSeen(%d msgs starting with %ld, %s, %d) in <%s>\n",
+       syslog(LOG_DEBUG, "CtdlSetSeen(%d msgs starting with %ld, %s, %d) in <%s>\n",
                num_target_msgnums, target_msgnums[0],
                (target_setting ? "SET" : "CLEAR"),
                which_set,
@@ -441,17 +441,17 @@ void CtdlSetSeen(long *target_msgnums, int num_target_msgnums,
 
 
 #if 0  /* This is a special diagnostic section.  Do not allow it to run during normal operation. */
-       CtdlLogPrintf(CTDL_DEBUG, "There are %d messages in the room.\n", num_msgs);
+       syslog(LOG_DEBUG, "There are %d messages in the room.\n", num_msgs);
        for (i=0; i<num_msgs; ++i) {
                if ((i > 0) && (msglist[i] <= msglist[i-1])) abort();
        }
-       CtdlLogPrintf(CTDL_DEBUG, "We are twiddling %d of them.\n", num_target_msgnums);
+       syslog(LOG_DEBUG, "We are twiddling %d of them.\n", num_target_msgnums);
        for (k=0; k<num_target_msgnums; ++k) {
                if ((k > 0) && (target_msgnums[k] <= target_msgnums[k-1])) abort();
        }
 #endif
 
-       CtdlLogPrintf(CTDL_DEBUG, "before update: %s\n", ChrPtr(vset));
+       syslog(LOG_DEBUG, "before update: %s\n", ChrPtr(vset));
 
        /* Translate the existing sequence set into an array of booleans */
        setstr = NewStrBuf();
@@ -574,7 +574,7 @@ void CtdlSetSeen(long *target_msgnums, int num_target_msgnums,
                vset = new_set;
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, " after update: %s\n", ChrPtr(vset));
+       syslog(LOG_DEBUG, " after update: %s\n", ChrPtr(vset));
 
        /* Decide which message set we're manipulating */
        switch (which_set) {
@@ -940,13 +940,13 @@ void memfmout(
                if (ch == '\n') {
                        if (client_write(outbuf, len) == -1)
                        {
-                               CtdlLogPrintf(CTDL_ERR, "memfmout(): aborting due to write failure.\n");
+                               syslog(LOG_ERR, "memfmout(): aborting due to write failure.\n");
                                return;
                        }
                        len = 0;
                        if (client_write(nl, nllen) == -1)
                        {
-                               CtdlLogPrintf(CTDL_ERR, "memfmout(): aborting due to write failure.\n");
+                               syslog(LOG_ERR, "memfmout(): aborting due to write failure.\n");
                                return;
                        }
                        column = 0;
@@ -958,13 +958,13 @@ void memfmout(
                        if (column > 72) {              /* Beyond 72 columns, break on the next space */
                                if (client_write(outbuf, len) == -1)
                                {
-                                       CtdlLogPrintf(CTDL_ERR, "memfmout(): aborting due to write failure.\n");
+                                       syslog(LOG_ERR, "memfmout(): aborting due to write failure.\n");
                                        return;
                                }
                                len = 0;
                                if (client_write(nl, nllen) == -1)
                                {
-                                       CtdlLogPrintf(CTDL_ERR, "memfmout(): aborting due to write failure.\n");
+                                       syslog(LOG_ERR, "memfmout(): aborting due to write failure.\n");
                                        return;
                                }
                                column = 0;
@@ -980,13 +980,13 @@ void memfmout(
                        if (column > 1000) {            /* Beyond 1000 columns, break anywhere */
                                if (client_write(outbuf, len) == -1)
                                {
-                                       CtdlLogPrintf(CTDL_ERR, "memfmout(): aborting due to write failure.\n");
+                                       syslog(LOG_ERR, "memfmout(): aborting due to write failure.\n");
                                        return;
                                }
                                len = 0;
                                if (client_write(nl, nllen) == -1)
                                {
-                                       CtdlLogPrintf(CTDL_ERR, "memfmout(): aborting due to write failure.\n");
+                                       syslog(LOG_ERR, "memfmout(): aborting due to write failure.\n");
                                        return;
                                }
                                column = 0;
@@ -996,7 +996,7 @@ void memfmout(
        if (len) {
                if (client_write(outbuf, len) == -1)
                {
-                       CtdlLogPrintf(CTDL_ERR, "memfmout(): aborting due to write failure.\n");
+                       syslog(LOG_ERR, "memfmout(): aborting due to write failure.\n");
                        return;
                }
                len = 0;
@@ -1185,11 +1185,11 @@ struct CtdlMessage *CtdlFetchMessage(long msgnum, int with_body)
        cit_uint8_t ch;
        cit_uint8_t field_header;
 
-       CtdlLogPrintf(CTDL_DEBUG, "CtdlFetchMessage(%ld, %d)\n", msgnum, with_body);
+       syslog(LOG_DEBUG, "CtdlFetchMessage(%ld, %d)\n", msgnum, with_body);
 
 #ifdef MESSAGE_IN_ROOM
        if (!CtdlMessageInRoom(msgnum)) {
-               CtdlLogPrintf(CTDL_DEBUG, "Message %ld not in current room\n", msgnum);
+               syslog(LOG_DEBUG, "Message %ld not in current room\n", msgnum);
                return NULL;
        }
 #endif
@@ -1208,7 +1208,7 @@ struct CtdlMessage *CtdlFetchMessage(long msgnum, int with_body)
         */
        ch = *mptr++;
        if (ch != 255) {
-               CtdlLogPrintf(CTDL_ERR, "Message %ld appears to be corrupted.\n", msgnum);
+               syslog(LOG_ERR, "Message %ld appears to be corrupted.\n", msgnum);
                cdb_free(dmsgtext);
                return NULL;
        }
@@ -1272,7 +1272,7 @@ int is_valid_message(struct CtdlMessage *msg) {
        if (msg == NULL)
                return 0;
        if ((msg->cm_magic) != CTDLMESSAGE_MAGIC) {
-               CtdlLogPrintf(CTDL_WARNING, "is_valid_message() -- self-check failed\n");
+               syslog(LOG_WARNING, "is_valid_message() -- self-check failed\n");
                return 0;
        }
        return 1;
@@ -1319,7 +1319,7 @@ void fixed_output_pre(char *name, char *filename, char *partnum, char *disp,
        struct ma_info *ma;
        
        ma = (struct ma_info *)cbuserdata;
-       CtdlLogPrintf(CTDL_DEBUG, "fixed_output_pre() type=<%s>\n", cbtype);    
+       syslog(LOG_DEBUG, "fixed_output_pre() type=<%s>\n", cbtype);    
        if (!strcasecmp(cbtype, "multipart/alternative")) {
                ++ma->is_ma;
                ma->did_print = 0;
@@ -1339,7 +1339,7 @@ void fixed_output_post(char *name, char *filename, char *partnum, char *disp,
        struct ma_info *ma;
        
        ma = (struct ma_info *)cbuserdata;
-       CtdlLogPrintf(CTDL_DEBUG, "fixed_output_post() type=<%s>\n", cbtype);   
+       syslog(LOG_DEBUG, "fixed_output_post() type=<%s>\n", cbtype);   
        if (!strcasecmp(cbtype, "multipart/alternative")) {
                --ma->is_ma;
                ma->did_print = 0;
@@ -1363,7 +1363,7 @@ void fixed_output(char *name, char *filename, char *partnum, char *disp,
 
        ma = (struct ma_info *)cbuserdata;
 
-       CtdlLogPrintf(CTDL_DEBUG,
+       syslog(LOG_DEBUG,
                "fixed_output() part %s: %s (%s) (%ld bytes)\n",
                partnum, filename, cbtype, (long)length);
 
@@ -1372,7 +1372,7 @@ void fixed_output(char *name, char *filename, char *partnum, char *disp,
         * we've already printed another section, skip this one.
         */     
        if ( (ma->is_ma) && (ma->did_print) ) {
-               CtdlLogPrintf(CTDL_DEBUG, "Skipping part %s (%s)\n", partnum, cbtype);
+               syslog(LOG_DEBUG, "Skipping part %s (%s)\n", partnum, cbtype);
                return;
        }
        ma->did_print = 1;
@@ -1444,7 +1444,7 @@ void choose_preferred(char *name, char *filename, char *partnum, char *disp,
                extract_token(buf, CC->preferred_formats, i, '|', sizeof buf);
                if ( (!strcasecmp(buf, cbtype)) && (!ma->freeze) ) {
                        if (i < ma->chosen_pref) {
-                               CtdlLogPrintf(CTDL_DEBUG, "Setting chosen part: <%s>\n", partnum);
+                               syslog(LOG_DEBUG, "Setting chosen part: <%s>\n", partnum);
                                safestrncpy(ma->chosen_part, partnum, sizeof ma->chosen_part);
                                ma->chosen_pref = i;
                        }
@@ -1522,7 +1522,7 @@ void output_preferred(char *name,
                        cprintf("\n");
                        if (client_write(text_content, length) == -1)
                        {
-                               CtdlLogPrintf(CTDL_ERR, "output_preferred(): aborting due to write failure.\n");
+                               syslog(LOG_ERR, "output_preferred(): aborting due to write failure.\n");
                                return;
                        }
                        if (add_newline) cprintf("\n");
@@ -1615,7 +1615,7 @@ int CtdlOutputMsg(long msg_num,           /* message number (local) to fetch */
        struct encapmsg encap;
        int r;
 
-       CtdlLogPrintf(CTDL_DEBUG, "CtdlOutputMsg(msgnum=%ld, mode=%d, section=%s)\n", 
+       syslog(LOG_DEBUG, "CtdlOutputMsg(msgnum=%ld, mode=%d, section=%s)\n", 
                msg_num, mode,
                (section ? section : "<>")
        );
@@ -1635,7 +1635,7 @@ int CtdlOutputMsg(long msg_num,           /* message number (local) to fetch */
 
 #ifdef MESSAGE_IN_ROOM
        if (!CtdlMessageInRoom(msg_num)) {
-               CtdlLogPrintf(CTDL_DEBUG, "Message %ld not in current room\n", msg_num);
+               syslog(LOG_DEBUG, "Message %ld not in current room\n", msg_num);
                if (do_proto) cprintf("%d Can't locate msg %ld in room\n",
                        ERROR + MESSAGE_NOT_FOUND, msg_num);
                return(om_no_such_msg);
@@ -1722,7 +1722,7 @@ char *qp_encode_email_addrs(char *source)
        if (source == NULL) return source;
        if (IsEmptyStr(source)) return source;
        cit_backtrace();
-       CtdlLogPrintf(CTDL_DEBUG, "qp_encode_email_addrs: [%s]\n", source);
+       syslog(LOG_DEBUG, "qp_encode_email_addrs: [%s]\n", source);
 
        AddrPtr = malloc (sizeof (long) * nAddrPtrMax);
        AddrUtf8 = malloc (sizeof (long) * nAddrPtrMax);
@@ -2098,7 +2098,7 @@ void Dump_RFC822HeadersBody(
                if (outlen > 1000) {
                        if (client_write(outbuf, outlen) == -1)
                        {
-                               CtdlLogPrintf(CTDL_ERR, "Dump_RFC822HeadersBody(): aborting due to write failure.\n");
+                               syslog(LOG_ERR, "Dump_RFC822HeadersBody(): aborting due to write failure.\n");
                                return;
                        }
                        outlen = 0;
@@ -2169,7 +2169,7 @@ void DumpFormatFixed(
 
                        if (client_write(buf, buflen) == -1)
                        {
-                               CtdlLogPrintf(CTDL_ERR, "DumpFormatFixed(): aborting due to write failure.\n");
+                               syslog(LOG_ERR, "DumpFormatFixed(): aborting due to write failure.\n");
                                return;
                        }
                        *buf = '\0';
@@ -2211,7 +2211,7 @@ int CtdlOutputPreLoadedMsg(
        char snode[100];
        char mid[100];
 
-       CtdlLogPrintf(CTDL_DEBUG, "CtdlOutputPreLoadedMsg(TheMessage=%s, %d, %d, %d, %d\n",
+       syslog(LOG_DEBUG, "CtdlOutputPreLoadedMsg(TheMessage=%s, %d, %d, %d, %d\n",
                ((TheMessage == NULL) ? "NULL" : "not null"),
                mode, headers_only, do_proto, crlf);
 
@@ -2219,7 +2219,7 @@ int CtdlOutputPreLoadedMsg(
        nl = (crlf ? "\r\n" : "\n");
 
        if (!is_valid_message(TheMessage)) {
-               CtdlLogPrintf(CTDL_ERR,
+               syslog(LOG_ERR,
                        "ERROR: invalid preloaded message for output\n");
                cit_backtrace ();
                return(om_no_such_msg);
@@ -2613,7 +2613,7 @@ int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newms
        long *msgs_to_be_merged = NULL;
        int num_msgs_to_be_merged = 0;
 
-       CtdlLogPrintf(CTDL_DEBUG,
+       syslog(LOG_DEBUG,
                "CtdlSaveMsgPointersInRoom(room=%s, num_msgs=%d, repl=%d, suppress_rca=%d)\n",
                roomname, num_newmsgs, do_repl_check, suppress_refcount_adj
        );
@@ -2629,7 +2629,7 @@ int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newms
        if (CtdlGetRoomLock(&CC->room,
           ((roomname != NULL) ? roomname : CC->room.QRname) )
           != 0) {
-               CtdlLogPrintf(CTDL_ERR, "No such room <%s>\n", roomname);
+               syslog(LOG_ERR, "No such room <%s>\n", roomname);
                return(ERROR + ROOM_NOT_FOUND);
        }
 
@@ -2666,14 +2666,14 @@ int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newms
                }
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "%d unique messages to be merged\n", num_msgs_to_be_merged);
+       syslog(LOG_DEBUG, "%d unique messages to be merged\n", num_msgs_to_be_merged);
 
        /*
         * Now merge the new messages
         */
        msglist = realloc(msglist, (sizeof(long) * (num_msgs + num_msgs_to_be_merged)) );
        if (msglist == NULL) {
-               CtdlLogPrintf(CTDL_ALERT, "ERROR: can't realloc message list!\n");
+               syslog(LOG_ALERT, "ERROR: can't realloc message list!\n");
        }
        memcpy(&msglist[num_msgs], msgs_to_be_merged, (sizeof(long) * num_msgs_to_be_merged) );
        num_msgs += num_msgs_to_be_merged;
@@ -2697,7 +2697,7 @@ int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newms
 
        /* Perform replication checks if necessary */
        if ( (DoesThisRoomNeedEuidIndexing(&CC->room)) && (do_repl_check) ) {
-               CtdlLogPrintf(CTDL_DEBUG, "CtdlSaveMsgPointerInRoom() doing repl checks\n");
+               syslog(LOG_DEBUG, "CtdlSaveMsgPointerInRoom() doing repl checks\n");
 
                for (i=0; i<num_msgs_to_be_merged; ++i) {
                        msgid = msgs_to_be_merged[i];
@@ -2727,7 +2727,7 @@ int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newms
        }
 
        else {
-               CtdlLogPrintf(CTDL_DEBUG, "CtdlSaveMsgPointerInRoom() skips repl checks\n");
+               syslog(LOG_DEBUG, "CtdlSaveMsgPointerInRoom() skips repl checks\n");
        }
 
        /* Submit this room for processing by hooks */
@@ -2816,7 +2816,7 @@ long send_message(struct CtdlMessage *msg) {
        /* Write our little bundle of joy into the message base */
        if (cdb_store(CDB_MSGMAIN, &newmsgid, (int)sizeof(long),
                      smr.ser, smr.len) < 0) {
-               CtdlLogPrintf(CTDL_ERR, "Can't store message\n");
+               syslog(LOG_ERR, "Can't store message\n");
                retval = 0L;
        } else {
                if (is_bigmsg) {
@@ -2859,7 +2859,7 @@ void serialize_message(struct ser_ret *ret,               /* return values */
         * Check for valid message format
         */
        if (is_valid_message(msg) == 0) {
-               CtdlLogPrintf(CTDL_ERR, "serialize_message() aborting due to invalid message\n");
+               syslog(LOG_ERR, "serialize_message() aborting due to invalid message\n");
                ret->len = 0;
                ret->ser = NULL;
                return;
@@ -2872,7 +2872,7 @@ void serialize_message(struct ser_ret *ret,               /* return values */
 
        ret->ser = malloc(ret->len);
        if (ret->ser == NULL) {
-               CtdlLogPrintf(CTDL_ERR, "serialize_message() malloc(%ld) failed: %s\n",
+               syslog(LOG_ERR, "serialize_message() malloc(%ld) failed: %s\n",
                        (long)ret->len, strerror(errno));
                ret->len = 0;
                ret->ser = NULL;
@@ -2890,7 +2890,7 @@ void serialize_message(struct ser_ret *ret,               /* return values */
                safestrncpy((char *)&ret->ser[wlen], msg->cm_fields[(int)forder[i]], fieldlen+1);
                wlen = wlen + fieldlen + 1;
        }
-       if (ret->len != wlen) CtdlLogPrintf(CTDL_ERR, "ERROR: len=%ld wlen=%ld\n",
+       if (ret->len != wlen) syslog(LOG_ERR, "ERROR: len=%ld wlen=%ld\n",
                (long)ret->len, (long)wlen);
 
        return;
@@ -2916,7 +2916,7 @@ void dump_message(struct CtdlMessage *msg,        /* unserialized msg */
         * Check for valid message format
         */
        if (is_valid_message(msg) == 0) {
-               CtdlLogPrintf(CTDL_ERR, "dump_message() aborting due to invalid message\n");
+               syslog(LOG_ERR, "dump_message() aborting due to invalid message\n");
                return;
        }
 
@@ -2929,7 +2929,7 @@ void dump_message(struct CtdlMessage *msg,        /* unserialized msg */
                                   msg->cm_fields[(int)forder[i]]);
                        if (client_write (buf, strlen(buf)) == -1)
                        {
-                               CtdlLogPrintf(CTDL_ERR, "dump_message(): aborting due to write failure.\n");
+                               syslog(LOG_ERR, "dump_message(): aborting due to write failure.\n");
                                return;
                        }
                }
@@ -2948,19 +2948,19 @@ void ReplicationChecks(struct CtdlMessage *msg) {
 
        if (DoesThisRoomNeedEuidIndexing(&CC->room) == 0) return;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Performing replication checks in <%s>\n",
+       syslog(LOG_DEBUG, "Performing replication checks in <%s>\n",
                CC->room.QRname);
 
        /* No exclusive id?  Don't do anything. */
        if (msg == NULL) return;
        if (msg->cm_fields['E'] == NULL) return;
        if (IsEmptyStr(msg->cm_fields['E'])) return;
-       /*CtdlLogPrintf(CTDL_DEBUG, "Exclusive ID: <%s> for room <%s>\n",
+       /*syslog(LOG_DEBUG, "Exclusive ID: <%s> for room <%s>\n",
                msg->cm_fields['E'], CC->room.QRname);*/
 
        old_msgnum = CtdlLocateMessageByEuid(msg->cm_fields['E'], &CC->room);
        if (old_msgnum > 0L) {
-               CtdlLogPrintf(CTDL_DEBUG, "ReplicationChecks() replacing message %ld\n", old_msgnum);
+               syslog(LOG_DEBUG, "ReplicationChecks() replacing message %ld\n", old_msgnum);
                CtdlDeleteMessages(CC->room.QRname, &old_msgnum, 1, "");
        }
 }
@@ -3003,7 +3003,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
        size_t tmp = 0;
        int rv = 0;
 
-       CtdlLogPrintf(CTDL_DEBUG, "CtdlSubmitMsg() called\n");
+       syslog(LOG_DEBUG, "CtdlSubmitMsg() called\n");
        if (is_valid_message(msg) == 0) return(-1);     /* self check */
 
        /* If this message has no timestamp, we take the liberty of
@@ -3039,7 +3039,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
 
        /* Learn about what's inside, because it's what's inside that counts */
        if (msg->cm_fields['M'] == NULL) {
-               CtdlLogPrintf(CTDL_ERR, "ERROR: attempt to save message with NULL body\n");
+               syslog(LOG_ERR, "ERROR: attempt to save message with NULL body\n");
                return(-2);
        }
 
@@ -3071,7 +3071,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
        }
 
        /* Goto the correct room */
-       CtdlLogPrintf(CTDL_DEBUG, "Selected room %s\n", (recps) ? CCC->room.QRname : SENTITEMS);
+       syslog(LOG_DEBUG, "Selected room %s\n", (recps) ? CCC->room.QRname : SENTITEMS);
        strcpy(hold_rm, CCC->room.QRname);
        strcpy(actual_rm, CCC->room.QRname);
        if (recps != NULL) {
@@ -3083,7 +3083,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
                if (CCC->user.axlevel == AxProbU) {
                        strcpy(hold_rm, actual_rm);
                        strcpy(actual_rm, config.c_twitroom);
-                       CtdlLogPrintf(CTDL_DEBUG, "Diverting to twit room\n");
+                       syslog(LOG_DEBUG, "Diverting to twit room\n");
                }
        }
 
@@ -3092,7 +3092,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
                strcpy(actual_rm, force_room);
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Final selection: %s\n", actual_rm);
+       syslog(LOG_DEBUG, "Final selection: %s\n", actual_rm);
        if (strcasecmp(actual_rm, CCC->room.QRname)) {
                /* CtdlGetRoom(&CCC->room, actual_rm); */
                CtdlUserGoto(actual_rm, 0, 1, NULL, NULL);
@@ -3106,7 +3106,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
        }
 
        /* Perform "before save" hooks (aborting if any return nonzero) */
-       CtdlLogPrintf(CTDL_DEBUG, "Performing before-save hooks\n");
+       syslog(LOG_DEBUG, "Performing before-save hooks\n");
        if (PerformMessageHooks(msg, EVT_BEFORESAVE) > 0) return(-3);
 
        /*
@@ -3118,7 +3118,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
        }
 
        /* Save it to disk */
-       CtdlLogPrintf(CTDL_DEBUG, "Saving to disk\n");
+       syslog(LOG_DEBUG, "Saving to disk\n");
        newmsgid = send_message(msg);
        if (newmsgid <= 0L) return(-5);
 
@@ -3126,7 +3126,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
         * be a critical section because nobody else knows about this message
         * yet.
         */
-       CtdlLogPrintf(CTDL_DEBUG, "Creating MetaData record\n");
+       syslog(LOG_DEBUG, "Creating MetaData record\n");
        memset(&smi, 0, sizeof(struct MetaData));
        smi.meta_msgnum = newmsgid;
        smi.meta_refcount = 0;
@@ -3144,7 +3144,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
         *    message to attach to the journalized copy.
         */
        if (CCC->redirect_buffer != NULL) {
-               CtdlLogPrintf(CTDL_ALERT, "CCC->redirect_buffer is not NULL during message submission!\n");
+               syslog(LOG_ALERT, "CCC->redirect_buffer is not NULL during message submission!\n");
                abort();
        }
        CCC->redirect_buffer = NewStrBufPlain(NULL, SIZ);
@@ -3156,7 +3156,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
        PutMetaData(&smi);
 
        /* Now figure out where to store the pointers */
-       CtdlLogPrintf(CTDL_DEBUG, "Storing pointers\n");
+       syslog(LOG_DEBUG, "Storing pointers\n");
 
        /* If this is being done by the networker delivering a private
         * message, we want to BYPASS saving the sender's copy (because there
@@ -3164,7 +3164,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
         */
        if ((!CCC->internal_pgm) || (recps == NULL)) {
                if (CtdlSaveMsgPointerInRoom(actual_rm, newmsgid, 1, msg) != 0) {
-                       CtdlLogPrintf(CTDL_ERR, "ERROR saving message pointer!\n");
+                       syslog(LOG_ERR, "ERROR saving message pointer!\n");
                        CtdlSaveMsgPointerInRoom(config.c_aideroom, newmsgid, 0, msg);
                }
        }
@@ -3179,12 +3179,12 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,     /* message to save */
          for (i=0; i<num_tokens(recps->recp_room, '|'); ++i) {
                extract_token(recipient, recps->recp_room, i,
                                        '|', sizeof recipient);
-               CtdlLogPrintf(CTDL_DEBUG, "Delivering to room <%s>\n", recipient);
+               syslog(LOG_DEBUG, "Delivering to room <%s>\n", recipient);
                CtdlSaveMsgPointerInRoom(recipient, newmsgid, 0, msg);
        }
 
        /* Bump this user's messages posted counter. */
-       CtdlLogPrintf(CTDL_DEBUG, "Updating user\n");
+       syslog(LOG_DEBUG, "Updating user\n");
        CtdlGetUserLock(&CCC->user, CCC->curr_user);
        CCC->user.posted = CCC->user.posted + 1;
        CtdlPutUserLock(&CCC->user);
@@ -3207,7 +3207,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
          for (i=0; i<num_tokens(recps->recp_local, '|'); ++i) {
                extract_token(recipient, recps->recp_local, i,
                                        '|', sizeof recipient);
-               CtdlLogPrintf(CTDL_DEBUG, "Delivering private local mail to <%s>\n",
+               syslog(LOG_DEBUG, "Delivering private local mail to <%s>\n",
                        recipient);
                if (CtdlGetUser(&userbuf, recipient) == 0) {
                        // Add a flag so the Funambol module knows its mail
@@ -3242,14 +3242,14 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,     /* message to save */
                        }
                }
                else {
-                       CtdlLogPrintf(CTDL_DEBUG, "No user <%s>\n", recipient);
+                       syslog(LOG_DEBUG, "No user <%s>\n", recipient);
                        CtdlSaveMsgPointerInRoom(config.c_aideroom,
                                newmsgid, 0, msg);
                }
        }
 
        /* Perform "after save" hooks */
-       CtdlLogPrintf(CTDL_DEBUG, "Performing after-save hooks\n");
+       syslog(LOG_DEBUG, "Performing after-save hooks\n");
        PerformMessageHooks(msg, EVT_AFTERSAVE);
 
        /* For IGnet mail, we have to save a new copy into the spooler for
@@ -3293,7 +3293,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
        }
 
        /* Go back to the room we started from */
-       CtdlLogPrintf(CTDL_DEBUG, "Returning to original room %s\n", hold_rm);
+       syslog(LOG_DEBUG, "Returning to original room %s\n", hold_rm);
        if (strcasecmp(hold_rm, CCC->room.QRname))
                CtdlUserGoto(hold_rm, 0, 1, NULL, NULL);
 
@@ -3303,7 +3303,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
         * contain a recipient.
         */
        if ((recps != NULL) && (recps->num_internet > 0)) {
-               CtdlLogPrintf(CTDL_DEBUG, "Generating delivery instructions\n");
+               syslog(LOG_DEBUG, "Generating delivery instructions\n");
                instr_alloc = 1024;
                instr = malloc(instr_alloc);
                snprintf(instr, instr_alloc,
@@ -4063,7 +4063,7 @@ struct recptypes *validate_recipients(const char *supplied_recipients,
                striplt(this_recp);
                if (IsEmptyStr(this_recp))
                        break;
-               CtdlLogPrintf(CTDL_DEBUG, "Evaluating recipient #%d: %s\n", num_recps, this_recp);
+               syslog(LOG_DEBUG, "Evaluating recipient #%d: %s\n", num_recps, this_recp);
                ++num_recps;
                mailtype = alias(this_recp);
                mailtype = alias(this_recp);
@@ -4207,12 +4207,12 @@ struct recptypes *validate_recipients(const char *supplied_recipients,
                strcpy(ret->errormsg, "No recipients specified.");
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "validate_recipients()\n");
-       CtdlLogPrintf(CTDL_DEBUG, " local: %d <%s>\n", ret->num_local, ret->recp_local);
-       CtdlLogPrintf(CTDL_DEBUG, "  room: %d <%s>\n", ret->num_room, ret->recp_room);
-       CtdlLogPrintf(CTDL_DEBUG, "  inet: %d <%s>\n", ret->num_internet, ret->recp_internet);
-       CtdlLogPrintf(CTDL_DEBUG, " ignet: %d <%s>\n", ret->num_ignet, ret->recp_ignet);
-       CtdlLogPrintf(CTDL_DEBUG, " error: %d <%s>\n", ret->num_error, ret->errormsg);
+       syslog(LOG_DEBUG, "validate_recipients()\n");
+       syslog(LOG_DEBUG, " local: %d <%s>\n", ret->num_local, ret->recp_local);
+       syslog(LOG_DEBUG, "  room: %d <%s>\n", ret->num_room, ret->recp_room);
+       syslog(LOG_DEBUG, "  inet: %d <%s>\n", ret->num_internet, ret->recp_internet);
+       syslog(LOG_DEBUG, " ignet: %d <%s>\n", ret->num_ignet, ret->recp_ignet);
+       syslog(LOG_DEBUG, " error: %d <%s>\n", ret->num_error, ret->errormsg);
 
        free(recipients);
        return(ret);
@@ -4229,7 +4229,7 @@ void free_recipients(struct recptypes *valid) {
        }
 
        if (valid->recptypes_magic != RECPTYPES_MAGIC) {
-               CtdlLogPrintf(CTDL_EMERG, "Attempt to call free_recipients() on some other data type!\n");
+               syslog(LOG_EMERG, "Attempt to call free_recipients() on some other data type!\n");
                abort();
        }
 
@@ -4586,12 +4586,12 @@ int CtdlDeleteMessages(char *room_name,         /* which room */
                regcomp(&re, content_type, 0);
                need_to_free_re = 1;
        }
-       CtdlLogPrintf(CTDL_DEBUG, "CtdlDeleteMessages(%s, %d msgs, %s)\n",
+       syslog(LOG_DEBUG, "CtdlDeleteMessages(%s, %d msgs, %s)\n",
                room_name, num_dmsgnums, content_type);
 
        /* get room record, obtaining a lock... */
        if (CtdlGetRoomLock(&qrbuf, room_name) != 0) {
-               CtdlLogPrintf(CTDL_ERR, "CtdlDeleteMessages(): Room <%s> not found\n",
+               syslog(LOG_ERR, "CtdlDeleteMessages(): Room <%s> not found\n",
                        room_name);
                if (need_to_free_re) regfree(&re);
                return (0);     /* room not found */
@@ -4668,7 +4668,7 @@ int CtdlDeleteMessages(char *room_name,           /* which room */
        /* Now free the memory we used, and go away. */
        if (msglist != NULL) free(msglist);
        if (dellist != NULL) free(dellist);
-       CtdlLogPrintf(CTDL_DEBUG, "%d message(s) deleted.\n", num_deleted);
+       syslog(LOG_DEBUG, "%d message(s) deleted.\n", num_deleted);
        if (need_to_free_re) regfree(&re);
        return (num_deleted);
 }
@@ -4902,7 +4902,7 @@ void AdjRefCount(long msgnum, int incr)
        struct arcq new_arcq;
        int rv = 0;
 
-       CtdlLogPrintf(CTDL_DEBUG, "AdjRefCount() msg %ld ref count delta %+d\n",
+       syslog(LOG_DEBUG, "AdjRefCount() msg %ld ref count delta %+d\n",
                msgnum, incr
        );
 
@@ -4914,7 +4914,7 @@ void AdjRefCount(long msgnum, int incr)
 
        /* msgnum < 0 means that we're trying to close the file */
        if (msgnum < 0) {
-               CtdlLogPrintf(CTDL_DEBUG, "Closing the AdjRefCount queue file\n");
+               syslog(LOG_DEBUG, "Closing the AdjRefCount queue file\n");
                begin_critical_section(S_SUPPMSGMAIN);
                if (arcfp != NULL) {
                        fclose(arcfp);
@@ -4966,7 +4966,7 @@ int TDAP_ProcessAdjRefCountQueue(void)
 
        r = link(file_arcq, file_arcq_temp);
        if (r != 0) {
-               CtdlLogPrintf(CTDL_CRIT, "%s: %s\n", file_arcq_temp, strerror(errno));
+               syslog(LOG_CRIT, "%s: %s\n", file_arcq_temp, strerror(errno));
                end_critical_section(S_SUPPMSGMAIN);
                return(num_records_processed);
        }
@@ -4976,7 +4976,7 @@ int TDAP_ProcessAdjRefCountQueue(void)
 
        fp = fopen(file_arcq_temp, "rb");
        if (fp == NULL) {
-               CtdlLogPrintf(CTDL_CRIT, "%s: %s\n", file_arcq_temp, strerror(errno));
+               syslog(LOG_CRIT, "%s: %s\n", file_arcq_temp, strerror(errno));
                return(num_records_processed);
        }
 
@@ -4988,7 +4988,7 @@ int TDAP_ProcessAdjRefCountQueue(void)
        fclose(fp);
        r = unlink(file_arcq_temp);
        if (r != 0) {
-               CtdlLogPrintf(CTDL_CRIT, "%s: %s\n", file_arcq_temp, strerror(errno));
+               syslog(LOG_CRIT, "%s: %s\n", file_arcq_temp, strerror(errno));
        }
 
        return(num_records_processed);
@@ -5019,7 +5019,7 @@ void TDAP_AdjRefCount(long msgnum, int incr)
        smi.meta_refcount += incr;
        PutMetaData(&smi);
        end_critical_section(S_SUPPMSGMAIN);
-       CtdlLogPrintf(CTDL_DEBUG, "TDAP_AdjRefCount() msg %ld ref count delta %+d, is now %d\n",
+       syslog(LOG_DEBUG, "TDAP_AdjRefCount() msg %ld ref count delta %+d, is now %d\n",
                msgnum, incr, smi.meta_refcount
        );
 
@@ -5027,7 +5027,7 @@ void TDAP_AdjRefCount(long msgnum, int incr)
         * (and its supplementary record as well).
         */
        if (smi.meta_refcount == 0) {
-               CtdlLogPrintf(CTDL_DEBUG, "Deleting message <%ld>\n", msgnum);
+               syslog(LOG_DEBUG, "Deleting message <%ld>\n", msgnum);
                
                /* Call delete hooks with NULL room to show it has gone altogether */
                PerformDeleteHooks(NULL, msgnum);
@@ -5073,7 +5073,7 @@ void CtdlWriteObject(char *req_room,                      /* Room to stuff it in */
                safestrncpy(roomname, req_room, sizeof(roomname));
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Raw length is %ld\n", (long)raw_length);
+       syslog(LOG_DEBUG, "Raw length is %ld\n", (long)raw_length);
 
        if (is_binary) {
                encoded_message = malloc((size_t) (((raw_length * 134) / 100) + 4096 ) );
@@ -5111,7 +5111,7 @@ void CtdlWriteObject(char *req_room,                      /* Room to stuff it in */
                );
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Allocating\n");
+       syslog(LOG_DEBUG, "Allocating\n");
        msg = malloc(sizeof(struct CtdlMessage));
        memset(msg, 0, sizeof(struct CtdlMessage));
        msg->cm_magic = CTDLMESSAGE_MAGIC;
@@ -5135,7 +5135,7 @@ void CtdlWriteObject(char *req_room,                      /* Room to stuff it in */
         * other objects of this type that are currently in the room.
         */
        if (is_unique) {
-               CtdlLogPrintf(CTDL_DEBUG, "Deleted %d other msgs of this type\n",
+               syslog(LOG_DEBUG, "Deleted %d other msgs of this type\n",
                        CtdlDeleteMessages(roomname, NULL, 0, content_type)
                );
        }
index af08b4b81b3dd2620f0d1e7717d1ba529d59ded0..2df743a7750b424da971c289f22b7361c03f1efd 100644 (file)
@@ -255,13 +255,10 @@ typedef union YYSTYPE
 
     time_t             Number;
     enum _MERIDIAN     Meridian;
-
-
-
-/* Line 214 of yacc.c  */
-#line 263 "y.tab.c"
-} YYSTYPE;
-# define YYSTYPE_IS_TRIVIAL 1
+}
+/* Line 193 of yacc.c.  */
+#line 247 "y.tab.c"
+       YYSTYPE;
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
 # define YYSTYPE_IS_DECLARED 1
 #endif
index c6801b6d352b2d7f4c4e665eedd9fa71d64add9f..91fca856b2412078ab020815170d80ba33ceeb52 100644 (file)
@@ -1019,7 +1019,7 @@ void CtdlUserGoto(char *where, int display_result, int transiently,
 
        if (retmsgs != NULL) *retmsgs = total_messages;
        if (retnew != NULL) *retnew = new_messages;
-       CtdlLogPrintf(CTDL_DEBUG, "<%s> %d new of %d total messages\n",
+       syslog(LOG_DEBUG, "<%s> %d new of %d total messages\n",
                CC->room.QRname,
                new_messages, total_messages
        );
@@ -1162,7 +1162,7 @@ void cmd_goto(char *gargs)
                                   ((ra & UA_KNOWN) == 0) &&
                                   (CC->user.axlevel < AxAideU)
                                   ) {
-                               CtdlLogPrintf(CTDL_DEBUG, "Failed to acquire private room\n");
+                               syslog(LOG_DEBUG, "Failed to acquire private room\n");
                        } else {
                                memcpy(&CC->room, &QRscratch,
                                        sizeof(struct ctdlroom));
@@ -1342,7 +1342,7 @@ int CtdlRenameRoom(char *old_name, char *new_name, int new_floor) {
        long owner = 0L;
        char actual_old_name[ROOMNAMELEN];
 
-       CtdlLogPrintf(CTDL_DEBUG, "CtdlRenameRoom(%s, %s, %d)\n",
+       syslog(LOG_DEBUG, "CtdlRenameRoom(%s, %s, %d)\n",
                old_name, new_name, new_floor);
 
        if (new_floor >= 0) {
@@ -1433,11 +1433,11 @@ int CtdlRenameRoom(char *old_name, char *new_name, int new_floor) {
                lgetfloor(&flbuf, old_floor);
                --flbuf.f_ref_count;
                lputfloor(&flbuf, old_floor);
-               CtdlLogPrintf(CTDL_DEBUG, "Reference count for floor %d is now %d\n", old_floor, flbuf.f_ref_count);
+               syslog(LOG_DEBUG, "Reference count for floor %d is now %d\n", old_floor, flbuf.f_ref_count);
                lgetfloor(&flbuf, new_floor);
                ++flbuf.f_ref_count;
                lputfloor(&flbuf, new_floor);
-               CtdlLogPrintf(CTDL_DEBUG, "Reference count for floor %d is now %d\n", new_floor, flbuf.f_ref_count);
+               syslog(LOG_DEBUG, "Reference count for floor %d is now %d\n", new_floor, flbuf.f_ref_count);
        }
 
        /* ...and everybody say "YATTA!" */     
@@ -1686,7 +1686,7 @@ void CtdlScheduleRoomForDeletion(struct ctdlroom *qrbuf)
        char old_name[ROOMNAMELEN];
        static int seq = 0;
 
-       CtdlLogPrintf(CTDL_NOTICE, "Scheduling room <%s> for deletion\n",
+       syslog(LOG_NOTICE, "Scheduling room <%s> for deletion\n",
                qrbuf->QRname);
 
        safestrncpy(old_name, qrbuf->QRname, sizeof old_name);
@@ -1724,7 +1724,7 @@ void CtdlDeleteRoom(struct ctdlroom *qrbuf)
        char filename[100];
        /* TODO: filename magic? does this realy work? */
 
-       CtdlLogPrintf(CTDL_NOTICE, "Deleting room <%s>\n", qrbuf->QRname);
+       syslog(LOG_NOTICE, "Deleting room <%s>\n", qrbuf->QRname);
 
        /* Delete the info file */
        assoc_file_name(filename, sizeof filename, qrbuf, ctdl_info_dir);
@@ -1855,11 +1855,11 @@ unsigned CtdlCreateRoom(char *new_room_name,
        struct floor flbuf;
        visit vbuf;
 
-       CtdlLogPrintf(CTDL_DEBUG, "CtdlCreateRoom(name=%s, type=%d, view=%d)\n",
+       syslog(LOG_DEBUG, "CtdlCreateRoom(name=%s, type=%d, view=%d)\n",
                new_room_name, new_room_type, new_room_view);
 
        if (CtdlGetRoom(&qrbuf, new_room_name) == 0) {
-               CtdlLogPrintf(CTDL_DEBUG, "%s already exists.\n", new_room_name);
+               syslog(LOG_DEBUG, "%s already exists.\n", new_room_name);
                return(0);
        }
 
@@ -2067,9 +2067,9 @@ void cmd_einf(char *ok)
                return;
        }
        assoc_file_name(infofilename, sizeof infofilename, &CC->room, ctdl_info_dir);
-       CtdlLogPrintf(CTDL_DEBUG, "opening\n");
+       syslog(LOG_DEBUG, "opening\n");
        fp = fopen(infofilename, "w");
-       CtdlLogPrintf(CTDL_DEBUG, "checking\n");
+       syslog(LOG_DEBUG, "checking\n");
        if (fp == NULL) {
                cprintf("%d Cannot open %s: %s\n",
                  ERROR + INTERNAL_ERROR, infofilename, strerror(errno));
index cd89694d14ca20bc90db68fc999b24aa98c08621..b9eeef46f8d9c9fff224c1c7d2489cdb502e8a9b 100755 (executable)
@@ -81,7 +81,7 @@ cat <<EOF  >$U_FILE
 void upgrade_modules (void)
 {
 
-    CtdlLogPrintf (CTDL_INFO, "Upgrade modules.\n");
+    syslog(LOG_INFO, "Upgrade modules.\n");
 
 EOF
 
@@ -118,17 +118,17 @@ void initialise_modules (int threading)
     nSizErrmsg = 0;
 
     if (threading)
-        CtdlLogPrintf (CTDL_INFO, "Initialize modules, CtdlThreads enabled.\n");
+        syslog(LOG_INFO, "Initialize modules, CtdlThreads enabled.\n");
     else
-        CtdlLogPrintf (CTDL_INFO, "Initialize modules, CtdlThreads not yet enabled.\n");
+        syslog(LOG_INFO, "Initialize modules, CtdlThreads not yet enabled.\n");
 /* static server initialization: */
-        CtdlLogPrintf(CTDL_INFO, "Loaded module: %s\n", CTDL_INIT_CALL(citserver));
-        CtdlLogPrintf(CTDL_INFO, "Loaded module: %s\n", CTDL_INIT_CALL(control));
-        CtdlLogPrintf(CTDL_INFO, "Loaded module: %s\n", CTDL_INIT_CALL(euidindex));
-        CtdlLogPrintf(CTDL_INFO, "Loaded module: %s\n", CTDL_INIT_CALL(file_ops));
-        CtdlLogPrintf(CTDL_INFO, "Loaded module: %s\n", CTDL_INIT_CALL(msgbase));
-        CtdlLogPrintf(CTDL_INFO, "Loaded module: %s\n", CTDL_INIT_CALL(room_ops));
-        CtdlLogPrintf(CTDL_INFO, "Loaded module: %s\n", CTDL_INIT_CALL(user_ops));
+        syslog(LOG_INFO, "Loaded module: %s\n", CTDL_INIT_CALL(citserver));
+        syslog(LOG_INFO, "Loaded module: %s\n", CTDL_INIT_CALL(control));
+        syslog(LOG_INFO, "Loaded module: %s\n", CTDL_INIT_CALL(euidindex));
+        syslog(LOG_INFO, "Loaded module: %s\n", CTDL_INIT_CALL(file_ops));
+        syslog(LOG_INFO, "Loaded module: %s\n", CTDL_INIT_CALL(msgbase));
+        syslog(LOG_INFO, "Loaded module: %s\n", CTDL_INIT_CALL(room_ops));
+        syslog(LOG_INFO, "Loaded module: %s\n", CTDL_INIT_CALL(user_ops));
 /* dynamic modules: */
 
 EOF
@@ -165,7 +165,7 @@ do
                RES_OUT=`echo $RES | cut -b2-`
                /usr/bin/printf "Found entry point in file $i\n"
 cat <<EOF  >> $C_FILE
-       CtdlLogPrintf(CTDL_INFO, "Loaded module: %s\n", CTDL_INIT_CALL($RES_OUT));
+       syslog(LOG_INFO, "Loaded module: %s\n", CTDL_INIT_CALL($RES_OUT));
 
 EOF
 cat <<EOF >>$H_FILE
@@ -177,7 +177,7 @@ EOF
                RES_OUT=`echo $RES | cut -b2-`
                /usr/bin/printf "Found upgrade point in file $i\n"
 cat <<EOF  >> $U_FILE
-       CtdlLogPrintf (CTDL_INFO, "%s\n", CTDL_UPGRADE_CALL($RES_OUT));
+       syslog(LOG_INFO, "%s\n", CTDL_UPGRADE_CALL($RES_OUT));
 
 EOF
 cat <<EOF >>$H_FILE
@@ -215,7 +215,7 @@ EOF
                                                /usr/bin/printf "Found entry point in file modules/$j/$k\n"
 # Add this entry point to the .c file
 cat <<EOF >> $C_FILE
-       CtdlLogPrintf(CTDL_INFO, "Loaded module: %s\n", CTDL_INIT_CALL($RES_OUT));
+       syslog(LOG_INFO, "Loaded module: %s\n", CTDL_INIT_CALL($RES_OUT));
 EOF
 # Add this entry point to the .h file
 cat <<EOF >> $H_FILE
@@ -228,7 +228,7 @@ EOF
                                                /usr/bin/printf "Found upgrade point in file modules/$j/$k\n"
 # Add this entry point to the .c file
 cat <<EOF >> $U_FILE
-       CtdlLogPrintf (CTDL_INFO, "%s\n", CTDL_UPGRADE_CALL($RES_OUT));
+       syslog(LOG_INFO, "%s\n", CTDL_UPGRADE_CALL($RES_OUT));
 EOF
 # Add this entry point to the .h file
 cat <<EOF >> $H_FILE
@@ -271,7 +271,7 @@ EOF
                                                RES_OUT=`echo $RES | cut -b2-`
                                                /usr/bin/printf "Found entry point in file user_modules/$j/$k\n"
 cat <<EOF >> $C_FILE
-       CtdlLogPrintf(CTDL_INFO, "Loaded module: %s\n", CTDL_INIT_CALL($RES_OUT));
+       syslog(LOG_INFO, "Loaded module: %s\n", CTDL_INIT_CALL($RES_OUT));
 EOF
 cat <<EOF >> $H_FILE
 CTDL_MODULE_INIT($RES_OUT);
@@ -282,7 +282,7 @@ EOF
                                                RES_OUT=`echo $RES | cut -b2-`
                                                /usr/bin/printf "Found upgrade point in file user_modules/$j/$k\n"
 cat <<EOF >> $U_FILE
-       CtdlLogPrintf (CTDL_INFO, "%s\n", CTDL_UPGRADE_CALL($RES_OUT));
+       syslog(LOG_INFO, "%s\n", CTDL_UPGRADE_CALL($RES_OUT));
 EOF
 cat <<EOF >> $H_FILE
 CTDL_MODULE_UPGRADE($RES_OUT);
index 7bcae2b12e394cff537075d3be48ddf2246b84d9..df80cc845424658f94cfc7c5d4f3d706824f8aaa 100644 (file)
@@ -1,6 +1,22 @@
 /*
  * Citadel Dynamic Loading Module
  * Written by Brian Costello <btx@calyx.net>
+ *
+ * Copyright (c) 1987-2011 by the citadel.org team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include "sysdep.h"
@@ -12,6 +28,7 @@
 #include <string.h>
 #include <limits.h>
 #include <ctype.h>
+#include <syslog.h>
 #include <libcitadel.h>
 #include "citadel.h"
 #include "server.h"
@@ -109,8 +126,8 @@ void LogPrintMessages(long err)
 
        snprintf(Message, n * SIZ, ErrGeneral, Short, Where, List, Hint, DetailList);
 
-       CtdlLogPrintf(CTDL_DEBUG,Message);
-       CtdlLogPrintf(CTDL_DEBUG,ErrSubject);
+       syslog(LOG_EMERG,Message);
+       syslog(LOG_EMERG,ErrSubject);
        quickie_message("Citadel", NULL, NULL, AIDEROOM, Message, FMT_FIXED, ErrSubject);
        if (errormessages!=NULL) free (errormessages);
        errormessages = NULL;
@@ -225,7 +242,7 @@ void CtdlRegisterProtoHook(void (*handler) (char *), char *cmd, char *desc)
        p->desc = desc;
 
        Put(ProtoHookList, cmd, 4, p, NULL);
-       CtdlLogPrintf(CTDL_INFO, "Registered server command %s (%s)\n", cmd, desc);
+       syslog(LOG_INFO, "Registered server command %s (%s)\n", cmd, desc);
 }
 
 void CtdlDestroyProtoHooks(void)
@@ -246,7 +263,7 @@ void CtdlRegisterCleanupHook(void (*fcn_ptr) (void))
        newfcn->h_function_pointer = fcn_ptr;
        CleanupHookTable = newfcn;
 
-       CtdlLogPrintf(CTDL_INFO, "Registered a new cleanup function\n");
+       syslog(LOG_INFO, "Registered a new cleanup function\n");
 }
 
 
@@ -258,7 +275,7 @@ void CtdlUnregisterCleanupHook(void (*fcn_ptr) (void))
                /* This will also remove duplicates if any */
                while (cur != NULL &&
                                fcn_ptr == cur->h_function_pointer) {
-                       CtdlLogPrintf(CTDL_INFO, "Unregistered cleanup function\n");
+                       syslog(LOG_INFO, "Unregistered cleanup function\n");
                        p = cur->next;
                        if (cur == CleanupHookTable) {
                                CleanupHookTable = p;
@@ -276,7 +293,7 @@ void CtdlDestroyCleanupHooks(void)
        cur = CleanupHookTable;
        while (cur != NULL)
        {
-               CtdlLogPrintf(CTDL_INFO, "Destroyed cleanup function\n");
+               syslog(LOG_INFO, "Destroyed cleanup function\n");
                p = cur->next;
                free(cur);
                cur = p;
@@ -297,7 +314,7 @@ void CtdlRegisterSessionHook(void (*fcn_ptr) (void), int EventType)
        newfcn->eventtype = EventType;
        SessionHookTable = newfcn;
 
-       CtdlLogPrintf(CTDL_INFO, "Registered a new session function (type %d)\n",
+       syslog(LOG_INFO, "Registered a new session function (type %d)\n",
                EventType);
 }
 
@@ -311,7 +328,7 @@ void CtdlUnregisterSessionHook(void (*fcn_ptr) (void), int EventType)
                while (cur != NULL &&
                                fcn_ptr == cur->h_function_pointer &&
                                EventType == cur->eventtype) {
-                       CtdlLogPrintf(CTDL_INFO, "Unregistered session function (type %d)\n",
+                       syslog(LOG_INFO, "Unregistered session function (type %d)\n",
                                        EventType);
                        p = cur->next;
                        if (cur == SessionHookTable) {
@@ -330,7 +347,7 @@ void CtdlDestroySessionHooks(void)
        cur = SessionHookTable;
        while (cur != NULL)
        {
-               CtdlLogPrintf(CTDL_INFO, "Destroyed session function\n");
+               syslog(LOG_INFO, "Destroyed session function\n");
                p = cur->next;
                free(cur);
                cur = p;
@@ -351,7 +368,7 @@ void CtdlRegisterUserHook(void (*fcn_ptr) (struct ctdluser *), int EventType)
        newfcn->eventtype = EventType;
        UserHookTable = newfcn;
 
-       CtdlLogPrintf(CTDL_INFO, "Registered a new user function (type %d)\n",
+       syslog(LOG_INFO, "Registered a new user function (type %d)\n",
                EventType);
 }
 
@@ -365,7 +382,7 @@ void CtdlUnregisterUserHook(void (*fcn_ptr) (struct ctdluser *), int EventType)
                while (cur != NULL &&
                                fcn_ptr == cur->h_function_pointer &&
                                EventType == cur->eventtype) {
-                       CtdlLogPrintf(CTDL_INFO, "Unregistered user function (type %d)\n",
+                       syslog(LOG_INFO, "Unregistered user function (type %d)\n",
                                        EventType);
                        p = cur->next;
                        if (cur == UserHookTable) {
@@ -384,7 +401,7 @@ void CtdlDestroyUserHooks(void)
        cur = UserHookTable;
        while (cur != NULL)
        {
-               CtdlLogPrintf(CTDL_INFO, "Destroyed user function \n");
+               syslog(LOG_INFO, "Destroyed user function \n");
                p = cur->next;
                free(cur);
                cur = p;
@@ -406,7 +423,7 @@ void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *),
        newfcn->eventtype = EventType;
        MessageHookTable = newfcn;
 
-       CtdlLogPrintf(CTDL_INFO, "Registered a new message function (type %d)\n",
+       syslog(LOG_INFO, "Registered a new message function (type %d)\n",
                EventType);
 }
 
@@ -421,7 +438,7 @@ void CtdlUnregisterMessageHook(int (*handler)(struct CtdlMessage *),
                while (cur != NULL &&
                                handler == cur->h_function_pointer &&
                                EventType == cur->eventtype) {
-                       CtdlLogPrintf(CTDL_INFO, "Unregistered message function (type %d)\n",
+                       syslog(LOG_INFO, "Unregistered message function (type %d)\n",
                                        EventType);
                        p = cur->next;
                        if (cur == MessageHookTable) {
@@ -440,7 +457,7 @@ void CtdlDestroyMessageHook(void)
        cur = MessageHookTable; 
        while (cur != NULL)
        {
-               CtdlLogPrintf(CTDL_INFO, "Destroyed message function (type %d)\n", cur->eventtype);
+               syslog(LOG_INFO, "Destroyed message function (type %d)\n", cur->eventtype);
                p = cur->next;
                free(cur);
                cur = p;
@@ -459,7 +476,7 @@ void CtdlRegisterRoomHook(int (*fcn_ptr)(struct ctdlroom *))
        newfcn->fcn_ptr = fcn_ptr;
        RoomHookTable = newfcn;
 
-       CtdlLogPrintf(CTDL_INFO, "Registered a new room function\n");
+       syslog(LOG_INFO, "Registered a new room function\n");
 }
 
 
@@ -469,7 +486,7 @@ void CtdlUnregisterRoomHook(int (*fcn_ptr)(struct ctdlroom *))
 
        for (cur = RoomHookTable; cur != NULL; cur = cur->next) {
                while (cur != NULL && fcn_ptr == cur->fcn_ptr) {
-                       CtdlLogPrintf(CTDL_INFO, "Unregistered room function\n");
+                       syslog(LOG_INFO, "Unregistered room function\n");
                        p = cur->next;
                        if (cur == RoomHookTable) {
                                RoomHookTable = p;
@@ -488,7 +505,7 @@ void CtdlDestroyRoomHooks(void)
        cur = RoomHookTable;
        while (cur != NULL)
        {
-               CtdlLogPrintf(CTDL_INFO, "Destroyed room function\n");
+               syslog(LOG_INFO, "Destroyed room function\n");
                p = cur->next;
                free(cur);
                cur = p;
@@ -506,7 +523,7 @@ void CtdlRegisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) )
        newfcn->h_function_pointer = handler;
        NetprocHookTable = newfcn;
 
-       CtdlLogPrintf(CTDL_INFO, "Registered a new netproc function\n");
+       syslog(LOG_INFO, "Registered a new netproc function\n");
 }
 
 
@@ -518,7 +535,7 @@ void CtdlUnregisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) )
                /* This will also remove duplicates if any */
                while (cur != NULL &&
                                handler == cur->h_function_pointer ) {
-                       CtdlLogPrintf(CTDL_INFO, "Unregistered netproc function\n");
+                       syslog(LOG_INFO, "Unregistered netproc function\n");
                        p = cur->next;
                        if (cur == NetprocHookTable) {
                                NetprocHookTable = p;
@@ -536,7 +553,7 @@ void CtdlDestroyNetprocHooks(void)
        cur = NetprocHookTable;
        while (cur != NULL)
        {
-               CtdlLogPrintf(CTDL_INFO, "Destroyed netproc function\n");
+               syslog(LOG_INFO, "Destroyed netproc function\n");
                p = cur->next;
                free(cur);
                cur = p;
@@ -555,7 +572,7 @@ void CtdlRegisterDeleteHook(void (*handler)(char *, long) )
        newfcn->h_function_pointer = handler;
        DeleteHookTable = newfcn;
 
-       CtdlLogPrintf(CTDL_INFO, "Registered a new delete function\n");
+       syslog(LOG_INFO, "Registered a new delete function\n");
 }
 
 
@@ -567,7 +584,7 @@ void CtdlUnregisterDeleteHook(void (*handler)(char *, long) )
                /* This will also remove duplicates if any */
                while (cur != NULL &&
                                handler == cur->h_function_pointer ) {
-                       CtdlLogPrintf(CTDL_INFO, "Unregistered delete function\n");
+                       syslog(LOG_INFO, "Unregistered delete function\n");
                        p = cur->next;
                        if (cur == DeleteHookTable) {
                                DeleteHookTable = p;
@@ -584,7 +601,7 @@ void CtdlDestroyDeleteHooks(void)
        cur = DeleteHookTable;
        while (cur != NULL)
        {
-               CtdlLogPrintf(CTDL_INFO, "Destroyed delete function\n");
+               syslog(LOG_INFO, "Destroyed delete function\n");
                p = cur->next;
                free(cur);
                cur = p;                
@@ -606,7 +623,7 @@ void CtdlRegisterFixedOutputHook(char *content_type, void (*handler)(char *, int
        safestrncpy(newfcn->content_type, content_type, sizeof newfcn->content_type);
        FixedOutputTable = newfcn;
 
-       CtdlLogPrintf(CTDL_INFO, "Registered a new fixed output function for %s\n", newfcn->content_type);
+       syslog(LOG_INFO, "Registered a new fixed output function for %s\n", newfcn->content_type);
 }
 
 
@@ -617,7 +634,7 @@ void CtdlUnregisterFixedOutputHook(char *content_type)
        for (cur = FixedOutputTable; cur != NULL; cur = cur->next) {
                /* This will also remove duplicates if any */
                while (cur != NULL && (!strcasecmp(content_type, cur->content_type))) {
-                       CtdlLogPrintf(CTDL_INFO, "Unregistered fixed output function for %s\n", content_type);
+                       syslog(LOG_INFO, "Unregistered fixed output function for %s\n", content_type);
                        p = cur->next;
                        if (cur == FixedOutputTable) {
                                FixedOutputTable = p;
@@ -635,7 +652,7 @@ void CtdlDestroyFixedOutputHooks(void)
        cur = FixedOutputTable; 
        while (cur != NULL)
        {
-               CtdlLogPrintf(CTDL_INFO, "Destroyed fixed output function for %s\n", cur->content_type);
+               syslog(LOG_INFO, "Destroyed fixed output function for %s\n", cur->content_type);
                p = cur->next;
                free(cur);
                cur = p;
@@ -672,7 +689,7 @@ void CtdlRegisterXmsgHook(int (*fcn_ptr) (char *, char *, char *, char *), int o
        newfcn->order = order;
        newfcn->h_function_pointer = fcn_ptr;
        XmsgHookTable = newfcn;
-       CtdlLogPrintf(CTDL_INFO, "Registered a new x-msg function (priority %d)\n", order);
+       syslog(LOG_INFO, "Registered a new x-msg function (priority %d)\n", order);
 }
 
 
@@ -685,7 +702,7 @@ void CtdlUnregisterXmsgHook(int (*fcn_ptr) (char *, char *, char *, char *), int
                while (cur != NULL &&
                                fcn_ptr == cur->h_function_pointer &&
                                order == cur->order) {
-                       CtdlLogPrintf(CTDL_INFO, "Unregistered x-msg function "
+                       syslog(LOG_INFO, "Unregistered x-msg function "
                                        "(priority %d)\n", order);
                        p = cur->next;
                        if (cur == XmsgHookTable) {
@@ -704,7 +721,7 @@ void CtdlDestroyXmsgHooks(void)
        cur = XmsgHookTable;
        while (cur != NULL)
        {
-               CtdlLogPrintf(CTDL_INFO, "Destroyed x-msg function "
+               syslog(LOG_INFO, "Destroyed x-msg function "
                        "(priority %d)\n", cur->order);
                p = cur->next;
                        
@@ -743,7 +760,7 @@ void CtdlRegisterServiceHook(int tcp_port,
                snprintf(message, SIZ, "Unix domain socket '%s': ", sockpath);
        }
        else if (tcp_port <= 0) {       /* port -1 to disable */
-               CtdlLogPrintf(CTDL_INFO, "Service %s has been manually disabled, skipping\n", ServiceName);
+               syslog(LOG_INFO, "Service %s has been manually disabled, skipping\n", ServiceName);
                free (message);
                free(newfcn);
                return;
@@ -760,12 +777,12 @@ void CtdlRegisterServiceHook(int tcp_port,
        if (newfcn->msock > 0) {
                ServiceHookTable = newfcn;
                strcat(message, "registered.");
-               CtdlLogPrintf(CTDL_INFO, "%s\n", message);
+               syslog(LOG_INFO, "%s\n", message);
        }
        else {
                AddPortError(message, error);
                strcat(message, "FAILED.");
-               CtdlLogPrintf(CTDL_CRIT, "%s\n", message);
+               syslog(LOG_CRIT, "%s\n", message);
                free(newfcn);
        }
        free(message);
@@ -792,12 +809,12 @@ void CtdlUnregisterServiceHook(int tcp_port, char *sockpath,
                                tcp_port == cur->tcp_port) {
                        close(cur->msock);
                        if (sockpath) {
-                               CtdlLogPrintf(CTDL_INFO, "Closed UNIX domain socket %s\n",
+                               syslog(LOG_INFO, "Closed UNIX domain socket %s\n",
                                                sockpath);
                        } else if (tcp_port) {
-                               CtdlLogPrintf(CTDL_INFO, "Closed TCP port %d\n", tcp_port);
+                               syslog(LOG_INFO, "Closed TCP port %d\n", tcp_port);
                        } else {
-                               CtdlLogPrintf(CTDL_INFO, "Unregistered service \"%s\"\n", cur->ServiceName);
+                               syslog(LOG_INFO, "Unregistered service \"%s\"\n", cur->ServiceName);
                        }
                        p = cur->next;
                        if (cur == ServiceHookTable) {
@@ -823,11 +840,11 @@ void CtdlShutdownServiceHooks(void)
                        close(cur->msock);
                        cur->msock = -1;
                        if (cur->sockpath != NULL){
-                               CtdlLogPrintf(CTDL_INFO, "[%s] Closed UNIX domain socket %s\n",
+                               syslog(LOG_INFO, "[%s] Closed UNIX domain socket %s\n",
                                              cur->ServiceName,
                                              cur->sockpath);
                        } else {
-                               CtdlLogPrintf(CTDL_INFO, "[%s] closing service\n", 
+                               syslog(LOG_INFO, "[%s] closing service\n", 
                                              cur->ServiceName);
                        }
                }
@@ -844,12 +861,12 @@ void CtdlDestroyServiceHook(void)
        {
                close(cur->msock);
                if (cur->sockpath) {
-                       CtdlLogPrintf(CTDL_INFO, "Closed UNIX domain socket %s\n",
+                       syslog(LOG_INFO, "Closed UNIX domain socket %s\n",
                                cur->sockpath);
                } else if (cur->tcp_port) {
-                       CtdlLogPrintf(CTDL_INFO, "Closed TCP port %d\n", cur->tcp_port);
+                       syslog(LOG_INFO, "Closed TCP port %d\n", cur->tcp_port);
                } else {
-                       CtdlLogPrintf(CTDL_INFO, "Destroyed service \"%s\"\n", cur->ServiceName);
+                       syslog(LOG_INFO, "Destroyed service \"%s\"\n", cur->ServiceName);
                }
                p = cur->next;
                free(cur);
@@ -873,7 +890,7 @@ void CtdlRegisterSearchFuncHook(void (*fcn_ptr)(int *, long **, const char *), c
        newfcn->fcn_ptr = fcn_ptr;
        SearchFunctionHookTable = newfcn;
 
-       CtdlLogPrintf(CTDL_INFO, "Registered a new search function (%s)\n", name);
+       syslog(LOG_INFO, "Registered a new search function (%s)\n", name);
 }
 
 void CtdlUnregisterSearchFuncHook(void (*fcn_ptr)(int *, long **, const char *), char *name)
@@ -882,7 +899,7 @@ void CtdlUnregisterSearchFuncHook(void (*fcn_ptr)(int *, long **, const char *),
        
        for (cur = SearchFunctionHookTable; cur != NULL; cur = cur->next) {
                while (fcn_ptr && (cur->fcn_ptr == fcn_ptr) && name && !strcmp(name, cur->name)) {
-                       CtdlLogPrintf(CTDL_INFO, "Unregistered search function(%s)\n", name);
+                       syslog(LOG_INFO, "Unregistered search function(%s)\n", name);
                        p = cur->next;
                        if (cur == SearchFunctionHookTable) {
                                SearchFunctionHookTable = p;
@@ -952,11 +969,11 @@ int PerformMessageHooks(struct CtdlMessage *msg, int EventType)
 
        /* Other code may elect to protect this message from server-side
         * handlers; if this is the case, don't do anything.
-       CtdlLogPrintf(CTDL_DEBUG, "** Event type is %d, flags are %d\n",
+       syslog(LOG_DEBUG, "** Event type is %d, flags are %d\n",
                EventType, msg->cm_flags);
         */
        if (msg->cm_flags & CM_SKIP_HOOKS) {
-               CtdlLogPrintf(CTDL_DEBUG, "Skipping hooks\n");
+               syslog(LOG_DEBUG, "Skipping hooks\n");
                return(0);
        }
 
@@ -982,7 +999,7 @@ int PerformRoomHooks(struct ctdlroom *target_room)
        struct RoomFunctionHook *fcn;
        int total_retval = 0;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Performing room hooks for <%s>\n", target_room->QRname);
+       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);
index d4558f86d5299c3061406adbe70a3d869d474ceb..86cf5b0b031eb7d1c0dc2792ac9d6bda00f6336c 100644 (file)
@@ -1,9 +1,9 @@
 /*
  * citserver's main() function lives here.
  * 
- * Copyright (c) 1987-2010 by the citadel.org team
+ * Copyright (c) 1987-2011 by the citadel.org team
  *
- * This program is free software; you can redistribute it and/or modify
+ * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
@@ -15,7 +15,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
 #include "sysdep.h"
@@ -105,9 +105,9 @@ int main(int argc, char **argv)
        int home=0;
        int dbg=0;
        int have_log=0;
-       int have_minus_x=0;
        char relhome[PATH_MAX]="";
        char ctdldir[PATH_MAX]=CTDLDIR;
+       int syslog_facility = LOG_DAEMON;
 #ifdef HAVE_RUN_DIR
        struct stat filestats;
 #endif
@@ -123,7 +123,7 @@ int main(int argc, char **argv)
 
 
        /* initialise semaphores here. Patch by Matt and davew
-        * its called here as they are needed by CtdlLogPrintf for thread safety
+        * its called here as they are needed by syslog for thread safety
         */
        InitialiseSemaphores();
        
@@ -136,7 +136,6 @@ int main(int argc, char **argv)
                if (!strncmp(argv[a], "-l", 2)) {
                        safestrncpy(facility, &argv[a][2], sizeof(facility));
                        syslog_facility = SyslogFacility(facility);
-                       enable_syslog = 1;
                }
 
                /* run in the background if -d was specified */
@@ -149,12 +148,6 @@ int main(int argc, char **argv)
                        statcount = atoi(&argv[a][2]);
                }
 
-               /* -x specifies the desired logging level */
-               else if (!strncmp(argv[a], "-x", 2)) {
-                       verbosity = atoi(&argv[a][2]);
-                       have_minus_x = 1;
-               }
-
                else if (!strncmp(argv[a], "-h", 2)) {
                        relh=argv[a][2]!='/';
                        if (!relh) safestrncpy(ctdl_home_directory, &argv[a][2],
@@ -165,10 +158,14 @@ int main(int argc, char **argv)
                        home=1;
                }
 
+               else if (!strncmp(argv[a], "-x", 2)) {
+                       /* deprecated */
+               }
+
                else if (!strncmp(argv[a], "-t", 2)) {
                        if (freopen(&argv[a][2], "w", stderr) != stderr)
                        {
-                               CtdlLogPrintf(CTDL_EMERG, 
+                               syslog(LOG_EMERG, 
                                              "unable to open your trace log [%s]: %s", 
                                              &argv[a][2], 
                                              strerror(errno));
@@ -189,19 +186,22 @@ int main(int argc, char **argv)
 
                /* any other parameter makes it crash and burn */
                else {
-                       CtdlLogPrintf(CTDL_EMERG,       "citserver: usage: "
+                       fprintf(stderr, "citserver: usage: "
                                        "citserver "
                                        "[-lLogFacility] "
-                                       "[-d] [-D] [-s]"
-                                       " [-tTraceFile]"
-                                       " [-xLogLevel] [-hHomeDir]\n");
+                                       "[-d] [-D] [-s] "
+                                       "[-tTraceFile] "
+                                       "[-hHomeDir]\n"
+                       );
                        exit(1);
                }
 
        }
 
-       if (have_minus_x && running_as_daemon && have_log)
-               print_to_logfile = 1;
+       openlog("citserver",
+               ( running_as_daemon ? (LOG_PID) : (LOG_PID | LOG_PERROR) ),
+               syslog_facility
+       );
 
        calc_dirs_n_files(relh, home, relhome, ctdldir, dbg);
        /* daemonize, if we were asked to */
@@ -226,36 +226,26 @@ int main(int argc, char **argv)
        eCrash_RegisterThread("MasterThread", 0);
 #endif
 
-       /* Initialize the syslogger.  Yes, we are really using 0 as the
-        * facility, because we are going to bitwise-OR the facility to
-        * the severity of each message, allowing us to write to other
-        * facilities when we need to...
-        */
-       if (enable_syslog) {
-               openlog("citadel", LOG_NDELAY, 0);
-               setlogmask(LOG_UPTO(verbosity));
-       }
-       
        /* Tell 'em who's in da house */
-       CtdlLogPrintf(CTDL_NOTICE, "\n");
-       CtdlLogPrintf(CTDL_NOTICE, "\n");
-       CtdlLogPrintf(CTDL_NOTICE,
+       syslog(LOG_NOTICE, "\n");
+       syslog(LOG_NOTICE, "\n");
+       syslog(LOG_NOTICE,
                "*** Citadel server engine v%d.%02d (build %s) ***\n",
                (REV_LEVEL/100), (REV_LEVEL%100), svn_revision());
-       CtdlLogPrintf(CTDL_NOTICE, "Copyright (C) 1987-2010 by the Citadel development team.\n");
-       CtdlLogPrintf(CTDL_NOTICE, "This program is distributed under the terms of the GNU "
+       syslog(LOG_NOTICE, "Copyright (C) 1987-2010 by the Citadel development team.\n");
+       syslog(LOG_NOTICE, "This program is distributed under the terms of the GNU "
                                        "General Public License.\n");
-       CtdlLogPrintf(CTDL_NOTICE, "\n");
-       CtdlLogPrintf(CTDL_DEBUG, "Called as: %s\n", argv[0]);
-       CtdlLogPrintf(CTDL_INFO, "%s\n", libcitadel_version_string());
+       syslog(LOG_NOTICE, "\n");
+       syslog(LOG_DEBUG, "Called as: %s\n", argv[0]);
+       syslog(LOG_INFO, "%s\n", libcitadel_version_string());
 
        /* Load site-specific parameters, and set the ipgm secret */
-       CtdlLogPrintf(CTDL_INFO, "Loading citadel.config\n");
+       syslog(LOG_INFO, "Loading citadel.config\n");
        get_config();
        config.c_ipgm_secret = rand();
 
        /* get_control() MUST MUST MUST be called BEFORE the databases are opened!! */
-       CtdlLogPrintf(CTDL_INFO, "Acquiring control record\n");
+       syslog(LOG_INFO, "Acquiring control record\n");
        get_control();
 
        put_config();
@@ -275,12 +265,12 @@ int main(int argc, char **argv)
 #endif // HAVE_GETPWUID_R
 
                if ((mkdir(ctdl_run_dir, 0755) != 0) && (errno != EEXIST))
-                       CtdlLogPrintf(CTDL_EMERG, 
+                       syslog(LOG_EMERG, 
                                      "unable to create run directory [%s]: %s", 
                                      ctdl_run_dir, strerror(errno));
 
                if (chown(ctdl_run_dir, config.c_ctdluid, (pwp==NULL)?-1:pw.pw_gid) != 0)
-                       CtdlLogPrintf(CTDL_EMERG, 
+                       syslog(LOG_EMERG, 
                                      "unable to set the access rights for [%s]: %s", 
                                      ctdl_run_dir, strerror(errno));
        }
@@ -304,7 +294,7 @@ int main(int argc, char **argv)
        /*
         * Run any upgrade entry points
         */
-       CtdlLogPrintf(CTDL_INFO, "Upgrading modules.\n");
+       syslog(LOG_INFO, "Upgrading modules.\n");
        upgrade_modules();
        
 /**
@@ -344,7 +334,7 @@ int main(int argc, char **argv)
        /*
         * Load any server-side extensions available here.
         */
-       CtdlLogPrintf(CTDL_INFO, "Initializing server extensions\n");
+       syslog(LOG_INFO, "Initializing server extensions\n");
        size = strlen(ctdl_home_directory) + 9;
        
        initialise_modules(0);
@@ -384,18 +374,18 @@ int main(int argc, char **argv)
 #endif // HAVE_GETPWUID_R
 
                if (pwp == NULL)
-                       CtdlLogPrintf(CTDL_CRIT, "WARNING: getpwuid(%ld): %s\n"
+                       syslog(LOG_CRIT, "WARNING: getpwuid(%ld): %s\n"
                                   "Group IDs will be incorrect.\n", (long)CTDLUID,
                                strerror(errno));
                else {
                        initgroups(pw.pw_name, pw.pw_gid);
                        if (setgid(pw.pw_gid))
-                               CtdlLogPrintf(CTDL_CRIT, "setgid(%ld): %s\n", (long)pw.pw_gid,
+                               syslog(LOG_CRIT, "setgid(%ld): %s\n", (long)pw.pw_gid,
                                        strerror(errno));
                }
-               CtdlLogPrintf(CTDL_INFO, "Changing uid to %ld\n", (long)CTDLUID);
+               syslog(LOG_INFO, "Changing uid to %ld\n", (long)CTDLUID);
                if (setuid(CTDLUID) != 0) {
-                       CtdlLogPrintf(CTDL_CRIT, "setuid() failed: %s\n", strerror(errno));
+                       syslog(LOG_CRIT, "setuid() failed: %s\n", strerror(errno));
                }
 #if defined (HAVE_SYS_PRCTL_H) && defined (PR_SET_DUMPABLE)
                prctl(PR_SET_DUMPABLE, 1);
index 0078a161b811a5c307481dc5eba4019d8f409828..5468d24ca7519af883d5aa7a1209466479b31d95 100644 (file)
@@ -1,6 +1,5 @@
 /*
  * Citadel "system dependent" stuff.
- * See COPYING for copyright information.
  *
  * Here's where we (hopefully) have most parts of the Citadel server that
  * would need to be altered to run the server in a non-POSIX environment.
@@ -8,6 +7,21 @@
  * If we ever port to a different platform and either have multiple
  * variants of this file or simply load it up with #ifdefs.
  *
+ * Copyright (c) 1987-2011 by the citadel.org team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include "sysdep.h"
@@ -87,89 +101,6 @@ struct igheap *igheap = NULL;
 #endif
 
 
-int verbosity = DEFAULT_VERBOSITY;             /* Logging level */
-
-int syslog_facility = LOG_DAEMON;
-int enable_syslog = 0;
-int print_to_logfile = 1;
-
-/*
- * CtdlLogPrintf()  ...   Write logging information
- */
-void CtdlLogPrintf(enum LogLevel loglevel, const char *format, ...) {   
-       va_list arg_ptr;
-       va_start(arg_ptr, format);
-       vCtdlLogPrintf(loglevel, format, arg_ptr);
-       va_end(arg_ptr);
-}
-
-void vCtdlLogPrintf(enum LogLevel loglevel, const char *format, va_list arg_ptr)
-{
-
-       if (enable_syslog) {
-               vsyslog((syslog_facility | loglevel), format, arg_ptr);
-       }
-
-       /* stderr output code */
-       if (enable_syslog || !print_to_logfile) return;
-
-       /* if we run in forground and syslog is disabled, log to terminal */
-       if (loglevel <= verbosity) { 
-               struct timeval tv;
-               struct tm tim;
-               time_t unixtime;
-               CitContext *CCC = CC;
-               ThreadTSD *cTSD = CTP;
-               CtdlThreadNode *node = NULL;
-               long lwpid = 0;
-               char formatbuf[SIZ];
-               char LWP[64];
-               char SESS[64];
-
-               if (cTSD != NULL) {
-                       node = cTSD->self;
-               }
-
-               if ((node != NULL) && (node->reltid != 0)) {
-                       lwpid = node->reltid;
-               }
-
-               gettimeofday(&tv, NULL);
-
-               /* Promote to time_t; types differ on some OSes (like darwin) */
-               unixtime = tv.tv_sec;
-               localtime_r(&unixtime, &tim);
-
-               *LWP = '\0';
-               if (lwpid != 0) {
-                       snprintf(LWP, 64, "[LWP:%ld] ", lwpid);
-               }
-                       
-               *SESS = '\0';
-               if (CCC != NULL) {
-                       if (CCC->cs_pid != 0) {
-                               snprintf(SESS, 64, " [%3d] ", CCC->cs_pid);
-                       }
-                       else if (CCC->user.usernum != 0) {
-                               snprintf(SESS, 64, " [:%ld] ", CCC->user.usernum);
-                       }
-               }
-
-               snprintf(formatbuf, SIZ, 
-                        "%04d/%02d/%02d %2d:%02d:%02d.%06ld %s%s%s",
-                        tim.tm_year + 1900, tim.tm_mon + 1,
-                        tim.tm_mday, tim.tm_hour, tim.tm_min,
-                        tim.tm_sec, (long)tv.tv_usec, 
-                        LWP, SESS, format
-               );
-
-               vfprintf(stderr, formatbuf, arg_ptr);   
-               fflush(stderr);
-       }
-}   
-
-
-
 /*
  * Signal handler to shut down the server.
  */
@@ -187,7 +118,7 @@ static RETSIGTYPE signal_cleanup(int signum) {
                Cc->self->signal = signum;
        else
        {
-               CtdlLogPrintf(CTDL_DEBUG, "Caught signal %d; shutting down.\n", signum);
+               syslog(LOG_DEBUG, "Caught signal %d; shutting down.\n", signum);
                exit_signal = signum;
        }
 }
@@ -227,7 +158,7 @@ void init_sysdep(void) {
         * session to which the calling thread is currently bound.
         */
        if (citthread_key_create(&MyConKey, NULL) != 0) {
-               CtdlLogPrintf(CTDL_CRIT, "Can't create TSD key: %s\n",
+               syslog(LOG_CRIT, "Can't create TSD key: %s\n",
                        strerror(errno));
        }
 
@@ -303,7 +234,7 @@ int ctdl_tcp_server(char *ip_addr, int port_number, int queue_len, char *errorme
                        snprintf(errormessage, SIZ,
                                 "Error binding to [%s] : %s", ip_addr, strerror(errno)
                        );
-                       CtdlLogPrintf(CTDL_ALERT, "%s\n", errormessage);
+                       syslog(LOG_ALERT, "%s\n", errormessage);
                        return (-1);
                }
        }
@@ -314,7 +245,7 @@ int ctdl_tcp_server(char *ip_addr, int port_number, int queue_len, char *errorme
                        snprintf(errormessage, SIZ,
                                 "Error binding to [%s] : %s", ip_addr, strerror(errno)
                        );
-                       CtdlLogPrintf(CTDL_ALERT, "%s\n", errormessage);
+                       syslog(LOG_ALERT, "%s\n", errormessage);
                        return (-1);
                }
        }
@@ -323,7 +254,7 @@ int ctdl_tcp_server(char *ip_addr, int port_number, int queue_len, char *errorme
                snprintf(errormessage, SIZ,
                         "Can't start: no port number specified."
                );
-               CtdlLogPrintf(CTDL_ALERT, "%s\n", errormessage);
+               syslog(LOG_ALERT, "%s\n", errormessage);
                return (-1);
        }
        sin6.sin6_port = htons((u_short) port_number);
@@ -336,7 +267,7 @@ int ctdl_tcp_server(char *ip_addr, int port_number, int queue_len, char *errorme
                snprintf(errormessage, SIZ,
                         "Can't create a listening socket: %s", strerror(errno)
                );
-               CtdlLogPrintf(CTDL_ALERT, "%s\n", errormessage);
+               syslog(LOG_ALERT, "%s\n", errormessage);
                return (-1);
        }
        /* Set some socket options that make sense. */
@@ -354,7 +285,7 @@ int ctdl_tcp_server(char *ip_addr, int port_number, int queue_len, char *errorme
                snprintf(errormessage, SIZ,
                         "Can't bind: %s", strerror(errno)
                );
-               CtdlLogPrintf(CTDL_ALERT, "%s\n", errormessage);
+               syslog(LOG_ALERT, "%s\n", errormessage);
                return (-1);
        }
 
@@ -364,7 +295,7 @@ int ctdl_tcp_server(char *ip_addr, int port_number, int queue_len, char *errorme
                snprintf(errormessage, SIZ,
                         "Can't listen: %s", strerror(errno)
                );
-               CtdlLogPrintf(CTDL_ALERT, "%s\n", errormessage);
+               syslog(LOG_ALERT, "%s\n", errormessage);
                return (-1);
        }
        return (s);
@@ -395,7 +326,7 @@ int ctdl_uds_server(char *sockpath, int queue_len, char *errormessage)
                snprintf(errormessage, SIZ, "citserver: can't unlink %s: %s",
                        sockpath, strerror(errno)
                );
-               CtdlLogPrintf(CTDL_EMERG, "%s\n", errormessage);
+               syslog(LOG_EMERG, "%s\n", errormessage);
                return(-1);
        }
 
@@ -408,7 +339,7 @@ int ctdl_uds_server(char *sockpath, int queue_len, char *errormessage)
                snprintf(errormessage, SIZ, 
                         "citserver: Can't create a socket: %s",
                         strerror(errno));
-               CtdlLogPrintf(CTDL_EMERG, "%s\n", errormessage);
+               syslog(LOG_EMERG, "%s\n", errormessage);
                return(-1);
        }
 
@@ -416,7 +347,7 @@ int ctdl_uds_server(char *sockpath, int queue_len, char *errormessage)
                snprintf(errormessage, SIZ, 
                         "citserver: Can't bind: %s",
                         strerror(errno));
-               CtdlLogPrintf(CTDL_EMERG, "%s\n", errormessage);
+               syslog(LOG_EMERG, "%s\n", errormessage);
                return(-1);
        }
 
@@ -425,7 +356,7 @@ int ctdl_uds_server(char *sockpath, int queue_len, char *errormessage)
                snprintf(errormessage, SIZ, 
                         "citserver: Can't set socket to non-blocking: %s",
                         strerror(errno));
-               CtdlLogPrintf(CTDL_EMERG, "%s\n", errormessage);
+               syslog(LOG_EMERG, "%s\n", errormessage);
                close(s);
                return(-1);
        }
@@ -434,7 +365,7 @@ int ctdl_uds_server(char *sockpath, int queue_len, char *errormessage)
                snprintf(errormessage, SIZ, 
                         "citserver: Can't listen: %s",
                         strerror(errno));
-               CtdlLogPrintf(CTDL_EMERG, "%s\n", errormessage);
+               syslog(LOG_EMERG, "%s\n", errormessage);
                return(-1);
        }
 
@@ -563,7 +494,7 @@ int client_write(const char *buf, int nbytes)
                        if (select(1, NULL, &wset, NULL, NULL) == -1) {
                                if (errno == EINTR)
                                {
-                                       CtdlLogPrintf(CTDL_DEBUG, "client_write(%d bytes) select() interrupted.\n", nbytes-bytes_written);
+                                       syslog(LOG_DEBUG, "client_write(%d bytes) select() interrupted.\n", nbytes-bytes_written);
                                        if (CtdlThreadCheckStop()) {
                                                CC->kill_me = 1;
                                                return (-1);
@@ -572,7 +503,7 @@ int client_write(const char *buf, int nbytes)
                                                continue;
                                        }
                                } else {
-                                       CtdlLogPrintf(CTDL_ERR,
+                                       syslog(LOG_ERR,
                                                "client_write(%d bytes) select failed: %s (%d)\n",
                                                nbytes - bytes_written,
                                                strerror(errno), errno);
@@ -586,12 +517,12 @@ int client_write(const char *buf, int nbytes)
                retval = write(Ctx->client_socket, &buf[bytes_written],
                        nbytes - bytes_written);
                if (retval < 1) {
-                       CtdlLogPrintf(CTDL_ERR,
+                       syslog(LOG_ERR,
                                "client_write(%d bytes) failed: %s (%d)\n",
                                nbytes - bytes_written,
                                strerror(errno), errno);
                        cit_backtrace();
-                       // CtdlLogPrintf(CTDL_DEBUG, "Tried to send: %s",  &buf[bytes_written]);
+                       // syslog(LOG_DEBUG, "Tried to send: %s",  &buf[bytes_written]);
                        Ctx->kill_me = 1;
                        return -1;
                }
@@ -660,7 +591,7 @@ int client_read_blob(StrBuf *Target, int bytes, int timeout)
 #endif
                retval = client_read_sslblob(Target, bytes, timeout);
                if (retval < 0) {
-                       CtdlLogPrintf(CTDL_CRIT, 
+                       syslog(LOG_CRIT, 
                                      "%s failed\n",
                                      __FUNCTION__);
                }
@@ -705,7 +636,7 @@ int client_read_blob(StrBuf *Target, int bytes, int timeout)
                                                O_TERM,
                                                &Error);
                if (retval < 0) {
-                       CtdlLogPrintf(CTDL_CRIT, 
+                       syslog(LOG_CRIT, 
                                      "%s failed: %s\n",
                                      __FUNCTION__, 
                                      Error);
@@ -890,7 +821,7 @@ int CtdlClientGetLine(StrBuf *Target)
                 fclose(fd);
 
                if (rc < 0)
-                       CtdlLogPrintf(CTDL_CRIT, 
+                       syslog(LOG_CRIT, 
                                      "%s failed\n",
                                      __FUNCTION__);
 #endif
@@ -948,7 +879,7 @@ int CtdlClientGetLine(StrBuf *Target)
                 fclose(fd);
 
                if ((rc < 0) && (Error != NULL))
-                       CtdlLogPrintf(CTDL_CRIT, 
+                       syslog(LOG_CRIT, 
                                      "%s failed: %s\n",
                                      __FUNCTION__,
                                      Error);
@@ -1013,13 +944,13 @@ void close_masters (void)
 
                if (serviceptr->tcp_port > 0)
                {
-                       CtdlLogPrintf(CTDL_INFO, "Closing listener on port %d\n",
+                       syslog(LOG_INFO, "Closing listener on port %d\n",
                                serviceptr->tcp_port);
                        serviceptr->tcp_port = 0;
                }
                
                if (serviceptr->sockpath != NULL)
-                       CtdlLogPrintf(CTDL_INFO, "Closing listener on '%s'\n",
+                       syslog(LOG_INFO, "Closing listener on '%s'\n",
                                serviceptr->sockpath);
 
                close(serviceptr->msock);
@@ -1090,7 +1021,7 @@ void start_daemon(int unused) {
         * to be reused for other files.
         */
        if (chdir(ctdl_run_dir) != 0)
-               CtdlLogPrintf(CTDL_EMERG, 
+               syslog(LOG_EMERG, 
                              "unable to change into directory [%s]: %s", 
                              ctdl_run_dir, strerror(errno));
 
@@ -1108,7 +1039,7 @@ void start_daemon(int unused) {
         if ((freopen("/dev/null", "r", stdin) != stdin) || 
            (freopen("/dev/null", "w", stdout) != stdout) || 
            (freopen("/dev/null", "w", stderr) != stderr))
-               CtdlLogPrintf(CTDL_EMERG, 
+               syslog(LOG_EMERG, 
                              "unable to reopen stdin/out/err %s", 
                              strerror(errno));
                
@@ -1170,7 +1101,7 @@ void checkcrash(void)
                StrBuf *CrashMail;
 
                CrashMail = NewStrBuf();
-               CtdlLogPrintf(CTDL_ALERT, "Posting crash message\n");
+               syslog(LOG_ALERT, "Posting crash message\n");
                StrBufPrintf(CrashMail, 
                        " \n"
                        " The Citadel server process (citserver) terminated unexpectedly."
@@ -1315,17 +1246,17 @@ do_select:      force_purge = 0;
                 */
                if (retval < 0) {
                        if (errno == EBADF) {
-                               CtdlLogPrintf(CTDL_NOTICE, "select() failed: (%s)\n",
+                               syslog(LOG_NOTICE, "select() failed: (%s)\n",
                                        strerror(errno));
                                goto do_select;
                        }
                        if (errno != EINTR) {
-                               CtdlLogPrintf(CTDL_EMERG, "Exiting (%s)\n", strerror(errno));
+                               syslog(LOG_EMERG, "Exiting (%s)\n", strerror(errno));
                                CtdlThreadStopAll();
                                continue;
                        } else {
 #if 0
-                               CtdlLogPrintf(CTDL_DEBUG, "Interrupted CtdlThreadSelect.\n");
+                               syslog(LOG_DEBUG, "Interrupted CtdlThreadSelect.\n");
 #endif
                                if (CtdlThreadCheckStop()) return(NULL);
                                goto do_select;
@@ -1459,16 +1390,16 @@ void *select_on_master (void *arg)
                 */
                if (retval < 0) {
                        if (errno == EBADF) {
-                               CtdlLogPrintf(CTDL_NOTICE, "select() failed: (%s)\n",
+                               syslog(LOG_NOTICE, "select() failed: (%s)\n",
                                        strerror(errno));
                                continue;
                        }
                        if (errno != EINTR) {
-                               CtdlLogPrintf(CTDL_EMERG, "Exiting (%s)\n", strerror(errno));
+                               syslog(LOG_EMERG, "Exiting (%s)\n", strerror(errno));
                                CtdlThreadStopAll();
                        } else {
 #if 0
-                               CtdlLogPrintf(CTDL_DEBUG, "Interrupted CtdlThreadSelect.\n");
+                               syslog(LOG_DEBUG, "Interrupted CtdlThreadSelect.\n");
 #endif
                                if (CtdlThreadCheckStop()) return(NULL);
                                continue;
@@ -1487,7 +1418,7 @@ void *select_on_master (void *arg)
                        if (FD_ISSET(serviceptr->msock, &master_fds)) {
                                ssock = accept(serviceptr->msock, NULL, 0);
                                if (ssock >= 0) {
-                                       CtdlLogPrintf(CTDL_DEBUG,
+                                       syslog(LOG_DEBUG,
                                                "New client socket %d\n",
                                                ssock);
 
@@ -1496,7 +1427,7 @@ void *select_on_master (void *arg)
                                         * operations barf on FreeBSD.  Not a fatal error.
                                         */
                                        if (fcntl(ssock, F_SETFL, 0) < 0) {
-                                               CtdlLogPrintf(CTDL_EMERG,
+                                               syslog(LOG_EMERG,
                                                        "citserver: Can't set socket to blocking: %s\n",
                                                        strerror(errno));
                                        }
@@ -1578,7 +1509,6 @@ int SyslogFacility(char *name)
                if(!strcasecmp(name, facTbl[i].name))
                        return facTbl[i].facility;
        }
-       enable_syslog = 0;
        return LOG_DAEMON;
 }
 
@@ -1684,7 +1614,7 @@ void dump_heap(void) {
        struct igheap *thisheap;
 
        for (thisheap = igheap; thisheap != NULL; thisheap = thisheap->next) {
-               CtdlLogPrintf(CTDL_CRIT, "UNFREED: %30s : %d\n",
+               syslog(LOG_CRIT, "UNFREED: %30s : %d\n",
                        thisheap->file, thisheap->line);
        }
 }
index 663e9b50b0b0108683cd90099af0b94fbf17704f..f0343c728adae0c117cc6e3a2acf36d7edca79b3 100644 (file)
@@ -47,12 +47,6 @@ void cprintf (const char *format, ...) __attribute__((__format__(__printf__,1,2)
 void cprintf (const char *format, ...);
 #endif
 
-void CtdlLogPrintf(enum LogLevel loglevel, const char *format, ...) __attribute__((__format__(__printf__,2,3)));
-void vCtdlLogPrintf (enum LogLevel loglevel, const char *format, va_list arg_ptr);
-
-extern int enable_syslog;
-extern int print_to_logfile;
-
 void init_sysdep (void);
 int ctdl_tcp_server(char *ip_addr, int port_number, int queue_len, char *errormessage);
 int ctdl_uds_server(char *sockpath, int queue_len, char *errormessage);
@@ -87,10 +81,7 @@ extern int verbosity;
 extern int rescan[];
 
 
-
-
 extern int SyslogFacility(char *name);
-extern int syslog_facility;
 
 
 /*
index 91a2d786cb6c1c4ebaae0eb9b96532cc988033e2..94ca65341bd8b62e59fecc0d1556e0815b597762 100644 (file)
@@ -128,12 +128,12 @@ int enable_syslog = 0;
 
 
 /*
- * CtdlLogPrintf()  ...   Write logging information; 
+ * syslog()  ...   Write logging information; 
  *                  simple here to have the same 
  *                  symbols in the client.
  */
 
-void CtdlLogPrintf(enum LogLevel loglevel, const char *format, ...) {   
+void syslog(enum LogLevel loglevel, const char *format, ...) {   
        va_list arg_ptr;
 
        va_start(arg_ptr, format);
index 0dcf4c38e8e4c255a98bc23e3cde03cf14a988f7..3f7aa7ee2e2b8b914b1eba53ead5cb69eac530b0 100644 (file)
@@ -1,9 +1,9 @@
 /*
  * Thread handling stuff for Citadel server
  *
- * Copyright (c) 1987-2010 by the citadel.org team
+ * Copyright (c) 1987-2011 by the citadel.org team
  *
- * This program is free software; you can redistribute it and/or modify
+ * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
@@ -27,6 +27,7 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <signal.h>
+#include <syslog.h>
 
 #include "sysdep.h"
 #if TIME_WITH_SYS_TIME
@@ -136,7 +137,7 @@ int try_critical_section(int which_one)
  */
 void begin_critical_section(int which_one)
 {
-       /* CtdlLogPrintf(CTDL_DEBUG, "begin_critical_section(%d)\n", which_one); */
+       /* syslog(LOG_DEBUG, "begin_critical_section(%d)\n", which_one); */
 
        /* For all types of critical sections except those listed here,
         * ensure nobody ever tries to do a critical section within a
@@ -182,7 +183,7 @@ void ctdl_thread_internal_init_tsd(void)
        int ret;
        
        if ((ret = citthread_key_create(&ThreadKey, ctdl_thread_internal_dest_tsd))) {
-               CtdlLogPrintf(CTDL_EMERG, "citthread_key_create: %s\n", strerror(ret));
+               syslog(LOG_EMERG, "citthread_key_create: %s\n", strerror(ret));
                exit(CTDLEXIT_DB);
        }
 }
@@ -263,7 +264,7 @@ void ctdl_thread_internal_init(void)
        /* Get ourself a thread entry */
        this_thread = malloc(sizeof(CtdlThreadNode));
        if (this_thread == NULL) {
-               CtdlLogPrintf(CTDL_EMERG, "Thread system, can't allocate CtdlThreadNode, exiting\n");
+               syslog(LOG_EMERG, "Thread system, can't allocate CtdlThreadNode, exiting\n");
                return;
        }
        // Ensuring this is zero'd means we make sure the thread doesn't start doing its thing until we are ready.
@@ -278,7 +279,7 @@ void ctdl_thread_internal_init(void)
        this_thread->state = CTDL_THREAD_RUNNING;
        
        if ((ret = citthread_attr_init(&this_thread->attr))) {
-               CtdlLogPrintf(CTDL_EMERG, "Thread system, citthread_attr_init: %s\n", strerror(ret));
+               syslog(LOG_EMERG, "Thread system, citthread_attr_init: %s\n", strerror(ret));
                free(this_thread);
                return;
        }
@@ -376,7 +377,7 @@ void CtdlThreadStopAll(void)
                citthread_cond_signal(&this_thread->ThreadCond);
                citthread_cond_signal(&this_thread->SleepCond);
                this_thread->stop_ticker = time(NULL);
-               CtdlLogPrintf(CTDL_DEBUG, "Thread system stopping thread \"%s\" (0x%08lx).\n",
+               syslog(LOG_DEBUG, "Thread system stopping thread \"%s\" (0x%08lx).\n",
                        this_thread->name, this_thread->tid);
                this_thread = this_thread->next;
        }
@@ -391,7 +392,7 @@ void CtdlThreadWakeAll(void)
 {
        CtdlThreadNode *this_thread;
        
-       CtdlLogPrintf(CTDL_DEBUG, "Thread system waking all threads.\n");
+       syslog(LOG_DEBUG, "Thread system waking all threads.\n");
        
        begin_critical_section(S_THREAD_LIST);
        this_thread = CtdlThreadList;
@@ -477,7 +478,7 @@ const char *CtdlThreadName(const char *name)
        
        if (!CT)
        {
-               CtdlLogPrintf(CTDL_WARNING, "Thread system WARNING. Attempt to CtdlThreadRename() a non thread. %s\n", name);
+               syslog(LOG_WARNING, "Thread system WARNING. Attempt to CtdlThreadRename() a non thread. %s\n", name);
                return NULL;
        }
        old_name = CT->name;
@@ -500,14 +501,14 @@ void CtdlThreadCancel(CtdlThreadNode *thread)
                this_thread = thread;
        if (!this_thread)
        {
-               CtdlLogPrintf(CTDL_EMERG, "Thread system PANIC. Attempt to CtdlThreadCancel() a non thread.\n");
+               syslog(LOG_EMERG, "Thread system PANIC. Attempt to CtdlThreadCancel() a non thread.\n");
                CtdlThreadStopAll();
                return;
        }
        
        if (!this_thread->thread_func)
        {
-               CtdlLogPrintf(CTDL_EMERG, "Thread system PANIC. Attempt to CtdlThreadCancel() the garbage collector.\n");
+               syslog(LOG_EMERG, "Thread system PANIC. Attempt to CtdlThreadCancel() the garbage collector.\n");
                CtdlThreadStopAll();
                return;
        }
@@ -526,7 +527,7 @@ int CtdlThreadCheckStop(void)
        
        if (!CT)
        {
-               CtdlLogPrintf(CTDL_EMERG, "Thread system PANIC, CtdlThreadCheckStop() called by a non thread.\n");
+               syslog(LOG_EMERG, "Thread system PANIC, CtdlThreadCheckStop() called by a non thread.\n");
                CtdlThreadStopAll();
                return -1;
        }
@@ -535,7 +536,7 @@ int CtdlThreadCheckStop(void)
 
        if (CT->signal)
        {
-               CtdlLogPrintf(CTDL_DEBUG, "Thread \"%s\" caught signal %d.\n", CT->name, CT->signal);
+               syslog(LOG_DEBUG, "Thread \"%s\" caught signal %d.\n", CT->name, CT->signal);
                if (CT->signal == SIGHUP)
                        CT->state = CTDL_THREAD_STOP_REQ;
                CT->signal = 0;
@@ -590,7 +591,7 @@ void CtdlThreadSleep(int secs)
        
        if (!CT)
        {
-               CtdlLogPrintf(CTDL_WARNING, "CtdlThreadSleep() called by something that is not a thread. Should we die?\n");
+               syslog(LOG_WARNING, "CtdlThreadSleep() called by something that is not a thread. Should we die?\n");
                return;
        }
        
@@ -623,11 +624,11 @@ static void ctdl_internal_thread_cleanup(void *arg)
                const char *name = CT->name;
                const pid_t tid = CT->tid;
 
-               CtdlLogPrintf(CTDL_NOTICE, "Thread \"%s\" (0x%08lx) exited.\n", name, (unsigned long) tid);
+               syslog(LOG_NOTICE, "Thread \"%s\" (0x%08lx) exited.\n", name, (unsigned long) tid);
        }
        else 
        {
-               CtdlLogPrintf(CTDL_NOTICE, "some ((unknown ? ? ?) Thread exited.\n");
+               syslog(LOG_NOTICE, "some ((unknown ? ? ?) Thread exited.\n");
        }
        
        #ifdef HAVE_BACKTRACE
@@ -667,7 +668,7 @@ void ctdl_thread_internal_calc_loadavg(void)
                        workers++;
                }
 #ifdef WITH_THREADLOG
-               CtdlLogPrintf(CTDL_DEBUG, "CtdlThread, \"%s\" (%lu) \"%s\" %.2f %.2f %.2f %.2f\n",
+               syslog(LOG_DEBUG, "CtdlThread, \"%s\" (%lu) \"%s\" %.2f %.2f %.2f %.2f\n",
                        that_thread->name,
                        that_thread->tid,
                        CtdlThreadStates[that_thread->state],
@@ -682,7 +683,7 @@ void ctdl_thread_internal_calc_loadavg(void)
        CtdlThreadLoadAvg = load_avg/num_threads;
        CtdlThreadWorkerAvg = worker_avg/workers;
 #ifdef WITH_THREADLOG
-       CtdlLogPrintf(CTDL_INFO, "System load average %.2f, workers averag %.2f, threads %d, workers %d, sessions %d\n", CtdlThreadGetLoadAvg(), CtdlThreadWorkerAvg, num_threads, num_workers, num_sessions);
+       syslog(LOG_INFO, "System load average %.2f, workers averag %.2f, threads %d, workers %d, sessions %d\n", CtdlThreadGetLoadAvg(), CtdlThreadWorkerAvg, num_threads, num_workers, num_sessions);
 #endif
 }
 
@@ -704,7 +705,7 @@ void CtdlThreadGC (void)
                CtdlThreadList->state = CTDL_THREAD_EXITED;
        
 #ifdef WITH_THREADLOG
-       CtdlLogPrintf(CTDL_DEBUG, "Thread system running garbage collection.\n");
+       syslog(LOG_DEBUG, "Thread system running garbage collection.\n");
 #endif
        /*
         * Woke up to do garbage collection
@@ -718,7 +719,7 @@ void CtdlThreadGC (void)
                if ((that_thread->state == CTDL_THREAD_STOP_REQ || that_thread->state == CTDL_THREAD_STOPPING)
                        && (!citthread_equal(that_thread->tid, citthread_self())))
                {
-                       CtdlLogPrintf(CTDL_DEBUG, "Waiting for thread %s (0x%08lx) to exit.\n", that_thread->name, that_thread->tid);
+                       syslog(LOG_DEBUG, "Waiting for thread %s (0x%08lx) to exit.\n", that_thread->name, that_thread->tid);
                        terminate_stuck_sessions();
                }
                else
@@ -732,9 +733,9 @@ void CtdlThreadGC (void)
                
                if (that_thread->stop_ticker + 5 == time(NULL))
                {
-                       CtdlLogPrintf(CTDL_DEBUG, "Thread System: The thread \"%s\" (0x%08lx) failed to self terminate within 5 ticks. It would be cancelled now.\n", that_thread->name, that_thread->tid);
+                       syslog(LOG_DEBUG, "Thread System: The thread \"%s\" (0x%08lx) failed to self terminate within 5 ticks. It would be cancelled now.\n", that_thread->name, that_thread->tid);
                        if ((that_thread->flags & CTDLTHREAD_WORKER) == 0)
-                               CtdlLogPrintf(CTDL_INFO, "Thread System: A non worker thread would have been canceled this may cause message loss.\n");
+                               syslog(LOG_INFO, "Thread System: A non worker thread would have been canceled this may cause message loss.\n");
 //                     that_thread->state = CTDL_THREAD_CANCELLED;
                        that_thread->stop_ticker++;
 //                     citthread_cancel(that_thread->tid);
@@ -752,7 +753,7 @@ void CtdlThreadGC (void)
                if (citthread_equal(that_thread->tid, citthread_self()) && that_thread->thread_func)
                {       /* Sanity check */
                        end_critical_section(S_THREAD_LIST);
-                       CtdlLogPrintf(CTDL_EMERG, "Thread system PANIC, a thread is trying to clean up after itself.\n");
+                       syslog(LOG_EMERG, "Thread system PANIC, a thread is trying to clean up after itself.\n");
                        abort();
                        return;
                }
@@ -760,7 +761,7 @@ void CtdlThreadGC (void)
                if (num_threads <= 0)
                {       /* Sanity check */
                        end_critical_section(S_THREAD_LIST);
-                       CtdlLogPrintf(CTDL_EMERG, "Thread system PANIC, num_threads <= 0 and trying to do Garbage Collection.\n");
+                       syslog(LOG_EMERG, "Thread system PANIC, num_threads <= 0 and trying to do Garbage Collection.\n");
                        abort();
                        return;
                }
@@ -787,17 +788,17 @@ void CtdlThreadGC (void)
                 */
                ret = citthread_join (that_thread->tid, NULL);
                if (ret == EDEADLK)
-                       CtdlLogPrintf(CTDL_DEBUG, "Garbage collection on own thread.\n");
+                       syslog(LOG_DEBUG, "Garbage collection on own thread.\n");
                else if (ret == EINVAL)
-                       CtdlLogPrintf(CTDL_DEBUG, "Garbage collection, that thread already joined on.\n");
+                       syslog(LOG_DEBUG, "Garbage collection, that thread already joined on.\n");
                else if (ret == ESRCH)
-                       CtdlLogPrintf(CTDL_DEBUG, "Garbage collection, no thread to join on.\n");
+                       syslog(LOG_DEBUG, "Garbage collection, no thread to join on.\n");
                else if (ret != 0)
-                       CtdlLogPrintf(CTDL_DEBUG, "Garbage collection, citthread_join returned an unknown error(%d).\n", ret);
+                       syslog(LOG_DEBUG, "Garbage collection, citthread_join returned an unknown error(%d).\n", ret);
                /*
                 * Now we own that thread entry
                 */
-               CtdlLogPrintf(CTDL_INFO, "Garbage Collection for thread \"%s\" (0x%08lx).\n",
+               syslog(LOG_INFO, "Garbage Collection for thread \"%s\" (0x%08lx).\n",
                        that_thread->name, that_thread->tid);
                citthread_mutex_destroy(&that_thread->ThreadMutex);
                citthread_cond_destroy(&that_thread->ThreadCond);
@@ -812,7 +813,7 @@ void CtdlThreadGC (void)
        /* Sanity check number of worker threads */
        if (workers != sys_workers)
        {
-               CtdlLogPrintf(CTDL_EMERG,
+               syslog(LOG_EMERG,
                        "Thread system PANIC, discrepancy in number of worker threads. Counted %d, should be %d.\n",
                        workers, sys_workers
                        );
@@ -869,7 +870,7 @@ static void *ctdl_internal_thread_func (void *arg)
 #if defined(HAVE_SYSCALL_H) && defined (SYS_gettid)
        this_thread->reltid = syscall(SYS_gettid);
 #endif
-       CtdlLogPrintf(CTDL_NOTICE, "Created a new thread \"%s\" (0x%08lx).\n",
+       syslog(LOG_NOTICE, "Created a new thread \"%s\" (0x%08lx).\n",
                this_thread->name, this_thread->tid);
        
        /*
@@ -914,7 +915,7 @@ CtdlThreadNode *ctdl_internal_init_thread_struct(CtdlThreadNode *this_thread, lo
                citthread_cond_destroy(&(this_thread->ThreadCond));
                citthread_mutex_destroy(&(this_thread->SleepMutex));
                citthread_cond_destroy(&(this_thread->SleepCond));
-               CtdlLogPrintf(CTDL_EMERG, "Thread system, citthread_attr_init: %s\n", strerror(ret));
+               syslog(LOG_EMERG, "Thread system, citthread_attr_init: %s\n", strerror(ret));
                free(this_thread);
                return NULL;
        }
@@ -926,7 +927,7 @@ CtdlThreadNode *ctdl_internal_init_thread_struct(CtdlThreadNode *this_thread, lo
        if (flags & CTDLTHREAD_BIGSTACK)
        {
 #ifdef WITH_THREADLOG
-               CtdlLogPrintf(CTDL_INFO, "Thread system. Creating BIG STACK thread.\n");
+               syslog(LOG_INFO, "Thread system. Creating BIG STACK thread.\n");
 #endif
                if ((ret = citthread_attr_setstacksize(&this_thread->attr, THREADSTACKSIZE))) {
                        citthread_mutex_unlock(&this_thread->ThreadMutex);
@@ -935,7 +936,7 @@ CtdlThreadNode *ctdl_internal_init_thread_struct(CtdlThreadNode *this_thread, lo
                        citthread_mutex_destroy(&(this_thread->SleepMutex));
                        citthread_cond_destroy(&(this_thread->SleepCond));
                        citthread_attr_destroy(&this_thread->attr);
-                       CtdlLogPrintf(CTDL_EMERG, "Thread system, citthread_attr_setstacksize: %s\n",
+                       syslog(LOG_EMERG, "Thread system, citthread_attr_setstacksize: %s\n",
                                strerror(ret));
                        free(this_thread);
                        return NULL;
@@ -964,13 +965,13 @@ CtdlThreadNode *ctdl_internal_create_thread(char *name, long flags, void *(*thre
 
        if (num_threads >= 32767)
        {
-               CtdlLogPrintf(CTDL_EMERG, "Thread system. Thread list full.\n");
+               syslog(LOG_EMERG, "Thread system. Thread list full.\n");
                return NULL;
        }
                
        this_thread = malloc(sizeof(CtdlThreadNode));
        if (this_thread == NULL) {
-               CtdlLogPrintf(CTDL_EMERG, "Thread system, can't allocate CtdlThreadNode, exiting\n");
+               syslog(LOG_EMERG, "Thread system, can't allocate CtdlThreadNode, exiting\n");
                return NULL;
        }
        
@@ -978,7 +979,7 @@ CtdlThreadNode *ctdl_internal_create_thread(char *name, long flags, void *(*thre
        if (ctdl_internal_init_thread_struct(this_thread, flags) == NULL)
        {
                free(this_thread);
-               CtdlLogPrintf(CTDL_EMERG, "Thread system, can't initialise CtdlThreadNode, exiting\n");
+               syslog(LOG_EMERG, "Thread system, can't initialise CtdlThreadNode, exiting\n");
                return NULL;
        }
        /*
@@ -1008,7 +1009,7 @@ CtdlThreadNode *ctdl_internal_create_thread(char *name, long flags, void *(*thre
        if ((ret = citthread_create(&this_thread->tid, &this_thread->attr, ctdl_internal_thread_func, this_thread) != 0))
        {
                end_critical_section(S_THREAD_LIST);
-               CtdlLogPrintf(CTDL_ALERT, "Thread system, Can't create thread: %s\n",
+               syslog(LOG_ALERT, "Thread system, Can't create thread: %s\n",
                        strerror(ret));
                citthread_mutex_unlock(&this_thread->ThreadMutex);
                citthread_mutex_destroy(&(this_thread->ThreadMutex));
@@ -1063,7 +1064,7 @@ CtdlThreadNode *ctdl_thread_internal_start_scheduled (CtdlThreadNode *this_threa
        if ((ret = citthread_create(&this_thread->tid, &this_thread->attr, ctdl_internal_thread_func, this_thread) != 0))
        {
                end_critical_section(S_THREAD_LIST);
-               CtdlLogPrintf(CTDL_DEBUG, "Failed to start scheduled thread \"%s\": %s\n", this_thread->name, strerror(ret));
+               syslog(LOG_DEBUG, "Failed to start scheduled thread \"%s\": %s\n", this_thread->name, strerror(ret));
                citthread_mutex_destroy(&(this_thread->ThreadMutex));
                citthread_cond_destroy(&(this_thread->ThreadCond));
                citthread_mutex_destroy(&(this_thread->SleepMutex));
@@ -1107,7 +1108,7 @@ void ctdl_thread_internal_check_scheduled(void)
        now = time(NULL);
        
 #ifdef WITH_THREADLOG
-       CtdlLogPrintf(CTDL_DEBUG, "Checking for scheduled threads to start.\n");
+       syslog(LOG_DEBUG, "Checking for scheduled threads to start.\n");
 #endif
 
        this_thread = CtdlThreadSchedList;
@@ -1128,14 +1129,14 @@ void ctdl_thread_internal_check_scheduled(void)
                                
                        that_thread->next = that_thread->prev = NULL;
 #ifdef WITH_THREADLOG
-                       CtdlLogPrintf(CTDL_DEBUG, "About to start scheduled thread \"%s\".\n", that_thread->name);
+                       syslog(LOG_DEBUG, "About to start scheduled thread \"%s\".\n", that_thread->name);
 #endif
                        if (CT->state > CTDL_THREAD_STOP_REQ)
                        {       /* Only start it if the system is not stopping */
                                if (ctdl_thread_internal_start_scheduled (that_thread))
                                {
 #ifdef WITH_THREADLOG
-                                       CtdlLogPrintf(CTDL_INFO, "Thread system, Started a scheduled thread \"%s\" (0x%08lx).\n",
+                                       syslog(LOG_INFO, "Thread system, Started a scheduled thread \"%s\" (0x%08lx).\n",
                                                that_thread->name, that_thread->tid);
 #endif
                                }
@@ -1144,7 +1145,7 @@ void ctdl_thread_internal_check_scheduled(void)
 #ifdef WITH_THREADLOG
                else
                {
-                       CtdlLogPrintf(CTDL_DEBUG, "Thread \"%s\" will start in %ld seconds.\n",
+                       syslog(LOG_DEBUG, "Thread \"%s\" will start in %ld seconds.\n",
                                that_thread->name, that_thread->when - time(NULL));
                }
 #endif
@@ -1186,7 +1187,7 @@ int CtdlThreadSelect(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds
                citthread_mutex_lock(&CT->ThreadMutex); /* To prevent race condition of a sleeping thread */
                if (GC_thread->state > CTDL_THREAD_STOP_REQ && CT->state <= CTDL_THREAD_STOP_REQ)
                {
-                       CtdlLogPrintf(CTDL_DEBUG, "Thread %s (0x%08lx) refused stop request.\n", CT->name, CT->tid);
+                       syslog(LOG_DEBUG, "Thread %s (0x%08lx) refused stop request.\n", CT->name, CT->tid);
                        CT->state = CTDL_THREAD_RUNNING;
                }
                citthread_mutex_unlock(&CT->ThreadMutex);
@@ -1248,7 +1249,7 @@ void go_threading(void)
                CtdlThreadCreate("select_on_master", CTDLTHREAD_BIGSTACK, select_on_master, NULL);
        }
        else {
-               CtdlLogPrintf(CTDL_EMERG, "Running connection simulation stats\n");
+               syslog(LOG_EMERG, "Running connection simulation stats\n");
                gettimeofday(&start, NULL);
                CtdlThreadCreate("Connection simulation master", CTDLTHREAD_BIGSTACK, simulation_thread, NULL);
        }
@@ -1257,7 +1258,7 @@ void go_threading(void)
        /*
         * This thread is now used for garbage collection of other threads in the thread list
         */
-       CtdlLogPrintf(CTDL_INFO, "Startup thread %ld becoming garbage collector,\n", (long) citthread_self());
+       syslog(LOG_INFO, "Startup thread %ld becoming garbage collector,\n", (long) citthread_self());
 
        /*
         * We do a lot of locking and unlocking of the thread list in here.
@@ -1305,7 +1306,7 @@ void go_threading(void)
                        if (last_worker)
                        {
 #ifdef WITH_THREADLOG
-                               CtdlLogPrintf(CTDL_DEBUG, "Thread system, stopping excess worker thread \"%s\" (0x%08lx).\n",
+                               syslog(LOG_DEBUG, "Thread system, stopping excess worker thread \"%s\" (0x%08lx).\n",
                                        last_worker->name,
                                        last_worker->tid
                                        );
@@ -1337,7 +1338,7 @@ void go_threading(void)
                                }
                        }
                        else
-                               CtdlLogPrintf (CTDL_WARNING, "Server strangled due to machine load average too high.\n");
+                               syslog(LOG_WARNING, "Server strangled due to machine load average too high.\n");
                }
                }
 
@@ -1364,7 +1365,7 @@ void go_threading(void)
                gettimeofday(&now, NULL);
                timersub(&now, &start, &result);
                last_duration = (double)result.tv_sec + ((double)result.tv_usec / (double) 1000000);
-               CtdlLogPrintf(CTDL_EMERG, "Simulated %ld connections in %f seconds\n", stats_done, last_duration);
+               syslog(LOG_EMERG, "Simulated %ld connections in %f seconds\n", stats_done, last_duration);
        }
 }
 
index 1c4c9480ae4358f71c53729682e446da165aca76..5e0219f53f4fd14565e61ff38164740a11c3788c 100644 (file)
@@ -1,5 +1,21 @@
 /* 
  * Server functions which perform operations on user objects.
+ *
+ * Copyright (c) 1987-2011 by the citadel.org team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include "sysdep.h"
@@ -13,6 +29,7 @@
 #include <ctype.h>
 #include <sys/types.h>
 #include <sys/wait.h>
+#include <syslog.h>
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
 #endif
 #include "threads.h"
 #include "citadel_ldap.h"
 #include "context.h"
-
 #include "ctdl_module.h"
-
-////#define CTDL_INLINE_USR INLINE
 #include "user_ops.h"
 
 /* These pipes are used to talk to the chkpwd daemon, which is forked during startup */
@@ -216,10 +230,10 @@ int rename_user(char *oldname, char *newname) {
                else {          /* Sanity checks succeeded.  Now rename the user. */
                        if (usbuf.usernum == 0)
                        {
-                               CtdlLogPrintf (CTDL_DEBUG, "Can not rename user \"Citadel\".\n");
+                               syslog(LOG_DEBUG, "Can not rename user \"Citadel\".\n");
                                retcode = RENAMEUSER_NOT_FOUND;
                        } else {
-                               CtdlLogPrintf(CTDL_DEBUG, "Renaming <%s> to <%s>\n", oldname, newname);
+                               syslog(LOG_DEBUG, "Renaming <%s> to <%s>\n", oldname, newname);
                                cdb_delete(CDB_USERS, oldnamekey, strlen(oldnamekey));
                                safestrncpy(usbuf.fullname, newname, sizeof usbuf.fullname);
                                CtdlPutUser(&usbuf);
@@ -403,11 +417,11 @@ int CtdlGetUserByNumber(struct ctdluser *usbuf, long number)
 
        cdbun = cdb_fetch(CDB_USERSBYNUMBER, &number, sizeof(long));
        if (cdbun == NULL) {
-               CtdlLogPrintf(CTDL_INFO, "User %ld not found\n", number);
+               syslog(LOG_INFO, "User %ld not found\n", number);
                return(-1);
        }
 
-       CtdlLogPrintf(CTDL_INFO, "User %ld maps to %s\n", number, cdbun->ptr);
+       syslog(LOG_INFO, "User %ld maps to %s\n", number, cdbun->ptr);
        r = CtdlGetUser(usbuf, cdbun->ptr);
        cdb_free(cdbun);
        return(r);
@@ -456,7 +470,7 @@ void rebuild_ubn_for_user(struct ctdluser *usbuf, void *data) {
        }
 
        while (u != NULL) {
-               CtdlLogPrintf(CTDL_DEBUG, "Rebuilding usersbynumber index %10ld : %s\n",
+               syslog(LOG_DEBUG, "Rebuilding usersbynumber index %10ld : %s\n",
                        u->usernum, u->username);
                cdb_store(CDB_USERSBYNUMBER, &u->usernum, sizeof(long), u->username, strlen(u->username)+1);
 
@@ -517,7 +531,7 @@ int CtdlLoginExistingUser(char *authname, const char *trythisname)
        int found_user;
        long len;
 
-       CtdlLogPrintf(CTDL_DEBUG, "CtdlLoginExistingUser(%s, %s)\n", authname, trythisname);
+       syslog(LOG_DEBUG, "CtdlLoginExistingUser(%s, %s)\n", authname, trythisname);
 
        if ((CC->logged_in)) {
                return login_already_logged_in;
@@ -527,7 +541,7 @@ int CtdlLoginExistingUser(char *authname, const char *trythisname)
        
        if (!strncasecmp(trythisname, "SYS_", 4))
        {
-               CtdlLogPrintf(CTDL_DEBUG, "System user \"%s\" is not allowed to log in.\n", trythisname);
+               syslog(LOG_DEBUG, "System user \"%s\" is not allowed to log in.\n", trythisname);
                return login_not_found;
        }
 
@@ -556,21 +570,21 @@ int CtdlLoginExistingUser(char *authname, const char *trythisname)
                struct passwd *tempPwdPtr;
                char pwdbuffer[256];
        
-               CtdlLogPrintf(CTDL_DEBUG, "asking host about <%s>\n", username);
+               syslog(LOG_DEBUG, "asking host about <%s>\n", username);
 #ifdef HAVE_GETPWNAM_R
 #ifdef SOLARIS_GETPWUID
-               CtdlLogPrintf(CTDL_DEBUG, "Calling getpwnam_r()\n");
+               syslog(LOG_DEBUG, "Calling getpwnam_r()\n");
                tempPwdPtr = getpwnam_r(username, &pd, pwdbuffer, sizeof pwdbuffer);
 #else // SOLARIS_GETPWUID
-               CtdlLogPrintf(CTDL_DEBUG, "Calling getpwnam_r()\n");
+               syslog(LOG_DEBUG, "Calling getpwnam_r()\n");
                getpwnam_r(username, &pd, pwdbuffer, sizeof pwdbuffer, &tempPwdPtr);
 #endif // SOLARIS_GETPWUID
 #else // HAVE_GETPWNAM_R
-               CtdlLogPrintf(CTDL_DEBUG, "SHOULD NEVER GET HERE!!!\n");
+               syslog(LOG_DEBUG, "SHOULD NEVER GET HERE!!!\n");
                tempPwdPtr = NULL;
 #endif // HAVE_GETPWNAM_R
                if (tempPwdPtr == NULL) {
-                       CtdlLogPrintf(CTDL_DEBUG, "no such user <%s>\n", username);
+                       syslog(LOG_DEBUG, "no such user <%s>\n", username);
                        return login_not_found;
                }
        
@@ -578,7 +592,7 @@ int CtdlLoginExistingUser(char *authname, const char *trythisname)
                 * If not found, make one attempt to create it.
                 */
                found_user = getuserbyuid(&CC->user, pd.pw_uid);
-               CtdlLogPrintf(CTDL_DEBUG, "found it: uid=%ld, gecos=%s here: %d\n",
+               syslog(LOG_DEBUG, "found it: uid=%ld, gecos=%s here: %d\n",
                        (long)pd.pw_uid, pd.pw_gecos, found_user);
                if (found_user != 0) {
                        len = cutuserkey(username);
@@ -661,11 +675,11 @@ void cmd_user(char *cmdbuf)
        char username[256];
        int a;
 
-       CtdlLogPrintf(CTDL_DEBUG, "cmd_user(%s)\n", cmdbuf);
+       syslog(LOG_DEBUG, "cmd_user(%s)\n", cmdbuf);
        extract_token(username, cmdbuf, 0, '|', sizeof username);
-       CtdlLogPrintf(CTDL_DEBUG, "username: %s\n", username);
+       syslog(LOG_DEBUG, "username: %s\n", username);
        striplt(username);
-       CtdlLogPrintf(CTDL_DEBUG, "username: %s\n", username);
+       syslog(LOG_DEBUG, "username: %s\n", username);
 
        a = CtdlLoginExistingUser(NULL, username);
        switch (a) {
@@ -699,7 +713,7 @@ void cmd_user(char *cmdbuf)
 void do_login(void)
 {
        CC->logged_in = 1;
-       CtdlLogPrintf(CTDL_NOTICE, "<%s> logged in\n", CC->curr_user);
+       syslog(LOG_NOTICE, "<%s> logged in\n", CC->curr_user);
 
        CtdlGetUserLock(&CC->user, CC->curr_user);
        ++(CC->user.timescalled);
@@ -829,11 +843,11 @@ static int validpw(uid_t uid, const char *pass)
        int rv = 0;
 
        if (IsEmptyStr(pass)) {
-               CtdlLogPrintf(CTDL_DEBUG, "Refusing to chkpwd for uid=%d with empty password.\n", uid);
+               syslog(LOG_DEBUG, "Refusing to chkpwd for uid=%d with empty password.\n", uid);
                return 0;
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Validating password for uid=%d using chkpwd...\n", uid);
+       syslog(LOG_DEBUG, "Validating password for uid=%d using chkpwd...\n", uid);
 
        begin_critical_section(S_CHKPWD);
        rv = write(chkpwd_write_pipe[1], &uid, sizeof(uid_t));
@@ -842,11 +856,11 @@ static int validpw(uid_t uid, const char *pass)
        end_critical_section(S_CHKPWD);
 
        if (!strncmp(buf, "PASS", 4)) {
-               CtdlLogPrintf(CTDL_DEBUG, "...pass\n");
+               syslog(LOG_DEBUG, "...pass\n");
                return(1);
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "...fail\n");
+       syslog(LOG_DEBUG, "...fail\n");
        return 0;
 }
 
@@ -858,7 +872,7 @@ void start_chkpwd_daemon(void) {
        struct stat filestats;
        int i;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Starting chkpwd daemon for host authentication mode\n");
+       syslog(LOG_DEBUG, "Starting chkpwd daemon for host authentication mode\n");
 
        if ((stat(file_chkpwd, &filestats)==-1) ||
            (filestats.st_size==0)){
@@ -866,29 +880,29 @@ void start_chkpwd_daemon(void) {
                abort();
        }
        if (pipe(chkpwd_write_pipe) != 0) {
-               CtdlLogPrintf(CTDL_EMERG, "Unable to create pipe for chkpwd daemon: %s\n", strerror(errno));
+               syslog(LOG_EMERG, "Unable to create pipe for chkpwd daemon: %s\n", strerror(errno));
                abort();
        }
        if (pipe(chkpwd_read_pipe) != 0) {
-               CtdlLogPrintf(CTDL_EMERG, "Unable to create pipe for chkpwd daemon: %s\n", strerror(errno));
+               syslog(LOG_EMERG, "Unable to create pipe for chkpwd daemon: %s\n", strerror(errno));
                abort();
        }
 
        chkpwd_pid = fork();
        if (chkpwd_pid < 0) {
-               CtdlLogPrintf(CTDL_EMERG, "Unable to fork chkpwd daemon: %s\n", strerror(errno));
+               syslog(LOG_EMERG, "Unable to fork chkpwd daemon: %s\n", strerror(errno));
                abort();
        }
        if (chkpwd_pid == 0) {
-               CtdlLogPrintf(CTDL_DEBUG, "Now calling dup2() write\n");
+               syslog(LOG_DEBUG, "Now calling dup2() write\n");
                dup2(chkpwd_write_pipe[0], 0);
-               CtdlLogPrintf(CTDL_DEBUG, "Now calling dup2() write\n");
+               syslog(LOG_DEBUG, "Now calling dup2() write\n");
                dup2(chkpwd_read_pipe[1], 1);
-               CtdlLogPrintf(CTDL_DEBUG, "Now closing stuff\n");
+               syslog(LOG_DEBUG, "Now closing stuff\n");
                for (i=2; i<256; ++i) close(i);
-               CtdlLogPrintf(CTDL_DEBUG, "Now calling execl(%s)\n", file_chkpwd);
+               syslog(LOG_DEBUG, "Now calling execl(%s)\n", file_chkpwd);
                execl(file_chkpwd, file_chkpwd, NULL);
-               CtdlLogPrintf(CTDL_EMERG, "Unable to exec chkpwd daemon: %s\n", strerror(errno));
+               syslog(LOG_EMERG, "Unable to exec chkpwd daemon: %s\n", strerror(errno));
                abort();
                exit(errno);
        }
@@ -900,19 +914,19 @@ int CtdlTryPassword(const char *password, long len)
        int code;
 
        if ((CC->logged_in)) {
-               CtdlLogPrintf(CTDL_WARNING, "CtdlTryPassword: already logged in\n");
+               syslog(LOG_WARNING, "CtdlTryPassword: already logged in\n");
                return pass_already_logged_in;
        }
        if (!strcmp(CC->curr_user, NLI)) {
-               CtdlLogPrintf(CTDL_WARNING, "CtdlTryPassword: no user selected\n");
+               syslog(LOG_WARNING, "CtdlTryPassword: no user selected\n");
                return pass_no_user;
        }
        if (CtdlGetUser(&CC->user, CC->curr_user)) {
-               CtdlLogPrintf(CTDL_ERR, "CtdlTryPassword: internal error\n");
+               syslog(LOG_ERR, "CtdlTryPassword: internal error\n");
                return pass_internal_error;
        }
        if (password == NULL) {
-               CtdlLogPrintf(CTDL_INFO, "CtdlTryPassword: NULL password string supplied\n");
+               syslog(LOG_INFO, "CtdlTryPassword: NULL password string supplied\n");
                return pass_wrong_password;
        }
        code = (-1);
@@ -984,7 +998,7 @@ int CtdlTryPassword(const char *password, long len)
                do_login();
                return pass_ok;
        } else {
-               CtdlLogPrintf(CTDL_WARNING, "Bad password specified for <%s>\n", CC->curr_user);
+               syslog(LOG_WARNING, "Bad password specified for <%s>\n", CC->curr_user);
                return pass_wrong_password;
        }
 }
@@ -1035,7 +1049,7 @@ int purge_user(char pname[])
                return (ERROR + NO_SUCH_USER);
 
        if (CtdlGetUser(&usbuf, pname) != 0) {
-               CtdlLogPrintf(CTDL_ERR, "Cannot purge user <%s> - not found\n", pname);
+               syslog(LOG_ERR, "Cannot purge user <%s> - not found\n", pname);
                return (ERROR + NO_SUCH_USER);
        }
        /* Don't delete a user who is currently logged in.  Instead, just
@@ -1043,12 +1057,12 @@ int purge_user(char pname[])
         * during the next purge.
         */
        if (CtdlIsUserLoggedInByNum(usbuf.usernum)) {
-               CtdlLogPrintf(CTDL_WARNING, "User <%s> is logged in; not deleting.\n", pname);
+               syslog(LOG_WARNING, "User <%s> is logged in; not deleting.\n", pname);
                usbuf.axlevel = AxDeleted;
                CtdlPutUser(&usbuf);
                return (1);
        }
-       CtdlLogPrintf(CTDL_NOTICE, "Deleting user <%s>\n", pname);
+       syslog(LOG_NOTICE, "Deleting user <%s>\n", pname);
 
 /*
  * FIXME:
@@ -1228,7 +1242,7 @@ int create_user(const char *newusername, long len, int become_user)
                CC->cs_addr
        );
        CtdlAideMessage(buf, "User Creation Notice");
-       CtdlLogPrintf(CTDL_NOTICE, "New user <%s> created\n", username);
+       syslog(LOG_NOTICE, "New user <%s> created\n", username);
        return (0);
 }
 
@@ -1306,7 +1320,7 @@ void CtdlSetPassword(char *new_pw)
        CtdlGetUserLock(&CC->user, CC->curr_user);
        safestrncpy(CC->user.password, new_pw, sizeof(CC->user.password));
        CtdlPutUserLock(&CC->user);
-       CtdlLogPrintf(CTDL_INFO, "Password changed for user <%s>\n", CC->curr_user);
+       syslog(LOG_INFO, "Password changed for user <%s>\n", CC->curr_user);
        PerformSessionHooks(EVT_SETPASS);
 }
 
index 90c7ea8c2a0bf58e94bed9e5093bb8723e7925e4..bbddd4e885b731f3eaf0bfe6944218f5f22250a8 100644 (file)
@@ -2,6 +2,7 @@
 #define __USER_OPS_H__
 
 #include <ctype.h>
+#include <syslog.h>
 int hash (char *str);
 /* getuser is deprecated, use CtdlGetUser instead */
 int getuser (struct ctdluser *, char *) __attribute__ ((deprecated));
@@ -68,7 +69,7 @@ static INLINE long cutuserkey(char *username) {
        len = strlen(username);
        if (len >= USERNAME_SIZE)
        {
-               CtdlLogPrintf (CTDL_EMERG, "Username to long: %s", username);
+               syslog(LOG_EMERG, "Username to long: %s", username);
                cit_backtrace ();
                len = USERNAME_SIZE - 1; 
                ((char*)username)[USERNAME_SIZE - 1]='\0';
@@ -86,7 +87,7 @@ static INLINE void makeuserkey(char *key, const char *username, long len) {
 
        if (len >= USERNAME_SIZE)
        {
-               CtdlLogPrintf (CTDL_EMERG, "Username to long: %s", username);
+               syslog(LOG_EMERG, "Username to long: %s", username);
                cit_backtrace ();
                len = USERNAME_SIZE - 1; 
        }
index 858f0b61e0aee2332196023cad3b619174fae366..805451fe5b6804feb90661f29f470ea8fd192bd9 100644 (file)
@@ -216,6 +216,12 @@ int main(int argc, char **argv)
                        return 1;
                }
 
+       /* Start the logger */
+       openlog("webcit",
+               ( running_as_daemon ? (LOG_PID) : (LOG_PID | LOG_PERROR) ),
+               LOG_DAEMON
+       );
+
        if (optind < argc) {
                ctdlhost = argv[optind];
                if (++optind < argc)