about summary refs log tree commit diff
path: root/urt/rle_error.c
blob: 801eee177b236937b805b2d0d2f2d55d683c8d81 (plain) (blame)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
 * This software is copyrighted as noted below.  It may be freely copied,
 * modified, and redistributed, provided that the copyright notice is
 * preserved on all copies.
 *
 * There is no warranty or other guarantee of fitness for this software,
 * it is provided solely "as is".  Bug reports or fixes may be sent
 * to the author, who may or may not act on them as he desires.
 *
 * You may not include this software in a program or other software product
 * without supplying the source, or without informing the end-user that the
 * source is available for no extra charge.
 *
 * If you modify this software, you should include a notice giving the
 * name of the person performing the modification, the date of modification,
 * and the reason for such modification.
 */
/*
 * rle_error.c - Error message stuff for URT.
 *
 * Author:	Spencer W. Thomas
 * 		EECS Dept.
 * 		University of Michigan
 * Date:	Mon Mar  2 1992
 * Copyright (c) 1992, University of Michigan
 */

#include <string.h>

#include "rle_config.h"
#include "rle.h"

/*****************************************************************
 * TAG( rle_get_error )
 *
 * Print an error message for the return code from rle_get_setup
 * Inputs:
 * 	code:		The return code from rle_get_setup.
 *	pgmname:	Name of this program (argv[0]).
 *	fname:		Name of the input file.
 * Outputs:
 * 	Prints an error message on standard output.
 *	Returns code.
 */
int
rle_get_error( code, pgmname, fname )
    int code;
    CONST_DECL char *pgmname;
    CONST_DECL char *fname;
{
    if (! fname || strcmp( fname, "-" ) == 0 )
        fname = "Standard Input";

    switch( code )
    {
    case RLE_SUCCESS:		/* success */
        break;

    case RLE_NOT_RLE:		/* Not an RLE file */
        fprintf( stderr, "%s: %s is not an RLE file\n",
                 pgmname, fname );
        break;

    case RLE_NO_SPACE:			/* malloc failed */
        fprintf( stderr,
                 "%s: Malloc failed reading header of file %s\n",
                 pgmname, fname );
        break;

    case RLE_EMPTY:
        fprintf( stderr, "%s: %s is an empty file\n",
                 pgmname, fname );
        break;

    case RLE_EOF:
        fprintf( stderr,
                 "%s: RLE header of %s is incomplete (premature EOF)\n",
                 pgmname, fname );
        break;

    default:
        fprintf( stderr, "%s: Error encountered reading header of %s\n",
                 pgmname, fname );
        break;
    }
    return code;
}