27 #include <tqptrlist.h>
28 #include "tdeglobal.h"
30 #include <tdeapplication.h>
31 #include <tdeaboutdata.h>
33 #include <tdeconfig.h>
35 #include <kcharsets.h>
36 #include <kiconloader.h>
37 #include <tdehardwaredevices.h>
38 #include <tdenetworkconnections.h>
39 #include <kstandarddirs.h>
40 #include <kinstance.h>
41 #include "kstaticdeleter.h"
46 #define MYASSERT(x) if (!x) \
47 tqFatal("Fatal error: you need to have a TDEInstance object before\n" \
48 "you do anything that requires it! Examples of this are config\n" \
49 "objects, standard directories or translations.");
54 static void kglobal_init();
60 return _instance->
dirs();
67 return _instance->
config();
112 TDELocale::initInstance();
114 _instance->
aboutData()->translateInternalProgramName();
122 if( _charsets == 0 ) {
149 class KStringDict :
public TQDict<TQString>
152 KStringDict() : TQDict<TQString>(139) { }
165 _stringDict =
new KStringDict;
166 _stringDict->setAutoDelete(
true );
169 TQString *result = _stringDict->find(str);
172 result =
new TQString(str);
173 _stringDict->insert(str, result);
178 class KStaticDeleterList:
public TQPtrList<KStaticDeleterBase>
181 KStaticDeleterList() { }
187 if (!_staticDeleters)
189 if (_staticDeleters->find(obj) == -1)
190 _staticDeleters->append(obj);
197 _staticDeleters->removeRef(obj);
203 if (!TDEGlobal::_staticDeleters)
206 for(;_staticDeleters->count();)
208 _staticDeleters->take(0)->destructObject();
211 delete TDEGlobal::_staticDeleters;
212 TDEGlobal::_staticDeleters = 0;
217 KStringDict *TDEGlobal::_stringDict = 0;
222 KStaticDeleterList *TDEGlobal::_staticDeleters = 0;
226 static void kglobal_freeAll();
227 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID impLoad )
229 if (reason == DLL_PROCESS_DETACH)
234 __attribute__((destructor))
236 static void kglobal_freeAll()
238 delete TDEGlobal::_locale;
239 TDEGlobal::_locale = 0;
240 delete TDEGlobal::_charsets;
241 TDEGlobal::_charsets = 0;
242 delete TDEGlobal::_stringDict;
243 TDEGlobal::_stringDict = 0;
249 static void kglobal_init()
251 if (TDEGlobal::_staticDeleters)
254 TDEGlobal::_staticDeleters =
new KStaticDeleterList;
257 int kasciistricmp(
const char *str1,
const char *str2 )
259 const unsigned char *s1 = (
const unsigned char *)str1;
260 const unsigned char *s2 = (
const unsigned char *)str2;
262 unsigned char c1, c2;
265 return s1 ? 1 : (s2 ? -1 : 0);
267 return *s1 ? 1 : (*s2 ? -1 : 0);
268 for (;*s1; ++s1, ++s2) {
270 if (c1 >=
'A' && c1 <=
'Z')
272 if (c2 >=
'A' && c2 <=
'Z')
278 return *s1 ? res : (*s2 ? -1 : 0);