Statistics
| Revision:

root / trunk / libraries / libjni-proj4 / src / emess.c @ 13136

History | View | Annotate | Download (1.28 KB)

1
/* Error message processing */
2
#ifndef lint
3
static const char SCCSID[]="@(#)emess.c        4.6        94/05/24        GIE        REL";
4
#endif
5

    
6
#include <stdio.h>
7
#include <stdlib.h>
8
#include <stdarg.h>
9
#include <errno.h>
10
#include <string.h>
11
#include <proj_api.h>
12
#define EMESS_ROUTINE
13
#include "emess.h"
14
        void
15
emess(int code, char *fmt, ...) {
16
        va_list args;
17

    
18
        va_start(args, fmt);
19
        /* prefix program name, if given */
20
        if (fmt != NULL)
21
                (void)fprintf(stderr,"%s\n<%s>: ",pj_get_release(),
22
                              emess_dat.Prog_name);
23
        /* print file name and line, if given */
24
        if (emess_dat.File_name != NULL && *emess_dat.File_name) {
25
                (void)fprintf(stderr,"while processing file: %s", emess_dat.File_name);
26
                if (emess_dat.File_line > 0)
27
                        (void)fprintf(stderr,", line %d\n", emess_dat.File_line);
28
                else
29
                        (void)fputc('\n', stderr);
30
        } else
31
                putc('\n', stderr);
32
        /* if |code|==2, print errno code data */
33
        if (code == 2 || code == -2)
34
                (void)fprintf(stderr, "Sys errno: %d: %s\n",
35
                        errno,
36
#ifdef HAVE_STRERROR
37
                        strerror(errno));
38
#else
39
                        "<system mess. texts unavail.>");
40
#endif
41
        /* post remainder of call data */
42
        (void)vfprintf(stderr,fmt,args);
43
        va_end(args);
44
        /* die if code positive */
45
        if (code > 0) {
46
                (void)fputs("\nprogram abnormally terminated\n", stderr);
47
                exit(code);
48
        }
49
        else
50
                putc('\n', stderr);
51
}