path.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #ifndef MC__VFS_PATH_H
  2. #define MC__VFS_PATH_H
  3. /*** typedefs(not structures) and defined constants **********************************************/
  4. #define VFS_PATH_URL_DELIMITER "://"
  5. /*** enums ***************************************************************************************/
  6. typedef enum
  7. {
  8. VPF_NONE = 0,
  9. VPF_NO_CANON = 1 << 0,
  10. VPF_USE_DEPRECATED_PARSER = 1 << 1
  11. } vfs_path_flag_t;
  12. /*** structures declarations (and typedefs of structures)*****************************************/
  13. struct vfs_class;
  14. struct vfs_url_struct;
  15. typedef struct
  16. {
  17. GList *path;
  18. } vfs_path_t;
  19. typedef struct
  20. {
  21. char *user;
  22. char *password;
  23. char *host;
  24. gboolean ipv6;
  25. int port;
  26. char *path;
  27. struct vfs_class *class;
  28. char *encoding;
  29. char *vfs_prefix;
  30. struct
  31. {
  32. GIConv converter;
  33. DIR *info;
  34. } dir;
  35. } vfs_path_element_t;
  36. /*** global variables defined in .c file *********************************************************/
  37. /*** declarations of public functions ************************************************************/
  38. vfs_path_t *vfs_path_new (void);
  39. vfs_path_t *vfs_path_clone (const vfs_path_t * vpath);
  40. void vfs_path_remove_element_by_index (vfs_path_t * vpath, int element_index);
  41. void vfs_path_free (vfs_path_t * path);
  42. int vfs_path_elements_count (const vfs_path_t * path);
  43. char *vfs_path_to_str (const vfs_path_t * path);
  44. char *vfs_path_to_str_elements_count (const vfs_path_t * path, int elements_count);
  45. vfs_path_t *vfs_path_from_str (const char *path_str);
  46. vfs_path_t *vfs_path_from_str_flags (const char *path_str, vfs_path_flag_t flags);
  47. vfs_path_element_t *vfs_path_get_by_index (const vfs_path_t * path, int element_index);
  48. vfs_path_element_t *vfs_path_element_clone (const vfs_path_element_t * element);
  49. void vfs_path_element_free (vfs_path_element_t * element);
  50. struct vfs_class *vfs_prefix_to_class (const char *prefix);
  51. gboolean vfs_path_element_need_cleanup_converter (const vfs_path_element_t * element);
  52. char *vfs_path_serialize (const vfs_path_t * vpath, GError ** error);
  53. vfs_path_t *vfs_path_deserialize (const char *data, GError ** error);
  54. /*** inline functions ****************************************************************************/
  55. static inline gboolean
  56. vfs_path_element_valid (const vfs_path_element_t * element)
  57. {
  58. return (element != NULL && element->class != NULL);
  59. }
  60. #endif