3 #if defined(_WIN32) && !defined(__CYGWIN__)
10 #include <sys/types.h>
17 #include <qdatetime.h>
19 #if defined(_MSC_VER) || defined(__BORLANDC__)
21 #define pclose _pclose
36 if (command==0)
return 1;
38 QCString fullCmd=command;
39 fullCmd=fullCmd.stripWhiteSpace();
40 if (fullCmd.at(0)!=
'"' && fullCmd.find(
' ')!=-1)
43 fullCmd=
"\""+fullCmd+
"\"";
51 #if !defined(_WIN32) || defined(__CYGWIN__)
52 (void)commandHasConsole;
56 #ifdef _OS_SOLARIS // for Solaris we use vfork since it is more memory efficient
68 execl(
"/bin/sh",
"sh",
"-c",fullCmd.data(),(
char*)0);
73 while (waitpid(pid,&status,0 )<0)
84 #else // Other Unices just use fork
97 argv[2] = fullCmd.data();
99 execve(
"/bin/sh",(
char *
const *)argv,
environ);
104 if (waitpid(pid,&status,0)==-1)
106 if (errno!=EINTR)
return -1;
110 if (WIFEXITED(status))
112 return WEXITSTATUS(status);
120 #endif // !_OS_SOLARIS
122 #else // Win32 specific
123 if (commandHasConsole)
125 return system(fullCmd);
135 CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
137 QString commandw = QString::fromUtf8( command );
138 QString argsw = QString::fromUtf8( args );
144 SHELLEXECUTEINFOW sInfo = {
145 sizeof(SHELLEXECUTEINFOW),
146 SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI,
152 (LPCWSTR)commandw.ucs2(),
153 (LPCWSTR)argsw.ucs2(),
165 if (!ShellExecuteExW(&sInfo))
169 else if (sInfo.hProcess)
171 WaitForSingleObject(sInfo.hProcess,INFINITE);
174 if (!GetExitCodeProcess(sInfo.hProcess,&exitCode))
178 CloseHandle(sInfo.hProcess);
189 #if !defined(_WIN32) || defined(__CYGWIN__)
190 pid = (uint)getpid();
192 pid = (uint)GetCurrentProcessId();
197 #if defined(_WIN32) && !defined(__CYGWIN__)
204 if (value==0) value=
"";
205 #if defined(_WIN32) && !defined(__CYGWIN__)
206 SetEnvironmentVariable(name,value);
208 register char **ep = 0;
209 register size_t size;
210 const size_t namelen=qstrlen(name);
211 const size_t vallen=qstrlen(value) + 1;
218 if (!qstrncmp (*ep, name, (uint)namelen) &&
219 (*ep)[namelen] ==
'=')
232 new_environ = (
char **) realloc (
last_environ, (size + 2) *
sizeof (
char *));
236 new_environ = (
char **) malloc ((size + 2) *
sizeof (
char *));
244 new_environ[size] = (
char *)malloc (namelen + 1 + vallen);
245 if (new_environ[size]==0)
253 memcpy ((
char *) new_environ,
environ, size *
sizeof (
char *));
256 memcpy(new_environ[size], name, namelen);
257 new_environ[size][namelen] =
'=';
258 memcpy(&new_environ[size][namelen + 1], value, vallen);
259 new_environ[size + 1] = 0;
264 size_t len = qstrlen (*ep);
265 if (len + 1 < namelen + 1 + vallen)
268 char *newString = (
char *)malloc(namelen + 1 + vallen);
275 memcpy(*ep, name, namelen);
276 (*ep)[namelen] =
'=';
277 memcpy(&(*ep)[namelen + 1], value, vallen);
285 #if defined(_WIN32) && !defined(__CYGWIN__)
286 SetEnvironmentVariable(variable,0);
292 if (variable == NULL || *variable ==
'\0' || strchr (variable,
'=') != NULL)
297 len = qstrlen(variable);
302 if (!qstrncmp(*ep, variable, (uint)len) && (*ep)[len]==
'=')
306 do dp[0] = dp[1];
while (*dp++);
319 return getenv(variable);
324 #if defined(__MINGW32__)
325 return fseeko64(f,offset,whence);
326 #elif defined(_WIN32) && !defined(__CYGWIN__)
327 return _fseeki64(f,offset,whence);
329 return fseeko(f,offset,whence);
335 #if defined(__MINGW32__)
337 #elif defined(_WIN32) && !defined(__CYGWIN__)
346 #if defined(_WIN32) && !defined(__CYGWIN__)
347 QString fn(fileName);
349 return _wfopen((
wchar_t*)fn.ucs2(),(
wchar_t*)m.ucs2());
351 return fopen(fileName,mode);
357 #if defined(_WIN32) && !defined(__CYGWIN__)
366 #if defined(_WIN32) && !defined(__CYGWIN__)
375 #if defined(_WIN32) && !defined(__CYGWIN__)
376 return "gswin32c.exe";
384 #if defined(_WIN32) && !defined(__CYGWIN__)
393 #if defined(_WIN32) || defined(macintosh) || defined(__MACOSX__) || defined(__APPLE__)
402 return popen(name,type);
407 return pclose(stream);
427 #if defined(_WIN32) && !defined(__CYGWIN__)
437 if (isalpha (fileName [0]) && fileName[1] ==
':')
440 char const fst = fileName [0];