minor changes (a couple of error messages added to wxExecute)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@867 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
ddbbbdd486
commit
02847e5984
@ -172,7 +172,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxPrintPaperType, wxObject)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxPrintPaperDatabase, wxList)
|
||||
#endif
|
||||
|
||||
wxPostScriptDC::wxPostScriptDC (void)
|
||||
wxPostScriptDC::wxPostScriptDC ()
|
||||
{
|
||||
// m_yOrigin = 792; // For EPS output
|
||||
m_yOrigin = 842; // For A4 output
|
||||
@ -236,7 +236,7 @@ bool wxPostScriptDC::Create(const wxString& file, bool interactive, wxWindow *pa
|
||||
return m_ok;
|
||||
}
|
||||
|
||||
wxPostScriptDC::~wxPostScriptDC (void)
|
||||
wxPostScriptDC::~wxPostScriptDC ()
|
||||
{
|
||||
if (m_pstream)
|
||||
delete m_pstream;
|
||||
@ -305,7 +305,7 @@ void wxPostScriptDC::SetClippingRegion (long cx, long cy, long cw, long ch)
|
||||
*m_pstream << "closepath clip newpath\n";
|
||||
}
|
||||
|
||||
void wxPostScriptDC::DestroyClippingRegion (void)
|
||||
void wxPostScriptDC::DestroyClippingRegion ()
|
||||
{
|
||||
if (!m_pstream)
|
||||
return;
|
||||
@ -316,7 +316,7 @@ void wxPostScriptDC::DestroyClippingRegion (void)
|
||||
}
|
||||
}
|
||||
|
||||
void wxPostScriptDC::Clear (void)
|
||||
void wxPostScriptDC::Clear ()
|
||||
{
|
||||
}
|
||||
|
||||
@ -1084,7 +1084,7 @@ bool wxPostScriptDC::StartDoc (const wxString& message)
|
||||
}
|
||||
|
||||
|
||||
void wxPostScriptDC::EndDoc (void)
|
||||
void wxPostScriptDC::EndDoc ()
|
||||
{
|
||||
static char wxPostScriptHeaderReencodeISO1[] =
|
||||
"\n/reencodeISO {\n"
|
||||
@ -1323,7 +1323,7 @@ void wxPostScriptDC::EndDoc (void)
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxPostScriptDC::StartPage (void)
|
||||
void wxPostScriptDC::StartPage ()
|
||||
{
|
||||
if (!m_pstream)
|
||||
return;
|
||||
@ -1355,7 +1355,7 @@ void wxPostScriptDC::StartPage (void)
|
||||
*m_pstream << translate_x << " " << translate_y << " translate\n";
|
||||
}
|
||||
|
||||
void wxPostScriptDC::EndPage (void)
|
||||
void wxPostScriptDC::EndPage ()
|
||||
{
|
||||
if (!m_pstream)
|
||||
return;
|
||||
@ -1545,7 +1545,7 @@ Blit (long xdest, long ydest, long fwidth, long fheight,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
long wxPostScriptDC::GetCharHeight (void)
|
||||
long wxPostScriptDC::GetCharHeight ()
|
||||
{
|
||||
if (m_font.Ok())
|
||||
return m_font.GetPointSize ();
|
||||
@ -1866,7 +1866,7 @@ void wxPostScriptDC::DrawSpline( wxList *points )
|
||||
*(GetStream()) << c << " " << (GetYOrigin() - d) << " lineto stroke\n";
|
||||
}
|
||||
|
||||
long wxPostScriptDC::GetCharWidth (void)
|
||||
long wxPostScriptDC::GetCharWidth ()
|
||||
{
|
||||
// Chris Breeze: reasonable approximation using wxMODERN/Courier
|
||||
return (long) (GetCharHeight() * 72.0 / 120.0);
|
||||
@ -2136,7 +2136,7 @@ wxDialog(parent, -1, title, pos, size, style)
|
||||
wxEndBusyCursor();
|
||||
}
|
||||
|
||||
int wxPostScriptPrintDialog::ShowModal (void)
|
||||
int wxPostScriptPrintDialog::ShowModal ()
|
||||
{
|
||||
if ( wxDialog::ShowModal() == wxID_OK )
|
||||
{
|
||||
@ -2221,27 +2221,27 @@ void wxSetAFMPath(const char *f)
|
||||
}
|
||||
|
||||
// Get current values
|
||||
char *wxGetPrinterCommand(void)
|
||||
char *wxGetPrinterCommand()
|
||||
{
|
||||
return wxThePrintSetupData->GetPrinterCommand();
|
||||
}
|
||||
|
||||
char *wxGetPrintPreviewCommand(void)
|
||||
char *wxGetPrintPreviewCommand()
|
||||
{
|
||||
return wxThePrintSetupData->GetPrintPreviewCommand();
|
||||
}
|
||||
|
||||
char *wxGetPrinterOptions(void)
|
||||
char *wxGetPrinterOptions()
|
||||
{
|
||||
return wxThePrintSetupData->GetPrinterOptions();
|
||||
}
|
||||
|
||||
char *wxGetPrinterFile(void)
|
||||
char *wxGetPrinterFile()
|
||||
{
|
||||
return wxThePrintSetupData->GetPrinterFile();
|
||||
}
|
||||
|
||||
int wxGetPrinterOrientation(void)
|
||||
int wxGetPrinterOrientation()
|
||||
{
|
||||
return wxThePrintSetupData->GetPrinterOrientation();
|
||||
}
|
||||
@ -2256,12 +2256,12 @@ void wxGetPrinterTranslation(long *x, long *y)
|
||||
wxThePrintSetupData->GetPrinterTranslation(x, y);
|
||||
}
|
||||
|
||||
int wxGetPrinterMode(void)
|
||||
int wxGetPrinterMode()
|
||||
{
|
||||
return wxThePrintSetupData->GetPrinterMode();
|
||||
}
|
||||
|
||||
char *wxGetAFMPath(void)
|
||||
char *wxGetAFMPath()
|
||||
{
|
||||
return wxThePrintSetupData->GetAFMPath();
|
||||
}
|
||||
@ -2270,7 +2270,7 @@ char *wxGetAFMPath(void)
|
||||
* Print setup data
|
||||
*/
|
||||
|
||||
wxPrintSetupData::wxPrintSetupData(void)
|
||||
wxPrintSetupData::wxPrintSetupData()
|
||||
{
|
||||
printerCommand = (char *) NULL;
|
||||
previewCommand = (char *) NULL;
|
||||
@ -2288,7 +2288,7 @@ wxPrintSetupData::wxPrintSetupData(void)
|
||||
printerFile = (char *) NULL;
|
||||
}
|
||||
|
||||
wxPrintSetupData::~wxPrintSetupData(void)
|
||||
wxPrintSetupData::~wxPrintSetupData()
|
||||
{
|
||||
if (printerCommand)
|
||||
delete[] printerCommand;
|
||||
@ -2411,32 +2411,32 @@ void wxPrintSetupData::SetColour(bool col)
|
||||
}
|
||||
|
||||
// Get current values
|
||||
char *wxPrintSetupData::GetPrinterCommand(void)
|
||||
char *wxPrintSetupData::GetPrinterCommand()
|
||||
{
|
||||
return printerCommand;
|
||||
}
|
||||
|
||||
char *wxPrintSetupData::GetPrintPreviewCommand(void)
|
||||
char *wxPrintSetupData::GetPrintPreviewCommand()
|
||||
{
|
||||
return previewCommand;
|
||||
}
|
||||
|
||||
char *wxPrintSetupData::GetPrinterOptions(void)
|
||||
char *wxPrintSetupData::GetPrinterOptions()
|
||||
{
|
||||
return printerFlags;
|
||||
}
|
||||
|
||||
char *wxPrintSetupData::GetPrinterFile(void)
|
||||
char *wxPrintSetupData::GetPrinterFile()
|
||||
{
|
||||
return printerFile;
|
||||
}
|
||||
|
||||
char *wxPrintSetupData::GetPaperName(void)
|
||||
char *wxPrintSetupData::GetPaperName()
|
||||
{
|
||||
return paperName;
|
||||
}
|
||||
|
||||
int wxPrintSetupData::GetPrinterOrientation(void)
|
||||
int wxPrintSetupData::GetPrinterOrientation()
|
||||
{
|
||||
return printerOrient;
|
||||
}
|
||||
@ -2453,17 +2453,17 @@ void wxPrintSetupData::GetPrinterTranslation(long *x, long *y)
|
||||
*y = printerTranslateY;
|
||||
}
|
||||
|
||||
int wxPrintSetupData::GetPrinterMode(void)
|
||||
int wxPrintSetupData::GetPrinterMode()
|
||||
{
|
||||
return printerMode;
|
||||
}
|
||||
|
||||
char *wxPrintSetupData::GetAFMPath(void)
|
||||
char *wxPrintSetupData::GetAFMPath()
|
||||
{
|
||||
return afmPath;
|
||||
}
|
||||
|
||||
bool wxPrintSetupData::GetColour(void)
|
||||
bool wxPrintSetupData::GetColour()
|
||||
{
|
||||
return printColour;
|
||||
}
|
||||
@ -2538,21 +2538,21 @@ wxPrintPaperType::wxPrintPaperType(const char *name, int wmm, int hmm, int wp, i
|
||||
pageName = copystring(name);
|
||||
}
|
||||
|
||||
wxPrintPaperType::~wxPrintPaperType(void)
|
||||
wxPrintPaperType::~wxPrintPaperType()
|
||||
{
|
||||
delete[] pageName;
|
||||
}
|
||||
|
||||
wxPrintPaperDatabase::wxPrintPaperDatabase(void):wxList(wxKEY_STRING)
|
||||
wxPrintPaperDatabase::wxPrintPaperDatabase():wxList(wxKEY_STRING)
|
||||
{
|
||||
DeleteContents(TRUE);
|
||||
}
|
||||
|
||||
wxPrintPaperDatabase::~wxPrintPaperDatabase(void)
|
||||
wxPrintPaperDatabase::~wxPrintPaperDatabase()
|
||||
{
|
||||
}
|
||||
|
||||
void wxPrintPaperDatabase::CreateDatabase(void)
|
||||
void wxPrintPaperDatabase::CreateDatabase()
|
||||
{
|
||||
// Need correct values for page size in pixels.
|
||||
// Each unit is one 'point' = 1/72 of an inch.
|
||||
@ -2570,7 +2570,7 @@ void wxPrintPaperDatabase::CreateDatabase(void)
|
||||
AddPaperType(_("Legal 8 1/2 x 14 in"), 216, 356, 612, 1009);
|
||||
}
|
||||
|
||||
void wxPrintPaperDatabase::ClearDatabase(void)
|
||||
void wxPrintPaperDatabase::ClearDatabase()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
@ -16,6 +16,9 @@
|
||||
#include "wx/utils.h"
|
||||
#include "wx/string.h"
|
||||
|
||||
#include "wx/intl.h"
|
||||
#include "wx/log.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
@ -30,7 +33,7 @@
|
||||
|
||||
|
||||
#ifdef __SVR4__
|
||||
#include <sys/systeminfo.h>
|
||||
#include <sys/systeminfo.h>
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
@ -203,7 +206,7 @@ void wxFatalError( const wxString &msg, const wxString &title )
|
||||
if (!title.IsNull()) fprintf( stderr, "%s ", WXSTRINGCAST(title) );
|
||||
if (!msg.IsNull()) fprintf( stderr, ": %s", WXSTRINGCAST(msg) );
|
||||
fprintf( stderr, ".\n" );
|
||||
exit(1);
|
||||
exit(3); // the same exit code as for abort()
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
@ -222,10 +225,11 @@ bool wxDirExists( const wxString& dir )
|
||||
// subprocess routines
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
typedef struct {
|
||||
struct wxEndProcessData
|
||||
{
|
||||
gint pid, tag;
|
||||
wxProcess *process;
|
||||
} wxEndProcessData;
|
||||
};
|
||||
|
||||
static void GTK_EndProcessDetector(gpointer data, gint source,
|
||||
GdkInputCondition WXUNUSED(condition) )
|
||||
@ -261,12 +265,11 @@ long wxExecute( char **argv, bool sync, wxProcess *process )
|
||||
wxEndProcessData *data = new wxEndProcessData;
|
||||
int end_proc_detect[2];
|
||||
|
||||
if (*argv == NULL)
|
||||
return 0;
|
||||
wxCHECK_MSG( *argv, 0, "can't exec empty command" );
|
||||
|
||||
/* Create pipes */
|
||||
if (pipe(end_proc_detect) == -1) {
|
||||
perror("pipe failed");
|
||||
wxLogSysError(_("Pipe creation failed"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -277,33 +280,34 @@ long wxExecute( char **argv, bool sync, wxProcess *process )
|
||||
pid_t pid = fork();
|
||||
#endif
|
||||
if (pid == -1) {
|
||||
perror ("fork failed");
|
||||
// error
|
||||
wxLogSysError(_("Fork failed"));
|
||||
return 0;
|
||||
} else if (pid == 0) {
|
||||
/* Close fd not useful */
|
||||
}
|
||||
else if (pid == 0) {
|
||||
// we're in child
|
||||
close(end_proc_detect[0]); // close reading side
|
||||
|
||||
/* child */
|
||||
#ifdef _AIX
|
||||
execvp ((const char *)*argv, (const char **)argv);
|
||||
#else
|
||||
execvp (*argv, argv);
|
||||
#endif
|
||||
if (errno == ENOENT)
|
||||
wxError("command not found", *argv);
|
||||
else
|
||||
perror (*argv);
|
||||
wxError("could not execute", *argv);
|
||||
_exit (-1);
|
||||
}
|
||||
// there is no return after successful exec()
|
||||
wxLogSysError(_("Can't execute '%s'"), *argv);
|
||||
|
||||
_exit(-1);
|
||||
}
|
||||
else {
|
||||
// we're in parent
|
||||
close(end_proc_detect[1]); // close writing side
|
||||
data->tag = gdk_input_add(end_proc_detect[0], GDK_INPUT_READ,
|
||||
GTK_EndProcessDetector, (gpointer)data);
|
||||
data->pid = pid;
|
||||
if (!sync) {
|
||||
data->process = process;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
data->process = (wxProcess *) NULL;
|
||||
data->pid = -(data->pid);
|
||||
|
||||
@ -313,24 +317,30 @@ long wxExecute( char **argv, bool sync, wxProcess *process )
|
||||
delete data;
|
||||
}
|
||||
|
||||
// @@@ our return value indicates success even if execvp() in the child
|
||||
// failed!
|
||||
return pid;
|
||||
}
|
||||
};
|
||||
|
||||
long wxExecute( const wxString& command, bool sync, wxProcess *process )
|
||||
{
|
||||
if (command.IsNull() || command == "") return FALSE;
|
||||
static const char *IFS = " \t\n";
|
||||
|
||||
wxCHECK_MSG( !command.IsEmpty(), 0, "can't exec empty command" );
|
||||
|
||||
int argc = 0;
|
||||
char *argv[127];
|
||||
char tmp[1024];
|
||||
const char *IFS = " \t\n";
|
||||
char *tmp = new char[command.Len() + 1];
|
||||
strcpy(tmp, command);
|
||||
|
||||
strncpy (tmp, command, sizeof(tmp) / sizeof(char) - 1);
|
||||
tmp[sizeof (tmp) / sizeof (char) - 1] = '\0';
|
||||
argv[argc++] = strtok (tmp, IFS);
|
||||
argv[argc++] = strtok(tmp, IFS);
|
||||
while ((argv[argc++] = strtok((char *) NULL, IFS)) != NULL)
|
||||
/* loop */ ;
|
||||
return wxExecute(argv, sync, process);
|
||||
|
||||
long lRc = wxExecute(argv, sync, process);
|
||||
|
||||
delete [] tmp;
|
||||
|
||||
return lRc;
|
||||
};
|
||||
|
||||
|
||||
|
@ -16,6 +16,9 @@
|
||||
#include "wx/utils.h"
|
||||
#include "wx/string.h"
|
||||
|
||||
#include "wx/intl.h"
|
||||
#include "wx/log.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
@ -30,7 +33,7 @@
|
||||
|
||||
|
||||
#ifdef __SVR4__
|
||||
#include <sys/systeminfo.h>
|
||||
#include <sys/systeminfo.h>
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
@ -203,7 +206,7 @@ void wxFatalError( const wxString &msg, const wxString &title )
|
||||
if (!title.IsNull()) fprintf( stderr, "%s ", WXSTRINGCAST(title) );
|
||||
if (!msg.IsNull()) fprintf( stderr, ": %s", WXSTRINGCAST(msg) );
|
||||
fprintf( stderr, ".\n" );
|
||||
exit(1);
|
||||
exit(3); // the same exit code as for abort()
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
@ -222,10 +225,11 @@ bool wxDirExists( const wxString& dir )
|
||||
// subprocess routines
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
typedef struct {
|
||||
struct wxEndProcessData
|
||||
{
|
||||
gint pid, tag;
|
||||
wxProcess *process;
|
||||
} wxEndProcessData;
|
||||
};
|
||||
|
||||
static void GTK_EndProcessDetector(gpointer data, gint source,
|
||||
GdkInputCondition WXUNUSED(condition) )
|
||||
@ -261,12 +265,11 @@ long wxExecute( char **argv, bool sync, wxProcess *process )
|
||||
wxEndProcessData *data = new wxEndProcessData;
|
||||
int end_proc_detect[2];
|
||||
|
||||
if (*argv == NULL)
|
||||
return 0;
|
||||
wxCHECK_MSG( *argv, 0, "can't exec empty command" );
|
||||
|
||||
/* Create pipes */
|
||||
if (pipe(end_proc_detect) == -1) {
|
||||
perror("pipe failed");
|
||||
wxLogSysError(_("Pipe creation failed"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -277,33 +280,34 @@ long wxExecute( char **argv, bool sync, wxProcess *process )
|
||||
pid_t pid = fork();
|
||||
#endif
|
||||
if (pid == -1) {
|
||||
perror ("fork failed");
|
||||
// error
|
||||
wxLogSysError(_("Fork failed"));
|
||||
return 0;
|
||||
} else if (pid == 0) {
|
||||
/* Close fd not useful */
|
||||
}
|
||||
else if (pid == 0) {
|
||||
// we're in child
|
||||
close(end_proc_detect[0]); // close reading side
|
||||
|
||||
/* child */
|
||||
#ifdef _AIX
|
||||
execvp ((const char *)*argv, (const char **)argv);
|
||||
#else
|
||||
execvp (*argv, argv);
|
||||
#endif
|
||||
if (errno == ENOENT)
|
||||
wxError("command not found", *argv);
|
||||
else
|
||||
perror (*argv);
|
||||
wxError("could not execute", *argv);
|
||||
_exit (-1);
|
||||
}
|
||||
// there is no return after successful exec()
|
||||
wxLogSysError(_("Can't execute '%s'"), *argv);
|
||||
|
||||
_exit(-1);
|
||||
}
|
||||
else {
|
||||
// we're in parent
|
||||
close(end_proc_detect[1]); // close writing side
|
||||
data->tag = gdk_input_add(end_proc_detect[0], GDK_INPUT_READ,
|
||||
GTK_EndProcessDetector, (gpointer)data);
|
||||
data->pid = pid;
|
||||
if (!sync) {
|
||||
data->process = process;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
data->process = (wxProcess *) NULL;
|
||||
data->pid = -(data->pid);
|
||||
|
||||
@ -313,24 +317,30 @@ long wxExecute( char **argv, bool sync, wxProcess *process )
|
||||
delete data;
|
||||
}
|
||||
|
||||
// @@@ our return value indicates success even if execvp() in the child
|
||||
// failed!
|
||||
return pid;
|
||||
}
|
||||
};
|
||||
|
||||
long wxExecute( const wxString& command, bool sync, wxProcess *process )
|
||||
{
|
||||
if (command.IsNull() || command == "") return FALSE;
|
||||
static const char *IFS = " \t\n";
|
||||
|
||||
wxCHECK_MSG( !command.IsEmpty(), 0, "can't exec empty command" );
|
||||
|
||||
int argc = 0;
|
||||
char *argv[127];
|
||||
char tmp[1024];
|
||||
const char *IFS = " \t\n";
|
||||
char *tmp = new char[command.Len() + 1];
|
||||
strcpy(tmp, command);
|
||||
|
||||
strncpy (tmp, command, sizeof(tmp) / sizeof(char) - 1);
|
||||
tmp[sizeof (tmp) / sizeof (char) - 1] = '\0';
|
||||
argv[argc++] = strtok (tmp, IFS);
|
||||
argv[argc++] = strtok(tmp, IFS);
|
||||
while ((argv[argc++] = strtok((char *) NULL, IFS)) != NULL)
|
||||
/* loop */ ;
|
||||
return wxExecute(argv, sync, process);
|
||||
|
||||
long lRc = wxExecute(argv, sync, process);
|
||||
|
||||
delete [] tmp;
|
||||
|
||||
return lRc;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user