Mercurial > trustbridge
diff cinst/nssstore_win.c @ 363:d10d9bc2e84f
Update Windows api usage. Warning: To build on windows you need
a shell32.dll with SHGetKnownFolder
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Mon, 14 Apr 2014 16:57:41 +0000 |
parents | c0eac5c8c245 |
children | cbd0c1c20b30 |
line wrap: on
line diff
--- a/cinst/nssstore_win.c Sat Apr 12 17:20:30 2014 +0200 +++ b/cinst/nssstore_win.c Mon Apr 14 16:57:41 2014 +0000 @@ -158,8 +158,8 @@ cmd_line_len = wcslen (lpApplicationName) + wcslen(selection_file) + 1; lpCommandLine = xmalloc (cmd_line_len * sizeof(wchar_t)); - wcscpy (lpCommandLine, lpApplicationName); - wcscat (lpCommandLine, selection_file); + wcscpy_s (lpCommandLine, cmd_line_len, lpApplicationName); + wcscat_s (lpCommandLine, cmd_line_len, selection_file); success = CreateProcessAsUserW (hToken, lpApplicationName, @@ -201,7 +201,7 @@ * This creates a security attributes structure that restricts * write access to the Administrators group but allows everyone to read files * in that directory. - * Basically a very complicated vetrsion of mkdir path -m 604 + * Basically a very complicated version of mkdir path -m 644 * * If the directory exists the permissions of that directory are checked if * they are acceptable and true or false is returned accordingly. @@ -365,16 +365,11 @@ /* TODO */ } -#if 0 - result = SHGetKnownFolderPath (FOLDERID_ProgramData, /* Get program data dir */ + result = SHGetKnownFolderPath (&FOLDERID_ProgramData, /* Get program data dir */ KF_FLAG_CREATE | /* Create if it does not exist */ KF_FLAG_INIT, /* Initialize it if created */ - -1, /* Get it for the default user */ + INVALID_HANDLE_VALUE, /* Get it for the default user */ &folder_name); -#endif - /* TODO figure out how to do this with mingw */ - result = S_OK; - folder_name = L"C:\\ProgramData"; if (result != S_OK) { @@ -394,12 +389,12 @@ } path = xmalloc (path_len * sizeof (wchar_t)); - if (wcscpy (path, folder_name) != 0) + if (wcscpy_s (path, path_len, folder_name) != 0) { ERRORPRINTF ("Failed to copy folder name.\n"); -#if 0 + CoTaskMemFree (folder_name); -#endif + return NULL; } @@ -407,14 +402,14 @@ CoTaskMemFree (folder_name); #endif - if (wcscat (path, L"\\") != 0) + if (wcscat_s (path, path_len, L"\\") != 0) { ERRORPRINTF ("Failed to cat dirsep.\n"); xfree(path); return NULL; } - if (wcscat (path, APPNAME) != 0) + if (wcscat_s (path, path_len, APPNAME) != 0) { ERRORPRINTF ("Failed to cat appname.\n"); xfree(path); @@ -432,14 +427,14 @@ return NULL; } - if (wcscat (path, L"\\") != 0) + if (wcscat_s (path, path_len, L"\\") != 0) { ERRORPRINTF ("Failed to cat dirsep.\n"); xfree(path); return NULL; } - if (wcscat (path, SELECTION_FILE_NAME) != 0) + if (wcscat_s (path, path_len, SELECTION_FILE_NAME) != 0) { ERRORPRINTF ("Failed to cat filename.\n"); xfree(path);