Enlightenment CVS committal

Author  : davemds
Project : e17
Module  : libs/efreet

Dir     : e17/libs/efreet/src/lib


Modified Files:
        Efreet.h Efreet_Trash.h Makefile.am efreet_trash.c 
Added Files:
        efreet_uri.c efreet_uri.h 


Log Message:
 Move Efreet_Uri stuff on the proper file. We can now use this in e instead of 
the internal one.

===================================================================
RCS file: /cvs/e/e17/libs/efreet/src/lib/Efreet.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- Efreet.h    2 Aug 2008 21:48:44 -0000       1.5
+++ Efreet.h    3 Aug 2008 00:07:17 -0000       1.6
@@ -22,6 +22,7 @@
  * @li Icon Theme Specification
  * @li Desktop Entry Specification
  * @li Desktop Menu Specification
+ * @li FDO URI Specification
  * @li Shared Mime Info Specification
  * @li Trash Specification
  */
@@ -57,6 +58,7 @@
 #include "efreet_desktop.h"
 #include "efreet_menu.h"
 #include "efreet_utils.h"
+#include "efreet_uri.h"
 
 EAPI int efreet_init(void);
 EAPI int efreet_shutdown(void);
===================================================================
RCS file: /cvs/e/e17/libs/efreet/src/lib/Efreet_Trash.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- Efreet_Trash.h      2 Aug 2008 21:48:44 -0000       1.2
+++ Efreet_Trash.h      3 Aug 2008 00:07:17 -0000       1.3
@@ -2,15 +2,6 @@
 #ifndef EFREET_TRASH_H
 #define EFREET_TRASH_H
 
-/**
- * @file Efreet_Trash.h
- * @brief Contains the methods used to support the FDO trash specification.
- * @addtogroup Efreet_Trash Efreet_Trash: The XDG Trash Specification
- * Efreet_Trash.h provides all of the necessary headers and includes to
- * work with Efreet_Trash.
- * @{
- */
-
 #ifdef EAPI
 #undef EAPI
 #endif
@@ -36,29 +27,14 @@
 extern "C" {
 #endif
 
-
-
 /**
- * Efreet_Uri
- */
-typedef struct Efreet_Uri Efreet_Uri;
-
-/**
- * Efreet_Uri
- * @brief Contains a simple rappresentation of an uri. The string don't have 
- * special chars escaped.
+ * @file Efreet_Trash.h
+ * @brief Contains the methods used to support the FDO trash specification.
+ * @addtogroup Efreet_Trash Efreet_Trash: The XDG Trash Specification
+ * Efreet_Trash.h provides all of the necessary headers and includes to
+ * work with Efreet_Trash.
+ * @{
  */
-struct Efreet_Uri
-{
-    const char *protocol;   /**< The name of the host if any, or NULL */
-    const char *hostname;   /**< The name of the host if any, or NULL */
-    const char *path;       /**< The full file path whitout protocol nor host*/
-};
-
-
-EAPI const char *efreet_uri_escape(Efreet_Uri *uri);
-EAPI Efreet_Uri *efreet_uri_parse(const char *val);
-EAPI void        efreet_uri_free(Efreet_Uri *uri);
 
 EAPI int         efreet_trash_init(void);
 EAPI void        efreet_trash_shutdown(void);
@@ -68,8 +44,7 @@
 EAPI Ecore_List *efreet_trash_ls(void);
 EAPI int         efreet_trash_is_empty(void);
 EAPI int         efreet_trash_empty_trash(void);
-   
-   
+
 /**
  * @}
  */
===================================================================
RCS file: /cvs/e/e17/libs/efreet/src/lib/Makefile.am,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -3 -r1.11 -r1.12
--- Makefile.am 16 Jul 2008 19:45:12 -0000      1.11
+++ Makefile.am 3 Aug 2008 00:07:17 -0000       1.12
@@ -15,7 +15,8 @@
 efreet_icon.h \
 efreet_ini.h \
 efreet_menu.h \
-efreet_utils.h
+efreet_utils.h \
+efreet_uri.h
 
 EFREETSOURCES = \
 efreet.c \
@@ -26,6 +27,7 @@
 efreet_desktop.c \
 efreet_menu.c \
 efreet_utils.c \
+efreet_uri.c \
 efreet_private.h \
 efreet_xml.h \
 $(EFREETHEADERS)
===================================================================
RCS file: /cvs/e/e17/libs/efreet/src/lib/efreet_trash.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- efreet_trash.c      2 Aug 2008 22:09:04 -0000       1.2
+++ efreet_trash.c      3 Aug 2008 00:07:17 -0000       1.3
@@ -108,8 +108,7 @@
             return 0;
         }
     }
-   
-      
+
     /* create info file */
     snprintf(dest, PATH_MAX, "%s/info/%s.trashinfo",
              efreet_trash_dir_get(), fname);
@@ -119,7 +118,7 @@
         fputs("[Trash Info]\n", f); //TODO is '\n' right?? (or \r\c??)
 
         fputs("Path=", f);
-        escaped = efreet_uri_escape(uri);
+        escaped = efreet_uri_encode(uri);
         fputs(escaped + 7, f); // +7 == don't write 'file://'
         IF_RELEASE(escaped);
 
@@ -198,115 +197,3 @@
     return files;
 }
 
-
-/**
- * @param val: a valid uri string to parse
- * @return Return The corresponding Efreet_Uri structure. Or NULL on errors.
- * @brief Parse a single uri and return an Efreet_Uri struct. If there's no
- * hostname in the uri then the hostname parameter is NULL. All the uri escaped
- * chars will be converted back.
- */
-EAPI Efreet_Uri *
-efreet_uri_parse(const char *val)
-{
-    Efreet_Uri *uri;
-    const char *p;
-    char protocol[64], hostname[_POSIX_HOST_NAME_MAX], path[PATH_MAX];
-    int i = 0;
-
-    /* An uri should be in the form <protocol>://<hostname>/<path> */
-    p = strstr(val, "://");
-    if (!p) return NULL;
-
-    memset(protocol, 0, 64);
-    memset(hostname, 0, _POSIX_HOST_NAME_MAX);
-    memset(path, 0, PATH_MAX);
-
-    /* parse protocol */
-    p = val;
-    for (i = 0; *p != ':' && *p != '\0' && i < 64; p++, i++)
-         protocol[i] = *p;
-    protocol[i] = '\0';
-
-    /* parse hostname */
-    p += 3;
-    if (*p != '/')
-    {
-        for (i = 0; *p != '/' && *p != '\0' && i < _POSIX_HOST_NAME_MAX; p++, 
i++)
-            hostname[i] = *p;
-        hostname[i] = '\0';
-    }
-    else
-        hostname[0] = '\0';
-
-    /* parse path */
-    /* See http://www.faqs.org/rfcs/rfc1738.html for the escaped chars */
-    for (i = 0; *p != '\0' && i < PATH_MAX; i++, p++)
-    {
-        if (*p == '%')
-        {
-            path[i] = *(++p);
-            path[i + 1] = *(++p);
-            path[i] = (char)strtol(&(path[i]), NULL, 16);
-            path[i + 1] = '\0';
-        }
-        else
-            path[i] = *p;
-    }
-
-    uri = NEW(Efreet_Uri, 1);
-    if (!uri) return NULL;
-
-    uri->protocol = ecore_string_instance(protocol);
-    uri->hostname = ecore_string_instance(hostname);
-    uri->path = ecore_string_instance(path);
-
-    return uri;
-}
-
-/**
- * @param uri: The uri structure to escape
- * @return The string rapresentation of an uri (ex: 'file:///home/my%20name')
- * @brief Get the string rapresentation of the given uri struct escaping
- * illegal caracters. The resulting string will contain the protocol but not 
the
- * hostname, as many apps doesn't handle it.
- */
-EAPI const char *
-efreet_uri_escape(Efreet_Uri *uri)
-{
-    char dest[PATH_MAX * 3 + 4];
-    const char *p;
-    int i;
-
-    if (!uri || !uri->path || !uri->protocol) return NULL;
-    memset(dest, 0, PATH_MAX * 3 + 4);
-    snprintf(dest, strlen(uri->protocol) + 4, "%s://", uri->protocol);
-
-    /* Most app doesn't handle the hostname in the uri so it's put to NULL */
-    for (i = strlen(uri->protocol) + 3, p = uri->path; *p != '\0'; p++, i++)
-    {
-        if (isalnum(*p) || strchr("/$-_.+!*'()", *p))
-            dest[i] = *p;
-        else
-        {
-            snprintf(&(dest[i]), 4, "%%%02X", *p);
-            i += 2;
-        }
-    }
-
-    return ecore_string_instance(dest);
-}
-
-/**
- * @param uri: The uri to free
- * @brief Free the given uri structure.
- */
-EAPI void
-efreet_uri_free(Efreet_Uri *uri)
-{
-    if (!uri) return;
-    IF_RELEASE(uri->protocol);
-    IF_RELEASE(uri->path);
-    IF_RELEASE(uri->hostname);
-    FREE(uri);
-}



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to