Annotation of src/usr.bin/tcfs/tcfserrors.c, Revision 1.2
1.1 provos 1: /*
2: * Transparent Cryptographic File System (TCFS) for NetBSD
3: * Author and mantainer: Luigi Catuogno [luicat@tcfs.unisa.it]
4: *
5: * references: http://tcfs.dia.unisa.it
6: * tcfs-bsd@tcfs.unisa.it
7: */
8:
9: /*
10: * Base utility set v0.1
11: */
12:
13: #include <stdio.h>
14: #include <unistd.h>
15: #include "tcfserrors.h"
16:
17: void tcfs_error (int error_type, char *custom_message)
18: {
19: if (error_type!=ER_CUSTOM && error_type!=OK)
20: fprintf (stderr, "Error: ");
21:
22: switch (error_type)
23: {
24: case ER_AUTH:
25: case ER_MEM:
26: case ER_TCFS:
27: case ER_PERM:
28: case ER_ENABLE:
29: case ER_DISABLE:
30: case ER_COUNT:
31: case ER_USER:
32: case OK:
33: fprintf (stderr, "%s\n", tcfs_errors_strings[error_type]);
34: exit (error_type);
35: case ER_CUSTOM:
36: fprintf (stderr, "%s\n", custom_message);
37: exit (1);
38: case ER_UNKOPT:
39: if (custom_message)
40: fprintf (stderr, "%s: %s\n", tcfs_errors_strings[error_type], custom_message);
41: else
42: fprintf (stderr, "%s\n", tcfs_errors_strings[error_type]);
43:
44: exit (error_type);
45: break; /* Useless code */
46: default:
47: fprintf (stderr, "internal error.\n");
48: exit (1);
49: }
50: }
51:
52: void show_usage (char *fmt, char *arg)
53: {
54: printf (fmt, arg);
55: }