File: error.c

package info (click to toggle)
bar 1.11.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 928 kB
  • sloc: ansic: 4,381; sh: 3,334; makefile: 264
file content (44 lines) | stat: -rw-r--r-- 657 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
#include "config.h"

#include "headers.h"
#include "error.h"

int get_errno(void)
{
	return(errno);
}

void clear_errno(void)
{
	errno = 0;
}

void print_error(FILE *ferr, char *fmt, ...)
{
	va_list ap;
	char msg[256] = { 0 };

	va_start(ap, fmt);
	(void)vsprintf(msg, fmt, ap);
	va_end(ap);

	fprintf(ferr, "*** ERROR: ");
	if (errno != 0) {
		fprintf(ferr, "[%d]: %s\n", errno, strerror(errno));
		fprintf(ferr, "           ");
	}
	fprintf(ferr, "%s\n", msg);
}

void print_esup(FILE *ferr, char *fmt, ...)
{
	va_list ap;
	char msg[256] = { 0 };

	va_start(ap, fmt);
	(void)vsprintf(msg, fmt, ap);
	va_end(ap);

	fprintf(ferr, "           %s\n", msg);
}