ftpcmdio.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #ifndef VSF_FTPCMDIO_H
  2. #define VSF_FTPCMDIO_H
  3. struct mystr;
  4. struct vsf_session;
  5. /* vsf_cmdio_sock_setup()
  6. * PURPOSE
  7. * Initialise a few socket settings (keepalive, nonagle, etc). on the FTP
  8. * control connection.
  9. */
  10. void vsf_cmdio_sock_setup(void);
  11. /* vsf_cmdio_write()
  12. * PURPOSE
  13. * Write a response to the FTP control connection.
  14. * PARAMETERS
  15. * p_sess - the current session object
  16. * status - the status code to report
  17. * p_text - the text to report
  18. */
  19. void vsf_cmdio_write(struct vsf_session* p_sess, int status,
  20. const char* p_text);
  21. /* vsf_cmdio_write_hyphen()
  22. * PURPOSE
  23. * Write a response to the FTP control connection, with a hyphen '-'
  24. * continuation indicator.
  25. * PARAMETERS
  26. * p_sess - the current session object
  27. * status - the status code to report
  28. * p_text - the text to report
  29. */
  30. void vsf_cmdio_write_hyphen(struct vsf_session* p_sess, int status,
  31. const char* p_text);
  32. /* vsf_cmdio_write_raw()
  33. * PURPOSE
  34. * Write a raw response to the FTP control connection. A status code is
  35. * not prepended, and it is also the client's responsibility to include
  36. * newline characters if required.
  37. * PARAMETERS
  38. * p_sess - the current session object
  39. * p_text - the text to report
  40. */
  41. void vsf_cmdio_write_raw(struct vsf_session* p_sess, const char* p_text);
  42. /* vsf_cmdio_write_exit()
  43. * PURPOSE
  44. * The same as vsf_cmdio_write(), and then the calling process is exited. The
  45. * write is _guaranteed_ to not block (ditching output if neccessary).
  46. */
  47. void vsf_cmdio_write_exit(struct vsf_session* p_sess, int status,
  48. const char* p_text, int exit_val);
  49. /* vsf_cmdio_write_str()
  50. * PURPOSE
  51. * The same as vsf_cmdio_write(), apart from the text is specified as a
  52. * string buffer object "p_str".
  53. */
  54. void vsf_cmdio_write_str(struct vsf_session* p_sess, int status,
  55. const struct mystr* p_str);
  56. /* vsf_cmdio_write_str_hyphen()
  57. * PURPOSE
  58. * The same as vsf_cmdio_write_str(), apart from the response line is
  59. * output with the continuation indicator '-' between the response code and
  60. * the response text. This indicates there are more lines of response.
  61. */
  62. void vsf_cmdio_write_str_hyphen(struct vsf_session* p_sess, int status,
  63. const struct mystr* p_str);
  64. /* vsf_cmdio_set_alarm()
  65. * PURPOSE
  66. * Activate the control connection inactivity timeout. This is explicitly
  67. * exposed in the API so that we can play it safe, and activate the alarm
  68. * before _any_ potentially blocking calls.
  69. * PARAMETERS
  70. * p_sess - The current session object
  71. */
  72. void vsf_cmdio_set_alarm(struct vsf_session* p_sess);
  73. /* vsf_cmdio_get_cmd_and_arg()
  74. * PURPOSE
  75. * Read an FTP command (and optional argument) from the FTP control connection.
  76. * PARAMETERS
  77. * p_sess - The current session object
  78. * p_cmd_str - Where to put the FTP command string (may be empty)
  79. * p_arg_str - Where to put the FTP argument string (may be empty)
  80. * set_alarm - If true, the control connection inactivity monitor is used
  81. */
  82. void vsf_cmdio_get_cmd_and_arg(struct vsf_session* p_sess,
  83. struct mystr* p_cmd_str,
  84. struct mystr* p_arg_str, int set_alarm);
  85. #endif /* VSF_FTPCMDIO_H */