diff options
author | Rüdiger Timm <rt@openoffice.org> | 2004-11-26 13:16:52 +0000 |
---|---|---|
committer | Rüdiger Timm <rt@openoffice.org> | 2004-11-26 13:16:52 +0000 |
commit | cc713419dd805949dee36f5ea49911af11cb1437 (patch) | |
tree | 2b1a25259db4d78cd485d5d8f2c97ccac32a6d78 /crashrep | |
parent | 2076dfa71380fa1ac7e500497696c137ec62cb96 (diff) |
INTEGRATION: CWS recovery04 (1.18.10); FILE MERGED
2004/11/18 15:10:26 hro 1.18.10.4: #i36938# Use crash reporter generated preview
2004/11/01 12:18:44 hro 1.18.10.3: #i34683# Commited missing changes
2004/09/03 04:48:46 hro 1.18.10.2: #i28480# Sending only mode for crash reporter
2004/09/03 02:49:17 hro 1.18.10.1: #116177# Don't include pstack output in crash report
Diffstat (limited to 'crashrep')
-rwxr-xr-x | crashrep/source/unx/main.cxx | 215 |
1 files changed, 129 insertions, 86 deletions
diff --git a/crashrep/source/unx/main.cxx b/crashrep/source/unx/main.cxx index 6799955283a6..8fbee964e38f 100755 --- a/crashrep/source/unx/main.cxx +++ b/crashrep/source/unx/main.cxx @@ -2,9 +2,9 @@ * * $RCSfile: main.cxx,v $ * - * $Revision: 1.18 $ + * $Revision: 1.19 $ * - * last change: $Author: hr $ $Date: 2004-06-28 14:04:59 $ + * last change: $Author: rt $ $Date: 2004-11-26 14:16:52 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -78,6 +78,9 @@ const char *basename( const char *filename ) using namespace std; static bool g_bNoUI = false; +static bool g_bSendReport = false; +static bool g_bLoadReport = false; + static bool g_bDebugMode = false; static int g_signal = 0; @@ -191,86 +194,6 @@ static size_t fcopy( FILE *fpout, FILE *fpin ) writes the report to a temp-file from which it can be reviewed and sent */ -bool write_stack( long pid ) -{ - bool bSuccess = false; - - if ( pid ) - { - char *stmp= tmpnam( g_szStackFile ); - FILE *fout, *fin; - char buf[1024]; - - /* open mailfile */ - fout = fopen(stmp, "w"); - - if ( fout ) - { - char cmdbuf[1024]; - - fputs( "<***stacks***>\n", fout ); - - if ( !g_strPStackFileName.length() ) - { - - snprintf(cmdbuf, 1024, PSTACK_CMD, pid); - fin = popen(cmdbuf, "r"); - - if ( fin ) - { - while (fgets(buf, 1024, fin) != NULL) - { - bSuccess = true; - fputs(buf, fout); - } - pclose( fin ); - - } - - } - else - { - fin = fopen( g_strPStackFileName.c_str(), "r" ); - if ( fin ) - { - bSuccess = true; - fcopy( fout, fin ); - fclose( fin ); - } - } - - fputs( "</***stacks***>\n", fout ); - - if ( bSuccess ) - { - fputs( "<***maps***>\n", fout ); - bSuccess = false; - - snprintf(cmdbuf, 1024, PMAP_CMD, pid); - fin = popen(cmdbuf, "r"); - - if ( fin ) - { - while (fgets(buf, 1024, fin) != NULL) - { - bSuccess = true; - fputs(buf, fout); - } - pclose( fin ); - - } - fputs( "</***maps***>\n", fout ); - } - - fclose ( fout ); - - } - } - - - return bSuccess; -} - bool write_report( const hash_map< string, string >& rSettings ) { @@ -395,7 +318,6 @@ bool save_crash_report( const string& rFileName, const hash_map< string, string return bSuccess; } - bool SendHTTPRequest( FILE *fp, const char *pszServer, @@ -817,6 +739,14 @@ static long setup_commandline_arguments( int argc, char** argv, int *pSignal ) { g_bNoUI = true; } + else if ( 0 == strcmp( argv[n], "-send" ) ) + { + g_bSendReport = true; + } + else if ( 0 == strcmp( argv[n], "-load" ) ) + { + g_bLoadReport = true; + } else if ( argv[n] && strlen(argv[n]) ) { printf( @@ -1002,6 +932,80 @@ static string read_from_file( const string& rFileName ) } #define RCFILE ".crash_reportrc" +#define XMLFILE ".crash_report_frames" +#define CHKFILE ".crash_report_checksum" +#define LCKFILE ".crash_report_unsent" +#define PRVFILE ".crash_report_preview" + +static void load_crash_data() +{ + g_strXMLFileName = get_home_dir(); + g_strXMLFileName += "/"; + g_strXMLFileName += string(XMLFILE); + + g_strChecksumFileName = get_home_dir(); + g_strChecksumFileName += "/"; + g_strChecksumFileName += string(CHKFILE); +} + +static bool write_crash_data() +{ + bool success = true; + string sFile = get_home_dir(); + + sFile += "/"; + sFile += string(XMLFILE); + + FILE *fp = fopen( sFile.c_str(), "w" ); + + if ( fp ) + { + FILE *fpin = fopen( g_strXMLFileName.c_str(), "r" ); + + if ( fpin ) + { + fcopy( fp, fpin ); + fclose( fpin ); + } + + fclose( fp ); + } + + sFile = get_home_dir(); + + sFile += "/"; + sFile += string(CHKFILE); + + fp = fopen( sFile.c_str(), "w" ); + + if ( fp ) + { + FILE *fpin = fopen( g_strChecksumFileName.c_str(), "r" ); + + if ( fpin ) + { + fcopy( fp, fpin ); + fclose( fpin ); + } + + fclose( fp ); + } + + sFile = get_home_dir(); + + sFile += "/"; + sFile += string(LCKFILE); + + fp = fopen( sFile.c_str(), "w" ); + + if ( fp ) + { + fprintf( fp, "Unsent\n" ); + fclose( fp ); + } + + return success; +} static bool write_settings( const hash_map< string, string >& rSettings ) { @@ -1155,7 +1159,12 @@ int main( int argc, char** argv ) long pid = setup_commandline_arguments( argc, argv, &g_signal ); - if ( write_stack( pid ) ) + if ( g_bLoadReport ) + { + load_crash_data(); + } + + if ( g_bSendReport ) { if ( !get_accessibility_state() && !g_bNoUI ) { @@ -1184,11 +1193,45 @@ int main( int argc, char** argv ) send_crash_report( NULL, aDialogSettings ); } + } + else + { + hash_map< string, string > aDialogSettings; + + read_settings( aDialogSettings ); + read_settings_from_environment( aDialogSettings ); - unlink( g_szStackFile ); + write_crash_data(); + write_report( aDialogSettings ); - return 0; + string sPreviewFile = get_home_dir(); + sPreviewFile += "/"; + sPreviewFile += string(PRVFILE); + + FILE *fpout = fopen( sPreviewFile.c_str(), "w+" ); + if ( fpout ) + { + FILE *fpin = fopen( g_szReportFile, "r" ); + if ( fpin ) + { + fcopy( fpout, fpin ); + fclose( fpin ); + } + fclose( fpout ); + } + + unlink( g_szReportFile ); + } + + if ( g_bLoadReport ) + { + unlink( g_strXMLFileName.c_str() ); + unlink( g_strChecksumFileName.c_str() ); } + + unlink( g_szStackFile ); + + return 0; } return -1; |