2 * Copyright (C) 2009, 2011 J. Ali Harlow <ali@juiblex.co.uk>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 char *plover_strconcat(const char *string,...)
41 while((s=va_arg(aq,const char *)))
47 strcpy(result,string);
48 t=result+strlen(result);
49 while((s=va_arg(ap,const char *)))
60 char *plover_default_prefix_for_vendor(const char *vendor)
64 * We want to sidestep any redirecting that MS-Windows may
65 * introduce since this will be based on the architecture
66 * of the installer whereas the architecture that actually
67 * matters is of the packages (checked elsewhere).
70 typedef BOOL (WINAPI *is_wow64_process_t)(HANDLE,PBOOL);
71 is_wow64_process_t is_wow64_process;
72 char *program_files=NULL;
74 is_wow64_process=(is_wow64_process_t)
75 GetProcAddress(GetModuleHandleA("kernel32"),"IsWow64Process");
77 is_wow64_process(GetCurrentProcess(),&is_wow64);
79 program_files=getenv("ProgramW6432");
82 SHGetFolderPath(NULL,CSIDL_PROGRAM_FILES|CSIDL_FLAG_DONT_VERIFY,NULL,0,
86 return plover_strconcat(program_files,"\\",vendor?vendor:"Plover",NULL);
93 * Get the directory containing the program executable.
96 char *plover_get_program_directory(const char *argv0)
100 char path[PATH_MAX],*t;
101 GetModuleFileName(NULL,path,sizeof(path));
110 s=strrchr(path,'\\');
115 s=argv0?strrchr(argv0,'/'):NULL;
117 return strndup(argv0,s-argv0);