1 //####COPYRIGHTBEGIN####
3 // ----------------------------------------------------------------------------
4 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
6 // This program is part of the eCos host tools.
8 // This program is free software; you can redistribute it and/or modify it
9 // under the terms of the GNU General Public License as published by the Free
10 // Software Foundation; either version 2 of the License, or (at your option)
13 // This program is distributed in the hope that it will be useful, but WITHOUT
14 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 // You should have received a copy of the GNU General Public License along with
19 // this program; if not, write to the Free Software Foundation, Inc.,
20 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 // ----------------------------------------------------------------------------
24 //####COPYRIGHTEND####
25 // PkgAdminTclWaitDlg.cpp : implementation file
30 #include "PkgAdminTclWaitDlg.h"
36 static char THIS_FILE[] = __FILE__;
39 /////////////////////////////////////////////////////////////////////////////
40 // CPkgAdminTclWaitDlg dialog
43 CPkgAdminTclWaitDlg::CPkgAdminTclWaitDlg(CWnd* pParent /*=NULL*/)
44 : CDialog(CPkgAdminTclWaitDlg::IDD, pParent)
46 //{{AFX_DATA_INIT(CPkgAdminTclWaitDlg)
47 // NOTE: the ClassWizard will add member initialization here
52 void CPkgAdminTclWaitDlg::DoDataExchange(CDataExchange* pDX)
54 CDialog::DoDataExchange(pDX);
55 //{{AFX_DATA_MAP(CPkgAdminTclWaitDlg)
56 // NOTE: the ClassWizard will add DDX and DDV calls here
61 BEGIN_MESSAGE_MAP(CPkgAdminTclWaitDlg, CDialog)
62 //{{AFX_MSG_MAP(CPkgAdminTclWaitDlg)
67 /////////////////////////////////////////////////////////////////////////////
68 // CPkgAdminTclWaitDlg message handlers
70 // The thread function for executing ecosadmin.tcl
71 UINT CPkgAdminTclWaitDlg::EvalTclThread (LPVOID pvParam)
73 // invoke the Tcl command specified in the data structure
74 EvalTclStruct * pParam = (EvalTclStruct *) pvParam;
75 Tcl_Interp * interp = Tcl_CreateInterp ();
76 Tcl_Channel outchan = Tcl_OpenFileChannel (interp, "nul", "a+", 777);
77 Tcl_SetStdChannel (outchan, TCL_STDOUT); // direct standard output to NUL:
78 char * pszStatus = Tcl_SetVar (interp, "argv0", pParam->argv0, NULL);
79 pszStatus = Tcl_SetVar (interp, "argv", pParam->argv, NULL);
80 pszStatus = Tcl_SetVar (interp, "argc", pParam->argc, NULL);
81 pszStatus = Tcl_SetVar (interp, "gui_mode", "1", NULL); // return errors in result string
82 pParam->status = Tcl_EvalFile (interp, pParam->argv0);
83 pParam->result = Tcl_GetStringResult (interp);
84 Tcl_SetStdChannel (NULL, TCL_STDOUT);
85 Tcl_UnregisterChannel (interp, outchan);
86 Tcl_DeleteInterp (interp);
88 // close the wait dialog to signal completion
89 ::PostMessage (pParam->hwnd, WM_CLOSE, 0, 0);
93 int CPkgAdminTclWaitDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
95 if (CDialog::OnCreate(lpCreateStruct) == -1)
98 etsInfo.hwnd = m_hWnd; // pass the window handle of the wait dialog into the thread
99 AfxBeginThread (EvalTclThread, &etsInfo, 0, 0, 0, NULL);