Diff for /parser3/src/main/pa_exec.C between versions 1.48.2.18.2.14 and 1.48.2.18.2.17

version 1.48.2.18.2.14, 2003/04/07 15:32:57 version 1.48.2.18.2.17, 2003/07/22 08:19:58
Line 33  static DWORD CreateHiddenConsoleProcess( Line 33  static DWORD CreateHiddenConsoleProcess(
                                         LPHANDLE phOutRead,                                          LPHANDLE phOutRead,
                                         LPHANDLE phErrRead)                                          LPHANDLE phErrRead)
 {  {
     DWORD result=0;          DWORD result=0;
         BOOL fCreated;          BOOL fCreated;
     STARTUPINFO si;          STARTUPINFO si;
     SECURITY_ATTRIBUTES sa={0};          SECURITY_ATTRIBUTES sa={0};
     HANDLE hInRead;          HANDLE hInRead;
     HANDLE hOutWrite;          HANDLE hOutWrite;
     HANDLE hErrWrite;          HANDLE hErrWrite;
           
     // Create pipes          // Create pipes
     // initialize security attributes for handle inheritance (for WinNT)          // initialize security attributes for handle inheritance (for WinNT)
     sa.nLength=sizeof(sa);          sa.nLength=sizeof(sa);
     sa.bInheritHandle=TRUE;          sa.bInheritHandle=TRUE;
     sa.lpSecurityDescriptor=NULL;          sa.lpSecurityDescriptor=NULL;
           
     // create STDIN pipe          // create STDIN pipe
     if(!CreatePipe(&hInRead, phInWrite, &sa, 0))          if(!CreatePipe(&hInRead, phInWrite, &sa, 0))
         goto error;                  goto error;
           
     // create STDOUT pipe          // create STDOUT pipe
     if(!CreatePipe(phOutRead, &hOutWrite, &sa, 0))          if(!CreatePipe(phOutRead, &hOutWrite, &sa, 0))
         goto error;                  goto error;
           
     // create STDERR pipe          // create STDERR pipe
     if(!CreatePipe(phErrRead, &hErrWrite, &sa, 0))          if(!CreatePipe(phErrRead, &hErrWrite, &sa, 0))
         goto error;                  goto error;
           
     // process startup information          // process startup information
     memset(&si, 0, sizeof(si));          memset(&si, 0, sizeof(si));
     si.cb=sizeof(si);           si.cb=sizeof(si); 
     si.dwFlags=STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;          si.dwFlags=STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
     // child process' console must be hidden for Win95 compatibility          // child process' console must be hidden for Win95 compatibility
     si.wShowWindow=SW_HIDE;          si.wShowWindow=SW_HIDE;
     // assign "other" sides of pipes          // assign "other" sides of pipes
     si.hStdInput=hInRead;          si.hStdInput=hInRead;
     si.hStdOutput=hOutWrite;          si.hStdOutput=hOutWrite;
     si.hStdError=hErrWrite;          si.hStdError=hErrWrite;
           
         // calculating script's directory          // calculating script's directory
         char dir[MAX_STRING];          char dir[MAX_STRING];
         strncpy(dir, szCmdLine, MAX_STRING-1); dir[MAX_STRING-1]=0;          strncpy(dir, szCmdLine, MAX_STRING-1); dir[MAX_STRING-1]=0;
         lsplit(dir,' '); // trim arguments          lsplit(dir,' '); // trim arguments
         rsplit(dir,'/'); rsplit(dir,'\\'); // trim filename          rsplit(dir,'/'); rsplit(dir,'\\'); // trim filename
         chdir(dir);          chdir(dir);
           
     // Create a child process (suspended)          // Create a child process (suspended)
     fCreated=CreateProcess(NULL,          fCreated=CreateProcess(NULL,
                               (LPTSTR)szCmdLine,                  (LPTSTR)szCmdLine,
                               NULL,                  NULL,
                               NULL,                  NULL,
                               TRUE,                  TRUE,
                               CREATE_NO_WINDOW,                  CREATE_NO_WINDOW,
                               szEnv,                  szEnv,
                               dir,                  dir,
                               &si,                  &si,
                               ppi);                  ppi);
         if(!fCreated)          if(!fCreated)
                 result=GetLastError();                  result=GetLastError();
           
     CloseHandle(hInRead);          CloseHandle(hInRead);
     CloseHandle(hOutWrite);          CloseHandle(hOutWrite);
     CloseHandle(hErrWrite);          CloseHandle(hErrWrite);
           
     if(!fCreated)          if(!fCreated)
         goto error;                  goto error;
           
     return result;          return result;
           
 error:  error:
         if(!result/*yet*/)          if(!result/*yet*/)
                 result=GetLastError(); // get it                  result=GetLastError(); // get it
           
     CloseHandle(*phInWrite);          CloseHandle(*phInWrite);
     CloseHandle(*phOutRead);          CloseHandle(*phOutRead);
     CloseHandle(*phErrRead);          CloseHandle(*phErrRead);
           
     return result;          return result;
 }  }
   
 static void read_pipe(String& result, HANDLE hOutRead, String::Language lang){  static void read_pipe(String& result, HANDLE hOutRead, String::Language lang){
Line 118  static void read_pipe(String& result, HA Line 118  static void read_pipe(String& result, HA
                 if(!ReadFile(hOutRead, buf, MAX_STRING-1, &size, NULL) || !size)                   if(!ReadFile(hOutRead, buf, MAX_STRING-1, &size, NULL) || !size) 
                         break;                          break;
                 buf[size]=0;                  buf[size]=0;
                 result.append_help_length(buf, size, lang);                  result.append_know_length(buf, size, lang);
         }          }
 }  }
   
Line 135  static const char* buildCommand(const ch Line 135  static const char* buildCommand(const ch
                                 if(*begin==' ') // alx: were an old magic for some linux-es                                  if(*begin==' ') // alx: were an old magic for some linux-es
                                         begin++;                                          begin++;
                                 if(char *end=strchr(begin, '\n')) {                                  if(char *end=strchr(begin, '\n')) {
                                         String string(begin, end-begin);                                          String string(pa_strdup(begin, end-begin));
                                         string << " " << file_spec_cstr;                                          string << " " << file_spec_cstr;
                                         result=string.cstr();                                          result=string.cstr();
                                 }                                  }
Line 284  static void read_pipe(String& result, in Line 284  static void read_pipe(String& result, in
                 if(length<=0)                  if(length<=0)
                         break;                          break;
                 buf[length]=0;                  buf[length]=0;
                 result.append_help_length(buf, length, lang);                  result.append_know_length(buf, length, lang);
         }          }
 }  }
   
Line 305  static void append_env_pair(HashStringSt Line 305  static void append_env_pair(HashStringSt
                 Append_env_pair_info *info) {                  Append_env_pair_info *info) {
 #ifdef WIN32  #ifdef WIN32
         info->string << key << "=" << value;          info->string << key << "=" << value;
         info->string.append_help_length("", 1, String::L_AS_IS); // zero byte          info->string.append_know_length("\1", 1, String::L_AS_IS); // placeholder for of zero byte
 #else  #else
         StringBody body;          StringBody body;
         body << key << "=" << value;          body << key << "=" << value;
Line 343  PA_exec_result pa_exec( Line 343  PA_exec_result pa_exec(
                 Append_env_pair_info info(string);                  Append_env_pair_info info(string);
                 env->for_each(append_env_pair, &info);                  env->for_each(append_env_pair, &info);
                 env_cstr=info.string.cstrm(String::L_UNSPECIFIED);                  env_cstr=info.string.cstrm(String::L_UNSPECIFIED);
                   for(char* replacer=env_cstr; *replacer; replacer++)
                           if(*replacer=='\1')
                                   *replacer=0;
         }          }
         if(DWORD error=CreateHiddenConsoleProcess(cmd, env_cstr, &pi, &hInWrite, &hOutRead, &hErrRead)) {          if(DWORD error=CreateHiddenConsoleProcess(cmd, env_cstr, &pi, &hInWrite, &hOutRead, &hErrRead)) {
                 char szErrorDesc[MAX_STRING];                  char szErrorDesc[MAX_STRING];

Removed from v.1.48.2.18.2.14  
changed lines
  Added in v.1.48.2.18.2.17


E-mail: