PageRenderTime 42ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/xbmc/pvrclients/ForTheRecord/lib/curl-7.21.4/lib/ftp.h

https://github.com/macardi/xbmc
C Header | 153 lines | 97 code | 15 blank | 41 comment | 0 complexity | 5ddbad520f3aabb5f7210b6c549c0158 MD5 | raw file
  1. #ifndef HEADER_CURL_FTP_H
  2. #define HEADER_CURL_FTP_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
  11. *
  12. * This software is licensed as described in the file COPYING, which
  13. * you should have received as part of this distribution. The terms
  14. * are also available at http://curl.haxx.se/docs/copyright.html.
  15. *
  16. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  17. * copies of the Software, and permit persons to whom the Software is
  18. * furnished to do so, under the terms of the COPYING file.
  19. *
  20. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  21. * KIND, either express or implied.
  22. *
  23. ***************************************************************************/
  24. #include "pingpong.h"
  25. #ifndef CURL_DISABLE_FTP
  26. extern const struct Curl_handler Curl_handler_ftp;
  27. #ifdef USE_SSL
  28. extern const struct Curl_handler Curl_handler_ftps;
  29. #endif
  30. CURLcode Curl_ftpsendf(struct connectdata *, const char *fmt, ...);
  31. CURLcode Curl_GetFTPResponse(ssize_t *nread, struct connectdata *conn,
  32. int *ftpcode);
  33. #endif /* CURL_DISABLE_FTP */
  34. /****************************************************************************
  35. * FTP unique setup
  36. ***************************************************************************/
  37. typedef enum {
  38. FTP_STOP, /* do nothing state, stops the state machine */
  39. FTP_WAIT220, /* waiting for the initial 220 response immediately after
  40. a connect */
  41. FTP_AUTH,
  42. FTP_USER,
  43. FTP_PASS,
  44. FTP_ACCT,
  45. FTP_PBSZ,
  46. FTP_PROT,
  47. FTP_CCC,
  48. FTP_PWD,
  49. FTP_SYST,
  50. FTP_NAMEFMT,
  51. FTP_QUOTE, /* waiting for a response to a command sent in a quote list */
  52. FTP_RETR_PREQUOTE,
  53. FTP_STOR_PREQUOTE,
  54. FTP_POSTQUOTE,
  55. FTP_CWD, /* change dir */
  56. FTP_MKD, /* if the dir didn't exist */
  57. FTP_MDTM, /* to figure out the datestamp */
  58. FTP_TYPE, /* to set type when doing a head-like request */
  59. FTP_LIST_TYPE, /* set type when about to do a dir list */
  60. FTP_RETR_TYPE, /* set type when about to RETR a file */
  61. FTP_STOR_TYPE, /* set type when about to STOR a file */
  62. FTP_SIZE, /* get the remote file's size for head-like request */
  63. FTP_RETR_SIZE, /* get the remote file's size for RETR */
  64. FTP_STOR_SIZE, /* get the size for (resumed) STOR */
  65. FTP_REST, /* when used to check if the server supports it in head-like */
  66. FTP_RETR_REST, /* when asking for "resume" in for RETR */
  67. FTP_PORT, /* generic state for PORT, LPRT and EPRT, check count1 */
  68. FTP_PRET, /* generic state for PRET RETR, PRET STOR and PRET LIST/NLST */
  69. FTP_PASV, /* generic state for PASV and EPSV, check count1 */
  70. FTP_LIST, /* generic state for LIST, NLST or a custom list command */
  71. FTP_RETR,
  72. FTP_STOR, /* generic state for STOR and APPE */
  73. FTP_QUIT,
  74. FTP_LAST /* never used */
  75. } ftpstate;
  76. struct ftp_parselist_data; /* defined later in ftplistparser.c */
  77. struct ftp_wc_tmpdata {
  78. struct ftp_parselist_data *parser;
  79. struct {
  80. curl_write_callback write_function;
  81. FILE *file_descriptor;
  82. } backup;
  83. };
  84. typedef enum {
  85. FTPFILE_MULTICWD = 1, /* as defined by RFC1738 */
  86. FTPFILE_NOCWD = 2, /* use SIZE / RETR / STOR on the full path */
  87. FTPFILE_SINGLECWD = 3 /* make one CWD, then SIZE / RETR / STOR on the file */
  88. } curl_ftpfile;
  89. typedef enum {
  90. FTPTRANSFER_BODY, /* yes do transfer a body */
  91. FTPTRANSFER_INFO, /* do still go through to get info/headers */
  92. FTPTRANSFER_NONE, /* don't get anything and don't get info */
  93. FTPTRANSFER_LAST /* end of list marker, never used */
  94. } curl_ftptransfer;
  95. /* This FTP struct is used in the SessionHandle. All FTP data that is
  96. connection-oriented must be in FTP_conn to properly deal with the fact that
  97. perhaps the SessionHandle is changed between the times the connection is
  98. used. */
  99. struct FTP {
  100. curl_off_t *bytecountp;
  101. char *user; /* user name string */
  102. char *passwd; /* password string */
  103. /* transfer a file/body or not, done as a typedefed enum just to make
  104. debuggers display the full symbol and not just the numerical value */
  105. curl_ftptransfer transfer;
  106. curl_off_t downloadsize;
  107. };
  108. /* ftp_conn is used for struct connection-oriented data in the connectdata
  109. struct */
  110. struct ftp_conn {
  111. struct pingpong pp;
  112. char *entrypath; /* the PWD reply when we logged on */
  113. char **dirs; /* realloc()ed array for path components */
  114. int dirdepth; /* number of entries used in the 'dirs' array */
  115. int diralloc; /* number of entries allocated for the 'dirs' array */
  116. char *file; /* decoded file */
  117. bool dont_check; /* Set to TRUE to prevent the final (post-transfer)
  118. file size and 226/250 status check. It should still
  119. read the line, just ignore the result. */
  120. bool ctl_valid; /* Tells Curl_ftp_quit() whether or not to do anything. If
  121. the connection has timed out or been closed, this
  122. should be FALSE when it gets to Curl_ftp_quit() */
  123. bool cwddone; /* if it has been determined that the proper CWD combo
  124. already has been done */
  125. bool cwdfail; /* set TRUE if a CWD command fails, as then we must prevent
  126. caching the current directory */
  127. char *prevpath; /* conn->path from the previous transfer */
  128. char transfertype; /* set by ftp_transfertype for use by Curl_client_write()a
  129. and others (A/I or zero) */
  130. int count1; /* general purpose counter for the state machine */
  131. int count2; /* general purpose counter for the state machine */
  132. int count3; /* general purpose counter for the state machine */
  133. ftpstate state; /* always use ftp.c:state() to change state! */
  134. char * server_os; /* The target server operating system. */
  135. curl_off_t known_filesize; /* file size is different from -1, if wildcard
  136. LIST parsing was done and wc_statemach set it */
  137. };
  138. #endif /* HEADER_CURL_FTP_H */