diff --git a/frontends/command-line/main.c b/frontends/command-line/main.c index 2d4e31949..052de7850 100644 --- a/frontends/command-line/main.c +++ b/frontends/command-line/main.c @@ -1,5 +1,7 @@ /* $Id$ */ +#include + #include #include #include @@ -10,10 +12,6 @@ #include #endif -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - #include "main.h" #include "actions.h" @@ -28,6 +26,21 @@ #ifdef ENABLE_NLS # include +# undef _ +# define _(String) dgettext (PACKAGE, String) +# ifdef gettext_noop +# define N_(String) gettext_noop (String) +# else +# define N_(String) (String) +# endif +#else +# define textdomain(String) (String) +# define gettext(String) (String) +# define dgettext(Domain,Message) (Message) +# define dcgettext(Domain,Message,Type) (Message) +# define bindtextdomain(Domain,Directory) (Domain) +# define _(String) (String) +# define N_(String) (String) #endif #define CHECK_RESULT(result) {int r = (result); if (r < 0) return (r);} @@ -441,12 +454,22 @@ OPTION_CALLBACK(model) return (GP_OK); } +static void +debug_func (GPLogLevels levels, const char *domain, const char *msg, + void *data) +{ + if (levels & GP_LOG_ERROR) + printf ("*** ERROR *** "); + printf ("%s: %s\n", domain, msg); +} + OPTION_CALLBACK (debug) { glob_debug = GP_DEBUG_HIGH; cli_debug_print(PACKAGE " " VERSION ": " "Turning on debug mode"); - gp_debug_set_level (GP_DEBUG_HIGH); + gp_log_add_func (GP_LOG_DATA | GP_LOG_DEBUG | GP_LOG_ERROR, + debug_func, NULL); return (GP_OK); } @@ -890,7 +913,7 @@ set_globals (void) * check every single error message returned by gphoto2, we need * to make sure that we have a serial port. */ - if (!strncmp (glob_port, "serial", 6)) + if (!strncmp (glob_port, "serial:", 7)) CHECK_RESULT (gp_camera_set_port_speed (glob_camera, glob_speed)); gp_camera_set_status_func (glob_camera, status_func, NULL); @@ -1031,15 +1054,13 @@ e.g. SET IOLIBS=C:\\GPHOTO2\\IOLIB\n"); exit(EXIT_FAILURE); } - if ((result = execute_options(argc, argv)) != GP_OK) { + result = execute_options(argc, argv); + if (result < 0) { printf ("gPhoto2 reported the error '%s'\n", gp_camera_get_result_as_string (glob_camera, result)); - if (gp_debug_get_level () == GP_DEBUG_NONE) { - printf ("Last debugging messages (use --debug for " - "more):\n"); - printf ("%s\n", gp_log_history_get ()); - } + printf ("Last debugging messages (use --debug for more):\n"); + printf ("%s\n", gp_log_history_get ()); exit (EXIT_FAILURE); } diff --git a/libgphoto2/gphoto2-debug.c b/libgphoto2/gphoto2-debug.c index 07b994576..1bff90ce5 100644 --- a/libgphoto2/gphoto2-debug.c +++ b/libgphoto2/gphoto2-debug.c @@ -26,23 +26,7 @@ #include #include -#include #include -#include - -static int port_func_set = 0; - -static int debug_level = GP_DEBUG_NONE; - -static void -gp_port_func (GPLogLevels levels, const char *domain, - const char *msg, void *data) -{ - if (debug_level) { - fprintf (stderr, msg); - fprintf (stderr, "\n"); - } -} /** * gp_debug_printf: @@ -63,11 +47,6 @@ gp_debug_printf (int level, const char *id, const char *format, ...) char buffer[2048]; va_list arg; - if (!port_func_set) - port_func_set = gp_log_add_func ( - GP_LOG_DATA | GP_LOG_DEBUG | GP_LOG_ERROR, - gp_port_func, NULL); - va_start (arg, format); #if HAVE_VSNPRINTF vsnprintf (buffer, sizeof (buffer), format, arg); @@ -76,32 +55,5 @@ gp_debug_printf (int level, const char *id, const char *format, ...) #endif va_end (arg); - if (level <= debug_level) - gp_log (GP_LOG_DEBUG, id, buffer); -} - -/** - * gp_debug_set_level: - * @level: a gphoto2 debug level - * - * Sets the debugging level. Only debugging messages with a debugging level - * higher than the given @level will be printed. - **/ -void -gp_debug_set_level (int level) -{ - debug_level = level; -} - -/** - * gp_debug_get_level: - * - * Gets the current debugging level. - * - * Return value: the current gphoto2 debug level or a gphoto2 error code - **/ -int -gp_debug_get_level (void) -{ - return (debug_level); + gp_log (GP_LOG_DEBUG, id, buffer); } diff --git a/libgphoto2/gphoto2-debug.h b/libgphoto2/gphoto2-debug.h index d0970a2eb..bb140aab2 100644 --- a/libgphoto2/gphoto2-debug.h +++ b/libgphoto2/gphoto2-debug.h @@ -29,7 +29,4 @@ /* DEPRECATED. Use gphoto2-port-log */ void gp_debug_printf (int level, const char *id, const char *format, ...); -void gp_debug_set_level (int level); -int gp_debug_get_level (void); - #endif /* __GPHOTO2_DEBUG_H__ */ diff --git a/po/POTFILES.in b/po/POTFILES.in index e3c32933d..8ea1f9398 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -16,3 +16,4 @@ libgphoto2/gphoto2-camera.c libgphoto2/gphoto2-filesys.c libgphoto2/gphoto2-abilities-list.c libgphoto2/gphoto2-result.c +frontends/command-line/main.c