Annotation of src/usr.bin/tcfs/tcfserrors.c, Revision 1.4
1.4 ! fgsch 1: /* $OpenBSD$ */
! 2:
1.1 provos 3: /*
4: * Transparent Cryptographic File System (TCFS) for NetBSD
5: * Author and mantainer: Luigi Catuogno [luicat@tcfs.unisa.it]
6: *
7: * references: http://tcfs.dia.unisa.it
8: * tcfs-bsd@tcfs.unisa.it
9: */
10:
11: /*
12: * Base utility set v0.1
13: */
14:
15: #include <stdio.h>
16: #include <unistd.h>
17: #include "tcfserrors.h"
18:
1.3 fgsch 19: static char *tcfs_errors_strings[]=
20: {
21: "Ok",
22: NULL,
23: "unknow option.",
24: "authentication error.",
25: "out of memory.",
26: "you do not have a TCFS key.",
27: "Who are you?!",
28: "ioctl error while setting permanent flag.",
29: "ioctl error while sending.",
30: "ioctl error while removing key.",
31: "ioctl error while getting key counter."
32: };
33:
1.1 provos 34: void tcfs_error (int error_type, char *custom_message)
35: {
36: if (error_type!=ER_CUSTOM && error_type!=OK)
37: fprintf (stderr, "Error: ");
38:
39: switch (error_type)
40: {
41: case ER_AUTH:
42: case ER_MEM:
43: case ER_TCFS:
44: case ER_PERM:
45: case ER_ENABLE:
46: case ER_DISABLE:
47: case ER_COUNT:
48: case ER_USER:
49: case OK:
50: fprintf (stderr, "%s\n", tcfs_errors_strings[error_type]);
51: exit (error_type);
52: case ER_CUSTOM:
53: fprintf (stderr, "%s\n", custom_message);
54: exit (1);
55: case ER_UNKOPT:
56: if (custom_message)
57: fprintf (stderr, "%s: %s\n", tcfs_errors_strings[error_type], custom_message);
58: else
59: fprintf (stderr, "%s\n", tcfs_errors_strings[error_type]);
60:
61: exit (error_type);
62: break; /* Useless code */
63: default:
64: fprintf (stderr, "internal error.\n");
65: exit (1);
66: }
67: }
68:
69: void show_usage (char *fmt, char *arg)
70: {
71: printf (fmt, arg);
72: }