File: error.c

package info (click to toggle)
vtk 5.8.0-13
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 130,524 kB
  • sloc: cpp: 1,129,256; ansic: 708,203; tcl: 48,526; python: 20,875; xml: 6,779; yacc: 4,208; perl: 3,121; java: 2,788; lex: 931; sh: 660; asm: 471; makefile: 299
file content (195 lines) | stat: -rw-r--r-- 5,226 bytes parent folder | download | duplicates (2)
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/*
 *  Copyright 1993, University Corporation for Atmospheric Research
 *      See netcdf/COPYRIGHT file for copying and redistribution conditions.
 */
/* $Id: error.c,v 1.14 90/02/23 16:08:55 davis Exp */

/*LINTLIBRARY*/

#include <ncconfig.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>

#include "rename.h"

#ifdef HAVE_STRERROR
#include <string.h> /* contains prototype for ansi libc function strerror() */
#else
#if defined DLL_NETCDF || defined _WIN32_WCE /* define when library is a DLL */
/* provide a strerror function for older windows systems */

char w32_tmp[NC_MAX_NAME];
static char *
strerror(int errnum)
{
  sprintf(w32_tmp, "Windows: %d", errnum);
  return w32_tmp;
}
#else
/* provide a strerror function for older unix systems */
static char *
strerror(int errnum)
{
    extern int sys_nerr;
    extern char *sys_errlist[];

    if(errnum < 0 || errnum >= sys_nerr) return NULL;
    /* else */
  return (char *)(sys_errlist[errnum]);
}
#endif
#endif /* NO_STRERROR */


#ifdef vms
/* UNTESTED */
/*
 * On the vms system, when a system error occurs which is not
 * mapped into the unix styled errno values, errno is set EVMSERR
 * and a VMS error code is set in vaxc$errno.
 * This routine prints the systems message associated with status return
 * from a system services call.
 */

#include <errno.h>
#include <descrip.h>
#include <ssdef.h>

static const char *
vms_strerror( int status )
{
  short msglen;
  static char msgbuf[256];
  $DESCRIPTOR(message, msgbuf);
  register ret;

  msgbuf[0] = 0;
  ret = SYS$GETMSG(status, &msglen, &message, 15, 0);

  if(ret != SS$_BUFFEROVF && ret != SS$_NORMAL) {
    (void) strcpy(msgbuf, "EVMSERR");
  }
  return(msgbuf);
}
#endif /* vms */


static char unknown[] = "Unknown Error";


const char *
nc_strerror(int err)
{

#ifdef vms
  if(err == EVMSERR)
  {
    return vms_strerror(err);
  }
  /* else */
#endif /* vms */

  if(NC_ISSYSERR(err))
  {
    const char *cp = (const char *) strerror(err);
    if(cp == NULL)
      return unknown;
    /* else */
    return cp;
  }
  /* else */

  switch (err) {
  case NC_NOERR:
      return "No error";
  case NC_EBADID:
      return "NetCDF: Not a valid ID";
  case NC_ENFILE:
      return "NetCDF: Too many files open";
  case NC_EEXIST:
      return "NetCDF: File exists && NC_NOCLOBBER";
  case NC_EINVAL:
      return "NetCDF: Invalid argument";
  case NC_EPERM:
      return "NetCDF: Write to read only";
  case NC_ENOTINDEFINE:
      return "NetCDF: Operation not allowed in data mode";
  case NC_EINDEFINE:
      return "NetCDF: Operation not allowed in define mode";
  case NC_EINVALCOORDS:
      return "NetCDF: Index exceeds dimension bound";
  case NC_EMAXDIMS:
      return "NetCDF: NC_MAX_DIMS exceeded";
  case NC_ENAMEINUSE:
      return "NetCDF: String match to name in use";
  case NC_ENOTATT:
      return "NetCDF: Attribute not found";
  case NC_EMAXATTS:
      return "NetCDF: NC_MAX_ATTRS exceeded";
  case NC_EBADTYPE:
      return "NetCDF: Not a valid data type or _FillValue type mismatch";
  case NC_EBADDIM:
      return "NetCDF: Invalid dimension ID or name";
  case NC_EUNLIMPOS:
      return "NetCDF: NC_UNLIMITED in the wrong index";
  case NC_EMAXVARS:
      return "NetCDF: NC_MAX_VARS exceeded";
  case NC_ENOTVAR:
      return "NetCDF: Variable not found";
  case NC_EGLOBAL:
      return "NetCDF: Action prohibited on NC_GLOBAL varid";
  case NC_ENOTNC:
      return "NetCDF: Unknown file format";
  case NC_ESTS:
      return "NetCDF: In Fortran, string too short";
  case NC_EMAXNAME:
      return "NetCDF: NC_MAX_NAME exceeded";
  case NC_EUNLIMIT:
      return "NetCDF: NC_UNLIMITED size already in use";
  case NC_ENORECVARS:
      return "NetCDF: nc_rec op when there are no record vars";
  case NC_ECHAR:
      return "NetCDF: Attempt to convert between text & numbers";
  case NC_EEDGE:
      return "NetCDF: Start+count exceeds dimension bound";
  case NC_ESTRIDE:
      return "NetCDF: Illegal stride";
  case NC_EBADNAME:
      return "NetCDF: Name contains illegal characters";
  case NC_ERANGE:
      return "NetCDF: Numeric conversion not representable";
  case NC_ENOMEM:
      return "NetCDF: Memory allocation (malloc) failure";
  case NC_EVARSIZE:
      return "NetCDF: One or more variable sizes violate format constraints";
  case NC_EDIMSIZE:
      return "NetCDF: Invalid dimension size";
  case NC_ETRUNC:
      return "NetCDF: File likely truncated or possibly corrupted";
  case NC_EAXISTYPE:
      return "NetCDF: Illegal axis type";
  case NC_EDAP:
      return "NetCDF: DAP failure";
  case NC_ECURL:
      return "NetCDF: libcurl failure";
  case NC_EIO:
      return "NetCDF: I/O failure";
  case NC_ENODATA:
      return "NetCDF: Variable has no data in DAP request";
  case NC_EDAPSVC:
      return "NetCDF: DAP server error";
  case NC_EDAS:
      return "NetCDF: Malformed or inaccessible DAP DAS";
  case NC_EDDS:
      return "NetCDF: Malformed or inaccessible DAP DDS";
  case NC_EDATADDS:
      return "NetCDF: Malformed or inaccessible DAP DATADDS";
  case NC_EDAPURL:
      return "NetCDF: Malformed DAP URL";
  case NC_EDAPCONSTRAINT:
      return "NetCDF: Malformed DAP Constraint";
  }
  /* default */
  return unknown;
}