summaryrefslogtreecommitdiff
path: root/packaging
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2013-05-18 10:00:37 +0000
committerMarcus Meissner <marcus@jet.franken.de>2013-05-18 10:00:37 +0000
commitd4c89d8688a30275e6273c30b5368a2f9248a2b9 (patch)
treee76bd34a153fac76ad5583f353ca38a2a62564e9 /packaging
parent466ac1c5a9ecf1733a35a29bb1ce23c87a52919c (diff)
downloadlibgphoto2-d4c89d8688a30275e6273c30b5368a2f9248a2b9.tar.gz
html: render tables for inclusion in support.php
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@14419 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'packaging')
-rw-r--r--packaging/generic/print-camera-list.c188
1 files changed, 188 insertions, 0 deletions
diff --git a/packaging/generic/print-camera-list.c b/packaging/generic/print-camera-list.c
index 218aa3aac..96cde9c29 100644
--- a/packaging/generic/print-camera-list.c
+++ b/packaging/generic/print-camera-list.c
@@ -1143,6 +1143,184 @@ fdi_device_end_func (const func_params_t *params, void *data)
return 0;
}
+/* HTML output */
+struct html_comment {
+ char *name;
+ char *comment;
+};
+struct html_data {
+ int nrofcomments;
+ struct html_comment *comments;
+};
+
+static int
+html_begin_func (const func_params_t *params, void **data) {
+ FILE *f;
+ char buf[512];
+ int n;
+ struct html_data *hd;
+
+ printf("<!-- This part was generated by %s - - html -->\n",
+ "libgphoto2 " ARGV0);
+ print_version_comment(stdout, " | ", "\n", "<!--+\n", " +-->\n");
+ printf("<table border=1>\n");
+ printf("<tr>\n");
+ printf(" <th>Camera Model</th>\n");
+ printf(" <th>Abilities</th>\n");
+ printf(" <th>Comments</th>\n");
+ printf("</tr>\n");
+
+ hd = malloc(sizeof(*hd));
+ hd->nrofcomments = 0;
+ hd->comments = NULL;
+
+ f = fopen("comments.txt","r");
+ if (!f)
+ return 0;
+ while (fgets(buf,sizeof(buf),f)) {
+ char *s = strchr(buf,';');
+ if (!s)
+ continue;
+ *s = '\0';
+ if (hd->nrofcomments) {
+ hd->comments = realloc(hd->comments, (hd->nrofcomments+1)*sizeof(hd->comments[0]));
+ } else {
+ hd->comments = malloc(sizeof(hd->comments[0]));
+ }
+ hd->comments[hd->nrofcomments].name = strdup(buf);
+ hd->comments[hd->nrofcomments].comment = strdup(s+1);
+ hd->nrofcomments++;
+ }
+ fclose (f);
+ return 0;
+}
+
+static char*
+escape_html(const char *str) {
+ char *s, *newstr, *ns;
+ int inc = 0;
+
+ s = str;
+ do {
+ s = strchr(s,'&');
+ if (s) {
+ inc+=strlen("&amp;");
+ s++;
+ }
+ } while (s);
+ /* FIXME: if we ever get a camera with <> or so, add escape code here */
+ newstr = malloc(strlen(str)+1+inc);
+ s = str; ns = newstr;
+ do {
+ char *x;
+ x = strchr(s,'&');
+ if (x) {
+ memcpy (ns, s, x-s);
+ ns += x-s;
+ memcpy (ns, "&amp;", strlen("&amp;"));
+ ns += strlen("&amp;");
+ s = x+1;
+ } else {
+ strcpy (ns, s);
+ break;
+ }
+ } while (1);
+ return newstr;
+}
+
+static int
+html_camera_func (
+ const func_params_t *params,
+ const int i,
+ const int total,
+ const CameraAbilities *a,
+ void *data
+) {
+ char *m;
+ CameraOperation op = a->operations;
+
+ if (a->device_type != GP_DEVICE_STILL_CAMERA)
+ return 0;
+
+ printf ("<tr>\n");
+ m = escape_html (a->model);
+ printf (" <td>%s</td>", m); free (m);
+ printf (" <td>");
+ if (!op) printf ("&nbsp;");
+ if (op & GP_OPERATION_CAPTURE_IMAGE) {
+ printf ("Image Capture");
+ op &= ~GP_OPERATION_CAPTURE_IMAGE;
+ if (op) printf (", ");
+ }
+ if (op & GP_OPERATION_CAPTURE_PREVIEW) {
+ printf ("Liveview");
+ op &= ~GP_OPERATION_CAPTURE_PREVIEW;
+ if (op) printf (", ");
+ }
+ if (op & GP_OPERATION_CONFIG) {
+ printf ("Configuration");
+ op &= ~GP_OPERATION_CONFIG;
+ if (op) printf (", ");
+ }
+ if (op) {
+ printf ("Other Ops %x", op);
+ }
+ printf(" </td>");
+ printf(" <td>");
+ switch (a->status) {
+ case GP_DRIVER_STATUS_PRODUCTION: break;
+ case GP_DRIVER_STATUS_TESTING: printf("Testing (Beta)"); break;
+ case GP_DRIVER_STATUS_EXPERIMENTAL: printf("Experimental"); break;
+ case GP_DRIVER_STATUS_DEPRECATED: printf("Deprecated"); break;
+ }
+ /* read comments */
+ printf(" &nbsp;");
+ printf(" </td>");
+ printf("</tr>\n");
+ return 0;
+}
+
+static int html_middle_func (
+ const func_params_t *params,
+ void **data
+) {
+ printf("</table><p>\n");
+ printf("Media Players that are supported by both libmtp and libgphoto2:<p/>\n");
+ printf("<table border=1>\n");
+ printf("<tr>\n");
+ printf(" <th>Media Player Model</th>\n");
+ printf("</tr>\n");
+ return 0;
+}
+
+static int
+html_camera2_func (
+ const func_params_t *params,
+ const int i,
+ const int total,
+ const CameraAbilities *a,
+ void *data
+) {
+ char *m;
+
+ if (a->device_type != GP_DEVICE_AUDIO_PLAYER)
+ return 0;
+
+ m = escape_html (a->model);
+ printf ("<tr>\n");
+ printf (" <td>%s</td>", m); free (m);
+ printf("</tr>\n");
+ return 0;
+}
+
+
+static int html_end_func (
+ const func_params_t *params,
+ void *data
+) {
+ printf("</table>\n");
+ return 0;
+}
/* time zero for debug log time stamps */
struct timeval glob_tv_zero = { 0, 0 };
@@ -1301,6 +1479,16 @@ static const output_format_t formats[] = {
udev_camera_func2,
udev_end_func
},
+ {"html",
+ "HTML table file for gphoto.org website",
+ "Paste it into /proj/libgphoto2/support.php",
+ NULL,
+ html_begin_func,
+ html_camera_func,
+ html_middle_func,
+ html_camera2_func,
+ html_end_func
+ },
{"idlist",
"list of IDs and names",
"grep for an ID to find the device name",