forked from qunying/rhide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
idecheck.cc
160 lines (145 loc) · 4.33 KB
/
idecheck.cc
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
/* Copyright (C) 1996-2000 Robert H”hne, see COPYING.RH for details */
/* This file is part of RHIDE. */
#ifdef __DJGPP__
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <crt0.h>
#include <sys/stat.h>
#define Uses_MsgBox
#include <tv.h>
#define Uses_tvutilFunctions
#include <libtvuti.h>
#include "rhide.h"
#include <rhutils.h>
int
CheckIDE()
{
char *djgpp = expand_spec("$(DJGPP)", NULL);
int djgpp_auto = 0;
if (!*djgpp || !__file_exists(djgpp))
{
char *tmp =
expand_spec("$(word 1,$(foreach file,$(addsuffix /../djgpp.env"
",$(subst ;, ,$(PATH))),$(wildcard $(file))))", NULL);
if (*tmp)
{
FExpand(tmp);
string_free(djgpp);
string_cat(djgpp, "DJGPP=", tmp, NULL);
putenv(djgpp);
djgpp = NULL;
__crt0_load_environment_file("rhide");
djgpp_auto = 1;
}
string_free(tmp);
}
string_free(djgpp);
if (djgpp_auto)
{
BigmessageBox(mfWarning | mfOKButton,
_("RHIDE has detected that your DJGPP environment variable "
"was not set. It is set now automatically. If RHIDE did "
"the right choice, please modify your autoexec.bat by adding "
"the following line to fix this problem:"
"\n\nSET DJGPP=%s\n"), getenv("DJGPP"));
}
char *djdir = expand_spec("$(DJDIR)", NULL);
char *language = expand_spec("$(LANGUAGE)", NULL);
char *localedir = expand_spec("$(LOCALEDIR)", NULL);
char *lcdir = string_dup("");
struct stat st;
int ret = 0;
int djdir_valid = 0;
int lcdir_valid = 0;
if (*djdir)
{
if (stat(djdir, &st) == 0)
{
if (S_ISDIR(st.st_mode))
djdir_valid = 1;
}
}
if (!djdir_valid)
{
if (BigmessageBox(mfError | mfYesButton | mfNoButton,
_("RHIDE has detected, that the environment variable "
"DJDIR has not been set (or not correct). This is a fatal mistake. "
"For information about fixing this, please read the "
"File README.1ST from the DJGPP distribution. "
"(about setting the DJGPP environment variable!!!) "
"Should I continue?")) == cmNo)
{
ret = 1;
goto end;
}
goto end;
}
if (*language && (strncasecmp(language, "en", 2) != 0))
{
if (!*localedir)
string_cat(localedir, djdir, "/share/locale", NULL);
string_cat(lcdir, localedir, "/", language, "/LC_MESSAGES", NULL);
if (stat(lcdir, &st) == 0)
{
if (S_ISDIR(st.st_mode))
lcdir_valid = 1;
}
}
else
lcdir_valid = 1;
if (!lcdir_valid)
{
if (BigmessageBox(mfWarning | mfYesButton | mfNoButton,
_("RHIDE could not access the direcory '%s', where "
"it searches for language specific strings. Please "
"read the file 'RHIDE.BIN' how to install RHIDE "
"correct. Should I continue?"), lcdir) == cmNo)
{
ret = 1;
goto end;
}
}
{
char *tmp = string_dup(djdir);
string_cat(tmp, "/lang/cxx/stdiostream.h");
if (!__file_exists(tmp))
{
string_free(tmp);
string_cat(tmp, djdir, "/lang/cxx/stdios~1.h", NULL);
if (__file_exists(tmp))
{
if (BigmessageBox(mfWarning | mfYesButton | mfNoButton,
_
("RHIDE has detected, that you are running on a System "
"where long filenames might be supported "
"and you have installed the C++ compiler. Are you "
"sure, you have read the DJGPP FAQ and the installing "
"instructions for gcc when running under such a system? "
"(like Windows 95/Windows NT) "
"There might be a problem with the standard C++ libraries and "
"the standard C++ include files because "
"of a LFN-conflict. Should I continue?")) == cmNo)
{
ret = 1;
string_free(tmp);
goto end;
}
}
string_free(tmp);
}
}
end:
string_free(djdir);
string_free(language);
string_free(localedir);
string_free(lcdir);
return ret;
}
#else
int
CheckIDE()
{
return 0;
}
#endif