-
Notifications
You must be signed in to change notification settings - Fork 7
/
common.c
48 lines (41 loc) · 1.25 KB
/
common.c
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#ifdef _WIN32
#include <windows.h>
#endif
#include "common.h"
void error_exit(long errcode, char *string)
{
char errmessage[256];
#ifdef _WIN32
HWND hWnd = NULL;
#endif
if (errcode != ERR_GENERIC)
printf("\n%s: %s\n", string, strerror(errno)); // string is used as Filename
switch(errcode)
{
case ERR_OPENIMAGE:
strcpy(errmessage, "File not found\n\nYou may have typed a wrong name or path to source CDI image");
break;
case ERR_SAVETRACK:
strcpy(errmessage, "Could not save track");
break;
case ERR_READIMAGE:
strcpy(errmessage, "Error reading image");
break;
case ERR_PATH:
strcpy(errmessage, "Could not find destination path");
break;
case ERR_GENERIC:
default: strcpy(errmessage, string); // string is used as Error message
}
#ifdef _WIN32
MessageBoxA(hWnd, errmessage, NULL, MB_OK | MB_ICONERROR);
ExitProcess(0);
#else
printf(errmessage);
exit(EXIT_FAILURE);
#endif
}