?? 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.html"><i>VxWorks Reference Manual : 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><i><a href="./ftpLib.html#ftpCommand">ftpCommand</a></i>( )</b> - send an FTP command and get the reply<br><b><i><a href="./ftpLib.html#ftpXfer">ftpXfer</a></i>( )</b> - initiate a transfer via FTP<br><b><i><a href="./ftpLib.html#ftpReplyGet">ftpReplyGet</a></i>( )</b> - get an FTP command reply<br><b><i><a href="./ftpLib.html#ftpHookup">ftpHookup</a></i>( )</b> - get a control connection to the FTP server on a specified host<br><b><i><a href="./ftpLib.html#ftpLogin">ftpLogin</a></i>( )</b> - log in to a remote FTP server<br><b><i><a href="./ftpLib.html#ftpDataConnInit">ftpDataConnInit</a></i>( )</b> - initialize an FTP data connection<br><b><i><a href="./ftpLib.html#ftpDataConnGet">ftpDataConnGet</a></i>( )</b> - get a completed FTP data connection<br><b><i><a href="./ftpLib.html#ftpLs">ftpLs</a></i>( )</b> - list directory contents via FTP<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>VxWorks provides an I/O driver, <b><a href="./netDrv.html#top">netDrv</a></b>, that allows transparent access toremote files via standard I/O system calls. The FTP facilities of <b><a href="./ftpLib.html#top">ftpLib</a></b>are primarily used by <b><a href="./netDrv.html#top">netDrv</a></b> to access remote files. Thus for mostpurposes, it is not necessary to be familiar with ftpLib.<p></blockquote><h4>HIGH-LEVEL INTERFACE</h4><blockquote><p>The routines <b><i><a href="./ftpLib.html#ftpXfer">ftpXfer</a></i>( )</b> and <b><i><a href="./ftpLib.html#ftpReplyGet">ftpReplyGet</a></i>( )</b> provide the highest level ofdirect interface to FTP. The routine <b><i><a href="./ftpLib.html#ftpXfer">ftpXfer</a></i>( )</b> connects to a specifiedremote FTP server, logs in under a specified user name, and initiates aspecified data transfer command. The routine <b><i><a href="./ftpLib.html#ftpReplyGet">ftpReplyGet</a></i>( )</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><i><a href="./ftpLib.html#ftpHookup">ftpHookup</a></i>( )</b>, <b><i><a href="./ftpLib.html#ftpLogin">ftpLogin</a></i>( )</b>, <b><i><a href="./ftpLib.html#ftpDataConnInit">ftpDataConnInit</a></i>( )</b>, <b><i><a href="./ftpLib.html#ftpDataConnGet">ftpDataConnGet</a></i>( )</b>,and <b><i><a href="./ftpLib.html#ftpCommand">ftpCommand</a></i>( )</b> provide the primitives necessary to create and usecontrol and data connections to remote FTP servers. The following exampleshows how to use these low-level routines. It implements roughly the samefunction as <b><i><a href="./ftpLib.html#ftpXfer">ftpXfer</a></i>( )</b>.<p><pre>char *host, *user, *passwd, *acct, *dirname, *filename;int ctrlSock = ERROR;int dataSock = ERROR;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></blockquote><h4>INCLUDE FILES</h4><blockquote><p><b>ftpLib.h</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./ftpLib.html#top">ftpLib</a></b>, <b><a href="./netDrv.html#top">netDrv</a></b><hr><a name="ftpCommand"></a><p align=right><a href="rtnIndex.html"><i>Libraries : Routines</i></a></p></blockquote><h1><i>ftpCommand</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>ftpCommand</i>( )</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 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><i><a href="./fioLib.html#printf">printf</a></i>( )</b> format with upto six arguments.<p>After the command is sent, <b><i><a href="./ftpLib.html#ftpCommand">ftpCommand</a></i>( )</b> waits for the reply from theremote server. The FTP reply code is returned in the same way as in<b><i><a href="./ftpLib.html#ftpReplyGet">ftpReplyGet</a></i>( )</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> 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><i><a href="./ftpLib.html#ftpReplyGet">ftpReplyGet</a></i>( )</b><p>VARARGS2<hr><a name="ftpXfer"></a><p align=right><a href="rtnIndex.html"><i>Libraries : Routines</i></a></p></blockquote><h1><i>ftpXfer</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>ftpXfer</i>( )</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 */ /* connection) */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine initiates a transfer via a remote FTP serverin the following order:<dl><dt>(1)<dd>Establishes a connection to the FTP server on the specified host.<p><dt>(2)<dd>Logs in with the specified user name, password, and account,as necessary for the particular host.<p><dt>(3)<dd>Sets the transfer type to image by sending the command "TYPE I".<p><dt>(4)<dd>Changes to the specified directory by sendingthe command "CWD <i>dirname</i>".<p><dt>(5)<dd> 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. </dl><p>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><i><a href="./ftpLib.html#ftpReplyGet">ftpReplyGet</a></i>( )</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) { ... }
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -