spf_log_stdio.c

Go to the documentation of this file.
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>        /* stdin / stdout */
00022 # include <stdlib.h>       /* malloc / free */
00023 #endif
00024 
00025 #include "spf.h"
00026 
00033 void
00034 SPF_error_stdio(const char *file, int line, const char *errmsg)
00035 {
00036     char        buf[128];
00037     if (file) {
00038                 snprintf(buf, sizeof(buf), "%s:%d", file, line);
00039                 fprintf(stderr, "%-20s Error: %s\n", buf, errmsg);
00040     }
00041     else {
00042                 fprintf(stderr, "Error: %s\n", errmsg);
00043         }
00044     abort();
00045 }
00046 
00047 void
00048 SPF_warning_stdio(const char *file, int line, const char *errmsg)
00049 {
00050     char        buf[128];
00051     if (file) {
00052                 snprintf(buf, sizeof(buf), "%s:%d", file, line);
00053                 fprintf(stderr, "%-20s Warning: %s\n", buf, errmsg);
00054     }
00055     else {
00056                 fprintf(stderr, "Warning: %s\n", errmsg);
00057         }
00058 }
00059 
00060 void
00061 SPF_info_stdio(const char *file __attribute__((unused)), int line __attribute__((unused)), const char *errmsg)
00062 {
00063     printf("%s\n", errmsg);
00064 }
00065 
00066 void
00067 SPF_debug_stdio(const char *file, int line, const char *errmsg)
00068 {
00069     char        buf[128];
00070     if (file) {
00071                 snprintf(buf, sizeof(buf), "%s:%d", file, line);
00072                 fprintf(stderr, "%-20s Debug: %s\n", buf, errmsg);
00073     }
00074     else {
00075                 fprintf(stderr, "Debug: %s\n", errmsg);
00076         }
00077 }

Generated on Tue Nov 4 13:27:39 2008 for libspf2 by  doxygen 1.5.4