root/lib/vfs/path.h

/* [previous][next][first][last][top][bottom][index][help]  */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. vfs_path_element_valid
  2. vfs_path_get_last_path_str
  3. vfs_path_get_last_path_vfs
  4. vfs_path_as_str

   1 #ifndef MC__VFS_PATH_H
   2 #define MC__VFS_PATH_H
   3 
   4 /*** typedefs(not structures) and defined constants **********************************************/
   5 
   6 #define VFS_PATH_URL_DELIMITER "://"
   7 
   8 /*** enums ***************************************************************************************/
   9 
  10 typedef enum
  11 {
  12     VPF_NONE = 0,
  13     VPF_NO_CANON = 1 << 0,
  14     VPF_USE_DEPRECATED_PARSER = 1 << 1,
  15     VPF_RECODE = 1 << 2,
  16     VPF_STRIP_HOME = 1 << 3,
  17     VPF_STRIP_PASSWORD = 1 << 4,
  18     VPF_HIDE_CHARSET = 1 << 5
  19 } vfs_path_flag_t;
  20 
  21 /*** structures declarations (and typedefs of structures)*****************************************/
  22 
  23 struct vfs_class;
  24 struct vfs_url_struct;
  25 
  26 typedef struct
  27 {
  28     gboolean relative;
  29     GArray *path;
  30     char *str;
  31 } vfs_path_t;
  32 
  33 typedef struct
  34 {
  35     char *user;
  36     char *password;
  37     char *host;
  38     gboolean ipv6;
  39     int port;
  40     char *path;
  41     struct vfs_class *class;
  42 #ifdef HAVE_CHARSET
  43     char *encoding;
  44 #endif
  45     char *vfs_prefix;
  46 
  47     struct
  48     {
  49 #ifdef HAVE_CHARSET
  50         GIConv converter;
  51 #endif
  52         DIR *info;
  53     } dir;
  54 } vfs_path_element_t;
  55 
  56 /*** global variables defined in .c file *********************************************************/
  57 
  58 /*** declarations of public functions ************************************************************/
  59 
  60 vfs_path_t *vfs_path_new (gboolean relative);
  61 vfs_path_t *vfs_path_clone (const vfs_path_t * vpath);
  62 void vfs_path_remove_element_by_index (vfs_path_t * vpath, int element_index);
  63 char *vfs_path_free (vfs_path_t * path, gboolean free_str);
  64 int vfs_path_elements_count (const vfs_path_t * path);
  65 
  66 char *vfs_path_to_str_elements_count (const vfs_path_t * path, int elements_count);
  67 char *vfs_path_to_str_flags (const vfs_path_t * vpath, int elements_count, vfs_path_flag_t flags);
  68 vfs_path_t *vfs_path_from_str (const char *path_str);
  69 vfs_path_t *vfs_path_from_str_flags (const char *path_str, vfs_path_flag_t flags);
  70 vfs_path_t *vfs_path_build_filename (const char *first_element, ...);
  71 vfs_path_t *vfs_path_append_new (const vfs_path_t * vpath, const char *first_element, ...);
  72 vfs_path_t *vfs_path_append_vpath_new (const vfs_path_t * first_vpath, ...);
  73 size_t vfs_path_tokens_count (const vfs_path_t * vpath);
  74 char *vfs_path_tokens_get (const vfs_path_t * vpath, ssize_t start_position, ssize_t length);
  75 vfs_path_t *vfs_path_vtokens_get (const vfs_path_t * vpath, ssize_t start_position, ssize_t length);
  76 
  77 void vfs_path_add_element (vfs_path_t * vpath, const vfs_path_element_t * path_element);
  78 const vfs_path_element_t *vfs_path_get_by_index (const vfs_path_t * path, int element_index);
  79 vfs_path_element_t *vfs_path_element_clone (const vfs_path_element_t * element);
  80 void vfs_path_element_free (vfs_path_element_t * element);
  81 
  82 struct vfs_class *vfs_prefix_to_class (const char *prefix);
  83 
  84 #ifdef HAVE_CHARSET
  85 char *vfs_get_encoding(const char *path, ssize_t len);
  86 gboolean vfs_path_element_need_cleanup_converter (const vfs_path_element_t * element);
  87 vfs_path_t *vfs_path_change_encoding (vfs_path_t * vpath, const char *encoding);
  88 #endif
  89 
  90 char *vfs_path_serialize (const vfs_path_t * vpath, GError ** error);
  91 vfs_path_t *vfs_path_deserialize (const char *data, GError ** error);
  92 
  93 GString *vfs_path_build_url_params_str (const vfs_path_element_t * element, gboolean keep_password);
  94 GString *vfs_path_element_build_pretty_path_str (const vfs_path_element_t * element);
  95 
  96 size_t vfs_path_len (const vfs_path_t * vpath);
  97 gboolean vfs_path_equal (const vfs_path_t * vpath1, const vfs_path_t * vpath2);
  98 gboolean vfs_path_equal_len (const vfs_path_t * vpath1, const vfs_path_t * vpath2, size_t len);
  99 vfs_path_t *vfs_path_to_absolute (const vfs_path_t * vpath);
 100 
 101 /*** inline functions ****************************************************************************/
 102 
 103 static inline gboolean
 104 vfs_path_element_valid (const vfs_path_element_t *element)
     /* [previous][next][first][last][top][bottom][index][help]  */
 105 {
 106     return (element != NULL && element->class != NULL);
 107 }
 108 
 109 /* --------------------------------------------------------------------------------------------- */
 110 
 111 static inline const char *
 112 vfs_path_get_last_path_str (const vfs_path_t *vpath)
     /* [previous][next][first][last][top][bottom][index][help]  */
 113 {
 114     const vfs_path_element_t *element;
 115 
 116     if (vpath == NULL)
 117         return NULL;
 118     element = vfs_path_get_by_index (vpath, -1);
 119     return (element != NULL) ? element->path : NULL;
 120 }
 121 
 122 /* --------------------------------------------------------------------------------------------- */
 123 
 124 static inline const struct vfs_class *
 125 vfs_path_get_last_path_vfs (const vfs_path_t *vpath)
     /* [previous][next][first][last][top][bottom][index][help]  */
 126 {
 127     const vfs_path_element_t *element;
 128 
 129     if (vpath == NULL)
 130         return NULL;
 131     element = vfs_path_get_by_index (vpath, -1);
 132     return (element != NULL) ? element->class : NULL;
 133 }
 134 
 135 /* --------------------------------------------------------------------------------------------- */
 136 /**
 137  * Convert vfs_path_t to string representation.
 138  *
 139  * @param vpath pointer to vfs_path_t object
 140  *
 141  * @return pointer to constant string
 142  */
 143 
 144 static inline const char *
 145 vfs_path_as_str (const vfs_path_t *vpath)
     /* [previous][next][first][last][top][bottom][index][help]  */
 146 {
 147     return (vpath == NULL ? NULL : vpath->str);
 148 }
 149 
 150 /* --------------------------------------------------------------------------------------------- */
 151 
 152 #endif

/* [previous][next][first][last][top][bottom][index][help]  */