📄 ftplib.html
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/ftpLib.html - generated by refgen from ftpLib.c --> <title> ftpLib </title></head><body bgcolor="#FFFFFF"> <hr><a name="top"></a><p align=right><a href="libIndex.htm"><i>VxWorks API Reference : OS Libraries</i></a></p></blockquote><h1>ftpLib</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>ftpLib</strong> - File Transfer Protocol (FTP) library </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><a href="./ftpLib.html#ftpCommand">ftpCommand</a>( )</b> - send an FTP command and get the reply <br><b><a href="./ftpLib.html#ftpCommandEnhanced">ftpCommandEnhanced</a>( )</b> - send an FTP command and get the complete RFC reply code<br><b><a href="./ftpLib.html#ftpXfer">ftpXfer</a>( )</b> - initiate a transfer via FTP<br><b><a href="./ftpLib.html#ftpReplyGet">ftpReplyGet</a>( )</b> - get an FTP command reply<br><b><a href="./ftpLib.html#ftpReplyGetEnhanced">ftpReplyGetEnhanced</a>( )</b> - get an FTP command reply<br><b><a href="./ftpLib.html#ftpHookup">ftpHookup</a>( )</b> - get a control connection to the FTP server on a specified host<br><b><a href="./ftpLib.html#ftpLogin">ftpLogin</a>( )</b> - log in to a remote FTP server<br><b><a href="./ftpLib.html#ftpDataConnInitPassiveMode">ftpDataConnInitPassiveMode</a>( )</b> - initialize an FTP data connection using PASV mode<br><b><a href="./ftpLib.html#ftpDataConnInit">ftpDataConnInit</a>( )</b> - initialize an FTP data connection using PORT mode<br><b><a href="./ftpLib.html#ftpDataConnGet">ftpDataConnGet</a>( )</b> - get a completed FTP data connection<br><b><a href="./ftpLib.html#ftpLs">ftpLs</a>( )</b> - list directory contents via FTP<br><b><a href="./ftpLib.html#ftpLibDebugOptionSet">ftpLibDebugOptionSet</a>( )</b> - set the debug level of the ftp library routines<br><b><a href="./ftpLib.html#ftpTransientConfigSet">ftpTransientConfigSet</a>( )</b> - set parameters for host <b>FTP_TRANSIENT</b> responses <br><b><a href="./ftpLib.html#ftpTransientConfigGet">ftpTransientConfigGet</a>( )</b> - get parameters for host <b>FTP_TRANSIENT</b> responses <br><b><a href="./ftpLib.html#ftpTransientFatalInstall">ftpTransientFatalInstall</a>( )</b> - set applette to stop FTP transient host responses<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>This library provides facilities for transferring files to and from a hostvia File Transfer Protocol (FTP). This library implements only the"client" side of the FTP facilities.<p></blockquote><h4>FTP IN VXWORKS</h4><blockquote><p>For most purposes, you should access the services of <b><a href="./ftpLib.html#top">ftpLib</a></b> by means of <b><a href="./netDrv.html#top">netDrv</a></b>, a VxWorks I/O driver that supports transparent access to remote files by means of standard I/O system calls. Before attempting to access <b><a href="./ftpLib.html#top">ftpLib</a></b> services directly, you should check whether <b><a href="./netDrv.html#top">netDrv</a></b> already provides the same access for less trouble.<p></blockquote><h4>HIGH-LEVEL INTERFACE</h4><blockquote><p>The routines <b><a href="./ftpLib.html#ftpXfer">ftpXfer</a>( )</b> and <b><a href="./ftpLib.html#ftpReplyGet">ftpReplyGet</a>( )</b> provide the highest level ofdirect interface to FTP. The routine <b><a href="./ftpLib.html#ftpXfer">ftpXfer</a>( )</b> connects to a specifiedremote FTP server, logs in under a specified user name, and initiates aspecified data transfer command. The routine <b><a href="./ftpLib.html#ftpReplyGet">ftpReplyGet</a>( )</b> receivescontrol reply messages sent by the remote FTP server in response to thecommands sent.<p></blockquote><h4>LOW-LEVEL INTERFACE</h4><blockquote><p>The routines <b><a href="./ftpLib.html#ftpHookup">ftpHookup</a>( )</b>, <b><a href="./ftpLib.html#ftpLogin">ftpLogin</a>( )</b>, <b><a href="./ftpLib.html#ftpDataConnInit">ftpDataConnInit</a>( )</b>, <b><a href="./ftpLib.html#ftpDataConnGet">ftpDataConnGet</a>( )</b>,<b><a href="./ftpLib.html#ftpCommand">ftpCommand</a>( )</b>, <b><a href="./ftpLib.html#ftpCommandEnhanced">ftpCommandEnhanced</a>( )</b> provide the primitives necessary to create and use control and data connections to remote FTP servers. The following example shows how to use these low-level routines. It implements roughly the same function as <b><a href="./ftpLib.html#ftpXfer">ftpXfer</a>( )</b>.<p><pre>char *host, *user, *passwd, *acct, *dirname, *filename;int ctrlSock = ERROR; /* This is the control socket file descriptor */int dataSock = ERROR; /* This is the data path socket file descriptor */if (((ctrlSock = ftpHookup (host)) == ERROR) || (ftpLogin (ctrlSock, user, passwd, acct) == ERROR) || (ftpCommand (ctrlSock, "TYPE I", 0, 0, 0, 0, 0, 0) != FTP_COMPLETE) || (ftpCommand (ctrlSock, "CWD %s", dirname, 0, 0, 0, 0, 0) != FTP_COMPLETE) || ((dataSock = ftpDataConnInit (ctrlSock)) == ERROR) || (ftpCommand (ctrlSock, "RETR %s", filename, 0, 0, 0, 0, 0) != FTP_PRELIM) || ((dataSock = ftpDataConnGet (dataSock)) == ERROR)) { /* an error occurred; close any open sockets and return */ if (ctrlSock != ERROR) close (ctrlSock); if (dataSock != ERROR) close (dataSock); return (ERROR); }</pre>For even lower-level access, please note that the sockets provided by <b><a href="./ftpLib.html#ftpHookup">ftpHookup</a>( )</b> and <b><a href="./ftpLib.html#ftpDataConnInit">ftpDataConnInit</a>( )</b> are standard TCP/IP sockets. Developers may implement <b><a href="./ioLib.html#read">read</a>( )</b>, <b><a href="./ioLib.html#write">write</a>( )</b> and <b><a href="./selectLib.html#select">select</a>( )</b> calls using these sockets for maximum flexibility.<p>To use this feature, include the following component:<b>INCLUDE_FTP</b><p></blockquote><h4>TUNING FOR MULTIPLE FILE ACCESS</h4><blockquote><p><p>Please note that accessing multiple files simultaneously may require increasing the memory available to the network stack. You can examine memory requirements by using <b><a href="./netShow.html#netStackSysPoolShow">netStackSysPoolShow</a>( )</b> and <b><a href="./netShow.html#netStackDataPoolShow">netStackDataPoolShow</a>( )</b>before opening and after closing files.<p>You may need to modify the following macro definitions according to your specific memory requirements:<p> <b>NUM_64</b><br> <b>NUM_128</b><br> <b>NUM_256</b><br> <b>NUM_512</b><br> <b>NUM_1024</b><br> <b>NUM_2048</b><br> <b>NUM_SYS_64</b><br> <b>NUM_SYS_128</b><br> <b>NUM_SYS_256</b><br> <b>NUM_SYS_512</b><br> <b>NUM_SYS_1024</b><br> <b>NUM_SYS_2048</b><p>Please also note that each concurrent file access requires three file descriptors (File, Control and Socket). The following macro definition may need modification per your application:<b>NUM_FILES</b><p>Developers are encouraged to enable the error reporting facility during debugging using the function <b>ftpLibDebugOptionsSet( )</b>. The output is displayed via the logging facility.<p></blockquote><h4>INCLUDE FILES</h4><blockquote><p><b>ftpLib.h</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./netDrv.html#top">netDrv</a></b>, <b><a href="./logLib.html#top">logLib</a></b><hr><a name="ftpCommand"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>ftpCommand( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>ftpCommand( )</strong> - send an FTP command and get the reply </p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int ftpCommand ( int ctrlSock, /* fd of control connection socket */ char * fmt, /* format string of command to send */ int arg1, /* first of six args to format string */ int arg2, int arg3, int arg4, int arg5, int arg6 )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This command has been superceded by <b><a href="./ftpLib.html#ftpCommandEnhanced">ftpCommandEnhanced</a>( )</b> <p>This routine sends the specified command on the specified socket, whichshould be a control connection to a remote FTP server.The command is specified as a string in <b><a href="./fioLib.html#printf">printf</a>( )</b> format with upto six arguments.<p>After the command is sent, <b><a href="./ftpLib.html#ftpCommand">ftpCommand</a>( )</b> waits for the reply from theremote server. The FTP reply code is returned in the same way as in<b><a href="./ftpLib.html#ftpReplyGet">ftpReplyGet</a>( )</b>.<p></blockquote><h4>EXAMPLE</h4><blockquote><p><pre>ftpCommand (ctrlSock, "TYPE I", 0, 0, 0, 0, 0, 0); /* image-type xfer */ftpCommand (ctrlSock, "STOR %s", file, 0, 0, 0, 0, 0); /* init file write */</pre></blockquote><h4>RETURNS</h4><blockquote><p><p><br> 1 = <b>FTP_PRELIM</b> (positive preliminary)<br> 2 = <b>FTP_COMPLETE</b> (positive completion)<br> 3 = <b>FTP_CONTINUE</b> (positive intermediate)<br> 4 = <b>FTP_TRANSIENT</b> (transient negative completion)<br> 5 = <b>FTP_ERROR</b> (permanent negative completion)<p>ERROR if there is a read/write error or an unexpected EOF.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./ftpLib.html#top">ftpLib</a></b>, <b><a href="./ftpLib.html#ftpReplyGet">ftpReplyGet</a>( )</b><p>VARARGS2<hr><a name="ftpCommandEnhanced"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>ftpCommandEnhanced( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>ftpCommandEnhanced( )</strong> - send an FTP command and get the complete RFC reply code</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int ftpCommandEnhanced ( int ctrlSock, /* fd of control connection socket */ char * fmt, /* format string of command to send */ int arg1, /* first of six args to format string */ int arg2, int arg3, int arg4, int arg5, int arg6, char * replyString, /* storage for the last line of the server */ /* response or NULL */ int replyStringLength /* Maximum character length of the replyString */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This command supercedes <b><a href="./ftpLib.html#ftpCommand">ftpCommand</a>( )</b> <p>This routine sends the specified command on the specified socket, whichshould be a control connection to a remote FTP server.The command is specified as a string in <b><a href="./fioLib.html#printf">printf</a>( )</b> format with upto six arguments.<p>After the command is sent, <b><a href="./ftpLib.html#ftpCommand">ftpCommand</a>( )</b> waits for the reply from theremote server. The FTP reply code is returned in the same way as in<b><a href="./ftpLib.html#ftpReplyGetEnhanced">ftpReplyGetEnhanced</a>( )</b>.<p></blockquote><h4>EXAMPLE</h4><blockquote><p><pre>ftpCommandEnhanced (ctrlSock, "TYPE I", 0, 0, 0, 0, 0, 0, 0, 0); /* image-type xfer */ftpCommandEnhanced (ctrlSock, "STOR %s", file, 0, 0, 0, 0, 0, 0, 0); /* init file write */ftpCommandEnhanced (ctrlSock, "PASV", file, 0, 0, 0, 0, 0, reply, rplyLen); /* Get port */</pre></blockquote><h4>RETURNS</h4><blockquote><p><p> The complete FTP response code (see RFC #959)<p>ERROR if there is a read/write error or an unexpected EOF.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./ftpLib.html#top">ftpLib</a></b>, <b><a href="./ftpLib.html#ftpReplyGetEnhanced">ftpReplyGetEnhanced</a>( )</b>, <b><a href="./ftpLib.html#ftpReplyGet">ftpReplyGet</a>( )</b><p>VARARGS2<hr><a name="ftpXfer"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>ftpXfer( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>ftpXfer( )</strong> - initiate a transfer via FTP</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS ftpXfer ( char * host, /* name of server host */ char * user, /* user name for host login */ char * passwd, /* password for host login */ char * acct, /* account for host login */ char * cmd, /* command to send to host */ char * dirname, /* directory to <b>cd</b> to before sending command */ char * filename, /* filename to send with command */ int * pCtrlSock, /* where to return control socket fd */ int * pDataSock /* where to return data socket fd, (NULL == */ /* don't open data connection) */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -