Enlightenment CVS committal Author : moom16 Project : e17 Module : apps/eclair
Dir : e17/apps/eclair/src Modified Files: eclair.c eclair_args.c Log Message: * Use getopt instead of strcmp to parse args (`vko's patch) * Print a message when a segfault happened, which asks the user to report the bug (GuYgUy's patch) Thanks to `vko and GuYgUy =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/eclair/src/eclair.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -3 -r1.11 -r1.12 --- eclair.c 7 May 2005 12:42:17 -0000 1.11 +++ eclair.c 7 May 2005 14:07:32 -0000 1.12 @@ -22,6 +22,8 @@ static void *_eclair_create_video_object_thread(void *param); static void _eclair_gui_create_window(Eclair *eclair); static void _eclair_video_create_window(Eclair *eclair); +static void _eclair_sig_pregest(); +static void _eclair_on_segv(int num); //Initialize eclair Evas_Bool eclair_init(Eclair *eclair, int *argc, char *argv[]) @@ -75,7 +77,6 @@ evas_list_free(filenames); edje_object_part_drag_value_set(eclair->gui_object, "volume_bar_drag", 1.0, 0.0); - ecore_evas_show(eclair->gui_window); return 1; } @@ -514,10 +515,9 @@ } ecore_evas_title_set(eclair->gui_window, "eclair"); ecore_evas_name_class_set(eclair->gui_window, "eclair", "eclair"); - ecore_evas_layer_set(eclair->gui_window, 999); ecore_evas_borderless_set(eclair->gui_window, 1); ecore_evas_shaped_set(eclair->gui_window, 1); - ecore_evas_hide(eclair->gui_window); + ecore_evas_show(eclair->gui_window); eclair->gui_x_window = ecore_evas_software_x11_window_get(eclair->gui_window); ecore_x_dnd_aware_set(eclair->gui_x_window, 1); @@ -584,8 +584,8 @@ edje_object_signal_callback_add(eclair->gui_object, "playlist_scroll_up_start", "", eclair_gui_playlist_scroll_cb, eclair); edje_object_signal_callback_add(eclair->gui_object, "playlist_scroll_up_stop", "", eclair_gui_playlist_scroll_cb, eclair); ecore_event_handler_add(ECORE_X_EVENT_XDND_POSITION, eclair_gui_dnd_position_cb, eclair); - ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY, eclair_gui_dnd_selection_cb, eclair); ecore_event_handler_add(ECORE_X_EVENT_XDND_DROP, eclair_gui_dnd_drop_cb, eclair); + ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY, eclair_gui_dnd_selection_cb, eclair); edje_object_message_handler_set(eclair->gui_object, eclair_gui_message_cb, eclair); } @@ -654,10 +654,40 @@ return NULL; } + +//Handle segvs +static void _eclair_sig_pregest() +{ + struct sigaction sa; + + sa.sa_handler = _eclair_on_segv; + sigaction(SIGSEGV, &sa, (struct sigaction *)0); +} + +//Display a message on segvs +static void _eclair_on_segv(int num) +{ + fprintf (stderr, "\n\n"); + fprintf (stderr, "Oops, eclair has crashed (SIG: %d) :(\n", num); + fprintf (stderr, "\n"); + fprintf (stderr, "Have you compiled the latest version of eclair, emotion, evas, and all eclair dependencies ?\n"); + fprintf (stderr, "If it failed again, please report bugs to Mo0m ([EMAIL PROTECTED])\n"); + fprintf (stderr, "Describe how bugs happened, gdb traces, and so on ;)\n"); + fprintf (stderr, "\n"); + fprintf (stderr, "With that, devs will be able to correct bugs faster and easier\n"); + fprintf (stderr, "If you correct the bug, or see in which code part it can provide, include it too\n"); + fprintf (stderr, "\n"); + fprintf (stderr, "Thanks :)\n"); + + exit(20); +} + int main(int argc, char *argv[]) { Eclair eclair; + _eclair_sig_pregest(); + if (!eclair_init(&eclair, &argc, argv)) return 1; =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/eclair/src/eclair_args.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- eclair_args.c 30 Apr 2005 17:28:23 -0000 1.2 +++ eclair_args.c 7 May 2005 14:07:32 -0000 1.3 @@ -1,68 +1,78 @@ #include "eclair_args.h" +#include <getopt.h> + +static void _eclair_args_print_usage(); //Parse the arguments of the application and stock the filenames to load in the list Evas_Bool eclair_args_parse(Eclair *eclair, int argc, char *argv[], Evas_List **filenames) { - int i; + int c, i; + + static struct option long_options[] = + { + { "help", no_argument, NULL, 'h' }, + { "theme", required_argument, NULL, 't' }, + { "gui-engine", required_argument, NULL, 'g' }, + { "video-engine", required_argument, NULL, 'v' }, + { NULL, 0, NULL, 0 } + }; - for (i = 1; i < argc; i++) + while ((c = getopt_long(argc, argv, "ht:g:v:", long_options, NULL)) != -1) { - if (argv[i][0] == '-') + switch (c) { - if (strcmp(argv[i], "--help") == 0) - { - //TODO: Display help message - fprintf(stderr, "Help: (TODO)\n--gui-engine [software|gl]\n--video-engine [software|gl]\n"); + case 0: + break; + case 'h': + _eclair_args_print_usage(); return 0; - } - else if (strcmp(argv[i], "--gui-engine") == 0) - { - if (argc <= i + 1) + break; + case 't': + //TODO + fprintf(stderr, "Not yet implemented...\n"); + break; + case 'g': + if (strcmp(optarg, "software") == 0) + eclair->video_engine = ECLAIR_SOFTWARE; + else if (strcmp(optarg, "gl") == 0) + eclair->gui_engine = ECLAIR_GL; + else { - fprintf(stderr, "Correct gui engines are: software gl\nDefault is: software\n\n"); + _eclair_args_print_usage(); return 0; } + break; + case 'v': + if (strcmp(optarg, "software") == 0) + eclair->video_engine = ECLAIR_SOFTWARE; + else if (strcmp(optarg, "gl") == 0) + eclair->video_engine = ECLAIR_GL; else { - i++; - if (strcmp(argv[i], "software") == 0) - eclair->gui_engine = ECLAIR_SOFTWARE; - else if (strcmp(argv[i], "gl") == 0) - eclair->gui_engine = ECLAIR_GL; - else - { - fprintf(stderr, "Correct gui engines are: software gl\nDefault is: software\n\n"); - return 0; - } - } - } - else if (strcmp(argv[i], "--video-engine") == 0) - { - if (argc <= i + 1) - { - fprintf(stderr, "Correct video engines are: software gl\nDefault is: software\n\n"); + _eclair_args_print_usage(); return 0; } - else - { - i++; - if (strcmp(argv[i], "software") == 0) - eclair->video_engine = ECLAIR_SOFTWARE; - else if (strcmp(argv[i], "gl") == 0) - eclair->video_engine = ECLAIR_GL; - else - { - fprintf(stderr, "Correct video engines are: software gl\nDefault is: software\n\n"); - return 0; - } - } - } - else - fprintf(stderr, "Unknown option: %s\nTry `eclair --help' for more information.\n\n", argv[i]); + break; + default: + _eclair_args_print_usage(); + return 0; } - else + } + if (optind < argc) + { + for (i = optind; i < argc; i++) *filenames = evas_list_append(*filenames, argv[i]); } - return 1; } + +static void _eclair_args_print_usage() +{ + printf("Usage: eclair [arguments] file(s)\n" + "\n" + "Available arguments:\n" + "-h, --help Print this message and exit\n" + "-t, --theme Specify an edj theme file for eclair\n" + "-g, --gui-engine [software|gl] Specify the gui engine\n" + "-v, --video-engine [software|gl] Specify the video engine\n"); +} ------------------------------------------------------- This SF.Net email is sponsored by: NEC IT Guy Games. Get your fingers limbered up and give it your best shot. 4 great events, 4 opportunities to win big! Highest score wins.NEC IT Guy Games. Play to win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs