gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r19586 - gnunet-gtk/src/fs


From: gnunet
Subject: [GNUnet-SVN] r19586 - gnunet-gtk/src/fs
Date: Wed, 1 Feb 2012 00:13:04 +0100

Author: grothoff
Date: 2012-02-01 00:13:03 +0100 (Wed, 01 Feb 2012)
New Revision: 19586

Modified:
   gnunet-gtk/src/fs/gnunet-fs-gtk-event_handler.c
Log:
-documenting get_suggested_filename_anonymity

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk-event_handler.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk-event_handler.c     2012-01-31 22:58:29 UTC 
(rev 19585)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk-event_handler.c     2012-01-31 23:13:03 UTC 
(rev 19586)
@@ -194,12 +194,17 @@
  * Called recursively to build a suggested filename by prepending
  * suggested names for its parent directories (if any).
  *
- * @param tm FIXME
- * @param iter FIXME
- * @param top FIXME
- * @param local_parents set to  GNUNET_YES if all parents are directories, and 
are downloaded.
- * @param anonymity FIXME
- * @param filename_is_absolute FIXME
+ * @param tm tree model this function gets the data from
+ * @param iter current position in the tree, for which we want a suggested 
filename
+ * @param top GNUNET_YES for the original call to this function,
+ *            GNUNET_NO for recursive calls; used to decide if the
+ *            current call is eligible to set 'anonymity' and 'local_parents'
+ * @param local_parents set to GNUNET_YES if all parents are directories, and 
are downloaded.
+ * @param anonymity set to the anonymity level of the closest ancestor 
download (if any);
+ *                      set to "-1" for uninitialized initially (will be left 
at -1 if
+ *                      no suitable parent download was found)
+ * @param filename_is_absolute set to GNUNET_YES if the suggestion is an 
absolute filename,
+ *                             GNUNET_NO for relative filenames (gotten from 
meta data)
  * @return suggested filename, possibly NULL
  */
 static char *
@@ -212,30 +217,41 @@
 {
   char *result;
   char *dirname;
-  char *local_filename, *filename;
+  char *local_filename;
+  char *filename;
   int downloaded_anonymity;
   int have_a_parent;
   struct GNUNET_CONTAINER_MetaData *meta;
   GtkTreeIter parent;
-  gtk_tree_model_get (tm, iter, 0, &meta, 15, &local_filename, 16, 
&downloaded_anonymity, -1);
-  if (local_filename == NULL && !top)
+  const char *basename; 
+  char *dot;
+
+  gtk_tree_model_get (tm, iter, 0, &meta, 
+                     15, &local_filename, 
+                     16, &downloaded_anonymity, 
+                     -1);
+  if ( (NULL == local_filename) && (GNUNET_NO == top) )
     *local_parents = GNUNET_NO;
-  if (downloaded_anonymity != -1 && *anonymity == -1 && !top)
+  if ( (downloaded_anonymity != -1) && (*anonymity == -1) && (GNUNET_NO == 
top) )
     *anonymity = downloaded_anonymity;
   if (gtk_tree_model_iter_parent (tm, &parent, iter))
   {
     have_a_parent = GNUNET_YES;
-    dirname = get_suggested_filename_anonymity (tm, &parent, GNUNET_NO, 
local_parents, anonymity, filename_is_absolute);
+    dirname = get_suggested_filename_anonymity (tm, &parent, GNUNET_NO,
+                                               local_parents, anonymity, 
+                                               filename_is_absolute);
   }
   else
   {
     have_a_parent = GNUNET_NO;
     dirname = NULL;
-    if (top)
+    if (GNUNET_NO == top)
       *local_parents = GNUNET_NO;
   }
   if (local_filename == NULL)
+  {
     filename = GNUNET_FS_meta_data_suggest_filename (meta);
+  }
   else
   {
     /* This directory was downloaded as /foo/bar/baz/somedirname
@@ -245,37 +261,38 @@
      * Without the .gnd extension we're going to just use a copy
      * of the directory file name - and that would fail. Sad.
      */
-    const char *basename; 
-    if (dirname == NULL && !have_a_parent)
+    if ( (NULL == dirname) && (GNUNET_NO == have_a_parent))
     {
       /* This is the ealderlest parent directory. Use absolute path. */
       basename = (const char *) local_filename;
       *filename_is_absolute = GNUNET_YES;
     }
     else
+    {
       basename = GNUNET_STRINGS_get_short_name (local_filename);
-    if (basename != NULL && strlen (basename) > 0)
+    }
+    if ( (NULL != basename) && (strlen (basename) > 0) )
     {
-      char *dot;
       filename = GNUNET_strdup (basename);
       dot = strrchr (filename, '.');
       if (dot)
         *dot = '\0';
     }
     else
+    {
       filename = GNUNET_FS_meta_data_suggest_filename (meta);
+    }
   }
-  if (dirname && filename)
+  if ( (NULL != dirname) && (NULL != filename) )
   {
     GNUNET_asprintf (&result, "%s%s%s", dirname, DIR_SEPARATOR_STR, filename);
     GNUNET_free (filename);
     GNUNET_free (dirname);
     return result;
   }
-  else if (filename)
+  if (NULL != filename)
     return filename;
-  else
-    return NULL;
+  return NULL;
 }
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]