From 9d80cdfd3d0be3eda0ef128a6280f90599568f95 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 9 Jan 2006 14:27:20 +0000 Subject: [PATCH] print_usb_usermap: made program name configurable git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@8443 67ed7778-7388-44ab-90cf-0a291f65f57c --- packaging/linux-hotplug/print-usb-usermap.c | 34 ++++++++++++--------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/packaging/linux-hotplug/print-usb-usermap.c b/packaging/linux-hotplug/print-usb-usermap.c index c357bb626..3e32c88c7 100644 --- a/packaging/linux-hotplug/print-usb-usermap.c +++ b/packaging/linux-hotplug/print-usb-usermap.c @@ -21,25 +21,26 @@ */ #define GP_USB_HOTPLUG_SCRIPT "usbcam" +#define ARGV0 "print-usb-usermap" #define HELP_TEXT \ -"print-usb-usermap - print usb.usermap file for linux-hotplug\n" \ +ARGV0 " - print usb.usermap file for linux-hotplug or FDI file for HAL\n" \ "\n" \ "Syntax:\n" \ -" print-usb-usermap [ --verbose ] [ --debug ] [ --fdi | ]\n" \ +" " ARGV0 " [ --verbose ] [ --debug ] [ --fdi | ]\n" \ "\n" \ " --verbose also print comments with camera model names\n" \ " --fdi print FDI file for HAL\n" \ " --debug print all debug output\n" \ "\n" \ -"print-usb-usermap prints the lines for the usb.usermap file on stdout.\n" \ +ARGV0 " prints the lines for the usb.usermap file on stdout.\n" \ "All other messages are printed on stderr. In case of any error, the \n" \ "program aborts regardless of data printed on stdout and returns a non-zero\n" \ "status code.\n" \ -"If no is given, print-usb-usermap uses the script name\n" \ -"If --fdi is given it generates a fdi file for HAL. Put it into\n" \ -"/usr/share/hal/fdi/information/10freedesktop/10-camera-libgphoto2.fdi\n" \ -"\"" GP_USB_HOTPLUG_SCRIPT "\"." +"If no is given, " ARGV0 " uses the script name\n" \ +" \"" GP_USB_HOTPLUG_SCRIPT "\"." \ +"If --fdi is given, " ARGV0 " generates a fdi file for HAL. Put it into\n" \ +"/usr/share/hal/fdi/information/10freedesktop/10-camera-libgphoto2.fdi\n" #include #include @@ -63,12 +64,13 @@ #define GP_USB_HOTPLUG_MATCH_DEV_SUBCLASS 0x0100 #define GP_USB_HOTPLUG_MATCH_DEV_PROTOCOL 0x0200 + #ifdef __GNUC__ #define CR(result) \ do { \ int r = (result); \ if (r < 0) { \ - fprintf(stderr, "print-usb-usermap: " \ + fprintf(stderr, ARGV0 ": " \ "Fatal error running `%s'.\n" \ "Aborting.\n", #result ); \ return (r); \ @@ -79,14 +81,15 @@ do { \ int r = (result); \ if (r < 0) { \ - fprintf(stderr, "print-usb-usermap: " \ + fprintf(stderr, ARGV0 ": " \ "Fatal error detected, aborting.\n"); \ return (r); \ } \ } while (0) #endif /* __GNUC__ */ -/* print-usb-usermap + +/* print_usb_usermap * * Print out lines that can be included into usb.usermap * - for all cams supported by our instance of libgphoto2. @@ -99,7 +102,7 @@ static int print_usb_usermap(const char *usermap_script, const int add_comments) { int x, n; CameraAbilitiesList *al; - CameraAbilities a; + CameraAbilities a; CR (gp_abilities_list_new (&al)); CR (gp_abilities_list_load (al, NULL)); /* use NULL context */ @@ -166,7 +169,8 @@ static int print_usb_usermap(const char *usermap_script, const int add_comments) return (0); } -/* print-fdi-map + +/* print_fdi_map * * Print FDI Device Information file for HAL with information on * all cams supported by our instance of libgphoto2. @@ -179,7 +183,7 @@ static int print_fdi_map(const int add_comments, const char *argv0) { int x, n; CameraAbilitiesList *al; - CameraAbilities a; + CameraAbilities a; CR (gp_abilities_list_new (&al)); CR (gp_abilities_list_load (al, NULL)); /* use NULL context */ @@ -187,7 +191,7 @@ static int print_fdi_map(const int add_comments, const char *argv0) printf(" \n"); printf("\n", - (argv0!=NULL)?argv0:"libgphoto2 print-usb-usermap"); + (argv0!=NULL)?argv0:"libgphoto2 " ARGV0); printf("\n"); printf(" \n"); printf(" \n"); @@ -257,6 +261,7 @@ static int print_fdi_map(const int add_comments, const char *argv0) return (0); } + /* time zero for debug log time stamps */ struct timeval glob_tv_zero = { 0, 0 }; @@ -274,6 +279,7 @@ debug_func (GPLogLevel level, const char *domain, const char *format, fprintf (stderr, "\n"); } + int main(int argc, char *argv[]) { char *usermap_script = NULL; /* script name to use */