File: win32err.h

package info (click to toggle)
dvd%2Brw-tools 7.1-14
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, sid, trixie
  • size: 1,828 kB
  • sloc: cpp: 13,672; ansic: 12,712; makefile: 55; perl: 28
file content (58 lines) | stat: -rw-r--r-- 1,327 bytes parent folder | download | duplicates (6)
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
# define EINVAL		ERROR_BAD_ARGUMENTS
# define ENOMEM		ERROR_OUTOFMEMORY
# define EMEDIUMTYPE	ERROR_MEDIA_INCOMPATIBLE
# define ENOMEDIUM	ERROR_MEDIA_OFFLINE
# define ENODEV		ERROR_BAD_COMMAND
# define EAGAIN		ERROR_NOT_READY
# define ENOSPC		ERROR_DISK_FULL
# define EIO		ERROR_NOT_SUPPORTED
# define ENXIO		ERROR_GEN_FAILURE
# define EBUSY		ERROR_SHARING_VIOLATION
# define ENOENT		ERROR_FILE_NOT_FOUND
# define ENOTDIR	ERROR_NO_VOLUME_LABEL
# define EINTR		ERROR_OPERATION_ABORTED
# define FATAL_START(e)	(0x10000|(e))
# define FATAL_MASK	 0x0FFFF

#ifdef errno
# undef errno
#endif

#ifdef __cplusplus
static class __win32_errno__ {
    public:
	operator int()		{ return GetLastError(); }
	int operator=(int e)	{ SetLastError(e); return e; }
} win32_errno;
# define errno		win32_errno
#else
# define errno		(GetLastError())
#endif

#define set_errno(e)	(SetLastError(e),e)

#ifdef perror
#undef perror
#endif
#define perror win32_perror
static void win32_perror (const char *str)
{ LPSTR lpMsgBuf;

    FormatMessageA( 
	FORMAT_MESSAGE_ALLOCATE_BUFFER |
	FORMAT_MESSAGE_FROM_SYSTEM | 
	FORMAT_MESSAGE_IGNORE_INSERTS,
	NULL,
	GetLastError(),
	0, // Default language
	(LPSTR) &lpMsgBuf,
	0,
	NULL 
	);
    if (str)
	fprintf (stderr,"%s: %s",str,lpMsgBuf);
    else
	fprintf (stderr,"%s",lpMsgBuf);

    LocalFree(lpMsgBuf);
}