~mingw-w64/mingw-w64/experimental

« back to all changes in this revision

Viewing changes to ironcrate/misc/maperr.c

  • Committer: ktietz70
  • Date: 2009-12-07 19:49:25 UTC
  • Revision ID: svn-v4:4407c894-4637-0410-b4f5-ada5f102cad1:experimental:1611
Rename to iCrt (ironCrate)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <w64crt.h>
 
2
#include <windows.h>
 
3
#include <errno.h>
 
4
 
 
5
static int __w64crt_mapsys2errno_0_0 (unsigned long);
 
6
 
 
7
static int
 
8
__w64crt_mapsys2errno_0_0 (unsigned long serr)
 
9
{
 
10
  switch (serr)
 
11
    {
 
12
    case ERROR_BAD_ENVIRONMENT:
 
13
      return E2BIG;
 
14
    case ERROR_ACCESS_DENIED:   case ERROR_CURRENT_DIRECTORY:
 
15
    case ERROR_LOCK_VIOLATION:  case ERROR_NETWORK_ACCESS_DENIED:
 
16
    case ERROR_CANNOT_MAKE:     case ERROR_FAIL_I24:
 
17
    case ERROR_DRIVE_LOCKED:    case ERROR_SEEK_ON_DEVICE:
 
18
    case ERROR_NOT_LOCKED:      case ERROR_LOCK_FAILED:
 
19
      return EACCES;
 
20
    case ERROR_NO_PROC_SLOTS:   case ERROR_MAX_THRDS_REACHED:
 
21
    case ERROR_NESTING_NOT_ALLOWED:
 
22
      return EAGAIN;
 
23
    case ERROR_INVALID_HANDLE:  case ERROR_INVALID_TARGET_HANDLE:
 
24
    case ERROR_DIRECT_ACCESS_HANDLE:
 
25
      return EBADF;
 
26
    case ERROR_WAIT_NO_CHILDREN:
 
27
    case ERROR_CHILD_NOT_COMPLETE:
 
28
      return ECHILD;
 
29
    case ERROR_FILE_EXISTS:
 
30
    case ERROR_ALREADY_EXISTS:
 
31
      return EEXIST;
 
32
    case ERROR_INVALID_ACCESS:  case ERROR_INVALID_FUNCTION:
 
33
    case ERROR_INVALID_DATA:    case ERROR_INVALID_PARAMETER:
 
34
    case ERROR_NEGATIVE_SEEK:
 
35
      return EINVAL;
 
36
    case ERROR_TOO_MANY_OPEN_FILES:
 
37
      return EMFILE;
 
38
    case ERROR_FILE_NOT_FOUND:  case ERROR_PATH_NOT_FOUND:
 
39
    case ERROR_INVALID_DRIVE:   case ERROR_NO_MORE_FILES:
 
40
    case ERROR_BAD_NETPATH:     case ERROR_BAD_NET_NAME:
 
41
    case ERROR_BAD_PATHNAME:    case ERROR_FILENAME_EXCED_RANGE:
 
42
      return ENOENT;
 
43
    case ERROR_BAD_FORMAT:
 
44
      return ENOEXEC;
 
45
    case ERROR_ARENA_TRASHED:   case ERROR_NOT_ENOUGH_MEMORY:
 
46
    case ERROR_INVALID_BLOCK:   case ERROR_NOT_ENOUGH_QUOTA:
 
47
      return ENOMEM;
 
48
    case ERROR_DISK_FULL:
 
49
      return ENOSPC;
 
50
    case ERROR_DIR_NOT_EMPTY:
 
51
      return ENOTEMPTY;
 
52
    case ERROR_BROKEN_PIPE:
 
53
      return EPIPE;
 
54
    case ERROR_NOT_SAME_DEVICE:
 
55
      return EXDEV;
 
56
    default:
 
57
      if (serr >= ERROR_INVALID_STARTING_CODESEG && serr <= ERROR_INFLOOP_IN_RELOC_CHAIN)
 
58
        return ENOEXEC;
 
59
      else if (serr >= ERROR_WRITE_PROTECT && serr <= ERROR_SHARING_BUFFER_EXCEEDED)
 
60
        return EACCES;
 
61
    }
 
62
  return EINVAL;
 
63
}
 
64
 
 
65
int
 
66
__w64crt_get_errno_from_oserr_0_0 (unsigned long serr)
 
67
{
 
68
  return __w64crt_mapsys2errno_0_0 (serr);
 
69
}