2008-01-05 16:23:04 +03:00
|
|
|
/*
|
|
|
|
* $Id$
|
|
|
|
*
|
2008-09-22 17:24:06 +04:00
|
|
|
* ede-crasher, a crash handler tool
|
2008-01-05 16:23:04 +03:00
|
|
|
* Part of Equinox Desktop Environment (EDE).
|
2009-07-06 15:51:25 +04:00
|
|
|
* Copyright (c) 2008-2009 EDE Authors.
|
2008-01-05 16:23:04 +03:00
|
|
|
*
|
|
|
|
* This program is licensed under terms of the
|
|
|
|
* GNU General Public License version 2 or newer.
|
|
|
|
* See COPYING for details.
|
|
|
|
*/
|
|
|
|
|
2010-03-28 16:54:45 +04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2008-01-05 16:23:04 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2010-03-28 16:54:45 +04:00
|
|
|
#include <edelib/Ede.h>
|
2008-01-05 16:23:04 +03:00
|
|
|
#include "CrashDialog.h"
|
|
|
|
|
|
|
|
#define CHECK_ARGV(argv, pshort, plong) ((strcmp(argv, pshort) == 0) || (strcmp(argv, plong) == 0))
|
|
|
|
|
2009-03-30 19:17:00 +04:00
|
|
|
static const char* next_param(int curr, char** argv, int argc) {
|
2008-01-05 16:23:04 +03:00
|
|
|
int j = curr + 1;
|
|
|
|
if(j >= argc)
|
|
|
|
return NULL;
|
|
|
|
if(argv[j][0] == '-')
|
|
|
|
return NULL;
|
|
|
|
return argv[j];
|
|
|
|
}
|
|
|
|
|
2009-03-30 19:17:00 +04:00
|
|
|
static void help(void) {
|
2008-09-22 17:24:06 +04:00
|
|
|
puts("Usage: ede-crasher [OPTIONS]");
|
2008-01-05 16:23:04 +03:00
|
|
|
puts("EDE crash handler\n");
|
|
|
|
puts("Options:");
|
|
|
|
puts(" -h, --help this help");
|
2009-07-06 15:51:25 +04:00
|
|
|
puts(" -e, --edeapp use this flag for EDE applications");
|
2008-01-05 16:23:04 +03:00
|
|
|
puts(" -b, --bugaddress [ADDRESS] bug address to use");
|
|
|
|
puts(" -p, --pid [PID] the PID of the program");
|
|
|
|
puts(" -a, --appname [NAME] name of the program");
|
2009-07-06 15:51:25 +04:00
|
|
|
puts(" -t, --apppath [PATH] path to the executable");
|
2008-01-05 16:23:04 +03:00
|
|
|
puts(" -s, --signal [SIGNAL] the signal number that was caught");
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
if(argc <= 1) {
|
|
|
|
help();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-03-28 16:54:45 +04:00
|
|
|
EDE_APPLICATION("ede-crasher");
|
|
|
|
|
2009-07-06 15:51:25 +04:00
|
|
|
const char* a;
|
|
|
|
ProgramDetails p;
|
|
|
|
|
|
|
|
p.bugaddress = NULL;
|
|
|
|
p.name = NULL;
|
|
|
|
p.path = NULL;
|
|
|
|
p.pid = NULL;
|
|
|
|
p.sig = NULL;
|
|
|
|
p.ede_app = false;
|
2008-01-05 16:23:04 +03:00
|
|
|
|
|
|
|
for(int i = 1; i < argc; i++) {
|
|
|
|
a = argv[i];
|
|
|
|
if(CHECK_ARGV(a, "-h", "--help")) {
|
|
|
|
help();
|
|
|
|
return 0;
|
2009-07-06 15:51:25 +04:00
|
|
|
} else if(CHECK_ARGV(a, "-e", "--edeapp")) {
|
|
|
|
p.ede_app = true;
|
2008-01-05 16:23:04 +03:00
|
|
|
} else if(CHECK_ARGV(a, "-b", "--bugaddress")) {
|
2009-07-06 15:51:25 +04:00
|
|
|
p.bugaddress = next_param(i, argv, argc);
|
|
|
|
if(!p.bugaddress) {
|
2008-01-05 16:23:04 +03:00
|
|
|
puts("Missing bug address parameter");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
} else if(CHECK_ARGV(a, "-p", "--pid")) {
|
2009-07-06 15:51:25 +04:00
|
|
|
p.pid = next_param(i, argv, argc);
|
|
|
|
if(!p.pid) {
|
2008-01-05 16:23:04 +03:00
|
|
|
puts("Missing pid parameter");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
} else if(CHECK_ARGV(a, "-a", "--appname")) {
|
2009-07-06 15:51:25 +04:00
|
|
|
p.name = next_param(i, argv, argc);
|
|
|
|
if(!p.name) {
|
2008-01-05 16:23:04 +03:00
|
|
|
puts("Missing application name");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
i++;
|
2009-07-06 15:51:25 +04:00
|
|
|
} else if(CHECK_ARGV(a, "-t", "--apppath")) {
|
|
|
|
p.path = next_param(i, argv, argc);
|
|
|
|
if(!p.path) {
|
2008-01-05 16:23:04 +03:00
|
|
|
puts("Missing application path");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
} else if(CHECK_ARGV(a, "-s", "--signal")) {
|
2009-07-06 15:51:25 +04:00
|
|
|
p.sig = next_param(i, argv, argc);
|
|
|
|
if(!p.sig) {
|
2008-01-05 16:23:04 +03:00
|
|
|
puts("Missing signal number");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
} else {
|
2008-09-22 17:24:06 +04:00
|
|
|
printf("Unknown '%s' parameter. Run 'ede-crasher -h' for options\n", a);
|
2008-01-05 16:23:04 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-06 15:51:25 +04:00
|
|
|
return crash_dialog_show(p);
|
2008-01-05 16:23:04 +03:00
|
|
|
}
|