comparison common/util.c @ 675:4ad764bfb39c

Add writing of the NSS line into the registry
author Andre Heinecke <andre.heinecke@intevation.de>
date Fri, 27 Jun 2014 18:53:52 +0200
parents d4766b4922c9
children 216a65d7fc4b
comparison
equal deleted inserted replaced
674:f1795a232418 675:4ad764bfb39c
18 #else 18 #else
19 #include <windows.h> 19 #include <windows.h>
20 #endif 20 #endif
21 21
22 #ifdef WIN32 22 #ifdef WIN32
23 char * get_install_dir()
24 {
25 wchar_t wPath[MAX_PATH];
26 char *utf8path = NULL;
27 char *dirsep = NULL;
28
29 if (!GetModuleFileNameW (NULL, wPath, MAX_PATH - 1))
30 {
31 PRINTLASTERROR ("Failed to obtain module file name. Path too long?");
32 return NULL;
33 }
34
35 /* wPath might not be 0 terminated */
36 wPath[MAX_PATH - 1] = '\0';
37
38 utf8path = wchar_to_utf8 (wPath, wcsnlen(wPath, MAX_PATH));
39
40 if (utf8path == NULL)
41 {
42 ERRORPRINTF ("Failed to convert module path to utf-8");
43 return NULL;
44 }
45
46 /* Cut away the executable name */
47 dirsep = strrchr(utf8path, '\\');
48 if (dirsep == NULL)
49 {
50 ERRORPRINTF ("Failed to find directory seperator.");
51 return NULL;
52 }
53 *dirsep = '\0';
54 return utf8path;
55 }
56
23 static PSID 57 static PSID
24 copy_sid(PSID from) 58 copy_sid(PSID from)
25 { 59 {
26 if (!from) 60 if (!from)
27 { 61 {

http://wald.intevation.org/projects/trustbridge/