File: error.c

package info (click to toggle)
s3d 0.2.2.1-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,356 kB
  • sloc: ansic: 21,128; python: 488; perl: 98; makefile: 31; sh: 29
file content (52 lines) | stat: -rw-r--r-- 1,314 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// SPDX-License-Identifier: LGPL-2.1-or-later
/* SPDX-FileCopyrightText: 2004-2015  Simon Wunderlich <sw@simonwunderlich.de>
 */


#include <stdarg.h>                     /* for va_start, va_end, va_list */
#include <stdio.h>                      /* for fprintf, stderr */
#include <string.h>                     /* for strerror */

/*  s3dprintf is only for internal use. */
#ifdef DEBUG
void s3dprintf(int relevance, const char *fmt, ...)
{
	char dbm[DBM_MAX];
	va_list args;
	if (relevance >= DEBUG) {
		va_start(args, fmt);
		vsnprintf((char *)&dbm, DBM_MAX, fmt, args);
		va_end(args);

		fprintf(stderr, "s3dlib: %s\n", (char *)&dbm);
	}
}
void errdn(int relevance, const char *func, int en)
{
	if (relevance >= DEBUG)
		fprintf(stderr, "s3dlib error: %s: (%d) %s\n", func, en, strerror(en));
}

void errds(int relevance, const char *func, const char *fmt, ...)
{
	char dbm[DBM_MAX];
	va_list args;
	if (relevance >= DEBUG) {
		va_start(args, fmt);
		vsnprintf((char *)&dbm, DBM_MAX, fmt, args);
		va_end(args);

		fprintf(stderr, "s3dlib error: %s:%s\n", func, (char *)&dbm);
	}
}
#endif
void errn(const char *func, int en)
{
	fprintf(stderr, "s3dlib error: %s: (%d) %s\n", func, en, strerror(en));
}
void errs(const char *func, const char *msg)
{
	fprintf(stderr, "s3dlib error: %s: %s\n", func, msg);
}