summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorGravatar Craig Fields <cfields@mit.edu>1993-04-13 15:56:19 +0000
committerGravatar Craig Fields <cfields@mit.edu>1993-04-13 15:56:19 +0000
commit3f13652ffe541299796bd8ca0a418a6f2661f3db (patch)
treed60f5bee6da53ae1ccd465ce5b8a868ffe258d14 /util
parent64bd3fab8a18c94b20f866f73eb0b693de61de03 (diff)
Initial revision
Diffstat (limited to 'util')
-rw-r--r--util/et/error_table.h30
-rw-r--r--util/et/mit-sipb-copyright.h19
-rw-r--r--util/et/test_et.c47
3 files changed, 96 insertions, 0 deletions
diff --git a/util/et/error_table.h b/util/et/error_table.h
new file mode 100644
index 0000000..78f7db2
--- /dev/null
+++ b/util/et/error_table.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright 1988 by the Student Information Processing Board of the
+ * Massachusetts Institute of Technology.
+ *
+ * For copyright info, see mit-sipb-copyright.h.
+ */
+
+#ifndef _ET_H
+/* Are we using ANSI C? */
+#ifndef __STDC__
+#define const
+#endif
+extern int errno;
+struct error_table {
+ char const * const * msgs;
+ long base;
+ int n_msgs;
+};
+struct et_list {
+ struct et_list *next;
+ const struct error_table *table;
+};
+extern struct et_list * _et_list;
+
+#define ERRCODE_RANGE 8 /* # of bits to shift table number */
+#define BITS_PER_CHAR 6 /* # bits to shift per character in name */
+
+extern const char *error_table_name();
+#define _ET_H
+#endif
diff --git a/util/et/mit-sipb-copyright.h b/util/et/mit-sipb-copyright.h
new file mode 100644
index 0000000..2f7eb29
--- /dev/null
+++ b/util/et/mit-sipb-copyright.h
@@ -0,0 +1,19 @@
+/*
+
+Copyright 1987, 1988 by the Student Information Processing Board
+ of the Massachusetts Institute of Technology
+
+Permission to use, copy, modify, and distribute this software
+and its documentation for any purpose and without fee is
+hereby granted, provided that the above copyright notice
+appear in all copies and that both that copyright notice and
+this permission notice appear in supporting documentation,
+and that the names of M.I.T. and the M.I.T. S.I.P.B. not be
+used in advertising or publicity pertaining to distribution
+of the software without specific, written prior permission.
+M.I.T. and the M.I.T. S.I.P.B. make no representations about
+the suitability of this software for any purpose. It is
+provided "as is" without express or implied warranty.
+
+*/
+
diff --git a/util/et/test_et.c b/util/et/test_et.c
new file mode 100644
index 0000000..955cb96
--- /dev/null
+++ b/util/et/test_et.c
@@ -0,0 +1,47 @@
+#include <stdio.h>
+#include <errno.h>
+#include "com_err.h"
+#include "test1.h"
+#include "test2.h"
+
+extern int sys_nerr, errno;
+
+main()
+{
+ printf("Before initiating error table:\n\n");
+ printf("Table name '%s'\n", error_table_name(KRB_MK_AP_TGTEXP));
+ printf("UNIX name '%s'\n", error_table_name(EPERM));
+ printf("Msg TGT-expired is '%s'\n", error_message(KRB_MK_AP_TGTEXP));
+ printf("Msg EPERM is '%s'\n", error_message(EPERM));
+ printf("Msg FOO_ERR is '%s'\n", error_message(FOO_ERR));
+ printf("Msg {sys_nerr-1} is '%s'\n", error_message(sys_nerr-1));
+ printf("Msg {sys_nerr} is '%s'\n", error_message(sys_nerr));
+
+ printf("With 0: tgt-expired -> %s\n", error_message(KRB_MK_AP_TGTEXP));
+
+ initialize_krb_error_table();
+ printf("KRB error table initialized: base %d (%s), name %s\n",
+ ERROR_TABLE_BASE_krb, error_message(ERROR_TABLE_BASE_krb),
+ error_table_name(ERROR_TABLE_BASE_krb));
+ initialize_krb_error_table();
+ printf("With krb: tgt-expired -> %s\n",
+ error_message(KRB_MK_AP_TGTEXP));
+
+ initialize_quux_error_table();
+ printf("QUUX error table initialized: base %d (%s), name %s\n",
+ ERROR_TABLE_BASE_quux, error_message(ERROR_TABLE_BASE_quux),
+ error_table_name(ERROR_TABLE_BASE_quux));
+
+ printf("Msg for TGT-expired is '%s'\n",
+ error_message(KRB_MK_AP_TGTEXP));
+ printf("Msg {sys_nerr-1} is '%s'\n", error_message(sys_nerr-1));
+ printf("Msg FOO_ERR is '%s'\n", error_message(FOO_ERR));
+ printf("Msg KRB_SKDC_CANT is '%s'\n",
+ error_message(KRB_SKDC_CANT));
+ printf("Msg 1e6 (8B 64) is '%s'\n", error_message(1000000));
+ printf("\n\nCOM_ERR tests:\n");
+ com_err("whoami", FOO_ERR, (char *)NULL);
+ com_err("whoami", FOO_ERR, " -- message goes %s", "here");
+ com_err("whoami", 0, (char *)0);
+ com_err("whoami", 0, "error number %d\n", 0);
+}