forked from jlelli/schedtool-dl
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy patherror.c
61 lines (47 loc) · 1.24 KB
/
error.c
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
53
54
55
56
57
58
59
60
61
/*
Schedtool
(c) by Freek <email_undisclosed>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Please see the file LICENSE for details.
*/
/*
Content:
This includes a nice error-function
*/
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include "error.h"
/* print ERROR: + given message + errormsg received via errno */
void decode_error(char *fmt, ...)
{
va_list args;
char *msg=NULL;
int tmp_errno=errno;
printf("ERROR: ");
va_start(args, fmt);
vprintf(fmt, args);
va_end(args);
if(errno) {
/* do our own errors */
if (errno == EINVAL) {
msg="value out of range / policy not implemented";
goto bail;
}
/* hu, can this be unsave ? */
msg=(char *)strerror(errno);
/* the strerror()-call went wrong */
if(errno != tmp_errno) {
msg="unknown error code, sorry";
}
bail:
printf(" - %s",msg);
}
printf("\n");
}