summaryrefslogtreecommitdiffstats
path: root/kdat/main.cpp
blob: c6c89f8b8783236d0ea1f280a90b94dd6fbd53cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// KDat - a tar-based DAT archiver
// Copyright (C) 1998-2000  Sean Vyain, svyain@mail.tds.net
// Copyright (C) 2001-2002  Lawrence Widman, kdat@cardiothink.com
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>

#include <tqfile.h>
#include <tqdir.h>

#include <tdeapplication.h>
#include <klocale.h>
#include <tdecmdlineargs.h>
#include <tdeaboutdata.h>
#include <kcrash.h>
#include <kmessagebox.h>

#include <signal.h>

#include "kdat.h"
#include "KDatMainWindow.h"

static const char description[] = 
	I18N_NOOP("tar-based DAT archiver for TDE");

/* in ErrorHandler.cpp */
void error_handler(int err_sig);

int main( int argc, char** argv )
{
  TDEAboutData aboutData( "kdat", I18N_NOOP("KDat"), 
    KDAT_VERSION, description, TDEAboutData::License_GPL, 
    "(c) 1999-2000, Sean Vyain; 2001-2002 Lawrence Widman");

  /* 2002-01-28 LEW: so we can dump core if we want to */
  // TDECrash::setCrashHandler(0);  // this is supposed to work, but it doesn't
#ifdef DEBUG
  {
    char *newarg;
    if( ( newarg = (char *)malloc( strlen("--nocrashhandler") + 1 ) ) == NULL )
      {
	KMessageBox::sorry(NULL, i18n("Can't allocate memory in kdat"));
        exit(1);
      }
    strcpy( newarg, "--nocrashhandler" );
    argv[ argc ] = newarg;
    argc++;
  }
  {
    int i;
    for(i=0; i<argc; i++){
      printf("Arg %d: %s\n", i, argv[i]);
    }
  }
#endif /* DEBUG */
  /* 2002-01-28 LEW */

  TDECmdLineArgs::init( argc, argv, &aboutData );
  aboutData.addAuthor( "Lawrence Widman", 0, "kdat@cardiothink.com");
//  TDECmdLineArgs::addCmdLineOptions( options ); // Add our own options.
  TDEApplication app;
  
  app.setMainWidget( KDatMainWindow::getInstance() );

  /* set up error handler so we don't crash without notice */
  signal(SIGHUP,  error_handler);
  signal(SIGINT,  error_handler);
  signal(SIGFPE,  error_handler);
  signal(SIGSEGV, error_handler);
  signal(SIGTERM, error_handler);   

  if ( app.isRestored() && KDatMainWindow::canBeRestored( 1 ) ) {
    KDatMainWindow::getInstance()->restore( 1 );
  } else {
    KDatMainWindow::getInstance()->show();
  }

  return app.exec();
}