Blame src/util/et/et_name.c

Packit fd8b60
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
Packit fd8b60
/*
Packit fd8b60
 * Copyright 1997 by Massachusetts Institute of Technology
Packit fd8b60
 *
Packit fd8b60
 * Copyright 1987 by MIT Student Information Processing Board
Packit fd8b60
 *
Packit fd8b60
 * Permission to use, copy, modify, and distribute this software
Packit fd8b60
 * and its documentation for any purpose and without fee is
Packit fd8b60
 * hereby granted, provided that the above copyright notice
Packit fd8b60
 * appear in all copies and that both that copyright notice and
Packit fd8b60
 * this permission notice appear in supporting documentation,
Packit fd8b60
 * and that the names of M.I.T. and the M.I.T. S.I.P.B. not be
Packit fd8b60
 * used in advertising or publicity pertaining to distribution
Packit fd8b60
 * of the software without specific, written prior permission.
Packit fd8b60
 * Furthermore if you modify this software you must label
Packit fd8b60
 * your software as modified software and not distribute it in such a
Packit fd8b60
 * fashion that it might be confused with the original M.I.T. software.
Packit fd8b60
 * M.I.T. and the M.I.T. S.I.P.B. make no representations about
Packit fd8b60
 * the suitability of this software for any purpose.  It is
Packit fd8b60
 * provided "as is" without express or implied warranty.
Packit fd8b60
 */
Packit fd8b60
Packit fd8b60
#include "com_err.h"
Packit fd8b60
#include "error_table.h"
Packit fd8b60
Packit fd8b60
static const char char_set[] =
Packit fd8b60
    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
Packit fd8b60
Packit fd8b60
const char *
Packit fd8b60
error_table_name_r (unsigned long num,
Packit fd8b60
                    /*@out@*/ /*@returned@*/ char *outbuf)
Packit fd8b60
/*@modifies outbuf@*/
Packit fd8b60
{
Packit fd8b60
    long ch;
Packit fd8b60
    int i;
Packit fd8b60
    /*@out@*/ char *p;
Packit fd8b60
Packit fd8b60
    p = outbuf;
Packit fd8b60
    num >>= ERRCODE_RANGE;
Packit fd8b60
Packit fd8b60
    for (i = 3; i >= 0; i--) {
Packit fd8b60
        ch = (num >> BITS_PER_CHAR * i) & ((1 << BITS_PER_CHAR) - 1);
Packit fd8b60
        if (ch != 0)
Packit fd8b60
            *p++ = char_set[ch-1];
Packit fd8b60
    }
Packit fd8b60
    *p = '\0';
Packit fd8b60
    return(outbuf);
Packit fd8b60
}
Packit fd8b60
Packit fd8b60
/*@observer@*/
Packit fd8b60
const char * error_table_name(unsigned long num)
Packit fd8b60
/*@modifies internalState@*/
Packit fd8b60
{
Packit fd8b60
    static char buf[6];
Packit fd8b60
Packit fd8b60
    return error_table_name_r(num, buf);
Packit fd8b60
}