cdi_error.c 800 Bytes
Newer Older
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1
2
3
4
5
6
7
8
9
#if defined (HAVE_CONFIG_H)
#  include "config.h"
#endif

#include <string.h>
#include <errno.h>
#include "cdi.h"

static char UnknownError[] = "Unknown Error";
10
static char _EUFTYPE[]     = "Unsupported file type";
Uwe Schulzweida's avatar
Uwe Schulzweida committed
11
static char _ELIBNAVAIL[]  = "Unsupported file type (library support not compiled in)";
12
static char _EUFSTRUCT[]   = "Unsupported file structure";
Uwe Schulzweida's avatar
Uwe Schulzweida committed
13
static char _EUNC4[]       = "Unsupported netCDF4 structure";
Uwe Schulzweida's avatar
Uwe Schulzweida committed
14

15
char *cdiStringError(int cdiErrno)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
16
17
18
19
{
  switch (cdiErrno) {
  case CDI_ESYSTEM:
    {
20
      char *cp = (char *) strerror(errno);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
21
22
23
      if ( cp == NULL ) break;
      return cp;
    }
24
25
26
  case CDI_EUFTYPE:    return _EUFTYPE;
  case CDI_ELIBNAVAIL: return _ELIBNAVAIL;
  case CDI_EUFSTRUCT:  return _EUFSTRUCT;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
27
  case CDI_EUNC4:      return _EUNC4;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
28
29
30
31
  }

  return UnknownError;
}