[git] gnupg-doc - branch, master, updated. 4bb81e5ae79457ced41a5f2b467fafcf4eebde3d

by Werner Koch cvs at cvs.gnupg.org
Wed Nov 8 18:41:11 CET 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GnuPG website and other docs".

The branch, master has been updated
       via  4bb81e5ae79457ced41a5f2b467fafcf4eebde3d (commit)
      from  8fc663510f8aa84e3852bd9e2c23e91b6f7d922e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 4bb81e5ae79457ced41a5f2b467fafcf4eebde3d
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Nov 8 18:36:58 2017 +0100

    tools: Add descriptions to directory listings.
    
    These descriptions are taken from the file ".title" in the respective
    sub-directory.  Only the first line is used.

diff --git a/tools/ftp-indexer.c b/tools/ftp-indexer.c
index e59ad60..5576e42 100644
--- a/tools/ftp-indexer.c
+++ b/tools/ftp-indexer.c
@@ -104,6 +104,12 @@ done
 #define ATTR_PRINTF(a,b)
 #define ATTR_NR_PRINTF(a,b)
 #endif
+#if __GNUC__ >= 4
+# define ATTR_SENTINEL(a) __attribute__ ((sentinel(a)))
+#else
+# define ATTR_SENTINEL(a)
+#endif
+
 
 #define digitp(a) ((a) >= '0' && (a) <= '9')
 #define VALID_URI_CHARS "abcdefghijklmnopqrstuvwxyz"   \
@@ -148,7 +154,7 @@ static strlist_t opt_exclude;
 static void die (const char *format, ...) ATTR_NR_PRINTF(1,2);
 static void err (const char *format, ...) ATTR_PRINTF(1,2);
 static void inf (const char *format, ...) ATTR_PRINTF(1,2);
-
+static char *xstrconcat (const char *s1, ...) ATTR_SENTINEL(0);
 
 
 static void
@@ -214,7 +220,7 @@ xcalloc (size_t n, size_t k)
 static char *
 xstrdup (const char *string)
 {
-  char *buf = xmalloc (strlen (string));
+  char *buf = xmalloc (strlen (string) + 1);
   strcpy (buf, string);
   return buf;
 }
@@ -231,6 +237,55 @@ my_stpcpy (char *a, const char *b)
 }
 
 
+/* Helper for xstrconcat.  */
+static char *
+do_strconcat (const char *s1, va_list arg_ptr)
+{
+  const char *argv[48];
+  size_t argc;
+  size_t needed;
+  char *buffer, *p;
+
+  argc = 0;
+  argv[argc++] = s1;
+  needed = strlen (s1);
+  while (((argv[argc] = va_arg (arg_ptr, const char *))))
+    {
+      needed += strlen (argv[argc]);
+      if (argc >= DIM (argv)-1)
+        die ("internal error: too may args for strconcat\n");
+      argc++;
+    }
+  needed++;
+  buffer = xmalloc (needed);
+  for (p = buffer, argc=0; argv[argc]; argc++)
+    p = my_stpcpy (p, argv[argc]);
+
+  return buffer;
+}
+
+
+/* Concatenate the string S1 with all the following strings up to a
+   NULL.  Returns a malloced buffer with the new string or NULL on a
+   malloc error or if too many arguments are given.  */
+static char *
+xstrconcat (const char *s1, ...)
+{
+  va_list arg_ptr;
+  char *result;
+
+  if (!s1)
+    result = xstrdup ("");
+  else
+    {
+      va_start (arg_ptr, s1);
+      result = do_strconcat (s1, arg_ptr);
+      va_end (arg_ptr);
+    }
+  return result;
+}
+
+
 /* If SPECIAL is NULL this function escapes in forms mode.  */
 static size_t
 escape_data (char *buffer, const void *data, size_t datalen,
@@ -902,13 +957,15 @@ print_footer (void)
 }
 
 
-/* Print COUNT directories from the array SORTED. */
+/* Print COUNT directories from the array SORTED.
+ * Note: This function assumes that the CWD is the listed directory.  */
 static void
 print_dirs (finfo_t *sorted, int count, int at_root)
 {
   int idx;
   finfo_t fi;
   int any = 0;
+  char *title = NULL;
 
   for (idx=0; idx < count; idx++)
     {
@@ -943,14 +1000,44 @@ print_dirs (finfo_t *sorted, int count, int at_root)
             }
         }
 
+      free (title);
+      title = NULL;
       if (opt_gpgweb)
-        printf ("<tr><td><img src=\"/share/folder.png\""
-                " width=\"22\" height=\"22\"/></td>"
-                "<td><a href=\"%s\">%s</a></td></tr>\n",
-                html_escape_href (fi->name), html_escape (fi->name));
-      else if (opt_html)
-        printf ("<tr><td width=\"40%%\"><a href=\"%s\">%s</a></td></tr>\n",
-                html_escape_href (fi->name), html_escape (fi->name));
+        {
+          char *fname;
+          FILE *fp;
+
+          fname = xstrconcat (fi->name, "/", ".title", NULL);
+          fp = fopen (fname, "r");
+          free (fname);
+          if (fp)
+            {
+              char line[200];
+
+              if (fgets (line, sizeof line, fp) && *line)
+                {
+                  if (line[strlen(line)-1] == '\n')
+                    line[strlen(line)-1] = 0;
+                  title = xstrdup (html_escape (line));
+                }
+              fclose (fp);
+            }
+        }
+
+      if (opt_html)
+        {
+          if (opt_gpgweb)
+            printf ("<tr><td><img src=\"/share/folder.png\""
+                    " width=\"22\" height=\"22\"/></td>"
+                    "<td><a href=\"%s\">%s</a></td>",
+                    html_escape_href (fi->name), html_escape (fi->name));
+          else
+            printf ("<tr><td width=\"40%%\"><a href=\"%s\">%s</a></td>",
+                    html_escape_href (fi->name), html_escape (fi->name));
+          if (title)
+            printf ("<td>%s</td>", title);
+          fputs ("</tr>\n", stdout);
+        }
       else
         printf ("D %s\n", fi->name);
     }
@@ -974,6 +1061,8 @@ print_dirs (finfo_t *sorted, int count, int at_root)
 
 
     }
+
+  free (title);
 }
 
 

-----------------------------------------------------------------------

Summary of changes:
 tools/ftp-indexer.c | 109 +++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 99 insertions(+), 10 deletions(-)


hooks/post-receive
-- 
The GnuPG website and other docs
http://git.gnupg.org




More information about the Gnupg-commits mailing list