📄 ftplib.html
字号:
This routine initiates a transfer via a remote FTP serverin the following order:<table></tr><tr valign=top><td>(1)<td>Establishes a connection to the FTP server on the specified host.</tr><tr valign=top><td>(2)<td>Logs in with the specified user name, password, and account,as necessary for the particular host.</tr><tr valign=top><td>(3)<td>Sets the transfer type to image by sending the command "TYPE I".</tr><tr valign=top><td>(4)<td>Changes to the specified directory by sendingthe command "CWD <i>dirname</i>".</tr><tr valign=top><td>(5)<td>Sends the specified transfer commandwith the specified filename as an argument, and establishes a data connection.Typical transfer commands are "STOR %s", to write to a remote file,or "RETR %s", to read a remote file.</table>The resulting control and data connection file descriptors are returnedvia <i>pCtrlSock</i> and <i>pDataSock</i>, respectively.<p>After calling this routine, the data can be read or written to the remoteserver by reading or writing on the file descriptor returned in<i>pDataSock</i>. When all incoming data has been read (as indicated by an EOF when reading the data socket) and/or all outgoing data has beenwritten, the data socket fd should be closed. The routine <b><a href="./ftpLib.html#ftpReplyGet">ftpReplyGet</a>( )</b>should then be called to receive the final reply on the control socket,after which the control socket should be closed.<p>If the FTP command does not involve data transfer, <i>pDataSock</i> should be NULL, in which case no data connection will be established. The only FTP commands supported for this case are DELE, RMD, and MKD.<p></blockquote><h4>EXAMPLE</h4><blockquote><p>The following code fragment reads the file "/usr/fred/myfile" from thehost "server", logged in as user "fred", with password "magic"and no account name.<p><pre> #include "vxWorks.h" #include "ftpLib.h" int ctrlSock; int dataSock; char buf [512]; int nBytes; STATUS status; if (ftpXfer ("server", "fred", "magic", "", "RETR %s", "/usr/fred", "myfile", &ctrlSock, &dataSock) == ERROR) return (ERROR); while ((nBytes = read (dataSock, buf, sizeof (buf))) > 0) { ... } close (dataSock); if (nBytes < 0) /* read error? */ status = ERROR; if (ftpReplyGet (ctrlSock, TRUE) != FTP_COMPLETE) status = ERROR; if (ftpCommand (ctrlSock, "QUIT", 0, 0, 0, 0, 0, 0) != FTP_COMPLETE) status = ERROR; close (ctrlSock);</pre></blockquote><h4>RETURNS</h4><blockquote><p><p>OK, or ERROR if any socket cannot be created or if a connection cannot bemade.<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><hr><a name="ftpReplyGet"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>ftpReplyGet( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>ftpReplyGet( )</strong> - get an FTP command reply</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int ftpReplyGet ( int ctrlSock, /* control socket fd of FTP connection */ BOOL expecteof /* TRUE = EOF expected, FALSE = EOF is error */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine has been superceded by <b><a href="./ftpLib.html#ftpReplyGetEnhanced">ftpReplyGetEnhanced</a>( )</b><p>This routine gets a command reply on the specified control socket.<p>The three-digit reply code from the first line is saved and interpreted.The left-most digit of the reply code identifies the type of code(see RETURNS below).<p>The caller's error status is always set to the complete three-digit reply coderegardless of the actual reply value (see the manual entry for <b><a href="./errnoLib.html#errnoGet">errnoGet</a>( )</b>).If the reply code indicates an error, the entire replyis printed if the ftp error printing is enabled (see the manualentry for <b>ftpLibDebugOptionsSet( )</b>).<p>If an EOF is encountered on the specified control socket, but no EOF wasexpected (<i>expecteof</i> == FALSE), then ERROR is returned.<p></blockquote><h4>RETURNS</h4><blockquote><p><p> 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.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./ftpLib.html#top">ftpLib</a></b><hr><a name="ftpReplyGetEnhanced"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>ftpReplyGetEnhanced( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>ftpReplyGetEnhanced( )</strong> - get an FTP command reply</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int ftpReplyGetEnhanced ( int ctrlSock, /* control socket fd of FTP connection */ BOOL expecteof, /* TRUE = EOF expected, FALSE = EOF is error */ char * replyString, /* Location to store text of reply, or NULL */ int stringLengthMax /* Maximum length of reply (not including NULL) */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine supercedes <b><a href="./ftpLib.html#ftpReplyGet">ftpReplyGet</a>( )</b><p>This routine gets a command reply on the specified control socket.<p>The three-digit reply code from the first line is saved and interpreted.The left-most digit of the reply code identifies the type of code(see RETURNS below).<p>The caller's error status is always set to the complete three-digit reply code(see the manual entry for <b><a href="./errnoLib.html#errnoGet">errnoGet</a>( )</b>).If the reply code indicates an error, the entire replyis printed if the ftp error printing is enabled (see the manualentry for <b>ftpLibDebugOptionsSet( )</b>).<p>The last line of text retrieved from the servers response is stored<br> in the location specified by replyString. If replyString is NULL<br> the parameter is ignored.<p>If an EOF is encountered on the specified control socket, but no EOF wasexpected (<i>expecteof</i> == FALSE), then ERROR is returned.<p></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.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./ftpLib.html#top">ftpLib</a></b><hr><a name="ftpHookup"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>ftpHookup( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>ftpHookup( )</strong> - get a control connection to the FTP server on a specified host</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int ftpHookup ( char * host /* server host name or inet address */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine establishes a control connection to the FTP server on thespecified host. This is the first step in interacting with a remote FTPserver at the lowest level. (For a higher-level interaction with a remoteFTP server, see the manual entry for <b><a href="./ftpLib.html#ftpXfer">ftpXfer</a>( )</b>.)<p></blockquote><h4>RETURNS</h4><blockquote><p><p>The file descriptor of the control socket, or ERROR if the Internetaddress or the host name is invalid, if a socket could not be created, orif a connection could not be made.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./ftpLib.html#top">ftpLib</a></b>, <b><a href="./ftpLib.html#ftpLogin">ftpLogin</a>( )</b>, <b><a href="./ftpLib.html#ftpXfer">ftpXfer</a>( )</b><hr><a name="ftpLogin"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>ftpLogin( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>ftpLogin( )</strong> - log in to a remote FTP server</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS ftpLogin ( int ctrlSock, /* fd of login control socket */ char * user, /* user name for host login */ char * passwd, /* password for host login */ char * account /* account for host login */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine logs in to a remote server with the specified user name,password, and account name, as required by the specific remote host. Thisis typically the next step after calling <b><a href="./ftpLib.html#ftpHookup">ftpHookup</a>( )</b> in interacting with aremote FTP server at the lowest level. (For a higher-level interactionwith a remote FTP server, see the manual entry for <b><a href="./ftpLib.html#ftpXfer">ftpXfer</a>( )</b>).<p></blockquote><h4>RETURNS</h4><blockquote><p><p>OK, or ERROR if the routine is unable to log in.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./ftpLib.html#top">ftpLib</a></b>, <b><a href="./ftpLib.html#ftpHookup">ftpHookup</a>( )</b>, <b><a href="./ftpLib.html#ftpXfer">ftpXfer</a>( )</b><hr><a name="ftpDataConnInitPassiveMode"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>ftpDataConnInitPassiveMode( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>ftpDataConnInitPassiveMode( )</strong> - initialize an FTP data connection using PASV mode</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int ftpDataConnInitPassiveMode ( int ctrlSock /* fd of associated control socket */ )</pre>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -