diff options
author | Jason Downs <downsj@cvs.openbsd.org> | 1996-11-11 04:55:06 +0000 |
---|---|---|
committer | Jason Downs <downsj@cvs.openbsd.org> | 1996-11-11 04:55:06 +0000 |
commit | 066a987bf16f54e03a964424714abf17c430d1fb (patch) | |
tree | c82c969f6f69136b422aed922ae40829a4dcf7ce /lib/libcom_err/et_name.c | |
parent | e1f3fe3d0e5692a676c8be1703f378fb580ae38f (diff) |
Move libcom_err out of Kerberos, change include location.
Diffstat (limited to 'lib/libcom_err/et_name.c')
-rw-r--r-- | lib/libcom_err/et_name.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/lib/libcom_err/et_name.c b/lib/libcom_err/et_name.c new file mode 100644 index 00000000000..3fde10ad72c --- /dev/null +++ b/lib/libcom_err/et_name.c @@ -0,0 +1,55 @@ +/* $OpenBSD: et_name.c,v 1.1 1996/11/11 04:55:04 downsj Exp $ */ + +/*- + * 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. + */ + +#include "error_table.h" + +#ifndef lint +static const char copyright[] = + "Copyright 1987,1988 by Student Information Processing Board, Massachusetts Institute of Technology"; +static const char rcsid_et_name_c[] = + "$Id: et_name.c,v 1.1 1996/11/11 04:55:04 downsj Exp $"; +#endif + +static const char char_set[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"; + +static char buf[6]; + +const char * +error_table_name(num) + int num; +{ + int ch; + int i; + char *p; + + /* num = aa aaa abb bbb bcc ccc cdd ddd d?? ??? ??? */ + p = buf; + num >>= ERRCODE_RANGE; + /* num = ?? ??? ??? aaa aaa bbb bbb ccc ccc ddd ddd */ + num &= 077777777; + /* num = 00 000 000 aaa aaa bbb bbb ccc ccc ddd ddd */ + for (i = 4; i >= 0; i--) { + ch = (num >> BITS_PER_CHAR * i) & ((1 << BITS_PER_CHAR) - 1); + if (ch != 0) + *p++ = char_set[ch-1]; + } + *p = '\0'; + return(buf); +} |