2 // This file is part of the aMule Project.
4 // Copyright (c) 2004-2011 aMule Team ( admin@amule.org / http://www.amule.org )
6 // Any parts of this program derived from the xMule, lMule or eMule project,
7 // or contributed by third-party developers are copyrighted by their
10 // This program is free software; you can redistribute it and/or modify
11 // it under the terms of the GNU General Public License as published by
12 // the Free Software Foundation; either version 2 of the License, or
13 // (at your option) any later version.
15 // This program is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
20 // You should have received a copy of the GNU General Public License
21 // along with this program; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include "ExternalConnector.h"
26 #include "config.h" // Needed for VERSION and readline detection
27 #include <common/Format.h> // Needed for CFormat
28 #include <wx/tokenzr.h> // For wxStringTokenizer
31 #ifdef HAVE_LIBREADLINE
32 #if defined(HAVE_READLINE_READLINE_H)
33 #include <readline/readline.h> // Do_not_auto_remove
34 #elif defined(HAVE_READLINE_H)
35 #include <readline.h> // Do_not_auto_remove
36 #endif /* !defined(HAVE_READLINE_H) */
37 #endif /* HAVE_LIBREADLINE */
40 #ifdef HAVE_READLINE_HISTORY
41 #if defined(HAVE_READLINE_HISTORY_H)
42 #include <readline/history.h> // Do_not_auto_remove
43 #elif defined(HAVE_HISTORY_H)
44 #include <history.h> // Do_not_auto_remove
45 #endif /* defined(HAVE_READLINE_HISTORY_H) */
46 #endif /* HAVE_READLINE_HISTORY */
49 #include <ec/cpp/ECFileConfig.h> // Needed for CECFileConfig
50 #include <common/MD5Sum.h>
51 #include "OtherFunctions.h" // Needed for GetPassword()
52 #include "MuleVersion.h" // Needed for GetMuleVersion()
54 #ifdef _MSC_VER // silly warnings about deprecated functions
55 #pragma warning(disable:4996)
58 //-------------------------------------------------------------------
60 CaMuleExternalConnector
* CCommandTree::m_app
;
62 CCommandTree::~CCommandTree()
64 DeleteContents(m_subcommands
);
68 CCommandTree
* CCommandTree::AddCommand(CCommandTree
* command
)
70 command
->m_parent
= this;
71 const wxString
& cmd
= command
->m_command
;
73 for (it
= m_subcommands
.begin(); it
!= m_subcommands
.end(); ++it
) {
74 if ((*it
)->m_command
> cmd
) {
78 m_subcommands
.insert(it
, command
);
83 int CCommandTree::FindCommandId(const wxString
& command
, wxString
& args
, wxString
& cmdstr
) const
85 wxString cmd
= command
.BeforeFirst(wxT(' ')).Lower();
86 for (CmdPosConst_t it
= m_subcommands
.begin(); it
!= m_subcommands
.end(); ++it
) {
87 if ((*it
)->m_command
.Lower() == cmd
) {
88 args
= command
.AfterFirst(wxT(' ')).Trim(false);
89 return (*it
)->FindCommandId(args
, args
, cmdstr
);
92 cmdstr
= GetFullCommand().Lower();
93 if (m_params
== CMD_PARAM_ALWAYS
&& args
.IsEmpty()) {
94 return CMD_ERR_MUST_HAVE_PARAM
;
95 } else if (m_params
== CMD_PARAM_NEVER
&& !args
.IsEmpty()) {
96 return CMD_ERR_NO_PARAM
;
98 if ((m_cmd_id
>= 0) && (m_cmd_id
& CMD_DEPRECATED
)) {
99 m_app
->Show(wxT('\n') + m_verbose
+ wxT('\n'));
100 return m_cmd_id
& ~CMD_DEPRECATED
;
108 wxString
CCommandTree::GetFullCommand() const
110 wxString cmd
= m_command
;
112 const CCommandTree
*parent
= m_parent
;
113 while (parent
&& parent
->m_parent
) {
114 cmd
= parent
->m_command
+ wxT(" ") + cmd
;
115 parent
= parent
->m_parent
;
122 void CCommandTree::PrintHelpFor(const wxString
& command
) const
124 wxString cmd
= command
.BeforeFirst(wxT(' ')).Lower();
125 if (!cmd
.IsEmpty()) {
126 for (CmdPosConst_t it
= m_subcommands
.begin(); it
!= m_subcommands
.end(); ++it
) {
127 if ((*it
)->m_command
.Lower() == cmd
) {
128 (*it
)->PrintHelpFor(command
.AfterFirst(wxT(' ')).Trim(false));
133 m_app
->Show(CFormat(_("Unknown extension '%s' for the '%s' command.\n")) % command
% GetFullCommand());
135 m_app
->Show(CFormat(_("Unknown command '%s'.\n")) % command
);
138 wxString fullcmd
= GetFullCommand();
139 if (!fullcmd
.IsEmpty()) {
140 m_app
->Show(fullcmd
.Upper() + wxT(": ") + wxGetTranslation(m_short
) + wxT("\n"));
141 if (!m_verbose
.IsEmpty()) {
142 m_app
->Show(wxT("\n"));
143 m_app
->Show(wxGetTranslation(m_verbose
));
146 if (m_params
== CMD_PARAM_NEVER
) {
147 m_app
->Show(_("\nThis command cannot have an argument.\n"));
148 } else if (m_params
== CMD_PARAM_ALWAYS
) {
149 m_app
->Show(_("\nThis command must have an argument.\n"));
151 if (m_cmd_id
== CMD_ERR_INCOMPLETE
) {
152 m_app
->Show(_("\nThis command is incomplete, you must use one of the extensions below.\n"));
154 if (!m_subcommands
.empty()) {
158 m_app
->Show(_("\nAvailable extensions:\n"));
160 m_app
->Show(_("Available commands:\n"));
162 for (it
= m_subcommands
.begin(); it
!= m_subcommands
.end(); ++it
) {
163 if (!((*it
)->m_cmd_id
>= 0 && (*it
)->m_cmd_id
& CMD_DEPRECATED
) || m_parent
) {
164 int len
= (*it
)->m_command
.Length();
171 for (it
= m_subcommands
.begin(); it
!= m_subcommands
.end(); ++it
) {
172 if (!((*it
)->m_cmd_id
>= 0 && (*it
)->m_cmd_id
& CMD_DEPRECATED
) || m_parent
) {
173 m_app
->Show((*it
)->m_command
+ wxString(wxT(' '), maxlen
- (*it
)->m_command
.Length()) + wxGetTranslation((*it
)->m_short
) + wxT("\n"));
177 m_app
->Show(CFormat(_("\nAll commands are case insensitive.\nType '%s <command>' to get detailed info on <command>.\n")) % wxT("help"));
181 m_app
->Show(wxT("\n"));
184 //-------------------------------------------------------------------
186 #ifdef HAVE_LIBREADLINE
188 const CmdList_t
* CCommandTree::GetSubCommandsFor(const wxString
& command
, bool mayRestart
) const
190 if (command
.IsEmpty()) {
191 return &m_subcommands
;
194 wxString cmd
= command
.BeforeFirst(wxT(' ')).Lower();
196 if (mayRestart
&& cmd
== wxT("help")) {
197 return GetSubCommandsFor(command
.AfterFirst(wxT(' ')), false);
200 for (CmdPosConst_t it
= m_subcommands
.begin(); it
!= m_subcommands
.end(); ++it
) {
201 if ((*it
)->m_command
.Lower() == cmd
) {
202 return (*it
)->GetSubCommandsFor(command
.AfterFirst(wxT(' ')).Trim(false), mayRestart
);
210 // Forward-declare the completion function to make sure it's declaration
211 // matches the library requirements.
212 rl_compentry_func_t command_completion
;
215 // File-scope pointer to the application's command set.
216 static CCommandTree
* theCommands
;
219 char *command_completion(const char *text
, int state
)
221 static const CmdList_t
* curCommands
;
222 static CmdPosConst_t nextCommand
;
225 wxString
lineBuffer(rl_line_buffer
, *wxConvCurrent
);
226 wxString
prefix(lineBuffer
.Left(rl_point
).BeforeLast(wxT(' ')));
228 curCommands
= theCommands
->GetSubCommandsFor(prefix
);
230 nextCommand
= curCommands
->begin();
236 wxString
test(wxString(text
, *wxConvCurrent
).Lower());
237 while (nextCommand
!= curCommands
->end()) {
238 wxString curTest
= (*nextCommand
)->GetCommand();
240 if (curTest
.Lower().StartsWith(test
)) {
241 return strdup(static_cast<const char *>(unicode2char(curTest
)));
249 #endif /* HAVE_LIBREADLINE */
251 //-------------------------------------------------------------------
253 CaMuleExternalConnector::CaMuleExternalConnector()
254 : m_configFile(NULL
),
259 m_interactive(false),
264 m_NeedsConfigSave(false),
266 m_strFullVersion(NULL
),
267 m_strOSDescription(NULL
)
269 SetAppName(wxT("aMule")); // Do not change!
272 CaMuleExternalConnector::~CaMuleExternalConnector()
276 free(m_strFullVersion
);
277 free(m_strOSDescription
);
280 void CaMuleExternalConnector::OnInitCommandSet()
282 m_commands
.AddCommand(wxT("Quit"), CMD_ID_QUIT
, wxTRANSLATE("Exits from the application."), wxEmptyString
);
283 m_commands
.AddCommand(wxT("Exit"), CMD_ID_QUIT
, wxTRANSLATE("Exits from the application."), wxEmptyString
);
284 m_commands
.AddCommand(wxT("Help"), CMD_ID_HELP
, wxTRANSLATE("Show help."),
286 Do not translate the word 'help', it is a command to the program! */
287 wxTRANSLATE("To get help on a command, type 'help <command>'.\nTo get the full command list type 'help'.\n"));
290 void CaMuleExternalConnector::Show(const wxString
&s
)
293 printf("%s", (const char *)unicode2char(s
));
300 void CaMuleExternalConnector::ShowGreet()
302 wxString text
= GetGreetingTitle();
303 int len
= text
.Length();
304 Show(wxT('\n') + wxString(wxT('-'), 22 + len
) + wxT('\n'));
305 Show(wxT('|') + wxString(wxT(' '), 10) + text
+ wxString(wxT(' '), 10) + wxT('|') + wxT('\n'));
306 Show(wxString(wxT('-'), 22 + len
) + wxT('\n'));
307 // Do not merge the line below, or translators could translate "Help"
308 Show(CFormat(_("\nUse '%s' for command list\n\n")) % wxT("Help"));
311 void CaMuleExternalConnector::Process_Answer(const wxString
& answer
)
313 wxStringTokenizer
tokens(answer
, wxT("\n"));
314 while ( tokens
.HasMoreTokens() ) {
315 Show(wxT(" > ") + tokens
.GetNextToken() + wxT("\n"));
319 bool CaMuleExternalConnector::Parse_Command(const wxString
& buffer
)
322 wxStringTokenizer
tokens(buffer
);
323 while (tokens
.HasMoreTokens()) {
324 cmd
+= tokens
.GetNextToken() + wxT(' ');
331 int cmd_ID
= GetIDFromString(cmd
);
333 cmd_ID
= ProcessCommand(cmd_ID
);
338 m_commands
.PrintHelpFor(GetCmdArgs());
341 error
= _("Syntax error!");
343 case CMD_ERR_PROCESS_CMD
:
344 Show(_("Error processing command - should never happen! Report bug, please\n"));
346 case CMD_ERR_NO_PARAM
:
347 error
= _("This command should not have any parameters.");
349 case CMD_ERR_MUST_HAVE_PARAM
:
350 error
= _("This command must have a parameter.");
352 case CMD_ERR_INVALID_ARG
:
353 error
= _("Invalid argument.");
355 case CMD_ERR_INCOMPLETE
:
356 error
= _("This is an incomplete command.");
359 if (!error
.IsEmpty()) {
360 Show(error
+ wxT('\n'));
361 wxString
helpStr(wxT("help"));
362 if (!GetLastCmdStr().IsEmpty()) {
363 helpStr
<< wxT(' ') << GetLastCmdStr();
365 Show(CFormat(_("Type '%s' to get more help.\n")) % helpStr
);
367 return cmd_ID
== CMD_ID_QUIT
;
370 void CaMuleExternalConnector::GetCommand(const wxString
&prompt
, char* buffer
, size_t buffer_size
)
372 #ifdef HAVE_LIBREADLINE
373 char *text
= readline(unicode2char(prompt
+ wxT("$ ")));
375 (m_InputLine
== 0 || strcmp(text
,m_InputLine
) != 0)) {
382 Show(prompt
+ wxT("$ "));
383 const char *text
= fgets(buffer
, buffer_size
, stdin
); // == buffer if ok, NULL if eof
384 #endif /* HAVE_LIBREADLINE */
386 size_t len
= strlen(text
);
387 if (len
> buffer_size
- 1) {
388 len
= buffer_size
- 1;
390 if (buffer
!= text
) {
391 strncpy(buffer
, text
, len
);
395 strncpy(buffer
, "quit", buffer_size
);
399 void CaMuleExternalConnector::TextShell(const wxString
&prompt
)
404 bool The_End
= false;
406 GetCommand(prompt
, buffer
, sizeof buffer
);
407 buf
= char2unicode(buffer
);
408 The_End
= Parse_Command(buf
);
409 } while ((!The_End
) && (m_ECClient
->IsSocketConnected()));
412 void CaMuleExternalConnector::ConnectAndRun(const wxString
&ProgName
, const wxString
& ProgVersion
)
414 if (m_NeedsConfigSave
) {
420 Show(CFormat(_("This is %s %s %s\n")) % wxString::FromAscii(m_appname
) % wxT(VERSION
) % wxT(SVNDATE
));
422 Show(CFormat(_("This is %s %s\n")) % wxString::FromAscii(m_appname
) % wxT(VERSION
));
425 // HostName, Port and Password
426 if ( m_password
.IsEmpty() ) {
427 m_password
= GetPassword(true);
428 // MD5 hash for an empty string, according to rfc1321.
429 if (m_password
.Encode() == wxT("D41D8CD98F00B204E9800998ECF8427E")) {
434 if (!m_password
.IsEmpty()) {
437 Show(_("\nCreating client...\n"));
438 m_ECClient
= new CRemoteConnect(NULL
);
439 m_ECClient
->SetCapabilities(m_ZLIB
, true, false); // ZLIB, UTF8 numbers, notification
441 // ConnectToCore is blocking since m_ECClient was initialized with NULL
442 if (!m_ECClient
->ConnectToCore(m_host
, m_port
, wxT("foobar"), m_password
.Encode(), ProgName
, ProgVersion
)) {
443 // no connection => close gracefully
444 if (!m_ECClient
->GetServerReply().IsEmpty()) {
445 Show(CFormat(wxT("%s\n")) % m_ECClient
->GetServerReply());
447 Show(CFormat(_("Connection Failed. Unable to connect to %s:%d\n")) % m_host
% m_port
);
449 // Authenticate ourselves
450 // ConnectToCore() already authenticated for us.
451 //m_ECClient->ConnectionEstablished();
452 Show(m_ECClient
->GetServerReply()+wxT("\n"));
453 if (m_ECClient
->IsSocketConnected()) {
461 Show(CFormat(_("\nOk, exiting %s...\n")) % ProgName
);
465 m_ECClient
->DestroySocket();
467 Show(_("Cannot connect with an empty password.\nYou must specify a password either in config file\nor on command-line, or enter one when asked.\n\nExiting...\n"));
471 void CaMuleExternalConnector::OnInitCmdLine(wxCmdLineParser
& parser
, const char* appname
)
475 parser
.AddSwitch(wxEmptyString
, wxT("help"),
476 _("Show this help text."),
477 wxCMD_LINE_PARAM_OPTIONAL
);
478 parser
.AddOption(wxT("h"), wxT("host"),
479 _("Host where aMule is running. (default: localhost)"),
480 wxCMD_LINE_VAL_STRING
, wxCMD_LINE_PARAM_OPTIONAL
);
481 parser
.AddOption(wxT("p"), wxT("port"),
482 _("aMule's port for External Connection. (default: 4712)"),
483 wxCMD_LINE_VAL_NUMBER
, wxCMD_LINE_PARAM_OPTIONAL
);
484 parser
.AddOption(wxT("P"), wxT("password"),
485 _("External Connection password."),
486 wxCMD_LINE_VAL_STRING
, wxCMD_LINE_PARAM_OPTIONAL
);
487 parser
.AddOption(wxT("f"), wxT("config-file"),
488 _("Read configuration from file."),
489 wxCMD_LINE_VAL_STRING
, wxCMD_LINE_PARAM_OPTIONAL
);
490 parser
.AddSwitch(wxT("q"), wxT("quiet"),
491 _("Do not print any output to stdout."),
492 wxCMD_LINE_PARAM_OPTIONAL
);
493 parser
.AddSwitch(wxT("v"), wxT("verbose"),
494 _("Be verbose - show also debug messages."),
495 wxCMD_LINE_PARAM_OPTIONAL
);
496 parser
.AddOption(wxT("l"), wxT("locale"),
497 _("Sets program locale (language)."),
498 wxCMD_LINE_VAL_STRING
, wxCMD_LINE_PARAM_OPTIONAL
);
499 parser
.AddSwitch(wxT("w"), wxT("write-config"),
500 _("Write command line options to config file."),
501 wxCMD_LINE_PARAM_OPTIONAL
);
502 parser
.AddOption(wxEmptyString
, wxT("create-config-from"),
503 _("Creates config file based on aMule's config file."),
504 wxCMD_LINE_VAL_STRING
, wxCMD_LINE_PARAM_OPTIONAL
);
505 parser
.AddSwitch(wxEmptyString
, wxT("version"),
506 _("Print program version."),
507 wxCMD_LINE_PARAM_OPTIONAL
);
510 bool CaMuleExternalConnector::OnCmdLineParsed(wxCmdLineParser
& parser
)
512 if (parser
.Found(wxT("version"))) {
513 printf("%s %s\n", m_appname
, (const char *)unicode2char(GetMuleVersion()));
517 if (!parser
.Found(wxT("config-file"), &m_configFileName
)) {
518 m_configFileName
= wxT("remote.conf");
520 m_configDir
= GetConfigDir(m_configFileName
);
521 m_configFileName
= m_configDir
+ m_configFileName
;
523 wxString aMuleConfigFile
;
524 if (parser
.Found(wxT("create-config-from"), &aMuleConfigFile
)) {
525 aMuleConfigFile
= FinalizeFilename(aMuleConfigFile
);
526 if (!::wxFileExists(aMuleConfigFile
)) {
527 fprintf(stderr
, "%s\n", (const char *)unicode2char(wxT("FATAL ERROR: File does not exist: ") + aMuleConfigFile
));
530 CECFileConfig
aMuleConfig(aMuleConfigFile
);
531 LoadAmuleConfig(aMuleConfig
);
533 m_configFile
->Flush();
539 if ( !parser
.Found(wxT("host"), &m_host
) ) {
540 if ( m_host
.IsEmpty() ) {
541 m_host
= wxT("localhost");
546 if (parser
.Found(wxT("port"), &port
)) {
551 if (parser
.Found(wxT("password"), &pass_plain
)) {
552 if (!pass_plain
.IsEmpty()) {
553 m_password
.Decode(MD5Sum(pass_plain
).GetHash());
559 if (parser
.Found(wxT("write-config"))) {
560 m_NeedsConfigSave
= true;
563 parser
.Found(wxT("locale"), &m_language
);
565 if (parser
.Found(wxT("help"))) {
570 m_KeepQuiet
= parser
.Found(wxT("quiet"));
571 m_Verbose
= parser
.Found(wxT("verbose"));
576 void CaMuleExternalConnector::LoadAmuleConfig(CECFileConfig
& cfg
)
578 m_host
= wxT("localhost");
579 m_port
= cfg
.Read(wxT("/ExternalConnect/ECPort"), 4712l);
580 cfg
.ReadHash(wxT("/ExternalConnect/ECPassword"), &m_password
);
581 m_language
= cfg
.Read(wxT("/eMule/Language"), wxEmptyString
);
585 void CaMuleExternalConnector::LoadConfigFile()
588 m_configFile
= new CECFileConfig(m_configFileName
);
591 m_language
= m_configFile
->Read(wxT("/Locale"), wxEmptyString
);
592 m_host
= m_configFile
->Read(wxT("/EC/Host"), wxEmptyString
);
593 m_port
= m_configFile
->Read(wxT("/EC/Port"), 4712l);
594 m_configFile
->ReadHash(wxT("/EC/Password"), &m_password
);
595 m_ZLIB
= m_configFile
->Read(wxT("/EC/ZLIB"), 1l) != 0;
599 void CaMuleExternalConnector::SaveConfigFile()
601 if (!wxFileName::DirExists(m_configDir
)) {
602 wxFileName::Mkdir(m_configDir
);
605 m_configFile
= new CECFileConfig(m_configFileName
);
608 m_configFile
->Write(wxT("/Locale"), m_language
);
609 m_configFile
->Write(wxT("/EC/Host"), m_host
);
610 m_configFile
->Write(wxT("/EC/Port"), m_port
);
611 m_configFile
->WriteHash(wxT("/EC/Password"), m_password
);
615 bool CaMuleExternalConnector::OnInit()
618 #if wxUSE_ON_FATAL_EXCEPTION
619 // catch fatal exceptions
620 wxHandleFatalExceptions(true);
624 // If we didn't know that OnInit is called only once when creating the
625 // object, it could cause a memory leak. The two pointers below should
626 // be free()'d before assigning the new value.
627 // cppcheck-suppress publicAllocationError
628 m_strFullVersion
= strdup((const char *)unicode2char(GetMuleVersion()));
629 m_strOSDescription
= strdup((const char *)unicode2char(wxGetOsDescription()));
631 // Handle uncaught exceptions
632 InstallMuleExceptionHandler();
634 bool retval
= wxApp::OnInit();
636 InitCustomLanguages();
637 SetLocale(m_language
);
639 #ifdef HAVE_LIBREADLINE
640 // Allow conditional parsing of the ~/.inputrc file.
642 // OnInitCmdLine() is called from wxApp::OnInit() above,
643 // thus m_appname is already set.
644 rl_readline_name
= m_appname
;
646 // Allow completion of our commands
647 theCommands
= &m_commands
;
648 rl_completion_entry_function
= &command_completion
;
654 wxString
CaMuleExternalConnector::SetLocale(const wxString
& language
)
656 if (!language
.IsEmpty()) {
657 m_language
= language
;
661 m_locale
= new wxLocale
;
662 InitLocale(*m_locale
, StrLang2wx(language
));
665 return m_locale
== NULL
? wxString() : m_locale
->GetCanonicalName();
668 #if !wxUSE_GUI && defined(__WXMAC__) && !wxCHECK_VERSION(2, 9, 0)
670 #include <wx/apptrait.h> // Do_not_auto_remove
671 #include <wx/stdpaths.h> // Do_not_auto_remove
673 class CaMuleExternalConnectorTraits
: public wxConsoleAppTraits
676 virtual wxStandardPathsBase
& GetStandardPaths()
682 static wxStandardPathsCF s_stdPaths
;
685 wxStandardPathsCF
CaMuleExternalConnectorTraits::s_stdPaths
;
687 wxAppTraits
* CaMuleExternalConnector::CreateTraits()
689 return new CaMuleExternalConnectorTraits
;
694 #if wxUSE_ON_FATAL_EXCEPTION
695 // Gracefully handle fatal exceptions and print backtrace if possible
696 void CaMuleExternalConnector::OnFatalException()
698 /* Print the backtrace */
699 fprintf(stderr
, "\n--------------------------------------------------------------------------------\n");
700 fprintf(stderr
, "A fatal error has occurred and %s has crashed.\n", m_appname
);
701 fprintf(stderr
, "Please assist us in fixing this problem by posting the backtrace below in our\n");
702 fprintf(stderr
, "'aMule Crashes' forum and include as much information as possible regarding the\n");
703 fprintf(stderr
, "circumstances of this crash. The forum is located here:\n");
704 fprintf(stderr
, " http://forum.amule.org/index.php?board=67.0\n");
705 fprintf(stderr
, "If possible, please try to generate a real backtrace of this crash:\n");
706 fprintf(stderr
, " http://wiki.amule.org/wiki/Backtraces\n\n");
707 fprintf(stderr
, "----------------------------=| BACKTRACE FOLLOWS: |=----------------------------\n");
708 fprintf(stderr
, "Current version is: %s %s\n", m_appname
, m_strFullVersion
);
709 fprintf(stderr
, "Running on: %s\n\n", m_strOSDescription
);
711 print_backtrace(1); // 1 == skip this function.
713 fprintf(stderr
, "\n--------------------------------------------------------------------------------\n");
718 void CaMuleExternalConnector::OnAssertFailure(const wxChar
*file
, int line
, const wxChar
*func
, const wxChar
*cond
, const wxChar
*msg
)
720 #if !defined wxUSE_STACKWALKER || !wxUSE_STACKWALKER
721 wxString errmsg
= CFormat( wxT("%s:%s:%d: Assertion '%s' failed. %s") ) % file
% func
% line
% cond
% ( msg
? msg
: wxT("") );
723 fprintf(stderr
, "Assertion failed: %s\n", (const char*)unicode2char(errmsg
));
725 // Skip the function-calls directly related to the assert call.
726 fprintf(stderr
, "\nBacktrace follows:\n");
728 fprintf(stderr
, "\n");
730 wxApp::OnAssertFailure(file
, line
, func
, cond
, msg
);
734 // File_checked_for_headers