ftpdataio.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #ifndef VSF_FTPDATAIO_H
  2. #define VSF_FTPDATAIO_H
  3. #include "filesize.h"
  4. struct mystr;
  5. struct vsf_sysutil_sockaddr;
  6. struct vsf_sysutil_dir;
  7. struct vsf_session;
  8. /* vsf_ftpdataio_dispose_transfer_fd()
  9. * PURPOSE
  10. * Close down the remote data transfer file descriptor. If unsent data reamins
  11. * on the connection, this method blocks until it is transferred (or the data
  12. * timeout goes off, or the connection is severed).
  13. * PARAMETERS
  14. * p_sess - the current FTP session object
  15. * RETURNS
  16. * 1 on success, 0 otherwise.
  17. *
  18. */
  19. int vsf_ftpdataio_dispose_transfer_fd(struct vsf_session* p_sess);
  20. /* vsf_ftpdataio_get_pasv_fd()
  21. * PURPOSE
  22. * Return a connection data file descriptor obtained by the PASV connection
  23. * method. This includes accept()'ing a connection from the remote.
  24. * PARAMETERS
  25. * p_sess - the current FTP session object
  26. * RETURNS
  27. * The file descriptor upon success, or -1 upon error.
  28. */
  29. int vsf_ftpdataio_get_pasv_fd(struct vsf_session* p_sess);
  30. /* vsf_ftpdataio_get_pasv_fd()
  31. * PURPOSE
  32. * Return a connection data file descriptor obtained by the PORT connection
  33. * method. This includes connect()'ing to the remote.
  34. * PARAMETERS
  35. * p_sess - the current FTP session object
  36. * RETURNS
  37. * The file descriptor upon success, or -1 upon error.
  38. */
  39. int vsf_ftpdataio_get_port_fd(struct vsf_session* p_sess);
  40. /* vsf_ftpdataio_post_mark_connect()
  41. * PURPOSE
  42. * Perform any post-150-status-mark setup on the data connection. For example,
  43. * the negotiation of SSL.
  44. * PARAMETERS
  45. * p_sess - the current FTP session object
  46. * RETURNS
  47. * 1 on success, 0 otherwise.
  48. */
  49. int vsf_ftpdataio_post_mark_connect(struct vsf_session* p_sess);
  50. /* vsf_ftpdataio_transfer_file()
  51. * PURPOSE
  52. * Send data between the network and a local file. Send and receive are
  53. * supported, as well as ASCII mangling.
  54. * PARAMETERS
  55. * remote_fd - the file descriptor of the remote data connection
  56. * file_fd - the file descriptor of the local file
  57. * is_recv - 0 for sending to the remote, otherwise receive
  58. * is_ascii - non zero for ASCII mangling
  59. * RETURNS
  60. * A structure, containing
  61. * retval - 0 for success, failure otherwise
  62. * (-1 = local problem -2 = remote problem)
  63. * transferred - number of bytes transferred
  64. */
  65. struct vsf_transfer_ret
  66. {
  67. int retval;
  68. filesize_t transferred;
  69. };
  70. struct vsf_transfer_ret vsf_ftpdataio_transfer_file(
  71. struct vsf_session* p_sess,
  72. int remote_fd, int file_fd, int is_recv, int is_ascii);
  73. /* vsf_ftpdataio_transfer_dir()
  74. * PURPOSE
  75. * Send an ASCII directory lising of the requested directory to the remote
  76. * client.
  77. * PARAMETERS
  78. * p_sess - the current session object
  79. * is_control - whether to send on the control connection or data connection
  80. * p_dir - the local directory object
  81. * p_base_dir_str - the directory we opened relative to the current one
  82. * p_option_str - the options list provided to "ls"
  83. * p_filter_str - the filter string provided to "ls"
  84. * is_verbose - set to 0 if NLST used, 1 if LIST used
  85. */
  86. int vsf_ftpdataio_transfer_dir(struct vsf_session* p_sess, int is_control,
  87. struct vsf_sysutil_dir* p_dir,
  88. const struct mystr* p_base_dir_str,
  89. const struct mystr* p_option_str,
  90. const struct mystr* p_filter_str,
  91. int is_verbose);
  92. #endif /* VSF_FTPDATAIO_H */