summaryrefslogtreecommitdiff
path: root/packaging
diff options
context:
space:
mode:
authorHans Ulrich Niedermann <gp@n-dimensional.de>2006-12-11 15:57:04 +0000
committerHans Ulrich Niedermann <gp@n-dimensional.de>2006-12-11 15:57:04 +0000
commit506a5ec0fa3f522858572c5b021a9af2106520d2 (patch)
treea3a457607cac7b7eac2036307bfa71acd10b7581 /packaging
parent8c1c48b44c1def362d4a0129ce4de301d02411ae (diff)
downloadlibgphoto2-506a5ec0fa3f522858572c5b021a9af2106520d2.tar.gz
Add version comments for print-camera-list, rename conditional for gp2ddb
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@9567 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'packaging')
-rw-r--r--packaging/generic/print-camera-list.c78
1 files changed, 75 insertions, 3 deletions
diff --git a/packaging/generic/print-camera-list.c b/packaging/generic/print-camera-list.c
index 2ac262806..c6dce7c7e 100644
--- a/packaging/generic/print-camera-list.c
+++ b/packaging/generic/print-camera-list.c
@@ -53,6 +53,11 @@ ARGV0 " prints the camera list in the specified format FORMAT on stdout.\n" \
#include <gphoto2/gphoto2-camera.h>
#include <gphoto2/gphoto2-port-log.h>
+/* for detailed version message */
+#include <gphoto2/gphoto2-version.h>
+
+#include "config.h"
+
#ifndef TRUE
#define TRUE (0==0)
#endif
@@ -60,6 +65,59 @@ ARGV0 " prints the camera list in the specified format FORMAT on stdout.\n" \
#define FALSE (0!=0)
#endif
+typedef struct {
+ char *name;
+ GPVersionFunc version_func;
+} module_version;
+
+const module_version module_versions[] = {
+ { "libgphoto2", gp_library_version },
+ { "libgphoto2_port", gp_port_library_version },
+ { NULL, NULL }
+};
+
+/* print_version_comment
+ * Print comment to output containing information on library versions
+ *
+ * out the file to write the comment to
+ * startline printed at the start of each line, e.g. "# " or " | "
+ * endline printed as the end of each line, e.g. "\n" or "\n"
+ * firstline printed before first line, e.g. NULL or "<!--+\n"
+ * lastline printed after last line, e.g. "\n" or " +-->\n"
+ */
+
+static void
+print_version_comment(FILE *out,
+ const char *startline, const char *endline,
+ const char *firstline, const char *lastline)
+{
+ unsigned int n;
+ if (firstline != NULL) { fputs(firstline, out); }
+ fputs(startline, out);
+ fputs("Created from this library:", out);
+ fputs(endline, out);
+ for (n=0; (module_versions[n].name != NULL) && (module_versions[n].version_func != NULL); n++) {
+ const char *name = module_versions[n].name;
+ GPVersionFunc func = module_versions[n].version_func;
+ const char **v = func(GP_VERSION_SHORT);
+ unsigned int i;
+ if (!v) { continue; }
+ if (!v[0]) { continue; }
+ fputs(startline, out);
+ fputs(" ", out);
+ fprintf(out,"%-15s %-14s ", name, v[0]);
+ for (i=1; v[i] != NULL; i++) {
+ fputs(v[i], out);
+ if (v[i+1] != NULL) {
+ fputs(", ", out);
+ }
+ }
+ fputs(endline, out);
+ }
+ if (lastline != NULL) { fputs(lastline, out); }
+}
+
+
typedef char *string_array_t[];
typedef string_array_t *string_array_p;
@@ -283,7 +341,8 @@ idlist_camera_func (const func_params_t *params,
static int
udev_begin_func (const func_params_t *params)
{
- printf ("# udev rules file for libgphoto2 devices (udev < 0.98)\n#\n");
+ printf ("# udev rules file for libgphoto2 devices (udev < 0.98)\n");
+ print_version_comment(stdout, "# ", "\n", NULL, "#\n");
/* Note: 2 lines because we need to use || ... having them on the same
* line would mean &&.
*/
@@ -295,7 +354,8 @@ udev_begin_func (const func_params_t *params)
static int
udev_098_begin_func (const func_params_t *params)
{
- printf ("# udev rules file for libgphoto2 devices (udev >= 0.98)\n#\n");
+ printf ("# udev rules file for libgphoto2 devices (udev >= 0.98)\n");
+ print_version_comment(stdout, "# ", "\n", NULL, "#\n");
/* Note: 2 lines because we need to use || ... having them on the same
* line would mean &&.
*/
@@ -545,10 +605,13 @@ empty_end_func (const func_params_t *params)
+#ifdef ENABLED_GP2DDB
+
static int
ddb_begin_func (const func_params_t *params)
{
printf("# Beginning of gphoto2 device database (PRE-ALPHA format!)\n\n");
+ print_version_comment(stdout, "# ", "\n", NULL, "\n");
return 0;
}
@@ -710,6 +773,8 @@ ddb_camera_func (const func_params_t *params,
return 0;
}
+#endif /* ENABLED_GP2DDB */
+
/* print_fdi_map
*
@@ -726,6 +791,7 @@ fdi_begin_func (const func_params_t *params)
printf("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?> <!-- -*- SGML -*- -->\n");
printf("<!-- This file was generated by %s - - fdi -->\n",
"libgphoto2 " ARGV0);
+ print_version_comment(stdout, " | ", "\n", "<!--+\n", " +-->\n");
printf("<deviceinfo version=\"0.2\">\n");
printf(" <device>\n");
printf(" <match key=\"info.bus\" string=\"usb\">\n");
@@ -746,7 +812,7 @@ fdi_camera_func (const func_params_t *params,
s = (char *) a->model;
d = model;
- while (*s) {
+ while (*s && (d < &d[sizeof(d)-1])) {
if (*s == '&') {
strcpy(d,"&amp;");
d += strlen(d);
@@ -844,6 +910,7 @@ fdi_device_begin_func (const func_params_t *params)
printf("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?> <!-- -*- SGML -*- -->\n");
printf("<!-- This file was generated by %s - - fdi-device -->\n",
"libgphoto2 " ARGV0);
+ print_version_comment(stdout, " | ", "\n", "<!--+\n", " +-->\n");
printf("<deviceinfo version=\"0.2\">\n");
printf(" <device>\n");
printf(" <match key=\"info.bus\" string=\"usb\">\n");
@@ -891,6 +958,9 @@ fdi_device_camera_func (const func_params_t *params,
*/
printf(" <match key=\"usb_device.vendor_id\" int=\"%d\">\n", a->usb_vendor);
printf(" <match key=\"usb_device.product_id\" int=\"%d\">\n", a->usb_product);
+ if (params->add_comments) {
+ printf(" <!-- %s -->\n", a->model);
+ }
if (a->device_type & GP_DEVICE_AUDIO_PLAYER)
printf(" <append key=\"info.capabilities\" type=\"strlist\">portable_audio_player</append>\n");
else
@@ -1052,6 +1122,7 @@ static const output_format_t formats[] = {
camera_func: idlist_camera_func,
end_func: empty_end_func
},
+#ifdef ENABLED_GP2DDB
{name: "gp2ddb",
descr: "gphoto2 device database (PRE-ALPHA)",
help: "PRE-ALPHA test stage, do not use for production! Machine parseable.",
@@ -1060,6 +1131,7 @@ static const output_format_t formats[] = {
camera_func: ddb_camera_func,
end_func: ddb_end_func
},
+#endif
{NULL, NULL, NULL, NULL,
NULL, NULL, NULL}
};