FtpSetCallback.html 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
  2. <html>
  3. <head>
  4. <title>FtpSetCallback</title>
  5. <link rel="stylesheet" type="text/css" href="doc.css">
  6. </head>
  7. <body>
  8. <h1>FtpSetCallback</h1>
  9. <p>Establishes a callback function.</p>
  10. <h2>SYNOPSIS</h2>
  11. <pre>
  12. #include &lt;ftplib.h&gt;
  13. int FtpCallback(FtpCallbackOptions *opt, netbuf *nControl);
  14. </pre>
  15. <p>FtpCallbackOptions is declared as follows.</p>
  16. <pre>
  17. typedef struct FtpCallbackOptions {
  18. FtpCallback cbFunc; /* function to call */
  19. void *cbArg; /* argument to pass to function */
  20. unsigned int bytesXferred; /* callback if this number of bytes transferred */
  21. unsigned int idleTime; /* callback if this many milliseconds have elapsed */
  22. } FtpCallbackOptions;
  23. </pre>
  24. <h2>PARAMETERS</h2>
  25. <dl>
  26. <dt><b>opt</b></dt>
  27. <dd>The address of a structure that contains a pointer to the callback
  28. function and the criteria for calling it.</dd>
  29. <dt><b>nControl</b></dt>
  30. <dd>A handle returned by <a href="FtpConnect.html">FtpConnect()</a>
  31. or <a href="FtpAccess.html">FtpAccess()</a>.</dd>
  32. </dl>
  33. <h2>DESCRIPTION</h2>
  34. <p>FtpSetCallback() establishes a callback functions and tells FTPlib
  35. when to call it. A data connection inherits the options assigned to
  36. the control connection it is created from. Callbacks are only called
  37. on file data connections.</p>
  38. <p>The fields in FtpCallbackStruct are described below.</p>
  39. <dl>
  40. <dt>cbFunc</dt>
  41. <dd>Specifies the address of a user callback routine.</dd>
  42. <dt>cbArg</dt>
  43. <dd>Specifies an argument to pass to the user's callback
  44. routine.</dd>
  45. <dt>idleTime</dt>
  46. <dd>Specifies the socket idle time in milliseconds that triggers
  47. calling the user's callback routine.</dd>
  48. <dt>bytesXferred</dt>
  49. <dd>Specifies the number of bytes to transfer between calls to the
  50. user's callback routine.</dd>
  51. </dl>
  52. <p>The user's callback routine is specified as:</p>
  53. <pre>
  54. typedef int (*FtpCallback)(netbuf *nControl, int xfered, void *arg);
  55. </pre>
  56. <b>nControl</b> is the data connection in use. <b>xfered</b> specifies
  57. how many bytes of data have been transferred on the
  58. connection. <b>arg</b> is the value passed in the FtpCallbackOptions
  59. field cbArg.
  60. <p>The user can request to be called back on either of two
  61. events.</p>
  62. <p>If the routine should be called when the data socket is idle for
  63. some period of time, pass the number of milliseconds of inactivity
  64. that should trigger a callback in the idleTime field.</p>
  65. <p>If the routine should be called when a certain amount of data has
  66. been transferred, specify a non-zero value in bytesXferred. This
  67. value represents the minimum number of bytes to transfer between
  68. callbacks. When using this option, ftplib keeps track of the number of
  69. bytes transferred and calls the user once the specified number of
  70. bytes or more has been transferred. It then resets the count to 0 and
  71. starts again.</p>
  72. <p>If the user wishes to continue the transfer, the callback
  73. routine should return true (non-zero). It can abort the transfer by
  74. return zero.</p>
  75. <h2>RETURN VALUE</h2>
  76. <p>Returns 1 for success or 0 for failure.</p>
  77. </body>
  78. </html>