gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r5001 - gnunet-fuse


From: gnunet
Subject: [GNUnet-SVN] r5001 - gnunet-fuse
Date: Sat, 9 Jun 2007 23:19:15 -0600 (MDT)

Author: amatus
Date: 2007-06-09 23:19:15 -0600 (Sat, 09 Jun 2007)
New Revision: 5001

Modified:
   gnunet-fuse/ChangeLog
   gnunet-fuse/configure.ac
   gnunet-fuse/gnfs.h
   gnunet-fuse/main.c
   gnunet-fuse/readdir.c
   gnunet-fuse/special_file.c
Log:
Added .uri.<file> files which read the uri of <file>

Modified: gnunet-fuse/ChangeLog
===================================================================
--- gnunet-fuse/ChangeLog       2007-06-10 05:11:44 UTC (rev 5000)
+++ gnunet-fuse/ChangeLog       2007-06-10 05:19:15 UTC (rev 5001)
@@ -1,3 +1,5 @@
+2007-06-10 David Barksdale <address@hidden> 0.5
+* Added .uri.<file> files which read the uri of <file>
 2007-06-08 David Barksdale <address@hidden> 0.4
 * Added .uri files which read the uri of the containing directory
 2007-05-30 David Barksdale <address@hidden> 0.3

Modified: gnunet-fuse/configure.ac
===================================================================
--- gnunet-fuse/configure.ac    2007-06-10 05:11:44 UTC (rev 5000)
+++ gnunet-fuse/configure.ac    2007-06-10 05:19:15 UTC (rev 5001)
@@ -1,4 +1,4 @@
-AC_INIT(gnunet-fuse, 0.4)
+AC_INIT(gnunet-fuse, 0.5)
 AM_INIT_AUTOMAKE
 AM_CONFIG_HEADER(config.h)
 

Modified: gnunet-fuse/gnfs.h
===================================================================
--- gnunet-fuse/gnfs.h  2007-06-10 05:11:44 UTC (rev 5000)
+++ gnunet-fuse/gnfs.h  2007-06-10 05:19:15 UTC (rev 5001)
@@ -52,6 +52,7 @@
 extern struct GC_Configuration *cfg;
 extern struct GE_Context *ectx;
 extern unsigned int anonymity;
+extern int uri_files;
 extern struct dirent *root_de;
 extern struct MUTEX *root_mutex;
 

Modified: gnunet-fuse/main.c
===================================================================
--- gnunet-fuse/main.c  2007-06-10 05:11:44 UTC (rev 5000)
+++ gnunet-fuse/main.c  2007-06-10 05:19:15 UTC (rev 5001)
@@ -34,6 +34,7 @@
 static char *cfgFilename = DEFAULT_CLIENT_CONFIG_FILE;
 static char *cfgLogfile = "/tmp/gnunet_fuse.log";
 unsigned int anonymity = 1;
+int uri_files = 0;
 
 /* Root directory entry, currently used by the dirent cache when asked for / */
 struct dirent *root_de;
@@ -57,6 +58,8 @@
        { 'a', "anonymity", "LEVEL",
                "set the desired LEVEL of sender-anonymity", 1,
                &gnunet_getopt_configure_set_uint, &anonymity },
+       { 'u', "uri-files", NULL, "Make .uri files visible", 0,
+               &gnunet_getopt_configure_set_one, &uri_files },
        COMMAND_LINE_OPTION_END,
 };
 

Modified: gnunet-fuse/readdir.c
===================================================================
--- gnunet-fuse/readdir.c       2007-06-10 05:11:44 UTC (rev 5000)
+++ gnunet-fuse/readdir.c       2007-06-10 05:19:15 UTC (rev 5001)
@@ -34,6 +34,7 @@
 {
        fuse_fill_dir_t filler;
        void *buf;
+       const char *prefix;
 };
 
 static int readdir_callback(struct dirent *de, const gchar *filename,
@@ -48,7 +49,18 @@
        if(isRoot)
                return OK;
 
-       d->filler(d->buf, filename, NULL, 0);
+       if(d->prefix != NULL)
+       {
+               char *buf = MALLOC(strlen(d->prefix) + strlen(filename) + 1);
+
+               sprintf(buf, "%s%s", d->prefix, filename);
+               d->filler(d->buf, buf, NULL, 0);
+               FREE(buf);
+       }
+       else
+       {
+               d->filler(d->buf, filename, NULL, 0);
+       }
        return OK;
 }
 
@@ -81,9 +93,22 @@
        }
        filler(buf, ".", NULL, 0);
        filler(buf, "..", NULL, 0);
-       filler(buf, URI_FILE, NULL, 0);
+       if(uri_files)
+       {
+               filler(buf, URI_FILE, NULL, 0);
+               d.filler = filler;
+               d.buf = buf;
+               d.prefix = ".uri.";
+               ret = gn_directory_for_each(de, readdir_callback, &d);
+               if(ret == -1)
+               {
+                       ret = -ENOENT;
+                       goto out;
+               }
+       }
        d.filler = filler;
        d.buf = buf;
+       d.prefix = NULL;
        ret = gn_directory_for_each(de, readdir_callback, &d);
        if(ret == -1)
                ret = -ENOENT;

Modified: gnunet-fuse/special_file.c
===================================================================
--- gnunet-fuse/special_file.c  2007-06-10 05:11:44 UTC (rev 5000)
+++ gnunet-fuse/special_file.c  2007-06-10 05:19:15 UTC (rev 5001)
@@ -26,27 +26,51 @@
 char *gn_get_special_file(const char *path)
 {
        struct dirent *de;
-       char *parent, *buf = NULL;
-       int len;
+       char *buf = NULL, *file, *parent;
 
-       len = strlen(path);
-       if(len >= URI_LEN && strcmp(&path[len - URI_LEN], URI_FILE) == 0)
+       /* Break path into parent and file (dirname and basename kinda) */
+       parent = STRDUP(path);
+       file = strrchr(parent, G_DIR_SEPARATOR);
+       if(file == NULL)
+               goto out;
+       file[0] = '\0';
+       file++;
+
+       /* Check for special file name */
+       if(strcmp(file, URI_FILE) == 0)
        {
                char *uri;
 
-               parent = STRDUP(path);
-               parent[len - URI_LEN - 1] = '\0';
+               /* Return URI of the 'current' directory */
                de = gn_dirent_find(parent);
-               FREE(parent);
                if(de == NULL)
-                       return NULL;
+                       goto out;
                uri = ECRS_uriToString(de->de_uri);
                gn_dirent_put(de);
-               buf = MALLOC(strlen(uri) + 1);
+               buf = MALLOC(strlen(uri) + 2);
                strcpy(buf, uri);
                FREE(uri);
                strcat(buf, "\n");
        }
-       /* else if next case */
+       else if(strncmp(file, URI_FILE ".", URI_LEN + 1) == 0)
+       {
+               char *uri, *actual_file = MALLOC(strlen(path));
+
+               /* Return URI of the file named after the .uri. */
+               sprintf(actual_file, "%s" G_DIR_SEPARATOR_S "%s", parent,
+                       &file[URI_LEN + 1]);
+               de = gn_dirent_find(actual_file);
+               FREE(actual_file);
+               if(de == NULL)
+                       goto out;
+               uri = ECRS_uriToString(de->de_uri);
+               gn_dirent_put(de);
+               buf = MALLOC(strlen(uri) + 2);
+               strcpy(buf, uri);
+               FREE(uri);
+               strcat(buf, "\n");
+       }
+out:
+       FREE(parent);
        return buf;
 }





reply via email to

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