libspf2
1.2.10
|
00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of either: 00004 * 00005 * a) The GNU Lesser General Public License as published by the Free 00006 * Software Foundation; either version 2.1, or (at your option) any 00007 * later version, 00008 * 00009 * OR 00010 * 00011 * b) The two-clause BSD license. 00012 * 00013 * These licenses can be found with the distribution in the file LICENSES 00014 */ 00015 00016 00017 #include "spf_sys_config.h" 00018 00019 00020 #ifdef STDC_HEADERS 00021 # include <stdio.h> 00022 # include <stdlib.h> /* malloc / free */ 00023 #endif 00024 00025 #ifdef HAVE_SYSLOG_H 00026 00027 #include <syslog.h> /* stdin / stdout */ 00028 00029 #include "spf.h" 00030 00037 void 00038 SPF_error_syslog(const char *file, int line, const char *errmsg) 00039 { 00040 char buf[128]; 00041 if (file) { 00042 snprintf(buf, sizeof(buf), "%s:%d", file, line); 00043 syslog(LOG_MAIL | LOG_ERR, "%-20s %s", buf, errmsg); 00044 } 00045 else { 00046 syslog(LOG_MAIL | LOG_ERR, "%s", errmsg); 00047 } 00048 abort(); 00049 } 00050 00051 void 00052 SPF_warning_syslog(const char *file, int line, const char *errmsg) 00053 { 00054 char buf[128]; 00055 if (file) { 00056 snprintf(buf, sizeof(buf), "%s:%d", file, line); 00057 syslog(LOG_MAIL | LOG_WARNING, "%-20s %s", buf, errmsg); 00058 } 00059 else { 00060 syslog(LOG_MAIL | LOG_WARNING, "%s", errmsg); 00061 } 00062 } 00063 00064 void 00065 SPF_info_syslog(const char *file __attribute__ ((unused)), int line __attribute__ ((unused)), const char *errmsg) 00066 { 00067 syslog(LOG_MAIL | LOG_INFO, "%s", errmsg); 00068 } 00069 00070 void 00071 SPF_debug_syslog(const char *file, int line, const char *errmsg) 00072 { 00073 char buf[128] = ""; 00074 if (file) { 00075 snprintf(buf, sizeof(buf), "%s:%d", file, line); 00076 syslog(LOG_MAIL | LOG_DEBUG, "%-20s %s", buf, errmsg); 00077 } 00078 else { 00079 syslog(LOG_MAIL | LOG_DEBUG, "%s", errmsg); 00080 } 00081 } 00082 00083 #endif