~ubuntu-branches/debian/jessie/arcboot/jessie

« back to all changes in this revision

Viewing changes to e2fslib/et/error_message.c

  • Committer: Bazaar Package Importer
  • Author(s): Guido Guenther
  • Date: 2004-03-02 12:01:14 UTC
  • Revision ID: james.westby@ubuntu.com-20040302120114-0pukal9hlpt3k0l7
Tags: 0.3.8.1
correct subarch detection for IP32

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $ Header: lib/et/SCCS/s.error_message.c 1.16 99/10/23 01:16:05-00:00 tytso@mit.edu $
 
3
 * $ Source: /usr/src/e2fsprogs/BK/e2fsprogs/lib/et/SCCS/s.error_message.c $
 
4
 * $ Locker: <Not implemented> $
 
5
 *
 
6
 * Copyright 1987 by the Student Information Processing Board
 
7
 * of the Massachusetts Institute of Technology
 
8
 *
 
9
 * Permission to use, copy, modify, and distribute this software and
 
10
 * its documentation for any purpose is hereby granted, provided that
 
11
 * the names of M.I.T. and the M.I.T. S.I.P.B. not be used in
 
12
 * advertising or publicity pertaining to distribution of the software
 
13
 * without specific, written prior permission.  M.I.T. and the
 
14
 * M.I.T. S.I.P.B. make no representations about the suitability of
 
15
 * this software for any purpose.  It is provided "as is" without
 
16
 * express or implied warranty.
 
17
 */
 
18
 
 
19
#include <stdio.h>
 
20
#include <string.h>
 
21
#include <errno.h>
 
22
#include "com_err.h"
 
23
#include "error_table.h"
 
24
#include "internal.h"
 
25
 
 
26
static char buffer[25];
 
27
 
 
28
struct et_list * _et_list = (struct et_list *) NULL;
 
29
 
 
30
 
 
31
#ifdef __STDC__
 
32
const char * error_message (errcode_t code)
 
33
#else
 
34
const char * error_message (code)
 
35
        errcode_t       code;
 
36
#endif
 
37
{
 
38
    int offset;
 
39
    struct et_list *et;
 
40
    errcode_t table_num;
 
41
    int started = 0;
 
42
    char *cp;
 
43
 
 
44
    offset = (int) (code & ((1<<ERRCODE_RANGE)-1));
 
45
    table_num = code - offset;
 
46
    if (!table_num) {
 
47
#ifdef HAS_SYS_ERRLIST
 
48
        if (offset < sys_nerr)
 
49
            return(sys_errlist[offset]);
 
50
        else
 
51
            goto oops;
 
52
#else
 
53
        cp = strerror(offset);
 
54
        if (cp)
 
55
            return(cp);
 
56
        else
 
57
            goto oops;
 
58
#endif
 
59
    }
 
60
    for (et = _et_list; et; et = et->next) {
 
61
        if (et->table->base == table_num) {
 
62
            /* This is the right table */
 
63
            if (et->table->n_msgs <= offset)
 
64
                goto oops;
 
65
            return(et->table->msgs[offset]);
 
66
        }
 
67
    }
 
68
oops:
 
69
    strcpy (buffer, "Unknown code ");
 
70
    if (table_num) {
 
71
        strcat (buffer, error_table_name (table_num));
 
72
        strcat (buffer, " ");
 
73
    }
 
74
    for (cp = buffer; *cp; cp++)
 
75
        ;
 
76
    if (offset >= 100) {
 
77
        *cp++ = '0' + offset / 100;
 
78
        offset %= 100;
 
79
        started++;
 
80
    }
 
81
    if (started || offset >= 10) {
 
82
        *cp++ = '0' + offset / 10;
 
83
        offset %= 10;
 
84
    }
 
85
    *cp++ = '0' + offset;
 
86
    *cp = '\0';
 
87
    return(buffer);
 
88
}