File: errors.c

package info (click to toggle)
rpc2 2.7%2Bdebian-5
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 2,852 kB
  • ctags: 2,661
  • sloc: ansic: 19,928; sh: 9,110; lex: 437; yacc: 416; makefile: 126; asm: 35
file content (64 lines) | stat: -rw-r--r-- 1,466 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* BLURB lgpl

                           Coda File System
                              Release 5

          Copyright (c) 1987-1999 Carnegie Mellon University
                  Additional copyrights listed below

This  code  is  distributed "AS IS" without warranty of any kind under
the  terms of the  GNU  Library General Public Licence  Version 2,  as
shown in the file LICENSE. The technical and financial contributors to
Coda are listed in the file CREDITS.

                        Additional copyrights
                           none currently

#*/

#include <unistd.h>
#include <stdlib.h>
#include <rpc2/errors.h>
#include <rpc2/rpc2.h>

/* translate RPC2 error to System Error */
int RPC2_R2SError(int rpc2_err)
{
    int sys_err;
    if (rpc2_err <= 0) return rpc2_err;

    switch (rpc2_err) {
#include <switchc2s.h>
    default:
	fprintf(stderr, "Unknown translation for rpc2 error %d\n", rpc2_err);
	sys_err = 4711;
    }
    return sys_err;
}

/* translate System error to RPC2 error */
int RPC2_S2RError(int sys_err)
{
    int rpc2_err;
    if ( sys_err <= 0 ) return sys_err;

    switch (sys_err) {
#include <switchs2c.h>
    default:
	fprintf(stderr, "Unknown translation for system errno %d\n", sys_err);
	rpc2_err = 4711;
    }
    return rpc2_err;
}

const char *cerror(int err)
{
    const char *txt;

    switch (err) {
#include <switchs2e.h>
    case 0: txt = "Success"; break;
    default: txt = "Unknown error!";
    }
    return txt;
}