Annotation of src/usr.bin/tcfs/tcfserrors.c, Revision 1.6
1.6 ! fgsch 1: /* $OpenBSD: tcfserrors.c,v 1.5 2000/06/19 22:42:28 aaron Exp $ */
1.4 fgsch 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.5 aaron 34: void tcfs_error(int error_type, char *custom_message)
1.1 provos 35: {
1.5 aaron 36: if (error_type != ER_CUSTOM && error_type != OK)
37: fprintf(stderr, "Error: ");
1.1 provos 38:
1.5 aaron 39: switch (error_type) {
40: case ER_AUTH:
41: case ER_MEM:
42: case ER_TCFS:
43: case ER_PERM:
44: case ER_ENABLE:
45: case ER_DISABLE:
46: case ER_COUNT:
47: case ER_USER:
48: case OK:
49: fprintf(stderr, "%s\n", tcfs_errors_strings[error_type]);
50: exit(error_type);
51: case ER_CUSTOM:
52: fprintf(stderr, "%s\n", custom_message);
53: exit(1);
54: case ER_UNKOPT:
55: if (custom_message)
56: fprintf(stderr, "%s: %s\n", tcfs_errors_strings[error_type], custom_message);
57: else
58: fprintf(stderr, "%s\n", tcfs_errors_strings[error_type]);
1.1 provos 59:
1.5 aaron 60: exit(error_type);
61: break; /* Useless code */
62: default:
63: fprintf(stderr, "internal error.\n");
64: exit(1);
1.1 provos 65: }
66: }