libspf2 1.2.11
spf_log_stdio.c
Go to the documentation of this file.
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> /* stdin / stdout */
22# include <stdlib.h> /* malloc / free */
23#endif
24
25#include "spf.h"
26
33void
34SPF_error_stdio(const char *file, int line, const char *errmsg)
35{
36 char buf[128];
37 if (file) {
38 snprintf(buf, sizeof(buf), "%s:%d", file, line);
39 fprintf(stderr, "%-20s Error: %s\n", buf, errmsg);
40 }
41 else {
42 fprintf(stderr, "Error: %s\n", errmsg);
43 }
44 abort();
45}
46
47void
48SPF_warning_stdio(const char *file, int line, const char *errmsg)
49{
50 char buf[128];
51 if (file) {
52 snprintf(buf, sizeof(buf), "%s:%d", file, line);
53 fprintf(stderr, "%-20s Warning: %s\n", buf, errmsg);
54 }
55 else {
56 fprintf(stderr, "Warning: %s\n", errmsg);
57 }
58}
59
60void
61SPF_info_stdio(const char *file __attribute__((unused)), int line __attribute__((unused)), const char *errmsg)
62{
63 printf("%s\n", errmsg);
64}
65
66void
67SPF_debug_stdio(const char *file, int line, const char *errmsg)
68{
69 char buf[128];
70 if (file) {
71 snprintf(buf, sizeof(buf), "%s:%d", file, line);
72 fprintf(stderr, "%-20s Debug: %s\n", buf, errmsg);
73 }
74 else {
75 fprintf(stderr, "Debug: %s\n", errmsg);
76 }
77}
#define __attribute__(x)
Definition spf.h:17
void SPF_warning_stdio(const char *file, int line, const char *errmsg)
void SPF_debug_stdio(const char *file, int line, const char *errmsg)
void SPF_info_stdio(const char *file __attribute__((unused)), int line __attribute__((unused)), const char *errmsg)
void SPF_error_stdio(const char *file, int line, const char *errmsg)