"Fossies" - the Fresh Open Source Software Archive

Member "libspf2-1.2.10/src/libspf2/spf_log_syslog.c" (28 Jan 2012, 1781 Bytes) of package /linux/privat/libspf2-1.2.10.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "spf_log_syslog.c" see the Fossies "Dox" file reference documentation.

    1 /* 
    2  * This program is free software; you can redistribute it and/or modify
    3  * it under the terms of either:
    4  * 
    5  *   a) The GNU Lesser General Public License as published by the Free
    6  *      Software Foundation; either version 2.1, or (at your option) any
    7  *      later version,
    8  * 
    9  *   OR
   10  * 
   11  *   b) The two-clause BSD license.
   12  *
   13  * These licenses can be found with the distribution in the file LICENSES
   14  */
   15 
   16 
   17 #include "spf_sys_config.h"
   18 
   19 
   20 #ifdef STDC_HEADERS
   21 # include <stdio.h>
   22 # include <stdlib.h>       /* malloc / free */
   23 #endif
   24 
   25 #ifdef HAVE_SYSLOG_H
   26 
   27 #include <syslog.h>        /* stdin / stdout */
   28 
   29 #include "spf.h"
   30 
   31 /**
   32  * @file
   33  * Audited, 2008-09-13, Shevek.
   34  * Make sure no file:line combo is >127 bytes long.
   35  */
   36 
   37 void
   38 SPF_error_syslog(const char *file, int line, const char *errmsg)
   39 {
   40     char    buf[128];
   41     if (file) {
   42         snprintf(buf, sizeof(buf), "%s:%d", file, line);
   43         syslog(LOG_MAIL | LOG_ERR, "%-20s %s", buf, errmsg);
   44     }
   45     else {
   46         syslog(LOG_MAIL | LOG_ERR, "%s", errmsg);
   47     }
   48     abort();
   49 }
   50 
   51 void
   52 SPF_warning_syslog(const char *file, int line, const char *errmsg)
   53 {
   54     char    buf[128];
   55     if (file) {
   56         snprintf(buf, sizeof(buf), "%s:%d", file, line);
   57         syslog(LOG_MAIL | LOG_WARNING, "%-20s %s", buf, errmsg);
   58     }
   59     else {
   60         syslog(LOG_MAIL | LOG_WARNING, "%s", errmsg);
   61     }
   62 }
   63 
   64 void
   65 SPF_info_syslog(const char *file __attribute__ ((unused)), int line __attribute__ ((unused)), const char *errmsg)
   66 {
   67     syslog(LOG_MAIL | LOG_INFO, "%s", errmsg);
   68 }
   69 
   70 void
   71 SPF_debug_syslog(const char *file, int line, const char *errmsg)
   72 {
   73     char    buf[128] = "";
   74     if (file) {
   75         snprintf(buf, sizeof(buf), "%s:%d", file, line);
   76         syslog(LOG_MAIL | LOG_DEBUG, "%-20s %s", buf, errmsg);
   77     }
   78     else {
   79         syslog(LOG_MAIL | LOG_DEBUG, "%s", errmsg);
   80     }
   81 }
   82 
   83 #endif